diff options
-rw-r--r-- | drawinglayer/source/tools/primitive2dxmldump.cxx | 9 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 46 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/tdf156271.svg | 6 | ||||
-rw-r--r-- | svgio/source/svgreader/svgcharacternode.cxx | 63 |
4 files changed, 85 insertions, 39 deletions
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 8adaf82327d3..a68692649f46 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -919,6 +919,15 @@ void Primitive2dXmlDump::decomposeAndWrite( const drawinglayer::attribute::FontAttribute& aFontAttribute = rTextSimplePortionPrimitive2D.getFontAttribute(); rWriter.attribute("familyname", aFontAttribute.getFamilyName()); + const std::vector<double> aDx = rTextSimplePortionPrimitive2D.getDXArray(); + if (aDx.size()) + { + for (size_t iDx = 0; iDx < aDx.size(); ++iDx) + { + OString sName = "dx" + OString::number(iDx); + rWriter.attribute(sName, OUString::number(aDx[iDx])); + } + } rWriter.endElement(); } break; diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 7263439e86c1..0a976eb276e0 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -1431,6 +1431,52 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156269) assertXPath(pDocument, "//textsimpleportion[@text='two']", "fontcolor", "#000000"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156271) +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156271.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "x", "40"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "y", "10"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "text", "AB"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "dx0", "-30"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "dx1", "-19"); + + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "x", "40"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "y", "20"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "text", "AB"); + + // Without the fix in place, this test would have failed with + // - Expected: -30 + // - Actual : 0 + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "dx0", "-30"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "dx1", "-19"); + + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "x", "40"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "y", "30"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "text", "AB"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "dx0", "-30"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "dx1", "-19"); + + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "x", "40"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "y", "40"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "text", "AB"); + assertXPathNoAttribute(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "dx0"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf149880) { Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg"); diff --git a/svgio/qa/cppunit/data/tdf156271.svg b/svgio/qa/cppunit/data/tdf156271.svg new file mode 100644 index 000000000000..ff0267f35c82 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf156271.svg @@ -0,0 +1,6 @@ +<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> + <text x="40 10" y="10">AB</text> + <text x="10 10" dx="30" y="20">AB</text> + <text x="0 0" dx="40 10" y="30">AB</text> + <text x="10" dx="30 0" y="40">AB</text> +</svg> diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx index e9b719afc946..e7f08c908ad4 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -622,17 +622,6 @@ namespace svgio::svgreader // we have absolute positions, get first one as current text position X maPosition.setX(rSvgTextPositions.getX()[0].solve(rInfoProvider, NumberType::xcoordinate)); mbAbsoluteX = true; - - if(nSizeX > 1) - { - // fill deltas to maX - maX.reserve(nSizeX); - - for(sal_uInt32 a(1); a < nSizeX; a++) - { - maX.push_back(rSvgTextPositions.getX()[a].solve(rInfoProvider, NumberType::xcoordinate) - maPosition.getX()); - } - } } else { @@ -644,22 +633,25 @@ namespace svgio::svgreader } const sal_uInt32 nSizeDx(rSvgTextPositions.getDx().size()); - if(nSizeDx) { // relative positions given, translate position derived from parent maPosition.setX(maPosition.getX() + rSvgTextPositions.getDx()[0].solve(rInfoProvider, NumberType::xcoordinate)); + } - if(nSizeDx > 1) - { - // fill deltas to maX - maX.reserve(nSizeDx); + // fill deltas to maX + maX.reserve(nSizeX); - for(sal_uInt32 a(1); a < nSizeDx; a++) - { - maX.push_back(rSvgTextPositions.getDx()[a].solve(rInfoProvider, NumberType::xcoordinate)); - } + for(sal_uInt32 a(1); a < nSizeX; a++) + { + double nPos = rSvgTextPositions.getX()[a].solve(rInfoProvider, NumberType::xcoordinate) - maPosition.getX(); + + if(a < nSizeDx) + { + nPos += rSvgTextPositions.getDx()[a].solve(rInfoProvider, NumberType::xcoordinate); } + + maX.push_back(nPos); } // get text positions Y @@ -670,17 +662,6 @@ namespace svgio::svgreader // we have absolute positions, get first one as current text position Y maPosition.setY(rSvgTextPositions.getY()[0].solve(rInfoProvider, NumberType::ycoordinate)); mbAbsoluteX = true; - - if(nSizeY > 1) - { - // fill deltas to maY - maY.reserve(nSizeY); - - for(sal_uInt32 a(1); a < nSizeY; a++) - { - maY.push_back(rSvgTextPositions.getY()[a].solve(rInfoProvider, NumberType::ycoordinate) - maPosition.getY()); - } - } } else { @@ -697,17 +678,21 @@ namespace svgio::svgreader { // relative positions given, translate position derived from parent maPosition.setY(maPosition.getY() + rSvgTextPositions.getDy()[0].solve(rInfoProvider, NumberType::ycoordinate)); + } - if(nSizeDy > 1) - { - // fill deltas to maY - maY.reserve(nSizeDy); + // fill deltas to maY + maY.reserve(nSizeY); - for(sal_uInt32 a(1); a < nSizeDy; a++) - { - maY.push_back(rSvgTextPositions.getDy()[a].solve(rInfoProvider, NumberType::ycoordinate)); - } + for(sal_uInt32 a(1); a < nSizeY; a++) + { + double nPos = rSvgTextPositions.getY()[a].solve(rInfoProvider, NumberType::ycoordinate) - maPosition.getY(); + + if(a < nSizeDy) + { + nPos += rSvgTextPositions.getDy()[a].solve(rInfoProvider, NumberType::ycoordinate); } + + maY.push_back(nPos); } } |