incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1214352 - in /incubator/ooo/branches/alg/svgreplacement/main: drawinglayer/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/source/primitive2d/ svgio/ svgio/inc/svgio/svgreader/ svgio/source/svgreader/
Date Wed, 14 Dec 2011 17:17:52 GMT
Author: alg
Date: Wed Dec 14 17:17:51 2011
New Revision: 1214352

URL: http://svn.apache.org/viewvc?rev=1214352&view=rev
Log:
svg: Added support for Svg property 'pattern'

Added:
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx
  (with props)
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
  (with props)
Modified:
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk
    incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk
    incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Library_drawinglayer.mk Wed
Dec 14 17:17:51 2011
@@ -117,6 +117,7 @@ $(eval $(call gb_Library_add_exception_o
 	drawinglayer/source/primitive2d/metafileprimitive2d \
 	drawinglayer/source/primitive2d/modifiedcolorprimitive2d \
 	drawinglayer/source/primitive2d/pagepreviewprimitive2d \
+	drawinglayer/source/primitive2d/patternfillprimitive2d \
 	drawinglayer/source/primitive2d/polypolygonprimitive2d \
 	drawinglayer/source/primitive2d/polygonprimitive2d \
 	drawinglayer/source/primitive2d/primitivetools2d \

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/Package_inc.mk Wed Dec 14
17:17:51 2011
@@ -55,6 +55,7 @@ $(eval $(call gb_Package_add_file,drawin
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/metafileprimitive2d.hxx,drawinglayer/primitive2d/metafileprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx,drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx,drawinglayer/primitive2d/pagepreviewprimitive2d.hxx))
+$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx,drawinglayer/primitive2d/patternfillprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx,drawinglayer/primitive2d/pointarrayprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/polygonprimitive2d.hxx,drawinglayer/primitive2d/polygonprimitive2d.hxx))
 $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx,drawinglayer/primitive2d/polypolygonprimitive2d.hxx))

Modified: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
Wed Dec 14 17:17:51 2011
@@ -104,6 +104,7 @@
 #define PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D             (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
65)
 #define PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D             (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
66)
 #define PRIMITIVE2D_ID_CROPPRIMITIVE2D                      (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
67)
+#define PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D               (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER|
68)
 
 //////////////////////////////////////////////////////////////////////////////
 

