Skip to content

Commit 5d23e65

Browse files
authored
Merge pull request #257 from Progi1984/issue249
PR #249
2 parents d7bbf5c + 414c5ff commit 5d23e65

File tree

11 files changed

+340
-81
lines changed

11 files changed

+340
-81
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
- ODPresentation & PowerPoint2007 Writer : Support for video - @Progi1984 GH-123
2929
- ODPresentation & PowerPoint2007 Writer : Support for Visibility for slides - @Progi1984
3030
- PowerPoint2007 Reader : Layout Management - @vincentKool @Progi1984 GH-161
31+
- PowerPoint2007 Reader : Bullet Color - @Progi1984 GH-257
32+
- PowerPoint2007 Reader : Line Spacing - @Progi1984 GH-257
3133
- PowerPoint2007 Writer : Presentation with predefined View Type - @Progi1984 GH-120
3234
- PowerPoint2007 Writer : Implement alpha channel to Fills - @Dayjo GH-203 / @Progi1984 GH-215
3335
- PowerPoint2007 Writer : Implement Animations - @JewrassicPark GH-214 / @Progi1984 GH-217
34-
- PowerPoint2007 Writer : Layout Management - @vincentKool @Progi1984 GH-161
36+
- PowerPoint2007 Writer : Layout Management - @vincentKool @Progi1984 GH-161
37+
- PowerPoint2007 Writer : Bullet Color - @piotrbelina GH-249
38+
- PowerPoint2007 Writer : Line Spacing - @piotrbelina GH-249
3539

3640
## 0.6.0 - 2016-01-24
3741

docs/shapes_richtext.rst

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,54 @@ Below are the properties that you can set for a rich text shape.
2626
Properties that can be set for each paragraphs are as follow.
2727

