incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1226395 - in /incubator/ooo/trunk/main/svgio: inc/svgio/svgreader/svgdocumenthandler.hxx source/svgreader/svgclippathnode.cxx source/svgreader/svgdocumenthandler.cxx source/svgreader/svgmasknode.cxx source/svgreader/svgstyleattributes.cxx
Date Mon, 02 Jan 2012 11:33:52 GMT
Author: alg
Date: Mon Jan  2 11:33:52 2012
New Revision: 1226395

URL: http://svn.apache.org/viewvc?rev=1226395&view=rev
Log:
svg: #118698# added support for css style for svg tokens, unified css style character reading

Modified:
    incubator/ooo/trunk/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgclippathnode.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgmasknode.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx

Modified: incubator/ooo/trunk/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx?rev=1226395&r1=1226394&r2=1226395&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx (original)
+++ incubator/ooo/trunk/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx Mon Jan  2 11:33:52
2012
@@ -41,13 +41,13 @@ namespace svgio
         {
         private:
             // the complete SVG Document
-            SvgDocument         maDocument;
+            SvgDocument                     maDocument;
 
             // current node for parsing
-            SvgNode*            mpTarget;
+            SvgNode*                        mpTarget;
 
-            /// bitfield
-            bool                mbValidToken : 1;
+            // text collector string stack for css styles
+            std::vector< rtl::OUString >    maCssContents;
 
         public:
             SvgDocHdl(const rtl::OUString& rAbsolutePath);

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgclippathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgclippathnode.cxx?rev=1226395&r1=1226394&r2=1226395&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgclippathnode.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgclippathnode.cxx Mon Jan  2 11:33:52
2012
@@ -51,9 +51,6 @@ namespace svgio
 
         const SvgStyleAttributes* SvgClipPathNode::getSvgStyleAttributes() const
         {
-            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("clip-path"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
             return &maSvgStyleAttributes;
         }
 

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx?rev=1226395&r1=1226394&r2=1226395&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx Mon Jan  2 11:33:52
2012
@@ -125,7 +125,8 @@ namespace svgio
     {
         SvgDocHdl::SvgDocHdl(const rtl::OUString& aAbsolutePath)
         :   maDocument(aAbsolutePath),
-            mpTarget(0)
+            mpTarget(0),
+            maCssContents()
         {
         }
 
@@ -137,17 +138,20 @@ namespace svgio
                 OSL_ENSURE(false, "SvgDocHdl destructed with active target (!)");
                 delete mpTarget;
             }
+            OSL_ENSURE(!maCssContents.size(), "SvgDocHdl destructed with active css style
stack entry (!)");
 #endif
         }
 
         void SvgDocHdl::startDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException)
         {
             OSL_ENSURE(!mpTarget, "Already a target at document start (!)");
+            OSL_ENSURE(!maCssContents.size(), "SvgDocHdl startDocument with active css style
stack entry (!)");
         }
 
         void SvgDocHdl::endDocument(  ) throw (xml::sax::SAXException, uno::RuntimeException)
         {
             OSL_ENSURE(!mpTarget, "Still a target at document end (!)");
+            OSL_ENSURE(!maCssContents.size(), "SvgDocHdl endDocument with active css style
stack entry (!)");
         }
 
         void SvgDocHdl::startElement( const ::rtl::OUString& aName, const uno::Reference<
xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
@@ -294,8 +298,14 @@ namespace svgio
                     /// styles (as stylesheets)
                     case SVGTokenStyle:
                     {
-                        mpTarget = new SvgStyleNode(maDocument, mpTarget);
+                        SvgStyleNode* pNew = new SvgStyleNode(maDocument, mpTarget);
+                        mpTarget = pNew;
                         mpTarget->parseAttributes(xAttribs);
+
+                        if(pNew->isTextCss())
+                        {
+                            maCssContents.push_back(rtl::OUString());
+                        }
                         break;
                     }
 
@@ -355,6 +365,7 @@ namespace svgio
             {
                 const SVGToken aSVGToken(StrToSVGToken(aName));
                 SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
+                SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode*
>(mpTarget) : 0);
 
                 switch(aSVGToken)
                 {
@@ -427,6 +438,21 @@ namespace svgio
                     }
                 }
 
+                if(pCssStyle && pCssStyle->isTextCss())
+                {
+                    // css style parsing
+                    if(maCssContents.size())
+                    {
+                        // need to interpret css styles and remember them as StyleSheets
+                        pCssStyle->addCssStyleSheet(*(maCssContents.end() - 1));
+                        maCssContents.pop_back();
+                    }
+                    else
+                    {
+                        OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack
(!)");
+                    }
+                }
+
                 if(pWhitespaceCheck)
                 {
                     // cleanup read strings
@@ -480,12 +506,20 @@ namespace svgio
 
                             if(rSvgStyleNode.isTextCss())
                             {
-                                // need to interpret css styles and remember them as StyleSheets
-                                const ::rtl::OUString aTrimmedChars(aChars.trim());
+                                // collect characters for css style
+                                if(maCssContents.size())
+                                {
+                                    const ::rtl::OUString aTrimmedChars(aChars.trim());
                                 
-                                if(aTrimmedChars.getLength())
+                                    if(aTrimmedChars.getLength())
+                                    {
+                                        std::vector< rtl::OUString >::iterator aString(maCssContents.end()
- 1);
+                                        (*aString) += aTrimmedChars;
+                                    }
+                                }
+                                else
                                 {
-                                    rSvgStyleNode.addCssStyleSheet(aTrimmedChars);
+                                    OSL_ENSURE(false, "Closing CssStyle, but no collector
string on stack (!)");
                                 }
                             }
                             break;

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgmasknode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgmasknode.cxx?rev=1226395&r1=1226394&r2=1226395&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgmasknode.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgmasknode.cxx Mon Jan  2 11:33:52 2012
@@ -60,9 +60,6 @@ namespace svgio
 
         const SvgStyleAttributes* SvgMaskNode::getSvgStyleAttributes() const
         {
-            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("mask"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
             return &maSvgStyleAttributes;
         }
 

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1226395&r1=1226394&r2=1226395&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx Mon Jan  2 11:33:52
2012
@@ -203,7 +203,7 @@ namespace svgio
                         aId = aId + *mrOwner.getClass();
                         pNew = rDocument.findSvgStyleAttributesById(aId);
 
-                        if(!pNew)
+                        if(!pNew && rClassStr.getLength())
                         {
                             aId = rClassStr + aId;
                     
@@ -214,6 +214,10 @@ namespace svgio
                     {
                         pNew = rDocument.findSvgStyleAttributesById(*mrOwner.getId());
                     }
+                    else if(rClassStr.getLength())
+                    {
+                        pNew = rDocument.findSvgStyleAttributesById(rClassStr);
+                    }
                     
                     if(pNew)
                     {



Mime
View raw message