incubator-ooo-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1214717&view=rev
Log:
svg: Added support for Svg property 'opacity' for groups and grouping elements

Modified:
    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/svgclippathnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextnode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgusenode.cxx

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=1214717&r1=1214716&r2=1214717&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
Thu Dec 15 11:51:43 2011
@@ -171,6 +171,7 @@ namespace svgio
             TextDecoration              maTextDecoration;
             TextAnchor                  maTextAnchor;
             SvgPaint                    maColor;
+            SvgNumber                   maOpacity;
 
             /// link to content. If set, the node can be fetched on demand
             rtl::OUString               maClipPathXLink;
@@ -372,6 +373,10 @@ namespace svgio
             const basegfx::BColor* getColor() const;
             void setColor(const SvgPaint& rColor) { maColor = rColor; }
 
+            /// Opacity content
+            const SvgNumber getOpacity() const { return maOpacity; }
+            void setOpacity(const SvgNumber& rOpacity = SvgNumber()) { maOpacity = rOpacity;
}
+
             // ClipPathXLink content
             const rtl::OUString getClipPathXLink() const { return maClipPathXLink; }
             void setClipPathXLink(const rtl::OUString& rNew) { maClipPathXLink = rNew;
}

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=1214717&r1=1214716&r2=1214717&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
Thu Dec 15 11:51:43 2011
@@ -105,6 +105,7 @@ namespace svgio
             SVGTokenPatternUnits,
             SVGTokenPatternContentUnits,
             SVGTokenPatternTransform,