2828
- ``alignment`` see *[Alignment](#alignment)*
29-
- ``font`` see *[Font](#font)*
3029
- ``bulletStyle`` see *[Bullet](#bullet)*
30+
- ``lineSpacing`` see *[LineSpacing](#linespacing)*
31+
- ``font`` see *[Font](#font)*
32+
33+
34+
Bullet
35+
------
36+
37+
For a paragraph, you can define the bullet style.
38+
39+
Example:
40+
41+
.. code-block:: php
42+
43+
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
44+
use PhpOffice\PhpPresentation\Style\Bullet;
45+
46+
$oParagraph = new Paragraph();
47+
$oParagraph->getBulletStyle();
48+
49+
With the bullet style, you can define the char, the font, the color and the type.
50+
51+
.. code-block:: php
52+
53+
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
54+
use PhpOffice\PhpPresentation\Style\Bullet;
55+
use PhpOffice\PhpPresentation\Style\Color;
56+
57+
$oParagraph = new Paragraph();
58+
$oParagraph->getBulletStyle()->setBulletChar('-');
59+
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
60+
$oParagraph->getBulletStyle()->setBulletColor(new Color(Color::COLOR_RED));
61+
62+
63+
LineSpacing
64+
-----------
65+
66+
For a paragraph, you can define the line spacing.
67+
68+
Example:
69+
70+
.. code-block:: php
71+
72+
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
73+
74+
$oParagraph = new Paragraph();
75+
$oParagraph->setLineSpacing(200);
76+
$iLineSpacing = $oParagraph->getLineSpacing();
3177
3278
3379
Run
@@ -42,4 +88,4 @@ Example:
4288
use PhpOffice\PhpPresentation\Shape\RichText\Run;
4389
4490
$oRun = new Run();
45-
$oComment->setLanguage('fr-FR');
91+
$oRun->setLanguage('fr-FR');

samples/Sample_11_Shape.php

Lines changed: 115 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,147 @@
77

88
include_once 'Sample_Header.php';
99

10-
function fnSlideRichText(PhpPresentation $objPHPPresentation) {
11-
// Create templated slide
12-
echo date('H:i:s') . ' Create templated slide'.EOL;
13-
$currentSlide = createTemplatedSlide($objPHPPresentation);
14-
15-
// Create a shape (text)
16-
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
17-
$shape = $currentSlide->createRichTextShape();
18-
$shape->setHeight(100);
19-
$shape->setWidth(600);
20-
$shape->setOffsetX(100);
21-
$shape->setOffsetY(100);
22-
$shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_LEFT );
23-
24-
$textRun = $shape->createTextRun('RichText with');
25-
$textRun->getFont()->setBold(true);
26-
$textRun->getFont()->setSize(28);
27-
$textRun->getFont()->setColor(new Color( 'FF000000' ));
28-
29-
$shape->createBreak();
30-
31-
$textRun = $shape->createTextRun('Multiline');
32-
$textRun->getFont()->setBold(true);
33-
$textRun->getFont()->setSize(60);
34-
$textRun->getFont()->setColor(new Color( 'FF000000' ));
10+
function fnSlideRichText(PhpPresentation $objPHPPresentation)
11+
{
12+
// Create templated slide
13+
echo date('H:i:s') . ' Create templated slide' . EOL;
14+
$currentSlide = createTemplatedSlide($objPHPPresentation);
15+
16+
// Create a shape (text)
17+
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
18+
$shape = $currentSlide->createRichTextShape();
19+
$shape->setHeight(100);
20+
$shape->setWidth(600);
21+
$shape->setOffsetX(100);
22+
$shape->setOffsetY(100);
23+
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
24+
25+
$textRun = $shape->createTextRun('RichText with');
26+
$textRun->getFont()->setBold(true);
27+
$textRun->getFont()->setSize(28);
28+
$textRun->getFont()->setColor(new Color('FF000000'));
29+
30+
$shape->createBreak();
31+
32+
$textRun = $shape->createTextRun('Multiline');
33+
$textRun->getFont()->setBold(true);
34+
$textRun->getFont()->setSize(60);
35+
$textRun->getFont()->setColor(new Color('FF000000'));
36+
}
37+
38+
function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation)
39+
{
40+
// Create templated slide
41+
echo date('H:i:s') . ' Create templated slide' . EOL;
42+
$currentSlide = createTemplatedSlide($objPHPPresentation);
43+
44+
// Create a shape (text)
45+
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (100)' . EOL;
46+
$shape = $currentSlide->createRichTextShape();
47+
$shape->setHeight(100);
48+
$shape->setWidth(400);
49+
$shape->setOffsetX(100);
50+
$shape->setOffsetY(100);
51+
$shape->getActiveParagraph()->setLineSpacing(100);
52+
53+
$shape->createTextRun('RichText with');
54+
$shape->createBreak();
55+
$shape->createTextRun('Line Spacing 100');
56+
57+
// Create a shape (text)
58+
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (200)' . EOL;
59+
$shape = $currentSlide->createRichTextShape();
60+
$shape->setHeight(100);
61+
$shape->setWidth(400);
62+
$shape->setOffsetX(100);
63+
$shape->setOffsetY(200);
64+
$shape->getActiveParagraph()->setLineSpacing(200);
65+
66+
$shape->createTextRun('RichText with');
67+
$shape->createBreak();
68+
$shape->createTextRun('Line Spacing 200');
69+
70+
// Create a shape (text)
71+
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (300)' . EOL;
72+
$shape = $currentSlide->createRichTextShape();
73+
$shape->setHeight(100);
74+
$shape->setWidth(400);
75+
$shape->setOffsetX(100);
76+
$shape->setOffsetY(300);
77+
$shape->getActiveParagraph()->setLineSpacing(300);
78+
79+
$shape->createTextRun('RichText with');
80+
$shape->createBreak();
81+
$shape->createTextRun('Line Spacing 300');
3582
}
3683

37-
function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation) {
84+
function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation)
85+
{
3886
// Create templated slide
39-
echo date('H:i:s') . ' Create templated slide'.EOL;
87+
echo date('H:i:s') . ' Create templated slide' . EOL;
4088
$currentSlide = createTemplatedSlide($objPHPPresentation);
4189

4290
// Create a shape (text)
43-
echo date('H:i:s') . ' Create a shape (rich text) with shadow'.EOL;
91+
echo date('H:i:s') . ' Create a shape (rich text) with shadow' . EOL;
4492
$shape = $currentSlide->createRichTextShape();
45-
$shape->setHeight(100);
46-
$shape->setWidth(400);
47-
$shape->setOffsetX(100);
48-
$shape->setOffsetY(100);
49-
$shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_LEFT );
93+
$shape->setHeight(100);
94+
$shape->setWidth(400);
95+
$shape->setOffsetX(100);
96+
$shape->setOffsetY(100);
97+
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
5098
$shape->getShadow()->setVisible(true)->setAlpha(75)->setBlurRadius(2)->setDirection(45);
5199

52100
$textRun = $shape->createTextRun('RichText with shadow');
53-
$textRun->getFont()->setColor(new Color( 'FF000000' ));
101+
$textRun->getFont()->setColor(new Color('FF000000'));
102+
}
103+
104+
function fnSlideRichTextList(PhpPresentation $objPHPPresentation)
105+
{
106+
// Create templated slide
107+
echo date('H:i:s') . ' Create templated slide' . EOL;
108+
$currentSlide = createTemplatedSlide($objPHPPresentation);
109+
110+
// Create a shape (text)
111+
echo date('H:i:s') . ' Create a shape (rich text) with list with red bullet' . EOL;
112+
$shape = $currentSlide->createRichTextShape();
113+
$shape->setHeight(100);
114+
$shape->setWidth(400);
115+
$shape->setOffsetX(100);
116+
$shape->setOffsetY(100);
117+
$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET)->setBulletColor(new Color(Color::COLOR_RED));
118+
119+
$shape->createTextRun('Alpha');
120+
$shape->createParagraph()->createTextRun('Beta');
121+
$shape->createParagraph()->createTextRun('Delta');
122+
$shape->createParagraph()->createTextRun('Epsilon');
54123
}
55124

56125
// Create new PHPPresentation object
57-
echo date('H:i:s') . ' Create new PHPPresentation object'.EOL;
126+
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
58127
$objPHPPresentation = new PhpPresentation();
59128

60129
// Set properties
61-
echo date('H:i:s') . ' Set properties'.EOL;
130+
echo date('H:i:s') . ' Set properties' . EOL;
62131
$oProperties = $objPHPPresentation->getDocumentProperties();
63132
$oProperties->setCreator('PHPOffice')
64-
->setLastModifiedBy('PHPPresentation Team')
65-
->setTitle('Sample 11 Title')
66-
->setSubject('Sample 11 Subject')
67-
->setDescription('Sample 11 Description')
68-
->setKeywords('office 2007 openxml libreoffice odt php')
69-
->setCategory('Sample Category');
133+
->setLastModifiedBy('PHPPresentation Team')
134+
->setTitle('Sample 11 Title')
135+
->setSubject('Sample 11 Subject')
136+
->setDescription('Sample 11 Description')
137+
->setKeywords('office 2007 openxml libreoffice odt php')
138+
->setCategory('Sample Category');
70139

71140
// Remove first slide
72-
echo date('H:i:s') . ' Remove first slide'.EOL;
141+
echo date('H:i:s') . ' Remove first slide' . EOL;
73142
$objPHPPresentation->removeSlideByIndex(0);
74143

75144
fnSlideRichText($objPHPPresentation);
145+
fnSlideRichTextLineSpacing($objPHPPresentation);
76146
fnSlideRichTextShadow($objPHPPresentation);
147+
fnSlideRichTextList($objPHPPresentation);
77148

78149
// Save file
79150
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
80151
if (!CLI) {
81-
include_once 'Sample_Footer.php';
152+
include_once 'Sample_Footer.php';
82153
}

samples/Sample_Header.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,18 @@ protected function displayShapeInfo(AbstractShape $oShape)
349349
$this->append('<dt>Alignment Indent</dt><dd>'.$oParagraph->getAlignment()->getIndent().' px</dd>');
350350
$this->append('<dt>Alignment Level</dt><dd>'.$oParagraph->getAlignment()->getLevel().'</dd>');
351351
$this->append('<dt>Bullet Style</dt><dd> Bullet::'.$this->getConstantName('\PhpOffice\PhpPresentation\Style\Bullet', $oParagraph->getBulletStyle()->getBulletType()).'</dd>');
352-
$this->append('<dt>Bullet Font</dt><dd>'.$oParagraph->getBulletStyle()->getBulletFont().'</dd>');
352+
if ($oParagraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) {
353+
$this->append('<dt>Bullet Font</dt><dd>' . $oParagraph->getBulletStyle()->getBulletFont() . '</dd>');
354+
$this->append('<dt>Bullet Color</dt><dd>' . $oParagraph->getBulletStyle()->getBulletColor()->getARGB() . '</dd>');
355+
}
353356
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) {
354357
$this->append('<dt>Bullet Char</dt><dd>'.$oParagraph->getBulletStyle()->getBulletChar().'</dd>');
355358
}
356359
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) {
357360
$this->append('<dt>Bullet Start At</dt><dd>'.$oParagraph->getBulletStyle()->getBulletNumericStartAt().'</dd>');
358361
$this->append('<dt>Bullet Style</dt><dd>'.$oParagraph->getBulletStyle()->getBulletNumericStyle().'</dd>');
359362
}
363+
$this->append('<dt>Line Spacing</dt><dd>'.$oParagraph->getLineSpacing().'</dd>');
360364
$this->append('<dt>RichText</dt><dd><dl>');
361365
foreach ($oParagraph->getRichTextElements() as $oRichText) {
362366
if($oRichText instanceof BreakElement) {

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,9 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, Abs
797797
$oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl'));
798798
}
799799

800-
$oElementBuFont = $document->getElement('a:buFont', $oSubElement);
801800
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
801+
802+
$oElementBuFont = $document->getElement('a:buFont', $oSubElement);
802803
if ($oElementBuFont) {
803804
if ($oElementBuFont->hasAttribute('typeface')) {
804805
$oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
@@ -811,7 +812,7 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, Abs
811812
$oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
812813
}
813814
}
814-
/*$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
815+
$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
815816
if ($oElementBuAutoNum) {
816817
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
817818
if ($oElementBuAutoNum->hasAttribute('type')) {
@@ -820,7 +821,19 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, Abs
820821
if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) {
821822
$oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt'));
822823
}
823-
}*/
824+
}
825+
$oElementBuClr = $document->getElement('a:buClr', $oSubElement);
826+
if ($oElementBuClr) {
827+
$oColor = new Color();
828+
/**
829+
* @todo Create protected for reading Color
830+
*/
831+
$oElementColor = $document->getElement('a:srgbClr', $oElementBuClr);
832+
if ($oElementColor) {
833+
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
834+
}
835+
$oParagraph->getBulletStyle()->setBulletColor($oColor);
836+
}
824837
}
825838
$arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
826839
foreach ($arraySubElements as $oSubElement) {

0 commit comments

Comments
 (0)