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 :
21 : #include "filterfactory.hxx"
22 : #include "macros.hxx"
23 : #include "constant.hxx"
24 : #include "versions.hxx"
25 :
26 : #include <com/sun/star/lang/XInitialization.hpp>
27 : #include <comphelper/processfactory.hxx>
28 : #include <comphelper/enumhelper.hxx>
29 : #include <comphelper/configurationhelper.hxx>
30 : #include <rtl/ustrbuf.hxx>
31 :
32 :
33 : namespace filter{
34 : namespace config{
35 :
36 : /** @short define all possible parts of a filter query.
37 :
38 : @descr syntax: "<query>[:<param>[=<value>]]"
39 : e.g.: "_query_writer:default_first:use_order:sort_prop=uiname"
40 :
41 : argument description default
42 : -----------------------------------------------------------------------------------------------
43 : iflags=<mask> include filters by given mask 0
44 : eflags=<mask> exclude filters by given mask 0
45 : sort_prop=<[name,uiname]> sort by internal name or uiname name
46 : descending sort descending false
47 : use_order use order flag of filters for sorting false
48 : default_first set default filter on top of return list false
49 : case_sensitive compare "sort_prop" case sensitive false
50 : */
51 :
52 6799 : FilterFactory::FilterFactory(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
53 6799 : : m_xContext(rxContext)
54 : {
55 : BaseContainer::init(rxContext ,
56 : FilterFactory::impl_getImplementationName() ,
57 : FilterFactory::impl_getSupportedServiceNames(),
58 6799 : FilterCache::E_FILTER );
59 6799 : }
60 :
61 :
62 :
63 13598 : FilterFactory::~FilterFactory()
64 : {
65 13598 : }
66 :
67 :
68 :
69 0 : css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstance(const OUString& sFilter)
70 : throw(css::uno::Exception ,
71 : css::uno::RuntimeException)
72 : {
73 0 : return createInstanceWithArguments(sFilter, css::uno::Sequence< css::uno::Any >());
74 : }
75 :
76 :
77 :
78 463 : css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstanceWithArguments(const OUString& sFilter ,
79 : const css::uno::Sequence< css::uno::Any >& lArguments)
80 : throw(css::uno::Exception ,
81 : css::uno::RuntimeException)
82 : {
83 : // SAFE ->
84 463 : ::osl::ResettableMutexGuard aLock(m_aLock);
85 :
86 926 : OUString sRealFilter = sFilter;
87 :
88 : #ifdef _FILTER_CONFIG_MIGRATION_Q_
89 :
90 : /* -> TODO - HACK
91 : check if the given filter name realy exist ...
92 : Because our old implementation worked with an internal
93 : type name instead of a filter name. For a small migration time
94 : we must simulate this old feature :-( */
95 :
96 463 : if (!m_rCache->hasItem(FilterCache::E_FILTER, sFilter) && m_rCache->hasItem(FilterCache::E_TYPE, sFilter))
97 : {
98 : OSL_FAIL("Who use this deprecated functionality?");
99 : _FILTER_CONFIG_LOG_("FilterFactory::createInstanceWithArguments() ... simulate old type search functionality!\n");
100 :
101 0 : css::uno::Sequence< css::beans::NamedValue > lQuery(1);
102 0 : lQuery[0].Name = PROPNAME_TYPE;
103 0 : lQuery[0].Value <<= sFilter;
104 :
105 0 : css::uno::Reference< css::container::XEnumeration > xSet = createSubSetEnumerationByProperties(lQuery);
106 0 : while(xSet->hasMoreElements())
107 : {
108 0 : ::comphelper::SequenceAsHashMap lHandlerProps(xSet->nextElement());
109 0 : if (!(lHandlerProps[PROPNAME_NAME] >>= sRealFilter))
110 0 : continue;
111 0 : }
112 :
113 : // prevent outside code against NoSuchElementException!
114 : // But dont implement such defensive strategy for our new create handling :-)
115 0 : if (!m_rCache->hasItem(FilterCache::E_FILTER, sRealFilter))
116 0 : return css::uno::Reference< css::uno::XInterface>();
117 : }
118 :
119 : /* <- HACK */
120 :
121 : #endif // _FILTER_CONFIG_MIGRATION_Q_
122 :
123 : // search filter on cache
124 926 : CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sRealFilter);
125 926 : OUString sFilterService;
126 463 : aFilter[PROPNAME_FILTERSERVICE] >>= sFilterService;
127 :
128 : // create service instance
129 926 : css::uno::Reference< css::uno::XInterface > xFilter;
130 463 : if (!sFilterService.isEmpty())
131 463 : xFilter = m_xContext->getServiceManager()->createInstanceWithContext(sFilterService, m_xContext);
132 :
133 : // initialize filter
134 926 : css::uno::Reference< css::lang::XInitialization > xInit(xFilter, css::uno::UNO_QUERY);
135 463 : if (xInit.is())
136 : {
137 : // format: lInitData[0] = seq<PropertyValue>, which contains all configuration properties of this filter
138 : // lInitData[1] = lArguments[0]
139 : // ...
140 : // lInitData[n] = lArguments[n-1]
141 463 : css::uno::Sequence< css::beans::PropertyValue > lConfig;
142 463 : aFilter >> lConfig;
143 :
144 926 : ::comphelper::SequenceAsVector< css::uno::Any > stlArguments(lArguments);
145 463 : stlArguments.insert(stlArguments.begin(), css::uno::makeAny(lConfig));
146 :
147 926 : css::uno::Sequence< css::uno::Any > lInitData;
148 463 : stlArguments >> lInitData;
149 :
150 926 : xInit->initialize(lInitData);
151 : }
152 :
153 926 : return xFilter;
154 : // <- SAFE
155 : }
156 :
157 :
158 :
159 0 : css::uno::Sequence< OUString > SAL_CALL FilterFactory::getAvailableServiceNames()
160 : throw(css::uno::RuntimeException)
161 : {
162 : /* Attention: Instead of getElementNames() this method have to return only filter names,
163 : which can be created as UNO Services realy. Thats why we search for filters,
164 : which dont have a valid value for the property "FilterService".
165 : Of course we cant check for corrupted service names here. We can check
166 : for empty strings only ...
167 : */
168 0 : CacheItem lIProps;
169 0 : CacheItem lEProps;
170 0 : lEProps[PROPNAME_FILTERSERVICE] <<= OUString();
171 :
172 0 : OUStringList lUNOFilters;
173 : try
174 : {
175 0 : lUNOFilters = m_rCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps);
176 : }
177 0 : catch(const css::uno::RuntimeException&)
178 0 : { throw; }
179 0 : catch(const css::uno::Exception&)
180 0 : { lUNOFilters.clear(); }
181 :
182 0 : return lUNOFilters.getAsConstList();
183 : }
184 :
185 :
186 :
187 0 : css::uno::Reference< css::container::XEnumeration > SAL_CALL FilterFactory::createSubSetEnumerationByQuery(const OUString& sQuery)
188 : throw (css::uno::RuntimeException)
189 : {
190 : // reject old deprecated queries ...
191 0 : if (sQuery.matchAsciiL("_filterquery_",13,0))
192 : throw css::uno::RuntimeException(
193 : _FILTER_CONFIG_FROM_ASCII_("Use of deprecated and now unsupported query!"),
194 0 : static_cast< css::container::XContainerQuery* >(this));
195 :
196 : // convert "_query_xxx:..." to "getByDocService=xxx:..."
197 0 : OUString sNewQuery(sQuery);
198 0 : sal_Int32 pos = sNewQuery.indexOf("_query_");
199 0 : if (pos != -1)
200 : {
201 : OSL_FAIL("DEPRECATED!\nPlease use new query format: 'matchByDocumentService=...'");
202 0 : OUString sPatchedQuery("matchByDocumentService=" + sNewQuery.copy(7));
203 0 : sNewQuery = sPatchedQuery;
204 : }
205 :
206 : // analyze query and split it into its tokens
207 0 : QueryTokenizer lTokens(sNewQuery);
208 0 : QueryTokenizer::const_iterator pIt;
209 0 : OUStringList lEnumSet;
210 :
211 : // start query
212 : // (see attention comment below!)
213 0 : if (lTokens.valid())
214 : {
215 : // SAFE -> ----------------------
216 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
217 : // May be not all filters was loaded ...
218 : // But we need it now!
219 0 : impl_loadOnDemand();
220 0 : aLock.clear();
221 : // <- SAFE ----------------------
222 :
223 0 : if (lTokens.find(QUERY_IDENTIFIER_GETPREFERREDFILTERFORTYPE) != lTokens.end())
224 : OSL_FAIL("DEPRECATED!\nPlease use prop search at the TypeDetection container!");
225 : else
226 0 : if (lTokens.find(QUERY_IDENTIFIER_MATCHBYDOCUMENTSERVICE) != lTokens.end())
227 0 : lEnumSet = impl_queryMatchByDocumentService(lTokens);
228 : else
229 0 : if (lTokens.find(QUERY_IDENTIFIER_GET_SORTED_FILTERLIST) != lTokens.end())
230 0 : lEnumSet = impl_getSortedFilterList(lTokens);
231 : }
232 :
233 : // pack list of item names as an enum list
234 : // Attention: Do not return empty reference for empty list!
235 : // The outside check "hasMoreElements()" should be enough, to detect this state :-)
236 0 : css::uno::Sequence< OUString > lSet = lEnumSet.getAsConstList();
237 0 : ::comphelper::OEnumerationByName* pEnum = new ::comphelper::OEnumerationByName(this, lSet);
238 0 : return css::uno::Reference< css::container::XEnumeration >(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
239 : }
240 :
241 :
242 :
243 0 : OUStringList FilterFactory::impl_queryMatchByDocumentService(const QueryTokenizer& lTokens) const
244 : {
245 : // analyze query
246 0 : QueryTokenizer::const_iterator pIt;
247 :
248 0 : OUString sDocumentService;
249 0 : sal_Int32 nIFlags = 0;
250 0 : sal_Int32 nEFlags = 0;
251 :
252 0 : pIt = lTokens.find(QUERY_IDENTIFIER_MATCHBYDOCUMENTSERVICE);
253 0 : if (pIt != lTokens.end())
254 0 : sDocumentService = pIt->second;
255 :
256 : #define COMP_HACK
257 : #ifdef COMP_HACK
258 0 : if ( sDocumentService == "writer" )
259 : {
260 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
261 0 : sDocumentService = OUString( "com.sun.star.text.TextDocument" );
262 : }
263 0 : else if ( sDocumentService == "web" )
264 : {
265 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
266 0 : sDocumentService = OUString( "com.sun.star.text.WebDocument" );
267 : }
268 0 : else if ( sDocumentService == "global" )
269 : {
270 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
271 0 : sDocumentService = OUString( "com.sun.star.text.GlobalDocument" );
272 : }
273 0 : else if ( sDocumentService == "calc" )
274 : {
275 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
276 0 : sDocumentService = OUString( "com.sun.star.sheet.SpreadsheetDocument" );
277 : }
278 0 : else if ( sDocumentService == "draw" )
279 : {
280 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
281 0 : sDocumentService = OUString( "com.sun.star.drawing.DrawingDocument" );
282 : }
283 0 : else if ( sDocumentService == "impress" )
284 : {
285 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
286 0 : sDocumentService = OUString( "com.sun.star.presentation.PresentationDocument" );
287 : }
288 0 : else if ( sDocumentService == "math" )
289 : {
290 : OSL_FAIL("DEPRECATED!\nPlease use right document service for filter query!");
291 0 : sDocumentService = OUString( "com.sun.star.formula.FormulaProperties" );
292 : }
293 : #endif
294 :
295 0 : pIt = lTokens.find(QUERY_PARAM_IFLAGS);
296 0 : if (pIt != lTokens.end())
297 0 : nIFlags = OUString(pIt->second).toInt32();
298 :
299 0 : pIt = lTokens.find(QUERY_PARAM_EFLAGS);
300 0 : if (pIt != lTokens.end())
301 0 : nEFlags = OUString(pIt->second).toInt32();
302 :
303 : // SAFE -> ----------------------
304 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
305 :
306 : // search suitable filters
307 0 : FilterCache* pCache = impl_getWorkingCache();
308 0 : OUStringList lFilterNames = pCache->getItemNames(FilterCache::E_FILTER);
309 0 : OUStringList lResult ;
310 :
311 0 : for (OUStringList::const_iterator pName = lFilterNames.begin();
312 0 : pName != lFilterNames.end() ;
313 : ++pName )
314 : {
315 : try
316 : {
317 0 : const OUString& sName = *pName;
318 0 : const CacheItem aFilter = pCache->getItem(FilterCache::E_FILTER, sName);
319 0 : CacheItem::const_iterator pProp ;
320 :
321 : // "matchByDocumentService=" => any filter will be addressed here
322 : // "matchByDocumentService=all" => any filter will be addressed here
323 : // "matchByDocumentService=com.sun.star..." => only filter matching this document service will be addressed
324 0 : OUString sCheckValue = aFilter.getUnpackedValueOrDefault(PROPNAME_DOCUMENTSERVICE, OUString());
325 0 : if (
326 0 : (!sDocumentService.isEmpty() ) &&
327 0 : (!sDocumentService.equals(QUERY_CONSTVALUE_ALL)) &&
328 0 : (!sCheckValue.equals(sDocumentService) )
329 : )
330 : {
331 0 : continue; // ignore filter -> try next one!
332 : }
333 :
334 : // "iflags=" => not allowed
335 : // "iflags=-1" => not allowed
336 : // "iflags=0" => not useful
337 : // "iflags=283648" => only filter, which has set these flag field will be addressed
338 0 : sal_Int32 nCheckValue = aFilter.getUnpackedValueOrDefault(PROPNAME_FLAGS, (sal_Int32)0);
339 0 : if (
340 0 : (nIFlags > 0 ) &&
341 0 : ((nCheckValue & nIFlags) != nIFlags)
342 : )
343 : {
344 0 : continue; // ignore filter -> try next one!
345 : }
346 :
347 : // "eflags=" => not allowed
348 : // "eflags=-1" => not allowed
349 : // "eflags=0" => not useful
350 : // "eflags=283648" => only filter, which has not set these flag field will be addressed
351 0 : if (
352 0 : (nEFlags > 0 ) &&
353 0 : ((nCheckValue & nEFlags) == nEFlags)
354 : )
355 : {
356 0 : continue; // ignore filter -> try next one!
357 : }
358 :
359 : // OK - this filter passed all checks.
360 : // It match the query ...
361 0 : lResult.push_back(sName);
362 : }
363 0 : catch(const css::uno::RuntimeException&)
364 0 : { throw; }
365 0 : catch(const css::uno::Exception&)
366 0 : { continue; }
367 : }
368 :
369 0 : aLock.clear();
370 : // <- SAFE ----------------------
371 :
372 0 : return lResult;
373 : }
374 :
375 :
376 :
377 : class stlcomp_removeIfMatchFlags
378 : {
379 : private:
380 : FilterCache* m_pCache ;
381 : sal_Int32 m_nFlags ;
382 : sal_Bool m_bIFlags;
383 :
384 : public:
385 0 : stlcomp_removeIfMatchFlags(FilterCache* pCache ,
386 : sal_Int32 nFlags ,
387 : sal_Bool bIFlags)
388 : : m_pCache (pCache )
389 : , m_nFlags (nFlags )
390 0 : , m_bIFlags(bIFlags)
391 0 : {}
392 :
393 0 : bool operator() (const OUString& sFilter) const
394 : {
395 : try
396 : {
397 0 : const CacheItem aFilter = m_pCache->getItem(FilterCache::E_FILTER, sFilter);
398 0 : sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault(PROPNAME_FLAGS, ((sal_Int32)0));
399 :
400 0 : bool bMatch = false;
401 0 : if (m_bIFlags)
402 : // IFlags are interpeted as ALL_FLAGS_MUST_MATCH !
403 0 : bMatch = ((nFlags & m_nFlags) == m_nFlags);
404 : else
405 : // EFlags are interpreted as ATE_LEAST_ONE_FLAG_MUST_MATCH !
406 0 : bMatch = !(nFlags & m_nFlags);
407 : // We are asked for bRemove ! And bMatch = !bRemove => so bRemove = !bMatch .-)
408 0 : return !bMatch;
409 : }
410 0 : catch(const css::container::NoSuchElementException &)
411 : {
412 0 : return true;
413 : }
414 : }
415 : };
416 :
417 :
418 :
419 0 : OUStringList FilterFactory::impl_getSortedFilterList(const QueryTokenizer& lTokens) const
420 : {
421 : // analyze the given query parameter
422 0 : QueryTokenizer::const_iterator pIt1;
423 :
424 0 : OUString sModule;
425 0 : sal_Int32 nIFlags = -1;
426 0 : sal_Int32 nEFlags = -1;
427 :
428 0 : pIt1 = lTokens.find(QUERY_PARAM_MODULE);
429 0 : if (pIt1 != lTokens.end())
430 0 : sModule = pIt1->second;
431 0 : pIt1 = lTokens.find(QUERY_PARAM_IFLAGS);
432 0 : if (pIt1 != lTokens.end())
433 0 : nIFlags = OUString(pIt1->second).toInt32();
434 0 : pIt1 = lTokens.find(QUERY_PARAM_EFLAGS);
435 0 : if (pIt1 != lTokens.end())
436 0 : nEFlags = OUString(pIt1->second).toInt32();
437 :
438 : // simple search for filters of one specific module.
439 0 : OUStringList lFilterList;
440 0 : if (!sModule.isEmpty())
441 0 : lFilterList = impl_getSortedFilterListForModule(sModule, nIFlags, nEFlags);
442 : else
443 : {
444 : // more complex search for all filters
445 : // We check first, which office modules are installed ...
446 0 : OUStringList lModules = impl_getListOfInstalledModules();
447 0 : OUStringList::const_iterator pIt2;
448 0 : for ( pIt2 = lModules.begin();
449 0 : pIt2 != lModules.end() ;
450 : ++pIt2 )
451 : {
452 0 : sModule = *pIt2;
453 0 : OUStringList lFilters4Module = impl_getSortedFilterListForModule(sModule, nIFlags, nEFlags);
454 0 : OUStringList::const_iterator pIt3;
455 0 : for ( pIt3 = lFilters4Module.begin();
456 0 : pIt3 != lFilters4Module.end() ;
457 : ++pIt3 )
458 : {
459 0 : const OUString& sFilter = *pIt3;
460 0 : lFilterList.push_back(sFilter);
461 : }
462 0 : }
463 : }
464 :
465 0 : return lFilterList;
466 : }
467 :
468 :
469 :
470 0 : OUStringList FilterFactory::impl_getListOfInstalledModules() const
471 : {
472 : // SAFE -> ----------------------
473 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
474 0 : css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
475 0 : aLock.clear();
476 : // <- SAFE ----------------------
477 :
478 : try
479 : {
480 : css::uno::Reference< css::container::XNameAccess > xModuleConfig(
481 : ::comphelper::ConfigurationHelper::openConfig( xContext,
482 : CFGPACKAGE_OOO_MODULES,
483 : ::comphelper::ConfigurationHelper::E_READONLY),
484 0 : css::uno::UNO_QUERY_THROW);
485 0 : OUStringList lModules(xModuleConfig->getElementNames());
486 0 : return lModules;
487 : }
488 0 : catch(const css::uno::RuntimeException&)
489 0 : { throw; }
490 0 : catch(const css::uno::Exception&)
491 : {}
492 :
493 0 : return OUStringList();
494 : }
495 :
496 :
497 :
498 0 : OUStringList FilterFactory::impl_getSortedFilterListForModule(const OUString& sModule,
499 : sal_Int32 nIFlags,
500 : sal_Int32 nEFlags) const
501 : {
502 0 : OUStringList lSortedFilters = impl_readSortedFilterListFromConfig(sModule);
503 :
504 : // get all filters for the requested module
505 0 : CacheItem lIProps;
506 0 : lIProps[PROPNAME_DOCUMENTSERVICE] <<= sModule;
507 :
508 : // SAFE -> ----------------------
509 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
510 0 : FilterCache* pCache = impl_getWorkingCache();
511 0 : OUStringList lOtherFilters = pCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps);
512 0 : aLock.clear();
513 : // <- SAFE ----------------------
514 :
515 : // bring "other" filters in an alphabeticly order
516 : // It's needed below.
517 0 : ::std::sort(lOtherFilters.begin(), lOtherFilters.end());
518 :
519 : // merge both lists together
520 0 : OUStringList lMergedFilters = lSortedFilters;
521 0 : const OUStringList::const_iterator itlOtherFiltersEnd = lOtherFilters.end();
522 0 : const OUStringList::const_iterator itlSortedFiltersEnd = lSortedFilters.end();
523 0 : for (OUStringList::const_iterator pIt = lOtherFilters.begin();
524 : pIt != itlOtherFiltersEnd ;
525 : ++pIt )
526 : {
527 0 : if (::std::find(lSortedFilters.begin(), lSortedFilters.end(), *pIt) == itlSortedFiltersEnd)
528 0 : lMergedFilters.push_back(*pIt);
529 : }
530 :
531 0 : OUStringList::iterator pItToErase;
532 :
533 : // remove all filters from this merged list, which does not fit the flag specification
534 0 : if (nIFlags != -1)
535 : {
536 0 : pItToErase = ::std::remove_if(lMergedFilters.begin(), lMergedFilters.end(), stlcomp_removeIfMatchFlags(pCache, nIFlags, sal_True));
537 0 : lMergedFilters.erase(pItToErase, lMergedFilters.end());
538 : }
539 0 : if (nEFlags != -1)
540 : {
541 0 : pItToErase = ::std::remove_if(lMergedFilters.begin(), lMergedFilters.end(), stlcomp_removeIfMatchFlags(pCache, nEFlags, sal_False));
542 0 : lMergedFilters.erase(pItToErase, lMergedFilters.end());
543 : }
544 :
545 : // sort the default filter to the front of this list
546 : // TODO
547 :
548 0 : return lMergedFilters;
549 : }
550 :
551 :
552 :
553 0 : OUStringList FilterFactory::impl_readSortedFilterListFromConfig(const OUString& sModule) const
554 : {
555 : // SAFE -> ----------------------
556 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
557 0 : css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
558 0 : aLock.clear();
559 : // <- SAFE ----------------------
560 :
561 : try
562 : {
563 : css::uno::Reference< css::container::XNameAccess > xUISortConfig(
564 : ::comphelper::ConfigurationHelper::openConfig( xContext,
565 : CFGPACKAGE_TD_UISORT,
566 : ::comphelper::ConfigurationHelper::E_READONLY),
567 0 : css::uno::UNO_QUERY_THROW);
568 :
569 : // dont ccheck the module name here. If it does not exists, an exception is thrown and catched below.
570 : // We return an empty list as result then.
571 0 : css::uno::Reference< css::container::XNameAccess > xModule;
572 0 : xUISortConfig->getByName(sModule) >>= xModule;
573 0 : if (xModule.is()) // only to be on the safe side of life if the exception was not thrown .-)
574 : {
575 : // Note: convertion of the returned Any to OUStringList throws
576 : // an IllegalArgumentException if the type does not match ...
577 : // but it resets the OUStringList to a length of 0 if the Any is empty!
578 0 : OUStringList lSortedFilters(xModule->getByName(PROPNAME_SORTEDFILTERLIST));
579 0 : return lSortedFilters;
580 0 : }
581 : }
582 0 : catch(const css::uno::RuntimeException&)
583 0 : { throw; }
584 0 : catch(const css::uno::Exception&)
585 : {}
586 :
587 0 : return OUStringList();
588 : }
589 :
590 :
591 :
592 7129 : OUString FilterFactory::impl_getImplementationName()
593 : {
594 7129 : return OUString( "com.sun.star.comp.filter.config.FilterFactory" );
595 : }
596 :
597 :
598 :
599 6865 : css::uno::Sequence< OUString > FilterFactory::impl_getSupportedServiceNames()
600 : {
601 6865 : css::uno::Sequence< OUString > lServiceNames(1);
602 6865 : lServiceNames[0] = OUString( "com.sun.star.document.FilterFactory" );
603 6865 : return lServiceNames;
604 : }
605 :
606 :
607 :
608 6799 : css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
609 : {
610 6799 : FilterFactory* pNew = new FilterFactory( comphelper::getComponentContext(xSMGR) );
611 6799 : return css::uno::Reference< css::uno::XInterface >(static_cast< css::lang::XMultiServiceFactory* >(pNew), css::uno::UNO_QUERY);
612 : }
613 :
614 : } // namespace config
615 : } // namespace filter
616 :
617 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|