LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/filter - FilterConfigCache.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 139 259 53.7 %
Date: 2012-12-27 Functions: 14 36 38.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10