openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1482726 - in /openoffice/trunk/main: drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/source/primitive2d/ svgio/inc/svgio/svgreader/ svgio/source/svgreader/
Date Wed, 15 May 2013 08:47:52 GMT
Author: alg
Date: Wed May 15 08:47:52 2013
New Revision: 1482726

URL: http://svn.apache.org/r1482726
Log:
i121801 Corrected handling of gradient transformations

Modified:
    openoffice/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
    openoffice/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
    openoffice/trunk/main/svgio/inc/svgio/svgreader/svgnode.hxx
    openoffice/trunk/main/svgio/source/svgreader/svggnode.cxx
    openoffice/trunk/main/svgio/source/svgreader/svgnode.cxx
    openoffice/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx

Modified: openoffice/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
(original)
+++ openoffice/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
Wed May 15 08:47:52 2013
@@ -95,6 +95,9 @@ namespace drawinglayer
         class SvgGradientHelper
         {
         private:
+            /// the extra gradient transform
+            basegfx::B2DHomMatrix       maGradientTransform;
+
             /// geometric definition, the geometry to be filled
             basegfx::B2DPolyPolygon		maPolyPolygon;
 
@@ -149,6 +152,7 @@ namespace drawinglayer
         public:
             /// constructor
             SvgGradientHelper(
+                const basegfx::B2DHomMatrix& rGradientTransform,
                 const basegfx::B2DPolyPolygon& rPolyPolygon,
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,
@@ -156,6 +160,7 @@ namespace drawinglayer
                 SpreadMethod aSpreadMethod = Spread_pad);
 
             /// data read access
+            const basegfx::B2DHomMatrix& getGradientTransform() const { return maGradientTransform;
}
             const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon;
}
             const SvgGradientEntryVector& getGradientEntries() const { return maGradientEntries;
}
             const basegfx::B2DPoint& getStart() const { return maStart; }
@@ -198,6 +203,7 @@ namespace drawinglayer
         public:
             /// constructor
             SvgLinearGradientPrimitive2D(
+                const basegfx::B2DHomMatrix& rGradientTransform,
                 const basegfx::B2DPolyPolygon& rPolyPolygon,
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,
@@ -266,6 +272,7 @@ namespace drawinglayer
         public:
             /// constructor
             SvgRadialGradientPrimitive2D(
+                const basegfx::B2DHomMatrix& rGradientTransform,
                 const basegfx::B2DPolyPolygon& rPolyPolygon,
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,

Modified: openoffice/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx (original)
+++ openoffice/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx Wed May
15 08:47:52 2013
@@ -285,12 +285,14 @@ namespace drawinglayer
         }
 
         SvgGradientHelper::SvgGradientHelper(
+            const basegfx::B2DHomMatrix& rGradientTransform,
             const basegfx::B2DPolyPolygon& rPolyPolygon,
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
             bool bUseUnitCoordinates,
             SpreadMethod aSpreadMethod)
-        :   maPolyPolygon(rPolyPolygon),
+        :   maGradientTransform(rGradientTransform),
+            maPolyPolygon(rPolyPolygon),
             maGradientEntries(rGradientEntries),
             maStart(rStart),
             maSpreadMethod(aSpreadMethod),
@@ -306,7 +308,8 @@ namespace drawinglayer
         {
             const SvgGradientHelper& rCompare = static_cast< const SvgGradientHelper&
>(rSvgGradientHelper);
 
-            return (getPolyPolygon() == rCompare.getPolyPolygon()
+            return (getGradientTransform() == rCompare.getGradientTransform()
+                && getPolyPolygon() == rCompare.getPolyPolygon()
                 && getGradientEntries() == rCompare.getGradientEntries()
                 && getStart() == rCompare.getStart()
                 && getUseUnitCoordinates() == rCompare.getUseUnitCoordinates()
@@ -432,6 +435,11 @@ namespace drawinglayer
                     aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
                 }
 
+                if(!getGradientTransform().isIdentity())
+                {
+                    aUnitGradientToObject = getGradientTransform() * aUnitGradientToObject;
+                }
+
                 // create inverse from it
                 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
                 aObjectToUnitGradient.invert();
@@ -550,6 +558,7 @@ namespace drawinglayer
         }
 
         SvgLinearGradientPrimitive2D::SvgLinearGradientPrimitive2D(
+            const basegfx::B2DHomMatrix& rGradientTransform,
             const basegfx::B2DPolyPolygon& rPolyPolygon,
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
@@ -557,7 +566,7 @@ namespace drawinglayer
             bool bUseUnitCoordinates,
             SpreadMethod aSpreadMethod)
         :   BufferedDecompositionPrimitive2D(),
-            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates,
aSpreadMethod),
+            SvgGradientHelper(rGradientTransform, rPolyPolygon, rGradientEntries, rStart,
bUseUnitCoordinates, aSpreadMethod),
             maEnd(rEnd)
         {
         }
@@ -753,6 +762,8 @@ namespace drawinglayer
                 else
                 {
                     // interpret in object coordinate system -> object aspect ratio will
not scale result
+                    // use X-Axis with radius, it was already made relative to object width
when coming from
+                    // SVG import
                     const double fRadius((aObjectTransform * basegfx::B2DVector(getRadius(),
0.0)).getLength());
                     const basegfx::B2DPoint aStart(aObjectTransform * getStart());
 
@@ -760,6 +771,11 @@ namespace drawinglayer
                     aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
                 }
 
+                if(!getGradientTransform().isIdentity())
+                {
+                    aUnitGradientToObject = getGradientTransform() * aUnitGradientToObject;
+                }
+
                 // create inverse from it
                 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
                 aObjectToUnitGradient.invert();
@@ -827,6 +843,7 @@ namespace drawinglayer
         }
 
         SvgRadialGradientPrimitive2D::SvgRadialGradientPrimitive2D(
+            const basegfx::B2DHomMatrix& rGradientTransform,
             const basegfx::B2DPolyPolygon& rPolyPolygon,
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
@@ -835,7 +852,7 @@ namespace drawinglayer
             SpreadMethod aSpreadMethod,
             const basegfx::B2DPoint* pFocal)
         :   BufferedDecompositionPrimitive2D(),
-            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates,
aSpreadMethod),
+            SvgGradientHelper(rGradientTransform, rPolyPolygon, rGradientEntries, rStart,
bUseUnitCoordinates, aSpreadMethod),
             mfRadius(fRadius),
             maFocal(rStart),
             maFocalVector(0.0, 0.0),

Modified: openoffice/trunk/main/svgio/inc/svgio/svgreader/svgnode.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/inc/svgio/svgreader/svgnode.hxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/inc/svgio/svgreader/svgnode.hxx (original)
+++ openoffice/trunk/main/svgio/inc/svgio/svgreader/svgnode.hxx Wed May 15 08:47:52 2013
@@ -82,6 +82,11 @@ namespace svgio
             Display_inherit
         };
 
