[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-09-06 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |2 +-
 svgio/source/svgreader/svgcharacternode.cxx |   11 ---
 2 files changed, 1 insertion(+), 12 deletions(-)

New commits:
commit bc25df351f946c799112533af1cf9b1dcb2f6079
Author: Xisco Fauli 
AuthorDate: Wed Sep 6 11:35:26 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Sep 6 14:13:41 2023 +0200

tdf#157113: Add gap even if baseline is different

This was a workaround for https://bz.apache.org/ooo/show_bug.cgi?id=122524
but it's no longer needed since 5079e7937ef471a44dcf119dc6ae0a334d9c6adc
"tdf#156251: Add gap between text elements when needed"

Change-Id: I83af59a515d56af6b0e3cf3e351d3df52510a17d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156613
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index c0792504cfba..b337418dbdec 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1842,7 +1842,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156837)
 // - Actual  : 103
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", 
"94");
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"height", "10");
-assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", "3");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", " 3");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf156271)
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 0199a1ff9105..222c2739a689 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -514,17 +514,6 @@ namespace svgio::svgreader
 if(pPreviousCharacterNode->mpParentLine != mpParentLine)
 bAddGap = false;
 
-// With this option a baseline shift between two char 
parts ('words')
-// will not add a space 'gap' to the end of the (non-last) 
word. This
-// seems to be the standard behaviour, see last bugdoc 
attached #122524#
-const SvgStyleAttributes* pStyleLast = 
pPreviousCharacterNode->getSvgStyleAttributes();
-const SvgStyleAttributes* pStyleCurrent = 
getSvgStyleAttributes();
-
-if(pStyleLast && pStyleCurrent && 
pStyleLast->getBaselineShift() != pStyleCurrent->getBaselineShift())
-{
-bAddGap = false;
-}
-
 // add in-between whitespace (single space) to last
 // known character node
 if(bAddGap)


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-08-17 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   21 +
 svgio/qa/cppunit/data/tdf117920.svg   |7 +++
 svgio/source/svgreader/svgdocumenthandler.cxx |7 +--
 3 files changed, 29 insertions(+), 6 deletions(-)

New commits:
commit 8b9643960117612b7e1cae1ed8325c2630232d0f
Author: Xisco Fauli 
AuthorDate: Thu Aug 17 09:24:18 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Aug 18 01:09:04 2023 +0200

tdf#142424: Revert "related tdf#156579: just break for switch element"

This reverts commit e222f60ac2a71032dbdf62d7c7e28978b5a0b19c.

To make the switch element behave like a
group as least, so the transform attribute is parsed
Change-Id: Id8c21ac6da217d8f7bc350ff41022335bf1e0f1f

Change-Id: If1e53f9baad8995f26f9b885cfef6265040736bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155758
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 31e5bdb3ef13..2297367ee778 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -991,6 +991,27 @@ CPPUNIT_TEST_FIXTURE(Test, testNoneColor)
 assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygonstroke/line", "width", "3");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf117920)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf117920.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/transform", "xy11", "1");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy12", "0");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy13", "-18");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy21", "0");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy22", "1");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy23", "-6");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy31", "0");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy32", "0");
+assertXPath(pDocument, "/primitive2D/transform/transform", "xy33", "1");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf97936)
 {
 // check that both rectangles are rendered in the viewBox
diff --git a/svgio/qa/cppunit/data/tdf117920.svg 
b/svgio/qa/cppunit/data/tdf117920.svg
new file mode 100644
index ..487e0f6cb925
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf117920.svg
@@ -0,0 +1,7 @@
+http://www.w3.org/2000/svg;
+ xmlns:xlink="http://www.w3.org/1999/xlink;>
+   
+   
+   
+
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx 
b/svgio/source/svgreader/svgdocumenthandler.cxx
index 0b66a4bb44da..9c8ab88f2f62 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -199,6 +199,7 @@ namespace
 mpTarget->parseAttributes(xAttribs);
 break;
 }
+case SVGToken::Switch: //TODO: Support switch element
 case SVGToken::Defs:
 case SVGToken::G:
 {
@@ -442,12 +443,6 @@ namespace
 break;
 }
 
-case SVGToken::Switch:
-{
-//TODO: Support switch element
-break;
-}
-
 default:
 {
 mpTarget = new SvgNode(SVGToken::Unknown, maDocument, 
mpTarget);


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-08-15 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx |   21 +
 svgio/qa/cppunit/data/tdf156777.svg|   14 ++
 svgio/source/svgreader/svgtextpathnode.cxx |2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 20f57e14362674d321ef184e1987f41a6418adc2
Author: Xisco Fauli 
AuthorDate: Tue Aug 15 19:43:42 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Aug 15 21:42:31 2023 +0200

tdf#156777: check for css style in textpath

Change-Id: I63a274dd9fba37852412a194a490cb2b7634f1cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155726
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index d68e7ebf728a..31e5bdb3ef13 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -710,6 +710,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf97941)
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", "Times New Roman");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156777)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156777.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", 23);
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", "Quick brown fox jumps over the lazy dog.");
+
+// Without the fix in place, this test would have failed with
+// - Expected: #008000
+// - Actual  : #00
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"fontcolor", "#008000");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", 
"84");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", 
"23");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf104339)
 {
 Primitive2DSequence aSequenceTdf104339 = 
parseSvg(u"/svgio/qa/cppunit/data/tdf104339.svg");
diff --git a/svgio/qa/cppunit/data/tdf156777.svg 
b/svgio/qa/cppunit/data/tdf156777.svg
new file mode 100644
index ..9ce1dd8cd37c
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156777.svg
@@ -0,0 +1,14 @@
+http://www.w3.org/2000/svg;>
+  
+
+  
+
+  Quick brown fox jumps over the lazy dog.
+
+  
+
+
diff --git a/svgio/source/svgreader/svgtextpathnode.cxx 
b/svgio/source/svgreader/svgtextpathnode.cxx
index 2c5a823566ed..4dad47f62bb6 100644
--- a/svgio/source/svgreader/svgtextpathnode.cxx
+++ b/svgio/source/svgreader/svgtextpathnode.cxx
@@ -252,7 +252,7 @@ namespace svgio::svgreader
 
 const SvgStyleAttributes* SvgTextPathNode::getSvgStyleAttributes() 
const
 {
-return 
+return checkForCssStyle(maSvgStyleAttributes);
 }
 
 void SvgTextPathNode::parseAttribute(const OUString& rTokenName, 
SVGToken aSVGToken, const OUString& aContent)


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-08-02 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   31 
 svgio/qa/cppunit/data/tdf156577.svg |8 +++
 svgio/source/svgreader/svgcharacternode.cxx |   22 +++
 3 files changed, 52 insertions(+), 9 deletions(-)

New commits:
commit 79646e204f5d558f5519186cb62ef1c9254f857f
Author: Xisco Fauli 
AuthorDate: Wed Aug 2 11:49:56 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Aug 2 20:07:14 2023 +0200

tdf#156577: do no use parent position if x array is empty

Change-Id: Id29e5a440dbc3719c53bcc9226336a3c99d469e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155216
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 9bc0dfc24e19..4309add11fbb 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1431,6 +1431,37 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156269)
 assertXPath(pDocument, "//textsimpleportion[@text='two']", "fontcolor", 
"#00");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156577)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156577.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]", 
"width", "16");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "16");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", 
"30");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", 
"20");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", "ABC");
+assertXPathNoAttribute(pDocument, 
"/primitive2D/transform/textsimpleportion[1]", "dx0");
+
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"width", "16");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"height", "16");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", 
"30");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", 
"30");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", "ABC");
+
+// Without the fix in place, this test would have failed with
+// - Expected: 22
+// - Actual  : 52
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx0", "22");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx1", "53");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"dx2", "94");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf156283)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156283.svg");
diff --git a/svgio/qa/cppunit/data/tdf156577.svg 
b/svgio/qa/cppunit/data/tdf156577.svg
new file mode 100644
index ..de12f36667f8
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156577.svg
@@ -0,0 +1,8 @@
+http://www.w3.org/2000/svg;>
+   
+ABC
+
+   
+ABC
+   
+
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 5fab853ed0a0..8a6610c91d25 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -263,23 +263,27 @@ namespace svgio::svgreader
 
 // prepare TextArray
 ::std::vector< double > aTextArray(rSvgTextPosition.getX());
-if(aTextArray.size() < nLength)
+::std::vector< double > aDxArray(rSvgTextPosition.getDx());
+
+// Do nothing when X and Dx arrays are empty
+if((!aTextArray.empty() || !aDxArray.empty()) && 
aTextArray.size() < nLength)
 {
 const sal_uInt32 nArray(aTextArray.size());
 
 double fStartX(0.0);
-
-if(rSvgTextPosition.getParent() && 
rSvgTextPosition.getParent()->getAbsoluteX())
-{
-fStartX = 
rSvgTextPosition.getParent()->getPosition().getX();
-}
-else if (!aTextArray.empty())
+if (!aTextArray.empty())
 {
-fStartX = aTextArray[nArray - 1];
+if(rSvgTextPosition.getParent() && 
rSvgTextPosition.getParent()->getAbsoluteX())
+{
+fStartX = 
rSvgTextPosition.getParent()->getPosition().getX();
+}
+else
+{
+fStartX = aTextArray[nArray - 1];
+}
 }
 
 ::std::vector< double > 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-07-13 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   27 +++
 svgio/qa/cppunit/data/tdf156269.svg |8 
 svgio/source/svgreader/svgcharacternode.cxx |   48 ++--
 3 files changed, 59 insertions(+), 24 deletions(-)

New commits:
commit 1df7a1ac274db509f1a135b84a01ea51c4d0c1f9
Author: Xisco Fauli 
AuthorDate: Thu Jul 13 11:14:25 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jul 13 23:09:53 2023 +0200

tdf#156269: dx and dy do not depend on x and y

Change-Id: I99be5aa45b333ec3825373c3a10be0e24d23cb29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154380
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index b3d20603cfa7..7263439e86c1 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1404,6 +1404,33 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf97663)
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", 
"236");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156269)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156269.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "//textsimpleportion[@text='one']", "width", "16");
+assertXPath(pDocument, "//textsimpleportion[@text='one']", "height", "16");
+assertXPath(pDocument, "//textsimpleportion[@text='one']", "x", "10");
+assertXPath(pDocument, "//textsimpleportion[@text='one']", "y", "50");
+assertXPath(pDocument, "//textsimpleportion[@text='one']", "fontcolor", 
"#808080");
+
+assertXPath(pDocument, "//textsimpleportion[@text='two']", "width", "16");
+assertXPath(pDocument, "//textsimpleportion[@text='two']", "height", "16");
+
+// Without the fix in place, this test would have failed with
+// - Expected: 60
+// - Actual  : 10
+assertXPath(pDocument, "//textsimpleportion[@text='two']", "x", "60");
+assertXPath(pDocument, "//textsimpleportion[@text='two']", "y", "100");
+assertXPath(pDocument, "//textsimpleportion[@text='two']", "fontcolor", 
"#00");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149880)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg");
diff --git a/svgio/qa/cppunit/data/tdf156269.svg 
b/svgio/qa/cppunit/data/tdf156269.svg
new file mode 100644
index ..e840b351d17d
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156269.svg
@@ -0,0 +1,8 @@
+http://www.w3.org/2000/svg;>
+  
+  one
+
+  
+  two
+
+
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 4ffc46a483db..e62d21528d96 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -645,23 +645,23 @@ namespace svgio::svgreader
 {
 maPosition.setX(pParent->getPosition().getX());
 }
+}
+
+const sal_uInt32 nSizeDx(rSvgTextPositions.getDx().size());
 
-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)
+if(nSizeDx > 1)
 {
-// relative positions given, translate position derived 
from parent
-maPosition.setX(maPosition.getX() + 
rSvgTextPositions.getDx()[0].solve(rInfoProvider, NumberType::xcoordinate));
+// fill deltas to maX
+maX.reserve(nSizeDx);
 
-if(nSizeDx > 1)
+for(sal_uInt32 a(1); a < nSizeDx; a++)
 {
-// fill deltas to maX
-maX.reserve(nSizeDx);
-
-for(sal_uInt32 a(1); a < nSizeDx; a++)
-{
-
maX.push_back(rSvgTextPositions.getDx()[a].solve(rInfoProvider, 
NumberType::xcoordinate));
-}
+
maX.push_back(rSvgTextPositions.getDx()[a].solve(rInfoProvider, 
NumberType::xcoordinate));
 }
 }
 }
@@ -693,23 +693,23 @@ namespace svgio::svgreader
 {
 maPosition.setY(pParent->getPosition().getY());
 }
