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     throw(RuntimeException)
139 {
140     static OUString TYPEPKG( RTL_CONSTASCII_USTRINGPARAM( "types" ) );
141     static OUString FILTERPKG( RTL_CONSTASCII_USTRINGPARAM( "filters" ) );
142 
143     Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory();
144     Reference< XInterface >           xCfg;
145     try
146     {
147         // get access to config API (not to file!)
148         Reference< XMultiServiceFactory > xConfigProvider( xSMGR->createInstance(
149             OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
150 
151         if (xConfigProvider.is())
152         {
153             Sequence< Any > lParams(1);
154             PropertyValue   aParam    ;
155 
156             // define cfg path for open
157             aParam.Name = OUString::createFromAscii("nodepath");
158             if (TYPEPKG.equalsIgnoreAsciiCaseAscii(sPackage))
159                 aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.Types/Types");
160             if (FILTERPKG.equalsIgnoreAsciiCaseAscii(sPackage))
161                 aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.GraphicFilter/Filters");
162             lParams[0] = makeAny(aParam);
163 
164             // get access to file
165             xCfg = xConfigProvider->createInstanceWithArguments(
166                 OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), lParams);
167         }
168     }
169     catch(const RuntimeException&)
170         { throw; }
171     catch(const Exception&)
172         { xCfg.clear(); }
173 
174     return xCfg;
175 }
176 
ImplInit()177 void FilterConfigCache::ImplInit()
178 {
179     static OUString STYPE                ( RTL_CONSTASCII_USTRINGPARAM( "Type"               ) );
180     static OUString SUINAME              ( RTL_CONSTASCII_USTRINGPARAM( "UIName"             ) );
181     static OUString SDOCUMENTSERVICE     ( RTL_CONSTASCII_USTRINGPARAM( "DocumentService"    ) );
182     static OUString SFILTERSERVICE       ( RTL_CONSTASCII_USTRINGPARAM( "FilterService"      ) );
183     static OUString STEMPLATENAME        ( RTL_CONSTASCII_USTRINGPARAM( "TemplateName"       ) );
184     static OUString SFILEFORMATVERSION   ( RTL_CONSTASCII_USTRINGPARAM( "FileFormatVersion"  ) );
185     static OUString SUICOMPONENT         ( RTL_CONSTASCII_USTRINGPARAM( "UIComponent"        ) );
186     static OUString SFLAGS               ( RTL_CONSTASCII_USTRINGPARAM( "Flags"              ) );
187     static OUString SUSERDATA            ( RTL_CONSTASCII_USTRINGPARAM( "UserData"           ) );
188     static OUString SMEDIATYPE           ( RTL_CONSTASCII_USTRINGPARAM( "MediaType"          ) );
189     static OUString SEXTENSIONS          ( RTL_CONSTASCII_USTRINGPARAM( "Extensions"         ) );
190     static OUString SFORMATNAME          ( RTL_CONSTASCII_USTRINGPARAM( "FormatName"         ) );
191     static OUString SREALFILTERNAME      ( RTL_CONSTASCII_USTRINGPARAM( "RealFilterName"     ) );
192 
193     // get access to config
194     Reference< XNameAccess > xTypeAccess  ( openConfig("types"  ), UNO_QUERY );
195     Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY );
196 
197 	if ( xTypeAccess.is() && xFilterAccess.is() )
198 	{
199 		Sequence< OUString > lAllFilter = xFilterAccess->getElementNames();
200 		sal_Int32 nAllFilterCount = lAllFilter.getLength();
201 
202 		for ( sal_Int32 i = 0; i < nAllFilterCount; i++ )
203 		{
204 			OUString sInternalFilterName = lAllFilter[ i ];
205 			Reference< XPropertySet > xFilterSet;
206 			xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
207 			if (!xFilterSet.is())
208 				continue;
209 
210 			FilterConfigCacheEntry aEntry;
211 
212 			aEntry.sInternalFilterName = sInternalFilterName;
213 			xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType;
214 			xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName;
215 			xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType;
216 			Sequence< OUString > lFlags;
217 			xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
218 			if (lFlags.getLength()!=1 || !lFlags[0].getLength())
219 				continue;
220 			if (lFlags[0].equalsIgnoreAsciiCaseAscii("import"))
221 				aEntry.nFlags = 1;
222 			else
223 			if (lFlags[0].equalsIgnoreAsciiCaseAscii("export"))
224 				aEntry.nFlags = 2;
225 
226 			OUString sUIComponent;
227 			xFilterSet->getPropertyValue(SUICOMPONENT) >>= sUIComponent;
228 			aEntry.bHasDialog = sUIComponent.getLength();
229 
230 			::rtl::OUString sFormatName;
231 			xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
232 			aEntry.CreateFilterName( sFormatName );
233 
234 			Reference< XPropertySet > xTypeSet;
235 			xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet;
236 			if (!xTypeSet.is())
237 				continue;
238 
239 			xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType;
240 			xTypeSet->getPropertyValue(SEXTENSIONS) >>= aEntry.lExtensionList;
241 
242 			// The first extension will be used
243 			// to generate our internal FilterType ( BMP, WMF ... )
244 			String aExtension( aEntry.GetShortName() );
245 			if (aExtension.Len() != 3)
246 				continue;
247 
248 			if ( aEntry.nFlags & 1 )
249 				aImport.push_back( aEntry );
250 			if ( aEntry.nFlags & 2 )
251 				aExport.push_back( aEntry );
252 
253 			// bFilterEntryCreated!?
254 			if (!( aEntry.nFlags & 3 ))
255 				continue; //? Entry was already inserted ... but following code will be supressed?!
256 		}
257 	}
258 };
259 
260 const char* FilterConfigCache::InternalFilterListForSvxLight[] =
261 {
262 	"bmp","1","SVBMP",
263 	"bmp","2","SVBMP",
264 	"dxf","1","idx",
265 	"eps","1","ips",
266 	"eps","2","eps",
267 	"gif","1","SVIGIF",
268 	"gif","2","egi",
269 	"jpg","1","SVIJPEG",
270 	"jpg","2","SVEJPEG",
271 	"sgv","1","SVSGV",
272 	"sgf","1","SVSGF",
273 	"met","1","ime",
274 	"met","2","eme",
275 	"png","1","SVIPNG",
276 	"png","2","SVEPNG",
277 	"pct","1","ipt",
278 	"pct","2","ept",
279 	"pcd","1","icd",
280 	"psd","1","ipd",
281 	"pcx","1","ipx",
282 	"pbm","1","ipb",
283 	"pbm","2","epb",
284 	"pgm","1","ipb",
285 	"pgm","2","epg",
286 	"ppm","1","ipb",
287 	"ppm","2","epp",
288 	"ras","1","ira",
289 	"ras","2","era",
290 	"svm","1","SVMETAFILE",
291 	"svm","2","SVMETAFILE",
292 	"tga","1","itg",
293 	"tif","1","iti",
294 	"tif","2","eti",
295 	"emf","1","SVEMF",
296 	"emf","2","SVEMF",
297 	"wmf","1","SVWMF",
298 	"wmf","2","SVWMF",
299 	"xbm","1","SVIXBM",
300 	"xpm","1","SVIXPM",
301 	"xpm","2","exp",
302 	"svg","1","SVISVG",
303 	"svg","2","SVESVG",
304 	NULL
305 };
306 
ImplInitSmart()307 void FilterConfigCache::ImplInitSmart()
308 {
309 	const char** pPtr;
310 	for ( pPtr = InternalFilterListForSvxLight; *pPtr; pPtr++ )
311 	{
312 		FilterConfigCacheEntry	aEntry;
313 
314 		OUString	sExtension( OUString::createFromAscii( *pPtr++ ) );
315 
316 		aEntry.lExtensionList.realloc( 1 );
317         aEntry.lExtensionList[ 0 ] = sExtension;
318 
319 		aEntry.sType = sExtension;
320 		aEntry.sUIName = sExtension;
321 
322 		ByteString sFlags( *pPtr++ );
323 		aEntry.nFlags = sFlags.ToInt32();
324 
325 		OUString	sUserData( OUString::createFromAscii( *pPtr ) );
326 		aEntry.CreateFilterName( sUserData );
327 
328 		if ( aEntry.nFlags & 1 )
329 			aImport.push_back( aEntry );
330 		if ( aEntry.nFlags & 2 )
331 			aExport.push_back( aEntry );
332 	}
333 }
334 
335 // ------------------------------------------------------------------------
336 
FilterConfigCache(sal_Bool bConfig)337 FilterConfigCache::FilterConfigCache( sal_Bool bConfig ) :
338 	bUseConfig ( bConfig )
339 {
340 	if ( bUseConfig )
341 		ImplInit();
342 	else
343 		ImplInitSmart();
344 }
345 
~FilterConfigCache()346 FilterConfigCache::~FilterConfigCache()
347 {
348 
349 }
350 
GetImportFilterName(sal_uInt16 nFormat)351 String FilterConfigCache::GetImportFilterName( sal_uInt16 nFormat )
352 {
353     if( nFormat < aImport.size() )
354         return aImport[ nFormat ].sFilterName;
355     return String::EmptyString();
356 }
357 
GetImportFormatNumber(const String & rFormatName)358 sal_uInt16 FilterConfigCache::GetImportFormatNumber( const String& rFormatName )
359 {
360 	CacheVector::iterator aIter( aImport.begin() );
361 	while ( aIter != aImport.end() )
362 	{
363 		if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
364 			break;
365 		aIter++;
366 	}
367 	return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
368 }
369 
GetImportFormatNumberForMediaType(const String & rMediaType)370 sal_uInt16 FilterConfigCache::GetImportFormatNumberForMediaType( const String& rMediaType )
371 {
372 	CacheVector::iterator aIter( aImport.begin() );
373 	while ( aIter != aImport.end() )
374 	{
375 		if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
376 			break;
377 		aIter++;
378 	}
379 	return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
380 }
381 
GetImportFormatNumberForShortName(const String & rShortName)382 sal_uInt16 FilterConfigCache::GetImportFormatNumberForShortName( const String& rShortName )
383 {
384 	CacheVector::iterator aIter( aImport.begin() );
385 	while ( aIter != aImport.end() )
386 	{
387 		if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
388 			break;
389 		aIter++;
390 	}
391 	return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
392 }
393 
GetImportFormatNumberForTypeName(const String & rType)394 sal_uInt16 FilterConfigCache::GetImportFormatNumberForTypeName( const String& rType )
395 {
396 	CacheVector::iterator aIter( aImport.begin() );
397 	while ( aIter != aImport.end() )
398 	{
399 		if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
400 			break;
401 		aIter++;
402 	}
403 	return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
404 }
405 
GetImportFormatName(sal_uInt16 nFormat)406 String FilterConfigCache::GetImportFormatName( sal_uInt16 nFormat )
407 {
408     if( nFormat < aImport.size() )
409         return aImport[ nFormat ].sUIName;
410     return String::EmptyString();
411 }
412 
GetImportFormatMediaType(sal_uInt16 nFormat)413 String FilterConfigCache::GetImportFormatMediaType( sal_uInt16 nFormat )
414 {
415     if( nFormat < aImport.size() )
416         return aImport[ nFormat ].sMediaType;
417     return String::EmptyString();
418 }
419 
GetImportFormatShortName(sal_uInt16 nFormat)420 String FilterConfigCache::GetImportFormatShortName( sal_uInt16 nFormat )
421 {
422     if( nFormat < aImport.size() )
423         return aImport[ nFormat ].GetShortName();
424     return String::EmptyString();
425 }
426 
GetImportFormatExtension(sal_uInt16 nFormat,sal_Int32 nEntry)427 String FilterConfigCache::GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
428 {
429     if ( (nFormat < aImport.size()) && (nEntry < aImport[ nFormat ].lExtensionList.getLength()) )
430         return aImport[ nFormat ].lExtensionList[ nEntry ];
431     return String::EmptyString();
432 }
433 
GetImportFilterType(sal_uInt16 nFormat)434 String FilterConfigCache::GetImportFilterType( sal_uInt16 nFormat )
435 {
436     if( nFormat < aImport.size() )
437         return aImport[ nFormat ].sType;
438     return String::EmptyString();
439 }
440 
GetImportFilterTypeName(sal_uInt16 nFormat)441 String FilterConfigCache::GetImportFilterTypeName( sal_uInt16 nFormat )
442 {
443     if( nFormat < aImport.size() )
444         return aImport[ nFormat ].sFilterType;
445     return String::EmptyString();
446 }
447 
GetImportWildcard(sal_uInt16 nFormat,sal_Int32 nEntry)448 String FilterConfigCache::GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
449 {
450     String aWildcard( GetImportFormatExtension( nFormat, nEntry ) );
451     if ( aWildcard.Len() )
452 	    aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
453 	return aWildcard;
454 }
455 
IsImportInternalFilter(sal_uInt16 nFormat)456 sal_Bool FilterConfigCache::IsImportInternalFilter( sal_uInt16 nFormat )
457 {
458     return (nFormat < aImport.size()) && aImport[ nFormat ].bIsInternalFilter;
459 }
460 
IsImportPixelFormat(sal_uInt16 nFormat)461 sal_Bool FilterConfigCache::IsImportPixelFormat( sal_uInt16 nFormat )
462 {
463     return (nFormat < aImport.size()) && aImport[ nFormat ].bIsPixelFormat;
464 }
465 
IsImportDialog(sal_uInt16 nFormat)466 sal_Bool FilterConfigCache::IsImportDialog( sal_uInt16 nFormat )
467 {
468     return (nFormat < aImport.size()) && aImport[ nFormat ].bHasDialog;
469 }
470 
471 // ------------------------------------------------------------------------
472 
GetExportFilterName(sal_uInt16 nFormat)473 String FilterConfigCache::GetExportFilterName( sal_uInt16 nFormat )
474 {
475     if( nFormat < aExport.size() )
476         return aExport[ nFormat ].sFilterName;
477     return String::EmptyString();
478 }
479 
GetExportFormatNumber(const String & rFormatName)480 sal_uInt16 FilterConfigCache::GetExportFormatNumber( const String& rFormatName )
481 {
482 	CacheVector::iterator aIter( aExport.begin() );
483 	while ( aIter != aExport.end() )
484 	{
485 		if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
486 			break;
487 		aIter++;
488 	}
489 	return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
490 }
491 
GetExportFormatNumberForMediaType(const String & rMediaType)492 sal_uInt16 FilterConfigCache::GetExportFormatNumberForMediaType( const String& rMediaType )
493 {
494 	CacheVector::iterator aIter( aExport.begin() );
495 	while ( aIter != aExport.end() )
496 	{
497 		if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
498 			break;
499 		aIter++;
500 	}
501 	return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
502 }
503 
GetExportFormatNumberForShortName(const String & rShortName)504 sal_uInt16 FilterConfigCache::GetExportFormatNumberForShortName( const String& rShortName )
505 {
506 	CacheVector::iterator aIter( aExport.begin() );
507 	while ( aIter != aExport.end() )
508 	{
509 		if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
510 			break;
511 		aIter++;
512 	}
513 	return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
514 }
515 
GetExportFormatNumberForTypeName(const String & rType)516 sal_uInt16 FilterConfigCache::GetExportFormatNumberForTypeName( const String& rType )
517 {
518 	CacheVector::iterator aIter( aExport.begin() );
519 	while ( aIter != aExport.end() )
520 	{
521 		if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
522 			break;
523 		aIter++;
524 	}
525 	return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
526 }
527 
GetExportFormatName(sal_uInt16 nFormat)528 String FilterConfigCache::GetExportFormatName( sal_uInt16 nFormat )
529 {
530     if( nFormat < aExport.size() )
531         return aExport[ nFormat ].sUIName;
532     return String::EmptyString();
533 }
534 
GetExportFormatMediaType(sal_uInt16 nFormat)535 String FilterConfigCache::GetExportFormatMediaType( sal_uInt16 nFormat )
536 {
537     if( nFormat < aExport.size() )
538         return aExport[ nFormat ].sMediaType;
539     return String::EmptyString();
540 }
541 
GetExportFormatShortName(sal_uInt16 nFormat)542 String FilterConfigCache::GetExportFormatShortName( sal_uInt16 nFormat )
543 {
544     if( nFormat < aExport.size() )
545         return aExport[ nFormat ].GetShortName();
546     return String::EmptyString();
547 }
548 
GetExportFormatExtension(sal_uInt16 nFormat,sal_Int32 nEntry)549 String FilterConfigCache::GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
550 {
551     if ( (nFormat < aExport.size()) && (nEntry < aExport[ nFormat ].lExtensionList.getLength()) )
552         return aExport[ nFormat ].lExtensionList[ nEntry ];
553     return String::EmptyString();
554 }
555 
GetExportFilterTypeName(sal_uInt16 nFormat)556 String FilterConfigCache::GetExportFilterTypeName( sal_uInt16 nFormat )
557 {
558     if( nFormat < aExport.size() )
559         return aExport[ nFormat ].sFilterType;
560     return String::EmptyString();
561 }
562 
GetExportInternalFilterName(sal_uInt16 nFormat)563 String FilterConfigCache::GetExportInternalFilterName( sal_uInt16 nFormat )
564 {
565     if( nFormat < aExport.size() )
566         return aExport[ nFormat ].sInternalFilterName;
567     return String::EmptyString();
568 }
569 
GetExportWildcard(sal_uInt16 nFormat,sal_Int32 nEntry)570 String FilterConfigCache::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
571 {
572     String aWildcard( GetExportFormatExtension( nFormat, nEntry ) );
573     if ( aWildcard.Len() )
574 	    aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
575 	return aWildcard;
576 }
577 
IsExportInternalFilter(sal_uInt16 nFormat)578 sal_Bool FilterConfigCache::IsExportInternalFilter( sal_uInt16 nFormat )
579 {
580     return (nFormat < aExport.size()) && aExport[ nFormat ].bIsInternalFilter;
581 }
582 
IsExportPixelFormat(sal_uInt16 nFormat)583 sal_Bool FilterConfigCache::IsExportPixelFormat( sal_uInt16 nFormat )
584 {
585     return (nFormat < aExport.size()) && aExport[ nFormat ].bIsPixelFormat;
586 }
587 
IsExportDialog(sal_uInt16 nFormat)588 sal_Bool FilterConfigCache::IsExportDialog( sal_uInt16 nFormat )
589 {
590     return (nFormat < aExport.size()) && aExport[ nFormat ].bHasDialog;
591 }
592 
593 // ------------------------------------------------------------------------
594