summaryrefslogtreecommitdiff
path: root/sd/qa/unit
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-06-20 15:08:12 +0200
committerRegina Henschel <rb.henschel@t-online.de>2020-06-22 10:43:08 +0200
commit3f3b50015e4fd9efc3459612a70409fca49cf390 (patch)
treeb9bf5c45f1c8732e74c0852640b666eca78e59af /sd/qa/unit
parent586f106bbec37c81804c63969fd3ad0c1d3da054 (diff)
tdf#134053 tweak dash and space length for ooxml
OOXML does not specify how line caps are applied to dashes. MS Office keeps dash and space length for preset dash styles and for round custom dash styles and add them for square line caps on custom dash styles. ODF specifies, that the linecaps are added to the dashes and the spaces are reduced, so that the dash-space pair keeps its length. This patch changes the dash and space length on import and export so, that they look nearly the same in LibreOffice as in MS Office. For custom dash styles with square line cap the first dash is longer as in MS Office. I have no solution for that. But I consider it as minor problem, because MS Office has not even an UI for that case. It should not hinder the improvement for the usual cases. Change-Id: I3e3e4b7c9d71e440ed301d2be423100440cb688b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96769 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sd/qa/unit')
-rw-r--r--sd/qa/unit/data/pptx/tdf134053_dashdot.pptxbin0 -> 14891 bytes
-rw-r--r--sd/qa/unit/uiimpress.cxx34
2 files changed, 34 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf134053_dashdot.pptx b/sd/qa/unit/data/pptx/tdf134053_dashdot.pptx
new file mode 100644
index 000000000000..f2d951c570fd
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf134053_dashdot.pptx
Binary files differ
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 93a76ac2597d..56d1f8fc789b 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -345,6 +345,40 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient)
CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), aGradient.GetStartColor().AsRGBHexString());
CPPUNIT_ASSERT_EQUAL(OUString("0000ff"), aGradient.GetEndColor().AsRGBHexString());
}
+
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
+{
+ // Error was, that dashes and dots were longer than in MS Office.
+ mxComponent = loadFromDesktop(
+ m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf134053_dashdot.pptx"));
+ auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pShape = pActualPage->GetObj(0);
+ CPPUNIT_ASSERT_MESSAGE("No Shape", pShape);
+
+ // Break line into single dash and dot objects
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pShape, pView->GetSdrPageView());
+ dispatchCommand(mxComponent, ".uno:ConvertIntoMetafile", {});
+ dispatchCommand(mxComponent, ".uno:Break", {});
+
+ // Measure the rendered length of dash, dot and distance
+ SdrObject* pDash = pActualPage->GetObj(0);
+ const tools::Rectangle& rBoundDashRect = pDash->GetCurrentBoundRect();
+ const double fDashLength(rBoundDashRect.GetWidth());
+ SdrObject* pDot = pActualPage->GetObj(1);
+ const tools::Rectangle& rBoundDotRect = pDot->GetCurrentBoundRect();
+ const double fDotLength(rBoundDotRect.GetWidth());
+ const double fDistance(rBoundDotRect.Left() - rBoundDashRect.Right());
+
+ // Because 0% is not possible as dash length (as of June 2020) 1% is used in the fix.
+ // For that a larger delta is here allowed to the ideal value than needed for
+ // rounding errors.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Distance", 2117, fDistance, 12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dot length", 706, fDotLength, 12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dash length", 2822, fDashLength, 12);
+}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */