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

Jian Hong Cheng chengjh at apache.org
Sun Apr 14 08:53:48 PDT 2013


 svgio/inc/svgio/svgreader/svgnode.hxx            |    8 +
 svgio/inc/svgio/svgreader/svgstyleattributes.hxx |   32 +++++--
 svgio/source/svgreader/svgcirclenode.cxx         |    4 
 svgio/source/svgreader/svgellipsenode.cxx        |    6 -
 svgio/source/svgreader/svggnode.cxx              |    6 -
 svgio/source/svgreader/svgimagenode.cxx          |    6 -
 svgio/source/svgreader/svglinenode.cxx           |    6 -
 svgio/source/svgreader/svgmarkernode.cxx         |    6 -
 svgio/source/svgreader/svgnode.cxx               |  100 ++++++++++++++++++++++-
 svgio/source/svgreader/svgpathnode.cxx           |    6 -
 svgio/source/svgreader/svgpatternnode.cxx        |    6 -
 svgio/source/svgreader/svgpolynode.cxx           |    8 -
 svgio/source/svgreader/svgrectnode.cxx           |    6 -
 svgio/source/svgreader/svgstyleattributes.cxx    |   88 ++++++--------------
 svgio/source/svgreader/svgtextnode.cxx           |    6 -
 svgio/source/svgreader/svgusenode.cxx            |    6 -
 sw/source/filter/ww8/wrtww8.cxx                  |   42 ++++++---
 sw/source/filter/ww8/ww8atr.cxx                  |    3 
 sw/source/filter/ww8/ww8par2.cxx                 |    2 
 sw/source/filter/ww8/ww8par2.hxx                 |    1 
 sw/source/filter/ww8/ww8par6.cxx                 |    7 +
 21 files changed, 224 insertions(+), 131 deletions(-)

New commits:
commit 0efd28738af121097dcc186dab85dd65c88a0b7b
Author: Jian Hong Cheng <chengjh at apache.org>
Date:   Mon Jul 9 07:32:12 2012 +0000

    Fix issue #i120140: After doc file saved by AOO, one more section is created
    
    * sw/source/filter/ww8/wrtww8.cxx
    * sw/source/filter/ww8/ww8atr.cxx
    MS Word Binary Interoperability
    
    Patch by: Lin Yuan,<yuanlin.ibm at gmail.com>
    Found by: Yan Ji,<yanji.yj at gmail.com>
    Review by: Jian Hong Cheng,<chengjh at apache.org>
    Conflicts:
    	sw/source/filter/ww8/wrtww8.cxx
    
    Change-Id: If32bcced32b671f026ec8c32dd21684eb9e7b1fe

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index e997d61..a62370f 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2539,20 +2539,39 @@ void MSWordExportBase::WriteText()
                 ;
             else if ( !IsInTable() ) //No sections in table
             {
-                ReplaceCr( (char)0xc ); // indicator for Page/Section-Break
+                //#120140# Do not need to insert a page/section break after a section end. Check this case first
+                sal_Bool bNeedExportBreakHere = sal_True;
+                if ( aIdx.GetNode().IsTxtNode() )
+                {
+                    SwTxtNode *pTempNext = aIdx.GetNode().GetTxtNode();
+                    if ( pTempNext )
+                    {
+                        const SfxPoolItem * pTempItem = NULL;
+                        if (pTempNext->GetpSwAttrSet() && SFX_ITEM_SET == pTempNext->GetpSwAttrSet()->GetItemState(RES_PAGEDESC, false, &pTempItem)
+                            && pTempItem && ((SwFmtPageDesc*)pTempItem)->GetRegisteredIn())
+                        {
+                            //Next node has a new page style which means this node is a section end. Do not insert another page/section break here
+                            bNeedExportBreakHere = sal_False;
+                        }
+                    }
+                }
+                if (bNeedExportBreakHere)  //#120140# End of check
+                {
+                    ReplaceCr( (char)0xc ); // indicator for Page/Section-Break
 
-                const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent();
-                if ( !pParentFmt )
-                    pParentFmt = (SwSectionFmt*)0xFFFFFFFF;
+                    const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent();
+                    if ( !pParentFmt )
+                        pParentFmt = (SwSectionFmt*)0xFFFFFFFF;
 
-                sal_uLong nRstLnNum;
-                if ( aIdx.GetNode().IsCntntNode() )
-                    nRstLnNum = ((SwCntntNode&)aIdx.GetNode()).GetSwAttrSet().
-                                            GetLineNumber().GetStartValue();
-                else
-                    nRstLnNum = 0;
+                    sal_uLong nRstLnNum;
+                    if ( aIdx.GetNode().IsCntntNode() )
+                        nRstLnNum = ((SwCntntNode&)aIdx.GetNode()).GetSwAttrSet().
+                                                GetLineNumber().GetStartValue();
+                    else
+                        nRstLnNum = 0;
 
-                AppendSection( pAktPageDesc, pParentFmt, nRstLnNum );
+                    AppendSection( pAktPageDesc, pParentFmt, nRstLnNum );
+                }
             }
         }
         else if ( pNd->IsStartNode() )