+            SVGTokenOpacity,
 
             // AspectRatio and params
             SVGTokenPreserveAspectRatio,

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx?rev=1214717&r1=1214716&r2=1214717&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgclippathnode.cxx
Thu Dec 15 11:51:43 2011
@@ -116,7 +116,7 @@ namespace svgio
                     rTarget.push_back(
                         new drawinglayer::primitive2d::TransformPrimitive2D(
                             *getTransform(),
-                            Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
+                            drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
                     aNewTarget.clear();
                 }
                 else

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx?rev=1214717&r1=1214716&r2=1214717&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggnode.cxx Thu
Dec 15 11:51:43 2011
@@ -24,6 +24,7 @@
 
 #include <svgio/svgreader/svggnode.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -86,26 +87,49 @@ namespace svgio
 
         void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector&
rTarget, bool bReferenced) const
         {
-            drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
 
-            // decompose childs
-            SvgNode::decomposeSvgNode(aNewTarget, bReferenced);
-
-            if(!aNewTarget.empty())
+            if(pStyle)
             {
-                if(getTransform())
-                {
-                    // create embedding group element with transformation
-                    rTarget.push_back(
-                        new drawinglayer::primitive2d::TransformPrimitive2D(
-                            *getTransform(),
-                            Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
-                    aNewTarget.clear();
-                }
-                else
+                const double fOpacity(pStyle->getOpacity().getNumber());
+
+                if(fOpacity > 0.0)
                 {
-                    // append to current target
-                    rTarget.insert(rTarget.end(), aNewTarget.begin(), aNewTarget.end());
+                    drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+
+                    // decompose childs
+                    SvgNode::decomposeSvgNode(aNewTarget, bReferenced);
+
+                    if(!aNewTarget.empty())
+                    {
+                        // put content to primitive sequence
+                        drawinglayer::primitive2d::Primitive2DSequence aContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+
+                        if(basegfx::fTools::less(fOpacity, 1.0))
+                        {
+                            // embed in UnifiedTransparencePrimitive2D
+                            const drawinglayer::primitive2d::Primitive2DReference xRef(
+                                new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+                                    aContent,
+                                    1.0 - fOpacity));
+
+                            aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                        }
+
+                        if(getTransform())
+                        {
+                            // create embedding group element with transformation
+                            const drawinglayer::primitive2d::Primitive2DReference xRef(
+                                new drawinglayer::primitive2d::TransformPrimitive2D(
+                                    *getTransform(),
+                                    aContent));
+
+                            aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                        }
+
+                        // append to current target
+                        rTarget.push_back(new drawinglayer::primitive2d::GroupPrimitive2D(aContent));
+                    }
                 }
             }
         }

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx?rev=1214717&r1=1214716&r2=1214717&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
Thu Dec 15 11:51:43 2011
@@ -267,7 +267,7 @@ namespace svgio
 
                             if(aLinkedTarget.size())
                             {
-                                aEmbedded = Primitive2DVectorToPrimitive2DSequence(aLinkedTarget);
+                                aEmbedded = drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aLinkedTarget);
 
                                 if(aEmbedded.hasElements())
                                 {
@@ -309,7 +309,7 @@ namespace svgio
                         {
                             // create mapping
                             const SvgAspectRatio& rRatio = getSvgAspectRatio();
-                            const drawinglayer::primitive2d::Primitive2DSequence aSequence(Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+                            const drawinglayer::primitive2d::Primitive2DSequence aSequence(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
 
                             if(rRatio.isSet())
                             {

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=1214717&r1=1214716&r2=1214717&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
Thu Dec 15 11:51:43 2011
@@ -496,7 +496,7 @@ namespace svgio
 
                 if(aNewTarget.size())
                 {
-                    const drawinglayer::primitive2d::Primitive2DSequence aSequence(Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+                    const drawinglayer::primitive2d::Primitive2DSequence aSequence(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
 
                     rTarget.push_back(
                         new drawinglayer::primitive2d::TransformPrimitive2D(
@@ -644,7 +644,7 @@ namespace svgio
                             // embed in UnifiedTransparencePrimitive2D
                             rTarget.push_back(
                                 new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
-                                    Primitive2DVectorToPrimitive2DSequence(aNewFill),
+                                    drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewFill),
                                     1.0 - fFillOpacity));
                         }
                         else
@@ -764,7 +764,7 @@ namespace svgio
                                 // embed in UnifiedTransparencePrimitive2D
                                 rTarget.push_back(
                                     new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
-                                        Primitive2DVectorToPrimitive2DSequence(aNewStroke),
+                                        drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewStroke),
                                         1.0 - fStrokeOpacity));
                             }
                             else
@@ -1025,7 +1025,14 @@ namespace svgio
                 return;
             }
 
-            drawinglayer::primitive2d::Primitive2DVector aNewPrimitives;
+            const double fOpacity(getOpacity().getNumber());
+
+            if(basegfx::fTools::equalZero(fOpacity))
+            {
+                return;
+            }
+
+            drawinglayer::primitive2d::Primitive2DVector aNewTarget;
 
             if(!bIsLine)
             {
@@ -1040,10 +1047,10 @@ namespace svgio
                     aPath = basegfx::tools::createNonzeroConform(aPath);
                 }
 
-                add_fill(aPath, aNewPrimitives, aGeoRange);
+                add_fill(aPath, aNewTarget, aGeoRange);
             }
 
-            add_stroke(rPath, aNewPrimitives, aGeoRange);
+            add_stroke(rPath, aNewTarget, aGeoRange);
 
             // Svg supports markers for path, polygon, polyline and line
             if(SVGTokenPath == mrOwner.getType() ||         // path
@@ -1051,21 +1058,38 @@ namespace svgio
                 SVGTokenLine == mrOwner.getType())          // line
             {
                 // try to add markers
-                add_markers(rPath, aNewPrimitives);
+                add_markers(rPath, aNewTarget);
             }
 
-            if(pTransform && !aNewPrimitives.empty())
-            {
-                // embed in transformation
-                rTarget.push_back(
-                    new drawinglayer::primitive2d::TransformPrimitive2D(
-                        *pTransform,
-                        Primitive2DVectorToPrimitive2DSequence(aNewPrimitives)));
-            }
-            else
+            if(aNewTarget.size())
             {
-                // just append
-                rTarget.insert(rTarget.end(), aNewPrimitives.begin(), aNewPrimitives.end());
+                // put content to primitive sequence
+                drawinglayer::primitive2d::Primitive2DSequence aContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+
+                if(basegfx::fTools::less(fOpacity, 1.0))
+                {
+                    // embed in UnifiedTransparencePrimitive2D
+                    const drawinglayer::primitive2d::Primitive2DReference xRef(
+                        new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+                            aContent,
+                            1.0 - fOpacity));
+
+                    aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                }
+
+                if(pTransform)
+                {
+                    // create embedding group element with transformation
+                    const drawinglayer::primitive2d::Primitive2DReference xRef(
+                        new drawinglayer::primitive2d::TransformPrimitive2D(
+                            *pTransform,
+                            aContent));
+
+                    aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                }
+
+                // append to current target
+                rTarget.push_back(new drawinglayer::primitive2d::GroupPrimitive2D(aContent));
             }
         }
 
@@ -1098,6 +1122,7 @@ namespace svgio
             maTextDecoration(TextDecoration_notset),
             maTextAnchor(TextAnchor_notset),
             maColor(),
+            maOpacity(1.0),
             maClipPathXLink(),
             maMaskXLink(),
             maMarkerStartXLink(),
@@ -1664,6 +1689,16 @@ namespace svgio
                     }
                     break;
                 }
