LCOV - code coverage report
Current view: top level - svtools/source/filter - FilterConfigCache.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 159 262 60.7 %
Date: 2012-08-25 Functions: 16 36 44.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 190 485 39.2 %

           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 "FilterConfigCache.hxx"
      30                 :            : #include <svtools/filter.hxx>
      31                 :            : #include <com/sun/star/uno/Any.h>
      32                 :            : #include <comphelper/processfactory.hxx>
      33                 :            : #include <com/sun/star/uno/Exception.hpp>
      34                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      36                 :            : 
      37                 :            : using namespace ::com::sun::star::lang          ;   // XMultiServiceFactory
      38                 :            : using namespace ::com::sun::star::container     ;   // XNameAccess
      39                 :            : using namespace ::com::sun::star::uno           ;   // Reference
      40                 :            : using namespace ::com::sun::star::beans         ;   // PropertyValue
      41                 :            : using ::rtl::OUString;
      42                 :            : 
      43                 :            : const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameList[] =
      44                 :            : {
      45                 :            :     IMP_BMP, IMP_GIF, IMP_PNG,IMP_JPEG, IMP_XBM, IMP_XPM,
      46                 :            :     EXP_BMP, EXP_JPEG, EXP_PNG, NULL
      47                 :            : };
      48                 :            : 
      49                 :            : const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] =
      50                 :            : {
      51                 :            :     IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVSGF, IMP_SVSGV, IMP_SVG,
      52                 :            :     EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, NULL
      53                 :            : };
      54                 :            : 
      55                 :            : const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] =
      56                 :            : {
      57                 :            :     "egi", "icd", "ipd", "ipx", "ipb", "epb", "epg",
      58                 :            :     "epp", "ira", "era", "itg", "iti", "eti", "exp", NULL
      59                 :            : };
      60                 :            : 
      61                 :            : sal_Bool FilterConfigCache::bInitialized = sal_False;
      62                 :            : sal_Int32 FilterConfigCache::nIndType = -1;
      63                 :            : sal_Int32 FilterConfigCache::nIndUIName = -1;
      64                 :            : sal_Int32 FilterConfigCache::nIndDocumentService = -1;
      65                 :            : sal_Int32 FilterConfigCache::nIndFilterService = -1;
      66                 :            : sal_Int32 FilterConfigCache::nIndFlags = -1;
      67                 :            : sal_Int32 FilterConfigCache::nIndUserData = -1;
      68                 :            : sal_Int32 FilterConfigCache::nIndFileFormatVersion = -1;
      69                 :            : sal_Int32 FilterConfigCache::nIndTemplateName = -1;
      70                 :            : 
      71                 :       8534 : sal_Bool FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry )
      72                 :            : {
      73                 :       8534 :     bIsPixelFormat = bIsInternalFilter = sal_False;
      74         [ +  - ]:       8534 :     sFilterName = String( rUserDataEntry );
      75                 :            :     const char** pPtr;
      76 [ +  + ][ +  + ]:      76982 :     for ( pPtr = InternalPixelFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
                 [ +  + ]
      77                 :            :     {
      78         [ +  + ]:      68448 :         if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
      79                 :            :         {
      80                 :       1791 :             bIsInternalFilter = sal_True;
      81                 :       1791 :             bIsPixelFormat = sal_True;
      82                 :            :         }
      83                 :            :     }
      84 [ +  + ][ +  + ]:      63427 :     for ( pPtr = InternalVectorFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
                 [ +  + ]
      85                 :            :     {
      86         [ +  + ]:      54893 :         if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
      87                 :       1990 :             bIsInternalFilter = sal_True;
      88                 :            :     }
      89         [ +  + ]:       8534 :     if ( !bIsInternalFilter )
      90                 :            :     {
      91 [ +  + ][ +  + ]:      47492 :         for ( pPtr = ExternalPixelFilterNameList; *pPtr && ( bIsPixelFormat == sal_False ); pPtr++ )
                 [ +  + ]
      92                 :            :         {
      93 [ +  - ][ +  + ]:      42739 :             if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
      94                 :       3360 :                 bIsPixelFormat = sal_True;
      95                 :            :         }
      96                 :       4753 :         rtl::OUString sTemp(SVLIBRARY("?"));
      97                 :       4753 :         sal_Int32 nIndex = sTemp.indexOf(static_cast<sal_Unicode>('?'));
      98 [ +  - ][ +  - ]:       4753 :         sFilterName = sTemp.replaceAt(nIndex, 1, sFilterName);
      99                 :            :     }
     100                 :       8534 :     return sFilterName.Len() != 0;
     101                 :            : }
     102                 :            : 
     103                 :       8178 : String FilterConfigCache::FilterConfigCacheEntry::GetShortName()
     104                 :            : {
     105                 :       8178 :     String aShortName;
     106         [ +  - ]:       8178 :     if ( lExtensionList.getLength() )
     107                 :            :     {
     108 [ +  - ][ +  - ]:       8178 :         aShortName = lExtensionList[ 0 ];
     109 [ +  - ][ -  + ]:       8178 :         if ( aShortName.SearchAscii( "*.", 0 ) == 0 )
     110         [ #  # ]:          0 :             aShortName.Erase( 0, 2 );
     111                 :            :     }
     112                 :       8178 :     return aShortName;
     113                 :            : }
     114                 :            : 
     115                 :            : /** helper to open the configuration root of the underlying
     116                 :            :     config package
     117                 :            : 
     118                 :            :     @param  sPackage
     119                 :            :             specify, which config package should be opened.
     120                 :            :             Must be one of "types" or "filters"
     121                 :            : 
     122                 :            :     @return A valid object if open was successfull. The access on opened
     123                 :            :             data will be readonly. It returns NULL in case open failed.
     124                 :            : 
     125                 :            :     @throws It let pass RuntimeExceptions only.
     126                 :            :  */
     127                 :        182 : Reference< XInterface > openConfig(const char* sPackage)
     128                 :            :     throw(RuntimeException)
     129                 :            : {
     130                 :            :     Reference< XMultiServiceFactory > xSMGR(
     131         [ +  - ]:        182 :         comphelper::getProcessServiceFactory() );
     132                 :        182 :     Reference< XInterface >           xCfg;
     133                 :            :     try
     134                 :            :     {
     135                 :            :         // get access to config API (not to file!)
     136         [ +  - ]:        182 :         Reference< XMultiServiceFactory > xConfigProvider( xSMGR->createInstance(
     137 [ +  - ][ +  - ]:        182 :             OUString( "com.sun.star.configuration.ConfigurationProvider" )), UNO_QUERY);
     138                 :            : 
     139         [ +  - ]:        182 :         if (xConfigProvider.is())
     140                 :            :         {
     141         [ +  - ]:        182 :             Sequence< Any > lParams(1);
     142                 :        182 :             PropertyValue   aParam    ;
     143                 :            : 
     144                 :            :             // define cfg path for open
     145                 :        182 :             aParam.Name = OUString( "nodepath" );
     146         [ +  + ]:        182 :             if (rtl_str_compareIgnoreAsciiCase(sPackage, "types") == 0)
     147         [ +  - ]:         91 :                 aParam.Value <<= OUString( "/org.openoffice.TypeDetection.Types/Types" );
     148         [ +  + ]:        182 :             if (rtl_str_compareIgnoreAsciiCase(sPackage, "filters") == 0)
     149         [ +  - ]:         91 :                 aParam.Value <<= OUString( "/org.openoffice.TypeDetection.GraphicFilter/Filters" );
     150 [ +  - ][ +  - ]:        182 :             lParams[0] = makeAny(aParam);
     151                 :            : 
     152                 :            :             // get access to file
     153         [ +  - ]:        182 :             xCfg = xConfigProvider->createInstanceWithArguments(
     154 [ +  - ][ +  - ]:        182 :                 OUString( "com.sun.star.configuration.ConfigurationAccess" ), lParams);
                 [ +  - ]
     155                 :        182 :         }
     156                 :            :     }
     157      [ #  #  # ]:          0 :     catch(const RuntimeException&)
     158                 :          0 :         { throw; }
     159         [ #  # ]:          0 :     catch(const Exception&)
     160                 :          0 :         { xCfg.clear(); }
     161                 :            : 
     162                 :        182 :     return xCfg;
     163                 :            : }
     164                 :            : 
     165                 :         91 : void FilterConfigCache::ImplInit()
     166                 :            : {
     167                 :         91 :     OUString STYPE                ( "Type"                );
     168                 :         91 :     OUString SUINAME              ( "UIName"              );
     169                 :         91 :     OUString SUICOMPONENT         ( "UIComponent"         );
     170                 :         91 :     OUString SFLAGS               ( "Flags"               );
     171                 :         91 :     OUString SMEDIATYPE           ( "MediaType"           );
     172                 :         91 :     OUString SEXTENSIONS          ( "Extensions"          );
     173                 :         91 :     OUString SFORMATNAME          ( "FormatName"          );
     174                 :         91 :     OUString SREALFILTERNAME      ( "RealFilterName"      );
     175                 :            : 
     176                 :            :     // get access to config
     177 [ +  - ][ +  - ]:         91 :     Reference< XNameAccess > xTypeAccess  ( openConfig("types"  ), UNO_QUERY );
     178 [ +  - ][ +  - ]:         91 :     Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY );
     179                 :            : 
     180 [ +  - ][ +  - ]:         91 :     if ( xTypeAccess.is() && xFilterAccess.is() )
                 [ +  - ]
     181                 :            :     {
     182 [ +  - ][ +  - ]:         91 :         Sequence< OUString > lAllFilter = xFilterAccess->getElementNames();
     183                 :         91 :         sal_Int32 nAllFilterCount = lAllFilter.getLength();
     184                 :            : 
     185         [ +  + ]:       3963 :         for ( sal_Int32 i = 0; i < nAllFilterCount; i++ )
     186                 :            :         {
     187         [ +  - ]:       3872 :             OUString sInternalFilterName = lAllFilter[ i ];
     188                 :       3872 :             Reference< XPropertySet > xFilterSet;
     189 [ +  - ][ +  - ]:       3872 :             xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
                 [ +  - ]
     190         [ -  + ]:       3872 :             if (!xFilterSet.is())
     191                 :          0 :                 continue;
     192                 :            : 
     193         [ +  - ]:       3872 :             FilterConfigCacheEntry aEntry;
     194                 :            : 
     195                 :       3872 :             aEntry.sInternalFilterName = sInternalFilterName;
     196 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType;
     197 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName;
     198 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType;
     199         [ +  - ]:       3872 :             Sequence< OUString > lFlags;
     200 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
                 [ +  - ]
     201 [ +  - ][ -  + ]:       3872 :             if (lFlags.getLength()!=1 || lFlags[0].isEmpty())
         [ -  + ][ +  - ]
     202                 :          0 :                 continue;
     203 [ +  - ][ +  + ]:       3872 :             if (lFlags[0].equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("import")))
     204                 :       2376 :                 aEntry.nFlags = 1;
     205                 :            :             else
     206 [ +  - ][ +  - ]:       1496 :             if (lFlags[0].equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("export")))
     207                 :       1496 :                 aEntry.nFlags = 2;
     208                 :            : 
     209                 :       3872 :             OUString sUIComponent;
     210 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(SUICOMPONENT) >>= sUIComponent;
     211                 :       3872 :             aEntry.bHasDialog = sUIComponent.getLength();
     212                 :            : 
     213                 :       3872 :             ::rtl::OUString sFormatName;
     214 [ +  - ][ +  - ]:       3872 :             xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
     215         [ +  - ]:       3872 :             aEntry.CreateFilterName( sFormatName );
     216                 :            : 
     217                 :       3872 :             Reference< XPropertySet > xTypeSet;
     218 [ +  - ][ +  - ]:       3872 :             xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet;
                 [ +  - ]
     219         [ -  + ]:       3872 :             if (!xTypeSet.is())
     220                 :          0 :                 continue;
     221                 :            : 
     222 [ +  - ][ +  - ]:       3872 :             xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType;
     223 [ +  - ][ +  - ]:       3872 :             xTypeSet->getPropertyValue(SEXTENSIONS) >>= aEntry.lExtensionList;
                 [ +  - ]
     224                 :            : 
     225                 :            :             // The first extension will be used
     226                 :            :             // to generate our internal FilterType ( BMP, WMF ... )
     227         [ +  - ]:       3872 :             String aExtension( aEntry.GetShortName() );
     228         [ -  + ]:       3872 :             if (aExtension.Len() != 3)
     229                 :          0 :                 continue;
     230                 :            : 
     231         [ +  + ]:       3872 :             if ( aEntry.nFlags & 1 )
     232         [ +  - ]:       2376 :                 aImport.push_back( aEntry );
     233         [ +  + ]:       3872 :             if ( aEntry.nFlags & 2 )
     234         [ +  - ]:       1496 :                 aExport.push_back( aEntry );
     235                 :            : 
     236                 :            :             // bFilterEntryCreated!?
     237         [ -  + ]:       3872 :             if (!( aEntry.nFlags & 3 ))
     238                 :       3872 :                 continue; //? Entry was already inserted ... but following code will be supressed?!
     239 [ +  - ][ -  + ]:       3963 :         }
         [ -  + ][ -  + ]
         [ -  + ][ +  - ]
         [ -  + ][ +  - ]
         [ -  + ][ -  + ]
         [ +  - ][ +  - ]
     240                 :         91 :     }
     241                 :         91 : };
     242                 :            : 
     243                 :            : const char* FilterConfigCache::InternalFilterListForSvxLight[] =
     244                 :            : {
     245                 :            :     "bmp","1","SVBMP",
     246                 :            :     "bmp","2","SVBMP",
     247                 :            :     "dxf","1","idx",
     248                 :            :     "eps","1","ips",
     249                 :            :     "eps","2","eps",
     250                 :            :     "gif","1","SVIGIF",
     251                 :            :     "gif","2","egi",
     252                 :            :     "jpg","1","SVIJPEG",
     253                 :            :     "jpg","2","SVEJPEG",
     254                 :            :     "sgv","1","SVSGV",
     255                 :            :     "sgf","1","SVSGF",
     256                 :            :     "met","1","ime",
     257                 :            :     "met","2","eme",
     258                 :            :     "png","1","SVIPNG",
     259                 :            :     "png","2","SVEPNG",
     260                 :            :     "pct","1","ipt",
     261                 :            :     "pct","2","ept",
     262                 :            :     "pcd","1","icd",
     263                 :            :     "psd","1","ipd",
     264                 :            :     "pcx","1","ipx",
     265                 :            :     "pbm","1","ipb",
     266                 :            :     "pbm","2","epb",
     267                 :            :     "pgm","1","ipb",
     268                 :            :     "pgm","2","epg",
     269                 :            :     "ppm","1","ipb",
     270                 :            :     "ppm","2","epp",
     271                 :            :     "ras","1","ira",
     272                 :            :     "ras","2","era",
     273                 :            :     "svm","1","SVMETAFILE",
     274                 :            :     "svm","2","SVMETAFILE",
     275                 :            :     "tga","1","itg",
     276                 :            :     "tif","1","iti",
     277                 :            :     "tif","2","eti",
     278                 :            :     "emf","1","SVEMF",
     279                 :            :     "emf","2","SVEMF",
     280                 :            :     "wmf","1","SVWMF",
     281                 :            :     "wmf","2","SVWMF",
     282                 :            :     "xbm","1","SVIXBM",
     283                 :            :     "xpm","1","SVIXPM",
     284                 :            :     "xpm","2","exp",
     285                 :            :     "svg","1","SVISVG",
     286                 :            :     "svg","2","SVESVG",
     287                 :            :     NULL
     288                 :            : };
     289                 :            : 
     290                 :        111 : void FilterConfigCache::ImplInitSmart()
     291                 :            : {
     292                 :            :     const char** pPtr;
     293         [ +  + ]:       4773 :     for ( pPtr = InternalFilterListForSvxLight; *pPtr; pPtr++ )
     294                 :            :     {
     295         [ +  - ]:       4662 :         FilterConfigCacheEntry  aEntry;
     296                 :            : 
     297                 :       4662 :         OUString    sExtension( OUString::createFromAscii( *pPtr++ ) );
     298                 :            : 
     299         [ +  - ]:       4662 :         aEntry.lExtensionList.realloc( 1 );
     300         [ +  - ]:       4662 :         aEntry.lExtensionList[ 0 ] = sExtension;
     301                 :            : 
     302                 :       4662 :         aEntry.sType = sExtension;
     303                 :       4662 :         aEntry.sUIName = sExtension;
     304                 :            : 
     305                 :       4662 :         rtl::OString sFlags( *pPtr++ );
     306                 :       4662 :         aEntry.nFlags = sFlags.toInt32();
     307                 :            : 
     308                 :       4662 :         OUString    sUserData( OUString::createFromAscii( *pPtr ) );
     309         [ +  - ]:       4662 :         aEntry.CreateFilterName( sUserData );
     310                 :            : 
     311         [ +  + ]:       4662 :         if ( aEntry.nFlags & 1 )
     312         [ +  - ]:       2775 :             aImport.push_back( aEntry );
     313         [ +  + ]:       4662 :         if ( aEntry.nFlags & 2 )
     314         [ +  - ]:       1887 :             aExport.push_back( aEntry );
     315         [ +  - ]:       4662 :     }
     316                 :        111 : }
     317                 :            : 
     318                 :            : // ------------------------------------------------------------------------
     319                 :            : 
     320                 :        202 : FilterConfigCache::FilterConfigCache( sal_Bool bConfig ) :
     321         [ +  - ]:        202 :     bUseConfig ( bConfig )
     322                 :            : {
     323         [ +  + ]:        202 :     if ( bUseConfig )
     324         [ +  - ]:         91 :         ImplInit();
     325                 :            :     else
     326         [ +  - ]:        111 :         ImplInitSmart();
     327                 :        202 : }
     328                 :            : 
     329                 :        202 : FilterConfigCache::~FilterConfigCache()
     330                 :            : {
     331                 :        202 : }
     332                 :            : 
     333                 :       9069 : String FilterConfigCache::GetImportFilterName( sal_uInt16 nFormat )
     334                 :            : {
     335         [ +  - ]:       9069 :     if( nFormat < aImport.size() )
     336                 :       9069 :         return aImport[ nFormat ].sFilterName;
     337                 :       9069 :     return String::EmptyString();
     338                 :            : }
     339                 :            : 
     340                 :          4 : sal_uInt16 FilterConfigCache::GetImportFormatNumber( const String& rFormatName )
     341                 :            : {
     342                 :          4 :     CacheVector::iterator aIter( aImport.begin() );
     343 [ +  - ][ +  + ]:        112 :     while ( aIter != aImport.end() )
     344                 :            :     {
     345 [ +  - ][ -  + ]:        108 :         if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
     346                 :          0 :             break;
     347         [ +  - ]:        108 :         aIter++;
     348                 :            :     }
     349 [ +  - ][ +  - ]:          4 :     return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
         [ #  # ][ -  + ]
                 [ #  # ]
     350                 :            : }
     351                 :            : 
     352                 :          0 : sal_uInt16 FilterConfigCache::GetImportFormatNumberForMediaType( const String& rMediaType )
     353                 :            : {
     354                 :          0 :     CacheVector::iterator aIter( aImport.begin() );
     355 [ #  # ][ #  # ]:          0 :     while ( aIter != aImport.end() )
     356                 :            :     {
     357 [ #  # ][ #  # ]:          0 :         if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
     358                 :          0 :             break;
     359         [ #  # ]:          0 :         aIter++;
     360                 :            :     }
     361 [ #  # ][ #  # ]:          0 :     return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
         [ #  # ][ #  # ]
                 [ #  # ]
     362                 :            : }
     363                 :            : 
     364                 :         20 : sal_uInt16 FilterConfigCache::GetImportFormatNumberForShortName( const String& rShortName )
     365                 :            : {
     366                 :         20 :     CacheVector::iterator aIter( aImport.begin() );
     367 [ +  - ][ +  + ]:        482 :     while ( aIter != aImport.end() )
     368                 :            :     {
     369 [ +  - ][ +  - ]:        468 :         if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
         [ +  - ][ +  + ]
     370                 :          6 :             break;
     371         [ +  - ]:        462 :         aIter++;
     372                 :            :     }
     373 [ +  - ][ +  + ]:         20 :     return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
         [ +  - ][ +  + ]
                 [ #  # ]
     374                 :            : }
     375                 :            : 
     376                 :          0 : sal_uInt16 FilterConfigCache::GetImportFormatNumberForTypeName( const String& rType )
     377                 :            : {
     378                 :          0 :     CacheVector::iterator aIter( aImport.begin() );
     379 [ #  # ][ #  # ]:          0 :     while ( aIter != aImport.end() )
     380                 :            :     {
     381 [ #  # ][ #  # ]:          0 :         if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
     382                 :          0 :             break;
     383         [ #  # ]:          0 :         aIter++;
     384                 :            :     }
     385 [ #  # ][ #  # ]:          0 :     return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
         [ #  # ][ #  # ]
                 [ #  # ]
     386                 :            : }
     387                 :            : 
     388                 :          0 : String FilterConfigCache::GetImportFormatName( sal_uInt16 nFormat )
     389                 :            : {
     390         [ #  # ]:          0 :     if( nFormat < aImport.size() )
     391                 :          0 :         return aImport[ nFormat ].sUIName;
     392                 :          0 :     return String::EmptyString();
     393                 :            : }
     394                 :            : 
     395                 :          0 : String FilterConfigCache::GetImportFormatMediaType( sal_uInt16 nFormat )
     396                 :            : {
     397         [ #  # ]:          0 :     if( nFormat < aImport.size() )
     398                 :          0 :         return aImport[ nFormat ].sMediaType;
     399                 :          0 :     return String::EmptyString();
     400                 :            : }
     401                 :            : 
     402                 :          0 : String FilterConfigCache::GetImportFormatShortName( sal_uInt16 nFormat )
     403                 :            : {
     404         [ #  # ]:          0 :     if( nFormat < aImport.size() )
     405                 :          0 :         return aImport[ nFormat ].GetShortName();
     406                 :          0 :     return String::EmptyString();
     407                 :            : }
     408                 :            : 
     409                 :     183687 : String FilterConfigCache::GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
     410                 :            : {
     411 [ +  - ][ +  - ]:     183687 :     if ( (nFormat < aImport.size()) && (nEntry < aImport[ nFormat ].lExtensionList.getLength()) )
                 [ +  - ]
     412                 :     183687 :         return aImport[ nFormat ].lExtensionList[ nEntry ];
     413                 :     183687 :     return String::EmptyString();
     414                 :            : }
     415                 :            : 
     416                 :          0 : String FilterConfigCache::GetImportFilterType( sal_uInt16 nFormat )
     417                 :            : {
     418         [ #  # ]:          0 :     if( nFormat < aImport.size() )
     419                 :          0 :         return aImport[ nFormat ].sType;
     420                 :          0 :     return String::EmptyString();
     421                 :            : }
     422                 :            : 
     423                 :          0 : String FilterConfigCache::GetImportFilterTypeName( sal_uInt16 nFormat )
     424                 :            : {
     425         [ #  # ]:          0 :     if( nFormat < aImport.size() )
     426                 :          0 :         return aImport[ nFormat ].sFilterType;
     427                 :          0 :     return String::EmptyString();
     428                 :            : }
     429                 :            : 
     430                 :          0 : String FilterConfigCache::GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
     431                 :            : {
     432                 :          0 :     String aWildcard( GetImportFormatExtension( nFormat, nEntry ) );
     433         [ #  # ]:          0 :     if ( aWildcard.Len() )
     434 [ #  # ][ #  # ]:          0 :         aWildcard.Insert( rtl::OUString("*."), 0 );
                 [ #  # ]
     435                 :          0 :     return aWildcard;
     436                 :            : }
     437                 :            : 
     438                 :       9069 : sal_Bool FilterConfigCache::IsImportInternalFilter( sal_uInt16 nFormat )
     439                 :            : {
     440 [ +  - ][ +  - ]:       9069 :     return (nFormat < aImport.size()) && aImport[ nFormat ].bIsInternalFilter;
     441                 :            : }
     442                 :            : 
     443                 :          0 : sal_Bool FilterConfigCache::IsImportPixelFormat( sal_uInt16 nFormat )
     444                 :            : {
     445 [ #  # ][ #  # ]:          0 :     return (nFormat < aImport.size()) && aImport[ nFormat ].bIsPixelFormat;
     446                 :            : }
     447                 :            : 
     448                 :            : // ------------------------------------------------------------------------
     449                 :            : 
     450                 :        298 : String FilterConfigCache::GetExportFilterName( sal_uInt16 nFormat )
     451                 :            : {
     452         [ +  - ]:        298 :     if( nFormat < aExport.size() )
     453                 :        298 :         return aExport[ nFormat ].sFilterName;
     454                 :        298 :     return String::EmptyString();
     455                 :            : }
     456                 :            : 
     457                 :          0 : sal_uInt16 FilterConfigCache::GetExportFormatNumber( const String& rFormatName )
     458                 :            : {
     459                 :          0 :     CacheVector::iterator aIter( aExport.begin() );
     460 [ #  # ][ #  # ]:          0 :     while ( aIter != aExport.end() )
     461                 :            :     {
     462 [ #  # ][ #  # ]:          0 :         if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
     463                 :          0 :             break;
     464         [ #  # ]:          0 :         aIter++;
     465                 :            :     }
     466 [ #  # ][ #  # ]:          0 :     return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
         [ #  # ][ #  # ]
                 [ #  # ]
     467                 :            : }
     468                 :            : 
     469                 :          0 : sal_uInt16 FilterConfigCache::GetExportFormatNumberForMediaType( const String& rMediaType )
     470                 :            : {
     471                 :          0 :     CacheVector::iterator aIter( aExport.begin() );
     472 [ #  # ][ #  # ]:          0 :     while ( aIter != aExport.end() )
     473                 :            :     {
     474 [ #  # ][ #  # ]:          0 :         if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
     475                 :          0 :             break;
     476         [ #  # ]:          0 :         aIter++;
     477                 :            :     }
     478 [ #  # ][ #  # ]:          0 :     return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
         [ #  # ][ #  # ]
                 [ #  # ]
     479                 :            : }
     480                 :            : 
     481                 :        298 : sal_uInt16 FilterConfigCache::GetExportFormatNumberForShortName( const String& rShortName )
     482                 :            : {
     483                 :        298 :     CacheVector::iterator aIter( aExport.begin() );
     484 [ +  - ][ +  - ]:       3838 :     while ( aIter != aExport.end() )
     485                 :            :     {
     486 [ +  - ][ +  - ]:       3838 :         if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
         [ +  - ][ +  + ]
     487                 :        298 :             break;
     488         [ +  - ]:       3540 :         aIter++;
     489                 :            :     }
     490 [ +  - ][ -  + ]:        298 :     return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
         [ +  - ][ +  - ]
                 [ #  # ]
     491                 :            : }
     492                 :            : 
     493                 :          0 : sal_uInt16 FilterConfigCache::GetExportFormatNumberForTypeName( const String& rType )
     494                 :            : {
     495                 :          0 :     CacheVector::iterator aIter( aExport.begin() );
     496 [ #  # ][ #  # ]:          0 :     while ( aIter != aExport.end() )
     497                 :            :     {
     498 [ #  # ][ #  # ]:          0 :         if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
     499                 :          0 :             break;
     500         [ #  # ]:          0 :         aIter++;
     501                 :            :     }
     502 [ #  # ][ #  # ]:          0 :     return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
         [ #  # ][ #  # ]
                 [ #  # ]
     503                 :            : }
     504                 :            : 
     505                 :          0 : String FilterConfigCache::GetExportFormatName( sal_uInt16 nFormat )
     506                 :            : {
     507         [ #  # ]:          0 :     if( nFormat < aExport.size() )
     508                 :          0 :         return aExport[ nFormat ].sUIName;
     509                 :          0 :     return String::EmptyString();
     510                 :            : }
     511                 :            : 
     512                 :          0 : String FilterConfigCache::GetExportFormatMediaType( sal_uInt16 nFormat )
     513                 :            : {
     514         [ #  # ]:          0 :     if( nFormat < aExport.size() )
     515                 :          0 :         return aExport[ nFormat ].sMediaType;
     516                 :          0 :     return String::EmptyString();
     517                 :            : }
     518                 :            : 
     519                 :          0 : String FilterConfigCache::GetExportFormatShortName( sal_uInt16 nFormat )
     520                 :            : {
     521         [ #  # ]:          0 :     if( nFormat < aExport.size() )
     522                 :          0 :         return aExport[ nFormat ].GetShortName();
     523                 :          0 :     return String::EmptyString();
     524                 :            : }
     525                 :            : 
     526                 :          0 : String FilterConfigCache::GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
     527                 :            : {
     528 [ #  # ][ #  # ]:          0 :     if ( (nFormat < aExport.size()) && (nEntry < aExport[ nFormat ].lExtensionList.getLength()) )
                 [ #  # ]
     529                 :          0 :         return aExport[ nFormat ].lExtensionList[ nEntry ];
     530                 :          0 :     return String::EmptyString();
     531                 :            : }
     532                 :            : 
     533                 :          0 : String FilterConfigCache::GetExportFilterTypeName( sal_uInt16 nFormat )
     534                 :            : {
     535         [ #  # ]:          0 :     if( nFormat < aExport.size() )
     536                 :          0 :         return aExport[ nFormat ].sFilterType;
     537                 :          0 :     return String::EmptyString();
     538                 :            : }
     539                 :            : 
     540                 :          0 : String FilterConfigCache::GetExportInternalFilterName( sal_uInt16 nFormat )
     541                 :            : {
     542         [ #  # ]:          0 :     if( nFormat < aExport.size() )
     543                 :          0 :         return aExport[ nFormat ].sInternalFilterName;
     544                 :          0 :     return String::EmptyString();
     545                 :            : }
     546                 :            : 
     547                 :          0 : String FilterConfigCache::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
     548                 :            : {
     549                 :          0 :     String aWildcard( GetExportFormatExtension( nFormat, nEntry ) );
     550         [ #  # ]:          0 :     if ( aWildcard.Len() )
     551 [ #  # ][ #  # ]:          0 :         aWildcard.Insert( rtl::OUString("*."), 0 );
                 [ #  # ]
     552                 :          0 :     return aWildcard;
     553                 :            : }
     554                 :            : 
     555                 :        298 : sal_Bool FilterConfigCache::IsExportInternalFilter( sal_uInt16 nFormat )
     556                 :            : {
     557 [ +  - ][ +  - ]:        298 :     return (nFormat < aExport.size()) && aExport[ nFormat ].bIsInternalFilter;
     558                 :            : }
     559                 :            : 
     560                 :        388 : sal_Bool FilterConfigCache::IsExportPixelFormat( sal_uInt16 nFormat )
     561                 :            : {
     562 [ +  - ][ +  + ]:        388 :     return (nFormat < aExport.size()) && aExport[ nFormat ].bIsPixelFormat;
     563                 :            : }
     564                 :            : 
     565                 :          0 : sal_Bool FilterConfigCache::IsExportDialog( sal_uInt16 nFormat )
     566                 :            : {
     567 [ #  # ][ #  # ]:          0 :     return (nFormat < aExport.size()) && aExport[ nFormat ].bHasDialog;
     568                 :            : }
     569                 :            : 
     570                 :            : // ------------------------------------------------------------------------
     571                 :            : 
     572                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10