+}
+
+const sal_uInt32 nSizeDy(rSvgTextPositions.getDy().size());
 
-const sal_uInt32 nSizeDy(rSvgTextPositions.getDy().size());
+if(nSizeDy)
+{
+

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-07-11 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx |   20 ++--
 svgio/qa/cppunit/data/tdf156236.svg|7 +++
 svgio/source/svgreader/svgrectnode.cxx |   11 +++
 3 files changed, 28 insertions(+), 10 deletions(-)

New commits:
commit f7af4c311ad04ce5e54e08b9d7ccd71b75b7a32d
Author: Xisco Fauli 
AuthorDate: Tue Jul 11 16:08:38 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 12 06:35:20 2023 +0200

tdf#156236: For the rx or ry properties, "0" is valid

Change-Id: I32c865e409a339c40e00ee0f624c45380773
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154307
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 0f8b31d4b1cc..9f0b8ff7b9d7 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1048,11 +1048,11 @@ CPPUNIT_TEST_FIXTURE(Test, testClipRule)
 // - Actual  : 10
 assertXPath(pDocument, 
"/primitive2D/transform/mask[1]/polypolygon/polygon/point", 5);
 assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor", 
"color", "#ff");
-assertXPath(pDocument, 
"/primitive2D/transform/mask[1]/polypolygoncolor/polypolygon/polygon/point", 5);
+assertXPath(pDocument, 
"/primitive2D/transform/mask[1]/polypolygoncolor/polypolygon/polygon/point", 4);
 
 assertXPath(pDocument, 
"/primitive2D/transform/mask[2]/polypolygon/polygon/point", 5);
 assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor", 
"color", "#ff");
-assertXPath(pDocument, 
"/primitive2D/transform/mask[2]/polypolygoncolor/polypolygon/polygon/point", 5);
+assertXPath(pDocument, 
"/primitive2D/transform/mask[2]/polypolygoncolor/polypolygon/polygon/point", 4);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testi125329)
@@ -1271,6 +1271,22 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf94765)
 assertXPath(pDocument, 
"/primitive2D/transform/transform/svglineargradient[2]", "endy", "0");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156236)
+{
+Primitive2DSequence aSequenceTdf94765 = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156236.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf94765.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/polypolygoncolor[1]/polypolygon", "path", "m50 
180h-30v-60h60v60z");
+assertXPath(pDocument, 
"/primitive2D/transform/polypolygoncolor[2]/polypolygon", "path", "m150 
180h15c8.2842712474619 0 15-6.7157287525381 
15-15v-30c0-8.2842712474619-6.7157287525381-15-15-15h-30c-8.2842712474619 0-15 
6.7157287525381-15 15v30c0 8.2842712474619 6.7157287525381 15 15 15z");
+assertXPath(pDocument, 
"/primitive2D/transform/polypolygoncolor[3]/polypolygon", "path", "m250 
180h15c8.2842712474619 0 15-6.7157287525381 
15-15v-30c0-8.2842712474619-6.7157287525381-15-15-15h-30c-8.2842712474619 0-15 
6.7157287525381-15 15v30c0 8.2842712474619 6.7157287525381 15 15 15z");
+assertXPath(pDocument, 
"/primitive2D/transform/polypolygoncolor[4]/polypolygon", "path", "m350 
180c16.5685424949238 0 30-6.7157287525381 
30-15v-30c0-8.2842712474619-13.4314575050762-15-30-15s-30 6.7157287525381-30 
15v30c0 8.2842712474619 13.4314575050762 15 30 15z");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testBehaviourWhenWidthAndHeightIsOrIsNotSet)
 {
 // This test checks the behaviour when width and height attributes
diff --git a/svgio/qa/cppunit/data/tdf156236.svg 
b/svgio/qa/cppunit/data/tdf156236.svg
new file mode 100644
index ..12268652c03b
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156236.svg
@@ -0,0 +1,7 @@
+http://www.w3.org/2000/svg;>
+  
+  
+  
+  
+
+
diff --git a/svgio/source/svgreader/svgrectnode.cxx 
b/svgio/source/svgreader/svgrectnode.cxx
index 291d8540912f..c063ecf87195 100644
--- a/svgio/source/svgreader/svgrectnode.cxx
+++ b/svgio/source/svgreader/svgrectnode.cxx
@@ -32,9 +32,7 @@ namespace svgio::svgreader
 maX(0),
 maY(0),
 maWidth(0),
-maHeight(0),
-maRx(0),
-maRy(0)
+maHeight(0)
 {
 }
 
@@ -176,14 +174,11 @@ namespace svgio::svgreader
 double frX(getRx().isSet() ? getRx().solve(*this, 
NumberType::xcoordinate) : 0.0);
 double frY(getRy().isSet() ? getRy().solve(*this, 
NumberType::ycoordinate) : 0.0);
 
-frX = std::max(0.0, frX);
-frY = std::max(0.0, frY);
-
-if(0.0 == frY && frX > 0.0)
+if(!getRy().isSet() && 0.0 == frY && frX > 0.0)
 {
 frY = frX;
 }
-else if(0.0 == frX && frY > 0.0)
+else if(!getRx().isSet() && 0.0 == frX && frY > 0.0)
 {
 frX = frY;
 }


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-07-06 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   19 
 svgio/qa/cppunit/data/tdf156167.svg |   18 
 svgio/source/svgreader/svgtoken.cxx |  156 +++-
 3 files changed, 175 insertions(+), 18 deletions(-)

New commits:
commit 04c78e1a46a423071d7ea68724525ec7ef92e0e8
Author: Xisco Fauli 
AuthorDate: Wed Jul 5 13:31:27 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jul 6 14:36:44 2023 +0200

tdf#156167: create separate map for case insensitive strings

Add static_assert to make sure both maps have the same size

Regression from:
svgio: use "frozen" for mapping between token strings and enums

Change-Id: I2061606146cfcb34169dccf69b6f720727839d04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153174
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

Change-Id: Ic54dfe45eaff5ef75bcd4ebab715f278540da913
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154055
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 788eab52fdf5..24f146592249 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -505,6 +505,25 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156018)
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"color", "#ff");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156167)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156167.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]", 
"color", "#ffa500");
+
+// Without the fix in place, this test would have failed with
+// - Expected: #ffa500
+// - Actual  : #ff
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"color", "#ffa500");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", 
"color", "#ffa500");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf155932)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155932.svg");
diff --git a/svgio/qa/cppunit/data/tdf156167.svg 
b/svgio/qa/cppunit/data/tdf156167.svg
new file mode 100644
index ..5ab1254013c4
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156167.svg
@@ -0,0 +1,18 @@
+http://www.w3.org/2000/svg;
+  xmlns:xlink="http://www.w3.org/1999/xlink;>
+  
+
+
+ 
+
+
+
+
+
+#c {fill: red }
+#c {FiLl: oRaNgE }
+
+
+  
+
diff --git a/svgio/source/svgreader/svgtoken.cxx 
b/svgio/source/svgreader/svgtoken.cxx
index 1e2d3d7486da..0d77ca901ee8 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -180,25 +180,95 @@ constexpr frozen::unordered_map aSVGTokenMap
 { u"flowRoot", SVGToken::FlowRoot }
 };
 
-constexpr frozen::unordered_map 
aLowerCaseList
+// The same elements as the map above but lowercase. CSS is case insensitive
+// TODO: create separate maps for css and xml elements
+constexpr frozen::unordered_map 
aSVGLowerCaseTokenMapperList
 {
+{ u"width", SVGToken::Width },
+{ u"height", SVGToken::Height },
 { u"viewbox", SVGToken::ViewBox },
+{ u"transform", SVGToken::Transform },
+{ u"style", SVGToken::Style },
+{ u"display", SVGToken::Display }, // #i121656#
+{ u"d", SVGToken::D },
+{ u"x", SVGToken::X },
+{ u"y", SVGToken::Y },
+{ u"xmlns", SVGToken::Xmlns },
+{ u"version", SVGToken::Version },
+{ u"id", SVGToken::Id },
+{ u"in", SVGToken::In },
+{ u"rx", SVGToken::Rx },
+{ u"ry", SVGToken::Ry },
+{ u"points", SVGToken::Points },
+{ u"dx", SVGToken::Dx },
+{ u"dy", SVGToken::Dy },
+{ u"rotate", SVGToken::Rotate },
 { u"textlength", SVGToken::TextLength },
 { u"lengthadjust", SVGToken::LengthAdjust },
+{ u"font", SVGToken::Font },
+{ u"font-family", SVGToken::FontFamily },
+{ u"font-size", SVGToken::FontSize },
+{ u"font-size-adjust", SVGToken::FontSizeAdjust },
+{ u"font-stretch", SVGToken::FontStretch },
+{ u"font-style", SVGToken::FontStyle },
+{ u"font-variant", SVGToken::FontVariant },
+{ u"font-weight", SVGToken::FontWeight },
+{ u"direction", SVGToken::Direction },
+{ u"letter-spacing", SVGToken::LetterSpacing },
+{ u"text-decoration", SVGToken::TextDecoration },
+{ u"unicode-bidi", SVGToken::UnicodeBidi },
+{ u"word-spacing", SVGToken::WordSpacing },
+{ u"tspan", SVGToken::Tspan },
+{ u"tref", SVGToken::Tref },
 { u"textpath", SVGToken::TextPath },
 { u"startoffset", SVGToken::StartOffset },
+{ u"method", SVGToken::Method },
+{ u"spacing", SVGToken::Spacing },
+{ u"stddeviation", SVGToken::StdDeviation },
+{ u"text-align", 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-07-05 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   38 
 svgio/qa/cppunit/data/tdf156168.svg |   34 
 svgio/source/svgreader/svgnode.cxx  |4 +--
 3 files changed, 74 insertions(+), 2 deletions(-)

New commits:
commit e6ab906ebe9995fb813db7b66df4f9b2def76a1c
Author: Xisco Fauli 
AuthorDate: Wed Jul 5 14:36:06 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 5 17:15:25 2023 +0200

tdf#156168: do nothing when there is no concatenation

Regression from:
tdf#156034: check for css style further up in the hierarchy

Change-Id: I92c6673f1249cc4a273c490cdc0496474ce1f0c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153498
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

Change-Id: Ie699f40ea813d2ba5dc031008d56e2fce73a5715
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154056
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index a72bb39b993f..788eab52fdf5 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -403,6 +403,44 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf145896)
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", 
"color", "#ff");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156168)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156168.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", 8);
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]", 
"color", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"color", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", 
"color", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[4]", 
"color", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[5]", 
"color", "#00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[6]", 
"color", "#00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[7]", 
"color", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[8]", 
"color", "#ff");
+
+// Without the fix in place, this test would have failed with
+// - Expected: 4
+// - Actual  : 3
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke", 4);
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[1]/line", 
"width", "5");
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[1]/line", 
"color", "#00ff00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[2]/line", 
"width", "5");
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[2]/line", 
"color", "#00ff00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[3]/line", 
"width", "5");
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[3]/line", 
"color", "#00ff00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[4]/line", 
"width", "5");
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[4]/line", 
"color", "#00ff00");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf156034)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf156034.svg");
diff --git a/svgio/qa/cppunit/data/tdf156168.svg 
b/svgio/qa/cppunit/data/tdf156168.svg
new file mode 100644
index ..2cdbd35afd09
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf156168.svg
@@ -0,0 +1,34 @@
+
+
+http://www.w3.org/2000/svg;
+  xmlns:xlink="http://www.w3.org/1999/xlink;
+  style="font-family: 'Times New Roman', serif;
+font-size:large" >
+stroke enabled
+
+   
+#MyRed {
+fill: red;
+}
+#MyBlue {
+fill: blue;
+}
+.MyLime {
+stroke: lime;
+stroke-width: 5;
+}
+   
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svgio/source/svgreader/svgnode.cxx 
b/svgio/source/svgreader/svgnode.cxx
index 992aaf72bce0..4f82a16ebf1e 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -120,7 +120,7 @@ namespace {
 addCssStyle(rDocument, aNewConcatenated);
 
 // look further up in the hierarchy
-if(pParent && pParent->getId())
+if(!aConcatenated.isEmpty() && pParent && pParent->getId())
 {
 const OUString& rParentId = pParent->getId().value();
 addCssStyle(rDocument, "#" + rParentId + 
aConcatenated);
@@ -140,7 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-07-03 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   14 ++
 svgio/qa/cppunit/data/tdf150124.svg   |   12 
 svgio/source/svgreader/svgdocumenthandler.cxx |9 +++--
 svgio/source/svgreader/svgnode.cxx|   14 ++
 4 files changed, 31 insertions(+), 18 deletions(-)

New commits:
commit 13a41e7a12598c7896d6dc8d34aba6af5b80b83c
Author: Xisco Fauli 
AuthorDate: Mon Jul 3 14:11:43 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 3 16:15:13 2023 +0200

tdf#150124: do nothing when parent is of unkown type

Change-Id: I745b2a81200b0d8138b5f1b844849f20571d9546
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153878
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 6827d4f81d39..a72bb39b993f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -135,6 +135,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSymbol)
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#00d000");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf150124)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf150124.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPathChildren(pDocument, "/primitive2D", 1);
+assertXPath(pDocument, "/primitive2D/hiddengeometry", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf155819)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155819.svg");
diff --git a/svgio/qa/cppunit/data/tdf150124.svg 
b/svgio/qa/cppunit/data/tdf150124.svg
new file mode 100644
index ..29b2a1e3fd46
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf150124.svg
@@ -0,0 +1,12 @@
+http://www.w3.org/2000/svg;
+  xmlns:xlink="http://www.w3.org/1999/xlink;>
+  
+  
+  
+
+  
+  
+  
+  
+
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx 
b/svgio/source/svgreader/svgdocumenthandler.cxx
index 5f251b601bd0..46d938a7c31e 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -413,8 +413,7 @@ namespace
 
 default:
 {
-/// invalid token, ignore
-SAL_INFO( "svgio", "Unknown Base SvgToken <" + aName + "> 
(!)" );
+mpTarget = new SvgNode(SVGToken::Unknown, maDocument, 
mpTarget);
 break;
 }
 }
@@ -498,6 +497,8 @@ namespace
 /// structural element pattern
 case SVGToken::Pattern:
 
+default:
+
 /// content handling after parsing
 {
 if(mpTarget)
@@ -516,10 +517,6 @@ namespace
 }
 break;
 }
