incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1211525 - in /incubator/ooo/branches/alg/svgreplacement/main: offapi/com/sun/star/graphic/ svgio/inc/svgio/svgreader/ svgio/source/svgreader/ svgio/source/svguno/ svtools/source/filter/ vcl/inc/vcl/ vcl/source/gdi/
Date Wed, 07 Dec 2011 16:41:25 GMT
Author: alg
Date: Wed Dec  7 16:41:24 2011
New Revision: 1211525

URL: http://svn.apache.org/viewvc?rev=1211525&view=rev
Log:
svg: Added support for absolute and relative Urls in image, corrected rgb value read when
percent

Modified:
    incubator/ooo/branches/alg/svgreplacement/main/offapi/com/sun/star/graphic/XSvgParser.idl
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocument.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocument.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgimagenode.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svguno/xsvgparser.cxx
    incubator/ooo/branches/alg/svgreplacement/main/svtools/source/filter/filter.cxx
    incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx
    incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx

Modified: incubator/ooo/branches/alg/svgreplacement/main/offapi/com/sun/star/graphic/XSvgParser.idl
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/offapi/com/sun/star/graphic/XSvgParser.idl?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/offapi/com/sun/star/graphic/XSvgParser.idl
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/offapi/com/sun/star/graphic/XSvgParser.idl
Wed Dec  7 16:41:24 2011
@@ -40,7 +40,9 @@ interface XSvgParser : ::com::sun::star:
         @param xSvgStream
         The file containing the SVG XML data
      */
-    sequence< XPrimitive2D > getDecomposition( [in] io::XInputStream xSvgStream );
+    sequence< XPrimitive2D > getDecomposition( 
+        [in] io::XInputStream xSvgStream,
+        [in] string aAbsolutePath);
 };
 
 }; }; }; };

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocument.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocument.hxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocument.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocument.hxx
Wed Dec  7 16:41:24 2011
@@ -36,7 +36,10 @@ namespace svgio
         {
         private:
             /// the document hierarchy with all root nodes
-            SvgNodeVector       maNodes;
+            SvgNodeVector           maNodes;
+
+            /// the absolute path of the Svg file in progress (if available)
+            const rtl::OUString     maAbsolutePath;
 
             /// hash mapper to find nodes by their id
             typedef std::hash_map< const rtl::OUString, const SvgNode*, rtl::OUStringHash
> IdTokenMapper;
@@ -49,7 +52,7 @@ namespace svgio
             IdStyleTokenMapper      maIdStyleTokenMapperList;
 
         public:
-            SvgDocument();
+            SvgDocument(const rtl::OUString& rAbsolutePath);
             ~SvgDocument();
 
             /// append anopther root node, ownership changes
@@ -73,6 +76,7 @@ namespace svgio
 
             /// data read access
             const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
+            const rtl::OUString& getAbsolutePath() const { return maAbsolutePath; }
         };
     } // end of namespace svgreader
 } // end of namespace svgio

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgdocumenthandler.hxx
Wed Dec  7 16:41:24 2011
@@ -50,7 +50,7 @@ namespace svgio
             bool                mbValidToken : 1;
 
         public:
