LCOV - code coverage report
Current view: top level - svtools/source/filter - filter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 451 1004 44.9 %
Date: 2012-08-25 Functions: 27 71 38.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 596 2165 27.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <osl/mutex.hxx>
      30                 :            : #include <comphelper/processfactory.hxx>
      31                 :            : #include <comphelper/string.hxx>
      32                 :            : #include <ucbhelper/content.hxx>
      33                 :            : #include <cppuhelper/implbase1.hxx>
      34                 :            : #include <tools/urlobj.hxx>
      35                 :            : #include <vcl/salctype.hxx>
      36                 :            : #include <vcl/pngread.hxx>
      37                 :            : #include <vcl/pngwrite.hxx>
      38                 :            : #include <vcl/svgread.hxx>
      39                 :            : #include <vcl/virdev.hxx>
      40                 :            : #include <vcl/svapp.hxx>
      41                 :            : #include <osl/file.hxx>
      42                 :            : #include <svtools/filter.hxx>
      43                 :            : #include "FilterConfigCache.hxx"
      44                 :            : #include <svtools/FilterConfigItem.hxx>
      45                 :            : #include <svtools/fltcall.hxx>
      46                 :            : #include <svtools/wmf.hxx>
      47                 :            : #include "gifread.hxx"
      48                 :            : #include "jpeg.hxx"
      49                 :            : #include "xbmread.hxx"
      50                 :            : #include "xpmread.hxx"
      51                 :            : #include <svl/solar.hrc>
      52                 :            : #include <svtools/svtools.hrc>
      53                 :            : #include "sgffilt.hxx"
      54                 :            : #include "osl/module.hxx"
      55                 :            : #include <com/sun/star/uno/Reference.h>
      56                 :            : #include <com/sun/star/awt/Size.hpp>
      57                 :            : #include <com/sun/star/uno/XInterface.hpp>
      58                 :            : #include <com/sun/star/uno/XWeak.hpp>
      59                 :            : #include <com/sun/star/uno/XAggregation.hpp>
      60                 :            : #include <com/sun/star/lang/XTypeProvider.hpp>
      61                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      62                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      63                 :            : #include <com/sun/star/io/XOutputStream.hpp>
      64                 :            : #include <com/sun/star/svg/XSVGWriter.hpp>
      65                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      66                 :            : #include <com/sun/star/ucb/CommandAbortedException.hpp>
      67                 :            : #include <unotools/ucbstreamhelper.hxx>
      68                 :            : #include <unotools/localfilehelper.hxx>
      69                 :            : #include <rtl/bootstrap.hxx>
      70                 :            : #include <rtl/instance.hxx>
      71                 :            : #include <rtl/logfile.hxx>
      72                 :            : #include <vector>
      73                 :            : 
      74                 :            : #include "SvFilterOptionsDialog.hxx"
      75                 :            : 
      76                 :            : #define PMGCHUNG_msOG       0x6d734f47      // Microsoft Office Animated GIF
      77                 :            : 
      78                 :            : #define IMPORT_FUNCTION_NAME    "GraphicImport"
      79                 :            : #define EXPORT_FUNCTION_NAME    "GraphicExport"
      80                 :            : 
      81                 :            : // -----------
      82                 :            : // - statics -
      83                 :            : // -----------
      84                 :            : 
      85                 :            : using namespace ::rtl;
      86                 :            : using namespace ::com::sun::star;
      87                 :            : 
      88                 :            : using comphelper::string::getTokenCount;
      89                 :            : using comphelper::string::getToken;
      90                 :            : 
      91                 :            : typedef ::std::vector< GraphicFilter* > FilterList_impl;
      92                 :            : static FilterList_impl* pFilterHdlList = NULL;
      93                 :            : 
      94                 :        404 : static ::osl::Mutex& getListMutex()
      95                 :            : {
      96 [ +  + ][ +  - ]:        404 :     static ::osl::Mutex s_aListProtection;
         [ +  - ][ #  # ]
      97                 :        404 :     return s_aListProtection;
      98                 :            : }
      99                 :            : 
     100                 :            : // -------------------------
     101                 :            : // - ImpFilterOutputStream -
     102                 :            : // -------------------------
     103                 :            : 
     104                 :            : class ImpFilterOutputStream : public ::cppu::WeakImplHelper1< ::com::sun::star::io::XOutputStream >
     105                 :            : {
     106                 :            : protected:
     107                 :            : 
     108                 :            :     SvStream&                           mrStm;
     109                 :            : 
     110                 :          0 :     virtual void SAL_CALL               writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& rData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Write( rData.getConstArray(), rData.getLength() ); }
     111                 :          0 :     virtual void SAL_CALL               flush() throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Flush(); }
     112                 :          0 :     virtual void SAL_CALL               closeOutput() throw() {}
     113                 :            : 
     114                 :            : public:
     115                 :            : 
     116                 :          0 :                                         ImpFilterOutputStream( SvStream& rStm ) : mrStm( rStm ) {}
     117         [ #  # ]:          0 :                                         ~ImpFilterOutputStream() {}
     118                 :            : };
     119                 :            : 
     120                 :          0 : sal_Bool ImplDirEntryHelper::Exists( const INetURLObject& rObj )
     121                 :            : {
     122                 :          0 :     sal_Bool bExists = sal_False;
     123                 :            : 
     124                 :            :     try
     125                 :            :     {
     126                 :            :         ::ucbhelper::Content    aCnt( rObj.GetMainURL( INetURLObject::NO_DECODE ),
     127 [ #  # ][ #  # ]:          0 :                               ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
     128                 :            : 
     129         [ #  # ]:          0 :         bExists = aCnt.isDocument();
              [ #  #  # ]
                 [ #  # ]
     130                 :            :     }
     131                 :          0 :     catch(const ::com::sun::star::ucb::CommandAbortedException&)
     132                 :            :     {
     133                 :            :         SAL_WARN( "svtools.filter", "CommandAbortedException" );
     134                 :            :     }
     135                 :          0 :     catch(const ::com::sun::star::ucb::ContentCreationException&)
     136                 :            :     {
     137                 :            :         SAL_WARN( "svtools.filter", "ContentCreationException" );
     138                 :            :     }
     139                 :          0 :     catch( ... )
     140                 :            :     {
     141                 :            :         SAL_WARN( "svtools.filter", "Any other exception" );
     142                 :            :     }
     143                 :          0 :     return bExists;
     144                 :            : }
     145                 :            : 
     146                 :            : // -----------------------------------------------------------------------------
     147                 :            : 
     148                 :          0 : void ImplDirEntryHelper::Kill( const String& rMainUrl )
     149                 :            : {
     150                 :            :     try
     151                 :            :     {
     152                 :            :         ::ucbhelper::Content aCnt( rMainUrl,
     153 [ #  # ][ #  # ]:          0 :                              ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
     154                 :            : 
     155                 :            :         aCnt.executeCommand( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" )),
     156 [ #  # ][ #  # ]:          0 :                              ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     157                 :            :     }
     158                 :          0 :     catch(const ::com::sun::star::ucb::CommandAbortedException&)
     159                 :            :     {
     160                 :            :         SAL_WARN( "svtools.filter", "CommandAbortedException" );
     161                 :            :     }
     162                 :          0 :     catch( ... )
     163                 :            :     {
     164                 :            :         SAL_WARN( "svtools.filter", "Any other exception" );
     165                 :            :     }
     166                 :          0 : }
     167                 :            : 
     168                 :            : // --------------------
     169                 :            : // - Helper functions -
     170                 :            : // --------------------
     171                 :            : 
     172                 :            : //--------------------------------------------------------------------------
     173                 :            : 
     174                 :         27 : sal_uInt8* ImplSearchEntry( sal_uInt8* pSource, sal_uInt8* pDest, sal_uLong nComp, sal_uLong nSize )
     175                 :            : {
     176         [ +  + ]:      10707 :     while ( nComp-- >= nSize )
     177                 :            :     {
     178                 :            :         sal_uLong i;
     179         [ +  - ]:      10824 :         for ( i = 0; i < nSize; i++ )
     180                 :            :         {
     181         [ +  + ]:      10824 :             if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
     182                 :      10680 :                 break;
     183                 :            :         }
     184         [ -  + ]:      10680 :         if ( i == nSize )
     185                 :          0 :             return pSource;
     186                 :      10680 :         pSource++;
     187                 :            :     }
     188                 :         27 :     return NULL;
     189                 :            : }
     190                 :            : 
     191                 :            : //--------------------------------------------------------------------------
     192                 :            : 
     193                 :          3 : inline String ImpGetExtension( const String &rPath )
     194                 :            : {
     195         [ +  - ]:          3 :     String          aExt;
     196 [ +  - ][ +  - ]:          3 :     INetURLObject   aURL( rPath );
     197 [ +  - ][ +  - ]:          3 :     aExt = aURL.GetFileExtension().toAsciiUpperCase();
     198         [ +  - ]:          3 :     return aExt;
     199                 :            : }
     200                 :            : 
     201                 :          9 : bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
     202                 :            : {
     203                 :            :     sal_uInt8 sBuf[3];
     204                 :            :     // store number format
     205                 :          9 :     sal_uInt16 oldNumberFormat = rStream.GetNumberFormatInt();
     206                 :            :     sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
     207 [ +  + ][ +  + ]:         24 :     for ( nOffset = 0; ( nOffset <= 512 ) && ( ( nStreamPos + nOffset + 14 ) <= nStreamLen ); nOffset += 512 )
                 [ +  + ]
     208                 :            :     {
     209                 :            :         short y1,x1,y2,x2;
     210                 :         15 :         sal_Bool bdBoxOk = sal_True;
     211                 :            : 
     212         [ +  - ]:         15 :         rStream.Seek( nStreamPos + nOffset);
     213                 :            :         // size of the pict in version 1 pict ( 2bytes) : ignored
     214         [ +  - ]:         15 :         rStream.SeekRel(2);
     215                 :            :         // bounding box (bytes 2 -> 9)
     216         [ +  - ]:         15 :         rStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
     217 [ +  - ][ +  - ]:         15 :         rStream >> y1 >> x1 >> y2 >> x2;
         [ +  - ][ +  - ]
     218         [ +  - ]:         15 :         rStream.SetNumberFormatInt(oldNumberFormat); // reset format
     219                 :            : 
     220 [ +  + ][ +  - ]:         15 :         if (x1 > x2 || y1 > y2 || // bad bdbox
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
     221                 :            :             (x1 == x2 && y1 == y2) || // 1 pixel picture
     222                 :            :             x2-x1 > 2048 || y2-y1 > 2048 ) // picture anormaly big
     223                 :         15 :           bdBoxOk = sal_False;
     224                 :            : 
     225                 :            :         // read version op
     226         [ +  - ]:         15 :         rStream.Read( sBuf,3 );
     227                 :            :         // see http://developer.apple.com/legacy/mac/library/documentation/mac/pdf/Imaging_With_QuickDraw/Appendix_A.pdf
     228                 :            :         // normal version 2 - page A23 and A24
     229 [ +  + ][ -  + ]:         15 :         if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x02)
                 [ #  # ]
     230                 :          0 :             return true;
     231                 :            :         // normal version 1 - page A25
     232 [ -  + ][ #  # ]:         15 :         else if (sBuf[ 0 ] == 0x11 && sBuf[ 1 ] == 0x01 && bdBoxOk)
                 [ #  # ]
     233                 :          0 :             return true;
     234                 :            :     }
     235                 :          9 :     return false;
     236                 :            : }
     237                 :            : 
     238                 :            : 
     239                 :            : /*************************************************************************
     240                 :            : |*
     241                 :            : |*    ImpPeekGraphicFormat()
     242                 :            : |*
     243                 :            : |*    Beschreibung:
     244                 :            : |*        Diese Funktion kann zweierlei:
     245                 :            : |*        1.) Datei anlesen, Dateiformat ermitteln
     246                 :            : |*            Eingabe-prarameter:
     247                 :            : |*              rPath            - Dateipfad
     248                 :            : |*              rFormatExtension - Inhalt egal
     249                 :            : |*              bTest            - setze sal_False
     250                 :            : |*            Ausgabe-parameter:
     251                 :            : |*              Funkionswert     - sal_True wenn Erfolg
     252                 :            : |*              rFormatExtension - Bei Erfolg: uebliche Dateiendung
     253                 :            : |*                                 des Formats (Grossbuchstaben)
     254                 :            : |*        2.) Datei anlesen, Dateiformat ueberpruefen
     255                 :            : |*            Eingabe-prarameter:
     256                 :            : |*              rPath            - Dateipfad
     257                 :            : |*              rFormatExtension - uebliche Dateiendung des Formats
     258                 :            : |*                                 (Grossbuchstaben)
     259                 :            : |*              bTest            - setze sal_True
     260                 :            : |*            Ausgabe-parameter:
     261                 :            : |*              Funkionswert     - sal_False, wenn die Datei bestimmt nicht
     262                 :            : |*                                 vom uebgebenen Format ist.
     263                 :            : |*                                 sal_True, wenn die Datei WAHRSCHEINLICH von
     264                 :            : |*                                 dem Format ist, ODER WENN DAS FORMAT
     265                 :            : |*                                 DIESER FUNKTION NICHT BEKANNT IST!
     266                 :            : |*
     267                 :            : *************************************************************************/
     268                 :            : 
     269                 :       9111 : static sal_Bool ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtension, sal_Bool bTest )
     270                 :            : {
     271                 :            :     sal_uInt16  i;
     272                 :            :     sal_uInt8    sFirstBytes[ 256 ];
     273                 :            :     sal_uLong   nFirstLong,nSecondLong;
     274                 :       9111 :     sal_uLong   nStreamPos = rStream.Tell();
     275                 :            : 
     276         [ +  - ]:       9111 :     rStream.Seek( STREAM_SEEK_TO_END );
     277                 :       9111 :     sal_uLong nStreamLen = rStream.Tell() - nStreamPos;
     278         [ +  - ]:       9111 :     rStream.Seek( nStreamPos );
     279                 :            : 
     280         [ -  + ]:       9111 :     if ( !nStreamLen )
     281                 :            :     {
     282                 :          0 :         SvLockBytes* pLockBytes = rStream.GetLockBytes();
     283         [ #  # ]:          0 :         if ( pLockBytes  )
     284         [ #  # ]:          0 :             pLockBytes->SetSynchronMode( sal_True );
     285                 :            : 
     286         [ #  # ]:          0 :         rStream.Seek( STREAM_SEEK_TO_END );
     287                 :          0 :         nStreamLen = rStream.Tell() - nStreamPos;
     288         [ #  # ]:          0 :         rStream.Seek( nStreamPos );
     289                 :            :     }
     290         [ -  + ]:       9111 :     if (!nStreamLen)
     291                 :            :     {
     292                 :          0 :         return false; // this prevents at least a STL assertion
     293                 :            :     }
     294         [ +  + ]:       9111 :     else if (nStreamLen >= 256)
     295                 :            :     {   // load first 256 bytes into a buffer
     296         [ +  - ]:       9052 :         rStream.Read( sFirstBytes, 256 );
     297                 :            :     }
     298                 :            :     else
     299                 :            :     {
     300         [ +  - ]:         59 :         rStream.Read( sFirstBytes, nStreamLen );
     301                 :            : 
     302         [ +  + ]:       8194 :         for( i = (sal_uInt16) nStreamLen; i < 256; i++ )
     303                 :       8135 :             sFirstBytes[ i ]=0;
     304                 :            :     }
     305                 :            : 
     306         [ -  + ]:       9111 :     if( rStream.GetError() )
     307                 :          0 :         return sal_False;
     308                 :            : 
     309                 :            :     // Die ersten 8 Bytes in nFirstLong, nSecondLong unterbringen,
     310                 :            :     // Big-Endian:
     311         [ +  + ]:      45555 :     for( i = 0, nFirstLong = 0L, nSecondLong = 0L; i < 4; i++ )
     312                 :            :     {
     313                 :      36444 :         nFirstLong=(nFirstLong<<8)|(sal_uLong)sFirstBytes[i];
     314                 :      36444 :         nSecondLong=(nSecondLong<<8)|(sal_uLong)sFirstBytes[i+4];
     315                 :            :     }
     316                 :            : 
     317                 :            :     // Folgende Variable ist nur bei bTest==sal_True interessant. Sie
     318                 :            :     // bleibt sal_False, wenn das Format (rFormatExtension) hier noch nicht
     319                 :            :     // einprogrammiert wurde.
     320                 :       9111 :     sal_Bool bSomethingTested = sal_False;
     321                 :            : 
     322                 :            :     // Nun werden die verschieden Formate ueberprueft. Dabei ist die
     323                 :            :     // Reihenfolge nicht egal. Z.b. koennte eine MET-Datei auch durch
     324                 :            :     // den BMP-Test gehen, umgekehrt kann eine BMP-Datei kaum durch den
     325                 :            :     // MET-Test gehen. Also sollte MET vor BMP getestet werden.
     326                 :            :     // Theoretisch waere aber vielleicht auch eine BMP-Datei denkbar,
     327                 :            :     // die durch den MET-Test geht.
     328                 :            :     // Diese Probleme gibt es natuerlich nicht nur bei MET und BMP.
     329                 :            :     // Deshalb wird im Falle der Uberpruefung eines Formats (bTest==sal_True)
     330                 :            :     // nur genau dieses eine Format getestet. Alles andere koennte fatale
     331                 :            :     // Folgen haben, z.B. wenn der Benutzer sagt, es sei BMP-Datei (und es
     332                 :            :     // ist BMP-Datei), und hier wuerde die Datei durch den MET-Test gehen...
     333                 :            : 
     334                 :            :     //--------------------------- MET ------------------------------------
     335 [ +  + ][ +  - ]:       9111 :     if( !bTest || ( rFormatExtension.CompareToAscii( "MET", 3 ) == COMPARE_EQUAL ) )
         [ -  + ][ +  + ]
     336                 :            :     {
     337                 :       9105 :         bSomethingTested=sal_True;
     338         [ -  + ]:       9105 :         if( sFirstBytes[2] == 0xd3 )
     339                 :            :         {
     340         [ #  # ]:          0 :             rStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
     341         [ #  # ]:          0 :             rStream.Seek( nStreamPos );
     342                 :            :             sal_uInt16 nFieldSize;
     343                 :            :             sal_uInt8 nMagic;
     344                 :          0 :             sal_Bool bOK=sal_True;
     345 [ #  # ][ #  # ]:          0 :             rStream >> nFieldSize >> nMagic;
     346         [ #  # ]:          0 :             for (i=0; i<3; i++) {
     347         [ #  # ]:          0 :                 if (nFieldSize<6) { bOK=sal_False; break; }
     348         [ #  # ]:          0 :                 if (nStreamLen < rStream.Tell() + nFieldSize ) { bOK=sal_False; break; }
     349         [ #  # ]:          0 :                 rStream.SeekRel(nFieldSize-3);
     350 [ #  # ][ #  # ]:          0 :                 rStream >> nFieldSize >> nMagic;
     351         [ #  # ]:          0 :                 if (nMagic!=0xd3) { bOK=sal_False; break; }
     352                 :            :             }
     353         [ #  # ]:          0 :             rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
     354 [ #  # ][ #  # ]:          0 :             if (bOK && !rStream.GetError()) {
                 [ #  # ]
     355         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("MET");
     356                 :          0 :                 return sal_True;
     357                 :            :             }
     358                 :            :         }
     359                 :            :     }
     360                 :            : 
     361                 :            :     //--------------------------- BMP ------------------------------------
     362 [ +  + ][ +  - ]:       9111 :     if( !bTest || ( rFormatExtension.CompareToAscii( "BMP", 3 ) == COMPARE_EQUAL ) )
         [ -  + ][ +  + ]
     363                 :            :     {
     364                 :            :         sal_uInt8 nOffs;
     365                 :            : 
     366                 :       9105 :         bSomethingTested=sal_True;
     367                 :            : 
     368                 :            :         // OS/2-Bitmaparray ('BA') koennen wir evtl. auch lesen,
     369                 :            :         // dementspr. muessen wir den Offset anpassen,
     370                 :            :         // um auf die erste Bitmap im Array zu stossen
     371 [ -  + ][ #  # ]:       9105 :         if ( sFirstBytes[0] == 0x42 && sFirstBytes[1] == 0x41 )
     372                 :          0 :             nOffs = 14;
     373                 :            :         else
     374                 :       9105 :             nOffs = 0;
     375                 :            : 
     376                 :            :         // Jetzt testen wir zunaechst auf 'BM'
     377 [ -  + ][ #  # ]:       9105 :         if ( sFirstBytes[0+nOffs]==0x42 && sFirstBytes[1+nOffs]==0x4d )
     378                 :            :         {
     379                 :            :             // unter OS/2 koennen die Reserved-Flags != 0 sein
     380                 :            :             // (was sie eigentlich nicht duerften);
     381                 :            :             // in diesem Fall testen wir die Groesse des BmpInfoHeaders
     382 [ #  # ][ #  # ]:          0 :             if ( ( sFirstBytes[6+nOffs]==0x00 &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     383                 :          0 :                    sFirstBytes[7+nOffs]==0x00 &&
     384                 :          0 :                    sFirstBytes[8+nOffs]==0x00 &&
     385                 :          0 :                    sFirstBytes[9+nOffs]==0x00 ) ||
     386                 :          0 :                    sFirstBytes[14+nOffs] == 0x28 ||
     387                 :          0 :                    sFirstBytes[14+nOffs] == 0x0c )
     388                 :            :             {
     389         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("BMP");
     390                 :          0 :                 return sal_True;
     391                 :            :             }
     392                 :            :         }
     393                 :            :     }
     394                 :            : 
     395                 :            :     //--------------------------- WMF/EMF ------------------------------------
     396                 :            : 
     397 [ +  + ][ +  - ]:       9123 :     if( !bTest ||
         [ -  + ][ +  + ]
     398         [ +  - ]:          6 :         ( rFormatExtension.CompareToAscii( "WMF", 3 ) == COMPARE_EQUAL ) ||
     399         [ +  - ]:          6 :             ( rFormatExtension.CompareToAscii( "EMF", 3 ) == COMPARE_EQUAL ) )
     400                 :            :     {
     401                 :       9105 :         bSomethingTested = sal_True;
     402                 :            : 
     403 [ +  + ][ +  + ]:       9105 :         if ( nFirstLong==0xd7cdc69a || nFirstLong==0x01000900 )
     404                 :            :         {
     405         [ +  - ]:         60 :             rFormatExtension = rtl::OUString("WMF");
     406                 :         60 :             return sal_True;
     407                 :            :         }
     408 [ +  + ][ +  - ]:       9045 :         else if( nFirstLong == 0x01000000 && sFirstBytes[ 40 ] == 0x20 && sFirstBytes[ 41 ] == 0x45 &&
         [ +  - ][ +  - ]
                 [ +  - ]
     409                 :         88 :             sFirstBytes[ 42 ] == 0x4d && sFirstBytes[ 43 ] == 0x46 )
     410                 :            :         {
     411         [ +  - ]:         44 :             rFormatExtension = rtl::OUString("EMF");
     412                 :         44 :             return sal_True;
     413                 :            :         }
     414                 :            :     }
     415                 :            : 
     416                 :            :     //--------------------------- PCX ------------------------------------
     417 [ +  + ][ +  - ]:       9007 :     if( !bTest || ( rFormatExtension.CompareToAscii( "PCX", 3 ) == COMPARE_EQUAL ) )
         [ -  + ][ +  + ]
     418                 :            :     {
     419                 :       9001 :         bSomethingTested=sal_True;
     420         [ -  + ]:       9001 :         if (sFirstBytes[0]==0x0a)
     421                 :            :         {
     422                 :          0 :             sal_uInt8 nVersion=sFirstBytes[1];
     423                 :          0 :             sal_uInt8 nEncoding=sFirstBytes[2];
     424 [ #  # ][ #  # ]:          0 :             if( ( nVersion==0 || nVersion==2 || nVersion==3 || nVersion==5 ) && nEncoding<=1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     425                 :            :             {
     426         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("PCX");
     427                 :          0 :                 return sal_True;
     428                 :            :             }
     429                 :            :         }
     430                 :            :     }
     431                 :            : 
     432                 :            :     //--------------------------- TIF ------------------------------------
     433 [ +  + ][ +  - ]:       9007 :     if( !bTest || ( rFormatExtension.CompareToAscii( "TIF", 3 ) == COMPARE_EQUAL ) )
         [ -  + ][ +  + ]
     434                 :            :     {
     435                 :       9001 :         bSomethingTested=sal_True;
     436 [ +  - ][ -  + ]:       9001 :         if ( nFirstLong==0x49492a00 || nFirstLong==0x4d4d002a )
     437                 :            :         {
     438         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("TIF");
     439                 :          0 :             return sal_True;
     440                 :            :         }
     441                 :            :     }
     442                 :            : 
     443                 :            :     //--------------------------- GIF ------------------------------------
     444 [ +  + ][ +  - ]:       9007 :     if( !bTest || ( rFormatExtension.CompareToAscii( "GIF", 3 ) == COMPARE_EQUAL ) )
         [ -  + ][ +  + ]
     445                 :            :     {
     446                 :       9001 :         bSomethingTested=sal_True;
     447 [ +  + ][ +  - ]:       9001 :         if ( nFirstLong==0x47494638 && (sFirstBytes[4]==0x37 || sFirstBytes[4]==0x39) && sFirstBytes[5]==0x61 )
         [ +  - ][ +  - ]
     448                 :            :         {
     449         [ +  - ]:         26 :             rFormatExtension = rtl::OUString("GIF");
     450                 :         26 :             return sal_True;
     451                 :            :         }
     452                 :            :     }
     453                 :            : 
     454                 :            :     //--------------------------- PNG ------------------------------------
     455 [ +  + ][ +  - ]:       8981 :     if( !bTest || ( rFormatExtension.CompareToAscii( "PNG", 3 ) == COMPARE_EQUAL ) )
         [ +  - ][ +  - ]
     456                 :            :     {
     457                 :       8981 :         bSomethingTested=sal_True;
     458 [ +  + ][ +  - ]:       8981 :         if (nFirstLong==0x89504e47 && nSecondLong==0x0d0a1a0a)
     459                 :            :         {
     460         [ +  - ]:       2032 :             rFormatExtension = rtl::OUString("PNG");
     461                 :       2032 :             return sal_True;
     462                 :            :         }
     463                 :            :     }
     464                 :            : 
     465                 :            :     //--------------------------- JPG ------------------------------------
     466 [ -  + ][ #  # ]:       6949 :     if( !bTest || ( rFormatExtension.CompareToAscii( "JPG", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     467                 :            :     {
     468                 :       6949 :         bSomethingTested=sal_True;
     469 [ +  + ][ +  - ]:       6949 :         if ( ( nFirstLong==0xffd8ffe0 && sFirstBytes[6]==0x4a && sFirstBytes[7]==0x46 && sFirstBytes[8]==0x49 && sFirstBytes[9]==0x46 ) ||
         [ +  - ][ +  - ]
         [ -  + ][ +  + ]
                 [ +  + ]
     470                 :            :              ( nFirstLong==0xffd8fffe ) || ( 0xffd8ff00 == ( nFirstLong & 0xffffff00 ) ) )
     471                 :            :         {
     472         [ +  - ]:         35 :             rFormatExtension = rtl::OUString("JPG");
     473                 :         35 :             return sal_True;
     474                 :            :         }
     475                 :            :     }
     476                 :            : 
     477                 :            :     //--------------------------- SVM ------------------------------------
     478 [ -  + ][ #  # ]:       6914 :     if( !bTest || ( rFormatExtension.CompareToAscii( "SVM", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     479                 :            :     {
     480                 :       6914 :         bSomethingTested=sal_True;
     481 [ -  + ][ #  # ]:       6914 :         if( nFirstLong==0x53564744 && sFirstBytes[4]==0x49 )
     482                 :            :         {
     483         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("SVM");
     484                 :          0 :             return sal_True;
     485                 :            :         }
     486 [ +  + ][ +  - ]:       6914 :         else if( sFirstBytes[0]==0x56 && sFirstBytes[1]==0x43 && sFirstBytes[2]==0x4C &&
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     487                 :      20715 :                  sFirstBytes[3]==0x4D && sFirstBytes[4]==0x54 && sFirstBytes[5]==0x46 )
     488                 :            :         {
     489         [ +  - ]:       6905 :             rFormatExtension = rtl::OUString("SVM");
     490                 :       6905 :             return sal_True;
     491                 :            :         }
     492                 :            :     }
     493                 :            : 
     494                 :            :     //--------------------------- PCD ------------------------------------
     495 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "PCD", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     496                 :            :     {
     497                 :          9 :         bSomethingTested = sal_True;
     498         [ -  + ]:          9 :         if( nStreamLen >= 2055 )
     499                 :            :         {
     500                 :            :             char sBuf[8];
     501         [ #  # ]:          0 :             rStream.Seek( nStreamPos + 2048 );
     502         [ #  # ]:          0 :             rStream.Read( sBuf, 7 );
     503                 :            : 
     504         [ #  # ]:          0 :             if( strncmp( sBuf, "PCD_IPI", 7 ) ==  0 )
     505                 :            :             {
     506         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("PCD");
     507                 :          0 :                 return sal_True;
     508                 :            :             }
     509                 :            :         }
     510                 :            :     }
     511                 :            : 
     512                 :            :     //--------------------------- PSD ------------------------------------
     513 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "PSD", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     514                 :            :     {
     515                 :          9 :         bSomethingTested = sal_True;
     516 [ -  + ][ #  # ]:          9 :         if ( ( nFirstLong == 0x38425053 ) && ( (nSecondLong >> 16 ) == 1 ) )
     517                 :            :         {
     518         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("PSD");
     519                 :          0 :             return sal_True;
     520                 :            :         }
     521                 :            :     }
     522                 :            : 
     523                 :            :     //--------------------------- EPS ------------------------------------
     524 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "EPS", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     525                 :            :     {
     526                 :          9 :         bSomethingTested = sal_True;
     527         [ +  - ]:          9 :         if ( ( nFirstLong == 0xC5D0D3C6 ) || ( ImplSearchEntry( sFirstBytes, (sal_uInt8*)"%!PS-Adobe", 10, 10 ) &&
           [ -  +  #  # ]
                 [ -  + ]
     528                 :          0 :              ImplSearchEntry( &sFirstBytes[15], (sal_uInt8*)"EPS", 3, 3 ) ) )
     529                 :            :         {
     530         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("EPS");
     531                 :          0 :             return sal_True;
     532                 :            :         }
     533                 :            :     }
     534                 :            : 
     535                 :            :     //--------------------------- DXF ------------------------------------
     536 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "DXF", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     537                 :            :     {
     538                 :            :         //Binary DXF File Format
     539         [ -  + ]:          9 :         if( strncmp( (const char*) sFirstBytes, "AutoCAD Binary DXF", 18 ) == 0 )
     540                 :            :         {
     541         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("DXF");
     542                 :          0 :             return sal_True;
     543                 :            :         }
     544                 :            : 
     545                 :            :         //ASCII DXF File Format
     546                 :          9 :         i=0;
     547 [ +  - ][ +  + ]:         27 :         while (i<256 && sFirstBytes[i]<=32)
                 [ +  + ]
     548                 :         18 :             ++i;
     549                 :            : 
     550 [ +  - ][ -  + ]:          9 :         if (i<256 && sFirstBytes[i]=='0')
     551                 :            :         {
     552                 :          0 :             ++i;
     553                 :            : 
     554                 :            :             //only now do we have sufficient data to make a judgement
     555                 :            :             //based on a '0' + 'SECTION' == DXF argument
     556                 :          0 :             bSomethingTested=sal_True;
     557                 :            : 
     558 [ #  # ][ #  # ]:          0 :             while( i<256 && sFirstBytes[i]<=32 )
                 [ #  # ]
     559                 :          0 :                 ++i;
     560                 :            : 
     561 [ #  # ][ #  # ]:          0 :             if (i+7<256 && (strncmp((const char*)(sFirstBytes+i),"SECTION",7)==0))
     562                 :            :             {
     563         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("DXF");
     564                 :          0 :                 return sal_True;
     565                 :            :             }
     566                 :            :         }
     567                 :            : 
     568                 :            :     }
     569                 :            : 
     570                 :            :     //--------------------------- PCT ------------------------------------
     571 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "PCT", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     572                 :            :     {
     573                 :          9 :         bSomethingTested = sal_True;
     574 [ +  - ][ -  + ]:          9 :         if (isPCT(rStream, nStreamPos, nStreamLen))
     575                 :            :         {
     576         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("PCT");
     577                 :          0 :             return sal_True;
     578                 :            :         }
     579                 :            :     }
     580                 :            : 
     581                 :            :     //------------------------- PBM + PGM + PPM ---------------------------
     582 [ -  + ][ #  # ]:          9 :     if( !bTest ||
         [ #  # ][ #  # ]
                 [ +  - ]
     583         [ #  # ]:          0 :         ( rFormatExtension.CompareToAscii( "PBM", 3 ) == COMPARE_EQUAL ) ||
     584         [ #  # ]:          0 :             ( rFormatExtension.CompareToAscii( "PGM", 3 ) == COMPARE_EQUAL ) ||
     585         [ #  # ]:          0 :                 ( rFormatExtension.CompareToAscii( "PPM", 3 ) == COMPARE_EQUAL ) )
     586                 :            :     {
     587                 :          9 :         bSomethingTested=sal_True;
     588         [ -  + ]:          9 :         if ( sFirstBytes[ 0 ] == 'P' )
     589                 :            :         {
     590   [ #  #  #  # ]:          0 :             switch( sFirstBytes[ 1 ] )
     591                 :            :             {
     592                 :            :                 case '1' :
     593                 :            :                 case '4' :
     594         [ #  # ]:          0 :                     rFormatExtension = rtl::OUString("PBM");
     595                 :          0 :                 return sal_True;
     596                 :            : 
     597                 :            :                 case '2' :
     598                 :            :                 case '5' :
     599         [ #  # ]:          0 :                     rFormatExtension = rtl::OUString("PGM");
     600                 :          0 :                 return sal_True;
     601                 :            : 
     602                 :            :                 case '3' :
     603                 :            :                 case '6' :
     604         [ #  # ]:          0 :                     rFormatExtension = rtl::OUString("PPM");
     605                 :          0 :                 return sal_True;
     606                 :            :             }
     607                 :            :         }
     608                 :            :     }
     609                 :            : 
     610                 :            :     //--------------------------- RAS( SUN RasterFile )------------------
     611 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "RAS", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     612                 :            :     {
     613                 :          9 :         bSomethingTested=sal_True;
     614         [ -  + ]:          9 :         if( nFirstLong == 0x59a66a95 )
     615                 :            :         {
     616         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("RAS");
     617                 :          0 :             return sal_True;
     618                 :            :         }
     619                 :            :     }
     620                 :            : 
     621                 :            :     //--------------------------- XPM ------------------------------------
     622         [ +  - ]:          9 :     if( !bTest )
     623                 :            :     {
     624                 :          9 :         bSomethingTested = sal_True;
     625         [ -  + ]:          9 :         if( ImplSearchEntry( sFirstBytes, (sal_uInt8*)"/* XPM */", 256, 9 ) )
     626                 :            :         {
     627         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("XPM");
     628                 :          0 :             return sal_True;
     629                 :            :         }
     630                 :            :     }
     631 [ #  # ][ #  # ]:          0 :     else if( rFormatExtension.CompareToAscii( "XPM", 3 ) == COMPARE_EQUAL )
     632                 :            :     {
     633                 :          0 :         bSomethingTested = sal_True;
     634                 :          0 :         return sal_True;
     635                 :            :     }
     636                 :            : 
     637                 :            :     //--------------------------- XBM ------------------------------------
     638         [ +  - ]:          9 :     if( !bTest )
     639                 :            :     {
     640                 :          9 :         sal_uLong nSize = ( nStreamLen > 2048 ) ? 2048 : nStreamLen;
     641         [ +  - ]:          9 :         sal_uInt8* pBuf = new sal_uInt8 [ nSize ];
     642                 :            : 
     643         [ +  - ]:          9 :         rStream.Seek( nStreamPos );
     644         [ +  - ]:          9 :         rStream.Read( pBuf, nSize );
     645                 :          9 :         sal_uInt8* pPtr = ImplSearchEntry( pBuf, (sal_uInt8*)"#define", nSize, 7 );
     646                 :            : 
     647         [ -  + ]:          9 :         if( pPtr )
     648                 :            :         {
     649         [ #  # ]:          0 :             if( ImplSearchEntry( pPtr, (sal_uInt8*)"_width", pBuf + nSize - pPtr, 6 ) )
     650                 :            :             {
     651         [ #  # ]:          0 :                 rFormatExtension = rtl::OUString("XBM");
     652         [ #  # ]:          0 :                 delete[] pBuf;
     653                 :          0 :                 return sal_True;
     654                 :            :             }
     655                 :            :         }
     656         [ +  - ]:          9 :         delete[] pBuf;
     657                 :            :     }
     658 [ #  # ][ #  # ]:          0 :     else if( rFormatExtension.CompareToAscii( "XBM", 3 ) == COMPARE_EQUAL )
     659                 :            :     {
     660                 :          0 :         bSomethingTested = sal_True;
     661                 :          0 :         return sal_True;
     662                 :            :     }
     663                 :            : 
     664                 :            :     //--------------------------- SVG ------------------------------------
     665 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "SVG", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     666                 :            :     {
     667                 :          9 :         bSomethingTested=sal_True;
     668                 :            : 
     669                 :            :         // just a simple test for the extension
     670 [ +  - ][ -  + ]:          9 :         if( rFormatExtension.CompareToAscii( "SVG", 3 ) == COMPARE_EQUAL )
     671                 :          0 :             return sal_True;
     672                 :            : 
     673                 :          9 :         sal_uLong nSize = ( nStreamLen > 1024 ) ? 1024 : nStreamLen;
     674         [ +  - ]:          9 :         std::vector<sal_uInt8> aBuf(nSize);
     675                 :            : 
     676         [ +  - ]:          9 :         rStream.Seek( nStreamPos );
     677 [ +  - ][ +  - ]:          9 :         rStream.Read( &aBuf[0], nSize );
     678                 :            : 
     679                 :            :         // read the first 1024 bytes & check a few magic string
     680                 :            :         // constants (heuristically)
     681                 :          9 :         sal_Int8 aMagic1[] = {'<', 's', 'v', 'g'};
     682 [ +  - ][ -  + ]:          9 :         if( std::search(aBuf.begin(), aBuf.end(),
     683         [ +  - ]:          9 :                         aMagic1, aMagic1+SAL_N_ELEMENTS(aMagic1)) != aBuf.end() )
     684                 :            :         {
     685         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("SVG");
     686                 :          0 :             return sal_True;
     687                 :            :         }
     688                 :            : 
     689                 :          9 :         sal_Int8 aMagic2[] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ', 's', 'v', 'g'};
     690 [ +  - ][ -  + ]:          9 :         if( std::search(aBuf.begin(), aBuf.end(),
     691         [ +  - ]:          9 :                         aMagic2, aMagic2+SAL_N_ELEMENTS(aMagic2)) != aBuf.end() )
     692                 :            :         {
     693         [ #  # ]:          0 :             rFormatExtension = rtl::OUString("SVG");
     694                 :          9 :             return sal_True;
     695         [ +  - ]:          9 :         }
     696                 :            :     }
     697                 :            : 
     698                 :            :     //--------------------------- TGA ------------------------------------
     699 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     700                 :            :     {
     701                 :          9 :         bSomethingTested = sal_True;
     702                 :            : 
     703                 :            :         // just a simple test for the extension
     704 [ +  - ][ -  + ]:          9 :         if( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL )
     705                 :          0 :             return sal_True;
     706                 :            :     }
     707                 :            : 
     708                 :            :     //--------------------------- SGV ------------------------------------
     709 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     710                 :            :     {
     711                 :          9 :         bSomethingTested = sal_True;
     712                 :            : 
     713                 :            :         // just a simple test for the extension
     714 [ +  - ][ -  + ]:          9 :         if( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL )
     715                 :          0 :             return sal_True;
     716                 :            :     }
     717                 :            : 
     718                 :            :     //--------------------------- SGF ------------------------------------
     719 [ -  + ][ #  # ]:          9 :     if( !bTest || ( rFormatExtension.CompareToAscii( "SGF", 3 ) == COMPARE_EQUAL ) )
         [ #  # ][ +  - ]
     720                 :            :     {
     721                 :          9 :         bSomethingTested=sal_True;
     722 [ +  + ][ +  - ]:          9 :         if( sFirstBytes[ 0 ] == 'J' && sFirstBytes[ 1 ] == 'J' )
     723                 :            :         {
     724         [ +  - ]:          6 :             rFormatExtension = rtl::OUString("SGF");
     725                 :          6 :             return sal_True;
     726                 :            :         }
     727                 :            :     }
     728                 :            : 
     729 [ -  + ][ #  # ]:       9111 :     return bTest && !bSomethingTested;
     730                 :            : }
     731                 :            : 
     732                 :            : //--------------------------------------------------------------------------
     733                 :            : 
     734                 :       9111 : sal_uInt16 GraphicFilter::ImpTestOrFindFormat( const String& rPath, SvStream& rStream, sal_uInt16& rFormat )
     735                 :            : {
     736                 :       9111 :     sal_uInt16 n = pConfig->GetImportFormatCount();
     737                 :            : 
     738                 :            :     // ggf. Filter bzw. Format durch anlesen ermitteln,
     739                 :            :     // oder durch anlesen zusichern, dass das Format stimmt:
     740         [ +  + ]:       9111 :     if( rFormat == GRFILTER_FORMAT_DONTKNOW )
     741                 :            :     {
     742         [ +  - ]:       9105 :         String aFormatExt;
     743 [ +  - ][ +  + ]:       9105 :         if( ImpPeekGraphicFormat( rStream, aFormatExt, sal_False ) )
     744                 :            :         {
     745         [ +  + ]:     183639 :             for( sal_uInt16 i = 0; i < n; i++ )
     746                 :            :             {
     747 [ +  - ][ +  - ]:     183600 :                 if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aFormatExt ) )
         [ +  - ][ +  + ]
     748                 :            :                 {
     749                 :       9063 :                     rFormat = i;
     750                 :       9063 :                     return GRFILTER_OK;
     751                 :            :                 }
     752                 :            :             }
     753                 :            :         }
     754                 :            :         // ggf. Filter anhand der Datei-Endung raussuchen:
     755         [ +  + ]:         42 :         if( rPath.Len() )
     756                 :            :         {
     757         [ +  - ]:          3 :             String aExt( ImpGetExtension( rPath ) );
     758         [ +  + ]:         78 :             for( sal_uInt16 i = 0; i < n; i++ )
     759                 :            :             {
     760 [ +  - ][ +  - ]:         75 :                 if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aExt ) )
         [ +  - ][ -  + ]
     761                 :            :                 {
     762                 :          0 :                     rFormat = i;
     763                 :          0 :                     return GRFILTER_OK;
     764                 :            :                 }
     765 [ +  - ][ +  - ]:          3 :             }
     766                 :            :         }
     767         [ +  - ]:       9105 :         return GRFILTER_FORMATERROR;
     768                 :            :     }
     769                 :            :     else
     770                 :            :     {
     771         [ +  - ]:          6 :         String aTmpStr( pConfig->GetImportFormatExtension( rFormat ) );
     772 [ +  - ][ +  - ]:          6 :         if( !ImpPeekGraphicFormat( rStream, aTmpStr.ToUpperAscii(), sal_True ) )
                 [ -  + ]
     773                 :          0 :             return GRFILTER_FORMATERROR;
     774 [ +  - ][ +  - ]:          6 :         if ( pConfig->GetImportFormatExtension( rFormat ).EqualsIgnoreCaseAscii( "pcd" ) )
         [ +  - ][ -  + ]
     775                 :            :         {
     776                 :          0 :             sal_Int32 nBase = 2;    // default Base0
     777 [ #  # ][ #  # ]:          0 :             if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base4" ) )
         [ #  # ][ #  # ]
     778                 :          0 :                 nBase = 1;
     779 [ #  # ][ #  # ]:          0 :             else if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base16" ) )
         [ #  # ][ #  # ]
     780                 :          0 :                 nBase = 0;
     781         [ #  # ]:          0 :             String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
     782 [ #  # ][ #  # ]:          0 :             FilterConfigItem aFilterConfigItem( aFilterConfigPath );
     783 [ #  # ][ #  # ]:          6 :             aFilterConfigItem.WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), nBase );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     784 [ +  - ][ +  - ]:          6 :         }
     785                 :            :     }
     786                 :            : 
     787                 :       9111 :     return GRFILTER_OK;
     788                 :            : }
     789                 :            : 
     790                 :            : //--------------------------------------------------------------------------
     791                 :            : 
     792                 :        298 : static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& rConfigItem )
     793                 :            : {
     794                 :        298 :     Graphic     aGraphic;
     795                 :            : 
     796 [ +  - ][ +  - ]:        298 :     ResMgr*     pResMgr = ResMgr::CreateResMgr( "svt", Application::GetSettings().GetUILocale() );
                 [ +  - ]
     797                 :            : 
     798 [ +  - ][ +  - ]:        298 :     sal_Int32 nLogicalWidth = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalWidth" ) ), 0 );
         [ +  - ][ +  - ]
     799 [ +  - ][ +  - ]:        298 :     sal_Int32 nLogicalHeight = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalHeight" ) ), 0 );
         [ +  - ][ +  - ]
     800                 :            : 
     801 [ +  - ][ +  - ]:        298 :     if ( rGraphic.GetType() != GRAPHIC_NONE )
     802                 :            :     {
     803 [ +  - ][ +  - ]:        298 :         sal_Int32 nMode = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ExportMode" ) ), -1 );
         [ +  - ][ +  - ]
     804                 :            : 
     805         [ +  - ]:        298 :         if ( nMode == -1 )  // the property is not there, this is possible, if the graphic filter
     806                 :            :         {                   // is called via UnoGraphicExporter and not from a graphic export Dialog
     807                 :        298 :             nMode = 0;      // then we are defaulting this mode to 0
     808 [ +  - ][ -  + ]:        298 :             if ( nLogicalWidth || nLogicalHeight )
     809                 :          0 :                 nMode = 2;
     810                 :            :         }
     811                 :            : 
     812                 :            : 
     813                 :        298 :         Size aOriginalSize;
     814         [ +  - ]:        298 :         Size aPrefSize( rGraphic.GetPrefSize() );
     815         [ +  - ]:        298 :         MapMode aPrefMapMode( rGraphic.GetPrefMapMode() );
     816 [ +  - ][ +  - ]:        298 :         if ( aPrefMapMode == MAP_PIXEL )
         [ +  - ][ +  + ]
     817 [ +  - ][ +  - ]:         31 :             aOriginalSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
         [ +  - ][ +  - ]
     818                 :            :         else
     819 [ +  - ][ +  - ]:        267 :             aOriginalSize = Application::GetDefaultDevice()->LogicToLogic( aPrefSize, aPrefMapMode, MAP_100TH_MM );
         [ +  - ][ +  - ]
     820         [ +  - ]:        298 :         if ( !nLogicalWidth )
     821                 :        298 :             nLogicalWidth = aOriginalSize.Width();
     822         [ +  - ]:        298 :         if ( !nLogicalHeight )
     823                 :        298 :             nLogicalHeight = aOriginalSize.Height();
     824 [ +  - ][ +  + ]:        298 :         if( rGraphic.GetType() == GRAPHIC_BITMAP )
     825                 :            :         {
     826                 :            : 
     827                 :            :             // Aufloesung wird eingestellt
     828         [ -  + ]:         31 :             if( nMode == 1 )
     829                 :            :             {
     830         [ #  # ]:          0 :                 Bitmap      aBitmap( rGraphic.GetBitmap() );
     831         [ #  # ]:          0 :                 MapMode     aMap( MAP_100TH_INCH );
     832                 :            : 
     833 [ #  # ][ #  # ]:          0 :                 sal_Int32   nDPI = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), 75 );
         [ #  # ][ #  # ]
     834         [ #  # ]:          0 :                 Fraction    aFrac( 1, Min( Max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) );
     835                 :            : 
     836         [ #  # ]:          0 :                 aMap.SetScaleX( aFrac );
     837         [ #  # ]:          0 :                 aMap.SetScaleY( aFrac );
     838                 :            : 
     839         [ #  # ]:          0 :                 Size aOldSize = aBitmap.GetSizePixel();
     840         [ #  # ]:          0 :                aGraphic = rGraphic;
     841         [ #  # ]:          0 :                aGraphic.SetPrefMapMode( aMap );
     842                 :          0 :                aGraphic.SetPrefSize( Size( aOldSize.Width() * 100,
     843 [ #  # ][ #  # ]:          0 :                                            aOldSize.Height() * 100 ) );
                 [ #  # ]
     844                 :            :             }
     845                 :            :             // Groesse wird eingestellt
     846         [ -  + ]:         31 :             else if( nMode == 2 )
     847                 :            :             {
     848         [ #  # ]:          0 :                aGraphic = rGraphic;
     849 [ #  # ][ #  # ]:          0 :                aGraphic.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
                 [ #  # ]
     850         [ #  # ]:          0 :                aGraphic.SetPrefSize( Size( nLogicalWidth, nLogicalHeight ) );
     851                 :            :             }
     852                 :            :             else
     853         [ +  - ]:         31 :                 aGraphic = rGraphic;
     854                 :            : 
     855 [ +  - ][ +  - ]:         31 :             sal_Int32 nColors = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ), 0 ); // #92767#
         [ +  - ][ +  - ]
     856         [ -  + ]:         31 :             if ( nColors )  // graphic conversion necessary ?
     857                 :            :             {
     858         [ #  # ]:          0 :                 BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
     859         [ #  # ]:          0 :                 aBmpEx.Convert( (BmpConversion)nColors );   // the entries in the xml section have the same meaning as
     860 [ #  # ][ #  # ]:          0 :                 aGraphic = aBmpEx;                          // they have in the BmpConversion enum, so it should be
         [ #  # ][ #  # ]
     861                 :            :             }                                               // allowed to cast them
     862                 :            :         }
     863                 :            :         else
     864                 :            :         {
     865 [ +  - ][ -  + ]:        267 :             if( ( nMode == 1 ) || ( nMode == 2 ) )
     866                 :            :             {
     867 [ #  # ][ #  # ]:          0 :                 GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
     868                 :          0 :                 ::com::sun::star::awt::Size aDefaultSize( 10000, 10000 );
     869 [ #  # ][ #  # ]:          0 :                 Size aNewSize( OutputDevice::LogicToLogic( Size( nLogicalWidth, nLogicalHeight ), MAP_100TH_MM, aMtf.GetPrefMapMode() ) );
                 [ #  # ]
     870                 :            : 
     871 [ #  # ][ #  # ]:          0 :                 if( aNewSize.Width() && aNewSize.Height() )
                 [ #  # ]
     872                 :            :                 {
     873                 :          0 :                     const Size aPreferredSize( aMtf.GetPrefSize() );
     874                 :          0 :                     aMtf.Scale( Fraction( aNewSize.Width(), aPreferredSize.Width() ),
     875 [ #  # ][ #  # ]:          0 :                                 Fraction( aNewSize.Height(), aPreferredSize.Height() ) );
                 [ #  # ]
     876                 :            :                 }
     877 [ #  # ][ #  # ]:          0 :                 aGraphic = Graphic( aMtf );
         [ #  # ][ #  # ]
     878                 :            :             }
     879                 :            :             else
     880         [ +  - ]:        267 :                 aGraphic = rGraphic;
     881         [ +  - ]:        298 :         }
     882                 :            : 
     883                 :            :     }
     884                 :            :     else
     885         [ #  # ]:          0 :         aGraphic = rGraphic;
     886                 :            : 
     887 [ +  - ][ +  - ]:        298 :     delete pResMgr;
     888                 :            : 
     889                 :        298 :     return aGraphic;
     890                 :            : }
     891                 :            : 
     892                 :          0 : static String ImpCreateFullFilterPath( const String& rPath, const String& rFilterName )
     893                 :            : {
     894                 :          0 :     ::rtl::OUString aPathURL;
     895                 :            : 
     896 [ #  # ][ #  # ]:          0 :     ::osl::FileBase::getFileURLFromSystemPath( rPath, aPathURL );
     897                 :          0 :     aPathURL += rtl::OUString( '/' );
     898                 :            : 
     899                 :          0 :     ::rtl::OUString aSystemPath;
     900         [ #  # ]:          0 :     ::osl::FileBase::getSystemPathFromFileURL( aPathURL, aSystemPath );
     901         [ #  # ]:          0 :     aSystemPath += ::rtl::OUString( rFilterName );
     902                 :            : 
     903         [ #  # ]:          0 :     return String( aSystemPath );
     904                 :            : }
     905                 :            : 
     906                 :            : 
     907                 :            : // --------------------------
     908                 :            : // - ImpFilterLibCacheEntry -
     909                 :            : // --------------------------
     910                 :            : 
     911                 :            : class ImpFilterLibCache;
     912                 :            : 
     913         [ #  # ]:          0 : struct ImpFilterLibCacheEntry
     914                 :            : {
     915                 :            :     ImpFilterLibCacheEntry* mpNext;
     916                 :            :     osl::Module             maLibrary;
     917                 :            :     String                  maFiltername;
     918                 :            :     PFilterCall             mpfnImport;
     919                 :            :     PFilterDlgCall          mpfnImportDlg;
     920                 :            : 
     921                 :            :                             ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername );
     922                 :          0 :     int                     operator==( const String& rFiltername ) const { return maFiltername == rFiltername; }
     923                 :            : 
     924                 :            :     PFilterCall             GetImportFunction();
     925                 :            : };
     926                 :            : 
     927                 :            : // ------------------------------------------------------------------------
     928                 :            : 
     929                 :          0 : ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername ) :
     930                 :            :         mpNext          ( NULL ),
     931                 :            :         maLibrary       ( rPathname ),
     932                 :            :         maFiltername    ( rFiltername ),
     933                 :            :         mpfnImport      ( NULL ),
     934 [ #  # ][ #  # ]:          0 :         mpfnImportDlg   ( NULL )
     935                 :            : {
     936                 :          0 : }
     937                 :            : 
     938                 :            : // ------------------------------------------------------------------------
     939                 :            : 
     940                 :          0 : PFilterCall ImpFilterLibCacheEntry::GetImportFunction()
     941                 :            : {
     942         [ #  # ]:          0 :     if( !mpfnImport )
     943         [ #  # ]:          0 :         mpfnImport = (PFilterCall) maLibrary.getFunctionSymbol(rtl::OUString(IMPORT_FUNCTION_NAME));
     944                 :            : 
     945                 :          0 :     return mpfnImport;
     946                 :            : }
     947                 :            : 
     948                 :            : // ------------------------------------------------------------------------
     949                 :            : 
     950                 :            : // ---------------------
     951                 :            : // - ImpFilterLibCache -
     952                 :            : // ---------------------
     953                 :            : 
     954                 :            : class ImpFilterLibCache
     955                 :            : {
     956                 :            :     ImpFilterLibCacheEntry* mpFirst;
     957                 :            :     ImpFilterLibCacheEntry* mpLast;
     958                 :            : 
     959                 :            : public:
     960                 :            :                             ImpFilterLibCache();
     961                 :            :                             ~ImpFilterLibCache();
     962                 :            : 
     963                 :            :     ImpFilterLibCacheEntry* GetFilter( const String& rFilterPath, const String& rFiltername );
     964                 :            : };
     965                 :            : 
     966                 :            : // ------------------------------------------------------------------------
     967                 :            : 
     968                 :          0 : ImpFilterLibCache::ImpFilterLibCache() :
     969                 :            :     mpFirst     ( NULL ),
     970                 :          0 :     mpLast      ( NULL )
     971                 :            : {
     972                 :          0 : }
     973                 :            : 
     974                 :            : // ------------------------------------------------------------------------
     975                 :            : 
     976                 :          0 : ImpFilterLibCache::~ImpFilterLibCache()
     977                 :            : {
     978                 :          0 :     ImpFilterLibCacheEntry* pEntry = mpFirst;
     979         [ #  # ]:          0 :     while( pEntry )
     980                 :            :     {
     981                 :          0 :         ImpFilterLibCacheEntry* pNext = pEntry->mpNext;
     982         [ #  # ]:          0 :         delete pEntry;
     983                 :          0 :         pEntry = pNext;
     984                 :            :     }
     985                 :          0 : }
     986                 :            : 
     987                 :            : // ------------------------------------------------------------------------
     988                 :            : 
     989                 :          0 : ImpFilterLibCacheEntry* ImpFilterLibCache::GetFilter( const String& rFilterPath, const String& rFilterName )
     990                 :            : {
     991                 :          0 :     ImpFilterLibCacheEntry* pEntry = mpFirst;
     992                 :            : 
     993         [ #  # ]:          0 :     while( pEntry )
     994                 :            :     {
     995         [ #  # ]:          0 :         if( *pEntry == rFilterName )
     996                 :          0 :             break;
     997                 :            :         else
     998                 :          0 :             pEntry = pEntry->mpNext;
     999                 :            :     }
    1000         [ #  # ]:          0 :     if( !pEntry )
    1001                 :            :     {
    1002         [ #  # ]:          0 :         String aPhysicalName( ImpCreateFullFilterPath( rFilterPath, rFilterName ) );
    1003 [ #  # ][ #  # ]:          0 :         pEntry = new ImpFilterLibCacheEntry( aPhysicalName, rFilterName );
    1004                 :            : 
    1005         [ #  # ]:          0 :         if ( pEntry->maLibrary.is() )
    1006                 :            :         {
    1007         [ #  # ]:          0 :             if( !mpFirst )
    1008                 :          0 :                 mpFirst = mpLast = pEntry;
    1009                 :            :             else
    1010                 :          0 :                 mpLast = mpLast->mpNext = pEntry;
    1011                 :            :         }
    1012                 :            :         else
    1013                 :            :         {
    1014 [ #  # ][ #  # ]:          0 :             delete pEntry;
    1015                 :          0 :             pEntry = NULL;
    1016         [ #  # ]:          0 :         }
    1017                 :            :     }
    1018                 :          0 :     return pEntry;
    1019                 :            : };
    1020                 :            : 
    1021                 :            : // ------------------------------------------------------------------------
    1022                 :            : 
    1023                 :            : namespace { struct Cache : public rtl::Static<ImpFilterLibCache, Cache> {}; }
    1024                 :            : 
    1025                 :            : // -----------------
    1026                 :            : // - GraphicFilter -
    1027                 :            : // -----------------
    1028                 :            : 
    1029                 :        202 : GraphicFilter::GraphicFilter( sal_Bool bConfig ) :
    1030                 :            :     bUseConfig        ( bConfig ),
    1031                 :        202 :     nExpGraphHint     ( 0 )
    1032                 :            : {
    1033         [ +  - ]:        202 :     ImplInit();
    1034                 :        202 : }
    1035                 :            : 
    1036                 :            : // ------------------------------------------------------------------------
    1037                 :            : 
    1038                 :        202 : GraphicFilter::~GraphicFilter()
    1039                 :            : {
    1040                 :            :     {
    1041 [ +  - ][ +  - ]:        202 :         ::osl::MutexGuard aGuard( getListMutex() );
    1042   [ #  #  +  - ]:        404 :         for(
                 [ +  - ]
    1043                 :        202 :             FilterList_impl::iterator it = pFilterHdlList->begin();
    1044                 :        202 :             it != pFilterHdlList->end();
    1045                 :            :             ++it
    1046                 :            :         ) {
    1047 [ +  - ][ +  - ]:        202 :             if( *it == this )
    1048                 :            :             {
    1049         [ +  - ]:        202 :                 pFilterHdlList->erase( it );
    1050                 :        202 :                 break;
    1051                 :            :             }
    1052                 :            :         }
    1053         [ +  - ]:        202 :         if( pFilterHdlList->empty() )
    1054                 :            :         {
    1055         [ +  - ]:        202 :             delete pFilterHdlList, pFilterHdlList = NULL;
    1056 [ +  - ][ +  - ]:        202 :             delete pConfig;
    1057         [ +  - ]:        202 :         }
    1058                 :            :     }
    1059                 :            : 
    1060                 :        202 :     delete pErrorEx;
    1061                 :        202 : }
    1062                 :            : 
    1063                 :            : // ------------------------------------------------------------------------
    1064                 :            : 
    1065                 :        202 : void GraphicFilter::ImplInit()
    1066                 :            : {
    1067                 :            :     {
    1068 [ +  - ][ +  - ]:        202 :         ::osl::MutexGuard aGuard( getListMutex() );
    1069                 :            : 
    1070         [ +  - ]:        202 :         if ( !pFilterHdlList )
    1071                 :            :         {
    1072 [ +  - ][ +  - ]:        202 :             pFilterHdlList = new FilterList_impl;
    1073 [ +  - ][ +  - ]:        202 :             pConfig = new FilterConfigCache( bUseConfig );
    1074                 :            :         }
    1075                 :            :         else
    1076         [ #  # ]:          0 :             pConfig = pFilterHdlList->front()->pConfig;
    1077                 :            : 
    1078 [ +  - ][ +  - ]:        202 :         pFilterHdlList->push_back( this );
    1079                 :            :     }
    1080                 :            : 
    1081         [ +  + ]:        202 :     if( bUseConfig )
    1082                 :            :     {
    1083         [ +  - ]:         91 :         rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program"));
    1084                 :         91 :         rtl::Bootstrap::expandMacros(url); //TODO: detect failure
    1085         [ +  - ]:         91 :         utl::LocalFileHelper::ConvertURLToPhysicalName(url, aFilterPath);
    1086                 :            :     }
    1087                 :            : 
    1088                 :        202 :     pErrorEx = new FilterErrorEx;
    1089                 :        202 :     bAbort = sal_False;
    1090                 :        202 : }
    1091                 :            : 
    1092                 :            : // ------------------------------------------------------------------------
    1093                 :            : 
    1094                 :         93 : sal_uLong GraphicFilter::ImplSetError( sal_uLong nError, const SvStream* pStm )
    1095                 :            : {
    1096                 :         93 :     pErrorEx->nFilterError = nError;
    1097         [ +  - ]:         93 :     pErrorEx->nStreamError = pStm ? pStm->GetError() : ERRCODE_NONE;
    1098                 :         93 :     return nError;
    1099                 :            : }
    1100                 :            : // ------------------------------------------------------------------------
    1101                 :            : 
    1102                 :         95 : sal_uInt16 GraphicFilter::GetImportFormatCount()
    1103                 :            : {
    1104                 :         95 :     return pConfig->GetImportFormatCount();
    1105                 :            : }
    1106                 :            : 
    1107                 :            : // ------------------------------------------------------------------------
    1108                 :            : 
    1109                 :          4 : sal_uInt16 GraphicFilter::GetImportFormatNumber( const String& rFormatName )
    1110                 :            : {
    1111                 :          4 :     return pConfig->GetImportFormatNumber( rFormatName );
    1112                 :            : }
    1113                 :            : 
    1114                 :            : // ------------------------------------------------------------------------
    1115                 :            : 
    1116                 :          0 : sal_uInt16 GraphicFilter::GetImportFormatNumberForMediaType( const String& rMediaType )
    1117                 :            : {
    1118                 :          0 :     return pConfig->GetImportFormatNumberForMediaType( rMediaType );
    1119                 :            : }
    1120                 :            : 
    1121                 :            : // ------------------------------------------------------------------------
    1122                 :            : 
    1123                 :         20 : sal_uInt16 GraphicFilter::GetImportFormatNumberForShortName( const String& rShortName )
    1124                 :            : {
    1125                 :         20 :     return pConfig->GetImportFormatNumberForShortName( rShortName );
    1126                 :            : }
    1127                 :            : 
    1128                 :            : // ------------------------------------------------------------------------
    1129                 :            : 
    1130                 :          0 : sal_uInt16 GraphicFilter::GetImportFormatNumberForTypeName( const String& rType )
    1131                 :            : {
    1132                 :          0 :     return pConfig->GetImportFormatNumberForTypeName( rType );
    1133                 :            : }
    1134                 :            : 
    1135                 :            : // ------------------------------------------------------------------------
    1136                 :            : 
    1137                 :          0 : String GraphicFilter::GetImportFormatName( sal_uInt16 nFormat )
    1138                 :            : {
    1139                 :          0 :     return pConfig->GetImportFormatName( nFormat );
    1140                 :            : }
    1141                 :            : 
    1142                 :            : // ------------------------------------------------------------------------
    1143                 :            : 
    1144                 :          0 : String GraphicFilter::GetImportFormatTypeName( sal_uInt16 nFormat )
    1145                 :            : {
    1146                 :          0 :     return pConfig->GetImportFilterTypeName( nFormat );
    1147                 :            : }
    1148                 :            : 
    1149                 :            : // ------------------------------------------------------------------------
    1150                 :            : 
    1151                 :          0 : String GraphicFilter::GetImportFormatMediaType( sal_uInt16 nFormat )
    1152                 :            : {
    1153                 :          0 :     return pConfig->GetImportFormatMediaType( nFormat );
    1154                 :            : }
    1155                 :            : 
    1156                 :            : // ------------------------------------------------------------------------
    1157                 :            : 
    1158                 :          0 : String GraphicFilter::GetImportFormatShortName( sal_uInt16 nFormat )
    1159                 :            : {
    1160                 :          0 :     return pConfig->GetImportFormatShortName( nFormat );
    1161                 :            : }
    1162                 :            : 
    1163                 :            : // ------------------------------------------------------------------------
    1164                 :            : 
    1165                 :          0 : String GraphicFilter::GetImportOSFileType( sal_uInt16 )
    1166                 :            : {
    1167                 :          0 :     String aOSFileType;
    1168                 :          0 :     return aOSFileType;
    1169                 :            : }
    1170                 :            : 
    1171                 :            : // ------------------------------------------------------------------------
    1172                 :            : 
    1173                 :          0 : String GraphicFilter::GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
    1174                 :            : {
    1175                 :          0 :     return pConfig->GetImportWildcard( nFormat, nEntry );
    1176                 :            : }
    1177                 :            : 
    1178                 :            : // ------------------------------------------------------------------------
    1179                 :            : 
    1180                 :          0 : sal_Bool GraphicFilter::IsImportPixelFormat( sal_uInt16 nFormat )
    1181                 :            : {
    1182                 :          0 :     return pConfig->IsImportPixelFormat( nFormat );
    1183                 :            : }
    1184                 :            : 
    1185                 :            : // ------------------------------------------------------------------------
    1186                 :            : 
    1187                 :        298 : sal_uInt16 GraphicFilter::GetExportFormatCount()
    1188                 :            : {
    1189                 :        298 :     return pConfig->GetExportFormatCount();
    1190                 :            : }
    1191                 :            : 
    1192                 :            : // ------------------------------------------------------------------------
    1193                 :            : 
    1194                 :          0 : sal_uInt16 GraphicFilter::GetExportFormatNumber( const String& rFormatName )
    1195                 :            : {
    1196                 :          0 :     return pConfig->GetExportFormatNumber( rFormatName );
    1197                 :            : }
    1198                 :            : 
    1199                 :            : // ------------------------------------------------------------------------
    1200                 :            : 
    1201                 :          0 : sal_uInt16 GraphicFilter::GetExportFormatNumberForMediaType( const String& rMediaType )
    1202                 :            : {
    1203                 :          0 :     return pConfig->GetExportFormatNumberForMediaType( rMediaType );
    1204                 :            : }
    1205                 :            : 
    1206                 :            : // ------------------------------------------------------------------------
    1207                 :            : 
    1208                 :        298 : sal_uInt16 GraphicFilter::GetExportFormatNumberForShortName( const String& rShortName )
    1209                 :            : {
    1210                 :        298 :     return pConfig->GetExportFormatNumberForShortName( rShortName );
    1211                 :            : }
    1212                 :            : 
    1213                 :            : // ------------------------------------------------------------------------
    1214                 :            : 
    1215                 :          0 : sal_uInt16 GraphicFilter::GetExportFormatNumberForTypeName( const String& rType )
    1216                 :            : {
    1217                 :          0 :     return pConfig->GetExportFormatNumberForTypeName( rType );
    1218                 :            : }
    1219                 :            : 
    1220                 :            : // ------------------------------------------------------------------------
    1221                 :            : 
    1222                 :          0 : String GraphicFilter::GetExportFormatName( sal_uInt16 nFormat )
    1223                 :            : {
    1224                 :          0 :     return pConfig->GetExportFormatName( nFormat );
    1225                 :            : }
    1226                 :            : 
    1227                 :            : // ------------------------------------------------------------------------
    1228                 :            : 
    1229                 :          0 : String GraphicFilter::GetExportFormatTypeName( sal_uInt16 nFormat )
    1230                 :            : {
    1231                 :          0 :     return pConfig->GetExportFilterTypeName( nFormat );
    1232                 :            : }
    1233                 :            : 
    1234                 :            : // ------------------------------------------------------------------------
    1235                 :            : 
    1236                 :          0 : String GraphicFilter::GetExportFormatMediaType( sal_uInt16 nFormat )
    1237                 :            : {
    1238                 :          0 :     return pConfig->GetExportFormatMediaType( nFormat );
    1239                 :            : }
    1240                 :            : 
    1241                 :            : // ------------------------------------------------------------------------
    1242                 :            : 
    1243                 :          0 : String GraphicFilter::GetExportFormatShortName( sal_uInt16 nFormat )
    1244                 :            : {
    1245                 :          0 :     return pConfig->GetExportFormatShortName( nFormat );
    1246                 :            : }
    1247                 :            : 
    1248                 :            : // ------------------------------------------------------------------------
    1249                 :            : 
    1250                 :          0 : String GraphicFilter::GetExportOSFileType( sal_uInt16 )
    1251                 :            : {
    1252                 :          0 :     String aOSFileType;
    1253                 :          0 :     return aOSFileType;
    1254                 :            : }
    1255                 :            : 
    1256                 :            : // ------------------------------------------------------------------------
    1257                 :            : 
    1258                 :          0 : String GraphicFilter::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
    1259                 :            : {
    1260                 :          0 :     return pConfig->GetExportWildcard( nFormat, nEntry );
    1261                 :            : }
    1262                 :            : 
    1263                 :            : // ------------------------------------------------------------------------
    1264                 :            : 
    1265                 :         90 : sal_Bool GraphicFilter::IsExportPixelFormat( sal_uInt16 nFormat )
    1266                 :            : {
    1267                 :         90 :     return pConfig->IsExportPixelFormat( nFormat );
    1268                 :            : }
    1269                 :            : 
    1270                 :            : // ------------------------------------------------------------------------
    1271                 :            : 
    1272                 :          0 : sal_uInt16 GraphicFilter::CanImportGraphic( const INetURLObject& rPath,
    1273                 :            :                                         sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat )
    1274                 :            : {
    1275                 :          0 :     sal_uInt16  nRetValue = GRFILTER_FORMATERROR;
    1276                 :            :     DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::CanImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
    1277                 :            : 
    1278 [ #  # ][ #  # ]:          0 :     String      aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
    1279         [ #  # ]:          0 :     SvStream*   pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
    1280         [ #  # ]:          0 :     if ( pStream )
    1281                 :            :     {
    1282         [ #  # ]:          0 :         nRetValue = CanImportGraphic( aMainUrl, *pStream, nFormat, pDeterminedFormat );
    1283 [ #  # ][ #  # ]:          0 :         delete pStream;
    1284                 :            :     }
    1285         [ #  # ]:          0 :     return nRetValue;
    1286                 :            : }
    1287                 :            : 
    1288                 :            : // ------------------------------------------------------------------------
    1289                 :            : 
    1290                 :          0 : sal_uInt16 GraphicFilter::CanImportGraphic( const String& rMainUrl, SvStream& rIStream,
    1291                 :            :                                         sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat )
    1292                 :            : {
    1293                 :          0 :     sal_uLong nStreamPos = rIStream.Tell();
    1294                 :          0 :     sal_uInt16 nRes = ImpTestOrFindFormat( rMainUrl, rIStream, nFormat );
    1295                 :            : 
    1296                 :          0 :     rIStream.Seek(nStreamPos);
    1297                 :            : 
    1298 [ #  # ][ #  # ]:          0 :     if( nRes==GRFILTER_OK && pDeterminedFormat!=NULL )
    1299                 :          0 :         *pDeterminedFormat = nFormat;
    1300                 :            : 
    1301                 :          0 :     return (sal_uInt16) ImplSetError( nRes, &rIStream );
    1302                 :            : }
    1303                 :            : 
    1304                 :            : // ------------------------------------------------------------------------
    1305                 :            : //SJ: TODO, we need to create a GraphicImporter component
    1306                 :          0 : sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath,
    1307                 :            :                                      sal_uInt16 nFormat, sal_uInt16 * pDeterminedFormat, sal_uInt32 nImportFlags )
    1308                 :            : {
    1309                 :          0 :     sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
    1310                 :            :     DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
    1311                 :            : 
    1312 [ #  # ][ #  # ]:          0 :     String      aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
    1313         [ #  # ]:          0 :     SvStream*   pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
    1314         [ #  # ]:          0 :     if ( pStream )
    1315                 :            :     {
    1316         [ #  # ]:          0 :         nRetValue = ImportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pDeterminedFormat, nImportFlags );
    1317 [ #  # ][ #  # ]:          0 :         delete pStream;
    1318                 :            :     }
    1319         [ #  # ]:          0 :     return nRetValue;
    1320                 :            : }
    1321                 :            : 
    1322                 :       9111 : sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
    1323                 :            :                                      sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags, WMF_EXTERNALHEADER *pExtHeader )
    1324                 :            : {
    1325                 :       9111 :     return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL, pExtHeader );
    1326                 :            : }
    1327                 :            : 
    1328                 :            : //-------------------------------------------------------------------------
    1329                 :            : 
    1330                 :       9111 : sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
    1331                 :            :                                      sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags,
    1332                 :            :                                      com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData,
    1333                 :            :                                      WMF_EXTERNALHEADER *pExtHeader )
    1334                 :            : {
    1335         [ +  - ]:       9111 :     String                  aFilterName;
    1336                 :            :     sal_uLong                   nStmBegin;
    1337                 :            :     sal_uInt16                  nStatus;
    1338         [ +  - ]:       9111 :     GraphicReader*          pContext = rGraphic.GetContext();
    1339                 :       9111 :     GfxLinkType             eLinkType = GFX_LINK_TYPE_NONE;
    1340                 :       9111 :     sal_Bool                    bDummyContext = ( pContext == (GraphicReader*) 1 );
    1341         [ +  - ]:       9111 :     const sal_Bool              bLinkSet = rGraphic.IsLink();
    1342                 :       9111 :     FilterConfigItem*       pFilterConfigItem = NULL;
    1343                 :            : 
    1344                 :       9111 :     Size                    aPreviewSizeHint( 0, 0 );
    1345                 :       9111 :     sal_Bool                bAllowPartialStreamRead = sal_False;
    1346                 :       9111 :     sal_Bool                bCreateNativeLink = sal_True;
    1347                 :            : 
    1348         [ +  - ]:       9111 :     ResetLastError();
    1349                 :            : 
    1350         [ -  + ]:       9111 :     if ( pFilterData )
    1351                 :            :     {
    1352                 :            :         sal_Int32 i;
    1353         [ #  # ]:          0 :         for ( i = 0; i < pFilterData->getLength(); i++ )
    1354                 :            :         {
    1355 [ #  # ][ #  # ]:          0 :             if ( (*pFilterData)[ i ].Name == "PreviewSizeHint" )
    1356                 :            :             {
    1357                 :          0 :                 awt::Size aSize;
    1358 [ #  # ][ #  # ]:          0 :                 if ( (*pFilterData)[ i ].Value >>= aSize )
                 [ #  # ]
    1359                 :            :                 {
    1360                 :          0 :                     aPreviewSizeHint = Size( aSize.Width, aSize.Height );
    1361 [ #  # ][ #  # ]:          0 :                     if ( aSize.Width || aSize.Height )
    1362                 :          0 :                         nImportFlags |= GRFILTER_I_FLAGS_FOR_PREVIEW;
    1363                 :            :                     else
    1364                 :          0 :                         nImportFlags &=~GRFILTER_I_FLAGS_FOR_PREVIEW;
    1365                 :            :                 }
    1366                 :            :             }
    1367 [ #  # ][ #  # ]:          0 :             else if ( (*pFilterData)[ i ].Name == "AllowPartialStreamRead" )
    1368                 :            :             {
    1369         [ #  # ]:          0 :                 (*pFilterData)[ i ].Value >>= bAllowPartialStreamRead;
    1370         [ #  # ]:          0 :                 if ( bAllowPartialStreamRead )
    1371                 :          0 :                     nImportFlags |= GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
    1372                 :            :                 else
    1373                 :          0 :                     nImportFlags &=~GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
    1374                 :            :             }
    1375 [ #  # ][ #  # ]:          0 :             else if ( (*pFilterData)[ i ].Name == "CreateNativeLink" )
    1376                 :            :             {
    1377         [ #  # ]:          0 :                 (*pFilterData)[ i ].Value >>= bCreateNativeLink;
    1378                 :            :             }
    1379                 :            :         }
    1380                 :            :     }
    1381                 :            : 
    1382 [ -  + ][ #  # ]:       9111 :     if( !pContext || bDummyContext )
    1383                 :            :     {
    1384         [ -  + ]:       9111 :         if( bDummyContext )
    1385                 :            :         {
    1386         [ #  # ]:          0 :             rGraphic.SetContext( NULL );
    1387                 :          0 :             nStmBegin = 0;
    1388                 :            :         }
    1389                 :            :         else
    1390                 :       9111 :             nStmBegin = rIStream.Tell();
    1391                 :            : 
    1392                 :       9111 :         bAbort = sal_False;
    1393         [ +  - ]:       9111 :         nStatus = ImpTestOrFindFormat( rPath, rIStream, nFormat );
    1394                 :            :         // Falls Pending, geben wir GRFILTER_OK zurueck,
    1395                 :            :         // um mehr Bytes anzufordern
    1396         [ -  + ]:       9111 :         if( rIStream.GetError() == ERRCODE_IO_PENDING )
    1397                 :            :         {
    1398         [ #  # ]:          0 :             rGraphic.SetContext( (GraphicReader*) 1 );
    1399         [ #  # ]:          0 :             rIStream.ResetError();
    1400         [ #  # ]:          0 :             rIStream.Seek( nStmBegin );
    1401         [ #  # ]:          0 :             return (sal_uInt16) ImplSetError( GRFILTER_OK );
    1402                 :            :         }
    1403                 :            : 
    1404         [ +  - ]:       9111 :         rIStream.Seek( nStmBegin );
    1405                 :            : 
    1406 [ +  + ][ -  + ]:       9111 :         if( ( nStatus != GRFILTER_OK ) || rIStream.GetError() )
                 [ +  + ]
    1407 [ +  - ][ +  - ]:         42 :             return (sal_uInt16) ImplSetError( ( nStatus != GRFILTER_OK ) ? nStatus : GRFILTER_OPENERROR, &rIStream );
    1408                 :            : 
    1409         [ -  + ]:       9069 :         if( pDeterminedFormat )
    1410                 :          0 :             *pDeterminedFormat = nFormat;
    1411                 :            : 
    1412 [ +  - ][ +  - ]:       9069 :         aFilterName = pConfig->GetImportFilterName( nFormat );
                 [ +  - ]
    1413                 :            :     }
    1414                 :            :     else
    1415                 :            :     {
    1416 [ #  # ][ #  # ]:          0 :         if( pContext && !bDummyContext )
    1417         [ #  # ]:          0 :             aFilterName = pContext->GetUpperFilterName();
    1418                 :            : 
    1419                 :          0 :         nStmBegin = 0;
    1420                 :          0 :         nStatus = GRFILTER_OK;
    1421                 :            :     }
    1422                 :            : 
    1423                 :            :     // read graphic
    1424 [ +  - ][ +  - ]:       9069 :     if ( pConfig->IsImportInternalFilter( nFormat ) )
    1425                 :            :     {
    1426 [ +  - ][ +  + ]:       9069 :         if( aFilterName.EqualsIgnoreCaseAscii( IMP_GIF )  )
    1427                 :            :         {
    1428 [ +  - ][ -  + ]:         26 :             if( rGraphic.GetContext() == (GraphicReader*) 1 )
    1429         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1430                 :            : 
    1431 [ +  - ][ +  + ]:         26 :             if( !ImportGIF( rIStream, rGraphic ) )
    1432                 :          3 :                 nStatus = GRFILTER_FILTERERROR;
    1433                 :            :             else
    1434                 :         23 :                 eLinkType = GFX_LINK_TYPE_NATIVE_GIF;
    1435                 :            :         }
    1436 [ +  - ][ +  + ]:       9043 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_PNG ) )
    1437                 :            :         {
    1438 [ +  - ][ -  + ]:       2032 :             if ( rGraphic.GetContext() == (GraphicReader*) 1 )
    1439         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1440                 :            : 
    1441         [ +  - ]:       2032 :             vcl::PNGReader aPNGReader( rIStream );
    1442                 :            : 
    1443                 :            :             // ignore animation for previews and set preview size
    1444 [ +  - ][ -  + ]:       2032 :             if( aPreviewSizeHint.Width() || aPreviewSizeHint.Height() )
                 [ -  + ]
    1445                 :            :             {
    1446                 :            :                 // position the stream at the end of the image if requested
    1447         [ #  # ]:          0 :                 if( !bAllowPartialStreamRead )
    1448         [ #  # ]:          0 :                     aPNGReader.GetChunks();
    1449                 :            :             }
    1450                 :            :             else
    1451                 :            :             {
    1452                 :            :                 // check if this PNG contains a GIF chunk!
    1453         [ +  - ]:       2032 :                 const std::vector< vcl::PNGReader::ChunkData >&    rChunkData = aPNGReader.GetChunks();
    1454                 :       2032 :                 std::vector< vcl::PNGReader::ChunkData >::const_iterator aIter( rChunkData.begin() );
    1455                 :       2032 :                 std::vector< vcl::PNGReader::ChunkData >::const_iterator aEnd ( rChunkData.end() );
    1456 [ +  - ][ +  + ]:      11977 :                 while( aIter != aEnd )
    1457                 :            :                 {
    1458                 :            :                     // Microsoft Office is storing Animated GIFs in following chunk
    1459 [ +  - ][ -  + ]:       9945 :                     if ( aIter->nType == PMGCHUNG_msOG )
    1460                 :            :                     {
    1461         [ #  # ]:          0 :                         sal_uInt32 nChunkSize = aIter->aData.size();
    1462         [ #  # ]:          0 :                         if ( nChunkSize > 11 )
    1463                 :            :                         {
    1464         [ #  # ]:          0 :                             const std::vector< sal_uInt8 >& rData = aIter->aData;
    1465 [ #  # ][ #  # ]:          0 :                             SvMemoryStream aIStrm( (void*)&rData[ 11 ], nChunkSize - 11, STREAM_READ );
    1466         [ #  # ]:          0 :                             ImportGIF( aIStrm, rGraphic );
    1467                 :          0 :                             eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
    1468         [ #  # ]:          0 :                             break;
    1469                 :            :                         }
    1470                 :            :                     }
    1471         [ +  - ]:       9945 :                     ++aIter;
    1472                 :            :                 }
    1473                 :            :             }
    1474                 :            : 
    1475         [ +  - ]:       2032 :             if ( eLinkType == GFX_LINK_TYPE_NONE )
    1476                 :            :             {
    1477         [ +  - ]:       2032 :                 BitmapEx aBmpEx( aPNGReader.Read( aPreviewSizeHint ) );
    1478 [ +  - ][ +  + ]:       2032 :                 if ( aBmpEx.IsEmpty() )
    1479                 :         15 :                     nStatus = GRFILTER_FILTERERROR;
    1480                 :            :                 else
    1481                 :            :                 {
    1482 [ +  - ][ +  - ]:       2017 :                     rGraphic = aBmpEx;
                 [ +  - ]
    1483                 :       2017 :                     eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
    1484         [ +  - ]:       2032 :                 }
    1485         [ +  - ]:       2032 :             }
    1486                 :            :         }
    1487 [ +  - ][ +  + ]:       7011 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_JPEG ) )
    1488                 :            :         {
    1489 [ +  - ][ -  + ]:         26 :             if( rGraphic.GetContext() == (GraphicReader*) 1 )
    1490         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1491                 :            : 
    1492                 :            :             // set LOGSIZE flag always, if not explicitly disabled
    1493                 :            :             // (see #90508 and #106763)
    1494         [ +  - ]:         26 :             if( 0 == ( nImportFlags & GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG ) )
    1495                 :         26 :                 nImportFlags |= GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG;
    1496                 :            : 
    1497 [ +  - ][ +  + ]:         26 :             if( !ImportJPEG( rIStream, rGraphic, NULL, nImportFlags ) )
    1498                 :          9 :                 nStatus = GRFILTER_FILTERERROR;
    1499                 :            :             else
    1500                 :         17 :                 eLinkType = GFX_LINK_TYPE_NATIVE_JPG;
    1501                 :            :         }
    1502 [ +  - ][ -  + ]:       6985 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_SVG ) )
    1503                 :            :         {
    1504 [ #  # ][ #  # ]:          0 :             if( rGraphic.GetContext() == (GraphicReader*) 1 )
    1505         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1506                 :            : 
    1507         [ #  # ]:          0 :             vcl::SVGReader  aSVGReader( rIStream );
    1508         [ #  # ]:          0 :             GDIMetaFile     aSVGMtf;
    1509                 :            : 
    1510 [ #  # ][ #  # ]:          0 :             if( 0 == aSVGReader.Read( aSVGMtf ).GetActionSize() )
                 [ #  # ]
    1511                 :            :             {
    1512                 :          0 :                 nStatus = GRFILTER_FILTERERROR;
    1513                 :            :             }
    1514                 :            :             else
    1515                 :            :             {
    1516 [ #  # ][ #  # ]:          0 :                 rGraphic = Graphic( aSVGMtf );
                 [ #  # ]
    1517                 :          0 :                 eLinkType = GFX_LINK_TYPE_NATIVE_SVG;
    1518 [ #  # ][ #  # ]:          0 :             }
    1519                 :            :         }
    1520 [ +  - ][ -  + ]:       6985 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XBM ) )
    1521                 :            :         {
    1522 [ #  # ][ #  # ]:          0 :             if( rGraphic.GetContext() == (GraphicReader*) 1 )
    1523         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1524                 :            : 
    1525 [ #  # ][ #  # ]:          0 :             if( !ImportXBM( rIStream, rGraphic ) )
    1526                 :          0 :                 nStatus = GRFILTER_FILTERERROR;
    1527                 :            :         }
    1528 [ +  - ][ -  + ]:       6985 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XPM ) )
    1529                 :            :         {
    1530 [ #  # ][ #  # ]:          0 :             if( rGraphic.GetContext() == (GraphicReader*) 1 )
    1531         [ #  # ]:          0 :                 rGraphic.SetContext( NULL );
    1532                 :            : 
    1533 [ #  # ][ #  # ]:          0 :             if( !ImportXPM( rIStream, rGraphic ) )
    1534                 :          0 :                 nStatus = GRFILTER_FILTERERROR;
    1535                 :            :         }
    1536 [ +  - ][ +  - ]:      13970 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_BMP ) ||
         [ +  + ][ +  + ]
    1537         [ +  - ]:       6985 :                     aFilterName.EqualsIgnoreCaseAscii( IMP_SVMETAFILE ) )
    1538                 :            :         {
    1539                 :            :             // SV interne Importfilter fuer Bitmaps und MetaFiles
    1540         [ +  - ]:       6905 :             rIStream >> rGraphic;
    1541         [ -  + ]:       6905 :             if( rIStream.GetError() )
    1542                 :          0 :                 nStatus = GRFILTER_FORMATERROR;
    1543                 :            :         }
    1544 [ +  - ][ +  + ]:        130 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_WMF ) ||
         [ +  + ][ +  + ]
    1545         [ +  - ]:         50 :                 aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
    1546                 :            :         {
    1547         [ +  - ]:         74 :             GDIMetaFile aMtf;
    1548 [ +  - ][ +  + ]:         74 :             if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pExtHeader ) )
    1549                 :         24 :                 nStatus = GRFILTER_FORMATERROR;
    1550                 :            :             else
    1551                 :            :             {
    1552 [ +  - ][ +  - ]:         50 :                 rGraphic = aMtf;
                 [ +  - ]
    1553                 :         50 :                 eLinkType = GFX_LINK_TYPE_NATIVE_WMF;
    1554         [ +  - ]:         74 :             }
    1555                 :            :         }
    1556 [ +  - ][ -  + ]:          6 :         else if( aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGF )
         [ #  # ][ +  - ]
    1557         [ #  # ]:          0 :                 || aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGV ) )
    1558                 :            :         {
    1559                 :            :             sal_uInt16          nVersion;
    1560         [ +  - ]:          6 :             unsigned char   nTyp = CheckSgfTyp( rIStream, nVersion );
    1561                 :            : 
    1562   [ -  -  +  - ]:          6 :             switch( nTyp )
    1563                 :            :             {
    1564                 :            :                 case SGF_BITIMAGE:
    1565                 :            :                 {
    1566         [ #  # ]:          0 :                     SvMemoryStream aTempStream;
    1567         [ #  # ]:          0 :                     if( aTempStream.GetError() )
    1568                 :          0 :                         return GRFILTER_OPENERROR;
    1569                 :            : 
    1570 [ #  # ][ #  # ]:          0 :                     if( !SgfBMapFilter( rIStream, aTempStream ) )
    1571                 :          0 :                         nStatus = GRFILTER_FILTERERROR;
    1572                 :            :                     else
    1573                 :            :                     {
    1574         [ #  # ]:          0 :                         aTempStream.Seek( 0L );
    1575         [ #  # ]:          0 :                         aTempStream >> rGraphic;
    1576                 :            : 
    1577         [ #  # ]:          0 :                         if( aTempStream.GetError() )
    1578                 :          0 :                             nStatus = GRFILTER_FILTERERROR;
    1579 [ #  # ][ #  # ]:          0 :                     }
    1580                 :            :                 }
    1581                 :          0 :                 break;
    1582                 :            : 
    1583                 :            :                 case SGF_SIMPVECT:
    1584                 :            :                 {
    1585         [ #  # ]:          0 :                     GDIMetaFile aMtf;
    1586 [ #  # ][ #  # ]:          0 :                     if( !SgfVectFilter( rIStream, aMtf ) )
    1587                 :          0 :                         nStatus = GRFILTER_FILTERERROR;
    1588                 :            :                     else
    1589 [ #  # ][ #  # ]:          0 :                         rGraphic = Graphic( aMtf );
         [ #  # ][ #  # ]
    1590                 :            :                 }
    1591                 :          0 :                 break;
    1592                 :            : 
    1593                 :            :                 case SGF_STARDRAW:
    1594                 :            :                 {
    1595         [ -  + ]:          6 :                     if( nVersion != SGV_VERSION )
    1596                 :          0 :                         nStatus = GRFILTER_VERSIONERROR;
    1597                 :            :                     else
    1598                 :            :                     {
    1599         [ +  - ]:          6 :                         GDIMetaFile aMtf;
    1600         [ -  + ]:          6 :                         if( !SgfSDrwFilter( rIStream, aMtf,
    1601 [ +  - ][ +  - ]:          6 :                                 INetURLObject(aFilterPath) ) )
                 [ +  - ]
    1602                 :            :                         {
    1603                 :          0 :                             nStatus = GRFILTER_FILTERERROR;
    1604                 :            :                         }
    1605                 :            :                         else
    1606 [ +  - ][ +  - ]:          6 :                             rGraphic = Graphic( aMtf );
         [ +  - ][ +  - ]
    1607                 :            :                     }
    1608                 :            :                 }
    1609                 :          6 :                 break;
    1610                 :            : 
    1611                 :            :                 default:
    1612                 :            :                 {
    1613                 :          0 :                     nStatus = GRFILTER_FORMATERROR;
    1614                 :            :                 }
    1615                 :          6 :                 break;
    1616                 :            :             }
    1617                 :            :         }
    1618                 :            :         else
    1619                 :          0 :             nStatus = GRFILTER_FILTERERROR;
    1620                 :            :     }
    1621                 :            :     else
    1622                 :            :     {
    1623                 :          0 :         ImpFilterLibCacheEntry* pFilter = NULL;
    1624                 :            : 
    1625                 :            :         // find first filter in filter paths
    1626         [ #  # ]:          0 :         sal_Int32 i, nTokenCount = getTokenCount(aFilterPath, ';');
    1627                 :          0 :         ImpFilterLibCache &rCache = Cache::get();
    1628 [ #  # ][ #  # ]:          0 :         for( i = 0; ( i < nTokenCount ) && ( pFilter == NULL ); i++ )
                 [ #  # ]
    1629 [ #  # ][ #  # ]:          0 :             pFilter = rCache.GetFilter( getToken(aFilterPath, i, ';'), aFilterName );
                 [ #  # ]
    1630         [ #  # ]:          0 :         if( !pFilter )
    1631                 :          0 :             nStatus = GRFILTER_FILTERERROR;
    1632                 :            :         else
    1633                 :            :         {
    1634         [ #  # ]:          0 :             PFilterCall pFunc = pFilter->GetImportFunction();
    1635                 :            : 
    1636         [ #  # ]:          0 :             if( !pFunc )
    1637                 :          0 :                 nStatus = GRFILTER_FILTERERROR;
    1638                 :            :             else
    1639                 :            :             {
    1640         [ #  # ]:          0 :                 String aShortName;
    1641         [ #  # ]:          0 :                 if( nFormat != GRFILTER_FORMAT_DONTKNOW )
    1642                 :            :                 {
    1643 [ #  # ][ #  # ]:          0 :                     aShortName = GetImportFormatShortName( nFormat ).ToUpperAscii();
         [ #  # ][ #  # ]
    1644 [ #  # ][ #  # ]:          0 :                     if ( ( pFilterConfigItem == NULL ) && aShortName.EqualsAscii( "PCD" ) )
         [ #  # ][ #  # ]
    1645                 :            :                     {
    1646         [ #  # ]:          0 :                         String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
    1647 [ #  # ][ #  # ]:          0 :                         pFilterConfigItem = new FilterConfigItem( aFilterConfigPath );
         [ #  # ][ #  # ]
    1648                 :            :                     }
    1649                 :            :                 }
    1650 [ #  # ][ #  # ]:          0 :                 if( !(*pFunc)( rIStream, rGraphic, pFilterConfigItem, sal_False ) )
    1651                 :          0 :                     nStatus = GRFILTER_FORMATERROR;
    1652                 :            :                 else
    1653                 :            :                 {
    1654                 :            :                     // try to set link type if format matches
    1655         [ #  # ]:          0 :                     if( nFormat != GRFILTER_FORMAT_DONTKNOW )
    1656                 :            :                     {
    1657 [ #  # ][ #  # ]:          0 :                         if( aShortName.CompareToAscii( TIF_SHORTNAME ) == COMPARE_EQUAL )
    1658                 :          0 :                             eLinkType = GFX_LINK_TYPE_NATIVE_TIF;
    1659 [ #  # ][ #  # ]:          0 :                         else if( aShortName.CompareToAscii( MET_SHORTNAME ) == COMPARE_EQUAL )
    1660                 :          0 :                             eLinkType = GFX_LINK_TYPE_NATIVE_MET;
    1661 [ #  # ][ #  # ]:          0 :                         else if( aShortName.CompareToAscii( PCT_SHORTNAME ) == COMPARE_EQUAL )
    1662                 :          0 :                             eLinkType = GFX_LINK_TYPE_NATIVE_PCT;
    1663                 :            :                     }
    1664 [ #  # ][ #  # ]:          0 :                 }
    1665                 :            :             }
    1666                 :            :         }
    1667                 :            :     }
    1668                 :            : 
    1669 [ +  + ][ +  - ]:       9069 :     if( nStatus == GRFILTER_OK && bCreateNativeLink && ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet )
         [ +  + ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
    1670                 :            :     {
    1671                 :       2101 :         const sal_uLong nStmEnd = rIStream.Tell();
    1672                 :       2101 :         const sal_uLong nBufSize = nStmEnd - nStmBegin;
    1673                 :            : 
    1674         [ +  - ]:       2101 :         if( nBufSize )
    1675                 :            :         {
    1676                 :       2101 :             sal_uInt8*  pBuf=0;
    1677                 :            :             try
    1678                 :            :             {
    1679         [ +  - ]:       2101 :                 pBuf = new sal_uInt8[ nBufSize ];
    1680                 :            :             }
    1681                 :          0 :             catch (const std::bad_alloc&)
    1682                 :            :             {
    1683                 :          0 :                 nStatus = GRFILTER_TOOBIG;
    1684                 :            :             }
    1685                 :            : 
    1686         [ +  - ]:       2101 :             if( nStatus == GRFILTER_OK )
    1687                 :            :             {
    1688         [ +  - ]:       2101 :                 rIStream.Seek( nStmBegin );
    1689         [ +  - ]:       2101 :                 rIStream.Read( pBuf, nBufSize );
    1690 [ +  - ][ +  - ]:       2101 :                 rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, sal_True ) );
                 [ +  - ]
    1691                 :            :             }
    1692                 :            :         }
    1693                 :            :     }
    1694                 :            : 
    1695                 :            :     // Set error code or try to set native buffer
    1696         [ +  + ]:       9069 :     if( nStatus != GRFILTER_OK )
    1697                 :            :     {
    1698         [ -  + ]:         51 :         if( bAbort )
    1699                 :          0 :             nStatus = GRFILTER_ABORT;
    1700                 :            : 
    1701         [ +  - ]:         51 :         ImplSetError( nStatus, &rIStream );
    1702         [ +  - ]:         51 :         rIStream.Seek( nStmBegin );
    1703         [ +  - ]:         51 :         rGraphic.Clear();
    1704                 :            :     }
    1705                 :            : 
    1706 [ -  + ][ #  # ]:       9069 :     delete pFilterConfigItem;
    1707         [ +  - ]:       9111 :     return nStatus;
    1708                 :            : }
    1709                 :            : 
    1710                 :            : 
    1711                 :            : // ------------------------------------------------------------------------
    1712                 :            : 
    1713                 :          0 : sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath,
    1714                 :            :     sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
    1715                 :            : {
    1716                 :            :     RTL_LOGFILE_CONTEXT( aLog, "GraphicFilter::ExportGraphic() (thb)" );
    1717                 :          0 :     sal_uInt16  nRetValue = GRFILTER_FORMATERROR;
    1718                 :            :     DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ExportGraphic() : ProtType == INET_PROT_NOT_VALID" );
    1719         [ #  # ]:          0 :     sal_Bool        bAlreadyExists = ImplDirEntryHelper::Exists( rPath );
    1720                 :            : 
    1721 [ #  # ][ #  # ]:          0 :     String      aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
    1722         [ #  # ]:          0 :     SvStream*   pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_WRITE | STREAM_TRUNC );
    1723         [ #  # ]:          0 :     if ( pStream )
    1724                 :            :     {
    1725         [ #  # ]:          0 :         nRetValue = ExportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pFilterData );
    1726 [ #  # ][ #  # ]:          0 :         delete pStream;
    1727                 :            : 
    1728 [ #  # ][ #  # ]:          0 :         if( ( GRFILTER_OK != nRetValue ) && !bAlreadyExists )
    1729         [ #  # ]:          0 :             ImplDirEntryHelper::Kill( aMainUrl );
    1730                 :            :     }
    1731         [ #  # ]:          0 :     return nRetValue;
    1732                 :            : }
    1733                 :            : 
    1734                 :            : // ------------------------------------------------------------------------
    1735                 :            : 
    1736                 :        298 : sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& rPath,
    1737                 :            :     SvStream& rOStm, sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
    1738                 :            : {
    1739                 :            :     RTL_LOGFILE_CONTEXT( aLog, "GraphicFilter::ExportGraphic() (thb)" );
    1740         [ +  - ]:        298 :     sal_uInt16 nFormatCount = GetExportFormatCount();
    1741                 :            : 
    1742         [ +  - ]:        298 :     ResetLastError();
    1743                 :        298 :     nExpGraphHint = 0;
    1744                 :            : 
    1745         [ -  + ]:        298 :     if( nFormat == GRFILTER_FORMAT_DONTKNOW )
    1746                 :            :     {
    1747 [ #  # ][ #  # ]:          0 :         INetURLObject aURL( rPath );
    1748 [ #  # ][ #  # ]:          0 :         String aExt( aURL.GetFileExtension().toAsciiUpperCase() );
    1749                 :            : 
    1750                 :            : 
    1751         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < nFormatCount; i++ )
    1752                 :            :         {
    1753 [ #  # ][ #  # ]:          0 :             if ( pConfig->GetExportFormatExtension( i ).EqualsIgnoreCaseAscii( aExt ) )
         [ #  # ][ #  # ]
    1754                 :            :             {
    1755                 :          0 :                 nFormat=i;
    1756                 :          0 :                 break;
    1757                 :            :             }
    1758 [ #  # ][ #  # ]:          0 :         }
    1759                 :            :     }
    1760         [ -  + ]:        298 :     if( nFormat >= nFormatCount )
    1761         [ #  # ]:          0 :         return (sal_uInt16) ImplSetError( GRFILTER_FORMATERROR );
    1762                 :            : 
    1763         [ +  - ]:        298 :     FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData );
    1764         [ +  - ]:        298 :     String aFilterName( pConfig->GetExportFilterName( nFormat ) );
    1765                 :            : 
    1766                 :        298 :     bAbort              = sal_False;
    1767                 :        298 :     sal_uInt16      nStatus = GRFILTER_OK;
    1768                 :            :     GraphicType eType;
    1769         [ +  - ]:        298 :     Graphic     aGraphic( rGraphic );
    1770                 :            : 
    1771 [ +  - ][ +  - ]:        298 :     aGraphic = ImpGetScaledGraphic( rGraphic, aConfigItem );
                 [ +  - ]
    1772         [ +  - ]:        298 :     eType = aGraphic.GetType();
    1773                 :            : 
    1774 [ +  - ][ +  + ]:        298 :     if( pConfig->IsExportPixelFormat( nFormat ) )
    1775                 :            :     {
    1776         [ +  + ]:        118 :         if( eType != GRAPHIC_BITMAP )
    1777                 :            :         {
    1778                 :         87 :             Size aSizePixel;
    1779                 :            :             sal_uLong nColorCount,nBitsPerPixel,nNeededMem,nMaxMem;
    1780         [ +  - ]:         87 :             VirtualDevice aVirDev;
    1781                 :            : 
    1782                 :            :             // Maximalen Speicherbedarf fuer das Bildes holen:
    1783                 :            : //          if( GetOptionsConfig() )
    1784                 :            : //              nMaxMem = (UINT32)GetOptionsConfig()->ReadKey( "VEC-TO-PIX-MAX-KB", "1024" ).ToInt32();
    1785                 :            : //          else
    1786                 :         87 :                 nMaxMem = 1024;
    1787                 :            : 
    1788                 :         87 :             nMaxMem *= 1024; // In Bytes
    1789                 :            : 
    1790                 :            :             // Berechnen, wie gross das Bild normalerweise werden wuerde:
    1791 [ +  - ][ +  - ]:         87 :             aSizePixel=aVirDev.LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode());
         [ +  - ][ +  - ]
    1792                 :            : 
    1793                 :            :             // Berechnen, wieviel Speicher das Bild benoetigen wuerde:
    1794         [ +  - ]:         87 :             nColorCount=aVirDev.GetColorCount();
    1795         [ -  + ]:         87 :             if      (nColorCount<=2)     nBitsPerPixel=1;
    1796         [ -  + ]:         87 :             else if (nColorCount<=4)     nBitsPerPixel=2;
    1797         [ -  + ]:         87 :             else if (nColorCount<=16)    nBitsPerPixel=4;
    1798         [ -  + ]:         87 :             else if (nColorCount<=256)   nBitsPerPixel=8;
    1799         [ -  + ]:         87 :             else if (nColorCount<=65536) nBitsPerPixel=16;
    1800                 :         87 :             else                         nBitsPerPixel=24;
    1801                 :         87 :             nNeededMem=((sal_uLong)aSizePixel.Width()*(sal_uLong)aSizePixel.Height()*nBitsPerPixel+7)/8;
    1802                 :            : 
    1803                 :            :             // ggf. Groesse des Bildes einschraenken:
    1804         [ -  + ]:         87 :             if (nMaxMem<nNeededMem)
    1805                 :            :             {
    1806                 :          0 :                 double fFak=sqrt(((double)nMaxMem)/((double)nNeededMem));
    1807                 :          0 :                 aSizePixel.Width()=(sal_uLong)(((double)aSizePixel.Width())*fFak);
    1808                 :          0 :                 aSizePixel.Height()=(sal_uLong)(((double)aSizePixel.Height())*fFak);
    1809                 :            :             }
    1810                 :            : 
    1811 [ +  - ][ +  - ]:         87 :             aVirDev.SetMapMode(MapMode(MAP_PIXEL));
                 [ +  - ]
    1812         [ +  - ]:         87 :             aVirDev.SetOutputSizePixel(aSizePixel);
    1813         [ +  - ]:         87 :             Graphic aGraphic2=aGraphic;
    1814         [ +  - ]:         87 :             aGraphic2.Draw(&aVirDev,Point(0,0),aSizePixel); // Gemein: dies aendert den MapMode
    1815 [ +  - ][ +  - ]:         87 :             aVirDev.SetMapMode(MapMode(MAP_PIXEL));
                 [ +  - ]
    1816 [ +  - ][ +  - ]:         87 :             aGraphic=Graphic(aVirDev.GetBitmap(Point(0,0),aSizePixel));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1817                 :            :         }
    1818                 :            :     }
    1819         [ -  + ]:        298 :     if( rOStm.GetError() )
    1820                 :          0 :         nStatus = GRFILTER_IOERROR;
    1821         [ +  - ]:        298 :     if( GRFILTER_OK == nStatus )
    1822                 :            :     {
    1823 [ +  - ][ +  - ]:        298 :         if ( pConfig->IsExportInternalFilter( nFormat ) )
    1824                 :            :         {
    1825 [ +  - ][ -  + ]:        298 :             if( aFilterName.EqualsIgnoreCaseAscii( EXP_BMP ) )
    1826                 :            :             {
    1827         [ #  # ]:          0 :                 Bitmap aBmp( aGraphic.GetBitmap() );
    1828 [ #  # ][ #  # ]:          0 :                 sal_Int32 nColorRes = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) ), 0 );
         [ #  # ][ #  # ]
    1829 [ #  # ][ #  # ]:          0 :                 if ( nColorRes && ( nColorRes <= (sal_uInt16)BMP_CONVERSION_24BIT) )
    1830                 :            :                 {
    1831 [ #  # ][ #  # ]:          0 :                     if( !aBmp.Convert( (BmpConversion) nColorRes ) )
    1832 [ #  # ][ #  # ]:          0 :                         aBmp = aGraphic.GetBitmap();
                 [ #  # ]
    1833                 :            :                 }
    1834         [ #  # ]:          0 :                 ResMgr*     pResMgr = CREATERESMGR( svt );
    1835 [ #  # ][ #  # ]:          0 :                 sal_Bool    bRleCoding = aConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "RLE_Coding" ) ), sal_True );
         [ #  # ][ #  # ]
    1836                 :            :                 // Wollen wir RLE-Kodiert speichern?
    1837         [ #  # ]:          0 :                 aBmp.Write( rOStm, bRleCoding );
    1838 [ #  # ][ #  # ]:          0 :                 delete pResMgr;
    1839                 :            : 
    1840         [ #  # ]:          0 :                 if( rOStm.GetError() )
    1841         [ #  # ]:          0 :                     nStatus = GRFILTER_IOERROR;
    1842                 :            :             }
    1843 [ +  - ][ +  + ]:        298 :             else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVMETAFILE ) )
    1844                 :            :             {
    1845 [ +  - ][ +  - ]:         90 :                 sal_Int32 nVersion = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), 0 ) ;
         [ +  - ][ +  - ]
    1846         [ +  - ]:         90 :                 if ( nVersion )
    1847                 :         90 :                     rOStm.SetVersion( nVersion );
    1848         [ +  - ]:         90 :                 GDIMetaFile aMTF;
    1849                 :            : 
    1850         [ +  - ]:         90 :                 if ( eType != GRAPHIC_BITMAP )
    1851 [ +  - ][ +  - ]:         90 :                     aMTF = aGraphic.GetGDIMetaFile();
    1852                 :            :                 else
    1853                 :            :                 {
    1854         [ #  # ]:          0 :                     VirtualDevice aVirDev;
    1855                 :            : 
    1856         [ #  # ]:          0 :                     aMTF.Record( &aVirDev );
    1857 [ #  # ][ #  # ]:          0 :                     aGraphic.Draw( &aVirDev, Point(), aGraphic.GetPrefSize() );
    1858         [ #  # ]:          0 :                     aMTF.Stop();
    1859         [ #  # ]:          0 :                     aMTF.SetPrefSize( aGraphic.GetPrefSize() );
    1860 [ #  # ][ #  # ]:          0 :                     aMTF.SetPrefMapMode( aGraphic.GetPrefMapMode() );
         [ #  # ][ #  # ]
    1861                 :            :                 }
    1862         [ +  - ]:         90 :                 aMTF.Write( rOStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC );
    1863         [ -  + ]:         90 :                 if( rOStm.GetError() )
    1864         [ +  - ]:         90 :                     nStatus = GRFILTER_IOERROR;
    1865                 :            :             }
    1866 [ +  - ][ +  + ]:        208 :             else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_WMF ) )
    1867                 :            :             {
    1868         [ +  - ]:         87 :                 if( eType == GRAPHIC_GDIMETAFILE )
    1869                 :            :                 {
    1870 [ +  - ][ +  - ]:         87 :                     if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
                 [ -  + ]
    1871                 :          0 :                         nStatus = GRFILTER_FORMATERROR;
    1872                 :            :                 }
    1873                 :            :                 else
    1874                 :            :                 {
    1875         [ #  # ]:          0 :                     Bitmap          aBmp( aGraphic.GetBitmap() );
    1876         [ #  # ]:          0 :                     GDIMetaFile     aMTF;
    1877         [ #  # ]:          0 :                     VirtualDevice   aVirDev;
    1878                 :            : 
    1879         [ #  # ]:          0 :                     aMTF.Record( &aVirDev );
    1880         [ #  # ]:          0 :                     aVirDev.DrawBitmap( Point(), aBmp );
    1881         [ #  # ]:          0 :                     aMTF.Stop();
    1882         [ #  # ]:          0 :                     aMTF.SetPrefSize( aBmp.GetSizePixel() );
    1883                 :            : 
    1884 [ #  # ][ #  # ]:          0 :                     if( !ConvertGDIMetaFileToWMF( aMTF, rOStm, &aConfigItem ) )
    1885 [ #  # ][ #  # ]:          0 :                         nStatus = GRFILTER_FORMATERROR;
                 [ #  # ]
    1886                 :            :                 }
    1887         [ -  + ]:         87 :                 if( rOStm.GetError() )
    1888                 :          0 :                     nStatus = GRFILTER_IOERROR;
    1889                 :            :             }
    1890 [ +  - ][ +  + ]:        121 :             else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_EMF ) )
    1891                 :            :             {
    1892         [ +  - ]:          3 :                 if( eType == GRAPHIC_GDIMETAFILE )
    1893                 :            :                 {
    1894 [ +  - ][ +  - ]:          3 :                     if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
                 [ -  + ]
    1895                 :          0 :                         nStatus = GRFILTER_FORMATERROR;
    1896                 :            :                 }
    1897                 :            :                 else
    1898                 :            :                 {
    1899         [ #  # ]:          0 :                     Bitmap          aBmp( aGraphic.GetBitmap() );
    1900         [ #  # ]:          0 :                     GDIMetaFile     aMTF;
    1901         [ #  # ]:          0 :                     VirtualDevice   aVirDev;
    1902                 :            : 
    1903         [ #  # ]:          0 :                     aMTF.Record( &aVirDev );
    1904         [ #  # ]:          0 :                     aVirDev.DrawBitmap( Point(), aBmp );
    1905         [ #  # ]:          0 :                     aMTF.Stop();
    1906         [ #  # ]:          0 :                     aMTF.SetPrefSize( aBmp.GetSizePixel() );
    1907                 :            : 
    1908 [ #  # ][ #  # ]:          0 :                     if( !ConvertGDIMetaFileToEMF( aMTF, rOStm, &aConfigItem ) )
    1909 [ #  # ][ #  # ]:          0 :                         nStatus = GRFILTER_FORMATERROR;
                 [ #  # ]
    1910                 :            :                 }
    1911         [ -  + ]:          3 :                 if( rOStm.GetError() )
    1912                 :          0 :                     nStatus = GRFILTER_IOERROR;
    1913                 :            :             }
    1914 [ +  - ][ -  + ]:        118 :             else if( aFilterName.EqualsIgnoreCaseAscii( EXP_JPEG ) )
    1915                 :            :             {
    1916                 :          0 :                 bool bExportedGrayJPEG = false;
    1917 [ #  # ][ #  # ]:          0 :                 if( !ExportJPEG( rOStm, aGraphic, pFilterData, &bExportedGrayJPEG ) )
    1918                 :          0 :                     nStatus = GRFILTER_FORMATERROR;
    1919         [ #  # ]:          0 :                 nExpGraphHint = bExportedGrayJPEG ? GRFILTER_OUTHINT_GREY : 0;
    1920                 :            : 
    1921         [ #  # ]:          0 :                 if( rOStm.GetError() )
    1922                 :          0 :                     nStatus = GRFILTER_IOERROR;
    1923                 :            :             }
    1924 [ +  - ][ +  - ]:        118 :             else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_PNG ) )
    1925                 :            :             {
    1926 [ +  - ][ +  - ]:        118 :                 vcl::PNGWriter aPNGWriter( aGraphic.GetBitmapEx(), pFilterData );
                 [ +  - ]
    1927         [ -  + ]:        118 :                 if ( pFilterData )
    1928                 :            :                 {
    1929                 :          0 :                     sal_Int32 k, j, i = 0;
    1930         [ #  # ]:          0 :                     for ( i = 0; i < pFilterData->getLength(); i++ )
    1931                 :            :                     {
    1932         [ #  # ]:          0 :                         if ( (*pFilterData)[ i ].Name == "AdditionalChunks" )
    1933                 :            :                         {
    1934         [ #  # ]:          0 :                             com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aAdditionalChunkSequence;
    1935 [ #  # ][ #  # ]:          0 :                             if ( (*pFilterData)[ i ].Value >>= aAdditionalChunkSequence )
    1936                 :            :                             {
    1937         [ #  # ]:          0 :                                 for ( j = 0; j < aAdditionalChunkSequence.getLength(); j++ )
    1938                 :            :                                 {
    1939 [ #  # ][ #  # ]:          0 :                                     if ( aAdditionalChunkSequence[ j ].Name.getLength() == 4 )
    1940                 :            :                                     {
    1941                 :          0 :                                         sal_uInt32 nChunkType = 0;
    1942         [ #  # ]:          0 :                                         for ( k = 0; k < 4; k++ )
    1943                 :            :                                         {
    1944                 :          0 :                                             nChunkType <<= 8;
    1945         [ #  # ]:          0 :                                             nChunkType |= (sal_uInt8)aAdditionalChunkSequence[ j ].Name[ k ];
    1946                 :            :                                         }
    1947         [ #  # ]:          0 :                                         com::sun::star::uno::Sequence< sal_Int8 > aByteSeq;
    1948 [ #  # ][ #  # ]:          0 :                                         if ( aAdditionalChunkSequence[ j ].Value >>= aByteSeq )
                 [ #  # ]
    1949                 :            :                                         {
    1950         [ #  # ]:          0 :                                             std::vector< vcl::PNGWriter::ChunkData >& rChunkData = aPNGWriter.GetChunks();
    1951         [ #  # ]:          0 :                                             if ( !rChunkData.empty() )
    1952                 :            :                                             {
    1953                 :          0 :                                                 sal_uInt32 nChunkLen = aByteSeq.getLength();
    1954                 :            : 
    1955         [ #  # ]:          0 :                                                 vcl::PNGWriter::ChunkData aChunkData;
    1956                 :          0 :                                                 aChunkData.nType = nChunkType;
    1957         [ #  # ]:          0 :                                                 if ( nChunkLen )
    1958                 :            :                                                 {
    1959         [ #  # ]:          0 :                                                     aChunkData.aData.resize( nChunkLen );
    1960 [ #  # ][ #  # ]:          0 :                                                     rtl_copyMemory( &aChunkData.aData[ 0 ], aByteSeq.getConstArray(), nChunkLen );
    1961                 :            :                                                 }
    1962         [ #  # ]:          0 :                                                 std::vector< vcl::PNGWriter::ChunkData >::iterator aIter = rChunkData.end() - 1;
    1963         [ #  # ]:          0 :                                                 rChunkData.insert( aIter, aChunkData );
    1964                 :            :                                             }
    1965         [ #  # ]:          0 :                                         }
    1966                 :            :                                     }
    1967                 :            :                                 }
    1968         [ #  # ]:          0 :                             }
    1969                 :            :                         }
    1970                 :            :                     }
    1971                 :            :                 }
    1972         [ +  - ]:        118 :                 aPNGWriter.Write( rOStm );
    1973                 :            : 
    1974         [ -  + ]:        118 :                 if( rOStm.GetError() )
    1975         [ +  - ]:        118 :                     nStatus = GRFILTER_IOERROR;
    1976                 :            :             }
    1977 [ #  # ][ #  # ]:          0 :             else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVG ) )
    1978                 :            :             {
    1979                 :          0 :                 sal_Bool bDone = sal_False;
    1980                 :            : 
    1981                 :            :                 // do we have a native SVG RenderGraphic, whose data can be written directly?
    1982 [ #  # ][ #  # ]:          0 :                 if( ( GRAPHIC_GDIMETAFILE == eType ) && aGraphic.IsRenderGraphic() )
         [ #  # ][ #  # ]
    1983                 :            :                 {
    1984         [ #  # ]:          0 :                     const ::vcl::RenderGraphic aRenderGraphic( aGraphic.GetRenderGraphic() );
    1985                 :            : 
    1986   [ #  #  #  # ]:          0 :                     if( aRenderGraphic.GetGraphicDataLength() &&
                 [ #  # ]
    1987                 :          0 :                         aRenderGraphic.GetGraphicDataMimeType().equalsIgnoreAsciiCase(
    1988 [ #  # ][ #  # ]:          0 :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/svg+xml" ) ) ) )
                 [ #  # ]
    1989                 :            :                     {
    1990                 :          0 :                         rOStm.Write( aRenderGraphic.GetGraphicData().get(),
    1991         [ #  # ]:          0 :                                      aRenderGraphic.GetGraphicDataLength() );
    1992                 :            : 
    1993         [ #  # ]:          0 :                            if( rOStm.GetError() )
    1994                 :            :                         {
    1995                 :          0 :                             nStatus = GRFILTER_IOERROR;
    1996                 :            :                         }
    1997         [ #  # ]:          0 :                     }
    1998                 :            :                 }
    1999                 :            : 
    2000         [ #  # ]:          0 :                 if( !bDone )
    2001                 :            :                 {
    2002                 :            :                     // do the normal GDIMetaFile export instead
    2003                 :            :                     try
    2004                 :            :                     {
    2005         [ #  # ]:          0 :                         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
    2006                 :            : 
    2007         [ #  # ]:          0 :                         if( xMgr.is() )
    2008                 :            :                         {
    2009         [ #  # ]:          0 :                             ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > xSaxWriter( xMgr->createInstance(
    2010 [ #  # ][ #  # ]:          0 :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" )) ), ::com::sun::star::uno::UNO_QUERY );
                 [ #  # ]
    2011                 :            : 
    2012         [ #  # ]:          0 :                             ::com::sun::star::uno::Reference< ::com::sun::star::svg::XSVGWriter > xSVGWriter( xMgr->createInstance(
    2013 [ #  # ][ #  # ]:          0 :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svg.SVGWriter" )) ), ::com::sun::star::uno::UNO_QUERY );
                 [ #  # ]
    2014                 :            : 
    2015 [ #  # ][ #  # ]:          0 :                             if( xSaxWriter.is() && xSVGWriter.is() )
                 [ #  # ]
    2016                 :            :                             {
    2017                 :            :                                 ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > xActiveDataSource(
    2018         [ #  # ]:          0 :                                     xSaxWriter, ::com::sun::star::uno::UNO_QUERY );
    2019                 :            : 
    2020         [ #  # ]:          0 :                                 if( xActiveDataSource.is() )
    2021                 :            :                                 {
    2022                 :            :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xStmIf(
    2023 [ #  # ][ #  # ]:          0 :                                         static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( rOStm ) ) );
    2024                 :            : 
    2025         [ #  # ]:          0 :                                     SvMemoryStream aMemStm( 65535, 65535 );
    2026                 :            : 
    2027 [ #  # ][ #  # ]:          0 :                                     ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( aMemStm );
    2028                 :            : 
    2029         [ #  # ]:          0 :                                     xActiveDataSource->setOutputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >(
    2030 [ #  # ][ #  # ]:          0 :                                         xStmIf, ::com::sun::star::uno::UNO_QUERY ) );
    2031 [ #  # ][ #  # ]:          0 :                                     ::com::sun::star::uno::Sequence< sal_Int8 > aMtfSeq( (sal_Int8*) aMemStm.GetData(), aMemStm.Tell() );
    2032 [ #  # ][ #  # ]:          0 :                                     xSVGWriter->write( xSaxWriter, aMtfSeq );
         [ #  # ][ #  # ]
    2033                 :          0 :                                 }
    2034                 :          0 :                             }
    2035         [ #  # ]:          0 :                         }
    2036                 :            :                     }
    2037         [ #  # ]:          0 :                     catch(const ::com::sun::star::uno::Exception&)
    2038                 :            :                     {
    2039                 :          0 :                         nStatus = GRFILTER_IOERROR;
    2040                 :            :                     }
    2041                 :            :                 }
    2042                 :            :             }
    2043                 :            :             else
    2044                 :          0 :                 nStatus = GRFILTER_FILTERERROR;
    2045                 :            :         }
    2046                 :            :         else
    2047                 :            :         {
    2048         [ #  # ]:          0 :             sal_Int32 i, nTokenCount = getTokenCount(aFilterPath, ';');
    2049         [ #  # ]:          0 :             for ( i = 0; i < nTokenCount; i++ )
    2050                 :            :             {
    2051 [ #  # ][ #  # ]:          0 :                 String aPhysicalName( ImpCreateFullFilterPath( getToken(aFilterPath, i, ';'), aFilterName ) );
                 [ #  # ]
    2052 [ #  # ][ #  # ]:          0 :                 osl::Module aLibrary( aPhysicalName );
    2053                 :            : 
    2054         [ #  # ]:          0 :                 PFilterCall pFunc = (PFilterCall) aLibrary.getFunctionSymbol(rtl::OUString(EXPORT_FUNCTION_NAME));
    2055                 :            :                 // Dialog in DLL ausfuehren
    2056         [ #  # ]:          0 :                 if( pFunc )
    2057                 :            :                 {
    2058 [ #  # ][ #  # ]:          0 :                     if ( !(*pFunc)( rOStm, aGraphic, &aConfigItem, sal_False ) )
    2059                 :          0 :                         nStatus = GRFILTER_FORMATERROR;
    2060                 :            :                     break;
    2061                 :            :                 }
    2062                 :            :                 else
    2063         [ #  # ]:          0 :                     nStatus = GRFILTER_FILTERERROR;
    2064 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
    2065                 :            :         }
    2066                 :            :     }
    2067         [ -  + ]:        298 :     if( nStatus != GRFILTER_OK )
    2068                 :            :     {
    2069         [ #  # ]:          0 :         if( bAbort )
    2070                 :          0 :             nStatus = GRFILTER_ABORT;
    2071                 :            : 
    2072         [ #  # ]:          0 :         ImplSetError( nStatus, &rOStm );
    2073                 :            :     }
    2074 [ +  - ][ +  - ]:        298 :     return nStatus;
                 [ +  - ]
    2075                 :            : }
    2076                 :            : 
    2077                 :            : // ------------------------------------------------------------------------
    2078                 :            : 
    2079                 :          0 : sal_Bool GraphicFilter::Setup( sal_uInt16 )
    2080                 :            : {
    2081                 :          0 :     return sal_False;
    2082                 :            : }
    2083                 :            : 
    2084                 :            : // ------------------------------------------------------------------------
    2085                 :            : 
    2086                 :          0 : sal_Bool GraphicFilter::HasExportDialog( sal_uInt16 nFormat )
    2087                 :            : {
    2088                 :          0 :     return pConfig->IsExportDialog( nFormat );
    2089                 :            : }
    2090                 :            : 
    2091                 :            : // ------------------------------------------------------------------------
    2092                 :            : 
    2093                 :          0 : sal_Bool GraphicFilter::DoExportDialog( Window* pWindow, sal_uInt16 nFormat )
    2094                 :            : {
    2095                 :          0 :     return DoExportDialog( pWindow, nFormat, FUNIT_MM );
    2096                 :            : }
    2097                 :            : 
    2098                 :          0 : sal_Bool GraphicFilter::DoExportDialog( Window*, sal_uInt16 nFormat, FieldUnit )
    2099                 :            : {
    2100                 :          0 :     sal_Bool bRet = sal_False;
    2101                 :            :      com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
    2102         [ #  # ]:          0 :         xSMgr( ::comphelper::getProcessServiceFactory() );
    2103                 :            : 
    2104                 :            :     uno::Reference< com::sun::star::uno::XInterface > xFilterOptionsDialog
    2105         [ #  # ]:          0 :         ( xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svtools.SvFilterOptionsDialog" )) ),
    2106 [ #  # ][ #  # ]:          0 :             com::sun::star::uno::UNO_QUERY );
                 [ #  # ]
    2107         [ #  # ]:          0 :     if ( xFilterOptionsDialog.is() )
    2108                 :            :     {
    2109                 :            :         com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XExecutableDialog > xExecutableDialog
    2110         [ #  # ]:          0 :             ( xFilterOptionsDialog, ::com::sun::star::uno::UNO_QUERY );
    2111                 :            :         com::sun::star::uno::Reference< com::sun::star::beans::XPropertyAccess > xPropertyAccess
    2112         [ #  # ]:          0 :             ( xFilterOptionsDialog, ::com::sun::star::uno::UNO_QUERY );
    2113 [ #  # ][ #  # ]:          0 :         if ( xExecutableDialog.is() && xPropertyAccess.is() )
                 [ #  # ]
    2114                 :            :         {
    2115         [ #  # ]:          0 :             com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aMediaDescriptor( 1 );
    2116 [ #  # ][ #  # ]:          0 :             aMediaDescriptor[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
         [ #  # ][ #  # ]
    2117 [ #  # ][ #  # ]:          0 :             rtl::OUString aStr( pConfig->GetExportInternalFilterName( nFormat ) );
                 [ #  # ]
    2118 [ #  # ][ #  # ]:          0 :             aMediaDescriptor[ 0 ].Value <<= aStr;
    2119 [ #  # ][ #  # ]:          0 :             xPropertyAccess->setPropertyValues( aMediaDescriptor );
    2120 [ #  # ][ #  # ]:          0 :             bRet = xExecutableDialog->execute() == com::sun::star::ui::dialogs::ExecutableDialogResults::OK;
                 [ #  # ]
    2121                 :          0 :         }
    2122                 :            :     }
    2123                 :          0 :     return bRet;
    2124                 :            : }
    2125                 :            : 
    2126                 :            : // ------------------------------------------------------------------------
    2127                 :            : 
    2128                 :          0 : const FilterErrorEx& GraphicFilter::GetLastError() const
    2129                 :            : {
    2130                 :          0 :     return *pErrorEx;
    2131                 :            : }
    2132                 :            : 
    2133                 :            : // ------------------------------------------------------------------------
    2134                 :            : 
    2135                 :       9409 : void GraphicFilter::ResetLastError()
    2136                 :            : {
    2137                 :       9409 :     pErrorEx->nFilterError = pErrorEx->nStreamError = 0UL;
    2138                 :       9409 : }
    2139                 :            : 
    2140                 :            : // ------------------------------------------------------------------------
    2141                 :            : 
    2142                 :        228 : const Link GraphicFilter::GetFilterCallback() const
    2143                 :            : {
    2144                 :        228 :     const Link aLink( LINK( this, GraphicFilter, FilterCallback ) );
    2145                 :        228 :     return aLink;
    2146                 :            : }
    2147                 :            : 
    2148                 :            : // ------------------------------------------------------------------------
    2149                 :            : 
    2150                 :        228 : IMPL_LINK( GraphicFilter, FilterCallback, ConvertData*, pData )
    2151                 :            : {
    2152                 :        228 :     long nRet = 0L;
    2153                 :            : 
    2154         [ +  - ]:        228 :     if( pData )
    2155                 :            :     {
    2156                 :        228 :         sal_uInt16      nFormat = GRFILTER_FORMAT_DONTKNOW;
    2157                 :        228 :         rtl::OString aShortName;
    2158   [ -  -  -  -  :        228 :         switch( pData->mnFormat )
          -  +  -  -  +  
                +  -  + ]
    2159                 :            :         {
    2160                 :          0 :             case( CVT_BMP ): aShortName = BMP_SHORTNAME; break;
    2161                 :          0 :             case( CVT_GIF ): aShortName = GIF_SHORTNAME; break;
    2162                 :          0 :             case( CVT_JPG ): aShortName = JPG_SHORTNAME; break;
    2163                 :          0 :             case( CVT_MET ): aShortName = MET_SHORTNAME; break;
    2164                 :          0 :             case( CVT_PCT ): aShortName = PCT_SHORTNAME; break;
    2165                 :        124 :             case( CVT_PNG ): aShortName = PNG_SHORTNAME; break;
    2166                 :          0 :             case( CVT_SVM ): aShortName = SVM_SHORTNAME; break;
    2167                 :          0 :             case( CVT_TIF ): aShortName = TIF_SHORTNAME; break;
    2168                 :         87 :             case( CVT_WMF ): aShortName = WMF_SHORTNAME; break;
    2169                 :          3 :             case( CVT_EMF ): aShortName = EMF_SHORTNAME; break;
    2170                 :          0 :             case( CVT_SVG ): aShortName = SVG_SHORTNAME; break;
    2171                 :            : 
    2172                 :            :             default:
    2173                 :         14 :             break;
    2174                 :            :         }
    2175 [ +  - ][ +  + ]:        228 :         if( GRAPHIC_NONE == pData->maGraphic.GetType() || pData->maGraphic.GetContext() ) // Import
         [ +  - ][ -  + ]
                 [ +  + ]
    2176                 :            :         {
    2177                 :            :             // Import
    2178 [ +  - ][ +  - ]:         20 :             nFormat = GetImportFormatNumberForShortName( rtl::OStringToOUString( aShortName, RTL_TEXTENCODING_UTF8) );
         [ +  - ][ +  - ]
    2179 [ +  - ][ +  - ]:         20 :             nRet = ImportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == 0;
                 [ +  - ]
    2180                 :            :         }
    2181         [ +  - ]:        208 :         else if( !aShortName.isEmpty() )
    2182                 :            :         {
    2183                 :            :             // Export
    2184 [ +  - ][ +  - ]:        208 :             nFormat = GetExportFormatNumberForShortName( rtl::OStringToOUString(aShortName, RTL_TEXTENCODING_UTF8) );
         [ +  - ][ +  - ]
    2185 [ +  - ][ +  - ]:        208 :             nRet = ExportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == 0;
                 [ +  - ]
    2186                 :        228 :         }
    2187                 :            :     }
    2188                 :        228 :     return nRet;
    2189                 :            : }
    2190                 :            : 
    2191                 :            : namespace
    2192                 :            : {
    2193                 :         91 :     class StandardGraphicFilter
    2194                 :            :     {
    2195                 :            :     public:
    2196                 :         91 :         StandardGraphicFilter()
    2197                 :         91 :         {
    2198         [ +  - ]:         91 :             m_aFilter.GetImportFormatCount();
    2199                 :         91 :         }
    2200                 :            :         GraphicFilter m_aFilter;
    2201                 :            :     };
    2202                 :            : 
    2203                 :            :     class theGraphicFilter : public rtl::Static<StandardGraphicFilter, theGraphicFilter> {};
    2204                 :            : }
    2205                 :            : 
    2206                 :       9316 : GraphicFilter& GraphicFilter::GetGraphicFilter()
    2207                 :            : {
    2208                 :       9316 :     return theGraphicFilter::get().m_aFilter;
    2209                 :            : }
    2210                 :            : 
    2211                 :          0 : int GraphicFilter::LoadGraphic( const String &rPath, const String &rFilterName,
    2212                 :            :                  Graphic& rGraphic, GraphicFilter* pFilter,
    2213                 :            :                  sal_uInt16* pDeterminedFormat )
    2214                 :            : {
    2215         [ #  # ]:          0 :     if ( !pFilter )
    2216         [ #  # ]:          0 :         pFilter = &GetGraphicFilter();
    2217                 :            : 
    2218         [ #  # ]:          0 :     const sal_uInt16 nFilter = rFilterName.Len() && pFilter->GetImportFormatCount()
    2219                 :            :                     ? pFilter->GetImportFormatNumber( rFilterName )
    2220 [ #  # ][ #  # ]:          0 :                     : GRFILTER_FORMAT_DONTKNOW;
                 [ #  # ]
    2221                 :            : 
    2222                 :          0 :     SvStream* pStream = NULL;
    2223 [ #  # ][ #  # ]:          0 :     INetURLObject aURL( rPath );
    2224                 :            : 
    2225 [ #  # ][ #  # ]:          0 :     if ( aURL.HasError() || INET_PROT_NOT_VALID == aURL.GetProtocol() )
                 [ #  # ]
    2226                 :            :     {
    2227                 :          0 :         aURL.SetSmartProtocol( INET_PROT_FILE );
    2228 [ #  # ][ #  # ]:          0 :         aURL.SetSmartURL( rPath );
    2229                 :            :     }
    2230         [ #  # ]:          0 :     else if ( INET_PROT_FILE != aURL.GetProtocol() )
    2231                 :            :     {
    2232         [ #  # ]:          0 :         pStream = ::utl::UcbStreamHelper::CreateStream( rPath, STREAM_READ );
    2233                 :            :     }
    2234                 :            : 
    2235                 :          0 :     int nRes = GRFILTER_OK;
    2236         [ #  # ]:          0 :     if ( !pStream )
    2237         [ #  # ]:          0 :         nRes = pFilter->ImportGraphic( rGraphic, aURL, nFilter, pDeterminedFormat );
    2238                 :            :     else
    2239         [ #  # ]:          0 :         nRes = pFilter->ImportGraphic( rGraphic, rPath, *pStream, nFilter, pDeterminedFormat );
    2240                 :            : 
    2241                 :            : #ifdef DBG_UTIL
    2242                 :            :     if( nRes )
    2243                 :            :         DBG_WARNING2( "GrafikFehler [%d] - [%s]", nRes, rPath.GetBuffer() );
    2244                 :            : #endif
    2245                 :            : 
    2246         [ #  # ]:          0 :     return nRes;
    2247                 :            : }
    2248                 :            : 
    2249                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10