[Libreoffice-commits] core.git: 6 commits - include/sfx2 include/vcl sc/inc vcl/inc vcl/source

Caolán McNamara caolanm at redhat.com
Sun Jan 1 22:22:33 UTC 2017


 include/sfx2/module.hxx     |    2 
 include/vcl/alpha.hxx       |    2 
 include/vcl/graph.hxx       |    4 
 sc/inc/global.hxx           |    1 
 vcl/inc/impgraph.hxx        |    4 
 vcl/source/gdi/graph.cxx    |    8 
 vcl/source/gdi/impgraph.cxx |  402 +++++++++++++++++++++-----------------------
 7 files changed, 207 insertions(+), 216 deletions(-)

New commits:
commit a2aceeb00de1529292709894bdb39b676a3f2337
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 21:07:19 2017 +0000

    return earlier, no logic change intended
    
    Change-Id: Icd75c46eb57c059fb60fd9701e6bb1fb651d8f3f

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 98d57ac..5689f27 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1520,86 +1520,87 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
 
 void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
 {
-    if( !rOStm.GetError() )
+    if (rOStm.GetError())
+        return;
+
+    if (rImpGraphic.ImplIsSwapOut())
     {
-        if( !rImpGraphic.ImplIsSwapOut() )
-        {
-            if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
-                ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
-                rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() &&
-                !rImpGraphic.maPdfData.hasElements())
-            {
-                // native format
-                rOStm.WriteUInt32( NATIVE_FORMAT_50 );
+        rOStm.SetError( SVSTREAM_GENERALERROR );
+        return;
+    }
 
-                // write compat info
-                std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rOStm, StreamMode::WRITE, 1 ));
-                pCompat.reset(); // destructor writes stuff into the header
+    if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
+        ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
+        rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() &&
+        !rImpGraphic.maPdfData.hasElements())
+    {
+        // native format
+        rOStm.WriteUInt32( NATIVE_FORMAT_50 );
 
-                rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
-                rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
-                WriteGfxLink( rOStm, *rImpGraphic.mpGfxLink );
-            }
-            else
-            {
-                // own format
-                const SvStreamEndian nOldFormat = rOStm.GetEndian();
-                rOStm.SetEndian( SvStreamEndian::LITTLE );
+        // write compat info
+        std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rOStm, StreamMode::WRITE, 1 ));
+        pCompat.reset(); // destructor writes stuff into the header
 
-                switch( rImpGraphic.ImplGetType() )
-                {
-                    case GraphicType::NONE:
-                    case GraphicType::Default:
-                    break;
+        rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
+        rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
+        WriteGfxLink( rOStm, *rImpGraphic.mpGfxLink );
+    }
+    else
+    {
+        // own format
+        const SvStreamEndian nOldFormat = rOStm.GetEndian();
+        rOStm.SetEndian( SvStreamEndian::LITTLE );
 
-                    case GraphicType::Bitmap:
-                    {
-                        if(rImpGraphic.getSvgData().get())
-                        {
-                            // stream out Svg defining data (length, byte array and evtl. path)
-                            // this is used e.g. in swapping out graphic data and in transporting it over UNO API
-                            // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
-                            // no problem to extend it; only used at runtime
-                            const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
-
-                            rOStm.WriteUInt32( nSvgMagic );
-                            rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() );
-                            rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(),
-                                rImpGraphic.getSvgData()->getSvgDataArrayLength());
-                            rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(),
-                                                       rOStm.GetStreamCharSet());
-                        }
-                        else if( rImpGraphic.ImplIsAnimated())
-                        {
-                            WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
-                        }
-                        else
-                        {
-                            WriteDIBBitmapEx(rImpGraphic.maEx, rOStm);
-                        }
-                    }
-                    break;
+        switch( rImpGraphic.ImplGetType() )
+        {
+            case GraphicType::NONE:
+            case GraphicType::Default:
+            break;
 
-                    default:
-                    {
-                        if (rImpGraphic.maPdfData.hasElements())
-                        {
-                            // Stream out PDF data.
-                            rOStm.WriteUInt32(nPdfMagic);
-                            rOStm.WriteUInt32(rImpGraphic.maPdfData.getLength());
-                            rOStm.WriteBytes(rImpGraphic.maPdfData.getConstArray(), rImpGraphic.maPdfData.getLength());
-                        }
-                        if( rImpGraphic.ImplIsSupportedGraphic() )
-                            WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile );
-                    }
-                    break;
+            case GraphicType::Bitmap:
+            {
+                if(rImpGraphic.getSvgData().get())
+                {
+                    // stream out Svg defining data (length, byte array and evtl. path)
+                    // this is used e.g. in swapping out graphic data and in transporting it over UNO API
+                    // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
+                    // no problem to extend it; only used at runtime
+                    const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
+
+                    rOStm.WriteUInt32( nSvgMagic );
+                    rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() );
+                    rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(),
+                        rImpGraphic.getSvgData()->getSvgDataArrayLength());
+                    rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(),
+                                               rOStm.GetStreamCharSet());
+                }
+                else if( rImpGraphic.ImplIsAnimated())
+                {
+                    WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
+                }
+                else
+                {
+                    WriteDIBBitmapEx(rImpGraphic.maEx, rOStm);
                 }