Added: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx?rev=1214352&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx
(added)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx
Wed Dec 14 17:17:51 2011
@@ -0,0 +1,84 @@
+/**************************************************************
+ * 
+ * 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_DRAWINGLAYER_PRIMITIVE2D_PATTERNFILLPRIMITIVE2D_HXX
+#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PATTERNFILLPRIMITIVE2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+    namespace primitive2d
+    {
+        /** PatternFillPrimitive2D class
+
+            This primitive allows filling a given PolyPolygon with a pattern
+            defined by a sequence of primitives which are mapped to  the unit range.
+            The pattern is defined using a reference range which defines a rectangular 
+            area relative to the PolyPolygon (in unit coordinates) which is virtually 
+            infinitely repeated. 
+         */
+        class DRAWINGLAYER_DLLPUBLIC PatternFillPrimitive2D : public BufferedDecompositionPrimitive2D
+        {
+        private:
+            const basegfx::B2DPolyPolygon       maMask;
+            const Primitive2DSequence           maChildren;
+            const basegfx::B2DRange             maReferenceRange;
+
+        protected:
+            /// create local decomposition
+            virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D&
rViewInformation) const;
+
+        public:
+            /// constructor
+            PatternFillPrimitive2D(
+                const basegfx::B2DPolyPolygon& rMask,
+                const Primitive2DSequence& rChildren,
+                const basegfx::B2DRange& rReferenceRange);
+
+            /// data read access
+            const basegfx::B2DPolyPolygon& getMask() const { return maMask; }
+            const Primitive2DSequence& getChildren() const { return maChildren; }
+            const basegfx::B2DRange& getReferenceRange() const { return maReferenceRange;
}
+
+            /// compare operator
+            virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+            /// get range
+            virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D&
rViewInformation) const;
+
+            /// provide unique ID
+            DeclPrimitrive2DIDBlock()
+        };
+    } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PATTERNFILLPRIMITIVE2D_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/inc/drawinglayer/primitive2d/patternfillprimitive2d.hxx
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx?rev=1214352&view=auto
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
(added)
+++ incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
Wed Dec 14 17:17:51 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_drawinglayer.hxx"
+
+#include <drawinglayer/primitive2d/patternfillprimitive2d.hxx>
+#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/texture/texture.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+    namespace primitive2d
+    {
+        Primitive2DSequence PatternFillPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D&
rViewInformation) const
+        {
+            Primitive2DSequence aRetval;
+
+            if(getChildren().hasElements())
+            {
+                if(!getReferenceRange().isEmpty() && getReferenceRange().getWidth()
> 0.0 && getReferenceRange().getHeight() > 0.0)
+                {
+                    const basegfx::B2DRange aMaskRange(getMask().getB2DRange());
+
+                    if(!aMaskRange.isEmpty() && aMaskRange.getWidth() > 0.0 &&
aMaskRange.getHeight() > 0.0)
+                    {
+                        // create tiling matrices
+                        ::std::vector< basegfx::B2DHomMatrix > aMatrices;
+                        texture::GeoTexSvxTiled aTiling(getReferenceRange().getMinimum(),
getReferenceRange().getRange());
+                        aTiling.appendTransformations(aMatrices);
+
+                        // check if content needs to be clipped
+                        const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
+                        const basegfx::B2DRange aContentRange(getB2DRangeFromPrimitive2DSequence(getChildren(),
rViewInformation));
+                        Primitive2DSequence aContent(getChildren());
+
+                        if(!aUnitRange.isInside(aContentRange))
+                        {
+                            const Primitive2DReference xRef(
+                                new MaskPrimitive2D(
+                                    basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aUnitRange)),
+                                    aContent));
+
+                            aContent = Primitive2DSequence(&xRef, 1);
+                        }
+
+                        // resize result
+                        aRetval.realloc(aMatrices.size());
+
+                        // create one primitive for each matrix
+                        for(sal_uInt32 a(0); a < aMatrices.size(); a++)
+                        {
+                            aRetval[a] = new TransformPrimitive2D(
+                                aMatrices[a],
+                                aContent);
+                        }
+
+                        // transform result which is in unit coordinates to mask's object
coordiantes
+                        {
+                            const basegfx::B2DHomMatrix aMaskTransform(
+                                basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                    aMaskRange.getRange(), 
+                                    aMaskRange.getMinimum()));
+
+                            const Primitive2DReference xRef(
+                                new TransformPrimitive2D(
+                                    aMaskTransform,
+                                    aRetval));
+
+                            aRetval = Primitive2DSequence(&xRef, 1);
+                        }
+
+                        // embed result in mask
+                        {
+                            const Primitive2DReference xRef(
+                                new MaskPrimitive2D(
+                                    getMask(),
+                                    aRetval));
+
+                            aRetval = Primitive2DSequence(&xRef, 1);
+                        }
+
+                    }
+                }
+            }
+
+            return aRetval;
+        }
+
+        PatternFillPrimitive2D::PatternFillPrimitive2D(
+            const basegfx::B2DPolyPolygon& rMask,
+            const Primitive2DSequence& rChildren,
+            const basegfx::B2DRange& rReferenceRange)
+        :   BufferedDecompositionPrimitive2D(),
+            maMask(rMask),
+            maChildren(rChildren),
+            maReferenceRange(rReferenceRange)
+        {
+        }
+
+        bool PatternFillPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+        {
+            if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+            {
+                const PatternFillPrimitive2D& rCompare = static_cast< const PatternFillPrimitive2D&
>(rPrimitive);
+
+                return (getMask() == rCompare.getMask()
+                    && getChildren() == rCompare.getChildren()
+                    && getReferenceRange() == rCompare.getReferenceRange());
+            }
+
+            return false;
+        }
+
+        basegfx::B2DRange PatternFillPrimitive2D::getB2DRange(const geometry::ViewInformation2D&
rViewInformation) const
+        {
+            return getMask().getB2DRange();
+        }
+
+        // provide unique ID
+        ImplPrimitrive2DIDBlock(PatternFillPrimitive2D, PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D)
+
+    } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/branches/alg/svgreplacement/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk Wed Dec 14 17:17:51
2011
@@ -72,6 +72,7 @@ $(eval $(call gb_Library_add_exception_o
     svgio/source/svgreader/svgnode \
     svgio/source/svgreader/svgpaint \
     svgio/source/svgreader/svgpathnode \
+    svgio/source/svgreader/svgpatternnode \
     svgio/source/svgreader/svgpolynode \
     svgio/source/svgreader/svgrectnode \
     svgio/source/svgreader/svgstyleattributes \

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk Wed Dec 14 17:17:51
2011
@@ -37,6 +37,7 @@ $(eval $(call gb_Package_add_file,svgio_
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgmasknode.hxx,svgio/svgreader/svgmasknode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgpaint.hxx,svgio/svgreader/svgpaint.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgpathnode.hxx,svgio/svgreader/svgpathnode.hxx))
+$(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgpatternnode.hxx,svgio/svgreader/svgpatternnode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgpolynode.hxx,svgio/svgreader/svgpolynode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgrectnode.hxx,svgio/svgreader/svgrectnode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgstyleattributes.hxx,svgio/svgreader/svgstyleattributes.hxx))

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
Wed Dec 14 17:17:51 2011
@@ -32,6 +32,7 @@
 
 namespace svgio { namespace svgreader { 
     class SvgGradientNode; 
+    class SvgPatternNode; 
     class SvgMarkerNode; 
 }}
 
@@ -151,6 +152,8 @@ namespace svgio
             SvgNumber                   maStopOpacity;
             const SvgGradientNode*      mpSvgGradientNodeFill;
             const SvgGradientNode*      mpSvgGradientNodeStroke;
+            const SvgPatternNode*       mpSvgPatternNodeFill;
+            const SvgPatternNode*       mpSvgPatternNodeStroke;
             SvgNumber                   maFillOpacity;
             SvgNumberVector             maStrokeDasharray;
             SvgNumber                   maStrokeDashOffset;
@@ -199,6 +202,16 @@ namespace svgio
                 drawinglayer::primitive2d::Primitive2DVector& rTarget, 
                 const SvgGradientNode& rFillGradient,
                 const basegfx::B2DRange& rGeoRange) const;
