I am using phppowerpoint to generate ppt files. I want to change default line height between lines in PPT.
here is bit of code I am using to generate ppt.
$shape->createParagraph()->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT)->setVertical(PHPPowerPoint_Style_Alignment::VERTICAL_TOP);
$textRun = $shape->createTextRun($ppt_build[$i][$k]['text'][$j]['textrun']);
$textRun->getFont()->setBold($ppt_build[$i][$k]['text'][$j]['bold']);
$textRun->getFont()->setSize($ppt_build[$i][$k]['text'][$j]['size']); //setName
$textRun->getFont()->setName($ppt_build[$i][$k]['text'][$j]['name']); //setName
$textRun->getFont()->setColor(new PHPPowerPoint_Style_Color($ppt_build[$i][$k]['text'][$j]['color']));
then creating a line break
$shape->createBreak();
I tried using giving 2 line breaks but it is more than I need.
I also tried solution mentioned here
http://phppowerpoint.codeplex.com/discussions/273396
But with that solution it adds space only before and after the paragraph.
is there any cheat sheet or list that contains xml nodes/elements/names used in xml files generated for powerpoint
follow below steps to achieve this
Inside
/* /powerpoint/PHPPowerPoint/Shape/RichText/Paragraph.php */
private $_spacing;
also
/**
* Get spacing
*
* #return PHPPowerPoint_Style_Spacing
*/
public function getSpacing() {
return $this->_spacing;
}
/**
* Set spacing
*
* #param PHPPowerPoint_Style_Spacing $spacing
* #throws Exception
* #return PHPPowerPoint_Shape_RichText_Paragraph
*/
public function setSpacing($spacing = '100000') {
$this->_spacing = $spacing;
return $this;
}
Then inside /PHPPowerPoint/Writer/PowerPoint2007/Slide.php
private function _writeParagraphs(PHPPowerPoint_Shared_XMLWriter $objWriter, $paragraphs) {
after
$objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel());
add
if ($paragraph->getSpacing()) {
$objWriter->startElement('a:lnSpc');
$objWriter->startElement('a:spcPct');
$objWriter->writeAttribute('val', $paragraph->getSpacing());
$objWriter->endElement();
$objWriter->endElement();
}
Related
I have a document with an index defined.
/** #ODM\Document */
class Stat
{
/** #ODM\Id(strategy="NONE", type="int") */
private $id;
/** #ODM\Field(type="string") */
private $period;
/** #ODM\ReferenceOne(targetDocument="Player") */
private $player;
/** #ODM\Field(type="string") #ODM\Index */
private $statType;
However, when I look at the indexes created in the collection, the only index is the _id.
To save the document I'm doing:
$stat = new Documents\Stat();
$stat->setId(1);
$stat->setPlayer($player);
$stat->setPeriod(1);
$stat->setStatType('goal');
$dm->persist($stat);
$dm->flush();
Is there something else I'm not doing?
Indexes are not created (nor ensured if they're in sync with mapping) during normal ODM usage.
If you're using Symfony then solving problem is easy, just run doctrine:mongodb:schema:create command from Symfony's console (and if you're using other framework, look for equivalent as command itself is provided by ODM).
If you want to control indexes from your code you can use SchemaManager which provides an API to control "schema" directly (you can also control indexes on per-document basis). Obtaining it is easy: $sm = $dm->getSchemaManager();.
// AppBundle/Document
namespace AppBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
/**
* #MongoDB\Document(repositoryClass="AppBundle\Repository\ProduitRepository")
* #MongoDBUnique(fields="$noProduit")
*/
class Produit
{
/**
* #MongoDB\Id
*/
protected $id;
/**
* #MongoDB\String
* #MongoDB\UniqueIndex(order="asc")
*/
protected $noProduit;
/**
* #MongoDB\Field(type="string")
*/
protected $libelle;
// getter and setter
}
// AppBundle/Controller
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->getSchemaManager()->ensureIndexes();
schema and database will be created automatically when you run your app.
For more info
visit this link
/**
* #ODM\Document
* #ODM\Indexes({
* #ODM\Index(keys={"statType"="asc"}),
* #ODM\UniqueIndex(keys={"period"="asc"})//For example unique index
* })
*/
class Stat
{
}
Then if you use symfony run php bin/console doctrine:mongodb:schema:create
I have the following peoplecode to open a link in new window using new window logic in peoplecode. The following peoplecode and java functions does the job perfectly until a new window is tried to open from an already existing new window which causes the regular expresssion to add one more _newwin which is wrong.
Code
Function FgNewWinUrl(&strUrl As string) Returns string;
Local string &sRegex, &sReplace, &Result;
/* Declare java object */
Local JavaObject &jUrl;
/**
* Peoplesoft Content types:
* -------------------------
* Component: c
* Script: s
* External: e
* Homepage: h
* Template: t
* Query: q
* Worklist: w
* Navigation: n
* File: f
**/
/* Regex strings */
/* psc/psp Site Portal Node Content Type */
rem &sRegex = "/(ps[cp])/([^\/]*)?/([^\/]*)?/([^\/]*)?/([csehtqwnf]{1})/";
&sRegex = "/(ps[cp])/([^\/]*)?/([^\/]*)?/([^\/]*)?/([csehtqwnf]{1})/";
rem ^[^_]+(?=_);
&sReplace = "/$1/$2_newwin/$3/$4/$5/";
/* Instantiate objects and replace */
&jUrl = CreateJavaObject("java.lang.String", &strUrl);
&Result = &jUrl.replaceAll(&sRegex, &sReplace);
/* Return modified URL */
Return &Result;
End-Function;
Here is my question:
I found a regex to find everything before an underscore. I want to apply that to the second group of the result from regex.
Please let me know how I can do that.
Try this
&sRegex = "/(ps[cp])/([^\/_]*)?(?:_newwin)?/([^\/]*)?/([^\/]*)?/([csehtqwnf]{1})/";
This adds an optional _newwin that is not inclueded in the group count.
If you have to support underscores in the second match we need to rely on greediness…
I have created the a test for a controller using Cake bake command.
Now, I want to test the function "index" of the controller and for it I do this:
public function testIndex() {
echo "printed";
$result = $this->testAction("/comments/1");
echo "not printed";
}
1 is the param, the id of the post where the comment is. Anyway, the controller works perfectly well, there's no problem with it.
As you can see, the test crashes after calling the testAction method. (it doesn't print the second echo)
I have seen that if the action called on the controller has any call to its model, testAction call won't work. But, if the action to test doesn't have any call to any Model, then, it works perfectly.
Whats happening here?
By the way, both databases, default and test has data in it so it's not either a problem with the database.
Thanks.
UPDATE:
here you have the rest of the testController generated by Cake bake command:
<?php
/* Comments Test cases generated on: 2012-04-12 11:49:17 : 1334224157*/
App::uses('CommentsController', 'Controller');
/**
* TestCommentsController *
*/
class TestCommentsController extends CommentsController {
/**
* Auto render
*
* #var boolean
*/
public $autoRender = false;
/**
* Redirect action
*
* #param mixed $url
* #param mixed $status
* #param boolean $exit
* #return void
*/
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
/**
* CommentsController Test Case
*
*/
class CommentsControllerTestCase extends CakeTestCase {
/**
* Fixtures
*
* #var array
*/
public $fixtures = array('app.comment');
/**
* setUp method
*
* #return void
*/
public function setUp() {
parent::setUp();
$this->Comments = new TestCommentsController();
$this->Comments->constructClasses();
}
/**
* tearDown method
*
* #return void
*/
public function tearDown() {
unset($this->Comments);
parent::tearDown();
}
When you're testing controllers, make sure to extend the test case class by ControllerTestCase to take advantage of the testAction() method.
I have the following code, which retrieves the page slugs from the database which are needed to then create a related sub page:
$builder->add('subtocontentoptions', 'entity', array(
'class' => 'ShoutAdminBundle:Content',
'property' => 'slug',
'query_builder' => function($repository) {
return $repository->createQueryBuilder('p')
->where('p.mainpage = :main')
->setParameter('main', '1')
->orderBy('p.created', 'ASC');
}
));
The code works, as it displays a drop down menu of all the parent pages I have. However, when I go to save the data to the database, I am given the following error:
ErrorException: Catchable Fatal Error: Object of class
Shout\AdminBundle\Entity\Content could not be converted to string in
C:\wamp\www\vendor\doctrine-dbal\lib\Doctrine\DBAL\Statement.php line
131
I have checked the contents of the Content entity file, and here is the variable being declared:
/**
* #var integer $subtocontentoptions
*
* #ORM\Column(name="SubToContentOptions", type="integer", nullable=false)
*/
private $subtocontentoptions;
And lower down the Content entity file:
/**
* Set subtocontentoptions
*
* #param integer $subtocontentoptions
*/
public function setSubtocontentoptions($subtocontentoptions)
{
$this->subtocontentoptions = $subtocontentoptions;
}
/**
* Get subtocontentoptions
*
* #return integer
*/
public function getSubtocontentoptions()
{
return $this->subtocontentoptions;
}
The rest of the code does work, once this drop down has been taken out. I'm not sure why the drop down is causing this error?
Thanks
Was having the same issue with a sf2/doctrine2 project, implementing the __toString method resolved this issue for me :
public function __toString()
{
return strval($this->id);
}
I have tow entities Slaplans and Slaholidays and a join table slaplans_slaholidays.
After creating two Slaholidays objects, I persist them both, add them to the Slaplans and flush. The problem is that only the slaplans and slaholidays tables are updated, but the join table isn't.
Slaplans Entity :
<?php
namespace ZC\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Slaplans
*
* #Table(name="slaplans")
* #Entity(repositoryClass="Repositories\Slaplans")
*/
class Slaplans
{
/*
* #ManyToMany(targetEntity="Slaholidays",inversedBy="plans", cascade={"ALL"})
* #JoinTable(name="slaplans_slaholidays",
* joinColumns={#JoinColumn(name="slaplanid" ,referencedColumnName="slaplanid")},
* inverseJoinColumns={#JoinColumn(name="slaholidayid" ,referencedColumnName="slaholidayid")})
* }
*/
private $holidays;
public function __construct()
{
$this->holidays = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getHolidays() {
return $this->holidays;
}
public function setHolidays($holidays)
{
$this->holidays=$holidays;
}
/*public function addHoliday($holiday) {
$this->holidays[]=$holiday;
}*/
}
Slaholidays Entity:
<?php
namespace ZC\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Slaholidays
*
* #Table(name="slaholidays")
* #Entity(repositoryClass="Repositories\Slaholidays")
*/
class Slaholidays
{
/**
* #var integer $slaholidayid
*
* #Column(name="slaholidayid", type="integer", nullable=false)
* #Id
* #GeneratedValue(strategy="IDENTITY")
*/
private $slaholidayid;
/*
* #ManyToMany(targetEntity="Slaplans",mappedBy="holidays", cascade={"ALL"})
*/
private $plans;
/*public function getPlans(){
return $this->plans;
}*/
}
Code to persist the entities:
$allholidays=array();
$holiday=$this->_em->getRepository('ZC\Entity\Slaholidays')->find($value);
$holiday=new ZC\Entity\Slaholidays();
//..sets holiday fields here
$this->_em->persist($holiday);
$allholidays[]=$holiday;
$slaplan->setHolidays($allholidays);
foreach ($slaplan->getHolidays() as $value) {
$this->_em->persist($value);
}
$this->_em->persist($slaplan);
$this->_em->flush();
The are two issues in your code:
The first one: you are persisting each Slaholiday twice: first with
$this->_em->persist($holiday);
and second with
foreach ($slaplan->getHolidays() as $value) {
$this->_em->persist($value);
}
There is no problem actually, as they are not actually persisted in the db until flush are called, but anyway, you don't need that foreach.
The reason why your join table is not updated is in $slaplan->setHolidays method. You are initializing $slaplan->holidays with ArrayCollection (which is right) and in setHolidays you set it to the input parameter (which is $allholidays Array, and this is not right).
So, the correct way to do that is to use add method of the ArrayCollection
public function setHolidays($holidays)
{
//$this->holidays->clear(); //clears the collection, uncomment if you need it
foreach ($holidays as $holiday){
$this->holidays->add($holiday);
}
}
OR
public function addHolidays(ZC\Entity\Slaholiday $holiday)
{
$this->holidays->add($holiday);
}
public function clearHolidays(){
$this->holidays->clear();
}
//..and in the working script...//
//..the rest of the script
$this->_em->persist($holiday);
//$slaplan->clearHolidays(); //uncomment if you need your collection cleaned
$slaplan->addHOliday($holiday);
Although Doctrine checks the owning side of an association for things that need to be persisted, it's always important to keep both sides of the association in sync.
My advise is to have get, add and remove (no set) methods at both sides, that look like this:
class Slaplans
{
public function getHolidays()
{
return $this->holidays->toArray();
}
public function addHoliday(Slaholiday $holiday)
{
if (!$this->holidays->contains($holiday)) {
$this->holidays->add($holiday);
$holiday->addPlan($this);
}
return $this;
}
public function removeHoliday(Slaholiday $holiday)
{
if ($this->holidays->contains($holiday)) {
$this->holidays->removeElement($holiday);
$holiday->removePlan($this);
}
return $this;
}
}
Do the same in Slaplan.
Now when you add a Slaholiday to a Slaplan, that Slaplan will also be added to the Slaholiday automatically. The same goes for removing.
So now you can do something like this:
$plan = $em->find('Slaplan', 1);
$holiday = new Slaholiday();
// set data on $holiday
// no need to persist $holiday, because you have a cascade={"ALL"} all on the association
$plan->addHoliday($holiday);
// no need to persist $plan, because it's managed by the entitymanager (unless you don't use change tracking policy "DEFERRED_IMPLICIT" (which is used by default))
$em->flush();
PS: Don't use cascade on both sides of the association. This will make things slower than necessary, and in some cases can lead to errors. If you create a Slaplan first, then add Slaholidays to it, keep the cascade in Slaplan and remove it from Slaholiday.