+            }
+            break;
 
-                rOStm.SetEndian( nOldFormat );
+            default:
+            {
+                if (rImpGraphic.maPdfData.hasElements())
+                {
+                    // Stream out PDF data.
+                    rOStm.WriteUInt32(nPdfMagic);
+                    rOStm.WriteUInt32(rImpGraphic.maPdfData.getLength());
+                    rOStm.WriteBytes(rImpGraphic.maPdfData.getConstArray(), rImpGraphic.maPdfData.getLength());
+                }
+                if( rImpGraphic.ImplIsSupportedGraphic() )
+                    WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile );
             }
+            break;
         }
-        else
-             rOStm.SetError( SVSTREAM_GENERALERROR );
+
+        rOStm.SetEndian( nOldFormat );
     }
 }
 
commit b560dc89e4c86cf624c327fd393e2c3166d66251
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 21:05:41 2017 +0000

    so noone cares about the return of [Read|Write]ImpGraphic
    
    Change-Id: I2e251ff71b1f20e43c797c3fc901f3a70dce7c6c

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index d016f55..4dea38c 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -138,8 +138,8 @@ private:
 
     bool                ImplExportNative( SvStream& rOStm ) const;
 
-    friend SvStream&    WriteImpGraphic( SvStream& rOStm, const ImpGraphic& rImpGraphic );
-    friend SvStream&    ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic );
+    friend void         WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic);
+    friend void         ReadImpGraphic(SvStream& rIStm, ImpGraphic& rImpGraphic);
 
     const SvgDataPtr&   getSvgData() const { return maSvgData; }
 };
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 2d3d85c..98d57ac 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1356,10 +1356,10 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
 }
 
 
-SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
+void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
 {
     if (rIStm.GetError())
-        return rIStm;
+        return;
 
     const sal_uLong nStmPos1 = rIStm.Tell();
     sal_uInt32 nTmp;
@@ -1375,7 +1375,7 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
     // read nothing. CAUTION: Eof is only true AFTER reading another
     // byte, a speciality of SvMemoryStream (!)
     if (rIStm.GetError() || rIStm.IsEof())
-        return rIStm;
+        return;
 
     if (NATIVE_FORMAT_50 == nTmp)
     {
@@ -1414,7 +1414,7 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
             rIStm.Seek( nStmPos1 );
             rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
         }
-        return rIStm;
+        return;
     }
 
     BitmapEx        aBmpEx;
@@ -1516,11 +1516,9 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
     }
 
     rIStm.SetEndian( nOldFormat );
-
-    return rIStm;
 }
 
-SvStream& WriteImpGraphic( SvStream& rOStm, const ImpGraphic& rImpGraphic )
+void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
 {
     if( !rOStm.GetError() )
     {
@@ -1603,8 +1601,6 @@ SvStream& WriteImpGraphic( SvStream& rOStm, const ImpGraphic& rImpGraphic )
         else
              rOStm.SetError( SVSTREAM_GENERALERROR );
     }
-
-    return rOStm;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 970edf67d2369288f12391be5cc06946fcd1684e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 21:03:49 2017 +0000

    noone cares about the return from WriteGraphic either
    
    Change-Id: Ia91a8b4ae7768bd1623b8e2b545fcc9beff1fbc7

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 1f338ea..3bd6a2c 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -212,8 +212,8 @@ public:
 
     bool            ExportNative( SvStream& rOStream ) const;
 
-    friend VCL_DLLPUBLIC SvStream& WriteGraphic( SvStream& rOStream, const Graphic& rGraphic );
-    friend VCL_DLLPUBLIC void ReadGraphic( SvStream& rIStream, Graphic& rGraphic );
+    friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& rGraphic);
+    friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& rGraphic);
 
 public:
 
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 2336648..1583212f 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -575,9 +575,9 @@ void ReadGraphic(SvStream& rIStream, Graphic& rGraphic)
     ReadImpGraphic(rIStream, *rGraphic.mxImpGraphic);
 }
 
