incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1368423 - /incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx
Date Thu, 02 Aug 2012 11:35:24 GMT
Author: alg
Date: Thu Aug  2 11:35:23 2012
New Revision: 1368423

URL: http://svn.apache.org/viewvc?rev=1368423&view=rev
Log:
#120435# Corrected CSS style detection to be executed only once per node

Modified:
    incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx?rev=1368423&r1=1368422&r2=1368423&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgnode.cxx Thu Aug  2 11:35:23 2012
@@ -43,68 +43,71 @@ namespace svgio
 
         const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr,
const SvgStyleAttributes& rOriginal) const
         {
-            const SvgDocument& rDocument = getDocument();
-
-            if(rDocument.hasSvgStyleAttributesById())
+            if(maCssStyleVector.empty()) // #120435# Evaluate for CSS styles only once, this
cannot change
             {
-                if(getClass())
+                const SvgDocument& rDocument = getDocument();
+
+                if(rDocument.hasSvgStyleAttributesById())
                 {
-                    // find all referenced CSS styles, a list of entries is allowed
-                    const rtl::OUString* pClassList = getClass();
-                    const sal_Int32 nLen(pClassList->getLength());
-                    sal_Int32 nPos(0);
-                    const SvgStyleAttributes* pNew = 0;
+                    if(getClass())
+                    {
+                        // find all referenced CSS styles, a list of entries is allowed
+                        const rtl::OUString* pClassList = getClass();
+                        const sal_Int32 nLen(pClassList->getLength());
+                        sal_Int32 nPos(0);
+                        const SvgStyleAttributes* pNew = 0;
 
-                    skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
+                        skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
     
-                    while(nPos < nLen)
-                    {
-                        rtl::OUStringBuffer aTokenValue;
+                        while(nPos < nLen)
+                        {
+                            rtl::OUStringBuffer aTokenValue;
                         
-                        copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
-                        skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
+                            copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue,
nLen);
+                            skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
 
-                        rtl::OUString aId(rtl::OUString::createFromAscii("."));
-                        const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+                            rtl::OUString aId(rtl::OUString::createFromAscii("."));
+                            const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
                         
-                        // look for CSS style common to token
-                        aId = aId + aOUTokenValue;
-                        pNew = rDocument.findSvgStyleAttributesById(aId);
+                            // look for CSS style common to token
+                            aId = aId + aOUTokenValue;
+                            pNew = rDocument.findSvgStyleAttributesById(aId);
     
-                        if(!pNew && rClassStr.getLength())
-                        {
-                            // look for CSS style common to class.token
-                            aId = rClassStr + aId;
+                            if(!pNew && rClassStr.getLength())
+                            {
+                                // look for CSS style common to class.token
+                                aId = rClassStr + aId;
                     
-                            pNew = rDocument.findSvgStyleAttributesById(aId);
-                        }
+                                pNew = rDocument.findSvgStyleAttributesById(aId);
+                            }
                         
+                            if(pNew)
+                            {
+                                const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
+                            }
+                        }
+                    }
+                
+                    if(maCssStyleVector.empty() && getId())
+                    {
+                        // if none found, search for CSS style equal to Id
+                        const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId());
+
                         if(pNew)
                         {
                             const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
                         }
                     }
-                }
-                
-                if(maCssStyleVector.empty() && getId())
-                {
-                    // if none found, search for CSS style equal to Id
-                    const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId());
 
-                    if(pNew)
+                    if(maCssStyleVector.empty() && rClassStr.getLength())
                     {
-                        const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
-                    }
-                }
-
-                if(maCssStyleVector.empty() && rClassStr.getLength())
-                {
-                    // if none found, search for CSS style equal to class type
-                    const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
+                        // if none found, search for CSS style equal to class type
+                        const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
                     
-                    if(pNew)
-                    {
-                        const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
+                        if(pNew)
+                        {
+                            const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
+                        }
                     }
                 }
             }
@@ -116,8 +119,12 @@ namespace svgio
             else
             {
                 // set CssStyleParent at maCssStyleVector members to hang them in front of
-                // the existing style
+                // the existing style. Build a style chain, reset parent of original for
security.
+                // Repeated style requests should only be issued from sub-Text nodes and
I'm not 
+                // sure if in-between text nodes may build other chains (should not happen).
But
+                // it's only a re-chaining with pointers (cheap), so allow to do it every
time.
                 SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal);
+                pCurrent->setCssStyleParent(0);
 
                 for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++)
                 {



Mime
View raw message