+            void add_fillPatternTransform(
+                const basegfx::B2DPolyPolygon& rPath, 
+                drawinglayer::primitive2d::Primitive2DVector& rTarget, 
+                const SvgPatternNode& rFillGradient,
+                const basegfx::B2DRange& rGeoRange) const;
+            void add_fillPattern(
+                const basegfx::B2DPolyPolygon& rPath, 
+                drawinglayer::primitive2d::Primitive2DVector& rTarget, 
+                const SvgPatternNode& rFillGradient,
+                const basegfx::B2DRange& rGeoRange) const;
             void add_fill(
                 const basegfx::B2DPolyPolygon& rPath, 
                 drawinglayer::primitive2d::Primitive2DVector& rTarget,
@@ -274,10 +287,18 @@ namespace svgio
             const SvgGradientNode* getSvgGradientNodeFill() const;
             void setSvgGradientNodeFill(const SvgGradientNode* pNew) { mpSvgGradientNodeFill
= pNew; }
 
+            /// access to evtl. set fill pattern
+            const SvgPatternNode* getSvgPatternNodeFill() const;
+            void setSvgPatternNodeFill(const SvgPatternNode* pNew) { mpSvgPatternNodeFill
= pNew; }
+
             /// access to evtl. set stroke gradient
             const SvgGradientNode* getSvgGradientNodeStroke() const;
             void setSvgGradientNodeStroke(const SvgGradientNode* pNew) { mpSvgGradientNodeStroke
= pNew; }
 
+            /// access to evtl. set stroke pattern
+            const SvgPatternNode* getSvgPatternNodeStroke() const;
+            void setSvgPatternNodeStroke(const SvgPatternNode* pNew) { mpSvgPatternNodeStroke
= pNew; }
+
             /// fill opacity content
             const SvgNumber getFillOpacity() const;
             void setFillOpacity(const SvgNumber& rFillOpacity = SvgNumber()) { maFillOpacity
= rFillOpacity; }

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
Wed Dec 14 17:17:51 2011
@@ -101,6 +101,10 @@ namespace svgio
             SVGTokenMarkerWidth,
             SVGTokenMarkerHeight,
             SVGTokenOrient,
+            SVGTokenPattern,
+            SVGTokenPatternUnits,
+            SVGTokenPatternContentUnits,
+            SVGTokenPatternTransform,
 
             // AspectRatio and params
             SVGTokenPreserveAspectRatio,

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
Wed Dec 14 17:17:51 2011
@@ -48,6 +48,7 @@
 #include <svgio/svgreader/svgclippathnode.hxx>
 #include <svgio/svgreader/svgmasknode.hxx>
 #include <svgio/svgreader/svgmarkernode.hxx>
+#include <svgio/svgreader/svgpatternnode.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -324,6 +325,15 @@ namespace svgio
                         break;
                     }
 