-SvStream& WriteGraphic( SvStream& rOStream, const Graphic& rGraphic )
+void WriteGraphic( SvStream& rOStream, const Graphic& rGraphic )
 {
-    return WriteImpGraphic(rOStream, *rGraphic.mxImpGraphic);
+    WriteImpGraphic(rOStream, *rGraphic.mxImpGraphic);
 }
 
 const SvgDataPtr& Graphic::getSvgData() const
commit 0a599225bcfc8682a7cc7f68dd3901d9791522b1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 21:02:44 2017 +0000

    noone cares about the return from ReadGraphic
    
    Change-Id: Ifd86dee6f2657155faaa31a229feb16178d89f34

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index f75b843..1f338ea 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -213,7 +213,7 @@ public:
     bool            ExportNative( SvStream& rOStream ) const;
 
     friend VCL_DLLPUBLIC SvStream& WriteGraphic( SvStream& rOStream, const Graphic& rGraphic );
-    friend VCL_DLLPUBLIC SvStream& ReadGraphic( SvStream& rIStream, Graphic& rGraphic );
+    friend VCL_DLLPUBLIC void ReadGraphic( SvStream& rIStream, Graphic& rGraphic );
 
 public:
 
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index db4f1a7..2336648 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -569,10 +569,10 @@ bool Graphic::ExportNative( SvStream& rOStream ) const
     return mxImpGraphic->ImplExportNative( rOStream );
 }
 
-SvStream& ReadGraphic( SvStream& rIStream, Graphic& rGraphic )
+void ReadGraphic(SvStream& rIStream, Graphic& rGraphic)
 {
     rGraphic.ImplTestRefCount();
-    return ReadImpGraphic(rIStream, *rGraphic.mxImpGraphic);
+    ReadImpGraphic(rIStream, *rGraphic.mxImpGraphic);
 }
 
 SvStream& WriteGraphic( SvStream& rOStream, const Graphic& rGraphic )
