incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1212349 - in /incubator/ooo/branches/alg/svgreplacement/main: basegfx/inc/basegfx/color/ basegfx/source/color/ svgio/ svgio/inc/svgio/svgreader/ svgio/source/svgreader/
Date Fri, 09 Dec 2011 12:07:03 GMT
Author: alg
Date: Fri Dec  9 12:07:02 2011
New Revision: 1212349

URL: http://svn.apache.org/viewvc?rev=1212349&view=rev
Log:
svg: Added clipPath and mask property support

Modified:
    incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolor.hxx
    incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolormodifier.hxx
    incubator/ooo/branches/alg/svgreplacement/main/basegfx/source/color/bcolormodifier.cxx
    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/svggradientnode.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtextpathnode.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtools.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtrefnode.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgusenode.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.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/svgtextpathnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtrefnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx

Modified: incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolor.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolor.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolor.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolor.hxx Fri
Dec  9 12:07:02 2011
@@ -151,9 +151,9 @@ namespace basegfx
 		// luminance
 		double luminance() const
 		{
-			const double fRedWeight(77.0 / 256.0);
-			const double fGreenWeight(151.0 / 256.0);
-			const double fBlueWeight(28.0 / 256.0);
+			const double fRedWeight(77.0 / 256.0);      // 0.30
+			const double fGreenWeight(151.0 / 256.0);   // 0.59
+			const double fBlueWeight(28.0 / 256.0);     // 0.11
 
 			return (mfX * fRedWeight + mfY * fGreenWeight + mfZ * fBlueWeight);
 		}

