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

Armin Le Grand alg at apache.org
Fri Jun 14 12:10:57 PDT 2013


 svgio/source/svgreader/svgnode.cxx |   33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 86d121eb3d832d88d3da380ab07bb506f687ddc6
Author: Armin Le Grand <alg at apache.org>
Date:   Fri Jun 14 17:06:00 2013 +0000

    Resolves: #i122522# apply needed order to CSS styles to presentation styles
    
    (cherry picked from commit 2610028a8a1465006059c504a5230b67f550406c)
    
    Conflicts:
    	svgio/source/svgreader/svgnode.cxx
    
    Change-Id: If1f4184da76b275e44737d5f16a3cb57357db67d

diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 8e95546..c4cc265 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -179,12 +179,43 @@ namespace svgio
         void SvgNode::parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs)
         {
             const sal_uInt32 nAttributes(xAttribs->getLength());
+            // #i122522# SVG defines that 'In general, this means that the presentation attributes have
+            // lower priority than other CSS style rules specified in author style sheets or ‘style’
+            // attributes.' in http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes
+            // (6.4 Specifying properties using the presentation attributes SVG 1.1). That means that
+            // e.g. font-size will appear as presentation attribute and CSS style attribute. In these
+            // cases, CSS style attributes need to have precedence. To do so it is possible to create
+            // a proirity system for all properties of a shape, but it will also work to parse the
+            // presentation attributes of type 'style' last, so they will overwrite the less-prioritized
+            // already interpreted ones. Thus, remember SVGTokenStyle entries and parse them last.
+            // To make this work it is required that parseAttribute is only called by parseAttributes
+            // which is the case.
+            std::vector< sal_uInt32 > aSVGTokenStyleIndexes;
 
             for(sal_uInt32 a(0); a < nAttributes; a++)
             {
                 const OUString aTokenName(xAttribs->getNameByIndex(a));
+                const SVGToken aSVGToken(StrToSVGToken(aTokenName));
 
-                parseAttribute(aTokenName, StrToSVGToken(aTokenName), xAttribs->getValueByIndex(a));
+                if(SVGTokenStyle == aSVGToken)
+                {
+                    // #i122522# remember SVGTokenStyle entry
+                    aSVGTokenStyleIndexes.push_back(a);
+                }
+                else
+                {
+                    parseAttribute(aTokenName, StrToSVGToken(aTokenName), xAttribs->getValueByIndex(a));
+                }
+            }
+
+            // #i122522# parse SVGTokenStyle entries last to override already interpreted
+            // 'presentation attributes' of potenially the same type
+            for(sal_uInt32 b(0); b < aSVGTokenStyleIndexes.size(); b++)
+            {
+                const sal_uInt32 nSVGTokenStyleIndex(aSVGTokenStyleIndexes[b]);
+                const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(nSVGTokenStyleIndex));
+
+                parseAttribute(aTokenName, SVGTokenStyle, xAttribs->getValueByIndex(nSVGTokenStyleIndex));
             }
         }
 


More information about the Libreoffice-commits mailing list