+                    /// structural element pattern
+                    case SVGTokenPattern:
+                    {
+                        /// new node for pattern
+                        mpTarget = new SvgPatternNode(maDocument, mpTarget);
+                        mpTarget->parseAttributes(xAttribs);
+                        break;
+                    }
+
                     default:
                     {
                         /// invalid token, ignore
@@ -390,6 +400,9 @@ namespace svgio
                     /// structural element marker
                     case SVGTokenMarker:
 
+                    /// structural element pattern
+                    case SVGTokenPattern:
+
                     /// content handling after parsing
                     {
                         if(mpTarget)

Modified: 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=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgnode.cxx Wed
Dec 14 17:17:51 2011
@@ -141,8 +141,9 @@ namespace svgio
                 if(SVGTokenDefs == getType() || 
                     SVGTokenSymbol == getType() ||
                     SVGTokenClipPathNode == getType() ||
+                    SVGTokenMask == getType() ||
                     SVGTokenMarker == getType() ||
-                    SVGTokenMask == getType() )
+                    SVGTokenPattern == getType())
                 {
                     // do not decompose defs or symbol nodes (these hold only style-like
                     // objects which may be used by referencing them) except when doing
@@ -151,6 +152,9 @@ namespace svgio
                     // also do not decompose ClipPaths and Masks. These should be embedded
                     // in a defs node (which gets not decomposed by itself), but you never
                     // know
+
+                    // also not directly used are Markers and Patterns, only indirecty used
+                    // by reference
                     return;
                 }
             }

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
Wed Dec 14 17:17:51 2011
@@ -40,6 +40,8 @@
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <svgio/svgreader/svgmarkernode.hxx>
 #include <basegfx/curve/b2dcubicbezier.hxx>
+#include <svgio/svgreader/svgpatternnode.hxx>
+#include <drawinglayer/primitive2d/patternfillprimitive2d.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -275,14 +277,16 @@ namespace svgio
                 // dismantle to geometry and add needed primitives
                 const basegfx::BColor* pFill = getFill();
                 const SvgGradientNode* pFillGradient = getSvgGradientNodeFill();
+                const SvgPatternNode* pFillPattern = getSvgPatternNodeFill();
                 const basegfx::BColor* pStroke = getStroke();
                 const SvgGradientNode* pStrokeGradient = getSvgGradientNodeStroke();
+                const SvgPatternNode* pStrokePattern = getSvgPatternNodeStroke();
                 basegfx::B2DPolyPolygon aMergedArea;
                 
                 // put primitives into Primitive2DSequence to have clear owner definitions
                 const drawinglayer::primitive2d::Primitive2DSequence aSeq(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(rSource));
 
-                if(pFillGradient || pStroke || pStrokeGradient)
+                if(pFillGradient || pFillPattern || pStroke || pStrokeGradient || pStrokePattern)
                 {
                     // text geometry is needed, create
                     // use neutral ViewInformation and create LineGeometryExtractor2D
@@ -314,13 +318,13 @@ namespace svgio
                     }
                 }
 
-                const bool bStrokeUsed(pStroke || pStrokeGradient);
+                const bool bStrokeUsed(pStroke || pStrokeGradient || pStrokePattern);
 
                 // add fill. Use geometry even for simple color fill when stroke
                 // is used, else text rendering and the geometry-based stroke will
                 // normally not really match optically due to divrese system text
                 // renderers
-                if(aMergedArea.count() && (pFillGradient || bStrokeUsed))
+                if(aMergedArea.count() && (pFillGradient || pFillPattern || bStrokeUsed))
                 {
                     // create text fill content based on geometry
                     add_fill(aMergedArea, rTarget, aMergedArea.getB2DRange());
@@ -471,6 +475,132 @@ namespace svgio
             }
         }
 