+                case SVGTokenOpacity:
+                {
+                    SvgNumber aNum;
+
+                    if(readSingleNumber(aContent, aNum))
+                    {
+                        setOpacity(SvgNumber(basegfx::clamp(aNum.getNumber(), 0.0, 1.0),
aNum.getUnit(), aNum.isSet()));
+                    }
+                    break;
+                }
                 case SVGTokenClipPathProperty:
                 {
                     readLocalUrl(aContent, maClipPathXLink);

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextnode.cxx?rev=1214717&r1=1214716&r2=1214717&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextnode.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtextnode.cxx
Thu Dec 15 11:51:43 2011
@@ -29,6 +29,7 @@
 #include <svgio/svgreader/svgtextpathnode.hxx>
 #include <svgio/svgreader/svgtspannode.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -143,7 +144,7 @@ namespace svgio
 
                         if(!aNewTarget.empty())
                         {
-                            const drawinglayer::primitive2d::Primitive2DSequence aPathContent(Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+                            const drawinglayer::primitive2d::Primitive2DSequence aPathContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
                             aNewTarget.clear();
 
                             // dismantle TextPrimitives and map them on curve/path
@@ -231,41 +232,59 @@ namespace svgio
 
             if(pStyle && !getChildren().empty())
             {
-                SvgTextPosition aSvgTextPosition(0, *this, getSvgTextPositions());
-                drawinglayer::primitive2d::Primitive2DVector aNewTarget;
-                const SvgNodeVector& rChildren = getChildren();
-                const sal_uInt32 nCount(rChildren.size());
+                const double fOpacity(pStyle->getOpacity().getNumber());
 
-                for(sal_uInt32 a(0); a < nCount; a++)
+                if(fOpacity > 0.0)
                 {
-                    const SvgNode& rCandidate = *rChildren[a];
+                    SvgTextPosition aSvgTextPosition(0, *this, getSvgTextPositions());
+                    drawinglayer::primitive2d::Primitive2DVector aNewTarget;
+                    const SvgNodeVector& rChildren = getChildren();
+                    const sal_uInt32 nCount(rChildren.size());
+
+                    for(sal_uInt32 a(0); a < nCount; a++)
+                    {
+                        const SvgNode& rCandidate = *rChildren[a];
     
-                    DecomposeChild(rCandidate, aNewTarget, aSvgTextPosition);
-                }
+                        DecomposeChild(rCandidate, aNewTarget, aSvgTextPosition);
+                    }
                 
-                if(!aNewTarget.empty())
-                {
-                    drawinglayer::primitive2d::Primitive2DVector aNewTarget2;
-
-                    addTextPrimitives(*this, aNewTarget2, aNewTarget);
-                    aNewTarget = aNewTarget2;
-                }
-
-                if(!aNewTarget.empty())
-                {
-                    if(getTransform())
+                    if(!aNewTarget.empty())
                     {
-                        // create embedding group element with transformation
-                        rTarget.push_back(
-                            new drawinglayer::primitive2d::TransformPrimitive2D(
-                                *getTransform(),
-                                Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
-                        aNewTarget.clear();
+                        drawinglayer::primitive2d::Primitive2DVector aNewTarget2;
+
+                        addTextPrimitives(*this, aNewTarget2, aNewTarget);
+                        aNewTarget = aNewTarget2;
                     }
-                    else
+
+                    if(!aNewTarget.empty())
                     {
+                         // put content to primitive sequence
+                        drawinglayer::primitive2d::Primitive2DSequence aContent(drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget));
+
+                        if(basegfx::fTools::less(fOpacity, 1.0))
+                        {
+                            // embed in UnifiedTransparencePrimitive2D
+                            const drawinglayer::primitive2d::Primitive2DReference xRef(
+                                new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+                                    aContent,
+                                    1.0 - fOpacity));
+
+                            aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                        }
+
+                        if(getTransform())
+                        {
+                            // create embedding group element with transformation
+                            const drawinglayer::primitive2d::Primitive2DReference xRef(
+                                new drawinglayer::primitive2d::TransformPrimitive2D(
+                                    *getTransform(),
+                                    aContent));
+
+                            aContent = drawinglayer::primitive2d::Primitive2DSequence(&xRef,
1);
+                        }
+
                         // append to current target
-                        rTarget.insert(rTarget.end(), aNewTarget.begin(), aNewTarget.end());
+                        rTarget.push_back(new drawinglayer::primitive2d::GroupPrimitive2D(aContent));
                     }
                 }
             }

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=1214717&r1=1214716&r2=1214717&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 Thu
Dec 15 11:51:43 2011
@@ -96,6 +96,7 @@ namespace svgio
         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 aSVGStrOpacity(rtl::OUString::createFromAscii("opacity")); 
 
         static rtl::OUString aSVGStrPreserveAspectRatio(rtl::OUString::createFromAscii("preserveAspectRatio"));

         static rtl::OUString aSVGStrDefer(rtl::OUString::createFromAscii("defer")); 
@@ -234,6 +235,7 @@ namespace svgio
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternUnits, SVGTokenPatternUnits));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternContentUnits,
SVGTokenPatternContentUnits));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPatternTransform, SVGTokenPatternTransform));
+                aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrOpacity, SVGTokenOpacity));
 
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPreserveAspectRatio,
SVGTokenPreserveAspectRatio));
                 aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDefer, SVGTokenDefer));

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=1214717&r1=1214716&r2=1214717&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 Thu
Dec 15 11:51:43 2011
@@ -178,7 +178,7 @@ namespace svgio
                         rTarget.push_back(
                             new drawinglayer::primitive2d::TransformPrimitive2D(
                                 aTransform,
-                                Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
+                                drawinglayer::primitive2d::Primitive2DVectorToPrimitive2DSequence(aNewTarget)));
                     }
                     else
                     {



Mime
View raw message