Modified: incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolormodifier.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolormodifier.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolormodifier.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/basegfx/inc/basegfx/color/bcolormodifier.hxx
Fri Dec  9 12:07:02 2011
@@ -35,10 +35,12 @@ namespace basegfx
 	*/
 	enum BColorModifyMode
 	{
-		BCOLORMODIFYMODE_REPLACE,		// replace all color with local color
-		BCOLORMODIFYMODE_INTERPOLATE,	// interpolate color between given and local with local value
-		BCOLORMODIFYMODE_GRAY,			// convert color to gray
-		BCOLORMODIFYMODE_BLACKANDWHITE	// convert color to B&W, local value is treshhold
+		BCOLORMODIFYMODE_REPLACE,		        // replace all color with local color
+		BCOLORMODIFYMODE_INTERPOLATE,	        // interpolate color between given and local with
local value
+		BCOLORMODIFYMODE_GRAY,			        // convert color to gray
+		BCOLORMODIFYMODE_BLACKANDWHITE,	        // convert color to B&W, local value is treshhold
+        BCOLORMODIFYMODE_INVERT,                // invert color
+        BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA     // convert color to alpha value (used for
Svg Mask)
 	};
 
 	/**	Class to hold a color, value and mode for a color modification. Color modification is

Modified: incubator/ooo/branches/alg/svgreplacement/main/basegfx/source/color/bcolormodifier.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/basegfx/source/color/bcolormodifier.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/basegfx/source/color/bcolormodifier.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/basegfx/source/color/bcolormodifier.cxx
Fri Dec  9 12:07:02 2011
@@ -56,6 +56,15 @@ namespace basegfx
 					return ::basegfx::BColor(1.0, 1.0, 1.0);
 				}
 			}
+            case BCOLORMODIFYMODE_INVERT :
+            {
+                return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(),
1.0 - aSourceColor.getBlue());
+            }
+            case BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA:
+            {
+                const double fAlpha(1.0 - ((aSourceColor.getRed() * 0.2125) + (aSourceColor.getGreen()
* 0.7154) + (aSourceColor.getBlue() * 0.0721)));
+                return ::basegfx::BColor(fAlpha, fAlpha, fAlpha);
+            }
 			default : // BCOLORMODIFYMODE_REPLACE
 			{
 				return maBColor;

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=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/Library_svgio.mk Fri Dec  9 12:07:02
2011
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_add_linked_libs
 $(eval $(call gb_Library_add_exception_objects,svgio,\
     svgio/source/svgreader/svgcharacternode \
     svgio/source/svgreader/svgcirclenode \
+    svgio/source/svgreader/svgclippathnode \
     svgio/source/svgreader/svgdocument \
     svgio/source/svgreader/svgdocumenthandler \
     svgio/source/svgreader/svgellipsenode \
@@ -66,6 +67,7 @@ $(eval $(call gb_Library_add_exception_o
     svgio/source/svgreader/svggradientstopnode \
     svgio/source/svgreader/svgimagenode \
     svgio/source/svgreader/svglinenode \
+    svgio/source/svgreader/svgmasknode \
     svgio/source/svgreader/svgnode \
     svgio/source/svgreader/svgpaint \
     svgio/source/svgreader/svgpathnode \

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=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/Package_inc.mk Fri Dec  9 12:07:02
2011
@@ -23,6 +23,7 @@ $(eval $(call gb_Package_Package,svgio_i
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgiodllapi.h,svgio/svgiodllapi.h))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgcharacternode.hxx,svgio/svgreader/svgcharacternode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgcirclenode.hxx,svgio/svgreader/svgcirclenode.hxx))
+$(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgclippathnode.hxx,svgio/svgreader/svgclippathnode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgdocument.hxx,svgio/svgreader/svgdocument.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgdocumenthandler.hxx,svgio/svgreader/svgdocumenthandler.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgellipsenode.hxx,svgio/svgreader/svgellipsenode.hxx))
@@ -32,6 +33,7 @@ $(eval $(call gb_Package_add_file,svgio_
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgimagenode.hxx,svgio/svgreader/svgimagenode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svglinenode.hxx,svgio/svgreader/svglinenode.hxx))
 $(eval $(call gb_Package_add_file,svgio_inc,inc/svgio/svgreader/svgnode.hxx,svgio/svgreader/svgnode.hxx))
+$(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/svgpolynode.hxx,svgio/svgreader/svgpolynode.hxx))

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svggradientnode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svggradientnode.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svggradientnode.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svggradientnode.hxx
Fri Dec  9 12:07:02 2011
@@ -33,12 +33,6 @@ namespace svgio
 {
     namespace svgreader
     {
-        enum gradientUnits
-        {
-            userSpaceOnUse,
-            objectBoundingBox
-        };
-
         class SvgGradientNode : public SvgNode
         {
         private:
@@ -59,12 +53,13 @@ namespace svgio
             SvgNumber                   maFy;
 
             /// variable scan values, dependent of given XAttributeList
-            gradientUnits               maGradientUnits;
+            SvgUnits                    maGradientUnits;
             drawinglayer::primitive2d::SpreadMethod   maSpreadMethod;
             basegfx::B2DHomMatrix*      mpaGradientTransform;
 
             /// link to another gradient used as style. If maXLink
-            /// is set, the node can be fetched on demand
+            /// is set, the node can be fetched on demand by using 
+            // tryToFindLink (buffered)
             rtl::OUString               maXLink;
             const SvgGradientNode*      mpXLink;
 
@@ -121,8 +116,8 @@ namespace svgio
             void setFy(const SvgNumber& rFy = SvgNumber()) { maFy = rFy; }
 
             /// gradientUnits content
-            gradientUnits getGradientUnits() const { return maGradientUnits; }
-            void setGradientUnits(const gradientUnits aGradientUnits) { maGradientUnits =
aGradientUnits; }
+            SvgUnits getGradientUnits() const { return maGradientUnits; }
+            void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits;
}
 
             /// SpreadMethod content
             drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod;
}

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=1212349&r1=1212348&r2=1212349&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
Fri Dec  9 12:07:02 2011
@@ -166,10 +166,19 @@ namespace svgio
             TextAnchor                  maTextAnchor;
             SvgPaint                    maColor;
 
+            /// link to content. If maXLink is set, the node can be fetched on demand
+            rtl::OUString               maClipPathXLink;
+            rtl::OUString               maMaskXLink;
+
             /// bitfield
             bool                        maFillRule : 1; // true: NonZero, false: EvenOdd
             bool                        maFillRuleSet : 1;
 
+            // defines if this attributes are part of a ClipPath. If yes,
+            // rough geometry will be created on decomposition by patching
+            // vaules for fill, stroke, strokeWidth and others
+            bool                        mbIsClipPathContent : 1;
+
             /// internal helpers
             void add_fillGradient(
                 const basegfx::B2DPolyPolygon& rPath, 
@@ -201,6 +210,9 @@ namespace svgio
             /// helper to evtl. link to css style
             void checkForCssStyle(const rtl::OUString& rClassStr) const;
 
+            /// helper to postprocess created primitives
+            void decomposePostProcess(drawinglayer::primitive2d::Primitive2DVector& rTarget)
const;
+
             /// scan helpers
             void readStyle(const rtl::OUString& rCandidate);
             const SvgStyleAttributes* getParentStyle() const;
@@ -309,6 +321,14 @@ namespace svgio
             const basegfx::BColor* getColor() const;
             void setColor(const SvgPaint& rColor) { maColor = rColor; }
 
+            // ClipPathXLink content
+            const rtl::OUString getClipPathXLink() const { return maClipPathXLink; }
+            void setClipPathXLink(const rtl::OUString& rNew) { maClipPathXLink = rNew;
}
+
+            // MaskXLink content
+            const rtl::OUString getMaskXLink() const { return maMaskXLink; }
+            void setMaskXLink(const rtl::OUString& rNew) { maMaskXLink = rNew; }
+
         };
     } // end of namespace svgreader
 } // end of namespace svgio

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtextpathnode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtextpathnode.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtextpathnode.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtextpathnode.hxx
Fri Dec  9 12:07:02 2011
@@ -42,7 +42,6 @@ namespace svgio
             /// link to path content. If maXLink
             /// is set, the node can be fetched on demand
             rtl::OUString           maXLink;
-            const SvgPathNode*      mpXLink;
 
             /// variable scan values, dependent of given XAttributeList
             SvgNumber               maStartOffset;
@@ -51,9 +50,6 @@ namespace svgio
             bool                    mbMethod : 1; // true = align, false = stretch
             bool                    mbSpacing : 1; // true = auto, false = exact
 
-            /// link on demand
-            void tryToFindLink();
-
         public:
             SvgTextPathNode(
                 SvgDocument& rDocument,
@@ -79,9 +75,6 @@ namespace svgio
             /// Spacing content
             bool getSpacing() const { return mbSpacing; }
             void setSpacing(bool bNew) { mbSpacing = bNew; }
-
-            /// access to referenced SvgPathNode
-            const SvgPathNode* getReferencedSvgPathNode() const;
         };
     } // end of namespace svgreader
 } // end of namespace svgio

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=1212349&r1=1212348&r2=1212349&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
Fri Dec  9 12:07:02 2011
@@ -84,6 +84,12 @@ namespace svgio
             SVGTokenTextAnchor,
             SVGTokenXmlSpace,
             SVGTokenColor,
+            SVGTokenClipPathNode,
+            SVGTokenClipPathProperty,
+            SVGTokenMask,
+            SVGTokenClipPathUnits,
+            SVGTokenMaskUnits,
+            SVGTokenMaskContentUnits,
 
             // AspectRatio and params
             SVGTokenPreserveAspectRatio,

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtools.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtools.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtools.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtools.hxx
Fri Dec  9 12:07:02 2011
@@ -40,6 +40,19 @@ namespace svgio
         void myAssert(const rtl::OUString& rMessage);
 #endif
 
+        // common non-token strings
+        struct commonStrings
+        {
+            static const rtl::OUString aStrUserSpaceOnUse;
+            static const rtl::OUString aStrObjectBoundingBox;
+        };
+
+        enum SvgUnits
+        {
+            userSpaceOnUse,
+            objectBoundingBox
+        };
+
         enum NumberType
         {
             xcoordinate,
@@ -185,6 +198,7 @@ namespace svgio
         basegfx::B2DRange readViewBox(const rtl::OUString& rCandidate, InfoProvider&
rInfoProvider);
         basegfx::B2DHomMatrix readTransform(const rtl::OUString& rCandidate, InfoProvider&
rInfoProvider);
         bool readSingleNumber(const rtl::OUString& rCandidate, SvgNumber& aNum);
+        bool readLocalUrl(const rtl::OUString& rCandidate, rtl::OUString& rURL);
         bool readSvgPaint(const rtl::OUString& rCandidate, SvgPaint& rSvgPaint, rtl::OUString&
rURL);
 
         bool readSvgNumberVector(const rtl::OUString& rCandidate, SvgNumberVector&
rSvgNumberVector);

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtrefnode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtrefnode.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtrefnode.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtrefnode.hxx
Fri Dec  9 12:07:02 2011
@@ -42,10 +42,6 @@ namespace svgio
             /// link to text content. If maXLink
             /// is set, the node can be fetched on demand
             rtl::OUString               maXLink;
-            const SvgTextNode*          mpXLink;
-
-            /// link on demand
-            void tryToFindLink();
 
         public:
             SvgTrefNode(

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgusenode.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgusenode.hxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgusenode.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgusenode.hxx
Fri Dec  9 12:07:02 2011
@@ -46,12 +46,8 @@ namespace svgio
             SvgNumber                   maHeight;
 
             /// link to content. If maXLink is set, the node can be fetched
-            // on demand by using tryToFindLink in accessors
+            // on demand
             rtl::OUString               maXLink;
-            const SvgNode*              mpXLink;
-
-            /// link on demand
-            void tryToFindLink();
 
         public:
             SvgUseNode(

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=1212349&r1=1212348&r2=1212349&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
Fri Dec  9 12:07:02 2011
@@ -45,6 +45,8 @@
 #include <svgio/svgreader/svgtextpathnode.hxx>
 #include <svgio/svgreader/svgstylenode.hxx>
 #include <svgio/svgreader/svgimagenode.hxx>
+#include <svgio/svgreader/svgclippathnode.hxx>
+#include <svgio/svgreader/svgmasknode.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -295,6 +297,23 @@ namespace svgio
                         break;
                     }
 
+                    /// structural elements clip-path and mask. Content gets scanned, but
+                    /// will not be decomposed (see SvgNode::decomposeSvgNode and bReferenced)
+                    case SVGTokenClipPathNode:
+                    {
+                        /// new node for ClipPath
+                        mpTarget = new SvgClipPathNode(maDocument, mpTarget);
+                        mpTarget->parseAttributes(xAttribs);
+                        break;
+                    }
+                    case SVGTokenMask:
+                    {
+                        /// new node for Mask
+                        mpTarget = new SvgMaskNode(maDocument, mpTarget);
+                        mpTarget->parseAttributes(xAttribs);
+                        break;
+                    }
+
                     default:
                     {
                         /// invalid token, ignore
@@ -354,6 +373,10 @@ namespace svgio
                     /// styles (as stylesheets)
                     case SVGTokenStyle:
 
+                    /// structural elements clip-path and mask
+                    case SVGTokenClipPathNode:
+                    case SVGTokenMask:
+
                     /// content handling after parsing
                     {
                         if(mpTarget)

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
Fri Dec  9 12:07:02 2011
@@ -187,14 +187,11 @@ namespace svgio
                 {
                     if(aContent.getLength())
                     {
-                        static rtl::OUString aStrUserSpaceOnUse(rtl::OUString::createFromAscii("userSpaceOnUse"));
-                        static rtl::OUString aStrObjectBoundingBox(rtl::OUString::createFromAscii("objectBoundingBox"));
-                        
-                        if(aContent.match(aStrUserSpaceOnUse, 0))
+                        if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
                         {
                             setGradientUnits(userSpaceOnUse);
                         }
-                        else if(aContent.match(aStrObjectBoundingBox, 0))
+                        else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
                         {
                             setGradientUnits(objectBoundingBox);
                         }

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=1212349&r1=1212348&r2=1212349&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 Fri
Dec  9 12:07:02 2011
@@ -136,12 +136,22 @@ namespace svgio
 
         void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector&
rTarget, bool bReferenced) const
         {
-            if(!bReferenced && (SVGTokenDefs == getType() || SVGTokenSymbol == getType()))
+            if(!bReferenced)
             {
-                // do not decompose defs or symbol nodes (these hold only style-like
-                // objects which may be used by referencing them) except when doing
-                // so controlled referenced
-                return;
+                if(SVGTokenDefs == getType() || 
+                    SVGTokenSymbol == getType() ||
+                    SVGTokenClipPathNode == getType() ||
+                    SVGTokenMask == getType())
+                {
+                    // do not decompose defs or symbol nodes (these hold only style-like
+                    // objects which may be used by referencing them) except when doing
+                    // so controlled referenced
+
+                    // 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
+                    return;
+                }
             }
 
             const SvgNodeVector& rChildren = getChildren();
@@ -152,7 +162,32 @@ namespace svgio
 
                 for(sal_uInt32 a(0); a < nCount; a++)
                 {
-                    rChildren[a]->decomposeSvgNode(rTarget, bReferenced);
+                    SvgNode* pCandidate = rChildren[a];
+
+                    if(pCandidate)
+                    {
+                        drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+                        pCandidate->decomposeSvgNode(aNewTarget, bReferenced);
+
+                        if(aNewTarget.size())
+                        {
+                            const SvgStyleAttributes* pAttributes = pCandidate->getSvgStyleAttributes();
+
+                            if(pAttributes)
+                            {
+                                // check for global attributes which need to be applied,
+                                // e.g. ClipPath or Mask
+                                pAttributes->decomposePostProcess(aNewTarget);
+                            }
+
+                            rTarget.insert(rTarget.end(), aNewTarget.begin(), aNewTarget.end());
+                        }
+                    }
+                    else
+                    {
+                        OSL_ENSURE(false, "Null-Pointer in child node list (!)");
+                    }
                 }
             }
         }

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=1212349&r1=1212348&r2=1212349&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
Fri Dec  9 12:07:02 2011
@@ -34,6 +34,8 @@
 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
 #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <svgio/svgreader/svgclippathnode.hxx>
+#include <svgio/svgreader/svgmasknode.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -204,6 +206,37 @@ namespace svgio
             }
         }
 
+        void SvgStyleAttributes::decomposePostProcess(drawinglayer::primitive2d::Primitive2DVector&
rTarget) const
+        {
+            if(rTarget.size())
+            {
+                if(getClipPathXLink().getLength())
+                {
+                    // try to access linked ClipPath
+                    const SvgClipPathNode* mpClip = dynamic_cast< const SvgClipPathNode*
>(mrOwner.getDocument().findSvgNodeById(getClipPathXLink()));
+
+                    if(mpClip)
+                    {
+                        mpClip->apply(rTarget);
+                    }
+                }
+            }
+
+            if(rTarget.size()) // test again, applied clipPath may have lead to empty geometry
+            {
+                if(getMaskXLink().getLength())
+                {
+                    // try to access linked Mask
+                    const SvgMaskNode* mpMask = dynamic_cast< const SvgMaskNode* >(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
+
+                    if(mpMask)
+                    {
+                        mpMask->apply(rTarget);
+                    }
+                }
+            }
+        }
+
         const SvgStyleAttributes* SvgStyleAttributes::getParentStyle() const 
         { 
             if(mpCssStyleParent)
@@ -666,10 +699,22 @@ namespace svgio
             maTextDecoration(TextDecoration_notset),
             maTextAnchor(TextAnchor_notset),
             maColor(),
-            
+            maClipPathXLink(),
+            maMaskXLink(),
+
             maFillRule(true),
-            maFillRuleSet(false)
+            maFillRuleSet(false),
+            mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType())
         {
+            if(!mbIsClipPathContent)
+            {
+                const SvgStyleAttributes* pParentStyle = getParentStyle();
+
+                if(pParentStyle)
+                {
+                    mbIsClipPathContent = pParentStyle->mbIsClipPathContent;
+                }
+            }
         }
 
         SvgStyleAttributes::~SvgStyleAttributes()
@@ -1203,12 +1248,28 @@ namespace svgio
                     }
                     break;
                 }
+                case SVGTokenClipPathProperty:
+                {
+                    readLocalUrl(aContent, maClipPathXLink);
+                    break;
+                }
+                case SVGTokenMask:
+                {
+                    readLocalUrl(aContent, maMaskXLink);
+                    break;
+                }
             }
         }
 
         const basegfx::BColor* SvgStyleAttributes::getFill() const 
         { 
-            if(maFill.isSet()) 
+            if(mbIsClipPathContent)
+            {
+                static basegfx::BColor aBlack(0.0, 0.0, 0.0);
+
+                return &aBlack;
+            }
+            else if(maFill.isSet()) 
             {
                 if(maFill.isCurrent())
                 {
@@ -1234,7 +1295,11 @@ namespace svgio
 
         const basegfx::BColor* SvgStyleAttributes::getStroke() const 
         { 
-            if(maStroke.isSet()) 
+            if(mbIsClipPathContent)
+            {
+                return 0;
+            }
+            else if(maStroke.isSet()) 
             {
                 if(maStroke.isCurrent())
                 {
@@ -1272,7 +1337,11 @@ namespace svgio
 
         const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeFill() const 
         { 
-            if(mpSvgGradientNodeFill)
+            if(mbIsClipPathContent)
+            {
+                return 0;
+            }
+            else if(mpSvgGradientNodeFill)
             {
                 return mpSvgGradientNodeFill; 
             }
@@ -1291,7 +1360,11 @@ namespace svgio
 
         const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeStroke() const 
         { 
-            if(mpSvgGradientNodeStroke)
+            if(mbIsClipPathContent)
+            {
+                return 0;
+            }
+            else if(mpSvgGradientNodeStroke)
             {
                 return mpSvgGradientNodeStroke; 
             }
@@ -1310,7 +1383,11 @@ namespace svgio
 
         const SvgNumber SvgStyleAttributes::getStrokeWidth() const 
         { 
-            if(maStrokeWidth.isSet()) 
+            if(mbIsClipPathContent)
+            {
+                return SvgNumber(0.0);
+            }
+            else if(maStrokeWidth.isSet()) 
             {
                 return maStrokeWidth; 
             }
@@ -1339,7 +1416,11 @@ namespace svgio
 
         const SvgNumber SvgStyleAttributes::getFillOpacity() const 
         { 
-            if(maFillOpacity.isSet()) 
+            if(mbIsClipPathContent)
+            {
+                return SvgNumber(1.0);
+            }
+            else if(maFillOpacity.isSet()) 
             {
                 return maFillOpacity; 
             }

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextpathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextpathnode.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextpathnode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextpathnode.cxx
Fri Dec  9 12:07:02 2011
@@ -272,21 +272,12 @@ namespace svgio
 {
     namespace svgreader
     {
-        void SvgTextPathNode::tryToFindLink()
-        {
-            if(!mpXLink && maXLink.getLength())
-            {
-                mpXLink = dynamic_cast< const SvgPathNode* >(getDocument().findSvgNodeById(maXLink));
-            }
-        }
-
         SvgTextPathNode::SvgTextPathNode(
             SvgDocument& rDocument,
             SvgNode* pParent)
         :   SvgNode(SVGTokenTextPath, rDocument, pParent),
             maSvgStyleAttributes(*this),
             maXLink(),
-            mpXLink(0),
             maStartOffset(),
             mbMethod(true),
             mbSpacing(false)
@@ -374,23 +365,15 @@ namespace svgio
                     if(nLen && sal_Unicode('#') == aContent[0])
                     {
                         maXLink = aContent.copy(1);
-                        tryToFindLink();
                     }
                     break;
                 }
             }
         }
 
-        const SvgPathNode* SvgTextPathNode::getReferencedSvgPathNode() const
-        {
-            const_cast< SvgTextPathNode* >(this)->tryToFindLink();
-
-            return mpXLink;
-        }
-
         bool SvgTextPathNode::isValid() const
         {
-            const SvgPathNode* pSvgPathNode = getReferencedSvgPathNode();
+            const SvgPathNode* pSvgPathNode = dynamic_cast< const SvgPathNode* >(getDocument().findSvgNodeById(maXLink));
 
             if(!pSvgPathNode)
             {
@@ -428,7 +411,7 @@ namespace svgio
         {
             if(rPathContent.hasElements())
             {
-                const SvgPathNode* pSvgPathNode = getReferencedSvgPathNode();
+                const SvgPathNode* pSvgPathNode = dynamic_cast< const SvgPathNode* >(getDocument().findSvgNodeById(maXLink));
 
                 if(pSvgPathNode)
                 {

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=1212349&r1=1212348&r2=1212349&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 Fri
Dec  9 12:07:02 2011
@@ -75,6 +75,12 @@ namespace svgio
         static rtl::OUString aSVGStrTextAnchor(rtl::OUString::createFromAscii("text-anchor"));

         static rtl::OUString aSVGStrXmlSpace(rtl::OUString::createFromAscii("xml:space"));

         static rtl::OUString aSVGStrColor(rtl::OUString::createFromAscii("color")); 
+        static rtl::OUString aSVGStrClipPathNode(rtl::OUString::createFromAscii("clipPath"));

+        static rtl::OUString aSVGStrClipPathProperty(rtl::OUString::createFromAscii("clip-path"));

+        static rtl::OUString aSVGStrMask(rtl::OUString::createFromAscii("mask")); 
+        static rtl::OUString aSVGStrClipPathUnits(rtl::OUString::createFromAscii("clipPathUnits"));

+        static rtl::OUString aSVGStrMaskUnits(rtl::OUString::createFromAscii("maskUnits"));

+        static rtl::OUString aSVGStrMaskContentUnits(rtl::OUString::createFromAscii("maskContentUnits"));

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

         static rtl::OUString aSVGStrDefer(rtl::OUString::createFromAscii("defer")); 
@@ -192,6 +198,12 @@ namespace svgio
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrTextAnchor, SVGTokenTextAnchor));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrXmlSpace, SVGTokenXmlSpace));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrColor, SVGTokenColor));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrClipPathNode, SVGTokenClipPathNode));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrClipPathProperty, SVGTokenClipPathProperty));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrMask, SVGTokenMask));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrClipPathUnits, SVGTokenClipPathUnits));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrMaskUnits, SVGTokenMaskUnits));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrMaskContentUnits, SVGTokenMaskContentUnits));
 
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPreserveAspectRatio,
SVGTokenPreserveAspectRatio));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDefer, SVGTokenDefer));

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx Fri
Dec  9 12:07:02 2011
@@ -46,6 +46,10 @@ namespace svgio
         }
 #endif
 
+        // common non-token strings
+        const rtl::OUString commonStrings::aStrUserSpaceOnUse(rtl::OUString::createFromAscii("userSpaceOnUse"));
+        const rtl::OUString commonStrings::aStrObjectBoundingBox(rtl::OUString::createFromAscii("objectBoundingBox"));
+
         basegfx::B2DHomMatrix SvgAspectRatio::createLinearMapping(const basegfx::B2DRange&
rTarget, const basegfx::B2DRange& rSource)
         {
             basegfx::B2DHomMatrix aRetval;
@@ -1138,6 +1142,26 @@ namespace svgio
             return readNumberAndUnit(rCandidate, nPos, aNum, nLen);
         }
 
+        bool readLocalUrl(const rtl::OUString& rCandidate, rtl::OUString& rURL)
+        {
+            static rtl::OUString aStrUrl(rtl::OUString::createFromAscii("url"));
+
+            if(rCandidate.match(aStrUrl, 0))
+            {
+                const sal_Int32 nLen(rCandidate.getLength());
+                sal_Int32 nPos(aStrUrl.getLength());
+                        
+                skip_char(rCandidate, sal_Unicode('('), sal_Unicode('#'), nPos, nLen);
+                rtl::OUStringBuffer aTokenValue;
+                copyToLimiter(rCandidate, sal_Unicode(')'), nPos, aTokenValue, nLen);
+                rURL = aTokenValue.makeStringAndClear();
+                
+                return true;
+            }
+
+            return false;
+        }
+
         bool readSvgPaint(const rtl::OUString& rCandidate, SvgPaint& rSvgPaint, rtl::OUString&
rURL)
         {
             const sal_Int32 nLen(rCandidate.getLength());
@@ -1154,7 +1178,6 @@ namespace svgio
                 else
                 {
                     static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
-                    static rtl::OUString aStrUrl(rtl::OUString::createFromAscii("url"));
                     static rtl::OUString aStrCurrentColor(rtl::OUString::createFromAscii("currentColor"));
 
                     if(rCandidate.match(aStrNone, 0))
@@ -1162,16 +1185,9 @@ namespace svgio
                         rSvgPaint = SvgPaint(aColor, true, false, false);
                         return true;
                     }
-                    else if(rCandidate.match(aStrUrl, 0))
+                    else if(readLocalUrl(rCandidate, rURL))
                     {
-                        const sal_Int32 nLen(rCandidate.getLength());
-                        sal_Int32 nPos(aStrUrl.getLength());
-                        
-                        skip_char(rCandidate, sal_Unicode('('), sal_Unicode('#'), nPos, nLen);
-                        rtl::OUStringBuffer aTokenValue;
-                        copyToLimiter(rCandidate, sal_Unicode(')'), nPos, aTokenValue, nLen);
-                        skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(')'), nPos, nLen);
-                        rURL = aTokenValue.makeStringAndClear();
+                        /// Url is copied to rURL, but needs to be solved outside this helper
                         return false;
                     }
                     else if(rCandidate.match(aStrCurrentColor, 0))

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtrefnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtrefnode.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtrefnode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtrefnode.cxx
Fri Dec  9 12:07:02 2011
@@ -31,21 +31,12 @@ namespace svgio
 {
     namespace svgreader
     {
-        void SvgTrefNode::tryToFindLink()
-        {
-            if(!mpXLink && maXLink.getLength())
-            {
-                mpXLink = dynamic_cast< const SvgTextNode* >(getDocument().findSvgNodeById(maXLink));
-            }
-        }
-
         SvgTrefNode::SvgTrefNode(
             SvgDocument& rDocument,
             SvgNode* pParent)
         :   SvgNode(SVGTokenTref, rDocument, pParent),
             maSvgStyleAttributes(*this),
-            maXLink(),
-            mpXLink(0)
+            maXLink()
         {
         }
 
@@ -81,7 +72,6 @@ namespace svgio
                     if(nLen && sal_Unicode('#') == aContent[0])
                     {
                         maXLink = aContent.copy(1);
-                        tryToFindLink();
                     }
                     break;
                 }
@@ -90,9 +80,7 @@ namespace svgio
 
         const SvgTextNode* SvgTrefNode::getReferencedSvgTextNode() const
         {
-            const_cast< SvgTrefNode* >(this)->tryToFindLink();
-
-            return mpXLink;
+            return dynamic_cast< const SvgTextNode* >(getDocument().findSvgNodeById(maXLink));
         }
 
     } // end of namespace svgreader

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx?rev=1212349&r1=1212348&r2=1212349&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx Fri
Dec  9 12:07:02 2011
@@ -32,14 +32,6 @@ namespace svgio
 {
     namespace svgreader
     {
-        void SvgUseNode::tryToFindLink()
-        {
-            if(!mpXLink && maXLink.getLength())
-            {
-                mpXLink = getDocument().findSvgNodeById(maXLink);
-            }
-        }
-
         SvgUseNode::SvgUseNode(
             SvgDocument& rDocument,
             SvgNode* pParent)
@@ -50,8 +42,7 @@ namespace svgio
             maY(),
             maWidth(),
             maHeight(),
-            maXLink(),
-            mpXLink(0)
+            maXLink()
         {
         }
 
@@ -143,7 +134,6 @@ namespace svgio
                     if(nLen && sal_Unicode('#') == aContent[0])
                     {
                         maXLink = aContent.copy(1);
-                        tryToFindLink();
                     }
                     break;
                 }
@@ -153,7 +143,7 @@ namespace svgio
         void SvgUseNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector&
rTarget, bool bReferenced) const
         {
             // try to access link to content
-            const_cast< SvgUseNode* >(this)->tryToFindLink();
+            const SvgNode* mpXLink = getDocument().findSvgNodeById(maXLink);
 
             if(mpXLink)
             {



Mime
View raw message