-default:
-{
-/// invalid token, ignore
-}
 }
 
 if(pSvgTitleDescNode && mpTarget)
diff --git a/svgio/source/svgreader/svgnode.cxx 
b/svgio/source/svgreader/svgnode.cxx
index 37b34deff0f6..d87c76d81e20 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -395,21 +395,11 @@ namespace {
 mbDecomposing(false),
 mbCssStyleVectorBuilt(false)
 {
-OSL_ENSURE(SVGToken::Unknown != maType, "SvgNode with unknown type 
created (!)");
-
-if(pParent)
+// tdf#150124 ignore when parent is unknown
+if(pParent && pParent->getType() != SVGToken::Unknown)
 {
 pParent->maChildren.emplace_back(this);
 }
-else
-{
-#ifdef DBG_UTIL
-if(SVGToken::Svg != getType())
-{
-OSL_ENSURE(false, "No parent for this node (!)");
-}
-#endif
-}
 }
 
 SvgNode::~SvgNode()


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-06-19 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   19 ++-
 svgio/qa/cppunit/data/tdf145896.svg   |   12 
 svgio/source/svgreader/svgdocumenthandler.cxx |   17 +++--
 svgio/source/svgreader/svgstylenode.cxx   |6 +++---
 4 files changed, 36 insertions(+), 18 deletions(-)

New commits:
commit 08a6ca6d426280f9ce225d9f25694c43e7ab810f
Author: Xisco Fauli 
AuthorDate: Mon Jun 19 16:17:00 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jun 19 23:04:46 2023 +0200

tdf#145896: set style to 'text/css' by default

This is a regression from 4c31a0be1d8048bf3340acbb59248185e4b93041
"Resolves: #i125326# accept CssStyles with missing type attribute"

Calling setTextCss(true) when there are no attributes is wrong,
since it might have attributes like 'id'.
The unittest added also covers i125326 is still fixed

Change-Id: Ic5e4899211ae98c866f64f17e69a3a8cd24e4959
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153290
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index c9ec752d882a..43dde4da9997 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -302,9 +302,26 @@ CPPUNIT_TEST_FIXTURE(Test, testFontsizeRelative)
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"familyname", "serif");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf145896)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf145896.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+// Without the fix in place, this test would have failed with
+// - Expected: #00
+// - Actual  : #00
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]", 
"color", "#00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"color", "#008000");
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", 
"color", "#ff");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf97717)
 {
-//Check when font-size uses relative units (em,ex) and it's based on its 
parent's font-size
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf97717.svg");
 CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
 
diff --git a/svgio/qa/cppunit/data/tdf145896.svg 
b/svgio/qa/cppunit/data/tdf145896.svg
new file mode 100644
index ..d434a961b9d0
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf145896.svg
@@ -0,0 +1,12 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="-0 0 300 300">
+
+
+.st0{fill:yellow;}.st1{fill:green;}
+
+
+.st2{fill:red;}
+
+
+
+
+
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx 
b/svgio/source/svgreader/svgdocumenthandler.cxx
index 43151253aacc..e26312d43163 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -302,21 +302,10 @@ namespace
 {
 SvgStyleNode* pNew = new SvgStyleNode(maDocument, 
mpTarget);
 mpTarget = pNew;
-const sal_uInt32 nAttributes(xAttribs->getLength());
 
-if(0 == nAttributes)
-{
-// #i125326# no attributes, thus also no 
type="text/css". This is allowed to be missing,
-// thus do mark this style as CssStyle. This is 
required to read the contained
-// text (which defines the css style)
-pNew->setTextCss(true);
-}
-else
-{
-// #i125326# there are attributes, read them. This 
will set isTextCss to true if
-// a type="text/css" is contained as exact match, else 
not
-mpTarget->parseAttributes(xAttribs);
-}
+// #i125326# there are attributes, read them. This will 
set isTextCss to false if
+// type attibute is different to "text/css"
+mpTarget->parseAttributes(xAttribs);
 
 if(pNew->isTextCss())
 {
diff --git a/svgio/source/svgreader/svgstylenode.cxx 
b/svgio/source/svgreader/svgstylenode.cxx
index ef25e6a83b47..b11f7129e0b3 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -28,7 +28,7 @@ namespace svgio::svgreader
 SvgDocument& rDocument,
 SvgNode* pParent)
 :   SvgNode(SVGToken::Style, rDocument, pParent),
-mbTextCss(false)
+mbTextCss(true)
 {
 }
 
@@ -57,9 +57,9 @@ 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-06-19 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   19 ++
 svgio/qa/cppunit/data/tdf97717.svg  |   11 ++
 svgio/source/svgreader/svggnode.cxx |   38 
 3 files changed, 47 insertions(+), 21 deletions(-)

New commits:
commit d47b37eea9779e3c354e6c19a7211a306965b7ef
Author: Xisco Fauli 
AuthorDate: Mon Jun 19 13:18:42 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jun 19 15:32:49 2023 +0200

tdf#97717: do not call add_postProcess from g element

Otherwise, it will be called twice, from g and from its children

Change-Id: I88535a7caab6a7711f917b3f383cd79b3b9fbd2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153260
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index ba267f5443a5..c9ec752d882a 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -302,6 +302,25 @@ CPPUNIT_TEST_FIXTURE(Test, testFontsizeRelative)
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"familyname", "serif");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf97717)
+{
+//Check when font-size uses relative units (em,ex) and it's based on its 
parent's font-size
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf97717.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence[1]", 
"transparence", "50");
+// Without the fix in place, this test would have failed here since the 
patch
+// would have contained two unifiedtransparence
+assertXPath(pDocument, 
"/primitive2D/transform/unifiedtransparence[1]/polypolygoncolor", "color", 
"#ff");
+assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence[2]", 
"transparence", "50");
+assertXPath(pDocument, 
"/primitive2D/transform/unifiedtransparence[2]/polypolygoncolor", "color", 
"#ff");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testMarkerOrient)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/MarkerOrient.svg");
diff --git a/svgio/qa/cppunit/data/tdf97717.svg 
b/svgio/qa/cppunit/data/tdf97717.svg
new file mode 100644
index ..c354e4416827
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf97717.svg
@@ -0,0 +1,11 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; viewBox="-0 0 300 300">
+
+   
+
+
+   
+   
+   
+
diff --git a/svgio/source/svgreader/svggnode.cxx 
b/svgio/source/svgreader/svggnode.cxx
index aca500af60ab..f49e737daafa 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 
 namespace svgio::svgreader
 {
@@ -85,31 +86,26 @@ namespace svgio::svgreader
 
 void 
SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& 
rTarget, bool bReferenced) const
 {
-if(SVGToken::Defs == getType())
-{
-// #i125258# no decompose needed for defs element, call parent 
for SVGTokenDefs
-SvgNode::decomposeSvgNode(rTarget, bReferenced);
-}
-else
-{
-// #i125258# for SVGTokenG decompose children
-const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+SvgNode::decomposeSvgNode(rTarget, bReferenced);
 
-if(pStyle)
+// if g element has transform, apply it
+if(SVGToken::G == getType())
+{
+if(getTransform())
 {
-const double fOpacity(pStyle->getOpacity().getNumber());
-
-if(fOpacity > 0.0 && Display::None != getDisplay())
-{
-drawinglayer::primitive2d::Primitive2DContainer 
aContent;
+drawinglayer::primitive2d::Primitive2DContainer 
aSource(std::move(rTarget));
+// create embedding group element with transformation
+const drawinglayer::primitive2d::Primitive2DReference xRef(
+new drawinglayer::primitive2d::TransformPrimitive2D(
+*getTransform(),
+std::move(aSource)));
 
-// decompose children
-SvgNode::decomposeSvgNode(aContent, bReferenced);
+aSource = drawinglayer::primitive2d::Primitive2DContainer 
{ xRef };
 
-if(!aContent.empty())
-{
-pStyle->add_postProcess(rTarget, 
std::move(aContent), getTransform());
-}
+if(!aSource.empty())
+{
+ 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-06-15 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   13 ++
 svgio/qa/cppunit/data/tdf155833.svg |   31 
 svgio/source/svgreader/svgimagenode.cxx |   60 +---
 3 files changed, 70 insertions(+), 34 deletions(-)

New commits:
commit 472d7ce57bdf1473538dda23c9328d44cdf816c8
Author: Xisco Fauli 
AuthorDate: Thu Jun 15 10:10:38 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 15 12:39:16 2023 +0200

tdf#155833: apply transform to image even if target is equal to viewbox

Change-Id: Ie820528384d096c6a332e2abd0095f68c7f64a0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153103
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index bdfbfcccb911..7184c5fa500b 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -423,6 +423,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf45771)
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", "Times New Roman");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf155833)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155833.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/mask/transform/transform/transform/transform/transform/bitmap",
 1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf97941)
 {
 //Check tspan fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/tdf155833.svg 
b/svgio/qa/cppunit/data/tdf155833.svg
new file mode 100644
index ..8cc908424af0
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf155833.svg
@@ -0,0 +1,31 @@
+
+
+
+http://www.w3.org/1999/xlink;
+   xmlns="http://www.w3.org/2000/svg;
+   xmlns:svg="http://www.w3.org/2000/svg;>
+  
+
+
+  
+
+
+  
+
diff --git a/svgio/source/svgreader/svgimagenode.cxx 
b/svgio/source/svgreader/svgimagenode.cxx
index ed7b81cef61a..19c8c9404541 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -310,45 +310,37 @@ namespace svgio::svgreader
 if(aNewTarget.empty())
 return;
 
-if(aTarget.equal(aViewBox))
-{
-// just add to rTarget
-rTarget.append(aNewTarget);
-}
-else
-{
-// create mapping
-const SvgAspectRatio& rRatio = maSvgAspectRatio;
+// create mapping
+const SvgAspectRatio& rRatio = maSvgAspectRatio;
 
-// even when ratio is not set, use the defaults
-// let mapping be created from SvgAspectRatio
-const basegfx::B2DHomMatrix 
aEmbeddingTransform(rRatio.createMapping(aTarget, aViewBox));
+// even when ratio is not set, use the defaults
+// let mapping be created from SvgAspectRatio
+const basegfx::B2DHomMatrix 
aEmbeddingTransform(rRatio.createMapping(aTarget, aViewBox));
 
-if(!aEmbeddingTransform.isIdentity())
-{
-const drawinglayer::primitive2d::Primitive2DReference xRef(
-new drawinglayer::primitive2d::TransformPrimitive2D(
-aEmbeddingTransform,
-std::move(aNewTarget)));
-
-aNewTarget = 
drawinglayer::primitive2d::Primitive2DContainer { xRef };
-}
+if(!aEmbeddingTransform.isIdentity())
+{
+const drawinglayer::primitive2d::Primitive2DReference xRef(
+new drawinglayer::primitive2d::TransformPrimitive2D(
+aEmbeddingTransform,
+std::move(aNewTarget)));
 
-if(!rRatio.isMeetOrSlice())
-{
-// need to embed in MaskPrimitive2D to ensure clipping
-const drawinglayer::primitive2d::Primitive2DReference 
xMask(
-new drawinglayer::primitive2d::MaskPrimitive2D(
-basegfx::B2DPolyPolygon(
-
basegfx::utils::createPolygonFromRect(aTarget)),
-std::move(aNewTarget)));
-
-aNewTarget = 
drawinglayer::primitive2d::Primitive2DContainer { xMask };
-}
+aNewTarget = drawinglayer::primitive2d::Primitive2DContainer { 
xRef };
+}
 
-// embed and add to rTarget, take local extra-transform into 
account
-pStyle->add_postProcess(rTarget, std::move(aNewTarget), 
getTransform());
+if(!rRatio.isMeetOrSlice())
+{
+// need to embed in 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-06-14 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   18 ++
 svgio/qa/cppunit/data/tdf155819.svg   |   15 +++
 svgio/source/svgreader/svgstyleattributes.cxx |5 +++--
 3 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit d3f0a59f3c47095d4b1d8c01b1316a7dc7f5467d
Author: Xisco Fauli 
AuthorDate: Wed Jun 14 01:10:50 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jun 14 08:08:28 2023 +0200

tdf#155819: check marker property comes from a style sheet

Since 242b7d0162d55be0945ca849c3de841fbf6cb475
"svgio: simplify code" where bIsInStyleSheet was replaced by
getCssStyleParent() incorrectly

Change-Id: I48632e9374f4615e32d18a141aeabec2936e6ec8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153031
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index ad5852127551..559af49af695 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -135,6 +135,24 @@ CPPUNIT_TEST_FIXTURE(Test, testSymbol)
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#00d000");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf155819)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155819.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 1);
+assertXPath(pDocument, 
"/primitive2D/transform/polypolygonstroke/polypolygon", 1);
+// Without the fix in place, this test would have failed with
+// - Expected: 4
+// - Actual  : 0
+assertXPath(pDocument, "/primitive2D/transform/transform", 4);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFilterLuminanceToAlpha)
 {
 Primitive2DSequence aSequenceTdf132246 = 
parseSvg(u"/svgio/qa/cppunit/data/filterLuminanceToAlpha.svg");
diff --git a/svgio/qa/cppunit/data/tdf155819.svg 
b/svgio/qa/cppunit/data/tdf155819.svg
new file mode 100644
index ..30c2da4d1a5a
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf155819.svg
@@ -0,0 +1,15 @@
+
+http://www.w3.org/2000/svg; viewBox="0 0 100 100">
+  
+path {
+  fill: none;
+  stroke-width: 4px;
+  marker: url(#diamond);
+}
+  
+  
+  
+
+  
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 99267c762dc5..5f3a3f4aea8a 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1151,7 +1151,7 @@ namespace svgio::svgreader
 if(SVGToken::Path == mrOwner.getType() || // path
 SVGToken::Polygon == mrOwner.getType() || // polygon, 
polyline
 SVGToken::Line == mrOwner.getType() ||// line
-getCssStyleParent())
+SVGToken::Style == mrOwner.getType())// tdf#150323
 {
 // try to add markers
 add_markers(rPath, rTarget, pHelpPointIndices);
@@ -1894,7 +1894,8 @@ namespace svgio::svgreader
 }
 case SVGToken::Marker:
 {
-if(getCssStyleParent())
+// tdf#155819: Using the marker property from a style 
sheet is equivalent to using all three (start, mid, end).
+if(mrOwner.getType() == SVGToken::Style)
 {
 readLocalUrl(aContent, maMarkerEndXLink);
 maMarkerStartXLink = maMarkerMidXLink = 
maMarkerEndXLink;


[Libreoffice-commits] core.git: svgio/qa svgio/source

2023-06-08 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   18 ++
 svgio/qa/cppunit/data/tdf155733.svg   |   20 
 svgio/source/svgreader/svgstyleattributes.cxx |   12 ++--
 3 files changed, 44 insertions(+), 6 deletions(-)

New commits:
commit 195364a57a5e3090648cb327607bc52da2be583c
Author: Xisco Fauli 
AuthorDate: Thu Jun 8 13:49:11 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 8 16:33:55 2023 +0200

tdf#155733: no need to store these values

Change-Id: I1c22f8f344731eb5fbc5f77fc80267ebcdc81ed6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152740
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 967bcc0275cf..ce4db97e0954 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -989,6 +989,24 @@ CPPUNIT_TEST_FIXTURE(Test, 
testBehaviourWhenWidthAndHeightIsOrIsNotSet)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf155733)
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155733.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/transform[1]/softedge", 
"radius", "5");
+
+// Without the fix in place, the softedge would have been applied to the 
second element
+// - Expected: 1
+// - Actual  : 0
+assertXPath(pDocument, 
"/primitive2D/transform/transform[2]/unifiedtransparence", "transparence", 
"50");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf97663)
 {
 Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/em_units.svg");
diff --git a/svgio/qa/cppunit/data/tdf155733.svg 
b/svgio/qa/cppunit/data/tdf155733.svg
new file mode 100644
index ..db04ba9afd21
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf155733.svg
@@ -0,0 +1,20 @@
+http://www.w3.org/2000/svg;
+  xmlns:xlink="http://www.w3.org/1999/xlink;>
+  
+
+  
+
+  
+
+  
+
+  
+
+  
+  
+
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index eda757af80d3..600f1690cb80 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2879,7 +2879,7 @@ namespace svgio::svgreader
 
 if(!aClipPath.isEmpty())
 {
-const_cast< SvgStyleAttributes* >(this)->mpClipPathXLink = 
dynamic_cast< const SvgClipPathNode* 
>(mrOwner.getDocument().findSvgNodeById(aClipPath));
+return dynamic_cast< const SvgClipPathNode* 
>(mrOwner.getDocument().findSvgNodeById(aClipPath));
 }
 }
 
@@ -2914,7 +2914,7 @@ namespace svgio::svgreader
 
 if(!aFilter.isEmpty())
 {
-const_cast< SvgStyleAttributes* >(this)->mpFilterXLink = 
dynamic_cast< const SvgFilterNode* 
>(mrOwner.getDocument().findSvgNodeById(aFilter));
+return dynamic_cast< const SvgFilterNode* 
>(mrOwner.getDocument().findSvgNodeById(aFilter));
 }
 }
 
@@ -2949,7 +2949,7 @@ namespace svgio::svgreader
 
 if(!aMask.isEmpty())
 {
-const_cast< SvgStyleAttributes* >(this)->mpMaskXLink = 
dynamic_cast< const SvgMaskNode* 
>(mrOwner.getDocument().findSvgNodeById(aMask));
+return dynamic_cast< const SvgMaskNode* 
>(mrOwner.getDocument().findSvgNodeById(aMask));
 }
 }
 
@@ -2984,7 +2984,7 @@ namespace svgio::svgreader
 
 if(!aMarker.isEmpty())
 {
-const_cast< SvgStyleAttributes* 
>(this)->mpMarkerStartXLink = dynamic_cast< const SvgMarkerNode* 
>(mrOwner.getDocument().findSvgNodeById(getMarkerStartXLink()));
+return dynamic_cast< const SvgMarkerNode* 
>(mrOwner.getDocument().findSvgNodeById(getMarkerStartXLink()));
 }
 }
 
@@ -3019,7 +3019,7 @@ namespace svgio::svgreader
 
 if(!aMarker.isEmpty())
 {
-const_cast< SvgStyleAttributes* >(this)->mpMarkerMidXLink 
= dynamic_cast< const SvgMarkerNode* 
>(mrOwner.getDocument().findSvgNodeById(getMarkerMidXLink()));
+return dynamic_cast< const SvgMarkerNode* 
>(mrOwner.getDocument().findSvgNodeById(getMarkerMidXLink()));
 }
 }
 
@@ -3054,7 +3054,7 @@ namespace svgio::svgreader
 
 if(!aMarker.isEmpty())
 {
-const_cast< SvgStyleAttributes* >(this)->mpMarkerEndXLink 
= dynamic_cast< const SvgMarkerNode* 
>(mrOwner.getDocument().findSvgNodeById(getMarkerEndXLink()));
+return dynamic_cast< const 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-09-23 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx |2 +-
 svgio/qa/cppunit/data/textXmlSpace.svg |4 ++--
 svgio/source/svgreader/svgtools.cxx|8 +++-
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 5e6b02055a887bc49c5252c1ae359ae96947e80c
Author: Xisco Fauli 
AuthorDate: Fri Sep 23 13:25:06 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Sep 23 14:20:12 2022 +0200

tdf#151118: don't trim leading/trailing spaces in 'preserve' case

Thanks again to Mike Kaganski for spotting

Change-Id: Ifd8dcf15d7714ebc4f19083fefe0d78d27d46b4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140483
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index d2cc7bd90828..9d9fb93dc8c1 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -437,7 +437,7 @@ void Test::testTextXmlSpace()
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", 
"text", "a b");
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", 
"text", "a b");
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", 
"text", "ab");
-assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", 
"text", "a  b");
+assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", 
"text", " a  b ");
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[6]", 
"text", "a b");
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[7]", 
"text", "a   b");
 assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[8]", 