+        void SvgStyleAttributes::add_fillPatternTransform(
+            const basegfx::B2DPolyPolygon& rPath, 
+            drawinglayer::primitive2d::Primitive2DVector& rTarget, 
+            const SvgPatternNode& rFillPattern,
+            const basegfx::B2DRange& rGeoRange) const
+        {
+            // prepare fill polyPolygon with given pattern, check for patternTransform
+            if(rFillPattern.getPatternTransform() && !rFillPattern.getPatternTransform()->isIdentity())
+            {
+                // PatternTransform is active; Handle by filling the inverse transformed
+                // path and back-transforming the result
+                basegfx::B2DPolyPolygon aPath(rPath);
+                basegfx::B2DHomMatrix aInv(*rFillPattern.getPatternTransform());
+                drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+                aInv.invert();
+                aPath.transform(aInv);
+                add_fillPattern(aPath, aNewTarget, rFillPattern, aPath.getB2DRange());
+
+                if(aNewTarget.size())
+                {
+                    const drawinglayer::primitive2d::Primitive2DSequence aSequence(Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+
+                    rTarget.push_back(
+                        new drawinglayer::primitive2d::TransformPrimitive2D(
+                            *rFillPattern.getPatternTransform(),
+                            aSequence));
+                }
+            }
+            else
+            {
+                // no patternTransform, create fillPattern directly
+                add_fillPattern(rPath, rTarget, rFillPattern, rGeoRange);
+            }
+        }
+
+        void SvgStyleAttributes::add_fillPattern(
+            const basegfx::B2DPolyPolygon& rPath, 
+            drawinglayer::primitive2d::Primitive2DVector& rTarget, 
+            const SvgPatternNode& rFillPattern,
+            const basegfx::B2DRange& rGeoRange) const
+        {
+            // fill polyPolygon with given pattern
+            const drawinglayer::primitive2d::Primitive2DSequence& rPrimitives = rFillPattern.getPatternPrimitives();
+
+            if(rPrimitives.hasElements())
+            {
+                double fTargetWidth(rGeoRange.getWidth());
+                double fTargetHeight(rGeoRange.getHeight());
+
+                if(fTargetWidth > 0.0 && fTargetHeight > 0.0)
+                {
+                    // get relative values from pattern
+                    double fX(0.0);
+                    double fY(0.0);
+                    double fW(0.0);
+                    double fH(0.0);
+
+                    rFillPattern.getValuesRelative(fX, fY, fW, fH, rGeoRange, mrOwner);
+
+                    if(fW > 0.0 && fH > 0.0)
+                    {
+                        // build the reference range relative to the rGeoRange
+                        const basegfx::B2DRange aReferenceRange(fX, fY, fX + fW, fY + fH);
+
+                        // find out how the content is mapped to the reference range
+                        basegfx::B2DHomMatrix aMapPrimitivesToUnitRange;
+                        const basegfx::B2DRange* pViewBox = rFillPattern.getViewBox();
+
+                        if(pViewBox)
+                        {
+                            // use viewBox/preserveAspectRatio
+                            const SvgAspectRatio& rRatio = rFillPattern.getSvgAspectRatio();
+                            const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
+
+                            if(rRatio.isSet())
+                            {
+                                // let mapping be created from SvgAspectRatio
+                                aMapPrimitivesToUnitRange = rRatio.createMapping(aUnitRange,
*pViewBox);
+                            }
+                            else
+                            {
+                                // choose default mapping
+                                aMapPrimitivesToUnitRange = rRatio.createLinearMapping(aUnitRange,
*pViewBox);
+                            }
+                        }
+                        else
+                        {
+                            // use patternContentUnits
+                            const SvgUnits aPatternContentUnits(rFillPattern.getPatternContentUnits()
? *rFillPattern.getPatternContentUnits() : userSpaceOnUse);
+
+                            if(userSpaceOnUse == aPatternContentUnits)
+                            {
+                                // create relative mapping to unit coordinates
+                                aMapPrimitivesToUnitRange.scale(1.0 / (fW * fTargetWidth),
1.0 / (fH * fTargetHeight));
+                            }
+                            else
+                            {
+                                aMapPrimitivesToUnitRange.scale(1.0 / fW, 1.0 / fH);
+                            }
+                        }
+
+                        // apply aMapPrimitivesToUnitRange to content when used
+                        drawinglayer::primitive2d::Primitive2DSequence aPrimitives(rPrimitives);
+
+                        if(!aMapPrimitivesToUnitRange.isIdentity())
+                        {
+                            const drawinglayer::primitive2d::Primitive2DReference xRef(
+                                new drawinglayer::primitive2d::TransformPrimitive2D(
+                                    aMapPrimitivesToUnitRange,
+                                    aPrimitives));
+
+                            aPrimitives = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                        }
+
+                        // embed in PatternFillPrimitive2D
+                        rTarget.push_back(
+                            new drawinglayer::primitive2d::PatternFillPrimitive2D(
+                                rPath,
+                                aPrimitives,
+                                aReferenceRange));
+                    }
+                }
+            }
+        }
+
         void SvgStyleAttributes::add_fill(
             const basegfx::B2DPolyPolygon& rPath, 
             drawinglayer::primitive2d::Primitive2DVector& rTarget,
@@ -478,8 +608,9 @@ namespace svgio
         {
             const basegfx::BColor* pFill = getFill();
             const SvgGradientNode* pFillGradient = getSvgGradientNodeFill();
+            const SvgPatternNode* pFillPattern = getSvgPatternNodeFill();
 
-            if(pFill || pFillGradient)
+            if(pFill || pFillGradient || pFillPattern)
             {
                 const double fFillOpacity(getFillOpacity().solve(mrOwner, length));
 
@@ -492,6 +623,11 @@ namespace svgio
                         // create fill content with SVG gradient primitive
                         add_fillGradient(rPath, aNewFill, *pFillGradient, rGeoRange);
                     }
+                    else if(pFillPattern)
+                    {
+                        // create fill content with SVG pattern primitive
+                        add_fillPatternTransform(rPath, aNewFill, *pFillPattern, rGeoRange);
+                    }
                     else // if(pFill)
                     {
                         // create fill content
@@ -528,8 +664,9 @@ namespace svgio
         {
             const basegfx::BColor* pStroke = getStroke();
             const SvgGradientNode* pStrokeGradient = getSvgGradientNodeStroke();
+            const SvgPatternNode* pStrokePattern = getSvgPatternNodeStroke();
 
-            if(pStroke || pStrokeGradient)
+            if(pStroke || pStrokeGradient || pStrokePattern)
             {
                 drawinglayer::primitive2d::Primitive2DVector aNewStroke;
                 const double fStrokeOpacity(getStrokeOpacity().solve(mrOwner, length));
@@ -576,7 +713,7 @@ namespace svgio
                                 aDashArray);
                         }
 
-                        if(pStrokeGradient)
+                        if(pStrokeGradient || pStrokePattern)
                         {
                             // put primitive into Primitive2DReference and Primitive2DSequence
                             const drawinglayer::primitive2d::Primitive2DReference aRef(pNewLinePrimitive);
@@ -600,8 +737,18 @@ namespace svgio
 
                                 if(aMergedArea.count())
                                 {
-                                    // create fill content with SVG gradient primitive
-                                    add_fillGradient(aMergedArea, aNewStroke, *pStrokeGradient,
rGeoRange);
+                                    if(pStrokeGradient)
+                                    {
+                                        // create fill content with SVG gradient primitive.
Use original GeoRange,
+                                        // e.g. from circle without LineWidth
+                                        add_fillGradient(aMergedArea, aNewStroke, *pStrokeGradient,
rGeoRange);
+                                    }
+                                    else // if(pStrokePattern)
+                                    {
+                                        // create fill content with SVG pattern primitive.
Use GeoRange
+                                        // from the expanded data, e.g. circle with extended
geo by half linewidth
+                                        add_fillPatternTransform(aMergedArea, aNewStroke,
*pStrokePattern, aMergedArea.getB2DRange());
+                                    }
                                 }
                             }
                         }
@@ -932,6 +1079,8 @@ namespace svgio
             maStopOpacity(),
             mpSvgGradientNodeFill(0),
             mpSvgGradientNodeStroke(0),
+            mpSvgPatternNodeFill(0),
+            mpSvgPatternNodeStroke(0),
             maFillOpacity(),
             maStrokeDasharray(),
             maStrokeDashOffset(),
@@ -993,11 +1142,18 @@ namespace svgio
                     }
                     else if(aURL.getLength())
                     {
-                        const SvgGradientNode* pNode = dynamic_cast< const SvgGradientNode*
>(mrOwner.getDocument().findSvgNodeById(aURL));
+                        const SvgNode* pNode = mrOwner.getDocument().findSvgNodeById(aURL);
 
                         if(pNode)
                         {
-                            setSvgGradientNodeFill(pNode);
+                            if(SVGTokenLinearGradient == pNode->getType() || SVGTokenRadialGradient
 == pNode->getType())
+                            {
+                                setSvgGradientNodeFill(static_cast< const SvgGradientNode*
>(pNode));
+                            }
+                            else if(SVGTokenPattern == pNode->getType())
+                            {
+                                setSvgPatternNodeFill(static_cast< const SvgPatternNode*
>(pNode));
+                            }
                         }
                     }
                     break;
@@ -1043,11 +1199,18 @@ namespace svgio
                     }
                     else if(aURL.getLength())
                     {
-                        const SvgGradientNode* pNode = dynamic_cast< const SvgGradientNode*
>(mrOwner.getDocument().findSvgNodeById(aURL));
+                        const SvgNode* pNode = mrOwner.getDocument().findSvgNodeById(aURL);
 
                         if(pNode)
                         {
-                            setSvgGradientNodeStroke(pNode);
+                            if(SVGTokenLinearGradient == pNode->getType() || SVGTokenRadialGradient
 == pNode->getType())
+                            {
+                                setSvgGradientNodeStroke(static_cast< const SvgGradientNode*
>(pNode));
+                            }
+                            else if(SVGTokenPattern == pNode->getType())
+                            {
+                                setSvgPatternNodeStroke(static_cast< const SvgPatternNode*
>(pNode));
+                            }
                         }
                     }
                     break;
@@ -1670,6 +1833,52 @@ namespace svgio
             return 0;
         }
 