-            SvgDocHdl();
+            SvgDocHdl(const rtl::OUString& rAbsolutePath);
             ~SvgDocHdl();
 
             // Methods XDocumentHandler

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocument.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocument.cxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocument.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocument.cxx
Wed Dec  7 16:41:24 2011
@@ -30,8 +30,9 @@ namespace svgio
 {
     namespace svgreader
     {
-        SvgDocument::SvgDocument()
+        SvgDocument::SvgDocument(const rtl::OUString& rAbsolutePath)
         :   maNodes(),
+            maAbsolutePath(rAbsolutePath),
             maIdTokenMapperList(),
             maIdStyleTokenMapperList()
         {

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=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
(original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgdocumenthandler.cxx
Wed Dec  7 16:41:24 2011
@@ -119,8 +119,8 @@ namespace svgio
 {
     namespace svgreader
     {
-        SvgDocHdl::SvgDocHdl()
-        :   maDocument(),
+        SvgDocHdl::SvgDocHdl(const rtl::OUString& aAbsolutePath)
+        :   maDocument(aAbsolutePath),
             mpTarget(0)
         {
         }

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=1211525&r1=1211524&r2=1211525&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
Wed Dec  7 16:41:24 2011
@@ -23,6 +23,7 @@
 #include "precompiled_svgio.hxx"
 
 #include <svgio/svgreader/svgimagenode.hxx>
+#include <svgio/svgreader/svgdocument.hxx>
 #include <sax/tools/converter.hxx>
 #include <tools/stream.hxx>
 #include <vcl/bitmapex.hxx>
@@ -34,6 +35,8 @@
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
+#include <rtl/uri.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -162,6 +165,35 @@ namespace svgio
             }
         }
 
+        void extractFromGraphic(
+            const Graphic& rGraphic, 
+            drawinglayer::primitive2d::Primitive2DSequence& rEmbedded,
+            basegfx::B2DRange& rViewBox,
+            BitmapEx& rBitmapEx)
+        {
+            if(GRAPHIC_BITMAP == rGraphic.GetType())
+            {
+                if(rGraphic.getSvgData().get())
+                {
+                    // embedded Svg
+                    rEmbedded = rGraphic.getSvgData()->getPrimitive2DSequence();
+
+                    // fill aViewBox
+                    rViewBox = rGraphic.getSvgData()->getRange();
+                }
+                else
+                {
+                    // get bitmap
+                    rBitmapEx = rGraphic.GetBitmapEx();
+                }
+            }
+            else
+            {
+                // evtl. convert to bitmap
+                rBitmapEx = rGraphic.GetBitmapEx();
+            }
+        }
+
         void SvgImageNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DVector&
rTarget, bool bReferenced) const
         {
             // get size range and create path
@@ -200,26 +232,48 @@ namespace svgio
                                 String(), 
                                 aStream))
                             {
-                                if(GRAPHIC_BITMAP == aGraphic.GetType())
-                                {
-                                    if(aGraphic.getSvgData().get())
-                                    {
-                                        // embedded Svg
-                                        aEmbedded = aGraphic.getSvgData()->getPrimitive2DSequence();
-
-                                        // fill aViewBox
-                                        aViewBox = aGraphic.getSvgData()->getRange();
-                                    }
-                                    else
-                                    {
-                                        // get bitmap
-                                        aBitmapEx = aGraphic.GetBitmapEx();
-                                    }
-                                }
-                                else
+                                extractFromGraphic(aGraphic, aEmbedded, aViewBox, aBitmapEx);
+                            }
+                        }
+                    }
+                    else if(maUrl.getLength())
+                    {
+                        const rtl::OUString& rPath = getDocument().getAbsolutePath();
+                        const rtl::OUString aAbsUrl(rtl::Uri::convertRelToAbs(rPath, maUrl));
+
+                        if(aAbsUrl.getLength())
+                        {
+                            SvFileStream aStream(aAbsUrl, STREAM_STD_READ);
+                            Graphic aGraphic;
+
+                            if(GRFILTER_OK == GraphicFilter::GetGraphicFilter()->ImportGraphic(
+                                aGraphic, 
+                                aAbsUrl, 
+                                aStream))
+                            {
+                                extractFromGraphic(aGraphic, aEmbedded, aViewBox, aBitmapEx);
+                            }
+                        }
+                    }
+                    else if(maXLink.getLength())
+                    {
+                        const SvgNode* mpXLink = getDocument().findSvgNodeById(maXLink);
+
+                        if(mpXLink)
+                        {
+                            drawinglayer::primitive2d::Primitive2DVector aLinkedTarget;
+
+                            mpXLink->decomposeSvgNode(aLinkedTarget, true);
+
+                            if(aLinkedTarget.size())
+                            {
+                                aEmbedded = Primitive2DVectorToPrimitive2DSequence(aLinkedTarget);
+
+                                if(aEmbedded.hasElements())
                                 {
-                                    // evtl. convert to bitmap
-                                    aBitmapEx = aGraphic.GetBitmapEx();
+                                    const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
+
+                                    aViewBox = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aEmbedded,
aViewInformation2D);
                                 }
                             }
                         }

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=1211525&r1=1211524&r2=1211525&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 Wed
Dec  7 16:41:24 2011
@@ -829,26 +829,40 @@ namespace svgio
                             if(nPos < nLen)
                             {
                                 const sal_Unicode aChar(rCandidate[nPos]);
-                                const bool bIsPercent(aChar == sal_Unicode('%'));
-                                const sal_Unicode aSkipChar(bIsPercent ? '%' : ',');
+                                const bool bIsPercent(sal_Unicode('%') == aChar);
                                 double fG(0.0);
 
-                                skip_char(rCandidate, sal_Unicode(' '), aSkipChar, nPos,
nLen);
+                                if(bIsPercent)
+                                {
+                                    skip_char(rCandidate, sal_Unicode('%'), nPos, nLen);
+                                }
+
+                                skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(','),
nPos, nLen);
 
                                 if(readNumber(rCandidate, nPos, fG, nLen))
                                 {
                                     double fB(0.0);
-                            
-                                    skip_char(rCandidate, sal_Unicode(' '), aSkipChar, nPos,
nLen);
-                            
+
+                                    if(bIsPercent)
+                                    {
+                                        skip_char(rCandidate, sal_Unicode('%'), nPos, nLen);
+                                    }
+
+                                    skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(','),
nPos, nLen);
+
                                     if(readNumber(rCandidate, nPos, fB, nLen))
                                     {
-                                        const double fFac(bIsPercent ? 0.001 : fFactor);
-    
+                                        const double fFac(bIsPercent ? 0.01 : fFactor);
+
                                         rColor.setRed(fR * fFac);
                                         rColor.setGreen(fG * fFac);
                                         rColor.setBlue(fB * fFac);
-                                
+
+                                        if(bIsPercent)
+                                        {
+                                            skip_char(rCandidate, sal_Unicode('%'), nPos,
nLen);
+                                        }
+
                                         skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(')'),
nPos, nLen);
                                         return true;
                                     }

Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svguno/xsvgparser.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svguno/xsvgparser.cxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svguno/xsvgparser.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svguno/xsvgparser.cxx Wed
Dec  7 16:41:24 2011
@@ -54,7 +54,8 @@ namespace svgio
 
             // XSvgParser
             virtual uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > >
SAL_CALL getDecomposition( 
-                const uno::Reference< ::io::XInputStream >& xSVGStream) throw (uno::RuntimeException);
+                const uno::Reference< ::io::XInputStream >& xSVGStream,
+                const ::rtl::OUString& aAbsolutePath) throw (uno::RuntimeException);
 
             // XServiceInfo
             virtual rtl::OUString SAL_CALL getImplementationName() throw(uno::RuntimeException);
@@ -105,14 +106,16 @@ namespace svgio
         {
         }
 
-        uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > XSvgParser::getDecomposition(const
uno::Reference< ::io::XInputStream >& xSVGStream) throw (uno::RuntimeException)
+        uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > XSvgParser::getDecomposition(
+            const uno::Reference< ::io::XInputStream >& xSVGStream, 
+            const ::rtl::OUString& aAbsolutePath ) throw (uno::RuntimeException)
         {
             drawinglayer::primitive2d::Primitive2DSequence aRetval;
 
             if(xSVGStream.is())
             {
                 // local document handler
-                SvgDocHdl* pSvgDocHdl = new SvgDocHdl();
+                SvgDocHdl* pSvgDocHdl = new SvgDocHdl(aAbsolutePath);
                 uno::Reference< xml::sax::XDocumentHandler > xSvgDocHdl(pSvgDocHdl);
 
                 try

Modified: incubator/ooo/branches/alg/svgreplacement/main/svtools/source/filter/filter.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svtools/source/filter/filter.cxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svtools/source/filter/filter.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svtools/source/filter/filter.cxx Wed Dec
 7 16:41:24 2011
@@ -1523,7 +1523,8 @@ sal_uInt16 GraphicFilter::ImportGraphic(
                     SvgDataPtr aSvgDataPtr(
                         new SvgData(
                             aNewData,
-                            nStmLen));
+                            nStmLen,
+                            rPath));
 
                     rGraphic = Graphic(aSvgDataPtr);
                     bOkay = true;

Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/inc/vcl/svgdata.hxx Wed Dec  7 16:41:24
2011
@@ -27,6 +27,7 @@
 #include <boost/utility.hpp>
 #include <com/sun/star/graphic/XPrimitive2D.hpp>
 #include <vcl/bitmapex.hxx>
+#include <rtl/ustring.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -43,6 +44,9 @@ private:
     SvgDataArray            maSvgDataArray;
     sal_uInt32              mnSvgDataArrayLength;
 
+    // The absolute Path if available
+    rtl::OUString           maPath;
+
     // on demand created content
     basegfx::B2DRange       maRange;
     Primitive2DSequence     maSequence;
@@ -53,11 +57,12 @@ private:
     void ensureSequenceAndRange();
 
 public:
-    SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength);
+    SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const
rtl::OUString& rPath);
 
     /// data read
     const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
     sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; }
+    const rtl::OUString& getPath() const { return maPath; }
 
     /// data read and evtl. on demand creation
     const basegfx::B2DRange& getRange() const;

Modified: incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx?rev=1211525&r1=1211524&r2=1211525&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/vcl/source/gdi/svgdata.cxx Wed Dec  7 16:41:24
2011
@@ -115,7 +115,7 @@ void SvgData::ensureSequenceAndRange()
 
                 if(xSvgParser.is())
                 {
-                    maSequence = xSvgParser->getDecomposition(myInputStream);
+                    maSequence = xSvgParser->getDecomposition(myInputStream, maPath);
                 }
             }
             catch(const uno::Exception&)
@@ -153,9 +153,10 @@ void SvgData::ensureSequenceAndRange()
 
 //////////////////////////////////////////////////////////////////////////////
 
-SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength)
+SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const
rtl::OUString& rPath)
 :   maSvgDataArray(rSvgDataArray),
     mnSvgDataArrayLength(nSvgDataArrayLength),
+    maPath(rPath),
     maRange(),
     maSequence(),
     maReplacement()



Mime
View raw message