incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1209140 [6/11] - in /incubator/ooo/branches/alg/svgreplacement/main: ./ basegfx/inc/basegfx/matrix/ basegfx/inc/basegfx/polygon/ basegfx/source/polygon/ cppcanvas/source/mtfrenderer/ drawinglayer/ drawinglayer/inc/drawinglayer/primitive2d/...
Date Thu, 01 Dec 2011 16:26:53 GMT
Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,116 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svggnode.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgGNode::SvgGNode(
+            SVGToken aType,
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(aType, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            mpaTransform(0)
+        {
+            OSL_ENSURE(aType == SVGTokenDefs || aType == SVGTokenG, "SvgGNode should ony be used for Group and Defs (!)");
+        }
+
+        SvgGNode::~SvgGNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("g"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgGNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+            // decompose childs
+            SvgNode::decomposeSvgNode(aNewTarget, bReferenced);
+
+            if(!aNewTarget.empty())
+            {
+                if(getTransform())
+                {
+                    // create embedding group element with transformation
+                    rTarget.push_back(
+                        new drawinglayer::primitive2d::TransformPrimitive2D(
+                            *getTransform(),
+                            Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
+                    aNewTarget.clear();
+                }
+                else
+                {
+                    // append to current target
+                    rTarget.insert(rTarget.end(), aNewTarget.begin(), aNewTarget.end());
+                }
+            }
+        }
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,499 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svggradientnode.hxx>
+#include <svgio/svgreader/svgdocument.hxx>
+#include <svgio/svgreader/svggradientstopnode.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        void SvgGradientNode::tryToFindLink()
+        {
+            if(!mpXLink && maXLink.getLength())
+            {
+                mpXLink = dynamic_cast< const SvgGradientNode* >(getDocument().findSvgNodeById(maXLink));
+            }
+        }
+
+        SvgGradientNode::SvgGradientNode(
+            SVGToken aType,
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(aType, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maX1(),
+            maY1(),
+            maX2(),
+            maY2(),
+            maCx(),
+            maCy(),
+            maR(),
+            maFx(),
+            maFy(),
+            maGradientUnits(objectBoundingBox),
+            maSpreadMethod(drawinglayer::primitive2d::Spread_pad),
+            mpaGradientTransform(0),
+            maXLink(),
+            mpXLink(0)
+        {
+        }
+
+        SvgGradientNode::~SvgGradientNode()
+        {
+            if(mpaGradientTransform) delete mpaGradientTransform;
+            // do NOT delete mpXLink, it's only referenced, not owned
+        }
+
+        const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
+        {
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgGradientNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenX1:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX1(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY1:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY1(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenX2:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX2(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY2:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY2(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenCx:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setCx(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenCy:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setCy(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenFx:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setFx(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenFy:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setFy(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenR:
+                {
+                    SvgNumber aNum;
+                        
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setR(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenGradientUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        static rtl::OUString aStrUserSpaceOnUse(rtl::OUString::createFromAscii("userSpaceOnUse"));
+                        static rtl::OUString aStrObjectBoundingBox(rtl::OUString::createFromAscii("objectBoundingBox"));
+                        
+                        if(aContent.match(aStrUserSpaceOnUse, 0))
+                        {
+                            setGradientUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(aStrObjectBoundingBox, 0))
+                        {
+                            setGradientUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenSpreadMethod:
+                {
+                    if(aContent.getLength())
+                    {
+                        static rtl::OUString aStrPad(rtl::OUString::createFromAscii("pad"));
+                        static rtl::OUString aStrReflect(rtl::OUString::createFromAscii("reflect"));
+                        static rtl::OUString aStrRepeat(rtl::OUString::createFromAscii("repeat"));
+                        
+                        if(aContent.match(aStrPad, 0))
+                        {
+                            setSpreadMethod(drawinglayer::primitive2d::Spread_pad);
+                        }
+                        else if(aContent.match(aStrReflect, 0))
+                        {
+                            setSpreadMethod(drawinglayer::primitive2d::Spread_reflect);
+                        }
+                        else if(aContent.match(aStrRepeat, 0))
+                        {
+                            setSpreadMethod(drawinglayer::primitive2d::Spread_repeat);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenGradientTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setGradientTransform(&aMatrix);
+                    }
+                    break;
+                }
+                case SVGTokenXlinkHref:
+                {
+                    const sal_Int32 nLen(aContent.getLength());
+
+                    if(nLen && sal_Unicode('#') == aContent[0])
+                    {
+                        maXLink = aContent.copy(1);
+                        tryToFindLink();
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgGradientNode::collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const
+        {
+            if(getChildren().empty())
+            {
+                const_cast< SvgGradientNode* >(this)->tryToFindLink();
+    
+                if(mpXLink)
+                {
+                    mpXLink->collectGradientEntries(aVector);
+                }
+            }
+            else
+            {
+                const sal_uInt32 nCount(getChildren().size());
+
+                for(sal_uInt32 a(0); a < nCount; a++)
+                {
+                    const SvgGradientStopNode* pCandidate = dynamic_cast< const SvgGradientStopNode* >(getChildren()[a]);
+
+                    if(pCandidate)
+                    {
+                        const SvgStyleAttributes* pStyle = pCandidate->getSvgStyleAttributes();
+
+                        if(pStyle)
+                        {
+                            double fOffset(pCandidate->getOffset().solve(*this));
+
+                            if(fOffset < 0.0)
+                            {
+                                OSL_ENSURE(false, "OOps, SvgGradientStopNode with offset out of range (!)");
+                                fOffset = 0.0;
+                            }
+                            else if(fOffset > 1.0)
+                            {
+                                OSL_ENSURE(false, "OOps, SvgGradientStopNode with offset out of range (!)");
+                                fOffset = 1.0;
+                            }
+
+                            aVector.push_back(
+                                drawinglayer::primitive2d::SvgGradientEntry(
+                                    fOffset,
+                                    pStyle->getStopColor(),
+                                    pStyle->getStopOpacity().solve(*this)));
+                        }
+                        else
+                        {
+                            OSL_ENSURE(false, "OOps, SvgGradientStopNode without Style (!)");
+                        }
+                    }
+                }
+            }
+        }
+
+        const SvgNumber SvgGradientNode::getX1() const
+        {
+            if(maX1.isSet())
+            {
+                return maX1;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getX1();
+            }
+
+            // default is 0%
+            return SvgNumber(0.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getY1() const
+        {
+            if(maY1.isSet())
+            {
+                return maY1;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getY1();
+            }
+
+            // default is 0%
+            return SvgNumber(0.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getX2() const
+        {
+            if(maX2.isSet())
+            {
+                return maX2;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getX2();
+            }
+
+            // default is 100%
+            return SvgNumber(100.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getY2() const
+        {
+            if(maY2.isSet())
+            {
+                return maY2;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getY2();
+            }
+
+            // default is 0%
+            return SvgNumber(0.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getCx() const
+        {
+            if(maCx.isSet())
+            {
+                return maCx;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getCx();
+            }
+
+            // default is 50%
+            return SvgNumber(50.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getCy() const
+        {
+            if(maCy.isSet())
+            {
+                return maCy;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getCy();
+            }
+
+            // default is 50%
+            return SvgNumber(50.0, Unit_percent);
+        }
+
+        const SvgNumber SvgGradientNode::getR() const
+        {
+            if(maR.isSet())
+            {
+                return maR;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getR();
+            }
+
+            // default is 50%
+            return SvgNumber(50.0, Unit_percent);
+        }
+
+        const SvgNumber* SvgGradientNode::getFx() const
+        {
+            if(maFx.isSet())
+            {
+                return &maFx;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getFx();
+            }
+
+            return 0;
+        }
+
+        const SvgNumber* SvgGradientNode::getFy() const
+        {
+            if(maFy.isSet())
+            {
+                return &maFy;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getFy();
+            }
+
+            return 0;
+        }
+
+        const basegfx::B2DHomMatrix* SvgGradientNode::getGradientTransform() const
+        {
+            if(mpaGradientTransform)
+            {
+                return mpaGradientTransform;
+            }
+
+            const_cast< SvgGradientNode* >(this)->tryToFindLink();
+            
+            if(mpXLink)
+            {
+                return mpXLink->getGradientTransform();
+            }
+
+            return 0;
+        }
+
+        void SvgGradientNode::setGradientTransform(const basegfx::B2DHomMatrix* pMatrix)
+        {
+            if(mpaGradientTransform)
+            {
+                delete mpaGradientTransform;
+                mpaGradientTransform = 0;
+            }
+
+            if(pMatrix)
+            {
+                mpaGradientTransform = new basegfx::B2DHomMatrix(*pMatrix);
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientstopnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientstopnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientstopnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientstopnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,87 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svggradientstopnode.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgGradientStopNode::SvgGradientStopNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenStop, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maOffset()
+        {
+        }
+
+        SvgGradientStopNode::~SvgGradientStopNode()
+        {
+        }
+
+        const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
+        {
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgGradientStopNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenOffset:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setOffset(aNum);
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,178 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgimagenode.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgImageNode::SvgImageNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenRect, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maSvgAspectRatio(),
+            mpaTransform(0),
+            maX(0),
+            maY(0),
+            maWidth(0),
+            maHeight(0),
+            maXLink()
+        {
+        }
+
+        SvgImageNode::~SvgImageNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgImageNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("image"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgImageNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenPreserveAspectRatio:
+                {
+                    setSvgAspectRatio(readSvgAspectRatio(aContent));
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+                case SVGTokenX:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenWidth:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setWidth(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenHeight:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setHeight(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenXlinkHref:
+                {
+                    const sal_Int32 nLen(aContent.getLength());
+
+                    if(nLen && sal_Unicode('#') == aContent[0])
+                    {
+                        maXLink = aContent.copy(1);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgImageNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            // get size range and create path
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+
+            if(pStyle && getWidth().isSet() && getHeight().isSet())
+            {
+                const double fWidth(getWidth().solve(*this, xcoordinate));
+                const double fHeight(getHeight().solve(*this, ycoordinate));
+
+                if(fWidth > 0.0 && fHeight > 0.0)
+                {
+                    const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0);
+                    const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0);
+                    const basegfx::B2DRange aRange(fX, fY, fX + fWidth, fY + fHeight);
+
+
+
+
+                }
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svglinenode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svglinenode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svglinenode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svglinenode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,158 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svglinenode.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgLineNode::SvgLineNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenLine, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maX1(0),
+            maY1(0),
+            maX2(0),
+            maY2(0),
+            mpaTransform(0)
+        {
+        }
+
+        SvgLineNode::~SvgLineNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgLineNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("line"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgLineNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenX1:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX1(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY1:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY1(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenX2:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX2(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY2:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY2(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgLineNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+
+            if(pStyle)
+            {
+                const basegfx::B2DPoint X(
+                    getX1().isSet() ? getX1().solve(*this, xcoordinate) : 0.0,
+                    getY1().isSet() ? getY1().solve(*this, ycoordinate) : 0.0);
+                const basegfx::B2DPoint Y(
+                    getX2().isSet() ? getX2().solve(*this, xcoordinate) : 0.0,
+                    getY2().isSet() ? getY2().solve(*this, ycoordinate) : 0.0);
+
+                if(!X.equal(Y))
+                {
+                    basegfx::B2DPolygon aPath;
+                
+                    aPath.append(X);
+                    aPath.append(Y);
+
+                    pStyle->add_path(basegfx::B2DPolyPolygon(aPath), rTarget, getTransform());
+                }
+            }
+        }
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,257 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgnode.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svgio/svgreader/svgdocument.hxx>
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        const SvgStyleAttributes* SvgNode::getSvgStyleAttributes() const
+        {
+            return 0;
+        }
+
+        SvgNode::SvgNode(
+            SVGToken aType,
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   maType(aType),
+            mrDocument(rDocument),
+            mpParent(pParent),
+            mpAlternativeParent(0),
+            maChildren(),
+            mpId(0),
+            mpClass(0),
+            maXmlSpace(XmlSpace_notset)
+        {
+            OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)");
+            
+            if(pParent)
+            {
+                pParent->maChildren.push_back(this);
+            }
+            else
+            {
+#ifdef DBG_UTIL
+                if(SVGTokenSvg != getType())
+                {
+                    OSL_ENSURE(false, "No parent for this node (!)");
+                }
+#endif
+            }
+        }
+
+        SvgNode::~SvgNode()
+        {
+            while(maChildren.size())
+            {
+                delete maChildren[maChildren.size() - 1];
+                maChildren.pop_back();
+            }
+
+            if(mpId) delete mpId;
+            if(mpClass) delete mpClass;
+        }
+
+        void SvgNode::parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs)
+        {
+            const sal_uInt32 nAttributes(xAttribs->getLength());
+            
+            for(sal_uInt32 a(0); a < nAttributes; a++)
+            {
+                const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(a));
+                        
+                parseAttribute(aTokenName, StrToSVGToken(aTokenName), xAttribs->getValueByIndex(a));
+            }
+        }
+
+        void SvgNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            switch(aSVGToken)
+            {
+                case SVGTokenId:
+                {
+                    if(aContent.getLength())
+                    {
+                        setId(&aContent);
+                    }
+                    break;
+                }
+                case SVGTokenClass:
+                {
+                    if(aContent.getLength())
+                    {
+                        setClass(&aContent);
+                    }
+                    break;
+                }
+                case SVGTokenXmlSpace:
+                {
+                    if(aContent.getLength())
+                    {
+                        static rtl::OUString aStrDefault(rtl::OUString::createFromAscii("default"));
+                        static rtl::OUString aStrPreserve(rtl::OUString::createFromAscii("preserve"));
+
+                        if(aContent.match(aStrDefault))
+                        {
+                            setXmlSpace(XmlSpace_default);
+                        }
+                        else if(aContent.match(aStrPreserve))
+                        {
+                            setXmlSpace(XmlSpace_preserve);
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            if(!bReferenced && (SVGTokenDefs == getType() || SVGTokenSymbol == getType()))
+            {
+                // do not decompose defs or symbol nodes (these hold only style-like
+                // objects which may be used by referencing them) except when doing
+                // so controlled referenced
+                return;
+            }
+
+            const SvgNodeVector& rChildren = getChildren();
+
+            if(!rChildren.empty())
+            {
+                const sal_uInt32 nCount(rChildren.size());
+
+                for(sal_uInt32 a(0); a < nCount; a++)
+                {
+                    rChildren[a]->decomposeSvgNode(rTarget, bReferenced);
+                }
+            }
+        }
+
+        const basegfx::B2DRange* SvgNode::getCurrentViewPort() const
+        {
+            if(getParent())
+            {
+                return getParent()->getCurrentViewPort();
+            }
+            else
+            {
+                return 0;
+            }
+        }
+
+        double SvgNode::getCurrentFontSize() const
+        {
+            if(getSvgStyleAttributes())
+            {
+                return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate);
+            }
+            else if(getParent())
+            {
+                return getParent()->getCurrentFontSize();
+            }
+            else
+            {
+                return 0.0;
+            }
+        }
+
+        double SvgNode::getCurrentXHeight() const
+        {
+            if(getSvgStyleAttributes())
+            {
+                // for XHeight, use FontSize currently
+                return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate);
+            }
+            else if(getParent())
+            {
+                return getParent()->getCurrentXHeight();
+            }
+            else
+            {
+                return 0.0;
+            }
+        }
+
+        void SvgNode::setId(const rtl::OUString* pfId) 
+        { 
+            if(mpId) 
+            {
+                mrDocument.removeSvgNodeFromMapper(*mpId);
+                delete mpId; 
+                mpId = 0; 
+            }
+                
+            if(pfId) 
+            {
+                mpId = new rtl::OUString(*pfId); 
+                mrDocument.addSvgNodeToMapper(*mpId, *this);
+            }
+        }
+
+        void SvgNode::setClass(const rtl::OUString* pfClass) 
+        { 
+            if(mpClass) 
+            {
+                mrDocument.removeSvgNodeFromMapper(*mpClass);
+                delete mpClass; 
+                mpClass = 0; 
+            }
+                
+            if(pfClass) 
+            {
+                mpClass = new rtl::OUString(*pfClass); 
+                mrDocument.addSvgNodeToMapper(*mpClass, *this);
+            }
+        }
+
+        XmlSpace SvgNode::getXmlSpace() const
+        {
+            if(maXmlSpace != XmlSpace_notset)
+            {
+                return maXmlSpace;
+            }
+            
+            if(getParent())
+            {
+                return getParent()->getXmlSpace(); 
+            }
+
+            // default is XmlSpace_default
+            return XmlSpace_default; 
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpaint.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpaint.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpaint.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpaint.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,37 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgpaint.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpathnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpathnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpathnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,125 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgpathnode.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgPathNode::SvgPathNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenPath, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            mpPolyPolygon(0),
+            mpaTransform(0),
+            maPathLength()
+        {
+        }
+
+        SvgPathNode::~SvgPathNode()
+        {
+            if(mpPolyPolygon) delete mpPolyPolygon;
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("path"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgPathNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenD:
+                {
+                    basegfx::B2DPolyPolygon aPath;
+                    
+                    if(basegfx::tools::importFromSvgD(aPath, aContent))
+                    {
+                        if(aPath.count())
+                        {
+                            setPath(&aPath);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+                case SVGTokenPathLength:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setPathLength(aNum);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgPathNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            // fill and/or stroke needed, also a path
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+            
+            if(pStyle && getPath())
+            {
+                pStyle->add_path(*getPath(), rTarget, getTransform());
+            }
+        }
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpolynode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpolynode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpolynode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpolynode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,121 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgpolynode.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgPolyNode::SvgPolyNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent,
+            bool bIsPolyline)
+        :   SvgNode(SVGTokenPolygon, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            mpPolygon(0),
+            mpaTransform(0),
+            mbIsPolyline(bIsPolyline)
+        {
+        }
+
+        SvgPolyNode::~SvgPolyNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+            if(mpPolygon) delete mpPolygon;
+        }
+
+        const SvgStyleAttributes* SvgPolyNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("poly"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgPolyNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenPoints:
+                {
+                    basegfx::B2DPolygon aPath;
+                    
+                    if(basegfx::tools::importFromSvgPoints(aPath, aContent))
+                    {
+                        if(aPath.count())
+                        {
+                            if(!isPolyline())
+                            {
+                                aPath.setClosed(true);
+                            }
+
+                            setPolygon(&aPath);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgPolyNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+
+            if(pStyle && getPolygon())
+            {
+                pStyle->add_path(basegfx::B2DPolyPolygon(*getPolygon()), rTarget, getTransform());
+            }
+        }
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgrectnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgrectnode.cxx?rev=1209140&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgrectnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgrectnode.cxx Thu Dec  1 16:25:17 2011
@@ -0,0 +1,219 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svgio.hxx"
+
+#include <svgio/svgreader/svgrectnode.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgRectNode::SvgRectNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenRect, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maX(0),
+            maY(0),
+            maWidth(0),
+            maHeight(0),
+            maRx(0),
+            maRy(0),
+            mpaTransform(0)
+        {
+        }
+
+        SvgRectNode::~SvgRectNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgRectNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("rect"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgRectNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
+        {
+            // call parent
+            SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+            // read style attributes
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+
+            // parse own
+            switch(aSVGToken)
+            {
+                case SVGTokenStyle:
+                {
+                    maSvgStyleAttributes.readStyle(aContent);
+                    break;
+                }
+                case SVGTokenX:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setX(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenY:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setY(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenWidth:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setWidth(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenHeight:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setHeight(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenRx:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setRx(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenRy:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setRy(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgRectNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const
+        {
+            // get size range and create path
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+
+            if(pStyle && getWidth().isSet() && getHeight().isSet())
+            {
+                const double fWidth(getWidth().solve(*this, xcoordinate));
+                const double fHeight(getHeight().solve(*this, ycoordinate));
+
+                if(fWidth > 0.0 && fHeight > 0.0)
+                {
+                    const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0);
+                    const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0);
+                    const basegfx::B2DRange aRange(fX, fY, fX + fWidth, fY + fHeight);
+                    basegfx::B2DPolygon aPath;
+
+                    if(getRx().isSet() || getRy().isSet())
+                    {
+                        double frX(getRx().isSet() ? getRx().solve(*this, xcoordinate) : 0.0);
+                        double frY(getRy().isSet() ? getRy().solve(*this, ycoordinate) : 0.0);
+
+                        frX = std::max(0.0, frX);
+                        frY = std::max(0.0, frY);
+
+                        if(0.0 == frY && frX > 0.0)
+                        {
+                            frY = frX;
+                        }
+                        else if(0.0 == frX && frY > 0.0)
+                        {
+                            frX = frY;
+                        }
+
+                        frX /= fWidth;
+                        frY /= fHeight;
+
+                        frX = std::min(0.5, frX);
+                        frY = std::min(0.5, frY);
+
+                        aPath = basegfx::tools::createPolygonFromRect(aRange, frX * 2.0, frY * 2.0);
+                    }
+                    else
+                    {
+                        aPath = basegfx::tools::createPolygonFromRect(aRange);
+                    }
+
+                    pStyle->add_path(basegfx::B2DPolyPolygon(aPath), rTarget, getTransform());
+                }
+            }
+        }
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof



Mime
View raw message