[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Mar 12 03:14:58 UTC 2019
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 22 +++-
sd/qa/unit/data/pptx/smartart-autoTxRot.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 91 ++++++++++++++++++++
3 files changed, 109 insertions(+), 4 deletions(-)
New commits:
commit aa773560eef3caebe010160f253084abbdce81c1
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Dec 1 17:51:11 2018 +0300
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Mar 12 04:14:33 2019 +0100
tdf#121844: properly implement autoTxRot support
... after commit cf7b97d1328ec2f2c8254abb9ce67d63d9c54c80
Change-Id: If46265f49a85d92254fedb719d76ff7319c092cc
Reviewed-on: https://gerrit.libreoffice.org/64396
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/69050
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 876eb3d06c8d..0b0c77f40fd5 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1007,20 +1007,34 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
break;
}
+ // ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text Rotation)
const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? maMap.find(XML_autoTxRot)->second : XML_upr;
+ sal_Int32 nShapeRot = rShape->getRotation();
+ while (nShapeRot < 0)
+ nShapeRot += 360 * PER_DEGREE;
+ while (nShapeRot > 360 * PER_DEGREE)
+ nShapeRot -= 360 * PER_DEGREE;
switch(nautoTxRot)
{
case XML_upr:
{
- if (rShape->getRotation())
- pTextBody->getTextProperties().moRotation = -F_PI180*90*rShape->getRotation();
+ int n90x = 0;
+ if (nShapeRot >= 315 * PER_DEGREE)
+ /* keep 0 */;
+ else if (nShapeRot > 225 * PER_DEGREE)
+ n90x = -3;
+ else if (nShapeRot >= 135 * PER_DEGREE)
+ n90x = -2;
+ else if (nShapeRot > 45 * PER_DEGREE)
+ n90x = -1;
+ pTextBody->getTextProperties().moRotation = n90x * 90 * PER_DEGREE;
}
break;
case XML_grav:
{
- if (rShape->getRotation()==90*F_PI180 || rShape->getRotation()==180*F_PI180)
- pTextBody->getTextProperties().moRotation = 180*F_PI180;
+ if (nShapeRot > (90 * PER_DEGREE) && nShapeRot < (270 * PER_DEGREE))
+ pTextBody->getTextProperties().moRotation = -180 * PER_DEGREE;
}
break;
case XML_none:
diff --git a/sd/qa/unit/data/pptx/smartart-autoTxRot.pptx b/sd/qa/unit/data/pptx/smartart-autoTxRot.pptx
new file mode 100644
index 000000000000..30e69a6de6c1
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-autoTxRot.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 9de4061a072b..5317ac19c919 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -45,6 +45,7 @@ public:
void testDir();
void testMaxDepth();
void testRotation();
+ void testTextAutoRotation();
void testVertialBoxList();
void testVertialBracketList();
void testTableList();
@@ -61,6 +62,7 @@ public:
CPPUNIT_TEST(testDir);
CPPUNIT_TEST(testMaxDepth);
CPPUNIT_TEST(testRotation);
+ CPPUNIT_TEST(testTextAutoRotation);
CPPUNIT_TEST(testVertialBoxList);
CPPUNIT_TEST(testVertialBracketList);
CPPUNIT_TEST(testTableList);
@@ -216,6 +218,95 @@ void SdImportTestSmartArt::testRotation()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testTextAutoRotation()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-autoTxRot.pptx"), PPTX);
+
+ auto testText = [&](int pageNo, sal_Int32 txtNo, const OUString& expTx, sal_Int32 expShRot,
+ sal_Int32 expTxRot) {
+ OString msgText = "Page: " + OString::number(pageNo) + " text: " + OString::number(txtNo);
+ uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, pageNo, xDocShRef),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xTxt(xShapeGroup->getByIndex(txtNo), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expTx, xTxt->getString());
+ uno::Reference<beans::XPropertySet> xTxtProps(xTxt, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expShRot,
+ xTxtProps->getPropertyValue("RotateAngle").get<sal_Int32>());
+
+ auto aGeomPropSeq = xTxtProps->getPropertyValue("CustomShapeGeometry")
+ .get<uno::Sequence<beans::PropertyValue>>();
+ comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
+
+ auto it = aCustomShapeGeometry.find("TextPreRotateAngle");
+ if (it == aCustomShapeGeometry.end())
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), sal_Int32(0), expTxRot);
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expTxRot, it->second.get<sal_Int32>());
+ }
+ };
+
+ // Slide 1: absent autoTxRot => defaults to "upr"
+ testText(0, 0, "a", 0, 0);
+ testText(0, 1, "b", 33750, 0);
+ testText(0, 2, "c", 31500, 0);
+ testText(0, 3, "d", 29250, 90);
+ testText(0, 4, "e", 27000, 90);
+ testText(0, 5, "f", 24750, 90);
+ testText(0, 6, "g", 22500, 180);
+ testText(0, 7, "h", 20250, 180);
+ testText(0, 8, "i", 18000, 180);
+ testText(0, 9, "j", 15750, 180);
+ testText(0, 10, "k", 13500, 180);
+ testText(0, 11, "l", 11250, 270);
+ testText(0, 12, "m", 9000, 270);
+ testText(0, 13, "n", 6750, 270);
+ testText(0, 14, "o", 4500, 0);
+ testText(0, 15, "p", 2250, 0);
+
+ // Slide 2: autoTxRot == "none"
+ testText(1, 0, "a", 0, 0);
+ testText(1, 1, "b", 33750, 0);
+ testText(1, 2, "c", 31500, 0);
+ testText(1, 3, "d", 29250, 0);
+ testText(1, 4, "e", 27000, 0);
+ testText(1, 5, "f", 24750, 0);
+ testText(1, 6, "g", 22500, 0);
+ testText(1, 7, "h", 20250, 0);
+ testText(1, 8, "i", 18000, 0);
+ testText(1, 9, "j", 15750, 0);
+ testText(1, 10, "k", 13500, 0);
+ testText(1, 11, "l", 11250, 0);
+ testText(1, 12, "m", 9000, 0);
+ testText(1, 13, "n", 6750, 0);
+ testText(1, 14, "o", 4500, 0);
+ testText(1, 15, "p", 2250, 0);
+
+ // Slide 3: autoTxRot == "grav"
+ testText(2, 0, "a", 0, 0);
+ testText(2, 1, "b", 33750, 0);
+ testText(2, 2, "c", 31500, 0);
+ testText(2, 3, "d", 29250, 0);
+ testText(2, 4, "e", 27000, 0);
+ testText(2, 5, "f", 24750, 180);
+ testText(2, 6, "g", 22500, 180);
+ testText(2, 7, "h", 20250, 180);
+ testText(2, 8, "i", 18000, 180);
+ testText(2, 9, "j", 15750, 180);
+ testText(2, 10, "k", 13500, 180);
+ testText(2, 11, "l", 11250, 180);
+ testText(2, 12, "m", 9000, 0);
+ testText(2, 13, "n", 6750, 0);
+ testText(2, 14, "o", 4500, 0);
+ testText(2, 15, "p", 2250, 0);
+
+ xDocShRef->DoClose();
+}
+
void SdImportTestSmartArt::testVertialBoxList()
{
sd::DrawDocShellRef xDocShRef = loadURL(
More information about the Libreoffice-commits
mailing list