diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2019-09-01 19:26:40 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2019-09-05 12:36:56 +0200 |
commit | 57c9bdab377a00649299d1a4c9ed2f9e5e03b84e (patch) | |
tree | 680bb89ff0c2d11745702e1fdca149fe0ea3f20f /sd/qa | |
parent | 8590de9d8c3f155f23155d7500fd805c0e21a26b (diff) |
tdf#127166, tdf#123903 improve import/export of line styles
I have added import and export of prstDash line styles, for OOXML
and for binary MS Office formats. This includes:
Corrected Dot <--> Dash confusion, corrected some wrong defaults,
added support for hairlines tdf#127267, take care of treating
length 0 as 100%.
tdf#108064 has introduced some mapping from our standard line styles
to OOXML prstDash. I have removed that and implemented to export
our styles as custDash and recover them back on import. That way the
dashing looks initially the same in MS Office. I have removed the now
wrong test.
Binary MS Office formats have no custom dash styles AFAIK, therefore
I have not changed the export of our styles there, but only added
support for prstDash styles.
Change-Id: Ia8cc8f90df6fdbe42adfc0236cc52becc670b333
Reviewed-on: https://gerrit.libreoffice.org/78372
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/data/odp/LineStylesOwn.odp | bin | 0 -> 15253 bytes | |||
-rw-r--r-- | sd/qa/unit/data/odp/tdf127267DashOnHairline.odp | bin | 0 -> 11874 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/presetDashDot.pptx | bin | 0 -> 11273 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml1.cxx | 113 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 8 |
5 files changed, 118 insertions, 3 deletions
diff --git a/sd/qa/unit/data/odp/LineStylesOwn.odp b/sd/qa/unit/data/odp/LineStylesOwn.odp Binary files differnew file mode 100644 index 000000000000..8a145bb9ff11 --- /dev/null +++ b/sd/qa/unit/data/odp/LineStylesOwn.odp diff --git a/sd/qa/unit/data/odp/tdf127267DashOnHairline.odp b/sd/qa/unit/data/odp/tdf127267DashOnHairline.odp Binary files differnew file mode 100644 index 000000000000..08aed1758b1f --- /dev/null +++ b/sd/qa/unit/data/odp/tdf127267DashOnHairline.odp diff --git a/sd/qa/unit/data/pptx/presetDashDot.pptx b/sd/qa/unit/data/pptx/presetDashDot.pptx Binary files differnew file mode 100644 index 000000000000..ae1525c97b14 --- /dev/null +++ b/sd/qa/unit/data/pptx/presetDashDot.pptx diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index dde6fa42781f..05d7d3aff31b 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/XTable.hpp> @@ -83,6 +84,9 @@ public: void testTdf94238(); void testPictureTransparency(); void testTdf125554(); + void testRoundtripOwnLineStyles(); + void testRoundtripPrstDash(); + void testDashOnHairline(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest1); @@ -116,6 +120,9 @@ public: CPPUNIT_TEST(testTdf94238); CPPUNIT_TEST(testTdf125554); CPPUNIT_TEST(testPictureTransparency); + CPPUNIT_TEST(testRoundtripOwnLineStyles); + CPPUNIT_TEST(testRoundtripPrstDash); + CPPUNIT_TEST(testDashOnHairline); CPPUNIT_TEST_SUITE_END(); @@ -905,6 +912,112 @@ void SdOOXMLExportTest1::testTdf125554() xDocShRef->DoClose(); } +void SdOOXMLExportTest1::testRoundtripOwnLineStyles() +{ + // Load odp document and read the LineDash values. + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/LineStylesOwn.odp"), ODP); + uno::Reference<drawing::XDrawPagesSupplier> xDocodp(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xDocodp.is()); + uno::Reference<drawing::XDrawPage> xPageodp(xDocodp->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xPageodp.is()); + drawing::LineDash aLineDashodp[10]; + for (sal_uInt16 i= 0; i < 10; i++) + { + uno::Reference<beans::XPropertySet> xShapeodp(getShape(i, xPageodp)); + CPPUNIT_ASSERT(xShapeodp.is()); + xShapeodp->getPropertyValue("LineDash") >>= aLineDashodp[i]; + } + + // Save to pptx, reload and compare the LineDash values + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + uno::Reference<drawing::XDrawPagesSupplier> xDocpptx(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xDocpptx.is()); + uno::Reference<drawing::XDrawPage> xPagepptx(xDocpptx->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xPagepptx.is()); + + for (sal_uInt16 i = 0; i < 10; i++) + { + drawing::LineDash aLineDashpptx; + uno::Reference<beans::XPropertySet> xShapepptx(getShape(i, xPagepptx)); + CPPUNIT_ASSERT(xShapepptx.is()); + xShapepptx->getPropertyValue("LineDash") >>= aLineDashpptx; + bool bIsSameLineDash = (aLineDashodp[i].Style == aLineDashpptx.Style + && aLineDashodp[i].Dots == aLineDashpptx.Dots + && aLineDashodp[i].DotLen == aLineDashpptx.DotLen + && aLineDashodp[i].Dashes == aLineDashpptx.Dashes + && aLineDashodp[i].DashLen == aLineDashpptx.DashLen + && aLineDashodp[i].Distance == aLineDashpptx.Distance); + CPPUNIT_ASSERT_MESSAGE("LineDash differ", bIsSameLineDash); + } + xDocShRef->DoClose(); +} + +void SdOOXMLExportTest1::testRoundtripPrstDash() +{ + // load and save document, compare prstDash values in saved document with original. + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/presetDashDot.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + const OUString sOriginal[] = { + "dash", + "dashDot", + "dot", + "lgDash", + "lgDashDot", + "lgDashDotDot", + "sysDash", + "sysDashDot", + "sysDashDotDot", + "sysDot" + }; + xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml"); + const OString sStart = "/p:sld/p:cSld/p:spTree/p:sp["; + const OString sEnd = "]/p:spPr/a:ln/a:prstDash"; + for (sal_uInt16 i = 0; i < 10; i++) + { + OString sXmlPath = sStart + OString::number(i+1) + sEnd; + OUString sResaved = getXPath(pXmlDoc, sXmlPath, "val"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong prstDash", sOriginal[i], sResaved); + } + + // tdf#126746: Make sure that dash-dot pattern starts with the longer dash, as defined in OOXML + // Make sure Style is drawing::DashStyle_RECTRELATIVE + uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xDoc.is()); + uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xPage.is()); + for (sal_uInt16 i = 0; i < 10; i++) + { + drawing::LineDash aLineDash; + uno::Reference<beans::XPropertySet> xShape(getShape(i, xPage)); + CPPUNIT_ASSERT(xShape.is()); + xShape->getPropertyValue("LineDash") >>= aLineDash; + CPPUNIT_ASSERT_MESSAGE("First dash is short", aLineDash.DotLen >= aLineDash.DashLen); + bool bIsRectRelative = aLineDash.Style == drawing::DashStyle_RECTRELATIVE; + CPPUNIT_ASSERT_MESSAGE("not RECTRELATIVE", bIsRectRelative); + } + + xDocShRef->DoClose(); +} + +void SdOOXMLExportTest1::testDashOnHairline() +{ + // load and save document, make sure the custDash has 11 child elements. + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf127267DashOnHairline.odp"), ODP); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml"); + const OString sXmlPath = "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:ln/a:custDash/a:ds"; + assertXPath(pXmlDoc, sXmlPath, 11); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index e2f82aa9d0c0..e9eeee5b8405 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -2478,6 +2478,8 @@ void SdOOXMLExportTest2::testTdf126741() xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); // dash dot dot line style import fix + // The original fixed values are replaced with the percent values, because + // with fix for tdf#127166 the MS Office preset styles are correctly detected. const SdrPage *pPage = GetPage( 1, xDocShRef ); SdrObject *const pObj = pPage->GetObj(0); CPPUNIT_ASSERT(pObj); @@ -2489,10 +2491,10 @@ void SdOOXMLExportTest2::testTdf126741() CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH, rStyleItem.GetValue()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), rDashItem.GetDashValue().GetDots()); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(280), rDashItem.GetDashValue().GetDotLen()); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(800), rDashItem.GetDashValue().GetDotLen()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), rDashItem.GetDashValue().GetDashes()); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), rDashItem.GetDashValue().GetDashLen()); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(105), rDashItem.GetDashValue().GetDistance()); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(100), rDashItem.GetDashValue().GetDashLen()); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(300), rDashItem.GetDashValue().GetDistance()); xDocShRef->DoClose(); } |