incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1214673 - in /incubator/ooo/branches/alg/svgreplacement/main/svgio: inc/svgio/svgreader/ source/svgreader/
Date Thu, 15 Dec 2011 09:32:30 GMT
Author: alg
Date: Thu Dec 15 09:32:30 2011
New Revision: 1214673

URL: http://svn.apache.org/viewvc?rev=1214673&view=rev
Log:
svg: Added various missing files not yet comitted for the last added features

Added:
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx   (with props)
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx   (with props)

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,73 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+
+#ifndef INCLUDED_SVGIO_SVGREADER_SVGCLIPPATHNODE_HXX
+#define INCLUDED_SVGIO_SVGREADER_SVGCLIPPATHNODE_HXX
+
+#include <svgio/svgiodllapi.h>
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        class SvgClipPathNode : public SvgNode
+        {
+        private:
+            /// use styles
+            SvgStyleAttributes          maSvgStyleAttributes;
+
+            /// variable scan values, dependent of given XAttributeList
+            basegfx::B2DHomMatrix*      mpaTransform;
+            SvgUnits                    maClipPathUnits;
+
+        public:
+            SvgClipPathNode(
+                SvgDocument& rDocument,
+                SvgNode* pParent);
+            virtual ~SvgClipPathNode();
+
+            virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+            virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
+            virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const;
+
+            /// apply contained clipPath to given geometry
+            void apply(drawinglayer::primitive2d::Primitive2DVector& rTarget) const;
+
+            /// clipPathUnits content
+            SvgUnits getClipPathUnits() const { return maClipPathUnits; }
+            void setClipPathUnits(const SvgUnits aClipPathUnits) { maClipPathUnits = aClipPathUnits; }
+
+            /// transform content
+            const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
+            void setTransform(const basegfx::B2DHomMatrix* pMatrix = 0) { if(mpaTransform) delete mpaTransform; mpaTransform = 0; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+        };
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_SVGIO_SVGREADER_SVGCLIPPATHNODE_HXX
+
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgclippathnode.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,123 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+
+#ifndef INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
+#define INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
+
+#include <svgio/svgiodllapi.h>
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        class SvgMarkerNode : public SvgNode
+        {
+        public:
+            enum MarkerUnits
+            {
+                strokeWidth,
+                userSpaceOnUse
+            };
+
+        private:
+            /// buffered decomposition
+            drawinglayer::primitive2d::Primitive2DSequence aPrimitives;
+
+            /// use styles
+            SvgStyleAttributes      maSvgStyleAttributes;
+
+            /// variable scan values, dependent of given XAttributeList
+            basegfx::B2DRange*      mpViewBox;
+            SvgAspectRatio          maSvgAspectRatio;
+            SvgNumber               maRefX;
+            SvgNumber               maRefY;
+            MarkerUnits             maMarkerUnits;
+            SvgNumber               maMarkerWidth;
+            SvgNumber               maMarkerHeight;
+            double                  mfAngle;
+
+            /// bitfield
+            bool                    mbOrientAuto : 1; // true == on, false == fAngle valid
+
+        public:
+            SvgMarkerNode(
+                SvgDocument& rDocument,
+                SvgNode* pParent);
+            virtual ~SvgMarkerNode();
+
+            virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+            virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
+
+            /// get marker primitives buffered, uses decomposeSvgNode internally
+            const drawinglayer::primitive2d::Primitive2DSequence& getMarkerPrimitives() const;
+
+            /// InfoProvider support for % values
+            virtual const basegfx::B2DRange* getCurrentViewPort() const;
+
+            /// viewBox content
+            const basegfx::B2DRange* getViewBox() const { return mpViewBox; }
+            void setViewBox(const basegfx::B2DRange* pViewBox = 0) { if(mpViewBox) delete mpViewBox; mpViewBox = 0; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
+
+            /// SvgAspectRatio content
+            const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }
+            void setSvgAspectRatio(const SvgAspectRatio& rSvgAspectRatio = SvgAspectRatio()) { maSvgAspectRatio = rSvgAspectRatio; }
+
+            /// RefX content, set if found in current context
+            const SvgNumber& getRefX() const { return maRefX; }
+            void setRefX(const SvgNumber& rRefX = SvgNumber()) { maRefX = rRefX; }
+
+            /// RefY content, set if found in current context
+            const SvgNumber& getRefY() const { return maRefY; }
+            void setRefY(const SvgNumber& rRefY = SvgNumber()) { maRefY = rRefY; }
+
+            /// MarkerUnits content
+            MarkerUnits getMarkerUnits() const { return maMarkerUnits; }
+            void setMarkerUnits(const MarkerUnits aMarkerUnits) { maMarkerUnits = aMarkerUnits; }
+
+            /// MarkerWidth content, set if found in current context
+            const SvgNumber& getMarkerWidth() const { return maMarkerWidth; }
+            void setMarkerWidth(const SvgNumber& rMarkerWidth = SvgNumber()) { maMarkerWidth = rMarkerWidth; }
+
+            /// MarkerHeight content, set if found in current context
+            const SvgNumber& getMarkerHeight() const { return maMarkerHeight; }
+            void setMarkerHeight(const SvgNumber& rMarkerHeight = SvgNumber()) { maMarkerHeight = rMarkerHeight; }
+
+            /// Angle content, set if found in current context
+            double getAngle() const { return mfAngle; }
+            void setAngle(double fAngle = 0.0) { mfAngle = fAngle; mbOrientAuto = false; }
+
+            /// OrientAuto content, set if found in current context
+            bool getOrientAuto() const { return mbOrientAuto; }
+            void setOrientAuto(bool bOrientAuto = true) { mbOrientAuto = bOrientAuto; }
+
+        };
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
+
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmarkernode.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,98 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+
+#ifndef INCLUDED_SVGIO_SVGREADER_SVGMASKNODE_HXX
+#define INCLUDED_SVGIO_SVGREADER_SVGMASKNODE_HXX
+
+#include <svgio/svgiodllapi.h>
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        class SvgMaskNode : public SvgNode
+        {
+        private:
+            /// use styles
+            SvgStyleAttributes          maSvgStyleAttributes;
+
+            /// variable scan values, dependent of given XAttributeList
+            SvgNumber                   maX;
+            SvgNumber                   maY;
+            SvgNumber                   maWidth;
+            SvgNumber                   maHeight;
+            basegfx::B2DHomMatrix*      mpaTransform;
+            SvgUnits                    maMaskUnits;
+            SvgUnits                    maMaskContentUnits;
+
+        public:
+            SvgMaskNode(
+                SvgDocument& rDocument,
+                SvgNode* pParent);
+            virtual ~SvgMaskNode();
+
+            virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+            virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
+            virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector& rTarget, bool bReferenced) const;
+
+            /// apply contained clipPath to given geometry
+            void apply(drawinglayer::primitive2d::Primitive2DVector& rTarget) const;
+
+            /// x content, set if found in current context
+            const SvgNumber& getX() const { return maX; }
+            void setX(const SvgNumber& rX = SvgNumber()) { maX = rX; }
+
+            /// y content, set if found in current context
+            const SvgNumber& getY() const { return maY; }
+            void setY(const SvgNumber& rY = SvgNumber()) { maY = rY; }
+
+            /// width content, set if found in current context
+            const SvgNumber& getWidth() const { return maWidth; }
+            void setWidth(const SvgNumber& rWidth = SvgNumber()) { maWidth = rWidth; }
+
+            /// height content, set if found in current context
+            const SvgNumber& getHeight() const { return maHeight; }
+            void setHeight(const SvgNumber& rHeight = SvgNumber()) { maHeight = rHeight; }
+
+            /// transform content
+            const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
+            void setTransform(const basegfx::B2DHomMatrix* pMatrix = 0) { if(mpaTransform) delete mpaTransform; mpaTransform = 0; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+
+            /// MaskUnits content
+            SvgUnits getMaskUnits() const { return maMaskUnits; }
+            void setMaskUnits(const SvgUnits aMaskUnits) { maMaskUnits = aMaskUnits; }
+
+            /// MaskContentUnits content
+            SvgUnits getMaskContentUnits() const { return maMaskContentUnits; }
+            void setMaskContentUnits(const SvgUnits aMaskContentUnits) { maMaskContentUnits = aMaskContentUnits; }
+        };
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_SVGIO_SVGREADER_SVGMASKNODE_HXX
+
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgmasknode.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,126 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+
+#ifndef INCLUDED_SVGIO_SVGREADER_SVGPATTERNNODE_HXX
+#define INCLUDED_SVGIO_SVGREADER_SVGPATTERNNODE_HXX
+
+#include <svgio/svgiodllapi.h>
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        class SvgPatternNode : public SvgNode
+        {
+        private:
+            /// buffered decomposition
+            drawinglayer::primitive2d::Primitive2DSequence aPrimitives;
+
+            /// use styles
+            SvgStyleAttributes      maSvgStyleAttributes;
+
+            /// variable scan values, dependent of given XAttributeList
+            basegfx::B2DRange*      mpViewBox;
+            SvgAspectRatio          maSvgAspectRatio;
+            SvgNumber               maX;
+            SvgNumber               maY;
+            SvgNumber               maWidth;
+            SvgNumber               maHeight;
+            SvgUnits*               mpPatternUnits;
+            SvgUnits*               mpPatternContentUnits;
+            basegfx::B2DHomMatrix*  mpaPatternTransform;
+
+            /// link to another pattern used as style. If maXLink
+            /// is set, the node can be fetched on demand by using 
+            // tryToFindLink (buffered)
+            rtl::OUString           maXLink;
+            const SvgPatternNode*   mpXLink;
+
+            /// link on demand
+            void tryToFindLink();
+
+        public:
+            SvgPatternNode(
+                SvgDocument& rDocument,
+                SvgNode* pParent);
+            virtual ~SvgPatternNode();
+
+            virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+            virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
+
+            /// global helpers
+            void getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode& rUser) const;
+
+            /// get pattern primitives buffered, uses decomposeSvgNode internally
+            const drawinglayer::primitive2d::Primitive2DSequence& getPatternPrimitives() const;
+
+            /// InfoProvider support for % values
+            virtual const basegfx::B2DRange* getCurrentViewPort() const;
+
+            /// viewBox content
+            const basegfx::B2DRange* getViewBox() const;
+            void setViewBox(const basegfx::B2DRange* pViewBox = 0) { if(mpViewBox) delete mpViewBox; mpViewBox = 0; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
+
+            /// SvgAspectRatio content
+            const SvgAspectRatio& getSvgAspectRatio() const;
+            void setSvgAspectRatio(const SvgAspectRatio& rSvgAspectRatio = SvgAspectRatio()) { maSvgAspectRatio = rSvgAspectRatio; }
+
+            /// X content, set if found in current context
+            const SvgNumber& getX() const;
+            void setX(const SvgNumber& rX = SvgNumber()) { maX = rX; }
+
+            /// Y content, set if found in current context
+            const SvgNumber& getY() const;
+            void setY(const SvgNumber& rY = SvgNumber()) { maY = rY; }
+
+            /// Width content, set if found in current context
+            const SvgNumber& getWidth() const;
+            void setWidth(const SvgNumber& rWidth = SvgNumber()) { maWidth = rWidth; }
+
+            /// Height content, set if found in current context
+            const SvgNumber& getHeight() const;
+            void setHeight(const SvgNumber& rHeight = SvgNumber()) { maHeight = rHeight; }
+
+            /// PatternUnits content
+            const SvgUnits* getPatternUnits() const;
+            void setPatternUnits(const SvgUnits aPatternUnits) { if(mpPatternUnits) delete mpPatternUnits; mpPatternUnits = 0; mpPatternUnits = new SvgUnits(aPatternUnits); }
+
+            /// PatternContentUnits content
+            const SvgUnits* getPatternContentUnits() const;
+            void setPatternContentUnits(const SvgUnits aPatternContentUnits) { if(mpPatternContentUnits) delete mpPatternContentUnits; mpPatternContentUnits = 0; mpPatternContentUnits = new SvgUnits(aPatternContentUnits); }
+
+            /// PatternTransform content
+            const basegfx::B2DHomMatrix* getPatternTransform() const;
+            void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix = 0) { if(mpaPatternTransform) delete mpaPatternTransform; mpaPatternTransform = 0; if(pMatrix) mpaPatternTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+
+        };
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_SVGIO_SVGREADER_SVGPATTERNNODE_HXX
+
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpatternnode.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,186 @@
+/**************************************************************
+ * 
+ * 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/svgclippathnode.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgClipPathNode::SvgClipPathNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenClipPathNode, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            mpaTransform(0),
+            maClipPathUnits(userSpaceOnUse)
+        {
+        }
+
+        SvgClipPathNode::~SvgClipPathNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgClipPathNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("clip-path"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgClipPathNode::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;
+                }
+                case SVGTokenClipPathUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setClipPathUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
+                        {
+                            setClipPathUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgClipPathNode::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());
+                }
+            }
+        }
+
+        void SvgClipPathNode::apply(drawinglayer::primitive2d::Primitive2DVector& rTarget) const
+        {
+            if(rTarget.size())
+            {
+                drawinglayer::primitive2d::Primitive2DVector aClipTarget;
+
+                // get clipPath definition as primitives
+                decomposeSvgNode(aClipTarget, true);
+
+                if(aClipTarget.size())
+                {
+                    // put content and clip definition to primitive sequence
+                    const drawinglayer::primitive2d::Primitive2DSequence aContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(rTarget));
+                    drawinglayer::primitive2d::Primitive2DSequence aClip(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aClipTarget));
+
+                    if(objectBoundingBox == getClipPathUnits())
+                    {
+                        // clip is object-relative, embed in content transformation
+                        const basegfx::B2DRange aContentRange(
+                            drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
+                                aContent,
+                                drawinglayer::geometry::ViewInformation2D()));
+
+                        const drawinglayer::primitive2d::Primitive2DReference xTransform(
+                            new drawinglayer::primitive2d::TransformPrimitive2D(
+                                basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                    aContentRange.getRange(),
+                                    aContentRange.getMinimum()),
+                                aClip));
+
+                        aClip = drawinglayer::primitive2d::Primitive2DSequence(&xTransform, 1);
+                    }
+
+                    // redefine target. Use TransparencePrimitive2D with created clip
+                    // geometry. Using the automatically set mbIsClipPathContent at 
+                    // SvgStyleAttributes the clip definition is without fill, stroke, 
+                    // and strokeWidth and forced to black, thus being 100% opaque
+                    rTarget.clear();
+                    rTarget.push_back(
+                        new drawinglayer::primitive2d::TransparencePrimitive2D(
+                            aContent,
+                            aClip));
+                }
+                else
+                {
+                    // An empty clipping path will completely clip away the element that had 
+                    // the ‘clip-path’ property applied. (Svg spec)
+                    rTarget.clear();
+                }
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx Thu Dec 15 09:32:30 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/svgmarkernode.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgMarkerNode::SvgMarkerNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenMarker, rDocument, pParent),
+            aPrimitives(),
+            maSvgStyleAttributes(*this),
+            mpViewBox(0),
+            maSvgAspectRatio(),
+            maRefX(0),
+            maRefY(0),
+            maMarkerUnits(strokeWidth),
+            maMarkerWidth(3),
+            maMarkerHeight(3),
+            mfAngle(0.0),
+            mbOrientAuto(false)
+        {
+        }
+
+        SvgMarkerNode::~SvgMarkerNode()
+        {
+            if(mpViewBox) delete mpViewBox;
+        }
+
+        const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("marker"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgMarkerNode::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 SVGTokenViewBox:
+                {
+                    const basegfx::B2DRange aRange(readViewBox(aContent, *this));
+
+                    if(!aRange.isEmpty())
+                    {
+                        setViewBox(&aRange);
+                    }
+                    break;
+                }
+                case SVGTokenPreserveAspectRatio:
+                {
+                    setSvgAspectRatio(readSvgAspectRatio(aContent));
+                    break;
+                }
+                case SVGTokenRefX:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setRefX(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenRefY:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setRefY(aNum);
+                    }
+                    break;
+                }
+                case SVGTokenMarkerUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        static rtl::OUString aStrStrokeWidth(rtl::OUString::createFromAscii("strokeWidth"));
+
+                        if(aContent.match(aStrStrokeWidth, 0))
+                        {
+                            setMarkerUnits(strokeWidth);
+                        }
+                        else if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setMarkerUnits(userSpaceOnUse);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenMarkerWidth:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setMarkerWidth(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenMarkerHeight:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        if(aNum.isPositive())
+                        {
+                            setMarkerHeight(aNum);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenOrient:
+                {
+                    const sal_Int32 nLen(aContent.getLength());
+
+                    if(nLen)
+                    {
+                        static rtl::OUString aStrAuto(rtl::OUString::createFromAscii("auto"));
+
+                        if(aContent.match(aStrAuto, 0))
+                        {
+                            setOrientAuto(true);
+                        }
+                        else
+                        {
+                            sal_Int32 nPos(0);
+                            double fAngle(0.0);
+
+                            if(readAngle(aContent, nPos, fAngle, nLen))
+                            {
+                                setAngle(fAngle);
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        const drawinglayer::primitive2d::Primitive2DSequence& SvgMarkerNode::getMarkerPrimitives() const
+        {
+            if(!aPrimitives.hasElements())
+            {
+                drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+                decomposeSvgNode(aNewTarget, true);
+
+                if(aNewTarget.size())
+                {
+                    const_cast< SvgMarkerNode* >(this)->aPrimitives = drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget);
+                }
+            }
+
+            return aPrimitives;
+        }
+
+        const basegfx::B2DRange* SvgMarkerNode::getCurrentViewPort() const
+        {
+            if(getViewBox())
+            {
+                return getViewBox();
+            }
+            else
+            {
+                return SvgNode::getCurrentViewPort();
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmarkernode.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,317 @@
+/**************************************************************
+ * 
+ * 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/svgmasknode.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        SvgMaskNode::SvgMaskNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenMask, rDocument, pParent),
+            maSvgStyleAttributes(*this),
+            maX(SvgNumber(-10.0, Unit_percent, true)),
+            maY(SvgNumber(-10.0, Unit_percent, true)),
+            maWidth(SvgNumber(120.0, Unit_percent, true)),
+            maHeight(SvgNumber(120.0, Unit_percent, true)),
+            mpaTransform(0),
+            maMaskUnits(objectBoundingBox),
+            maMaskContentUnits(userSpaceOnUse)
+        {
+        }
+
+        SvgMaskNode::~SvgMaskNode()
+        {
+            if(mpaTransform) delete mpaTransform;
+        }
+
+        const SvgStyleAttributes* SvgMaskNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("mask"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgMaskNode::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 SVGTokenTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setTransform(&aMatrix);
+                    }
+                    break;
+                }
+                case SVGTokenMaskUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setMaskUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
+                        {
+                            setMaskUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenMaskContentUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setMaskContentUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
+                        {
+                            setMaskContentUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgMaskNode::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());
+                }
+            }
+        }
+
+        void SvgMaskNode::apply(drawinglayer::primitive2d::Primitive2DVector& rTarget) const
+        {
+            if(rTarget.size())
+            {
+                drawinglayer::primitive2d::Primitive2DVector aMaskTarget;
+
+                // get mask definition as primitives
+                decomposeSvgNode(aMaskTarget, true);
+
+                if(aMaskTarget.size())
+                {
+                    // put content and clip definition to primitive sequence
+                    const drawinglayer::primitive2d::Primitive2DSequence aContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(rTarget));
+                    drawinglayer::primitive2d::Primitive2DSequence aMask(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aMaskTarget));
+
+                    // get range of content to be masked
+                    const basegfx::B2DRange aContentRange(
+                        drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
+                            aContent,
+                            drawinglayer::geometry::ViewInformation2D()));
+                    const double fContentWidth(aContentRange.getWidth());
+                    const double fContentHeight(aContentRange.getHeight());
+
+                    if(fContentWidth > 0.0 && fContentHeight > 0.0)
+                    {
+                        // create OffscreenBufferRange
+                        basegfx::B2DRange aOffscreenBufferRange;
+
+                        if(objectBoundingBox == getMaskUnits())
+                        {
+                            // fractions or percentages of the bounding box of the element to which the mask is applied
+                            const double fX(Unit_percent == getX().getUnit() ? getX().getNumber() * 0.01 : getX().getNumber());
+                            const double fY(Unit_percent == getY().getUnit() ? getY().getNumber() * 0.01 : getY().getNumber());
+                            const double fW(Unit_percent == getWidth().getUnit() ? getWidth().getNumber() * 0.01 : getWidth().getNumber());
+                            const double fH(Unit_percent == getHeight().getUnit() ? getHeight().getNumber() * 0.01 : getHeight().getNumber());
+
+                            aOffscreenBufferRange = basegfx::B2DRange(
+                                aContentRange.getMinX() + (fX * fContentWidth), 
+                                aContentRange.getMinY() + (fY * fContentHeight),
+                                aContentRange.getMinX() + ((fX + fW) * fContentWidth), 
+                                aContentRange.getMinY() + ((fY + fH) * fContentHeight));
+                        }
+                        else
+                        {
+                            const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0);
+                            const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0);
+
+                            aOffscreenBufferRange = basegfx::B2DRange(
+                                fX,
+                                fY,
+                                fX + (getWidth().isSet() ? getWidth().solve(*this, xcoordinate) : 0.0),
+                                fY + (getHeight().isSet() ? getHeight().solve(*this, ycoordinate) : 0.0));
+                        }
+
+                        if(objectBoundingBox == getMaskContentUnits())
+                        {
+                            // mask is object-relative, embed in content transformation
+                            const drawinglayer::primitive2d::Primitive2DReference xTransform(
+                                new drawinglayer::primitive2d::TransformPrimitive2D(
+                                    basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                        aContentRange.getRange(),
+                                        aContentRange.getMinimum()),
+                                    aMask));
+
+                            aMask = drawinglayer::primitive2d::Primitive2DSequence(&xTransform, 1);
+                        }
+
+                        // embed content to a ModifiedColorPrimitive2D since the definitions
+                        // how content is used as alpha is special for Svg
+                        {
+                            const drawinglayer::primitive2d::Primitive2DReference xInverseMask(
+                                new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
+                                    aMask,
+                                    basegfx::BColorModifier(
+                                        basegfx::BColor(0.0, 0.0, 0.0),
+                                        0.5,
+                                        basegfx::BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA)));
+
+                            aMask = drawinglayer::primitive2d::Primitive2DSequence(&xInverseMask, 1);
+                        }
+
+                        // prepare new content
+                        drawinglayer::primitive2d::BasePrimitive2D* pNewContent = new drawinglayer::primitive2d::TransparencePrimitive2D(
+                            aContent,
+                            aMask);
+
+                        // output up to now is defined by aContentRange and mask is oriented
+                        // relative to it. It is possible that aOffscreenBufferRange defines
+                        // a smaller area. In that case, embed to a mask primitive
+                        if(!aOffscreenBufferRange.isInside(aContentRange))
+                        {
+                            const drawinglayer::primitive2d::Primitive2DReference xContent(pNewContent);
+
+                            pNewContent = new drawinglayer::primitive2d::MaskPrimitive2D(
+                                basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aOffscreenBufferRange)),
+                                drawinglayer::primitive2d::Primitive2DSequence(&xContent, 1));
+                        }
+
+                        // redefine target. Use TransparencePrimitive2D with created mask
+                        // geometry
+                        rTarget.clear();
+                        rTarget.push_back(pNewContent);
+                    }
+                }
+                else
+                {
+                    // An empty clipping path will completely clip away the element that had 
+                    // the ‘clip-path’ property applied. (Svg spec)
+                    rTarget.clear();
+                }
+            }
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgmasknode.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx?rev=1214673&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx (added)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx Thu Dec 15 09:32:30 2011
@@ -0,0 +1,469 @@
+/**************************************************************
+ * 
+ * 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/svgpatternnode.hxx>
+#include <svgio/svgreader/svgdocument.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svgio
+{
+    namespace svgreader
+    {
+        void SvgPatternNode::tryToFindLink()
+        {
+            if(!mpXLink && maXLink.getLength())
+            {
+                mpXLink = dynamic_cast< const SvgPatternNode* >(getDocument().findSvgNodeById(maXLink));
+            }
+        }
+
+        SvgPatternNode::SvgPatternNode(
+            SvgDocument& rDocument,
+            SvgNode* pParent)
+        :   SvgNode(SVGTokenPattern, rDocument, pParent),
+            aPrimitives(),
+            maSvgStyleAttributes(*this),
+            mpViewBox(0),
+            maSvgAspectRatio(),
+            maX(),
+            maY(),
+            maWidth(),
+            maHeight(),
+            mpPatternUnits(0),
+            mpPatternContentUnits(0),
+            mpaPatternTransform(0),
+            maXLink(),
+            mpXLink(0)
+        {
+        }
+
+        SvgPatternNode::~SvgPatternNode()
+        {
+            if(mpViewBox) delete mpViewBox;
+            if(mpaPatternTransform) delete mpaPatternTransform;
+            if(mpPatternUnits) delete mpPatternUnits;
+            if(mpPatternContentUnits) delete mpPatternContentUnits;
+        }
+
+        const SvgStyleAttributes* SvgPatternNode::getSvgStyleAttributes() const
+        {
+            static rtl::OUString aClassStr(rtl::OUString::createFromAscii("pattern"));
+            maSvgStyleAttributes.checkForCssStyle(aClassStr);
+
+            return &maSvgStyleAttributes;
+        }
+
+        void SvgPatternNode::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 SVGTokenViewBox:
+                {
+                    const basegfx::B2DRange aRange(readViewBox(aContent, *this));
+
+                    if(!aRange.isEmpty())
+                    {
+                        setViewBox(&aRange);
+                    }
+                    break;
+                }
+                case SVGTokenPreserveAspectRatio:
+                {
+                    setSvgAspectRatio(readSvgAspectRatio(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 SVGTokenPatternUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setPatternUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
+                        {
+                            setPatternUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenPatternContentUnits:
+                {
+                    if(aContent.getLength())
+                    {
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
+                        {
+                            setPatternContentUnits(userSpaceOnUse);
+                        }
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
+                        {
+                            setPatternContentUnits(objectBoundingBox);
+                        }
+                    }
+                    break;
+                }
+                case SVGTokenPatternTransform:
+                {
+                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+                    if(!aMatrix.isIdentity())
+                    {
+                        setPatternTransform(&aMatrix);
+                    }
+                    break;
+                }
+                case SVGTokenXlinkHref:
+                {
+                    const sal_Int32 nLen(aContent.getLength());
+
+                    if(nLen && sal_Unicode('#') == aContent[0])
+                    {
+                        maXLink = aContent.copy(1);
+                        tryToFindLink();
+                    }
+                    break;
+                }
+            }
+        }
+
+        void SvgPatternNode::getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode& rUser) const
+        {
+            double fTargetWidth(rGeoRange.getWidth());
+            double fTargetHeight(rGeoRange.getHeight());
+
+            if(fTargetWidth > 0.0 && fTargetHeight > 0.0)
+            {
+                const SvgUnits aPatternUnits(getPatternUnits() ? *getPatternUnits() : objectBoundingBox);
+
+                if(objectBoundingBox == aPatternUnits)
+                {
+                    rfW = (getWidth().isSet()) ? getWidth().getNumber() : 0.0;
+                    rfH = (getHeight().isSet()) ? getHeight().getNumber() : 0.0;
+
+                    if(Unit_percent == getWidth().getUnit())
+                    {
+                        rfW *= 0.01;
+                    }
+
+                    if(Unit_percent == getHeight().getUnit())
+                    {
+                        rfH *= 0.01;
+                    }
+                }
+                else
+                {
+                    rfW = (getWidth().isSet()) ? getWidth().solve(rUser, xcoordinate) : 0.0;
+                    rfH = (getHeight().isSet()) ? getHeight().solve(rUser, ycoordinate) : 0.0;
+
+                    // make relative to rGeoRange
+                    rfW /= fTargetWidth;
+                    rfH /= fTargetHeight;
+                }
+
+                if(rfW > 0.0 && rfH > 0.0)
+                {
+                    if(objectBoundingBox == aPatternUnits)
+                    {
+                        rfX = (getX().isSet()) ? getX().getNumber() : 0.0;
+                        rfY = (getY().isSet()) ? getY().getNumber() : 0.0;
+
+                        if(Unit_percent == getX().getUnit())
+                        {
+                            rfX *= 0.01;
+                        }
+
+                        if(Unit_percent == getY().getUnit())
+                        {
+                            rfY *= 0.01;
+                        }
+                    }
+                    else
+                    {
+                        rfX = (getX().isSet()) ? getX().solve(rUser, xcoordinate) : 0.0;
+                        rfY = (getY().isSet()) ? getY().solve(rUser, ycoordinate) : 0.0;
+
+                        // make relative to rGeoRange
+                        rfX = (rfX - rGeoRange.getMinX()) / fTargetWidth;
+                        rfY = (rfY - rGeoRange.getMinY()) / fTargetHeight;
+                    }
+                }
+            }
+        }
+
+        const drawinglayer::primitive2d::Primitive2DSequence& SvgPatternNode::getPatternPrimitives() const
+        {
+            if(!aPrimitives.hasElements())
+            {
+                drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+                decomposeSvgNode(aNewTarget, true);
+
+                if(aNewTarget.size())
+                {
+                    const_cast< SvgPatternNode* >(this)->aPrimitives = drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget);
+                }
+            }
+
+            if(!aPrimitives.hasElements() && maXLink.getLength())
+            {
+                const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+                if(mpXLink)
+                {
+                    return mpXLink->getPatternPrimitives();
+                }
+            }
+
+            return aPrimitives;
+        }
+
+        const basegfx::B2DRange* SvgPatternNode::getCurrentViewPort() const
+        {
+            if(getViewBox())
+            {
+                return getViewBox();
+            }
+            else
+            {
+                return SvgNode::getCurrentViewPort();
+            }
+        }
+
+        const basegfx::B2DRange* SvgPatternNode::getViewBox() const 
+        { 
+            if(mpViewBox)
+            {
+                return mpViewBox; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getViewBox();
+            }
+
+            return 0;
+        }
+
+        const SvgAspectRatio& SvgPatternNode::getSvgAspectRatio() const 
+        { 
+            if(maSvgAspectRatio.isSet())
+            {
+                return maSvgAspectRatio; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getSvgAspectRatio();
+            }
+
+            return maSvgAspectRatio; 
+        }
+
+        const SvgNumber& SvgPatternNode::getX() const 
+        { 
+            if(maX.isSet())
+            {
+                return maX; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getX();
+            }
+
+            return maX; 
+        }
+
+        const SvgNumber& SvgPatternNode::getY() const 
+        { 
+            if(maY.isSet())
+            {
+                return maY; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getY();
+            }
+
+            return maY; 
+        }
+
+        const SvgNumber& SvgPatternNode::getWidth() const 
+        { 
+            if(maWidth.isSet())
+            {
+                return maWidth; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getWidth();
+            }
+
+            return maWidth; 
+        }
+
+        const SvgNumber& SvgPatternNode::getHeight() const 
+        { 
+            if(maHeight.isSet())
+            {
+                return maHeight; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getHeight();
+            }
+
+            return maHeight; 
+        }
+
+        const SvgUnits* SvgPatternNode::getPatternUnits() const 
+        { 
+            if(mpPatternUnits)
+            {
+                return mpPatternUnits; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getPatternUnits();
+            }
+
+            return 0; 
+        }
+
+        const SvgUnits* SvgPatternNode::getPatternContentUnits() const 
+        { 
+            if(mpPatternContentUnits)
+            {
+                return mpPatternContentUnits; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getPatternContentUnits();
+            }
+
+            return 0; 
+        }
+
+        const basegfx::B2DHomMatrix* SvgPatternNode::getPatternTransform() const 
+        { 
+            if(mpaPatternTransform)
+            {
+                return mpaPatternTransform; 
+            }
+
+            const_cast< SvgPatternNode* >(this)->tryToFindLink();
+
+            if(mpXLink)
+            {
+                return mpXLink->getPatternTransform();
+            }
+
+            return 0; 
+        }
+
+    } // end of namespace svgreader
+} // end of namespace svgio
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgpatternnode.cxx
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message