xref: /trunk/main/filter/source/config/cache/filtercache.hxx (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 #ifndef __FILTER_CONFIG_FILTERCACHE_HXX_
25 #define __FILTER_CONFIG_FILTERCACHE_HXX_
26 
27 //_______________________________________________
28 // includes
29 
30 #include "cacheitem.hxx"
31 #include <com/sun/star/uno/Exception.hpp>
32 #include <com/sun/star/util/URL.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/uno/XInterface.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <com/sun/star/container/XNameReplace.hpp>
38 #include <com/sun/star/util/ChangesEvent.hpp>
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/uno/Any.h>
41 #include <rtl/ustring.hxx>
42 
43 //_______________________________________________
44 // namespace
45 
46 namespace filter{
47     namespace config{
48 
49 //_______________________________________________
50 // definitions
51 
52 //_______________________________________________
53 
54 /** @short      implements a cache, which contains all
55                 elements of our filter and type detection
56                 configuration.
57 
58     @descr      The cache itself is threadsafe implemented.
59                 Because it should be used as a singleton only.
60                 To do so please use reference mechanism as wrapper
61                 around this FilterCache class.
62 
63     @attention  Because we use a trick to get a full initialized
64                 mutex lock during initialization time (means during
65                 the constructor runs), the base class FilterCacheLock
66                 must be the first of all declared one!
67                 Further we make it public. So any user of this class
68                 can lock us from outside too.
69  */
70 class FilterCache : public BaseLock
71 {
72     //-------------------------------------------
73     // public types
74 
75     public:
76 
77         //---------------------------------------
78 
79         /** @short  identify the type of a container item.
80 
81             @descr  Because the cache interface is a generic one
82                     every group of container items must be specified.
83          */
84         enum EItemType
85         {
86             E_TYPE          ,
87             E_FILTER        ,
88             E_FRAMELOADER   ,
89             E_CONTENTHANDLER,
90             E_DETECTSERVICE
91         };
92 
93         //---------------------------------------
94 
95         /** @short      indicates, which items already exists inside this cache
96                         and which not.
97 
98             @descr      This cache supports a 2-step load mechanism.
99                         First only types (and only some special properties of every type!)
100                         but no filters/frame loaders/content handlers will be readed.
101                         That should be enough to work with this cache e.g. for loading
102                         the first document. After this first document was loaded successfully,
103                         a special "load-on-demand-thread" will be started to fill this cache
104                         with ALL other informations, which was not readed before.
105                         That's the second step. All operations on top of this cache will be
106                         blocked then.
107          */
108         enum EFillState
109         {
110             E_CONTAINS_NOTHING          = 0,
111             E_CONTAINS_STANDARD         = 1,
112             E_CONTAINS_TYPES            = 2,
113             E_CONTAINS_FILTERS          = 4,
114             E_CONTAINS_DETECTSERVICES   = 8,
115             E_CONTAINS_FRAMELOADERS     = 16,
116             E_CONTAINS_CONTENTHANDLERS  = 32,
117             E_CONTAINS_ALL              = 63 // must be a combination of all excepting E_CONTAINS_NOTHING! Please update if items will be added or removed ...
118         };
119 
120     //-------------------------------------------
121     // private types
122 
123     private:
124 
125         //---------------------------------------
126         /** @short      regulate, which properties of a configured item
127                         will be readed.
128 
129             @descr      To perform reading of all configuration items,
130                         only standard properties will be handled. At a second
131                         step all optional properties will be read and added to
132                         our internal structures. Of course the combination of
133                         both options can be used too, to get all properties
134                         at the same time.
135          */
136         enum EReadOption
137         {
138             E_READ_NOTHING  = 0,
139             E_READ_STANDARD = 1,
140             E_READ_UPDATE   = 2,
141             E_READ_ALL      = 3
142         };
143 
144         //---------------------------------------
145         /** @short      indicates the state of a configuration set item.
146 
147             @descr      Inside method flush we check:
148                         <ul>
149                             <li>if the item exists inside config layer but not inside our cache => REMOVED</li>
150                             <li>if the item exists inside config layer and inside our cache => CHANGED</li>
151                             <li>if the item does not exists inside config layer but inside our cache => ADDED.</li>
152                         </ul>
153          */
154         enum EItemFlushState
155         {
156             /// indicates an unchanged item (can occur e.g. if an item was added and(!) removed before it was flushed ...
157             E_ITEM_UNCHANGED = 0,
158             /// indicates an item, which exists inside config layer but not inside our own cache
159             E_ITEM_REMOVED = 1,
160             /// indicates an item, which exists inside config layer and inside our own cache
161             E_ITEM_CHANGED = 2,
162             /// indicates an item, which does not exists inside config layer but inside our own cache
163             E_ITEM_ADDED = 3
164         };
165 
166         //---------------------------------------
167         /** TODO document me */
168         enum EConfigProvider
169         {
170             E_PROVIDER_TYPES = 0,
171             E_PROVIDER_FILTERS = 1,
172             E_PROVIDER_OTHERS = 2,
173             E_PROVIDER_OLD = 3
174         };
175 
176     //-------------------------------------------
177     // member
178 
179     private:
180 
181         //---------------------------------------
182         /** @short  reference to an uno service manager, which can be used
183                     to create own needed services. */
184         mutable css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
185 
186         //---------------------------------------
187         /** @short  holds the used configuration provider alive, which
188                     provides access to the list of types. */
189         mutable css::uno::Reference< css::uno::XInterface > m_xConfigTypes;
190 
191         //---------------------------------------
192         /** @short  holds the used configuration provider alive, which
193                     provides access to the list of filters. */
194         mutable css::uno::Reference< css::uno::XInterface > m_xConfigFilters;
195 
196         //---------------------------------------
197         /** @short  holds the used configuration provider alive, which
198                     provides access to the list of other values needed
199                     by our type detection framework. */
200         mutable css::uno::Reference< css::uno::XInterface > m_xConfigOthers;
201 
202         //---------------------------------------
203         /** @short  contains all loaded types with its properties. */
204         mutable CacheItemList m_lTypes;
205 
206         //---------------------------------------
207         /** @short  contains all well known detect service with its properties. */
208         mutable CacheItemList m_lDetectServices;
209 
210         //---------------------------------------
211         /** @short  contains all loaded filters with its properties. */
212         mutable CacheItemList m_lFilters;
213 
214         //---------------------------------------
215         /** @short  contains all loaded frame loader with its properties. */
216         mutable CacheItemList m_lFrameLoaders;
217 
218         //---------------------------------------
219         /** @short  contains all loaded content handler with its properties. */
220         mutable CacheItemList m_lContentHandlers;
221 
222         //---------------------------------------
223         /** @short  optimize mapping of URL extensions to a type representation,
224                     by using extensions as key and a list of internal
225                     type names as value. */
226         mutable CacheItemRegistration m_lExtensions2Types;
227 
228         //---------------------------------------
229         /** @short  optimize mapping of URL pattern to a type representation,
230                     by using patterns as key and a list of internal
231                     type names as value. */
232         mutable CacheItemRegistration m_lURLPattern2Types;
233 
234         //---------------------------------------
235         /** @short  contains the current locale of the office and will be
236                     used to work with localized configuration values. */
237         ::rtl::OUString m_sActLocale;
238 
239         ::rtl::OUString m_sProductName;
240 
241         //---------------------------------------
242         /** TODO */
243         ::rtl::OUString m_sOOoXMLFormatName;
244 
245         //---------------------------------------
246         /** TODO */
247         ::rtl::OUString m_sOOoXMLFormatVersion;
248 
249         //---------------------------------------
250         /** @short  contains status, which cache items/properties
251                     was already loaded from the underlying configuration.
252 
253             @descr  This information can be used to detect missing
254                     informations and load it on demand.
255 
256             @see    EFillState
257             @see    load()
258          */
259         EFillState m_eFillState;
260 
261         //---------------------------------------
262         /** TODO document me ... */
263         OUStringList m_lChangedTypes;
264         OUStringList m_lChangedFilters;
265         OUStringList m_lChangedDetectServices;
266         OUStringList m_lChangedFrameLoaders;
267         OUStringList m_lChangedContentHandlers;
268 
269         //---------------------------------------
270         /// readonly access to the module configuration of OOo
271         css::uno::Reference< css::container::XNameAccess > m_xModuleCfg;
272 
273     //-------------------------------------------
274     // interface
275 
276     public:
277 
278         //---------------------------------------
279         // ctor/dtor
280 
281         /** @short  standard ctor
282 
283             @descr  Its not allowed to do anything here ...
284                     especially is forbidden to start operations,
285                     which needs a FilterCache instance too!
286                     Why? Because this FilterCache instance will be
287                     used as a singleton! And if during this ctor any
288                     action related to this FilterCache singleton is
289                     started ... a race will be the result.
290 
291                     The first method after construction of a new
292                     singleton reference should be "load()". There
293                     a special fill state of this cache can be forced.
294          */
295         FilterCache();
296 
297         //---------------------------------------
298 
299         /** @short  standard dtor.
300          */
301         virtual ~FilterCache();
302 
303         //---------------------------------------
304 
305         /** @short  creates a copy of this container.
306 
307             @descr  Such copy can be used then to modify items (add/change/remove)
308                     without the risk to damage the original container.
309                     After its changed data was flushed to the configuration it can be
310                     removed.
311 
312                     The original container will get these new data automatically
313                     because it listens for changes on the internal used configuration layer.
314                     If the new data are needed immediately inside the original container,
315                     the method takeOver() can be used to copy all changes back.
316                     The may be following notifications of the configuration will be superfluous then.
317                     But they can't be stopped ...
318 
319                     All internal structures will be copied here. But the internal used
320                     configuration (update) access won't be copied. The cloned instance contains
321                     a different one.
322 
323             @note   The cloned instance is created on the heap. The user of this instance
324                     has to remove it later.
325          */
326         virtual FilterCache* clone() const;
327 
328         //---------------------------------------
329 
330         /** @short  copy the cache content or rClone back to this instance.
331          */
332         virtual void takeOver(const FilterCache& rClone);
333 
334         //---------------------------------------
335 
336         /** @short      force special fill state of this cache.
337 
338             @descr      This method checks if all requested items/properties already
339                         exist. Only missing informations will be read.
340                         Otherwise this method does nothing!
341 
342                         This method must be called from every user of this cache
343                         everytime it needs a filled cache. Normally we load
344                         only standard informations into this cache on startup.
345                         After a few seconds we start a special thread, which
346                         may fill this cache completely. But if somewhere outside
347                         need a filled cache before ... it can run into trouble,
348                         if this "load-on-demand" thread does not finished its work before.
349                         This method "load(xxx)" synchronize such load-on-demand requests.
350 
351                         Of course it would be possible to suppress this special load thread
352                         in general and start it manually inside this load() request.
353                         The outside code decides then, if and when this cache will be filled
354                         with all available informations ...
355 
356             @param      bByThread
357                         indicates using of this method by our global "load-on-demand-thread".
358                         Its an implementation detail! We use it to check, if this "load()"
359                         request was forced e.g. by one of our derived service container (which need
360                         it to full fill its own operations) or if it was forced by our own
361                         "load-on-demand-thread", which tries to optimize our startup performance
362                         and start this load() only in case the office startup was already finished!
363 
364             @throw      An exception if the cache could not be filled really
365                         or seems to be invalid afterwards. But there is no reaction
366                         at all if this method does nothing inside, because the cache
367                         is already full filled!
368          */
369         virtual void load(EFillState eRequired ,
370                           sal_Bool   bByThread = sal_False);
371 
372         //---------------------------------------
373 
374         /** @short      return the current fill state of this cache.
375 
376             @descr      This information can be used e.g. to start
377                         a search on top of this cache with a minimum on
378                         informations ... and do it again, if some other
379                         cache items seems to be available after calling of "loadAll()"
380                         on this cache and first search does not had any valid results.
381 
382             @return     sal_True if the required fill state exists for this cache; FALSE
383                         otherwise.
384          */
385         virtual sal_Bool isFillState(EFillState eRequired) const;
386 
387         //---------------------------------------
388 
389         /** @short      return a list of key names for items, which match
390                         the specified criteria.
391 
392             @descr      The returned key names can be used at another method "getItem()"
393                         of this cache to get further informations about this item.
394 
395             @attention  Please note: because this cache can be used inside multithreaded
396                         environments, such returned key name can point to an already removed
397                         item! Please be aware of some "NoSuchElementExceptions" if you try to
398                         call any other method of this cache in relation to this key name.
399 
400             @param      eType
401                         specify the sub container of this cache, which should be used for
402                         searching. see also EItemType.
403 
404             @param      lIProps
405                         specify the property set, which must exist at the searched items
406                         as minimum.
407 
408             @param      lEProps
409                         specify the property set, which must not(!) exist at the searched items
410                         as minimum.
411 
412             @return     [OUStringList]
413                         a list of key names, which identify items of the queried sub container.
414                         May be an empty list.
415 
416             @throw      [css::uno::Exception]
417                         if some input parameter are wrong or the cache itself is not valid
418                         any longer, because any operation before damage it.
419          */
420         virtual OUStringList getMatchingItemsByProps(      EItemType  eType                ,
421                                                      const CacheItem& lIProps              ,
422                                                      const CacheItem& lEProps = CacheItem()) const;
423 
424         //---------------------------------------
425 
426         /** @short      indicates if the requested sub container
427                         contains some items.
428 
429             @descr      We don't provide any information about the count
430                         of such items. Because we don't implement any index
431                         based interface! The information "we have items or not"
432                         must be enough for the outside code ... till somewhere
433                         give us a good reason. :-)
434 
435             @param      eType
436                         specify the sub container of this cache, which should be used.
437                         see also EItemType.
438 
439             @return     [sal_Bool]
440                         True, if the requested sub container contains some items;
441                         False otherwise.
442 
443             @throw      [css::uno::Exception]
444                         if some input parameter are wrong or the cache itself is not valid
445                         any longer, because any operation before damage it.
446          */
447         virtual sal_Bool hasItems(EItemType eType) const;
448 
449         //---------------------------------------
450 
451         /** @short      return a list of all key names, which represent
452                         an item inside the specified sub container.
453 
454             @attention  Please note: because this cache can be used inside multithreaded
455                         environments, such returned key names can point to some already removed
456                         items! Please be aware of some "NoSuchElementExceptions" if you try to
457                         call any other method of this cache in relation to this key names.
458 
459             @param      eType
460                         specify the sub container of this cache, which should be used for
461                         searching. see also EItemType.
462 
463             @return     [OUStringList]
464                         a list of key names, which can be used to access the item properties
465                         using some other methods of this cache.
466 
467             @throw      [css::uno::Exception]
468                         if some input parameter are wrong or the cache itself is not valid
469                         any longer, because any operation before damage it.
470          */
471         virtual OUStringList getItemNames(EItemType eType) const;
472 
473         //---------------------------------------
474 
475         /** @short      check if the required item exist inside this container.
476 
477             @attention  This method exists to supports some UNO container interfaces
478                         only. (e.g. XNameAccess.hasByName()). But inside multithreaded
479                         environments there is no guarantee, that this item still exists, if
480                         its really requested e.g. by calling getItem()!
481                         Be aware of some NoSuchElementExistExceptions ...
482 
483             @param      eType
484                         specify the sub container of this cache, which should be used.
485                         see also EItemType.
486 
487             @param      sItem
488                         the key name of the requested item inside the specified sub container.
489 
490             @throw      [css::uno::Exception]
491                         if some input parameter are wrong or the cache itself is not valid
492                         any longer, because any operation before damage it.
493          */
494         virtual sal_Bool hasItem(      EItemType        eType,
495                                  const ::rtl::OUString& sItem);
496 
497         //---------------------------------------
498 
499         /** @short      return an item, which match the specified type and name.
500 
501             @descr      Because this cache can be used inside multithreaded environments
502                         the caller must be aware of some exceptions - especially a "NoSuchElementException".
503                         May another thread already removed the required item before ...
504 
505             @param      eType
506                         specify the sub container of this cache, which should be used for
507                         searching. see also EItemType.
508 
509             @param      sItem
510                         specify the requested item by its key name.
511 
512             @return     [CacheItem]
513                         the required item if it could be located ...
514                         But we throw an exception if the required item does not exist!
515 
516             @throw      [css::container::NoSuchElementException]
517                         if the required item does not still exist.
518 
519             @throw      [css::uno::Exception]
520                         if some input parameter are wrong or the cache itself is not valid
521                         any longer, because any operation before damage it.
522          */
523         virtual CacheItem getItem(      EItemType        eType,
524                                   const ::rtl::OUString& sItem);
525 
526         //---------------------------------------
527 
528         /** TODO document me ...
529          */
530         virtual void removeItem(      EItemType        eType,
531                                 const ::rtl::OUString& sItem);
532 
533         //---------------------------------------
534 
535         /** TODO document me ...
536          */
537         virtual void setItem(      EItemType        eType ,
538                              const ::rtl::OUString& sItem ,
539                              const CacheItem&       aValue);
540 
541         //---------------------------------------
542 
543         /** TODO document me ...
544          */
545         virtual void refreshItem(      EItemType        eType,
546                                  const ::rtl::OUString& sItem);
547 
548         //---------------------------------------
549 
550         /** @short      add some implicit properties to the given
551                         cache item reference.
552 
553             @descr      Such properties can e.g. finalized or mandatory.
554                         They are not persistent  and not really part of e.g. a
555                         filter not. But they are attributes of a configuration
556                         entry and can influence our container interface.
557 
558             @attention  These properties are not part of the normal CacheItem
559                         returned by the method getItem(). Because getItem() is
560                         used internally too but these specialized properties
561                         are needed at our container services only. So these
562                         function sets are different to allow different handling.
563 
564             @param      eType
565                         specify the sub container of this cache, which should be used for
566                         searching. see also EItemType.
567 
568             @param      sItem
569                         specify the requested item by its key name.
570 
571             @param      rItem
572                         contains already the normal properties of this item,
573                         and will be used as out parameter to add the implicit
574                         attributes there.
575 
576             @throw      [css::uno::Exception]
577                         if an internal error occurred.
578                         Note: If the item is missing inside the underlying configuration
579                         no exception will be thrown. In such case the item is marked as
580                         finalized/mandatory automatically
581                         Reason: May be the item comes from the old configuration package and
582                         was not migrated to the new one. So we can't provide write access
583                         to such items ...
584          */
585         virtual void addStatePropsToItem(      EItemType        eType,
586                                          const ::rtl::OUString& sItem,
587                                                CacheItem&       rItem);
588 
589         //---------------------------------------
590 
591         /** TODO document me
592          */
593         virtual void removeStatePropsFromItem(CacheItem& aValue);
594 
595         //---------------------------------------
596 
597         /** @short      force writing of all changes (which was made after
598                         last flush was called) back to the configuration.
599 
600             @descr      TODO
601 
602             @throw      [css::uno::Exception]
603                         if the cache itself is not valid
604                         any longer, because any operation before damage it.
605          */
606         virtual void flush();
607 
608         //---------------------------------------
609 
610         /** @short      supports a flat type detection for given URL.
611 
612             @descr      Because such detection works on our optimized internal
613                         structures (e.g. mapping from extensions/pattern to type names),
614                         it should be made inside this cache.
615 
616             @param      aURL
617                         URL of the content, which type should be detected.
618                         Its already parsed and splitted into its different parts,
619                         like e.g.: main, jump marks etcpp.
620 
621             @param      rFlatTypes
622                         used as [out] parameter to add all types, which match to the given
623                         URL. Further an information is added for every type. It indicates, how
624                         this type is related to the specified URL (means e.g. if it matches
625                         by extension or URLPattern ...).
626 
627             @attention  Please note: because this cache can be used inside multithreaded
628                         environments, such returned key names can point to some already removed
629                         items! Please be aware of some "NoSuchElementExceptions" if you try to
630                         call any other method of this cache in relation to this key names.
631 
632             @throw      [css::uno::Exception]
633                         if the cache itself is not valid
634                         any longer, because any operation before damage it.
635          */
636         virtual void detectFlatForURL(const css::util::URL& aURL      ,
637                                             FlatDetection&  rFlatTypes) const;
638 
639     //-------------------------------------------
640     // private helper
641 
642     private:
643 
644         //---------------------------------------
645 
646         /** @short      return a reference to one of our internal
647                         sub container, which contains items of the
648                         requested type.
649 
650             @param      eType
651                         specify, which sub container is needed outside.
652 
653             @return     [CacheItemList&]
654                         a reference(!) to the right sub container member.
655 
656             @throw      [css::uno::Exception]
657                         if the required list does not exist.
658          */
659         CacheItemList& impl_getItemList(EItemType eType) const;
660 
661         //---------------------------------------
662 
663         /** @short      return a valid configuration update access
664                         to the underlying configuration package, which
665                         is fix for this cache.
666 
667             @descr      It checks first, if the internal member m_xConfig already
668                         points to an open update access. If not - it opens a new one.
669                         Doing so this method can be called everytimes a configuration
670                         access is needed.
671 
672             @param      eProvider
673                         specify the needed configuration provider.
674                         see EConfigProvider for further informations ...
675 
676             @attention  If a configuration access was opened successfully
677                         all necessary listener connections will be established
678                         too. So this cache will be informed about outside updates.
679          */
680         css::uno::Reference< css::uno::XInterface > impl_openConfig(EConfigProvider eProvide);
681 
682         //---------------------------------------
683 
684         /** @short      tries to open the requested configuration root
685                         using the specified modi.
686 
687             @param      sRoot
688                         specify the configuration root, which should be opened.
689 
690             @param      bReadOnly
691                         enable/disable write access on the returned configuration
692                         object.
693 
694             @param      bLocalesMode
695                         enable/disable special handling of localized configuration
696                         items by the returned configuration object.
697 
698             @return     A valid reference, if the configuration access could be opened
699                         and initialized within the requested modes successfully;
700                         a NULL reference otherwise.
701          */
702         css::uno::Reference< css::uno::XInterface > impl_createConfigAccess(const ::rtl::OUString& sRoot       ,
703                                                                                   sal_Bool         bReadOnly   ,
704                                                                                   sal_Bool         bLocalesMode);
705 
706         //---------------------------------------
707 
708         /** @short      reads the specified configuration key
709                         and return its value.
710 
711             @descr      The specified key must be an absolute configuration path,
712                         which can be splitted into its package and relative path tokens.
713 
714             @attention  Because this function might opens a new configuration
715                         read access for reading one key value only, it should
716                         be used in rare cases only. Its an easy way ... but an
717                         expensive one.
718 
719             @param      sDirectKey
720                         the absolute configuration path, which should be readed.
721 
722             @return     [css::uno::Any]
723                         the value of the requested key.
724                         Can be empty if an internal error occurred or if the requested
725                         key does not exists!
726          */
727         css::uno::Any impl_getDirectCFGValue(const ::rtl::OUString& sDirectKey);
728 
729         //---------------------------------------
730 
731         /** @short      load the underlying configuration into this cache.
732 
733             @descr      Which items should be readed can be regulate by the
734                         parameter eRequiredState. That provides the possibility
735                         to load standard values on startup only and update this
736                         cache later on demand with all available informations.
737 
738             @param      eRequiredState
739                         indicates, which fill state this cache should have afterwards.
740          */
741         void impl_load(EFillState eRequiredState);
742 
743         //---------------------------------------
744 
745         /** @short      validate the whole cache and create
746                         structures for optimized items access.
747 
748             @descr      Wrong cache items will be removed automatically.
749                         Wrong dependencies will be corrected automatically.
750                         If something could not be repaired - an exception
751                         is thrown.
752                         Further some optimized structures will be created.
753                         E.g.: a hash to map extensions to her types.
754 
755             @attention  There is no exception, if the cache could be repaired
756                         but contained wrong elements before!
757 
758             @throw      [css::uno::Exception]
759                         if cache is invalid and could not be repaired.
760          */
761         void impl_validateAndOptimize();
762 
763         //---------------------------------------
764 
765         /** @short      register the specified item for the given type.
766 
767             @descr      Because detect services, frame loader or content handler
768                         are not listed inside the xml configuration as separated
769                         items (they are properties of any type entry!), this method update
770                         the internal lists of such items. That's necessary to have
771                         it accessible for our container interfaces of detect, frame loader
772                         and content handler services.
773 
774             @param      pList
775                         points to a CacheItemList of this filter cache, where
776                         this item registration should be updated or added.
777 
778             @param      sItem
779                         specify the detect service, frame loader or content handler,
780                         which should be registered for the given type.
781 
782             @param      sType
783                         contains the internal type name, where the item should be registered for.
784 
785             @throw      [css::uno::Exception]
786                         If registration failed by any reason.
787                         That does not include double registrations!
788          */
789         void impl_resolveItem4TypeRegistration(      CacheItemList*   pList,
790                                                const ::rtl::OUString& sItem,
791                                                const ::rtl::OUString& sType);
792 
793     //-------------------------------------------
794     // static helper
795 
796     private:
797 
798         //---------------------------------------
799 
800         /** @short  read the specified config set into the cache.
801 
802             @descr  This method provides the following mechanism for reading:
803                     a) read only standard properties of set items
804                     b) read anything
805                     c) read only optional properties and update already existing
806                        items of the specified cache
807 
808             @param  xConfig
809                     API which provides access to the required configuration set.
810 
811             @param  eType
812                     specify the type of config item, which must be interpreted.
813                     Of course this information can be used to locate the right set
814                     at the given xConfig API object.
815 
816             @param  eOption
817                     regulate reading of standard/optional or all properties.
818 
819             @param  pCache
820                     points to the cache member, which should be filled or updated.
821 
822             @throw  [css::uno::Exception]
823                     if an unrecoverable error occur inside this operation.
824          */
825         void impl_loadSet(const css::uno::Reference< css::container::XNameAccess >& xConfig,
826                                 EItemType                                           eType  ,
827                                 EReadOption                                         eOption,
828                                 CacheItemList*                                      pCache );
829 
830         //---------------------------------------
831 
832         /** @short  read the specified container item from the given configuration set.
833 
834             @descr  Its not added to any internal structures here. That must be done
835                     outside this method.
836 
837             @param  xSet
838                     provides access to the configuration set, which includes all items.
839 
840             @param  eType
841                     specify, which container item type must be readed.
842 
843             @param  sItem
844                     means the internal name, which can be used to address the item
845                     properties relative to the given configuration set.
846 
847             @param  eOption
848                     regulate, which properties of the requested item should be read.
849                     See definition of EReadOption for further informations.
850 
851             @throw  [css::uno::Exception]
852                     if an unrecoverable error occur inside this operation.
853          */
854         CacheItem impl_loadItem(const css::uno::Reference< css::container::XNameAccess >& xSet   ,
855                                       EItemType                                           eType  ,
856                                 const ::rtl::OUString&                                    sItem  ,
857                                       EReadOption                                         eOption);
858 
859         //---------------------------------------
860 
861         /** @short  try to load the requested item on demand from the underlying configuration
862                     layer.
863 
864             @descr  The outside code has to be sure, that the item does not already exists
865                     inside this caches. Otherwise it will be loaded twice. This method
866                     doesn't check such constellations!
867 
868             @param  eType
869                     specify the type of config item, which must be interpreted.
870                     Of course this information can be used to locate the right set
871                     at the given xConfig API object.
872 
873             @param  sItem
874                     the set node name of the requested item.
875 
876             @return An iterator, which points directly to the new cached item.
877                     Is a valid iterator if no exception occurred here!
878                     But to improve robustness - it should be checked :-)
879 
880             @throw  [css::container::NoSuchElementException]
881                     if the item does not exists inside the configuration layer too!
882 
883             @throw  [css::uno::Exception]
884                     if an unrecoverable error occurs inside this operation.
885          */
886         CacheItemList::iterator impl_loadItemOnDemand(      EItemType        eType,
887                                                       const ::rtl::OUString& sItem);
888 
889         //---------------------------------------
890 
891         /** TODO */
892         void impl_saveItem(const css::uno::Reference< css::container::XNameReplace >& xSet  ,
893                                  EItemType                                            eType ,
894                            const CacheItem&                                           aValue);
895 
896         //---------------------------------------
897 
898         /** TODO */
899         void impl_addItem2FlushList(      EItemType        eType,
900                                     const ::rtl::OUString& sItem);
901 
902 
903         //---------------------------------------
904 
905         /** TODO */
906         void impl_flushByList(const css::uno::Reference< css::container::XNameAccess >& xSet  ,
907                                     EItemType                                           eType ,
908                               const CacheItemList&                                      rCache,
909                               const OUStringList&                                       lItems);
910 
911         //---------------------------------------
912 
913         /** @short  specify, which save operation is necessary for the specified item.
914 
915             @desrc  If an item of this cache will be added/removed or modified it will
916                     be changed inside memory only first. But we save its name inside a special
917                     list of changed items. If at least the method flush() is called, we use
918                     this list to check if the item was changed/added or removed. This method
919                     checks the exist state of the requested item inside our own cache
920                     and inside the underlying configuration layer to find out, if the item
921                     must be removed/added or modified inside the configuration layer.
922 
923             @param  xSet
924                     points directly to the configuration set, where the item should resist
925                     (if it exists!).
926 
927             @param  rList
928                     points to our internal cache list, where the item should resist
929                     (if it exists!).
930 
931             @param  sItem
932                     the internal name of the item, which should be checked.
933 
934             @return An enum value of type EItemFlushState, which indicates the needed
935                     API operation for updating the underlying configuration layer.
936 
937             @throws An exception if anything failed inside this operation.
938                     e.g. the given configuration set was not open.
939          */
940         EItemFlushState impl_specifyFlushOperation(const css::uno::Reference< css::container::XNameAccess >& xSet ,
941                                                    const CacheItemList&                                      rList,
942                                                    const ::rtl::OUString&                                    sItem);
943 
944         //---------------------------------------
945 
946         /** TODO */
947         void impl_readPatchUINames(const css::uno::Reference< css::container::XNameAccess >& xNode,
948                                          CacheItem&                                          rItem);
949 
950         //---------------------------------------
951 
952         /** TODO */
953         void impl_savePatchUINames(const css::uno::Reference< css::container::XNameReplace >& xNode,
954                                    const CacheItem&                                           rItem);
955 
956         //---------------------------------------
957 
958         /** TODO */
959         void impl_readOldFormat();
960 
961         //---------------------------------------
962 
963         /** TODO */
964         CacheItem impl_readOldItem(const css::uno::Reference< css::container::XNameAccess >& xSet ,
965                                          EItemType                                           eType,
966                                    const ::rtl::OUString&                                    sItem);
967 
968         //---------------------------------------
969 
970         /** TODO */
971         void impl_interpretDataVal4Type(const ::rtl::OUString& sValue,
972                                               sal_Int32        nProp ,
973                                               CacheItem&       rItem );
974 
975         //---------------------------------------
976 
977         /** TODO */
978         void impl_interpretDataVal4Filter(const ::rtl::OUString& sValue,
979                                                 sal_Int32        nProp ,
980                                                 CacheItem&       rItem );
981 
982         //---------------------------------------
983 
984         /** TODO */
985         OUStringList impl_tokenizeString(const ::rtl::OUString& sData     ,
986                                                sal_Unicode      cSeperator);
987 
988         //---------------------------------------
989 
990 #if OSL_DEBUG_LEVEL > 0
991         /** TODO */
992         ::rtl::OUString impl_searchFrameLoaderForType(const ::rtl::OUString& sType) const;
993         ::rtl::OUString impl_searchContentHandlerForType(const ::rtl::OUString& sType) const;
994 #endif
995 
996         //---------------------------------------
997         /** @short check if the specified OOo module is installed.
998 
999             @param  sModule
1000                     the long name of the module (e.g. "com.sun.star.text.TextDocument").
1001 
1002             @return sal_True if the requested module is installed; sal_False otherwise.
1003          */
1004         sal_Bool impl_isModuleInstalled(const ::rtl::OUString& sModule);
1005 
1006         //---------------------------------------
1007 
1008         /** @short  convert a list of flag names to its int representation.
1009 
1010             @param  lNames
1011                     the list of flag names.
1012 
1013             @return [sal_Int32]
1014                     the converted flag field.
1015          */
1016         static sal_Int32 impl_convertFlagNames2FlagField(const css::uno::Sequence< ::rtl::OUString >& lNames);
1017 
1018         //---------------------------------------
1019 
1020         /** @short  convert a flag field value to its list representation of flag names.
1021 
1022             @param  nFlags
1023                     the flag field value
1024 
1025             @return [seq< string >]
1026                     the converted flag name list.
1027          */
1028         static css::uno::Sequence< ::rtl::OUString > impl_convertFlagField2FlagNames(sal_Int32 nFlags);
1029 };
1030 
1031     } // namespace config
1032 } // namespace filter
1033 
1034 #endif // __FILTER_CONFIG_FILTERCACHE_HXX_
1035