+        const SvgPatternNode* SvgStyleAttributes::getSvgPatternNodeFill() const 
+        { 
+            if(mbIsClipPathContent)
+            {
+                return 0;
+            }
+            else if(mpSvgPatternNodeFill)
+            {
+                return mpSvgPatternNodeFill; 
+            }
+            else
+            {
+                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgPatternNodeFill();
+                }
+            }
+
+            return 0;
+        }
+
+        const SvgPatternNode* SvgStyleAttributes::getSvgPatternNodeStroke() const 
+        { 
+            if(mbIsClipPathContent)
+            {
+                return 0;
+            }
+            else if(mpSvgPatternNodeStroke)
+            {
+                return mpSvgPatternNodeStroke; 
+            }
+            else
+            {
+                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgPatternNodeStroke();
+                }
+            }
+
+            return 0;
+        }
+
         const SvgNumber SvgStyleAttributes::getStrokeWidth() const 
         { 
             if(mbIsClipPathContent)

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx?rev=1214352&r1=1214351&r2=1214352&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx Wed
Dec 14 17:17:51 2011
@@ -92,6 +92,10 @@ namespace svgio
         static rtl::OUString aSVGStrMarkerWidth(rtl::OUString::createFromAscii("markerWidth"));

         static rtl::OUString aSVGStrMarkerHeight(rtl::OUString::createFromAscii("markerHeight"));

         static rtl::OUString aSVGStrOrient(rtl::OUString::createFromAscii("orient")); 
+        static rtl::OUString aSVGStrPattern(rtl::OUString::createFromAscii("pattern")); 
+        static rtl::OUString aSVGStrPatternUnits(rtl::OUString::createFromAscii("patternUnits"));

+        static rtl::OUString aSVGStrPatternContentUnits(rtl::OUString::createFromAscii("patternContentUnits"));

+        static rtl::OUString aSVGStrPatternTransform(rtl::OUString::createFromAscii("patternTransform"));

 
         static rtl::OUString aSVGStrPreserveAspectRatio(rtl::OUString::createFromAscii("preserveAspectRatio"));

         static rtl::OUString aSVGStrDefer(rtl::OUString::createFromAscii("defer")); 
@@ -226,6 +230,10 @@ namespace svgio
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrMarkerWidth, SVGTokenMarkerWidth));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrMarkerHeight, SVGTokenMarkerHeight));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrOrient, SVGTokenOrient));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPattern, SVGTokenPattern));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternUnits, SVGTokenPatternUnits));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternContentUnits,
SVGTokenPatternContentUnits));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternTransform, SVGTokenPatternTransform));
 
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPreserveAspectRatio,
SVGTokenPreserveAspectRatio));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDefer, SVGTokenDefer));



Mime
View raw message