commit 8332bc39f507b659b07fe01a31164c0805175dd6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 20:59:56 2017 +0000

    return earlier, no logic change intended
    
    Change-Id: I39679d1c24ffa6f11c067a8fc3957c6a870f7403

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 29775ea..2d3d85c 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1358,166 +1358,165 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
 
 SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
 {
-    if( !rIStm.GetError() )
-    {
-        const sal_uLong nStmPos1 = rIStm.Tell();
-        sal_uInt32 nTmp;
+    if (rIStm.GetError())
+        return rIStm;
 
-        if ( !rImpGraphic.mbSwapUnderway )
-            rImpGraphic.ImplClear();
+    const sal_uLong nStmPos1 = rIStm.Tell();
+    sal_uInt32 nTmp;
 
-        // read Id
-        rIStm.ReadUInt32( nTmp );
+    if ( !rImpGraphic.mbSwapUnderway )
+        rImpGraphic.ImplClear();
 
-        // if there is no more data, avoid further expensive
-        // reading which will create VDevs and other stuff, just to
-        // read nothing. CAUTION: Eof is only true AFTER reading another
-        // byte, a speciality of SvMemoryStream (!)
-        if(!rIStm.GetError() && !rIStm.IsEof())
-        {
-            if( NATIVE_FORMAT_50 == nTmp )
-            {
-                Graphic         aGraphic;
-                GfxLink         aLink;
+    // read Id
+    rIStm.ReadUInt32( nTmp );
 
-                // read compat info
-                std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
-                pCompat.reset(); // destructor writes stuff into the header
+    // if there is no more data, avoid further expensive
+    // reading which will create VDevs and other stuff, just to
+    // read nothing. CAUTION: Eof is only true AFTER reading another
+    // byte, a speciality of SvMemoryStream (!)
+    if (rIStm.GetError() || rIStm.IsEof())
+        return rIStm;
 
-                ReadGfxLink( rIStm, aLink );
+    if (NATIVE_FORMAT_50 == nTmp)
+    {
+        Graphic         aGraphic;
+        GfxLink         aLink;
 
-                // set dummy link to avoid creation of additional link after filtering;
-                // we set a default link to avoid unnecessary swapping of native data
-                aGraphic.SetLink( GfxLink() );
+        // read compat info
+        std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
+        pCompat.reset(); // destructor writes stuff into the header
 
-                if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
-                {
-                    // set link only, if no other link was set
-                    const bool bSetLink = ( !rImpGraphic.mpGfxLink );
+        ReadGfxLink( rIStm, aLink );
 
-                    // assign graphic
-                    rImpGraphic = *aGraphic.ImplGetImpGraphic();
+        // set dummy link to avoid creation of additional link after filtering;
+        // we set a default link to avoid unnecessary swapping of native data
+        aGraphic.SetLink( GfxLink() );
 
-                    if( aLink.IsPrefMapModeValid() )
-                        rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
+        if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
+        {
+            // set link only, if no other link was set
+            const bool bSetLink = ( !rImpGraphic.mpGfxLink );
 
-                    if( aLink.IsPrefSizeValid() )
-                        rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
+            // assign graphic
+            rImpGraphic = *aGraphic.ImplGetImpGraphic();
 
-                    if( bSetLink )
-                        rImpGraphic.ImplSetLink( aLink );
-                }
-                else
-                {
-                    rIStm.Seek( nStmPos1 );
-                    rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
-                }
-            }
-            else
-            {
-                BitmapEx        aBmpEx;
-                const SvStreamEndian nOldFormat = rIStm.GetEndian();
+            if( aLink.IsPrefMapModeValid() )
+                rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
 
-                rIStm.SeekRel( -4 );
-                rIStm.SetEndian( SvStreamEndian::LITTLE );
-                ReadDIBBitmapEx(aBmpEx, rIStm);
+            if( aLink.IsPrefSizeValid() )
+                rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
 
-                if( !rIStm.GetError() )
-                {
-                    sal_uInt32  nMagic1(0), nMagic2(0);
-                    sal_uLong   nActPos = rIStm.Tell();
+            if( bSetLink )
+                rImpGraphic.ImplSetLink( aLink );
+        }
+        else
+        {
+            rIStm.Seek( nStmPos1 );
+            rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
+        }
+        return rIStm;
+    }
 
-                    rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
-                    rIStm.Seek( nActPos );
+    BitmapEx        aBmpEx;
+    const SvStreamEndian nOldFormat = rIStm.GetEndian();
 
-                    rImpGraphic = ImpGraphic( aBmpEx );
+    rIStm.SeekRel( -4 );
+    rIStm.SetEndian( SvStreamEndian::LITTLE );
+    ReadDIBBitmapEx(aBmpEx, rIStm);
 
-                    if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
-                    {
-                        rImpGraphic.mpAnimation = o3tl::make_unique<Animation>();
-                        ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
+    if( !rIStm.GetError() )
+    {
+        sal_uInt32  nMagic1(0), nMagic2(0);
+        sal_uLong   nActPos = rIStm.Tell();
 
-                        // #108077# manually set loaded BmpEx to Animation
-                        // (which skips loading its BmpEx if already done)
-                        rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
-                    }
-                    else
-                        rIStm.ResetError();
-                }
-                else
-                {
-                    GDIMetaFile aMtf;
+        rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
+        rIStm.Seek( nActPos );
 
-                    rIStm.Seek( nStmPos1 );
-                    rIStm.ResetError();
-                    ReadGDIMetaFile( rIStm, aMtf );
+        rImpGraphic = ImpGraphic( aBmpEx );
 
-                    if( !rIStm.GetError() )
-                    {
-                        rImpGraphic = aMtf;
-                    }
-                    else
-                    {
-                        sal_uInt32 nOrigError = rIStm.GetErrorCode();
-                        // try to stream in Svg defining data (length, byte array and evtl. path)
-                        // See below (operator<<) for more information
-                        const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
-                        sal_uInt32 nMagic;
-                        rIStm.Seek(nStmPos1);
-                        rIStm.ResetError();
-                        rIStm.ReadUInt32( nMagic );
-
-                        if (nSvgMagic == nMagic)
-                        {
-                            sal_uInt32 nSvgDataArrayLength(0);
-                            rIStm.ReadUInt32(nSvgDataArrayLength);
+        if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
+        {
+            rImpGraphic.mpAnimation = o3tl::make_unique<Animation>();
+            ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
 
-                            if (nSvgDataArrayLength)
-                            {
-                                SvgDataArray aNewData(nSvgDataArrayLength);
+            // #108077# manually set loaded BmpEx to Animation
+            // (which skips loading its BmpEx if already done)
+            rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
+        }
+        else
+            rIStm.ResetError();
+    }
+    else
+    {
+        GDIMetaFile aMtf;
 
-                                rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength);
-                                OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
+        rIStm.Seek( nStmPos1 );
+        rIStm.ResetError();
+        ReadGDIMetaFile( rIStm, aMtf );
 
-                                if (!rIStm.GetError())
-                                {
-                                    SvgDataPtr aSvgDataPtr(
-                                        new SvgData(
-                                            aNewData,
-                                            OUString(aPath)));
+        if( !rIStm.GetError() )
+        {
+            rImpGraphic = aMtf;
+        }
+        else
+        {
+            sal_uInt32 nOrigError = rIStm.GetErrorCode();
+            // try to stream in Svg defining data (length, byte array and evtl. path)
+            // See below (operator<<) for more information
+            const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
+            sal_uInt32 nMagic;
+            rIStm.Seek(nStmPos1);
+            rIStm.ResetError();
+            rIStm.ReadUInt32( nMagic );
+
+            if (nSvgMagic == nMagic)
+            {
+                sal_uInt32 nSvgDataArrayLength(0);
+                rIStm.ReadUInt32(nSvgDataArrayLength);
 
-                                    rImpGraphic = aSvgDataPtr;
-                                }
-                            }
-                        }
-                        else if (nMagic == nPdfMagic)
-                        {
-                            // Stream in PDF data.
-                            sal_uInt32 nPdfDataLength = 0;
-                            rIStm.ReadUInt32(nPdfDataLength);
+                if (nSvgDataArrayLength)
+                {
+                    SvgDataArray aNewData(nSvgDataArrayLength);
 
-                            if (nPdfDataLength)
-                            {
-                                uno::Sequence<sal_Int8> aPdfData(nPdfDataLength);
-                                rIStm.ReadBytes(aPdfData.getArray(), nPdfDataLength);
-                                if (!rIStm.GetError())
-                                    rImpGraphic.maPdfData = aPdfData;
-                            }
-                        }
-                        else
-                        {
-                            rIStm.SetError(nOrigError);
-                        }
+                    rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength);
+                    OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
 
-                        rIStm.Seek(nStmPos1);
+                    if (!rIStm.GetError())
+                    {
+                        SvgDataPtr aSvgDataPtr(
+                            new SvgData(
+                                aNewData,
+                                OUString(aPath)));
+
+                        rImpGraphic = aSvgDataPtr;
                     }
                 }
+            }
+            else if (nMagic == nPdfMagic)
+            {
+                // Stream in PDF data.
+                sal_uInt32 nPdfDataLength = 0;
+                rIStm.ReadUInt32(nPdfDataLength);
 
-                rIStm.SetEndian( nOldFormat );
+                if (nPdfDataLength)
+                {
+                    uno::Sequence<sal_Int8> aPdfData(nPdfDataLength);
+                    rIStm.ReadBytes(aPdfData.getArray(), nPdfDataLength);
+                    if (!rIStm.GetError())
+                        rImpGraphic.maPdfData = aPdfData;
+                }
+            }
+            else
+            {
+                rIStm.SetError(nOrigError);
             }
+
+            rIStm.Seek(nStmPos1);
         }
     }
 
+    rIStm.SetEndian( nOldFormat );
+
     return rIStm;
 }
 
commit a3eaeff2db210f3bfe36148a438a3cb593b28c55
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 1 20:47:01 2017 +0000

    don't need to forward declare ImageList here
    
    Change-Id: Id0477b52a004a9a24e4733aa4916cd1b011c6fdd

diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx
index c40f181..c0e1d06 100644
--- a/include/sfx2/module.hxx
+++ b/include/sfx2/module.hxx
@@ -29,8 +29,6 @@
 #include <tools/fldunit.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 
-class ImageList;
-
 class SfxBindings;
 class SfxObjectFactory;
 class ModalDialog;
diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx
index 9e3f497..40a1c5a 100644
--- a/include/vcl/alpha.hxx
+++ b/include/vcl/alpha.hxx
@@ -27,8 +27,6 @@
 #include <vcl/dllapi.h>
 #include <vcl/bitmap.hxx>
 
-
-class ImageList;
 class BitmapEx;
 
 class VCL_DLLPUBLIC AlphaMask : private Bitmap
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 1761e2f..c6bbb83 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -29,7 +29,6 @@
 
 #include <vector>
 
-class ImageList;
 class Bitmap;
 class SfxItemSet;
 class Color;


More information about the Libreoffice-commits mailing list