diff --git a/samples/Sample_11_Shape.php b/samples/Sample_11_Shape.php
index 37dc5a221..35d1a4540 100644
--- a/samples/Sample_11_Shape.php
+++ b/samples/Sample_11_Shape.php
@@ -81,6 +81,25 @@ function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation)
$shape->createTextRun('Line Spacing 300');
}
+function fnSlideRichTextRotation(PhpPresentation $objPHPPresentation)
+{
+ // Create templated slide
+ echo date('H:i:s') . ' Create templated slide' . EOL;
+ $currentSlide = createTemplatedSlide($objPHPPresentation);
+
+ // Create a shape (text)
+ echo date('H:i:s') . ' Create a shape (rich text) with rotation' . EOL;
+ $shape = $currentSlide->createRichTextShape();
+ $shape->setHeight(100);
+ $shape->setWidth(400);
+ $shape->setOffsetX(100);
+ $shape->setOffsetY(100);
+ $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
+ $shape->setRotation(45);
+
+ $shape->createTextRun('RichText with rotation');
+}
+
function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation)
{
// Create templated slide
@@ -143,6 +162,7 @@ function fnSlideRichTextList(PhpPresentation $objPHPPresentation)
fnSlideRichText($objPHPPresentation);
fnSlideRichTextLineSpacing($objPHPPresentation);
+fnSlideRichTextRotation($objPHPPresentation);
fnSlideRichTextShadow($objPHPPresentation);
fnSlideRichTextList($objPHPPresentation);
diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php
index 40356df18..362dd11c6 100644
--- a/samples/Sample_Header.php
+++ b/samples/Sample_Header.php
@@ -87,13 +87,21 @@
if (preg_match('/^Sample_\d+_/', $file)) {
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file));
$group = substr($name, 0, 1);
+ $id = substr($name, 0, 2);
if (!isset($files[$group])) {
- $files[$group] = '';
+ $files[$group] = array();
}
- $files[$group] .= "
{$name}";
+ if (!isset($files[$group][$id])) {
+ $files[$group][$id] = '';
+ }
+ $files[$group][$id] .= "{$name}";
+ ksort($files[$group]);
}
}
closedir($handle);
+ foreach ($files as $keyGroup => $arrayGroup) {
+ $files[$keyGroup] = implode('', $arrayGroup);
+ }
}
/**
diff --git a/src/PhpPresentation/Writer/ODPresentation/Content.php b/src/PhpPresentation/Writer/ODPresentation/Content.php
index 38e6e1a76..9433e4256 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Content.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Content.php
@@ -454,6 +454,10 @@ public function writeShapeTxt(XMLWriter $objWriter, RichText $shape): void
$objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
$objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
$objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
+ if ($shape->getRotation() != 0) {
+ $rotRad = deg2rad($shape->getRotation());
+ $objWriter->writeAttribute('draw:transform', 'rotate ('.$rotRad.')');
+ }
// draw:text-box
$objWriter->startElement('draw:text-box');
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
index 198b16f5c..636c41048 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
@@ -418,6 +418,18 @@ public function testRichTextBorder(): void
$this->assertIsSchemaOpenDocumentValid('1.2');
}
+ public function testRichTextRotation(): void
+ {
+ $expectedValue = rand(1, 360);
+ $oRichText1 = $this->oPresentation->getActiveSlide()->createRichTextShape();
+ $oRichText1->setRotation($expectedValue);
+
+ $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame';
+ $this->assertZipXmlElementExists('content.xml', $element);
+ $this->assertZipXmlAttributeExists('content.xml', $element, 'draw:transform');
+ $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:transform', 'rotate ('.deg2rad(360 - $expectedValue).')');
+ }
+
public function testRichTextShadow(): void
{
$randAlpha = mt_rand(0, 100);