[Libreoffice-commits] core.git: filter/source sd/source

Caolán McNamara caolanm at redhat.com
Sat Apr 1 15:40:34 UTC 2017


 filter/source/graphicfilter/icgm/cgm.cxx |   55 ++++++++++++++-----------------
 sd/source/filter/cgm/sdcgmfilter.cxx     |    8 ++--
 2 files changed, 30 insertions(+), 33 deletions(-)

New commits:
commit 62961938cab795f8b178f4049f2efca5a9e251df
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Apr 1 16:33:02 2017 +0100

    rework ImportCGM to take a SvStream
    
    Change-Id: I261cb5afd251e96fa676ba37fa397159eb7fce32

diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx
index 00d3ceca3567..3e9e0fcdf05e 100644
--- a/filter/source/graphicfilter/icgm/cgm.cxx
+++ b/filter/source/graphicfilter/icgm/cgm.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <com/sun/star/task/XStatusIndicator.hpp>
-#include <unotools/ucbstreamhelper.hxx>
 
 #include <osl/endian.h>
 #include <vcl/virdev.hxx>
@@ -707,7 +706,7 @@ bool CGM::Write( SvStream& rIStm )
 
 // GraphicImport - the exported function
 extern "C" SAL_DLLPUBLIC_EXPORT sal_uInt32 SAL_CALL
-ImportCGM( OUString const & rFileName, uno::Reference< frame::XModel > const & rXModel, sal_uInt32 nMode, css::uno::Reference<css::task::XStatusIndicator> const & aXStatInd )
+ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, sal_uInt32 nMode, css::uno::Reference<css::task::XStatusIndicator> const & aXStatInd)
 {
 
     sal_uInt32  nStatus = 0;            // retvalue == 0 -> ERROR
@@ -722,41 +721,37 @@ ImportCGM( OUString const & rFileName, uno::Reference< frame::XModel > const & r
             {
                 if ( nMode & CGM_IMPORT_CGM )
                 {
-                    std::unique_ptr<SvStream> pIn(::utl::UcbStreamHelper::CreateStream( rFileName, StreamMode::READ ));
-                    if ( pIn )
-                    {
-                        pIn->SetEndian( SvStreamEndian::BIG );
-                        sal_uInt64 const nInSize = pIn->remainingSize();
-                        pIn->Seek( 0 );
+                    rIn.SetEndian(SvStreamEndian::BIG);
+                    sal_uInt64 const nInSize = rIn.remainingSize();
+                    rIn.Seek(0);
 
-                        sal_uInt32  nNext = 0;
-                        sal_uInt32  nAdd = nInSize / 20;
-                        bool bProgressBar = aXStatInd.is();
-                        if ( bProgressBar )
-                            aXStatInd->start( "CGM Import" , nInSize );
+                    sal_uInt32  nNext = 0;
+                    sal_uInt32  nAdd = nInSize / 20;
+                    bool bProgressBar = aXStatInd.is();
+                    if ( bProgressBar )
+                        aXStatInd->start( "CGM Import" , nInSize );
 
-                        while ( pCGM->IsValid() && ( pIn->Tell() < nInSize ) && !pCGM->IsFinished() )
+                    while (pCGM->IsValid() && (rIn.Tell() < nInSize) && !pCGM->IsFinished())
+                    {
+                        if ( bProgressBar )
                         {
-                            if ( bProgressBar )
+                            sal_uInt32 nCurrentPos = rIn.Tell();
+                            if ( nCurrentPos >= nNext )
                             {
-                                sal_uInt32 nCurrentPos = pIn->Tell();
-                                if ( nCurrentPos >= nNext )
-                                {
-                                    aXStatInd->setValue( nCurrentPos );
-                                    nNext = nCurrentPos + nAdd;
-                                }
+                                aXStatInd->setValue( nCurrentPos );
+                                nNext = nCurrentPos + nAdd;
                             }
-
-                            if ( !pCGM->Write( *pIn ) )
-                                break;
                         }
-                        if ( pCGM->IsValid() )
-                        {
-                            nStatus = pCGM->GetBackGroundColor() | 0xff000000;
-                        }
-                        if ( bProgressBar )
-                            aXStatInd->end();
+
+                        if (!pCGM->Write(rIn))
+                            break;
+                    }
+                    if ( pCGM->IsValid() )
+                    {
+                        nStatus = pCGM->GetBackGroundColor() | 0xff000000;
                     }
+                    if ( bProgressBar )
+                        aXStatInd->end();
                 }
             }
         }
diff --git a/sd/source/filter/cgm/sdcgmfilter.cxx b/sd/source/filter/cgm/sdcgmfilter.cxx
index 9c34f6286b53..1c22e164f676 100644
--- a/sd/source/filter/cgm/sdcgmfilter.cxx
+++ b/sd/source/filter/cgm/sdcgmfilter.cxx
@@ -19,6 +19,7 @@
 
 #include <osl/module.hxx>
 #include <tools/urlobj.hxx>
+#include <unotools/ucbstreamhelper.hxx>
 #include <svl/itemset.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/docfilt.hxx>
@@ -40,11 +41,11 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::task;
 using namespace ::com::sun::star::frame;
 
-typedef sal_uInt32 ( SAL_CALL *ImportCGMPointer )( OUString const &, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const & );
+typedef sal_uInt32 ( SAL_CALL *ImportCGMPointer )(SvStream&, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const &);
 
 #ifdef DISABLE_DYNLOADING
 
-extern "C" sal_uInt32 ImportCGM( OUString const &, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const & );
+extern "C" sal_uInt32 ImportCGM(SvStream&, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const &);
 
 #endif
 
@@ -82,7 +83,8 @@ bool SdCGMFilter::Import()
             mrDocument.CreateFirstPages();
 
         CreateStatusIndicator();
-        nRetValue = FncImportCGM( aFileURL, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator );
+        std::unique_ptr<SvStream> xIn(::utl::UcbStreamHelper::CreateStream(aFileURL, StreamMode::READ));
+        nRetValue = xIn ? FncImportCGM(*xIn, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator) : 0;
 
         if( nRetValue )
         {


More information about the Libreoffice-commits mailing list