core.git: 2 commits - svgio/inc svgio/qa svgio/source
svgio/inc/SvgNumber.hxx |4 +-- svgio/inc/svgnode.hxx |3 -- svgio/inc/svgtspannode.hxx|2 - svgio/qa/cppunit/SvgImportTest.cxx| 34 ++ svgio/qa/cppunit/SvgNumberTest.cxx|2 - svgio/qa/cppunit/data/dy_in_ems.svg |7 + svgio/qa/cppunit/data/dy_in_exs.svg |7 + svgio/source/svgreader/SvgNumber.cxx |3 +- svgio/source/svgreader/svgnode.cxx| 17 +++-- svgio/source/svgreader/svgstyleattributes.cxx |8 +++--- svgio/source/svgreader/svgtspannode.cxx |5 --- 11 files changed, 62 insertions(+), 30 deletions(-) New commits: commit 86a8a3a43b642fc13bae6a89720496285f8f73d7 Author: Mike Kaganski AuthorDate: Tue Apr 9 13:56:13 2024 +0500 Commit: Mike Kaganski CommitDate: Thu Apr 18 18:21:15 2024 +0200 tdf#160594: Use the recommended fallback of 0.5em for ex in font-size This fixes the error of identical treatment of em and ex in font-size, which violated https://drafts.csswg.org/css-values-4/#font-relative-length. The fix uses the fallback of 0.5em for ex, similar to the code used in SvgNumber::solveNonPercentage. A follow-up should implement the correct use of "x-height of the first available font". Change-Id: Id9d581994e158d629d9752299ad93ac7e9fe4cad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166234 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index d06a50f0e98b..dd53d4e28a19 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -1677,6 +1677,22 @@ CPPUNIT_TEST_FIXTURE(Test, testDyInEms) assertXPath(pDocument, "//textsimpleportion[2]"_ostr, "y"_ostr, u"32"_ustr); } +CPPUNIT_TEST_FIXTURE(Test, testExs) +{ +// tdf#160594 given an SVG file with : +xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/dy_in_exs.svg"); + +assertXPath(pDocument, "//textsimpleportion"_ostr, 2); +assertXPath(pDocument, "//textsimpleportion[1]"_ostr, "height"_ostr, u"16"_ustr); + +sal_Int32 nSize = getXPath(pDocument, "//textsimpleportion[2]"_ostr, "height"_ostr).toInt32(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected less than: 16 +// - Actual : 16 +// i.e. the parent font-size was used, instead of its x-size. +CPPUNIT_ASSERT_LESS(sal_Int32(16), nSize); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/qa/cppunit/data/dy_in_exs.svg b/svgio/qa/cppunit/data/dy_in_exs.svg new file mode 100644 index ..816a64a4586c --- /dev/null +++ b/svgio/qa/cppunit/data/dy_in_exs.svg @@ -0,0 +1,7 @@ + + +http://www.w3.org/2000/svg"; width="1in" height="1in" viewBox="0 0 100% 100%"> + + foo + bar + \ No newline at end of file diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 63be6afe270c..763a7a3cdd96 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -2642,11 +2642,11 @@ namespace svgio::svgreader if(pSvgStyleAttributes) { const SvgNumber aParentNumber = pSvgStyleAttributes->getFontSizeNumber(); +double n = aParentNumber.getNumber() * maFontSizeNumber.getNumber(); +if (SvgUnit::ex == maFontSizeNumber.getUnit()) +n *= 0.5; // FIXME: use "x-height of the first available font" -return SvgNumber( -aParentNumber.getNumber() * maFontSizeNumber.getNumber(), -aParentNumber.getUnit(), -true); +return SvgNumber(n, aParentNumber.getUnit()); } } commit e27572686130df43d1d65c574b0c34f39fc0d1a9 Author: Mike Kaganski AuthorDate: Tue Apr 9 13:03:07 2024 +0500 Commit: Mike Kaganski CommitDate: Thu Apr 18 18:21:09 2024 +0200 tdf#160593: make sure to use current element's font size for em unit According to https://drafts.csswg.org/css-values-4/#font-relative-length em is "equal to the computed value of the font-size property of the element on which it is used". This means, that for an element that defines its own font-size, attributes like 'dy' using em refer to the new font-size, not to inherited font-size. Change-Id: Ie5a013df99a68edddf466e4c0ee5311f6219fcb2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166233 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/svgio/inc/SvgNumber.hxx b/svgio/inc/SvgNumber.hxx index b2fc51b6f7ac..6e371ba94b26 100644 -
[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/qa svgio/source
svgio/inc/svgcharacternode.hxx|4 + svgio/inc/svgtspannode.hxx|8 +- svgio/qa/cppunit/SvgImportTest.cxx| 52 ++ svgio/qa/cppunit/data/tdf86938.svg| 13 svgio/qa/cppunit/data/tdf93583.svg|7 ++ svgio/source/svgreader/svgcharacternode.cxx | 72 +- svgio/source/svgreader/svgdocumenthandler.cxx | 24 svgio/source/svgreader/svgtspannode.cxx |3 - 8 files changed, 143 insertions(+), 40 deletions(-) New commits: commit a2b6be8af9be3237efc3ed1244302cf899680e97 Author: Xisco Fauli AuthorDate: Mon Aug 14 17:34:00 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Aug 15 03:53:18 2023 +0200 tdf#86938: fix calculation of baseline-shift Change-Id: I8c30c29052f2ea1fe6e49360b972af868851131b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155671 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 53f6b23da4fd..d68e7ebf728a 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -746,6 +746,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf85770) assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf86938) +{ +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf86938.svg"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "line"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", "290"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", "183"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "above"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", "290"); + +// Without the fix in place, this test would have failed with +// - Expected: 159 +// - Actual : 207 +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "159"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "below"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "x", "290"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "y", "207"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf93583) { Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf93583.svg"); diff --git a/svgio/qa/cppunit/data/tdf86938.svg b/svgio/qa/cppunit/data/tdf86938.svg new file mode 100644 index ..40287a39de88 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf86938.svg @@ -0,0 +1,13 @@ +http://www.w3.org/2000/svg";> + line + above + below + diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx index ebc317c3a445..91ec98ae9b68 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -301,7 +301,7 @@ namespace svgio::svgreader const SvgNumber aNumber(rSvgStyleAttributes.getBaselineShiftNumber()); const double mfBaselineShift(aNumber.solve(*this)); -aPosition.setY(aPosition.getY() + mfBaselineShift); +aPosition.setY(aPosition.getY() - mfBaselineShift); break; } default: // BaselineShift::Baseline commit 5cfd31e505b4d1b4f9d2e21b0f9f8aac22539f47 Author: Xisco Fauli AuthorDate: Mon Aug 14 14:52:41 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Aug 15 03:53:06 2023 +0200 tdf#93583: use getTextWidth to calculate line's width Since every character in the line might use different styles Change-Id: I2ce079d4308f4acde42a8366838749a7c20331b4 Change-Id: I01f51f157caa667cebc8860ae37d4458fac2d511 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155666 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/svgio/inc/svgcharacternode.hxx b/svgio/inc/svgcharacternode.hxx index 059aa9ece1fd..d81066af47a6 100644 --- a/svgio/inc/svgcharacternode.hxx +++ b/svgio/inc/svgcharacternode.hxx @@ -24,6 +24,7 @@ #include +#include #include "svgtextnode.hxx" #include "svgtextposition.hxx" @@ -58,6 +59,9 @@ namespace svgio::svgreader OUString aText); virtual ~SvgCharacterNode() override; +static drawinglayer::attribute::FontAttribute getFontAttribute( +const SvgStyleAttributes& rSvgStyleAttributes); + virtual const SvgStyleAttr
[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/qa svgio/source
svgio/inc/svgcharacternode.hxx|4 - svgio/qa/cppunit/SvgImportTest.cxx| 16 +++--- svgio/source/svgreader/svgcharacternode.cxx | 42 +++- svgio/source/svgreader/svgdocumenthandler.cxx | 66 +- 4 files changed, 62 insertions(+), 66 deletions(-) New commits: commit 4f656a057e2a92e2107f7820fc563498c801d7d3 Author: Xisco Fauli AuthorDate: Thu Aug 10 11:49:19 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Aug 10 16:34:04 2023 +0200 svgio: handle addGap internally inside SvgCharacterNode Also add the gap at the beginning of the current node, not at the end of the previous one Change-Id: I6583059b4a7418010ac2af459e00fb0d02d39605 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/12 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/svgio/inc/svgcharacternode.hxx b/svgio/inc/svgcharacternode.hxx index f44d7547b4ca..e0e353a429a7 100644 --- a/svgio/inc/svgcharacternode.hxx +++ b/svgio/inc/svgcharacternode.hxx @@ -104,14 +104,12 @@ namespace svgio::svgreader void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const; void whiteSpaceHandling(); -void addGap(); +SvgCharacterNode* addGap(SvgCharacterNode* pPreviousCharacterNode); void concatenate(std::u16string_view rText); /// Text content const OUString& getText() const { return maText; } -const OUString& getTextBeforeSpaceHandling() const { return maTextBeforeSpaceHandling; } - void setWholeTextLine(const OUString& rWholeTextLine) { maWholeTextLine = rWholeTextLine; } const OUString& getWholeTextLine() const { return maWholeTextLine; } diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 80234e8b1f56..cf66e5bb623f 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -737,11 +737,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf85770) assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "11"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#00"); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Start "); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Start"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "Times New Roman"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#00"); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "End"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", " End"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "11"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman"); @@ -1163,12 +1163,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156251) // Without the fix in place, this test would have failed with // - Expected: 'You are ' // - Actual : 'You are' -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "You are "); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "not "); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "a banana!"); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "You are "); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "not "); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "a banana!"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "You are"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", " not"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", " a banana!"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "You are"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", " not"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", " a banana!"); } CPPUNIT_TEST_FIXTURE(Test, testMaskText) diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx index c953c5fc89c9..e014cd6bf1bf 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #
[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/qa svgio/source
svgio/inc/svgstyleattributes.hxx |3 - svgio/qa/cppunit/SvgImportTest.cxx| 29 ++ svgio/qa/cppunit/data/tdf149673.svg |7 ++ svgio/qa/cppunit/data/tdf156201.svg | 36 svgio/source/svgreader/svganode.cxx |2 svgio/source/svgreader/svgcirclenode.cxx |2 svgio/source/svgreader/svgellipsenode.cxx |2 svgio/source/svgreader/svggnode.cxx |2 svgio/source/svgreader/svgimagenode.cxx |2 svgio/source/svgreader/svglinenode.cxx|2 svgio/source/svgreader/svgpathnode.cxx|2 svgio/source/svgreader/svgpolynode.cxx|2 svgio/source/svgreader/svgrectnode.cxx|2 svgio/source/svgreader/svgstyleattributes.cxx | 73 ++ svgio/source/svgreader/svgtextnode.cxx|2 svgio/source/svgreader/svgusenode.cxx |2 16 files changed, 114 insertions(+), 56 deletions(-) New commits: commit 56039daae4a436d7ea1b093a02cf0e8ad3bda4a9 Author: Xisco Fauli AuthorDate: Mon Jul 10 14:46:34 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Jul 10 16:54:06 2023 +0200 tdf#149673: only check opacity from parent... ... if it has a local css style Because it's the first in the style stack Partially reverts 3e0e67a152e9631574e28dacb6e06a96f03ebca2 "tdf#155932: tdf#97717: only apply opacity when primitive" Change-Id: I6a6bf08a519c84ac58c6111fd7da308cbf8a3021 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154270 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx index 0516fa2543af..4ada2e687ee9 100644 --- a/svgio/inc/svgstyleattributes.hxx +++ b/svgio/inc/svgstyleattributes.hxx @@ -287,8 +287,7 @@ namespace svgio::svgreader void add_postProcess( drawinglayer::primitive2d::Primitive2DContainer& rTarget, drawinglayer::primitive2d::Primitive2DContainer&& rSource, -const std::optional& pTransform, -bool bIsPrimitive) const; +const std::optional& pTransform) const; /// helper to set mpCssStyleParent temporarily for CSS style hierarchies void setCssStyleParent(const SvgStyleAttributes* pNew) { mpCssStyleParent = pNew; } diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index fc9557a5c312..0f8b31d4b1cc 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -835,6 +835,22 @@ CPPUNIT_TEST_FIXTURE(Test, testRGBColor) assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf149673) +{ +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf149673.svg"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", "transparence", "90"); +assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence/polypolygoncolor[1]", "color", "#ff"); +assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence/polypolygoncolor[2]", "color", "#00ff00"); +assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence/polypolygoncolor[3]", "color", "#ff"); +} + CPPUNIT_TEST_FIXTURE(Test, testRGBAColor) { Primitive2DSequence aSequenceRGBAColor = parseSvg(u"/svgio/qa/cppunit/data/RGBAColor.svg"); diff --git a/svgio/qa/cppunit/data/tdf149673.svg b/svgio/qa/cppunit/data/tdf149673.svg new file mode 100644 index ..f73b9959d342 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf149673.svg @@ -0,0 +1,7 @@ +http://www.w3.org/2000/svg";> + + + + + + diff --git a/svgio/source/svgreader/svganode.cxx b/svgio/source/svgreader/svganode.cxx index 83dd7c50175e..e700574c5a40 100644 --- a/svgio/source/svgreader/svganode.cxx +++ b/svgio/source/svgreader/svganode.cxx @@ -94,7 +94,7 @@ namespace svgio::svgreader if(!aContent.empty()) { -pStyle->add_postProcess(rTarget, std::move(aContent), getTransform(), true); +pStyle->add_postProcess(rTarget, std::move(aContent), getTransform()); } } } diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx index 363e85d111ab..513c128cf272 100644 --- a/svgio/source/svgreader/svgcirclenode.cxx +++ b/svgio/source/svgreader/svgcirclenode.cxx @@ -135,7 +135,7 @@ namespace svgio::svgreader if(!aNewTarget.empty()) { -pStyle->add_postProcess(rTarget, std::move(aNewTarget