summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-05-15 08:47:52 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-17 14:43:25 +0100
commitb7a425aab6122b5848362815e5fe665c7e38da05 (patch)
treeaefb221b0f04f81d9b4dfdd17d1724e4e32ab088 /svgio
parent821446a0be326c0065c827ffcd4670c113c78755 (diff)
Resolves: #i121801# Corrected handling of gradient transformations
(cherry picked from commit 4f49f1d95e8d0be7df259ad1458441fd858be735) Conflicts: drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx svgio/source/svgreader/svgnode.cxx svgio/source/svgreader/svgstyleattributes.cxx Change-Id: I155854692a9d1771826867d2666fc6174e2c9256
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgio/svgreader/svgnode.hxx5
-rw-r--r--svgio/source/svgreader/svggnode.cxx2
-rw-r--r--svgio/source/svgreader/svgnode.cxx193
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx17
4 files changed, 124 insertions, 93 deletions
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index 2aa28165fe4e..725fb5cb2b8a 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -79,6 +79,11 @@ namespace svgio
Display_inherit
};
+ // helper to convert a string associated with a token of type SVGTokenDisplay
+ // to the enum Display. Empty trings return the default 'Display_inline' with
+ // which members should be initialized
+ Display getDisplayFromContent(const rtl::OUString& aContent);
+
class SvgNode : private boost::noncopyable, public InfoProvider
{
private:
diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx
index d18534092300..4f3e23b6167f 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -90,7 +90,7 @@ namespace svgio
{
const double fOpacity(pStyle->getOpacity().getNumber());
- if(fOpacity > 0.0)
+ if(fOpacity > 0.0 && Display_none != getDisplay())
{
drawinglayer::primitive2d::Primitive2DSequence aContent;
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index c4cc2659c91e..bbd21d21487e 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -219,6 +219,107 @@ namespace svgio
}
}
+ Display getDisplayFromContent(const rtl::OUString& aContent)
+ {
+ if(aContent.getLength())
+ {
+ static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline"));
+ static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block"));
+ static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item"));
+ static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in"));
+ static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact"));
+ static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker"));
+ static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table"));
+ static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table"));
+ static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group"));
+ static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group"));
+ static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group"));
+ static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row"));
+ static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group"));
+ static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column"));
+ static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell"));
+ static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption"));
+ static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
+ static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit"));
+
+ if(aContent.match(aStrInline))
+ {
+ return Display_inline;
+ }
+ else if(aContent.match(aStrNone))
+ {
+ return Display_none;
+ }
+ else if(aContent.match(aStrInherit))
+ {
+ return Display_inherit;
+ }
+ else if(aContent.match(aStrBlock))
+ {
+ return Display_block;
+ }
+ else if(aContent.match(aStrList_item))
+ {
+ return Display_list_item;
+ }
+ else if(aContent.match(aStrRun_in))
+ {
+ return Display_run_in;
+ }
+ else if(aContent.match(aStrCompact))
+ {
+ return Display_compact;
+ }
+ else if(aContent.match(aStrMarker))
+ {
+ return Display_marker;
+ }
+ else if(aContent.match(aStrTable))
+ {
+ return Display_table;
+ }
+ else if(aContent.match(aStrInline_table))
+ {
+ return Display_inline_table;
+ }
+ else if(aContent.match(aStrTable_row_group))
+ {
+ return Display_table_row_group;
+ }
+ else if(aContent.match(aStrTable_header_group))
+ {
+ return Display_table_header_group;
+ }
+ else if(aContent.match(aStrTable_footer_group))
+ {
+ return Display_table_footer_group;
+ }
+ else if(aContent.match(aStrTable_row))
+ {
+ return Display_table_row;
+ }
+ else if(aContent.match(aStrTable_column_group))
+ {
+ return Display_table_column_group;
+ }
+ else if(aContent.match(aStrTable_column))
+ {
+ return Display_table_column;
+ }
+ else if(aContent.match(aStrTable_cell))
+ {
+ return Display_table_cell;
+ }
+ else if(aContent.match(aStrTable_caption))
+ {
+ return Display_table_caption;
+ }
+ }
+
+ // return the default
+ return Display_inline;
+ }
+
void SvgNode::parseAttribute(const OUString& /*rTokenName*/, SVGToken aSVGToken, const OUString& aContent)
{
switch(aSVGToken)
@@ -261,97 +362,7 @@ namespace svgio
{
if(aContent.getLength())
{
- static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline"));
- static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block"));
- static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item"));
- static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in"));
- static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact"));
- static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker"));
- static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table"));
- static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table"));
- static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group"));
- static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group"));
- static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group"));
- static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row"));
- static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group"));
- static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column"));
- static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell"));
- static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption"));
- static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
- static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit"));
-
- if(aContent.match(aStrInline))
- {
- setDisplay(Display_inline);
- }
- else if(aContent.match(aStrNone))
- {
- setDisplay(Display_none);
- }
- else if(aContent.match(aStrInherit))
- {
- setDisplay(Display_inherit);
- }
- else if(aContent.match(aStrBlock))
- {
- setDisplay(Display_block);
- }
- else if(aContent.match(aStrList_item))
- {
- setDisplay(Display_list_item);
- }
- else if(aContent.match(aStrRun_in))
- {
- setDisplay(Display_run_in);
- }
- else if(aContent.match(aStrCompact))
- {
- setDisplay(Display_compact);
- }
- else if(aContent.match(aStrMarker))
- {
- setDisplay(Display_marker);
- }
- else if(aContent.match(aStrTable))
- {
- setDisplay(Display_table);
- }
- else if(aContent.match(aStrInline_table))
- {
- setDisplay(Display_inline_table);
- }
- else if(aContent.match(aStrTable_row_group))
- {
- setDisplay(Display_table_row_group);
- }
- else if(aContent.match(aStrTable_header_group))
- {
- setDisplay(Display_table_header_group);
- }
- else if(aContent.match(aStrTable_footer_group))
- {
- setDisplay(Display_table_footer_group);
- }
- else if(aContent.match(aStrTable_row))
- {
- setDisplay(Display_table_row);
- }
- else if(aContent.match(aStrTable_column_group))
- {
- setDisplay(Display_table_column_group);
- }
- else if(aContent.match(aStrTable_column))
- {
- setDisplay(Display_table_column);
- }
- else if(aContent.match(aStrTable_cell))
- {
- setDisplay(Display_table_cell);
- }
- else if(aContent.match(aStrTable_caption))
- {
- setDisplay(Display_table_caption);
- }
+ setDisplay(getDisplayFromContent(aContent));
}
break;
}
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 7b8a8a59cc1a..8d9c406ab744 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -309,10 +309,11 @@ namespace svgio
if(!aSvgGradientEntryVector.empty())
{
basegfx::B2DHomMatrix aGeoToUnit;
+ basegfx::B2DHomMatrix aGradientTransform;
if(rFillGradient.getGradientTransform())
{
- aGeoToUnit = *rFillGradient.getGradientTransform();
+ aGradientTransform = *rFillGradient.getGradientTransform();
}
if(userSpaceOnUse == rFillGradient.getGradientUnits())
@@ -357,6 +358,7 @@ namespace svgio
drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(
rTarget,
new drawinglayer::primitive2d::SvgLinearGradientPrimitive2D(
+ aGradientTransform,
rPath,
aSvgGradientEntryVector,
aStart,
@@ -418,6 +420,7 @@ namespace svgio
drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(
rTarget,
new drawinglayer::primitive2d::SvgRadialGradientPrimitive2D(
+ aGradientTransform,
rPath,
aSvgGradientEntryVector,
aStart,
@@ -1779,6 +1782,18 @@ namespace svgio
readLocalUrl(aContent, maMarkerEndXLink);
break;
}
+ case SVGTokenDisplay:
+ {
+ // There may be display:none statements inside of style defines, e.g. the following line:
+ // style="display:none"
+ // taken from a svg example; this needs to be parsed and set at the owning node. Do not call
+ // mrOwner.parseAttribute(...) here, this would lead to a recursion
+ if(aContent.getLength())
+ {
+ mrOwner.setDisplay(getDisplayFromContent(aContent));
+ }
+ break;
+ }
default:
{
break;