+        // helper to convert a string associated with a token of type SVGTokenDisplay
+        // to the enum Display. Empty trings return the default 'Display_inline' with
+        // which members should be initialized
+        Display getDisplayFromContent(const rtl::OUString& aContent);
+
         class SvgNode : private boost::noncopyable, public InfoProvider
         {
         private:

Modified: openoffice/trunk/main/svgio/source/svgreader/svggnode.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/source/svgreader/svggnode.cxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/source/svgreader/svggnode.cxx (original)
+++ openoffice/trunk/main/svgio/source/svgreader/svggnode.cxx Wed May 15 08:47:52 2013
@@ -96,7 +96,7 @@ namespace svgio
             {
                 const double fOpacity(pStyle->getOpacity().getNumber());
 
-                if(fOpacity > 0.0)
+                if(fOpacity > 0.0 && Display_none != getDisplay())
                 {
                     drawinglayer::primitive2d::Primitive2DSequence aContent;
 

Modified: openoffice/trunk/main/svgio/source/svgreader/svgnode.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/source/svgreader/svgnode.cxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/source/svgreader/svgnode.cxx (original)
+++ openoffice/trunk/main/svgio/source/svgreader/svgnode.cxx Wed May 15 08:47:52 2013
@@ -194,6 +194,107 @@ namespace svgio
             }
         }
 
+        Display getDisplayFromContent(const rtl::OUString& aContent)
+        {
+            if(aContent.getLength())
+            {
+                static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline"));
+                static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block"));
+                static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item"));
+                static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in"));
+                static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact"));
+                static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker"));
+                static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table"));
+                static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table"));
+                static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group"));
+                static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group"));
+                static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group"));
+                static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row"));
+                static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group"));
+                static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column"));
+                static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell"));
+                static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption"));
+                static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
+                static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit"));
+
+                if(aContent.match(aStrInline))
+                {
+                    return Display_inline;
+                }
+                else if(aContent.match(aStrNone))
+                {
+                    return Display_none;
+                }
+                else if(aContent.match(aStrInherit))
+                {
+                    return Display_inherit;
+                }
+                else if(aContent.match(aStrBlock))
+                {
+                    return Display_block;
+                }
+                else if(aContent.match(aStrList_item))
+                {
+                    return Display_list_item;
+                }
+                else if(aContent.match(aStrRun_in))
+                {
+                    return Display_run_in;
+                }
+                else if(aContent.match(aStrCompact))
+                {
+                    return Display_compact;
+                }
+                else if(aContent.match(aStrMarker))
+                {
+                    return Display_marker;
+                }
+                else if(aContent.match(aStrTable))
+                {
+                    return Display_table;
+                }
+                else if(aContent.match(aStrInline_table))
+                {
+                    return Display_inline_table;
+                }
+                else if(aContent.match(aStrTable_row_group))
+                {
+                    return Display_table_row_group;
+                }
+                else if(aContent.match(aStrTable_header_group))
+                {
+                    return Display_table_header_group;
+                }
+                else if(aContent.match(aStrTable_footer_group))
+                {
+                    return Display_table_footer_group;
+                }
+                else if(aContent.match(aStrTable_row))
+                {
+                    return Display_table_row;
+                }
+                else if(aContent.match(aStrTable_column_group))
+                {
+                    return Display_table_column_group;
+                }
+                else if(aContent.match(aStrTable_column))
+                {
+                    return Display_table_column;
+                }
+                else if(aContent.match(aStrTable_cell))
+                {
+                    return Display_table_cell;
+                }
+                else if(aContent.match(aStrTable_caption))
+                {
+                    return Display_table_caption;
+                }
+            }
+
+            // return the default
+            return Display_inline;
+        }
+
         void SvgNode::parseAttribute(const rtl::OUString& /*rTokenName*/, SVGToken aSVGToken,
const rtl::OUString& aContent)
         {
             switch(aSVGToken)
@@ -236,97 +337,7 @@ namespace svgio
                 {
                     if(aContent.getLength())
                     {
-                        static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline"));
-                        static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block"));
-                        static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item"));
-                        static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in"));
-                        static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact"));
-                        static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker"));
-                        static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table"));
-                        static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table"));
-                        static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group"));
-                        static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group"));
-                        static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group"));
-                        static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row"));
-                        static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group"));
-                        static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column"));
-                        static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell"));
-                        static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption"));
-                        static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
-                        static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit"));
-
-                        if(aContent.match(aStrInline))
-                        {
-                            setDisplay(Display_inline);
-                        }
-                        else if(aContent.match(aStrNone))
-                        {
-                            setDisplay(Display_none);
-                        }
-                        else if(aContent.match(aStrInherit))
-                        {
-                            setDisplay(Display_inherit);
-                        }
-                        else if(aContent.match(aStrBlock))
-                        {
-                            setDisplay(Display_block);
-                        }
-                        else if(aContent.match(aStrList_item))
-                        {
-                            setDisplay(Display_list_item);
-                        }
-                        else if(aContent.match(aStrRun_in))
-                        {
-                            setDisplay(Display_run_in);
-                        }
-                        else if(aContent.match(aStrCompact))
-                        {
-                            setDisplay(Display_compact);
-                        }
-                        else if(aContent.match(aStrMarker))
-                        {
-                            setDisplay(Display_marker);
-                        }
-                        else if(aContent.match(aStrTable))
-                        {
-                            setDisplay(Display_table);
-                        }
-                        else if(aContent.match(aStrInline_table))
-                        {
-                            setDisplay(Display_inline_table);
-                        }
-                        else if(aContent.match(aStrTable_row_group))
-                        {
-                            setDisplay(Display_table_row_group);
-                        }
-                        else if(aContent.match(aStrTable_header_group))
-                        {
-                            setDisplay(Display_table_header_group);
-                        }
-                        else if(aContent.match(aStrTable_footer_group))
-                        {
-                            setDisplay(Display_table_footer_group);
-                        }
-                        else if(aContent.match(aStrTable_row))
-                        {
-                            setDisplay(Display_table_row);
-                        }
-                        else if(aContent.match(aStrTable_column_group))
-                        {
-                            setDisplay(Display_table_column_group);
-                        }
-                        else if(aContent.match(aStrTable_column))
-                        {
-                            setDisplay(Display_table_column);
-                        }
-                        else if(aContent.match(aStrTable_cell))
-                        {
-                            setDisplay(Display_table_cell);
-                        }
-                        else if(aContent.match(aStrTable_caption))
-                        {
-                            setDisplay(Display_table_caption);
-                        }
+                        setDisplay(getDisplayFromContent(aContent));
                     }
                     break;
                 }

Modified: openoffice/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1482726&r1=1482725&r2=1482726&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx (original)
+++ openoffice/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx Wed May 15 08:47:52
2013
@@ -318,10 +318,11 @@ namespace svgio
             if(!aSvgGradientEntryVector.empty())
             {
                 basegfx::B2DHomMatrix aGeoToUnit;
+                basegfx::B2DHomMatrix aGradientTransform;
 
                 if(rFillGradient.getGradientTransform())
                 {
-                    aGeoToUnit = *rFillGradient.getGradientTransform();
+                    aGradientTransform = *rFillGradient.getGradientTransform();
                 }
 
                 if(userSpaceOnUse == rFillGradient.getGradientUnits())
@@ -366,6 +367,7 @@ namespace svgio
                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(
                         rTarget,
                         new drawinglayer::primitive2d::SvgLinearGradientPrimitive2D(
+                            aGradientTransform,
                             rPath, 
                             aSvgGradientEntryVector,
                             aStart,
@@ -427,6 +429,7 @@ namespace svgio
                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(
                         rTarget,
                         new drawinglayer::primitive2d::SvgRadialGradientPrimitive2D(
+                            aGradientTransform,
                             rPath, 
                             aSvgGradientEntryVector,
                             aStart,
@@ -1184,7 +1187,7 @@ namespace svgio
         {
         }
 
-        void SvgStyleAttributes::parseStyleAttribute(const rtl::OUString& /*rTokenName*/,
SVGToken aSVGToken, const rtl::OUString& aContent)
+        void SvgStyleAttributes::parseStyleAttribute(const rtl::OUString& rTokenName,
SVGToken aSVGToken, const rtl::OUString& aContent)
         {
             switch(aSVGToken)
             {
@@ -1788,6 +1791,18 @@ namespace svgio
                     readLocalUrl(aContent, maMarkerEndXLink);
                     break;
                 }
+                case SVGTokenDisplay:
+                {
+                    // There may be display:none statements inside of style defines, e.g.
the following line:
+                    // style="display:none" 
+                    // taken from a svg example; this needs to be parsed and set at the owning
node. Do not call
+                    // mrOwner.parseAttribute(...) here, this would lead to a recursion
+                    if(aContent.getLength())
+                    {
+                        mrOwner.setDisplay(getDisplayFromContent(aContent));
+                    }
+                    break;
+                }
                 default:
                 {
                     break;



Mime
View raw message