"text", "a b");
diff --git a/svgio/qa/cppunit/data/textXmlSpace.svg 
b/svgio/qa/cppunit/data/textXmlSpace.svg
index f200d74dd3f3..fe1bc8ceeb79 100644
--- a/svgio/qa/cppunit/data/textXmlSpace.svg
+++ b/svgio/qa/cppunit/data/textXmlSpace.svg
@@ -1,12 +1,12 @@
 http://www.w3.org/2000/svg; version="1.1"
viewBox="0 0 250 250">
-  a  b
+   a  b 
   a   b
   a
   b
   a
 b
-  a  b
+   a  b 
   a b
   a
   b
diff --git a/svgio/source/svgreader/svgtools.cxx 
b/svgio/source/svgreader/svgtools.cxx
index eeca00ac3330..02a37dc0e8b4 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1525,13 +1525,11 @@ namespace svgio::svgreader
 // convert tab to space
 aRetval = convert(aRetval, aTab, aSpace, false);
 
-// strip of all leading and trailing spaces
-aRetval = aRetval.trim();
-
 if(bIsDefault)
 {
-// consolidate contiguous space
-aRetval = consolidateContiguousSpace(aRetval);
+// strip of all leading and trailing spaces
+// and consolidate contiguous space
+aRetval = consolidateContiguousSpace(aRetval.trim());
 }
 
 return aRetval;


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-08-11 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   24 
 svgio/qa/cppunit/data/markerInCssStyle.svg|   14 ++
 svgio/source/svgreader/svgstyleattributes.cxx |3 ++-
 3 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit cad5220c707ab7483e9146182e3353146ae24d41
Author: Xisco Fauli 
AuthorDate: Wed Aug 10 14:58:28 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Aug 11 13:03:06 2022 +0200

tdf#150323: also add markers if there is a css style parent

Change-Id: Ia900726ee31b7b19e98122d40b33581c9a60dcc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138090
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 8037f850768a..7db9c8335b1f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -47,6 +47,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testFontsizeRelative();
 void testMarkerOrient();
 void testMarkerInPresentation();
+void testMarkerInCssStyle();
 void testTdf45771();
 void testTdf97941();
 void testTdf104339();
@@ -94,6 +95,7 @@ public:
 CPPUNIT_TEST(testFontsizeRelative);
 CPPUNIT_TEST(testMarkerOrient);
 CPPUNIT_TEST(testMarkerInPresentation);
+CPPUNIT_TEST(testMarkerInCssStyle);
 CPPUNIT_TEST(testTdf45771);
 CPPUNIT_TEST(testTdf97941);
 CPPUNIT_TEST(testTdf104339);
@@ -394,6 +396,28 @@ void Test::testMarkerInPresentation()
 assertXPath(pDocument, "/primitive2D/transform/transform/transform", 0);
 }
 
