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