@@ -2723,7 +2742,6 @@ void WW8Export::WriteFkpPlcUsw()
              the existence of an ObjectPool dir is necessary for triggering
              some magic. cmc
             */
-            /* Similiarly having msvbasic storage seems to also trigger creating this stream */
             GetWriter().GetStorage().OpenSotStorage(OUString(SL::aObjectPool),
                 STREAM_READWRITE | STREAM_SHARE_DENYALL);
         }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 2f93faf..92116b2 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3485,7 +3485,8 @@ sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar )
                 nUCode = 0x0;
             }
             //And the para is not of len 0, then replace this cr with the mark
-            if( nChar == 0x0e || nUCode == 0x0d )
+            //#120140# If there is a cr before a column break, need replace the cr. So remove the "nChar==0x0e" check.
+            if( nUCode == 0x0d )
                 bReplaced = false;
             else
             {
commit ce0f4825730a0f96ca5369a7d07982ea073901fb
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Apr 14 03:36:03 2013 +0200

    Fix compilation problem caused by previous commit
    
    Change-Id: I5fe90dd5a39c705b7b4dbc0c8d0b9e383c62e449

diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index fbc2e08..2e4ed84 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3425,7 +3425,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
             {
                 // <WW8SwFlyPara> constructor has changed - new 4th parameter
                 // containing WW8 page top margin.
-                pTableSFlyPara = new WW8SwFlyPara(*pPaM, *pTableWFlyPara,
+                pTableSFlyPara = new WW8SwFlyPara(*pPaM, *this, *pTableWFlyPara,
                     maSectionManager.GetWWPageTopMargin(),
                     maSectionManager.GetPageLeft(), maSectionManager.GetTextAreaWidth(),
                     nIniFlyDx, nIniFlyDy);
diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
index fe25b3d..ca8a31d 100644
--- a/sw/source/filter/ww8/ww8par2.hxx
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -75,6 +75,7 @@ struct WW8SwFlyPara
 
     // add parameter <nWWPgTop> - WW8's page top margin
     WW8SwFlyPara( SwPaM& rPaM,
+                  SwWW8ImplReader& rIo,
                   WW8FlyPara& rWW,
                   const sal_uInt32 nWWPgTop,
                   const sal_uInt32 nPgLeft,
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index c503662..e1ae0f6 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1726,6 +1726,7 @@ bool WW8FlyPara::IsEmpty() const
 
 // #i18732# - changes made on behalf of CMC
 WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
+                            SwWW8ImplReader& rIo,
                             WW8FlyPara& rWW,
                             const sal_uInt32 nWWPgTop,
                             const sal_uInt32 nPgLeft,
@@ -2285,7 +2286,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
 
     // <WW8SwFlyPara> constructor has changed - new 4th parameter
     // containing WW8 page top margin.
-    pSFlyPara = new WW8SwFlyPara( *pPaM, *pWFlyPara,
+    pSFlyPara = new WW8SwFlyPara( *pPaM, *this, *pWFlyPara,
                                   maSectionManager.GetWWPageTopMargin(),
                                   maSectionManager.GetPageLeft(),
                                   maSectionManager.GetTextAreaWidth(),
commit 4e07258cbd1f4fb16d6ce2174fb5c74c3b36da33
Author: Chen ZuoJun <zjchen at apache.org>
Date:   Mon Oct 8 12:21:52 2012 +0000

    #i119466# Doc file loaded by AOO, table with incorrect text wrapping property.
    
    Reported by: louqle
    Patch by: Chen Zuo Jun
    Review by: Lei De Bin

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 43277d5..c503662 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1740,6 +1740,10 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
     nNewNettoWidth = MINFLY;                    // Minimum
 
     eSurround = ( rWW.nSp37 > 1 ) ? SURROUND_IDEAL : SURROUND_NONE;
+    //#i119466 mapping "Around" wrap setting to "Parallel" for table
+    const bool bIsTable = rIo.pPlcxMan->HasParaSprm(0x2416);
+    if (  bIsTable && rWW.nSp37 == 2 )
+        eSurround = SURROUND_PARALLEL;
 
     /*
      #95905#, #83307# seems to have gone away now, so reenable parallel
commit 5bdba378d6fc9f18f618967ec37d07efed2afee4
Author: Armin Le Grand <alg at apache.org>
Date:   Thu Aug 2 10:35:23 2012 +0000

    #120435# Corrected CSS style detection to be executed only once per node

diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 81a47c7..ff44050 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -37,68 +37,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())
-                {
-                    // 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;
+                const SvgDocument& rDocument = getDocument();
 
-                    skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
-
-                    while(nPos < nLen)
+                if(rDocument.hasSvgStyleAttributesById())
+                {
+                    if(getClass())
                     {
-                        rtl::OUStringBuffer aTokenValue;
+                        // 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;
 
-                        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());
+                        while(nPos < nLen)
+                        {
+                            rtl::OUStringBuffer aTokenValue;
 
-                        // look for CSS style common to token
-                        aId = aId + aOUTokenValue;
-                        pNew = rDocument.findSvgStyleAttributesById(aId);
+                            copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
+                            skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
 
-                        if(!pNew && rClassStr.getLength())
-                        {
-                            // look for CSS style common to class.token
-                            aId = rClassStr + aId;
+                            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);
+
+                            if(!pNew && rClassStr.getLength())
+                            {
+                                // look for CSS style common to class.token
+                                aId = rClassStr + 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 none found, search for CSS style equal to class type
+                        const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
 
-                if(maCssStyleVector.empty() && rClassStr.getLength())
-                {
-                    // 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);
+                        }
                     }
                 }
             }
@@ -110,8 +113,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++)
                 {
commit bc589d57f083279b6d619904b937fae706ece493
Author: Armin Le Grand <alg at apache.org>
Date:   Tue Oct 30 14:05:53 2012 +0000

    #121221# added boolean state to remember when the StrokeDasharray was set to empty by purpose

diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
index e8c39d7..4e0c1ac 100644
--- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
+++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
@@ -203,6 +203,9 @@ namespace svgio
             // vaules for fill, stroke, strokeWidth and others
             bool                        mbIsClipPathContent : 1;
 
+            // #121221# Defines if evtl. an empty array *is* set
+            bool                        mbStrokeDasharraySet : 1;
+
             /// internal helpers
             void add_fillGradient(
                 const basegfx::B2DPolyPolygon& rPath,
@@ -319,6 +322,10 @@ namespace svgio
             const SvgNumberVector& getStrokeDasharray() const;
             void setStrokeDasharray(const SvgNumberVector& rStrokeDasharray = SvgNumberVector()) { maStrokeDasharray = rStrokeDasharray; }
 
+            /// #121221# StrokeDasharray needs a set state, it *may* be set to empty by purpose
+            bool getStrokeDasharraySet() const { return mbStrokeDasharraySet; }
+            void setStrokeDasharraySet(bool bNew) { mbStrokeDasharraySet = bNew; }
+
             /// StrokeDashOffset content
             const SvgNumber getStrokeDashOffset() const;
             void setStrokeDashOffset(const SvgNumber& rStrokeDashOffset = SvgNumber()) { maStrokeDashOffset = rStrokeDashOffset; }
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index aa672a6..0787490 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1156,7 +1156,8 @@ namespace svgio
             mpMarkerEndXLink(0),
             maFillRule(FillRule_notset),
             maClipRule(FillRule_nonzero),
-            mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType())
+            mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()),
+            mbStrokeDasharraySet(false)
         {
             if(!mbIsClipPathContent)
             {
@@ -1263,9 +1264,18 @@ namespace svgio
                 {
                     if(aContent.getLength())
                     {
+                        static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
                         SvgNumberVector aVector;
 
-                        if(readSvgNumberVector(aContent, aVector))
+                        if(aContent.match(aStrNone))
+                        {
+                            // #121221# The special value 'none' needs to be handled
+                            // in the sense that *when* it is set, the parent shall not
+                            // be used. Before this was only dependent on the array being
+                            // empty
+                            setStrokeDasharraySet(true);
+                        }
+                        else if(readSvgNumberVector(aContent, aVector))
                         {
                             setStrokeDasharray(aVector);
                         }
@@ -2020,6 +2030,11 @@ namespace svgio
             {
                 return maStrokeDasharray;
             }
+            else if(getStrokeDasharraySet())
+            {
+                // #121221# is set to empty *by purpose*, do not visit parent styles
+                return maStrokeDasharray;
+            }
 
             const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
 
commit f75ca1fdad1094fbea4bb6cb0e3cc9458700c470
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Jul 25 08:28:44 2012 +0000

    Fix #120334# Added support for multiple CSS styles per graphic primitive
    
    (cherry picked from commit 37446076e684a0d0de448366ab927531e3b54bba)
    
    Conflicts:
    	svgio/inc/svgio/svgreader/svgstyleattributes.hxx
    	svgio/source/svgreader/svgcirclenode.cxx
    	svgio/source/svgreader/svgellipsenode.cxx
    	svgio/source/svgreader/svggnode.cxx
    	svgio/source/svgreader/svgimagenode.cxx
    	svgio/source/svgreader/svglinenode.cxx
    	svgio/source/svgreader/svgmarkernode.cxx
    	svgio/source/svgreader/svgpathnode.cxx
    	svgio/source/svgreader/svgpatternnode.cxx
    	svgio/source/svgreader/svgpolynode.cxx
    	svgio/source/svgreader/svgrectnode.cxx
    	svgio/source/svgreader/svgstyleattributes.cxx
    	svgio/source/svgreader/svgtextnode.cxx
    	svgio/source/svgreader/svgusenode.cxx
    
    Change-Id: Id554528932eea590d645cb5e5a1ea8cf7f1d0aac

diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index 1fc1e50..759859b 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -47,6 +47,7 @@ namespace svgio
     namespace svgreader
     {
         typedef ::std::vector< SvgNode* > SvgNodeVector;
+        typedef ::std::vector< const SvgStyleAttributes* > SvgStyleAttributeVector;
 
         enum XmlSpace
         {
@@ -76,6 +77,13 @@ namespace svgio
             /// XmlSpace value
             XmlSpace                    maXmlSpace;
 
+            /// CSS styles
+            SvgStyleAttributeVector     maCssStyleVector;
+
+        protected:
+            /// helper to evtl. link to css style
+            const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+
         public:
             SvgNode(
                 SVGToken aType,
diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
index 6de6351..e8c39d7 100644
--- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
+++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
@@ -136,12 +136,18 @@ namespace svgio
             TextAnchor_end
         };
 
+        enum FillRule
+        {
+            FillRule_notset,
+            FillRule_nonzero,
+            FillRule_evenodd
+        };
+
         class SvgStyleAttributes
         {
         private:
             SvgNode&                    mrOwner;
             const SvgStyleAttributes*   mpCssStyleParent;
-
             SvgPaint                    maFill;
             SvgPaint                    maStroke;
             SvgPaint                    maStopColor;
@@ -184,18 +190,19 @@ namespace svgio
             OUString               maMarkerEndXLink;
             const SvgMarkerNode*        mpMarkerEndXLink;
 
+            /// fill rule
+            FillRule                    maFillRule;
+
+            // ClipRule setting (only valid wne mbIsClipPathContent == true, default is FillRule_nonzero)
+            FillRule                    maClipRule;
+
             /// bitfield
-            bool                        maFillRule : 1; // true: NonZero, false: EvenOdd
-            bool                        maFillRuleSet : 1;
 
             // defines if this attributes are part of a ClipPath. If yes,
             // rough geometry will be created on decomposition by patching
             // vaules for fill, stroke, strokeWidth and others
             bool                        mbIsClipPathContent : 1;
 
-            // ClipRule setting (only valid wne mbIsClipPathContent == true)
-            bool                        mbClipRule : 1; // true == nonzero(default), false == evenodd
-
             /// internal helpers
             void add_fillGradient(
                 const basegfx::B2DPolyPolygon& rPath,
@@ -253,8 +260,9 @@ namespace svgio
                 const drawinglayer::primitive2d::Primitive2DSequence& rSource,
                 const basegfx::B2DHomMatrix* pTransform) const;
 
-            /// helper to evtl. link to css style
-            void checkForCssStyle(const OUString& rClassStr) const;
+            /// helper to set mpCssStyleParent temporarily for CSS style hierarchies
+            void setCssStyleParent(const SvgStyleAttributes* pNew) { mpCssStyleParent = pNew; }
+            const SvgStyleAttributes* getCssStyleParent() const { return mpCssStyleParent; }
 
             /// scan helpers
             void readStyle(const OUString& rCandidate);
@@ -304,7 +312,8 @@ namespace svgio
             void setFillOpacity(const SvgNumber& rFillOpacity = SvgNumber()) { maFillOpacity = rFillOpacity; }
 
             /// fill rule content
-            bool getFillRule() const;
+            const FillRule getFillRule() const;
+            void setFillRule(const FillRule aFillRule = FillRule_notset) { maFillRule = aFillRule; }
 
             /// fill StrokeDasharray content
             const SvgNumberVector& getStrokeDasharray() const;
diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx
index 4f26ae9..6dc269c 100644
--- a/svgio/source/svgreader/svgcirclenode.cxx
+++ b/svgio/source/svgreader/svgcirclenode.cxx
@@ -47,9 +47,7 @@ namespace svgio
         const SvgStyleAttributes* SvgCircleNode::getSvgStyleAttributes() const
         {
             static OUString aClassStr(OUString::createFromAscii("circle"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgCircleNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgellipsenode.cxx b/svgio/source/svgreader/svgellipsenode.cxx
index 1228992..aa42d7a 100644
--- a/svgio/source/svgreader/svgellipsenode.cxx
+++ b/svgio/source/svgreader/svgellipsenode.cxx
@@ -47,10 +47,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgEllipseNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("ellipse"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("ellipse"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgEllipseNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx
index 80a0fa1..d185340 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -45,10 +45,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("g"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("g"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgGNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index 952472c..7c7de6b 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -64,10 +64,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgImageNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("image"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("image"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgImageNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svglinenode.cxx b/svgio/source/svgreader/svglinenode.cxx
index 877bd22..74e9fac 100644
--- a/svgio/source/svgreader/svglinenode.cxx
+++ b/svgio/source/svgreader/svglinenode.cxx
@@ -47,10 +47,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgLineNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("line"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("line"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgLineNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx
index 5ee664d..e79b0f0 100644
--- a/svgio/source/svgreader/svgmarkernode.cxx
+++ b/svgio/source/svgreader/svgmarkernode.cxx
@@ -50,10 +50,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("marker"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("marker"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgMarkerNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index d00beaf..81a47c7 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -35,6 +35,96 @@ namespace svgio
             return 0;
         }
 
+        const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+        {
+            const SvgDocument& rDocument = getDocument();
+
+            if(rDocument.hasSvgStyleAttributesById())
+            {
+                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);
+
+                    while(nPos < nLen)
+                    {
+                        rtl::OUStringBuffer aTokenValue;
+
+                        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());
+
+                        // 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;
+
+                            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() && rClassStr.getLength())
+                {
+                    // 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(maCssStyleVector.empty())
+            {
+                return &rOriginal;
+            }
+            else
+            {
+                // set CssStyleParent at maCssStyleVector members to hang them in front of
+                // the existing style
+                SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal);
+
+                for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++)
+                {
+                    SvgStyleAttributes* pCandidate = const_cast< SvgStyleAttributes* >(maCssStyleVector[maCssStyleVector.size() - a - 1]);
+
+                    pCandidate->setCssStyleParent(pCurrent);
+                    pCurrent = pCandidate;
+                }
+
+                return pCurrent;
+            }
+        }
+
         SvgNode::SvgNode(
             SVGToken aType,
             SvgDocument& rDocument,
@@ -46,7 +136,8 @@ namespace svgio
             maChildren(),
             mpId(0),
             mpClass(0),
-            maXmlSpace(XmlSpace_notset)
+            maXmlSpace(XmlSpace_notset),
+            maCssStyleVector()
         {
             OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)");
 
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index a50beef..9e77f72 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -45,10 +45,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("path"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("path"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgPathNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx
index c507bd3..229a7c6 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -64,10 +64,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgPatternNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("pattern"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("pattern"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgPatternNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index 3100fc3..eef4808 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -47,11 +47,9 @@ namespace svgio
 
         const SvgStyleAttributes* SvgPolyNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStrA(OUString::createFromAscii("polygon"));
-            static OUString aClassStrB(OUString::createFromAscii("polyline"));
-            maSvgStyleAttributes.checkForCssStyle(mbIsPolyline? aClassStrB : aClassStrA);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStrA(rtl::OUString::createFromAscii("polygon"));
+            static rtl::OUString aClassStrB(rtl::OUString::createFromAscii("polyline"));
+            return checkForCssStyle(mbIsPolyline? aClassStrB : aClassStrA, maSvgStyleAttributes);
         }
 
         void SvgPolyNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgrectnode.cxx b/svgio/source/svgreader/svgrectnode.cxx
index c394816..5d518a4 100644
--- a/svgio/source/svgreader/svgrectnode.cxx
+++ b/svgio/source/svgreader/svgrectnode.cxx
@@ -49,10 +49,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgRectNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("rect"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("rect"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgRectNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index a64e66e..aa672a6 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -203,53 +203,11 @@ namespace svgio
             }
         }
 
-        void SvgStyleAttributes::checkForCssStyle(const OUString& rClassStr) const
-        {
-            if(!mpCssStyleParent)
-            {
-                const SvgDocument& rDocument = mrOwner.getDocument();
-                const SvgStyleAttributes* pNew = 0;
-
-                if(rDocument.hasSvgStyleAttributesById())
-                {
-                    if(mrOwner.getClass())
-                    {
-                        OUString aId(OUString::createFromAscii("."));
-                        aId = aId + *mrOwner.getClass();
-                        pNew = rDocument.findSvgStyleAttributesById(aId);
-
-                        if(!pNew && rClassStr.getLength())
-                        {
-                            aId = rClassStr + aId;
-
-                            pNew = rDocument.findSvgStyleAttributesById(aId);
-                        }
-                    }
-
-                    if(!pNew && mrOwner.getId())
-                    {
-                        pNew = rDocument.findSvgStyleAttributesById(*mrOwner.getId());
-                    }
-
-                    if(!pNew && rClassStr.getLength())
-                    {
-                        pNew = rDocument.findSvgStyleAttributesById(rClassStr);
-                    }
-
-                    if(pNew)
-                    {
-                        // found css style, set as parent
-                        const_cast< SvgStyleAttributes* >(this)->mpCssStyleParent = pNew;
-                    }
-                }
-            }
-        }
-
         const SvgStyleAttributes* SvgStyleAttributes::getParentStyle() const
         {
-            if(mpCssStyleParent)
+            if(getCssStyleParent())
             {
-                return mpCssStyleParent;
+                return getCssStyleParent();
             }
 
             if(mrOwner.getParent())
@@ -1061,8 +1019,8 @@ namespace svgio
             {
                 basegfx::B2DPolyPolygon aPath(rPath);
                 const bool bNeedToCheckClipRule(SVGTokenPath == mrOwner.getType() || SVGTokenPolygon == mrOwner.getType());
-                const bool bClipPathIsNonzero(!bIsLine && bNeedToCheckClipRule && mbIsClipPathContent && mbClipRule);
-                const bool bFillRuleIsNonzero(!bIsLine && bNeedToCheckClipRule && !mbIsClipPathContent && getFillRule());
+                const bool bClipPathIsNonzero(!bIsLine && bNeedToCheckClipRule && mbIsClipPathContent && FillRule_nonzero == maClipRule);
+                const bool bFillRuleIsNonzero(!bIsLine && bNeedToCheckClipRule && !mbIsClipPathContent && FillRule_nonzero == getFillRule());
 
                 if(bClipPathIsNonzero || bFillRuleIsNonzero)
                 {
@@ -1196,10 +1154,9 @@ namespace svgio
             mpMarkerMidXLink(0),
             maMarkerEndXLink(),
             mpMarkerEndXLink(0),
-            maFillRule(true),
-            maFillRuleSet(false),
-            mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()),
-            mbClipRule(true)
+            maFillRule(FillRule_notset),
+            maClipRule(FillRule_nonzero),
+            mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType())
         {
             if(!mbIsClipPathContent)
             {
@@ -1266,13 +1223,11 @@ namespace svgio
                     {
                         if(aContent.match(commonStrings::aStrNonzero))
                         {
-                            maFillRule = true;
-                            maFillRuleSet = true;
+                            maFillRule = FillRule_nonzero;
                         }
                         else if(aContent.match(commonStrings::aStrEvenOdd))
                         {
-                            maFillRule = false;
-                            maFillRuleSet = true;
+                            maFillRule = FillRule_evenodd;
                         }
                     }
                     break;
@@ -1783,11 +1738,11 @@ namespace svgio
                     {
                         if(aContent.match(commonStrings::aStrNonzero))
                         {
-                            mbClipRule = true;
+                            maClipRule = FillRule_nonzero;
                         }
                         else if(aContent.match(commonStrings::aStrEvenOdd))
                         {
-                            mbClipRule = false;
+                            maClipRule = FillRule_evenodd;
                         }
                     }
                     break;
@@ -2041,9 +1996,9 @@ namespace svgio
             return SvgNumber(1.0);
         }
 
-        bool SvgStyleAttributes::getFillRule() const
+        const FillRule SvgStyleAttributes::getFillRule() const
         {
-            if(maFillRuleSet)
+            if(FillRule_notset != maFillRule)
             {
                 return maFillRule;
             }
@@ -2056,7 +2011,7 @@ namespace svgio
             }
 
             // default is NonZero
-            return true;
+            return FillRule_nonzero;
         }
 
         const SvgNumberVector& SvgStyleAttributes::getStrokeDasharray() const
diff --git a/svgio/source/svgreader/svgtextnode.cxx b/svgio/source/svgreader/svgtextnode.cxx
index 17cbd90..77adede 100644
--- a/svgio/source/svgreader/svgtextnode.cxx
+++ b/svgio/source/svgreader/svgtextnode.cxx
@@ -49,10 +49,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgTextNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("text"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("text"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgTextNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
diff --git a/svgio/source/svgreader/svgusenode.cxx b/svgio/source/svgreader/svgusenode.cxx
index 65a6949..1768a17 100644
--- a/svgio/source/svgreader/svgusenode.cxx
+++ b/svgio/source/svgreader/svgusenode.cxx
@@ -48,10 +48,8 @@ namespace svgio
 
         const SvgStyleAttributes* SvgUseNode::getSvgStyleAttributes() const
         {
-            static OUString aClassStr(OUString::createFromAscii("use"));
-            maSvgStyleAttributes.checkForCssStyle(aClassStr);
-
-            return &maSvgStyleAttributes;
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("use"));
+            return checkForCssStyle(aClassStr, maSvgStyleAttributes);
         }
 
         void SvgUseNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)


More information about the Libreoffice-commits mailing list