+void Test::testMarkerInCssStyle()
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/markerInCssStyle.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 20
+// - Actual  : 0
+assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/line", 20);
+
+assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "color", 
"#008000");
+assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "width", "1");
+assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "linejoin", 
"Miter");
+assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "miterangle", 
"28");
+assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "linecap", 
"BUTT");
+}
+
 void Test::testTdf45771()
 {
 //Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/markerInCssStyle.svg 
b/svgio/qa/cppunit/data/markerInCssStyle.svg
new file mode 100644
index ..a7a8374f6ee3
--- /dev/null
+++ b/svgio/qa/cppunit/data/markerInCssStyle.svg
@@ -0,0 +1,14 @@
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink;>
+
+
+   
+
+
+
+
+path.boundary {stroke: red; fill: #ccc; stroke-width: 3; marker-mid: 
url(#bip); marker-end: url(#bip)}
+
+
+
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index c787c4dffa92..32fed8b8daff 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1149,7 +1149,8 @@ namespace svgio::svgreader
 // Svg supports markers for path, polygon, polyline and line
 if(SVGToken::Path == mrOwner.getType() || // path
 SVGToken::Polygon == mrOwner.getType() || // polygon, 
polyline
-SVGToken::Line == mrOwner.getType())  // line
+SVGToken::Line == mrOwner.getType() ||// line
+getCssStyleParent())
 {
 // try to add markers
 add_markers(rPath, rTarget, pHelpPointIndices);


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-07-18 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   16 
 svgio/qa/cppunit/data/ClipPathUsingClipPath.svg |   24 
 svgio/source/svgreader/svgstyleattributes.cxx   |3 ++-
 3 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 47c428537154cd94b1d9a7547bde21ce711abd0d
Author: Xisco Fauli 
AuthorDate: Mon Jul 18 13:21:35 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 18 21:59:57 2022 +0200

related: tdf#97539: SVGIO: iterate over parent's clippaths

This commit reintroduces fb33451a27d8668bc14f5bcfd6ea742fc4c5b84c
"tdf#97539: SVGIO: iterate over parent's clippaths" which I
reverted it in 82c0a363abbceac6464b62c3571aa3225415c7db
"tdf#97539; if parent is css style, look one level up" because
I thought it was no longer necessary, but I was wrong.
Also add a unittest

Change-Id: Ib66ca0afd63e8e52be6677b6965179e092a61aa8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137195
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 97ee9aa35351..c25ae86cf7f3 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -64,6 +64,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testClipPathAndParentStyle();
 void testClipPathAndStyle();
 void testShapeWithClipPath();
+void testClipPathUsingClipPath();
 void testi125329();
 void testMaskingPath07b();
 void test123926();
@@ -108,6 +109,7 @@ public:
 CPPUNIT_TEST(testClipPathAndParentStyle);
 CPPUNIT_TEST(testClipPathAndStyle);
 CPPUNIT_TEST(testShapeWithClipPath);
+CPPUNIT_TEST(testClipPathUsingClipPath);
 CPPUNIT_TEST(testi125329);
 CPPUNIT_TEST(testMaskingPath07b);
 CPPUNIT_TEST(test123926);
@@ -685,6 +687,20 @@ void Test::testShapeWithClipPath()
 assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygoncolor/polypolygon/polygon", 1);
 }
 
+void Test::testClipPathUsingClipPath()
+{
+Primitive2DSequence aSequenceClipPathAndStyle = 
parseSvg(u"/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg");
+CPPUNIT_ASSERT_EQUAL(1, 
static_cast(aSequenceClipPathAndStyle.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/mask/polypolygon/polygon/point", 20);
+assertXPath(pDocument, 
"/primitive2D/transform/mask/mask/polypolygon/polygon/point", 13);
+}
+
 void Test::testi125329()
 {
 //Check style inherit from * css element
diff --git a/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg 
b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg
new file mode 100644
index ..5eaa7928cb85
--- /dev/null
+++ b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg
@@ -0,0 +1,24 @@
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink;>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 6b676cd952f7..6ad1b1d25cc2 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1196,10 +1196,11 @@ namespace svgio::svgreader
 }
 
 const SvgClipPathNode* pClip = accessClipPathXLink();
-if(pClip)
+while(pClip)
 {
 // #i124852# transform may be needed when 
SvgUnits::userSpaceOnUse
 pClip->apply(aSource, pTransform);
+pClip = pClip->getSvgStyleAttributes()->accessClipPathXLink();
 }
 
 if(!aSource.empty()) // test again, applied clipPath may have lead 
to empty geometry


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-07-18 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx   |   19 +++
 svgio/qa/cppunit/data/symbol.svg |   11 +++
 svgio/source/svgreader/svgsymbolnode.cxx |2 +-
 3 files changed, 31 insertions(+), 1 deletion(-)

New commits:
commit 67c422585db43e30f0c9e4c9753fcd14f87a277f
Author: Xisco Fauli 
AuthorDate: Mon Jul 18 16:50:36 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 18 21:59:29 2022 +0200

tdf#126330: use correct type for symbol node

Change-Id: Ibd4b7e021dac28469cb3ea2d30e79de8f24c88be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137201
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 4724b3a6c8eb..97ee9aa35351 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -40,6 +40,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void checkRectPrimitive(Primitive2DSequence const & rPrimitive);
 
 void testStyles();
+void testSymbol();
 void testTdf87309();
 void testFontsizeKeywords();
 void testFontsizePercentage();
@@ -83,6 +84,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 public:
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testStyles);
+CPPUNIT_TEST(testSymbol);
 CPPUNIT_TEST(testTdf87309);
 CPPUNIT_TEST(testFontsizeKeywords);
 CPPUNIT_TEST(testFontsizePercentage);
@@ -198,6 +200,23 @@ void Test::testStyles()
 CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, 
aSequenceRectWithStylesByGroup));
 }
 
+void Test::testSymbol()
+{
+Primitive2DSequence aSequenceTdf87309 = 
parseSvg(u"/svgio/qa/cppunit/data/symbol.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf87309.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309);
+
+CPPUNIT_ASSERT (pDocument);
+
+// tdf#126330: Without the fix in place, this test would have failed with
+// - Expected: 1
+// - Actual  : 2
+// number of nodes is incorrect
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#00d000");
+}
+
 void Test::testTdf87309()
 {
 Primitive2DSequence aSequenceTdf87309 = 
parseSvg(u"/svgio/qa/cppunit/data/tdf87309.svg");
diff --git a/svgio/qa/cppunit/data/symbol.svg b/svgio/qa/cppunit/data/symbol.svg
new file mode 100644
index ..55110f3740b0
--- /dev/null
+++ b/svgio/qa/cppunit/data/symbol.svg
@@ -0,0 +1,11 @@
+
+http://www.w3.org/2000/svg;>
+
+  
+  
+  
+
+  
+
diff --git a/svgio/source/svgreader/svgsymbolnode.cxx 
b/svgio/source/svgreader/svgsymbolnode.cxx
index b92bde34a5fe..196c83a64db4 100644
--- a/svgio/source/svgreader/svgsymbolnode.cxx
+++ b/svgio/source/svgreader/svgsymbolnode.cxx
@@ -24,7 +24,7 @@ namespace svgio::svgreader
 SvgSymbolNode::SvgSymbolNode(
 SvgDocument& rDocument,
 SvgNode* pParent)
-:   SvgNode(SVGToken::Svg, rDocument, pParent),
+:   SvgNode(SVGToken::Symbol, rDocument, pParent),
 maSvgStyleAttributes(*this)
 {
 }


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-07-08 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx |   22 ++
 svgio/qa/cppunit/data/markerInPresentation.svg |   12 
 svgio/source/svgreader/svgstyleattributes.cxx  |4 ++--
 3 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit c1c8ce3b0f1037bca4d500af2f39363cd9d38db6
Author: Xisco Fauli 
AuthorDate: Fri Jul 8 18:14:36 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 8 19:58:51 2022 +0200

svgio: Rename variable and add unittest

The meaning of the name got obsolete after
cded65d05a01ac34af750ddb97f1ffb51f3d638a
< tdf#149893: Color names are ASCII case-insensitive >

Also add a unittest for 9b0069c2833313ba9fab91f45edd354ba334f94b
"SVG: Using the marker property from a style sheet is equivalent
to using all three (start, mid, end).·" when this code was added

Change-Id: I87e0866cbd56bbc770920b0778ce681ac9d255b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136910
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 1ce9b2e0fbfe..3165d596e333 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -45,6 +45,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testFontsizePercentage();
 void testFontsizeRelative();
 void testMarkerOrient();
+void testMarkerInPresentation();
 void testTdf45771();
 void testTdf97941();
 void testTdf104339();
@@ -85,6 +86,7 @@ public:
 CPPUNIT_TEST(testFontsizePercentage);
 CPPUNIT_TEST(testFontsizeRelative);
 CPPUNIT_TEST(testMarkerOrient);
+CPPUNIT_TEST(testMarkerInPresentation);
 CPPUNIT_TEST(testTdf45771);
 CPPUNIT_TEST(testTdf97941);
 CPPUNIT_TEST(testTdf104339);
@@ -343,6 +345,26 @@ void Test::testMarkerOrient()
 assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy33", "1");
 }
 
+void Test::testMarkerInPresentation()
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/markerInPresentation.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/line", 1);
+assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/polypolygon/polygon", 1);
+assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/polypolygon/polygon", 1);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 0
+// - Actual  : 2
+assertXPath(pDocument, "/primitive2D/transform/transform/transform", 0);
+}
+
 void Test::testTdf45771()
 {
 //Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/markerInPresentation.svg 
b/svgio/qa/cppunit/data/markerInPresentation.svg
new file mode 100644
index ..5071544e39fd
--- /dev/null
+++ b/svgio/qa/cppunit/data/markerInPresentation.svg
@@ -0,0 +1,12 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink;>
+
+  
+
+  
+
+
+  
+
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 70b019594248..f4f48e37d2c6 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1299,7 +1299,7 @@ namespace svgio::svgreader
 void SvgStyleAttributes::parseStyleAttribute(
 SVGToken aSVGToken,
 const OUString& aContent,
-bool bCaseIndependent)
+bool bIsInStyleSheet)
 {
 switch(aSVGToken)
 {
@@ -1876,7 +1876,7 @@ namespace svgio::svgreader
 }
 case SVGToken::Marker:
 {
-if(bCaseIndependent)
+if(bIsInStyleSheet)
 {
 readLocalUrl(aContent, maMarkerEndXLink);
 maMarkerStartXLink = maMarkerMidXLink = 
maMarkerEndXLink;


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-07-08 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/data/tdf149893.svg |2 +-
 svgio/source/svgreader/svgtools.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit a3e9fede7e998979db7941a527496eb98c822e98
Author: Xisco Fauli 
AuthorDate: Fri Jul 8 12:12:54 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 8 13:54:09 2022 +0200

related: tdf#149893: trim the color name

Change-Id: I50689993cbe979557a10d2d16eb2112471bef77d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136895
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/data/tdf149893.svg 
b/svgio/qa/cppunit/data/tdf149893.svg
index 05c41eac96af..b6b241566d13 100644
--- a/svgio/qa/cppunit/data/tdf149893.svg
+++ b/svgio/qa/cppunit/data/tdf149893.svg
@@ -1,3 +1,3 @@
 http://www.w3.org/2000/svg;>
-  
+  
 
diff --git a/svgio/source/svgreader/svgtools.cxx 
b/svgio/source/svgreader/svgtools.cxx
index c73d4c768451..c559bd620fbf 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -640,7 +640,7 @@ namespace svgio::svgreader
 { ColorTokenValueType(OUString("yellowgreen"), Color(154, 205, 
50) ) },
 };
 
-ColorTokenMapper::const_iterator 
aResult(aColorTokenMapperList.find(rName.toAsciiLowerCase()));
+ColorTokenMapper::const_iterator 
aResult(aColorTokenMapperList.find(rName.toAsciiLowerCase().trim()));
 
 if(aResult == aColorTokenMapperList.end())
 {


[Libreoffice-commits] core.git: svgio/qa svgio/source

2022-07-06 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx  |   22 ++
 svgio/qa/cppunit/data/tdf149880.svg |   11 +++
 svgio/source/svgreader/svgtools.cxx |   13 +++--
 3 files changed, 44 insertions(+), 2 deletions(-)

New commits:
commit d291957dce7a5af17717125cce974a2d2dd9d5b0
Author: Xisco Fauli 
AuthorDate: Wed Jul 6 16:52:38 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 6 20:34:03 2022 +0200

tdf#149880: handle url when it's inside the quotation marks

Change-Id: I053323f9b48c8856d520095da0a4768ac03b0176
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136847
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 4b5af1e54d84..5c041ac3b386 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testTdf94765();
 void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
 void testTdf97663();
+void testTdf149880();
 void testCssClassRedefinition();
 
 Primitive2DSequence parseSvg(std::u16string_view aSource);
@@ -107,6 +108,7 @@ public:
 CPPUNIT_TEST(testTdf94765);
 CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
 CPPUNIT_TEST(testTdf97663);
+CPPUNIT_TEST(testTdf149880);
 CPPUNIT_TEST(testCssClassRedefinition);
 CPPUNIT_TEST_SUITE_END();
 };
@@ -835,6 +837,26 @@ void Test::testTdf97663()
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", 
"236");
 }
 
+void Test::testTdf149880()
+{
+Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+
+drawinglayer::Primitive2dXmlDump dumper;
+xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+CPPUNIT_ASSERT (pDocument);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 1
+// - Actual  : 0
+// - In <>, XPath '/primitive2D/transform/mask/unhandled' number of nodes 
is incorrect
+assertXPath(pDocument,
+"/primitive2D/transform/mask/unhandled", "id", "PATTERNFILL");
+assertXPath(pDocument,
+
"/primitive2D/transform/mask/unhandled/mask/transform/transform/bitmap", 28);
+}
+
 void Test::testCssClassRedefinition()
 {
 // Tests for svg css class redefinition behavior
diff --git a/svgio/qa/cppunit/data/tdf149880.svg 
b/svgio/qa/cppunit/data/tdf149880.svg
new file mode 100644
index ..08ba748487cb
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf149880.svg
@@ -0,0 +1,11 @@
+
+http://www.w3.org/2000/svg; version="1.1">
+  
+
+  
+
+
+  
+
+  
+
diff --git a/svgio/source/svgreader/svgtools.cxx 
b/svgio/source/svgreader/svgtools.cxx
index 9ba7f1d47952..4ae287784d8c 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1072,9 +1072,18 @@ namespace svgio::svgreader
 const sal_Int32 nLen(rCandidate.getLength());
 sal_Int32 nPos(strlen(aStrUrl));
 
-skip_char(rCandidate, '(', '#', nPos, nLen);
+skip_char(rCandidate, '(', nPos, nLen);
+sal_Unicode aLimiter(')');
+
+if('"' == rCandidate[nPos])
+aLimiter = '"';
+
+skip_char(rCandidate, '"', nPos, nLen);
+skip_char(rCandidate, '#', nPos, nLen);
 OUStringBuffer aTokenValue;
-copyToLimiter(rCandidate, ')', nPos, aTokenValue, nLen);
+
+copyToLimiter(rCandidate, aLimiter, nPos, aTokenValue, nLen);
+
 rURL = aTokenValue.makeStringAndClear();
 
 return true;


[Libreoffice-commits] core.git: svgio/qa svgio/source

2019-09-19 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx|   15 +++
 svgio/qa/cppunit/data/tdf123926.svg   |   14 ++
 svgio/source/svgreader/svgstyleattributes.cxx |   13 +
 3 files changed, 42 insertions(+)

New commits:
commit 586de7ac433dca98edf4a5a3d13b5e393b9880ed
Author: Xisco Fauli 
AuthorDate: Thu Sep 19 16:08:59 2019 +0200
Commit: Xisco Faulí 
CommitDate: Thu Sep 19 21:57:24 2019 +0200

tdf#123926: SVGIO: Check parent's fill when...

... the element is a clippath and fill=none

fill="none" is created as SvgPaint(aColor, true, false, false)
in svgtools.cxx meaning bSet = true, bCurrent = False and
bOn = False, so it never checks its parent if it's a clippath

Change-Id: Ia8c556674809b2b86280219e4084550e366bbff8
Reviewed-on: https://gerrit.libreoffice.org/79201
Tested-by: Jenkins
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 5f714e98b4e7..aee83b05d440 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -59,6 +59,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testClipPathAndStyle();
 void testi125329();
 void testMaskingPath07b();
+void test123926();
 void test47446();
 void test47446b();
 void testMaskText();
@@ -92,6 +93,7 @@ public:
 CPPUNIT_TEST(testClipPathAndStyle);
 CPPUNIT_TEST(testi125329);
 CPPUNIT_TEST(testMaskingPath07b);
+CPPUNIT_TEST(test123926);
 CPPUNIT_TEST(test47446);
 CPPUNIT_TEST(test47446b);
 CPPUNIT_TEST(testMaskText);
@@ -562,6 +564,19 @@ void Test::testMaskingPath07b()
 
 }
 
+void Test::test123926()
+{
+Primitive2DSequence aSequence123926 = 
parseSvg("/svgio/qa/cppunit/data/tdf123926.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence123926.getLength()));
+
+drawinglayer::tools::Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence123926));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/transform/transform/unifiedtransparence/polypolygoncolor",
 "color", "#7cb5ec");
+}
+
 void Test::test47446()
 {
 //Check that marker's fill attribute is black is not set
diff --git a/svgio/qa/cppunit/data/tdf123926.svg 
b/svgio/qa/cppunit/data/tdf123926.svg
new file mode 100644
index ..1a5c2758aab4
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf123926.svg
@@ -0,0 +1,14 @@
+
+http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;>
+http://www.w3.org/1999/xlink; 
xmlns="http://www.w3.org/2000/svg; version="1.1" class="highcharts-root" 
style="font-family:Lucida Grande, Lucida Sans Unicode, 
Arial, Helvetica, sans-serif;font-size:12px;" width="600" height="400" 
viewBox="0 0 600 400">
+  
+
+  
+
+  
+  
+
+  
+
+  
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 5cda5995e82f..bd882e0e24c7 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2006,6 +2006,19 @@ namespace svgio
 {
 return ();
 }
+else if(mbIsClipPathContent)
+{
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if (pSvgStyleAttributes && maResolvingParent[0] < 
nStyleDepthLimit)
+{
+++maResolvingParent[0];
+const basegfx::BColor* pFill = 
pSvgStyleAttributes->getFill();
+--maResolvingParent[0];
+
+return pFill;
+}
+}
 }
 else if (!mpSvgGradientNodeFill && !mpSvgPatternNodeFill)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: svgio/qa svgio/source

2019-09-16 Thread Xisco Fauli (via logerrit)
 svgio/qa/cppunit/SvgImportTest.cxx |   68 -
 svgio/qa/cppunit/data/tdf99115.svg |   40 +
 svgio/source/svgreader/svgnode.cxx |   18 +++--
 3 files changed, 112 insertions(+), 14 deletions(-)

New commits:
commit 4007ced54d611d1397387f7329a47de5efaca32f
Author: Xisco Fauli 
AuthorDate: Mon Sep 16 12:54:59 2019 +0200
Commit: Xisco Faulí 
CommitDate: Mon Sep 16 15:38:36 2019 +0200

tdf#99115: add Css selector '*' style only if the element...

... is on top of the hierarchy

Otherwise, we add it for every element on the hierarchy

Adapt unittest from 
https://bugs.documentfoundation.org/show_bug.cgi?id=100198
Provided by Sam Yygier

Change-Id: I72c7ae08f3ce0194eff86697b202d5553810abeb
Reviewed-on: https://gerrit.libreoffice.org/78997
Tested-by: Jenkins
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 501df9c21ea1..4fe57b9adc3d 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -62,6 +62,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void test47446b();
 void testMaskText();
 void testTdf4();
+void testTdf99115();
 void testTdf101237();
 void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
 
@@ -92,6 +93,7 @@ public:
 CPPUNIT_TEST(test47446b);
 CPPUNIT_TEST(testMaskText);
 CPPUNIT_TEST(testTdf4);
+CPPUNIT_TEST(testTdf99115);
 CPPUNIT_TEST(testTdf101237);
 CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
 CPPUNIT_TEST_SUITE_END();
@@ -519,15 +521,15 @@ void Test::testi125329()
 
 CPPUNIT_ASSERT (pDocument);
 
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor", "color", "#c0c0c0"); // 
rect background color
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "height", 
"30"); // rect background height
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "width", 
"50"); // rect background width
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "minx", "15");
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "miny", "15");
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "maxx", "65");
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygoncolor/polypolygon", "maxy", "45");
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/line", "color", "#008000"); 
// rect stroke color
-assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/line", "width", "1"); // 
rect stroke width
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor", "color", 
"#c0c0c0"); // rect background color
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"height", "30"); // rect background height
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"width", "50"); // rect background width
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"minx", "15");
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"miny", "15");
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"maxx", "65");
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", 
"maxy", "45");
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "color", 
"#008000"); // rect stroke color
+assertXPath(pDocument, 
"/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "width", 
"1"); // rect stroke width
 }
 
 void Test::testMaskingPath07b()
@@ -609,6 +611,54 @@ void Test::testTdf4()
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", "Sans");
 }
 
+void Test::testTdf99115()
+{
+//Check that styles are resolved correctly where there is a * css selector
+Primitive2DSequence aSequenceTdf99115 = 
parseSvg("/svgio/qa/cppunit/data/tdf99115.svg");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf99115.getLength()));
+
+drawinglayer::tools::Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf99115)
 );
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", "red 1");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"fontcolor", "#ff");
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "18");

[Libreoffice-commits] core.git: svgio/qa svgio/source

2018-05-13 Thread Tomaž Vajngerl
 svgio/qa/cppunit/SvgImportTest.cxx|   66 +-
 svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg   |   12 
 svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg |   14 
 svgio/source/svgreader/svgsvgnode.cxx |   51 +++--
 4 files changed, 124 insertions(+), 19 deletions(-)

New commits:
commit 7e6dac4edce063a766497ecb498e293bf4e16e66
Author: Tomaž Vajngerl 
Date:   Sun May 13 20:21:17 2018 +0900

svgio: fix rendering when the width/height isn't present in SVG

The general size of the image should be the same when width/height
attributes are present. It is very wrong to assume the size of the
image is the area covered by all the primitives in the image.

Change-Id: I56f241e84dee37796f9804ce2569c4eb416e83a0
Reviewed-on: https://gerrit.libreoffice.org/54191
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index a83ec4aae189..6b71a0dfeb7a 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -27,11 +27,13 @@
 namespace
 {
 
+using namespace css;
 using namespace css::uno;
 using namespace css::io;
 using namespace css::graphic;
 using drawinglayer::primitive2d::Primitive2DSequence;
 using drawinglayer::primitive2d::Primitive2DContainer;
+using drawinglayer::primitive2d::Primitive2DReference;
 
 class Test : public test::BootstrapFixture, public XmlTestTools
 {
@@ -61,6 +63,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testMaskText();
 void testTdf4();
 void testTdf101237();
+void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
 
 Primitive2DSequence parseSvg(const OUString& aSource);
 
@@ -90,6 +93,7 @@ public:
 CPPUNIT_TEST(testMaskText);
 CPPUNIT_TEST(testTdf4);
 CPPUNIT_TEST(testTdf101237);
+CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -132,7 +136,6 @@ void Test::checkRectPrimitive(Primitive2DSequence const & 
rPrimitive)
 
 }
 
-
 bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const 
Primitive2DSequence& rB)
 {
 const sal_Int32 nCount(rA.getLength());
@@ -629,7 +632,68 @@ void Test::testTdf101237()
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#ff");
 assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"color", "#00");
 assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "5");
+}
+
+void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet()
+{
+// This test checks the behaviour when width and height attributes
+// are and are not set. In both cases the result must be the same,
+// however if the width / height are set, then the size of the image
+// is enforced, but this isn't really possible in LibreOffice (or
+// maybe we could lock the size in this case).
+// The behaviour in browsers is that when a SVG image has width / height
+// attributes set, then the image is shown with that size, but if it
+// isn't set then it is shown as scalable image which is the size of
+// the container.
+
+{
+Primitive2DSequence aSequence = 
parseSvg("svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg");
+CPPUNIT_ASSERT(aSequence.hasElements());
+
+geometry::RealRectangle2D aRealRect;
+basegfx::B2DRange aRange;
+uno::Sequence aViewParameters;
+
+for (Primitive2DReference const & xReference : aSequence)
+{
+if (xReference.is())
+{
+aRealRect = xReference->getRange(aViewParameters);
+aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, 
aRealRect.X2, aRealRect.Y2));
+}
+}
+
+double fWidth = (aRange.getWidth() / 2540.0) * 96.0;
+double fHeight = (aRange.getHeight() / 2540.0) * 96.0;
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fHeight, 1E-12);
+}
+
+{
+Primitive2DSequence aSequence = 
parseSvg("svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg");
+CPPUNIT_ASSERT(aSequence.hasElements());
 
+
+geometry::RealRectangle2D aRealRect;
+basegfx::B2DRange aRange;
+uno::Sequence aViewParameters;
+
+for (Primitive2DReference const & xReference : aSequence)
+{
+if (xReference.is())
+{
+aRealRect = xReference->getRange(aViewParameters);
+aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, 
aRealRect.X2, aRealRect.Y2));
+}
+}
+
+double fWidth = (aRange.getWidth() / 2540.0) * 96.0;
+double fHeight = (aRange.getHeight() / 2540.0) * 96.0;
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2016-08-30 Thread Xisco Fauli
 svgio/qa/cppunit/SvgImportTest.cxx|   20 
 svgio/qa/cppunit/data/tdf101237.svg   |   11 +++
 svgio/source/svgreader/svgstyleattributes.cxx |   24 ++--
 3 files changed, 49 insertions(+), 6 deletions(-)

New commits:
commit 75003438e4b429ffb3f013afd0e36d70545833cc
Author: Xisco Fauli 
Date:   Tue Aug 30 16:21:52 2016 +0200

tdf#101237 SVGIO: Use black as default when parents' fill...

...attributes are empty or none and there's a reference
to a clip-path present.

Change-Id: I4dc4e3bcaac43a007fbdb8a1d006cbd39c737396
Reviewed-on: https://gerrit.libreoffice.org/28500
Tested-by: Jenkins 
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 218f9e8..8bded0f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -61,6 +61,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void test47446b();
 void testMaskText();
 void testTdf4();
+void testTdf101237();
 
 Primitive2DSequence parseSvg(const char* aSource);
 
@@ -91,6 +92,7 @@ public:
 CPPUNIT_TEST(test47446b);
 CPPUNIT_TEST(testMaskText);
 CPPUNIT_TEST(testTdf4);
+CPPUNIT_TEST(testTdf101237);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -620,6 +622,24 @@ void Test::testTdf4()
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", "Sans");
 }
 
+void Test::testTdf101237()
+{
+//Check that fill color, stroke color and stroke-width are inherited from 
use element
+//when the element is within a clipPath element
+Primitive2DSequence aSequenceTdf101237 = 
parseSvg("/svgio/qa/cppunit/data/tdf101237.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceTdf101237.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf101237));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"color", "#00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "5");
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/tdf101237.svg 
b/svgio/qa/cppunit/data/tdf101237.svg
new file mode 100644
index 000..e5afa37
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf101237.svg
@@ -0,0 +1,11 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; fill="none">
+
+  
+
+  
+  
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 9fc8b23..cc66af5a 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2007,14 +2007,26 @@ namespace svgio
 
 if(pSvgStyleAttributes)
 {
-return pSvgStyleAttributes->getFill();
+const basegfx::BColor* pFill = 
pSvgStyleAttributes->getFill();
+
+if(mbIsClipPathContent)
+{
+if (pFill)
+{
+return pFill;
+}
+else
+{
+static basegfx::BColor aBlack(0.0, 0.0, 0.0);
+return 
+}
+}
+else
+{
+return pFill;
+}
 }
 }
-else if(mbIsClipPathContent)
-{
-static basegfx::BColor aBlack(0.0, 0.0, 0.0);
-return 
-}
 
 return nullptr;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svgio/qa svgio/source

2016-03-29 Thread Xisco Fauli
 svgio/qa/cppunit/SvgImportTest.cxx|   21 
 svgio/qa/cppunit/data/ClipPathAndStyle.svg|   13 ++
 svgio/source/svgreader/svgstyleattributes.cxx |  128 --
 3 files changed, 54 insertions(+), 108 deletions(-)

New commits:
commit 3041df16f8315859ddf22075eac8f9ad4fa37b8e
Author: Xisco Fauli 
Date:   Mon Mar 28 19:24:29 2016 +0200

SVGIO: Don't inherit style attributes from parent if the...

... shapes define their own attributes.

Partially revert commit c2d130425cc876cceb96cc7e47636426a9e48fa8

Change-Id: Iee98003f4ff63575a28818b091ab77431337192f
Reviewed-on: https://gerrit.libreoffice.org/23571
Tested-by: Jenkins 
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index c4b681b..046d905 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -54,6 +54,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testRGBAColor();
 void testTdf97936();
 void testClipPathAndParentStyle();
+void testClipPathAndStyle();
 
 Primitive2DSequence parseSvg(const char* aSource);
 
@@ -78,6 +79,7 @@ public:
 CPPUNIT_TEST(testRGBAColor);
 CPPUNIT_TEST(testTdf97936);
 CPPUNIT_TEST(testClipPathAndParentStyle);
+CPPUNIT_TEST(testClipPathAndStyle);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -423,6 +425,25 @@ void Test::testClipPathAndParentStyle()
 assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "5");
 
 }
+
+void Test::testClipPathAndStyle()
+{
+//Check that fill color, stroke color and stroke-width are inherited from 
use element
+//when the element is within a clipPath element
+Primitive2DSequence aSequenceClipPathAndStyle = 
parseSvg("/svgio/qa/cppunit/data/ClipPathAndStyle.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceClipPathAndStyle.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceClipPathAndStyle));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"color", "#cc");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "2");
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/ClipPathAndStyle.svg 
b/svgio/qa/cppunit/data/ClipPathAndStyle.svg
new file mode 100644
index 000..29814fa
--- /dev/null
+++ b/svgio/qa/cppunit/data/ClipPathAndStyle.svg
@@ -0,0 +1,13 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink;>
+  
+
+  
+
+  
+
+
\ No newline at end of file
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 6b768f0..e04999d 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1954,19 +1954,7 @@ namespace svgio
 
 const basegfx::BColor* SvgStyleAttributes::getFill() const
 {
-if(mbIsClipPathContent)
-{
-const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
-
-if(pSvgStyleAttributes)
-{
-return pSvgStyleAttributes->getFill();
-}
-
-static basegfx::BColor aBlack(0.0, 0.0, 0.0);
-return 
-}
-else if((SVGTokenMarker == mrOwner.getType()) && !maFill.isSet())
+if((SVGTokenMarker == mrOwner.getType()) && !maFill.isSet())
 {
 const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
 
@@ -1998,24 +1986,18 @@ namespace svgio
 return pSvgStyleAttributes->getFill();
 }
 }
+else if(mbIsClipPathContent)
+{
+static basegfx::BColor aBlack(0.0, 0.0, 0.0);
+return 
+}
 
 return nullptr;
 }
 
 const basegfx::BColor* SvgStyleAttributes::getStroke() const
 {
-if(mbIsClipPathContent)
-{
-const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
-
-if(pSvgStyleAttributes)
-{
-return pSvgStyleAttributes->getStroke();
-}
-
-return nullptr;
-}
-else if(maStroke.isSet())
+if(maStroke.isSet())
 {
 if(maStroke.isCurrent())
 {
@@ -2053,18 +2035,7 @@ namespace svgio
 
 const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeFill() 
const
 {
-if(mbIsClipPathContent)
-{
-const 

[Libreoffice-commits] core.git: svgio/qa svgio/source

2016-03-26 Thread Xisco Fauli
 svgio/qa/cppunit/SvgImportTest.cxx   |   20 +++
 svgio/qa/cppunit/data/ClipPathAndParentStyle.svg |   10 +++
 svgio/source/svgreader/svgstyleattributes.cxx|   62 +++
 3 files changed, 92 insertions(+)

New commits:
commit c2d130425cc876cceb96cc7e47636426a9e48fa8
Author: Xisco Fauli 
Date:   Sat Mar 26 16:23:23 2016 +0100

SVGIO: Shapes within a clippath element might inherit...

... fill, stroke, stroke-width and others attributes from
parent element, like use element

Change-Id: I911bc50409428e81135b81e6dfc82acd1c21d113
Reviewed-on: https://gerrit.libreoffice.org/23527
Tested-by: Jenkins 
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index feea817..c4b681b 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testRGBColor();
 void testRGBAColor();
 void testTdf97936();
+void testClipPathAndParentStyle();
 
 Primitive2DSequence parseSvg(const char* aSource);
 
@@ -76,6 +77,7 @@ public:
 CPPUNIT_TEST(testRGBColor);
 CPPUNIT_TEST(testRGBAColor);
 CPPUNIT_TEST(testTdf97936);
+CPPUNIT_TEST(testClipPathAndParentStyle);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -403,6 +405,24 @@ void Test::testTdf97936()
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"maxx", "60");
 assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"maxy", "100");
 }
+
+void Test::testClipPathAndParentStyle()
+{
+//Check that fill color, stroke color and stroke-width are inherited from 
use element
+//when the element is within a clipPath element
+Primitive2DSequence aSequenceClipPathAndParentStyle = 
parseSvg("/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceClipPathAndParentStyle.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceClipPathAndParentStyle));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#ff");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"color", "#00");
+assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", 
"width", "5");
+
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg 
b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg
new file mode 100644
index 000..d85a959
--- /dev/null
+++ b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg
@@ -0,0 +1,10 @@
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink;>
+  
+
+  
+
+  
+
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index b60d84b..6b768f0 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1956,6 +1956,13 @@ namespace svgio
 {
 if(mbIsClipPathContent)
 {
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if(pSvgStyleAttributes)
+{
+return pSvgStyleAttributes->getFill();
+}
+
 static basegfx::BColor aBlack(0.0, 0.0, 0.0);
 return 
 }
@@ -1999,6 +2006,13 @@ namespace svgio
 {
 if(mbIsClipPathContent)
 {
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if(pSvgStyleAttributes)
+{
+return pSvgStyleAttributes->getStroke();
+}
+
 return nullptr;
 }
 else if(maStroke.isSet())
@@ -2041,6 +2055,13 @@ namespace svgio
 {
 if(mbIsClipPathContent)
 {
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if(pSvgStyleAttributes)
+{
+return pSvgStyleAttributes->getSvgGradientNodeFill();
+}
+
 return nullptr;
 }
 else if(mpSvgGradientNodeFill)
@@ -2064,6 +2085,13 @@ namespace svgio
 {
 if(mbIsClipPathContent)
 {
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if(pSvgStyleAttributes)
+{
+return pSvgStyleAttributes->getSvgGradientNodeStroke();
+}
+
 return nullptr;
 }
 else if(mpSvgGradientNodeStroke)
@@ -2087,6 +2115,13 @@ namespace svgio
 {
 if(mbIsClipPathContent)

[Libreoffice-commits] core.git: svgio/qa svgio/source

2016-02-21 Thread Regina Henschel
 svgio/qa/cppunit/SvgImportTest.cxx|2 
 svgio/source/svgreader/svgsvgnode.cxx |  106 ++
 2 files changed, 70 insertions(+), 38 deletions(-)

New commits:
commit a2d8a9873deb5b39198c346cf637a9a8cb9e5105
Author: Regina Henschel 
Date:   Wed Feb 10 15:26:37 2016 +0400

tdf#97538 no cropping if width, height and viewBox missing

Now the whole image is inserted, so that it can be cropped in the
application. The patch repairs in addition a wrong ratio in the
case height is missing but viewBox is given, and fixes some
comments. Change in SvgImportTest.cxx by Xisco Fauli.

Change-Id: I8c0fbf8b78cf7ab5bc97d04783b49892da3d2849
Reviewed-on: https://gerrit.libreoffice.org/22363
Reviewed-by: jan iversen 
Tested-by: jan iversen 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index e5d2b03..801402c 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -279,7 +279,7 @@ void Test::testTdf79163()
 
 CPPUNIT_ASSERT (pDocument);
 
-assertXPath(pDocument, "/primitive2D/transform/mask/unifiedtransparence", 
"transparence", "0");
+assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", 
"transparence", "0");
 }
 
 void Test::testTdf97542_1()
diff --git a/svgio/source/svgreader/svgsvgnode.cxx 
b/svgio/source/svgreader/svgsvgnode.cxx
index 400d480..22b9fe8 100644
--- a/svgio/source/svgreader/svgsvgnode.cxx
+++ b/svgio/source/svgreader/svgsvgnode.cxx
@@ -353,7 +353,7 @@ namespace svgio
 {
 // Even outermost svg has not all information to 
resolve relative values,
 // I use content itself as fallback to set missing 
values for viewport
-// Any better idea for such ill structures svg 
documents?
+// Any better idea for such ill structured svg 
documents?
 const basegfx::B2DRange aChildRange(
 aSequence.getB2DRange(
 
drawinglayer::geometry::ViewInformation2D()));
@@ -380,7 +380,7 @@ namespace svgio
 {
 // Even outermost svg has not all information to 
resolve relative values,
 // I use content itself as fallback to set missing 
values for viewport
-// Any better idea for such ill structures svg 
documents?
+// Any better idea for such ill structured svg 
documents?
 const basegfx::B2DRange aChildRange(
 aSequence.getB2DRange(
 
drawinglayer::geometry::ViewInformation2D()));
@@ -485,8 +485,8 @@ namespace svgio
 const bool bHeightInvalid(getHeight().isSet() && 
basegfx::fTools::lessOrEqual(getHeight().getNumber(), 0.0));
 if(!bWidthInvalid && !bHeightInvalid)
 {
-basegfx::B2DRange aSvgCanvasRange; // effective value 
depends on viewBox
-double fW = 0.0; // effective value depends on viewBox
+basegfx::B2DRange aSvgCanvasRange; // viewport
+double fW = 0.0; // dummy values
 double fH = 0.0;
 if(getViewBox())
 {
@@ -496,78 +496,110 @@ namespace svgio
 const double fViewBoxHeight = 
getViewBox()->getHeight();
 if(basegfx::fTools::more(fViewBoxWidth,0.0) && 
basegfx::fTools::more(fViewBoxHeight,0.0))
 {
-// The intrinsic aspect ratio of the svg 
element is given by absolute values of both width and height
-// or if one or both of them is relative by 
the width and height of the viewBox
+// The intrinsic aspect ratio of the svg 
element is given by absolute values of svg width and svg height
+// or by the width and height of the viewBox, 
if svg width or svg height is relative.
 // see SVG 1.1 section 7.12
+bool bNeedsMapping(true);
 const bool bWidthIsAbsolute(getWidth().isSet() 
&& Unit_percent != getWidth().getUnit());
 const bool 
bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit());
+const double 
fViewBoxRatio(fViewBoxWidth/fViewBoxHeight);
 if(bWidthIsAbsolute && bHeightIsAbsolute)
 {
-

[Libreoffice-commits] core.git: svgio/qa svgio/source

2016-02-18 Thread Xisco Fauli
 svgio/qa/cppunit/SvgImportTest.cxx|   17 +
 svgio/qa/cppunit/data/FontsizeRelative.svg|5 +
 svgio/source/svgreader/svgstyleattributes.cxx |   14 ++
 3 files changed, 36 insertions(+)

New commits:
commit 324014c997ab90f5777f772a46e6faf887a00832
Author: Xisco Fauli 
Date:   Thu Feb 18 01:27:17 2016 +0100

SVGIO: Fix problem when relative font-size depends on its...

... parent's font-size

Change-Id: I13943923c401a5a06b3aa51181fd75292534e888
Reviewed-on: https://gerrit.libreoffice.org/22452
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 7870188..e5d2b03 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -42,6 +42,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testTdf87309();
 void testFontsizeKeywords();
 void testFontsizePercentage();
+void testFontsizeRelative();
 void testTdf45771();
 void testTdf97941();
 void testTdf85770();
@@ -63,6 +64,7 @@ public:
 CPPUNIT_TEST(testTdf87309);
 CPPUNIT_TEST(testFontsizeKeywords);
 CPPUNIT_TEST(testFontsizePercentage);
+CPPUNIT_TEST(testFontsizeRelative);
 CPPUNIT_TEST(testTdf45771);
 CPPUNIT_TEST(testTdf97941);
 CPPUNIT_TEST(testTdf85770);
@@ -197,6 +199,7 @@ void Test::testFontsizeKeywords()
 
 void Test::testFontsizePercentage()
 {
+//Check when font-size uses percentage and defined globally
 Primitive2DSequence aSequenceFontsizePercentage = 
parseSvg("/svgio/qa/cppunit/data/FontsizePercentage.svg");
 CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceFontsizePercentage.getLength());
 
@@ -208,6 +211,20 @@ void Test::testFontsizePercentage()
 assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "16");
 }
 
+void Test::testFontsizeRelative()
+{
+//Check when font-size uses relative units (em,ex) and it's based on its 
parent's font-size
+Primitive2DSequence aSequenceFontsizeRelative = 
parseSvg("/svgio/qa/cppunit/data/FontsizeRelative.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceFontsizeRelative.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceFontsizeRelative));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", "50");
+}
+
 void Test::testTdf45771()
 {
 //Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/FontsizeRelative.svg 
b/svgio/qa/cppunit/data/FontsizeRelative.svg
new file mode 100644
index 000..339e663
--- /dev/null
+++ b/svgio/qa/cppunit/data/FontsizeRelative.svg
@@ -0,0 +1,5 @@
+ http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink;>
+
+   Sample
+ 
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index a6ad68d..fb750fe 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2402,6 +2402,20 @@ namespace svgio
 return SvgNumber(
 maFontSizeNumber.getNumber() * aDefaultSize / 100.0, 
Unit_px, true);
 }
+else if((Unit_em == maFontSizeNumber.getUnit()) || (Unit_ex == 
maFontSizeNumber.getUnit()))
+{
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+if(pSvgStyleAttributes)
+{
+const SvgNumber aParentNumber = 
pSvgStyleAttributes->getFontSizeNumber();
+
+return SvgNumber(
+aParentNumber.getNumber() * 
maFontSizeNumber.getNumber(),
+aParentNumber.getUnit(),
+true);
+}
+}
 
 return maFontSizeNumber;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svgio/qa svgio/source test/source

2016-02-11 Thread Xisco Fauli
 svgio/qa/cppunit/SvgImportTest.cxx|   32 ++
 svgio/qa/cppunit/data/tdf97542_1.svg  |   15 
 svgio/qa/cppunit/data/tdf97542_2.svg  |   15 
 svgio/source/svgreader/svgstyleattributes.cxx |   15 +++-
 test/source/primitive2dxmldump.cxx|   28 +-
 5 files changed, 98 insertions(+), 7 deletions(-)

New commits:
commit b6a62f07557fe4ae0931e0f3e0f306d2f69b116b
Author: Xisco Fauli 
Date:   Fri Feb 5 00:25:58 2016 +0100

tdf#97542: SVGIO: First check the current fill attribute

Differenciate when gradient is defined in the text element or in its parents

Add unit tests

Change-Id: I85b09f72fbb1a3c8d2fa7350b4396b5bf924277f
Reviewed-on: https://gerrit.libreoffice.org/22131
Tested-by: Jenkins 
Reviewed-by: Jochen Nitschke 
Reviewed-by: Xisco Faulí 

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 50a7ef7..9214223 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -45,6 +45,8 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
 void testTdf45771();
 void testTdf85770();
 void testTdf79163();
+void testTdf97542_1();
+void testTdf97542_2();
 
 Primitive2DSequence parseSvg(const char* aSource);
 
@@ -60,6 +62,8 @@ public:
 CPPUNIT_TEST(testTdf45771);
 CPPUNIT_TEST(testTdf85770);
 CPPUNIT_TEST(testTdf79163);
+CPPUNIT_TEST(testTdf97542_1);
+CPPUNIT_TEST(testTdf97542_2);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -237,6 +241,34 @@ void Test::testTdf79163()
 assertXPath(pDocument, "/primitive2D/transform/mask/unifiedtransparence", 
"transparence", "0");
 }
 
+void Test::testTdf97542_1()
+{
+Primitive2DSequence aSequenceTdf97542_1 = 
parseSvg("/svgio/qa/cppunit/data/tdf97542_1.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceTdf97542_1.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97542_1));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/objectinfo/textsimpleportion", "fontcolor", "#00");
+}
+
+void Test::testTdf97542_2()
+{
+Primitive2DSequence aSequenceTdf97542_2 = 
parseSvg("/svgio/qa/cppunit/data/tdf97542_2.svg");
+CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceTdf97542_2.getLength());
+
+Primitive2dXmlDump dumper;
+xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97542_2));
+
+CPPUNIT_ASSERT (pDocument);
+
+assertXPath(pDocument, 
"/primitive2D/transform/objectinfo/svgradialgradient[1]", "x", "1");
+assertXPath(pDocument, 
"/primitive2D/transform/objectinfo/svgradialgradient[1]", "y", "1");
+assertXPath(pDocument, 
"/primitive2D/transform/objectinfo/svgradialgradient[1]", "radius", "3");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/tdf97542_1.svg 
b/svgio/qa/cppunit/data/tdf97542_1.svg
new file mode 100644
index 000..328bd97
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf97542_1.svg
@@ -0,0 +1,15 @@
+
+http://www.w3.org/2000/svg;>
+ 
+ 
+  
+   
+   
+  
+ 
+ 
+  Layer 1
+  
+  Text
+ 
+
diff --git a/svgio/qa/cppunit/data/tdf97542_2.svg 
b/svgio/qa/cppunit/data/tdf97542_2.svg
new file mode 100644
index 000..03cee96
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf97542_2.svg
@@ -0,0 +1,15 @@
+
+http://www.w3.org/2000/svg;>
+ 
+ 
+  
+   
+   
+  
+ 
+ 
+  Layer 1
+  
+  Text
+ 
+
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 2ae8a06..1f592e7 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -263,6 +263,9 @@ namespace svgio
 // dismantle to geometry and add needed primitives
 const basegfx::BColor* pFill = getFill();
 const SvgGradientNode* pFillGradient = 
getSvgGradientNodeFill();
+const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+const SvgGradientNode* pParentFillGradient =
+pSvgStyleAttributes ? 
pSvgStyleAttributes->getSvgGradientNodeFill() : nullptr;
 const SvgPatternNode* pFillPattern = getSvgPatternNodeFill();
 const basegfx::BColor* pStroke = getStroke();
 const SvgGradientNode* pStrokeGradient = 
getSvgGradientNodeStroke();
@@ -303,20 +306,20 @@ namespace svgio
 
 const bool bStrokeUsed(pStroke || pStrokeGradient || 
pStrokePattern);
 
+if(pFill && (!pFillGradient || pParentFillGradient))
+{
+// add the already prepared primitives for single color 
fill
+rTarget.append(rSource);
+}
  

[Libreoffice-commits] core.git: svgio/qa svgio/source

2014-07-15 Thread Joren De Cuyper
 svgio/qa/cppunit/SvgImportTest.cxx  |3 +++
 svgio/qa/cppunit/data/RectWithStylesByGroup.svg |   18 ++
 svgio/source/svgreader/svggnode.cxx |8 +++-
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 2dbd2cb9a55c90f4f3db3a781526cc2246d0bdd7
Author: Joren De Cuyper jore...@libreoffice.org
Date:   Tue Jul 15 13:52:10 2014 +0200

Avoid infinite loop when gathering g element styles

Same way of how fdo#74743 is fixed 3b7472b284131c09d91b69f26d5d26d54648f939

Change-Id: If6cc8eb6ff89b0081f27ff75a9b60a3e81cff1bd
Reviewed-on: https://gerrit.libreoffice.org/10326
Reviewed-by: Tomaž Vajngerl qui...@gmail.com
Tested-by: Tomaž Vajngerl qui...@gmail.com

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 23fcf90..a5e5e17 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -82,6 +82,9 @@ void Test::testStyles()
 Primitive2DSequence maSequenceRectWithParentStyle = 
parseSvg(/svgio/qa/cppunit/data/RectWithParentStyles.svg);
 CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithParentStyle.getLength());
 
+Primitive2DSequence maSequenceRectWithStylesByGroup = 
parseSvg(/svgio/qa/cppunit/data/RectWithStylesByGroup.svg);
+CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithStylesByGroup.getLength());
+
 // TODO: Test if the 3 sequences are equal..
 //const Primitive2DReference xReference(maSequenceRect[0]);
 }
diff --git a/svgio/qa/cppunit/data/RectWithStylesByGroup.svg 
b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg
new file mode 100644
index 000..6fefdf2
--- /dev/null
+++ b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg
@@ -0,0 +1,18 @@
+?xml version=1.0 standalone=no?
+!DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.1//EN
+  http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;
+svg xmlns=http://www.w3.org/2000/svg; version=1.1
+ width=10cm height=5cm viewBox=0 0 1000 500
+  defs
+style type=text/css![CDATA[
+  g {
+fill: red;
+stroke: blue;
+stroke-width: 3
+  }
+]]/style
+  /defs
+g
+  rect x=200 y=100 width=600 height=300/
+/g
+/svg
diff --git a/svgio/source/svgreader/svggnode.cxx 
b/svgio/source/svgreader/svggnode.cxx
index 82d3d5d..45fa6a3 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -43,7 +43,13 @@ namespace svgio
 
 const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
 {
-return checkForCssStyle(OUString(g), maSvgStyleAttributes);
+const SvgStyleAttributes* aCheckCssStyle = 
checkForCssStyle(OUString(g), maSvgStyleAttributes);
+const SvgStyleAttributes* aGetCssStyleParent = 
maSvgStyleAttributes.getCssStyleParent();
+
+if (aGetCssStyleParent == NULL)
+return aCheckCssStyle;
+
+return aGetCssStyleParent;
 }
 
 void SvgGNode::parseAttribute(const OUString rTokenName, SVGToken 
aSVGToken, const OUString aContent)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits