diff options
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 10 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.hxx | 5 | ||||
-rw-r--r-- | drawinglayer/source/tools/primitive2dxmldump.cxx | 2 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 46 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf | bin | 9636 -> 9472 bytes |
5 files changed, 40 insertions, 23 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 79ced761e8a2..7a64f8ad4dac 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -442,6 +442,10 @@ namespace emfplushelper maMapTransform *= basegfx::utils::createScaleTranslateB2DHomMatrix(100.0 * mnMmX / mnPixX, 100.0 * mnMmY / mnPixY, double(-mnFrameLeft), double(-mnFrameTop)); maMapTransform *= maBaseTransform; + + // Used only for performance optimization, to do not calculate it every line draw + mdExtractedXScale = std::hypot(maMapTransform.a(), maMapTransform.b()); + mdExtractedYScale = std::hypot(maMapTransform.c(), maMapTransform.d()); } ::basegfx::B2DPoint EmfPlusHelperData::Map(double ix, double iy) const @@ -517,7 +521,7 @@ namespace emfplushelper SAL_WARN_IF(pen->startCap != pen->endCap, "drawinglayer.emf", "emf+ pen uses different start and end cap"); } - const double transformedPenWidth = maMapTransform.get(0, 0) * pen->penWidth; + const double transformedPenWidth = mdExtractedYScale * pen->penWidth; drawinglayer::attribute::LineAttribute lineAttribute(pen->GetColor().getBColor(), transformedPenWidth, pen->GetLineJoinType(), @@ -529,7 +533,7 @@ namespace emfplushelper new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( polygon, lineAttribute, - pen->GetStrokeAttribute(maMapTransform.get(1, 1)))); + pen->GetStrokeAttribute(mdExtractedXScale))); } else { @@ -537,7 +541,7 @@ namespace emfplushelper new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( polygon, lineAttribute, - pen->GetStrokeAttribute(maMapTransform.get(1, 1)))); + pen->GetStrokeAttribute(mdExtractedXScale))); mrTargetHolders.Current().append( new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx index cf3474b5b1a7..3d8244b6f208 100644 --- a/drawinglayer/source/tools/emfphelperdata.hxx +++ b/drawinglayer/source/tools/emfphelperdata.hxx @@ -210,6 +210,11 @@ namespace emfplushelper GraphicStateMap mGSStack; GraphicStateMap mGSContainerStack; + /* Performance optimizators */ + /* Extracted Scale values from Transformation Matrix */ + double mdExtractedXScale; + double mdExtractedYScale; + /// data holders wmfemfhelper::TargetHolders& mrTargetHolders; wmfemfhelper::PropertyHolders& mrPropertyHolders; diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index a1fddf900543..27a8adf1b5e3 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -143,7 +143,7 @@ void writeStrokeAttribute(::tools::XmlWriter& rWriter, OUString sDotDash; for (double fDotDash : rStrokeAttribute.getDotDashArray()) { - sDotDash += OUString::number(round(100.0 * fDotDash)) + " "; + sDotDash += OUString::number(lround(fDotDash)) + " "; } rWriter.attribute("dotDashArray", sDotDash); rWriter.attribute("fullDotDashLength", rStrokeAttribute.getFullDotDashLen()); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 63661c9c73c2..a734010e0dac 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -389,13 +389,13 @@ void Test::TestDrawLine() // check correct import of the DrawLine: color and width of the line assertXPath(pDocument, aXPathPrefix + "polypolygonstroke/line", "color", "#000000"); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke/line", "width", "33"); + assertXPath(pDocument, aXPathPrefix + "polypolygonstroke/line", "width", "23"); } void Test::TestDrawLineWithDash() { - // EMF+ with records: DrawLine - // The lines with different dash styles + // EMF+ with records: DrawLine, ScaleWorldTransform, RotateWorldTransform + // Test lines with different dash styles and different World Rotation Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); @@ -405,23 +405,31 @@ void Test::TestDrawLineWithDash() CPPUNIT_ASSERT(pDocument); // check correct import of the DrawLine: color and width of the line - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke", 10); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[1]/line", "color", "#000000"); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[1]/line", "width", "132"); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[1]/stroke", 0); - - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[2]/line", "width", "132"); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[2]/stroke", "dotDashArray", - "13225 13225 "); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[3]/stroke", "dotDashArray", - "39674 13225 "); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[4]/stroke", "dotDashArray", - "39674 13225 13225 13225 "); - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[5]/stroke", "dotDashArray", - "39674 13225 13225 13225 13225 13225 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke", 12); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[1]/line", "color", "#000000"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[1]/line", "width", "185"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[1]/stroke", 0); + + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[2]/line", "width", "185"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[2]/stroke", "dotDashArray", + "185 185 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[3]/line", "width", "185"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[3]/stroke", "dotDashArray", + "556 185 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[4]/line", "width", "185"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[4]/stroke", "dotDashArray", + "556 185 185 185 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[5]/line", "width", "370"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[5]/stroke", "dotDashArray", + "556 185 185 185 185 185 "); //TODO polypolygonstroke[6-9]/stroke add support for PenDataDashedLineOffset - assertXPath(pDocument, aXPathPrefix + "polypolygonstroke[10]/stroke", "dotDashArray", - "66124 26450 198372 52899 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[10]/line", "width", "370"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[10]/stroke", "dotDashArray", + "1851 741 5554 1481 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[11]/line", "width", "370"); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[11]/stroke", "dotDashArray", + "1851 741 5554 1481 "); + assertXPath(pDocument, aXPathPrefix + "mask/polypolygonstroke[12]/line", "width", "370"); } void Test::TestLinearGradient() diff --git a/emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf b/emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf Binary files differindex dc5af59e3f66..547cfca3fcad 100644 --- a/emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf +++ b/emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf |