LCOV - code coverage report
Current view: top level - filter/source/config/cache - filtercache.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 671 961 69.8 %
Date: 2012-08-25 Functions: 36 44 81.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 804 2147 37.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "filtercache.hxx"
      31                 :            : #include "lateinitlistener.hxx"
      32                 :            : #include "macros.hxx"
      33                 :            : #include "constant.hxx"
      34                 :            : #include "cacheupdatelistener.hxx"
      35                 :            : 
      36                 :            : /*TODO see using below ... */
      37                 :            : #define AS_ENABLE_FILTER_UINAMES
      38                 :            : #define WORKAROUND_EXCEPTION_PROBLEM
      39                 :            : 
      40                 :            : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      41                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      42                 :            : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      43                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      44                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      45                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      46                 :            : #include <com/sun/star/beans/XProperty.hpp>
      47                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      48                 :            : #include <com/sun/star/beans/Property.hpp>
      49                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      50                 :            : #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
      51                 :            : #include <comphelper/sequenceasvector.hxx>
      52                 :            : #include <comphelper/locale.hxx>
      53                 :            : #include <comphelper/processfactory.hxx>
      54                 :            : 
      55                 :            : #include <unotools/configpaths.hxx>
      56                 :            : #include <rtl/ustrbuf.hxx>
      57                 :            : #include <rtl/logfile.hxx>
      58                 :            : #include <rtl/uri.hxx>
      59                 :            : #include <tools/urlobj.hxx>
      60                 :            : #include <tools/wldcrd.hxx>
      61                 :            : 
      62                 :            : #include <comphelper/configurationhelper.hxx>
      63                 :            : 
      64                 :            : 
      65                 :            : namespace filter{
      66                 :            :     namespace config{
      67                 :            : 
      68                 :            : namespace css = ::com::sun::star;
      69                 :            : 
      70                 :            : 
      71                 :            : // Error message in case filter config seems to be corrupted.
      72                 :            : // Note: Dont tell user something about "setup -repair"!
      73                 :            : // Its no longer supported by using native installers ...
      74                 :            : const char MESSAGE_CORRUPTED_FILTERCONFIG[] =
      75                 :            :     "The filter configuration appears to be defective. Please install the office suite again.";
      76                 :            : 
      77                 :        129 : FilterCache::FilterCache()
      78                 :            :     : BaseLock    (                                        )
      79                 :            :     , m_xSMGR     (::comphelper::getProcessServiceFactory())
      80 [ +  - ][ +  - ]:        129 :     , m_eFillState(E_CONTAINS_NOTHING                      )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      81                 :            : {
      82                 :            :     RTL_LOGFILE_TRACE("{ (as96863) FilterCache lifetime");
      83                 :        129 : }
      84                 :            : 
      85                 :            : 
      86                 :            : 
      87 [ +  - ][ +  - ]:        129 : FilterCache::~FilterCache()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      88                 :            : {
      89                 :            :     RTL_LOGFILE_TRACE("} (as96863) FilterCache lifetime");
      90         [ +  + ]:        129 :     if (m_xTypesChglisteners.is())
      91         [ +  - ]:        127 :         m_xTypesChglisteners->stopListening();
      92         [ +  + ]:        129 :     if (m_xFiltersChgListener.is())
      93         [ +  - ]:        127 :         m_xFiltersChgListener->stopListening();
      94         [ -  + ]:        258 : }
      95                 :            : 
      96                 :            : 
      97                 :            : 
      98                 :          2 : FilterCache* FilterCache::clone() const
      99                 :            : {
     100                 :            :     // SAFE -> ----------------------------------
     101         [ +  - ]:          2 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     102                 :            : 
     103 [ +  - ][ +  - ]:          2 :     FilterCache* pClone = new FilterCache();
     104                 :            : 
     105                 :            :     // Dont copy the configuration access points here.
     106                 :            :     // They will be created on demand inside the cloned instance,
     107                 :            :     // if they are needed.
     108                 :            : 
     109         [ +  - ]:          2 :     pClone->m_xSMGR                      = m_xSMGR;
     110                 :            : 
     111         [ +  - ]:          2 :     pClone->m_lTypes                     = m_lTypes;
     112         [ +  - ]:          2 :     pClone->m_lDetectServices            = m_lDetectServices;
     113         [ +  - ]:          2 :     pClone->m_lFilters                   = m_lFilters;
     114         [ +  - ]:          2 :     pClone->m_lFrameLoaders              = m_lFrameLoaders;
     115         [ +  - ]:          2 :     pClone->m_lContentHandlers           = m_lContentHandlers;
     116         [ +  - ]:          2 :     pClone->m_lExtensions2Types          = m_lExtensions2Types;
     117         [ +  - ]:          2 :     pClone->m_lURLPattern2Types          = m_lURLPattern2Types;
     118                 :            : 
     119                 :          2 :     pClone->m_sActLocale                 = m_sActLocale;
     120                 :          2 :     pClone->m_sFormatName                = m_sFormatName;
     121                 :          2 :     pClone->m_sFormatVersion             = m_sFormatVersion;
     122                 :            : 
     123                 :          2 :     pClone->m_eFillState                 = m_eFillState;
     124                 :            : 
     125         [ +  - ]:          2 :     pClone->m_lChangedTypes              = m_lChangedTypes;
     126         [ +  - ]:          2 :     pClone->m_lChangedFilters            = m_lChangedFilters;
     127         [ +  - ]:          2 :     pClone->m_lChangedDetectServices     = m_lChangedDetectServices;
     128         [ +  - ]:          2 :     pClone->m_lChangedFrameLoaders       = m_lChangedFrameLoaders;
     129         [ +  - ]:          2 :     pClone->m_lChangedContentHandlers    = m_lChangedContentHandlers;
     130                 :            : 
     131         [ +  - ]:          2 :     return pClone;
     132                 :            :     // <- SAFE ----------------------------------
     133                 :            : }
     134                 :            : 
     135                 :            : 
     136                 :            : 
     137                 :          2 : void FilterCache::takeOver(const FilterCache& rClone)
     138                 :            : {
     139                 :            :     // SAFE -> ----------------------------------
     140         [ +  - ]:          2 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     141                 :            : 
     142                 :            :     // a)
     143                 :            :     // Dont copy the configuration access points here!
     144                 :            :     // We must use our own ones ...
     145                 :            : 
     146                 :            :     // b)
     147                 :            :     // Further we can ignore the uno service manager.
     148                 :            :     // We should already have a valid instance.
     149                 :            : 
     150                 :            :     // c)
     151                 :            :     // Take over only changed items!
     152                 :            :     // Otherwise we risk the following scenario:
     153                 :            :     // c1) clone_1 contains changed filters
     154                 :            :     // c2) clone_2 container changed types
     155                 :            :     // c3) clone_1 take over changed filters and unchanged types
     156                 :            :     // c4) clone_2 take over unchanged filters(!) and changed types(!)
     157                 :            :     // c5) c4 overwrites c3!
     158                 :            : 
     159         [ -  + ]:          2 :     if (rClone.m_lChangedTypes.size()>0)
     160         [ #  # ]:          0 :         m_lTypes = rClone.m_lTypes;
     161         [ -  + ]:          2 :     if (rClone.m_lChangedDetectServices.size()>0)
     162         [ #  # ]:          0 :         m_lDetectServices = rClone.m_lDetectServices;
     163         [ +  - ]:          2 :     if (rClone.m_lChangedFilters.size()>0)
     164         [ +  - ]:          2 :         m_lFilters = rClone.m_lFilters;
     165         [ -  + ]:          2 :     if (rClone.m_lChangedFrameLoaders.size()>0)
     166         [ #  # ]:          0 :         m_lFrameLoaders = rClone.m_lFrameLoaders;
     167         [ -  + ]:          2 :     if (rClone.m_lChangedContentHandlers.size()>0)
     168         [ #  # ]:          0 :         m_lContentHandlers = rClone.m_lContentHandlers;
     169                 :            : 
     170                 :          2 :     m_lChangedTypes.clear();
     171                 :          2 :     m_lChangedDetectServices.clear();
     172                 :          2 :     m_lChangedFilters.clear();
     173                 :          2 :     m_lChangedFrameLoaders.clear();
     174                 :          2 :     m_lChangedContentHandlers.clear();
     175                 :            : 
     176                 :          2 :     m_sActLocale     = rClone.m_sActLocale;
     177                 :          2 :     m_sFormatName    = rClone.m_sFormatName;
     178                 :          2 :     m_sFormatVersion = rClone.m_sFormatVersion;
     179                 :            : 
     180                 :          2 :     m_eFillState     = rClone.m_eFillState;
     181                 :            : 
     182                 :            :     // renew all dependencies and optimizations
     183                 :            :     // Because we cant be shure, that changed filters on one clone
     184                 :            :     // and changed types of another clone work together.
     185                 :            :     // But here we can check against the lates changes ...
     186 [ +  - ][ +  - ]:          2 :     impl_validateAndOptimize();
     187                 :            :     // <- SAFE ----------------------------------
     188                 :          2 : }
     189                 :            : 
     190                 :            : 
     191                 :            : 
     192                 :      55072 : void FilterCache::load(EFillState eRequired,
     193                 :            : #if OSL_DEBUG_LEVEL > 1
     194                 :            :     sal_Bool bByThread
     195                 :            : #else
     196                 :            :     sal_Bool
     197                 :            : #endif
     198                 :            : )
     199                 :            :     throw(css::uno::Exception)
     200                 :            : {
     201                 :            :     // SAFE -> ----------------------------------
     202         [ +  - ]:      55072 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     203                 :            : 
     204                 :            :     // check if required fill state is already reached ...
     205                 :            :     // There is nothing to do then.
     206         [ +  + ]:      55072 :     if ((m_eFillState & eRequired) == eRequired)
     207                 :      55072 :         return;
     208                 :            : 
     209                 :            : #if OSL_DEBUG_LEVEL > 1
     210                 :            :     if (!bByThread && ((eRequired & E_CONTAINS_ALL) == E_CONTAINS_ALL))
     211                 :            :     {
     212                 :            :         OSL_FAIL("Who disturb our \"fill cache on demand\" feature and force loading of ALL data during office startup? Please optimize your code, so a full filled filter cache is not realy needed here!");
     213                 :            :     }
     214                 :            : #endif
     215                 :            : 
     216                 :            :     // Otherwise load the missing items.
     217                 :            : 
     218                 :            :     // ------------------------------------------
     219                 :            :     // a) load some const values from configration.
     220                 :            :     //    These values are needed there for loading
     221                 :            :     //    config items ...
     222                 :            :     //    Further we load some std items from the
     223                 :            :     //    configuration so we can try to load the first
     224                 :            :     //    office document with a minimal set of values.
     225         [ +  + ]:        574 :     if (m_eFillState == E_CONTAINS_NOTHING)
     226                 :            :     {
     227 [ +  - ][ +  - ]:        127 :         impl_getDirectCFGValue(CFGDIRECTKEY_OFFICELOCALE) >>= m_sActLocale;
     228         [ +  + ]:        127 :         if (m_sActLocale.isEmpty())
     229                 :            :         {
     230                 :            :             _FILTER_CONFIG_LOG_1_("FilterCache::ctor() ... could not specify office locale => use default \"%s\"\n", _FILTER_CONFIG_TO_ASCII_(DEFAULT_OFFICELOCALE));
     231         [ +  - ]:         63 :             m_sActLocale = DEFAULT_OFFICELOCALE;
     232                 :            :         }
     233                 :            : 
     234 [ +  - ][ +  - ]:        127 :         impl_getDirectCFGValue(CFGDIRECTKEY_FORMATNAME) >>= m_sFormatName;
     235         [ -  + ]:        127 :         if (m_sFormatName.isEmpty())
     236 [ #  # ][ #  # ]:          0 :             impl_getDirectCFGValue(CFGDIRECTKEY_PRODUCTNAME) >>= m_sFormatName;
     237                 :            : 
     238         [ -  + ]:        127 :         if (m_sFormatName.isEmpty())
     239                 :            :         {
     240                 :            :             _FILTER_CONFIG_LOG_1_("FilterCache::ctor() ... could not specify format name => use default \"%s\"\n", _FILTER_CONFIG_TO_ASCII_(DEFAULT_FORMATNAME));
     241         [ #  # ]:          0 :             m_sFormatName = DEFAULT_FORMATNAME;
     242                 :            :         }
     243                 :            : 
     244 [ +  - ][ +  - ]:        127 :         impl_getDirectCFGValue(CFGDIRECTKEY_FORMATVERSION) >>= m_sFormatVersion;
     245         [ -  + ]:        127 :         if (m_sFormatVersion.isEmpty())
     246                 :            :         {
     247                 :            :             _FILTER_CONFIG_LOG_1_("FilterCache::ctor() ... could not specify format version => use default \"%s\"\n", _FILTER_CONFIG_TO_ASCII_(DEFAULT_FORMATVERSION));
     248         [ #  # ]:          0 :             m_sFormatVersion = DEFAULT_FORMATVERSION;
     249                 :            :         }
     250                 :            : 
     251                 :            :         // Support the old configuration support. Read it only one times during office runtime!
     252         [ +  - ]:        127 :         impl_readOldFormat();
     253                 :            : 
     254                 :            :         // enable "loadOnDemand" feature ...
     255                 :            :         // Create uno listener, which waits for finishing the office startup
     256                 :            :         // and starts a thread, which calls loadAll() at this filter cache.
     257                 :            :         // Note: Its not a leak to create this listener with new here.
     258                 :            :         // It kills itself after working!
     259         [ +  - ]:        127 :         /* LateInitListener* pLateInit = */ new LateInitListener(m_xSMGR);
     260                 :            :     }
     261                 :            : 
     262                 :            :     // ------------------------------------------
     263                 :            :     // b) If the required fill state was not reached
     264                 :            :     //    but std values was already loaded ...
     265                 :            :     //    we must load some further missing items.
     266 [ +  - ][ +  - ]:      55072 :     impl_load(eRequired);
                 [ +  + ]
     267                 :            :     // <- SAFE
     268                 :            : }
     269                 :            : 
     270                 :            : 
     271                 :            : 
     272                 :        149 : sal_Bool FilterCache::isFillState(FilterCache::EFillState eState) const
     273                 :            :     throw(css::uno::Exception)
     274                 :            : {
     275                 :            :     // SAFE ->
     276         [ +  - ]:        149 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     277         [ +  - ]:        149 :     return ((m_eFillState & eState) == eState);
     278                 :            :     // <- SAFE
     279                 :            : }
     280                 :            : 
     281                 :            : 
     282                 :            : 
     283                 :       7407 : OUStringList FilterCache::getMatchingItemsByProps(      EItemType  eType  ,
     284                 :            :                                                   const CacheItem& lIProps,
     285                 :            :                                                   const CacheItem& lEProps) const
     286                 :            :     throw(css::uno::Exception)
     287                 :            : {
     288                 :            :     // SAFE ->
     289         [ +  - ]:       7407 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     290                 :            : 
     291                 :            :     // search for right list
     292                 :            :     // An exception is thrown - "eType" is unknown.
     293                 :            :     // => rList will be valid everytimes next line is reached.
     294         [ +  - ]:       7407 :     const CacheItemList& rList = impl_getItemList(eType);
     295                 :            : 
     296         [ +  - ]:       7407 :     OUStringList lKeys;
     297                 :            : 
     298                 :            :     // search items, which provides all needed properties of set "lIProps"
     299                 :            :     // but not of set "lEProps"!
     300 [ +  - ][ +  + ]:    1402040 :     for (CacheItemList::const_iterator pIt  = rList.begin();
     301         [ +  - ]:     701020 :                                        pIt != rList.end()  ;
     302                 :            :                                      ++pIt                 )
     303                 :            :     {
     304                 :            :         _FILTER_CONFIG_LOG_1_("getMatchingProps for \"%s\"  ...\n",
     305                 :            :                               _FILTER_CONFIG_TO_ASCII_(pIt->first))
     306 [ +  + ][ +  - ]:     700798 :         if (
                 [ +  + ]
     307 [ +  - ][ +  - ]:     693613 :             (pIt->second.haveProps(lIProps)    ) &&
     308 [ +  - ][ +  - ]:       7185 :             (pIt->second.dontHaveProps(lEProps))
     309                 :            :            )
     310                 :            :         {
     311 [ +  - ][ +  - ]:       7185 :             lKeys.push_back(pIt->first);
     312                 :            :         }
     313                 :            :     }
     314                 :            : 
     315         [ +  - ]:       7407 :     return lKeys;
     316                 :            :     // <- SAFE
     317                 :            : }
     318                 :            : 
     319                 :            : 
     320                 :            : 
     321                 :          6 : sal_Bool FilterCache::hasItems(EItemType eType) const
     322                 :            :     throw(css::uno::Exception)
     323                 :            : {
     324                 :            :     // SAFE ->
     325         [ +  - ]:          6 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     326                 :            : 
     327                 :            :     // search for right list
     328                 :            :     // An exception is thrown - "eType" is unknown.
     329                 :            :     // => rList will be valid everytimes next line is reached.
     330         [ +  - ]:          6 :     const CacheItemList& rList = impl_getItemList(eType);
     331                 :            : 
     332         [ +  - ]:          6 :     return !rList.empty();
     333                 :            :     // <- SAFE
     334                 :            : }
     335                 :            : 
     336                 :            : 
     337                 :            : 
     338                 :        791 : OUStringList FilterCache::getItemNames(EItemType eType) const
     339                 :            :     throw(css::uno::Exception)
     340                 :            : {
     341                 :            :     // SAFE ->
     342         [ +  - ]:        791 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     343                 :            : 
     344                 :            :     // search for right list
     345                 :            :     // An exception is thrown - "eType" is unknown.
     346                 :            :     // => rList will be valid everytimes next line is reached.
     347         [ +  - ]:        791 :     const CacheItemList& rList = impl_getItemList(eType);
     348                 :            : 
     349         [ +  - ]:        791 :     OUStringList lKeys;
     350 [ +  - ][ +  + ]:     171682 :     for (CacheItemList::const_iterator pIt  = rList.begin();
     351         [ +  - ]:      85841 :                                        pIt != rList.end()  ;
     352                 :            :                                      ++pIt                 )
     353                 :            :     {
     354 [ +  - ][ +  - ]:      85050 :         lKeys.push_back(pIt->first);
     355                 :            :     }
     356         [ +  - ]:        791 :     return lKeys;
     357                 :            :     // <- SAFE
     358                 :            : }
     359                 :            : 
     360                 :            : 
     361                 :            : 
     362                 :       7285 : sal_Bool FilterCache::hasItem(      EItemType        eType,
     363                 :            :                               const ::rtl::OUString& sItem)
     364                 :            :     throw(css::uno::Exception)
     365                 :            : {
     366                 :            :     // SAFE ->
     367         [ +  - ]:       7285 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     368                 :            : 
     369                 :            :     // search for right list
     370                 :            :     // An exception is thrown - "eType" is unknown.
     371                 :            :     // => rList will be valid everytimes next line is reached.
     372         [ +  - ]:       7285 :     const CacheItemList& rList = impl_getItemList(eType);
     373                 :            : 
     374                 :            :     // if item could not be found - check if it can be loaded
     375                 :            :     // from the underlying configuration layer. Might it was not already
     376                 :            :     // loaded into this FilterCache object before.
     377         [ +  - ]:       7285 :     CacheItemList::const_iterator pIt = rList.find(sItem);
     378 [ +  - ][ +  + ]:       7285 :     if (pIt != rList.end())
     379                 :       7029 :         return sal_True;
     380                 :            : 
     381                 :            :     try
     382                 :            :     {
     383         [ -  + ]:        256 :         impl_loadItemOnDemand(eType, sItem);
     384                 :            :         // no exception => item could be loaded!
     385                 :          0 :         return sal_True;
     386                 :            :     }
     387         [ +  - ]:        256 :     catch(const css::container::NoSuchElementException&)
     388                 :            :     {}
     389                 :            : 
     390 [ +  - ][ -  + ]:       7541 :     return sal_False;
     391                 :            :     // <- SAFE
     392                 :            : }
     393                 :            : 
     394                 :            : 
     395                 :            : 
     396                 :      27807 : CacheItem FilterCache::getItem(      EItemType        eType,
     397                 :            :                                const ::rtl::OUString& sItem)
     398                 :            :     throw(css::uno::Exception)
     399                 :            : {
     400                 :            :     // SAFE ->
     401         [ +  - ]:      27807 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     402                 :            : 
     403                 :            :     // search for right list
     404                 :            :     // An exception is thrown if "eType" is unknown.
     405                 :            :     // => rList will be valid everytimes next line is reached.
     406         [ +  - ]:      27807 :     CacheItemList& rList = impl_getItemList(eType);
     407                 :            : 
     408                 :            :     // check if item exists ...
     409         [ +  - ]:      27807 :     CacheItemList::iterator pIt = rList.find(sItem);
     410 [ +  - ][ +  + ]:      27807 :     if (pIt == rList.end())
     411                 :            :     {
     412                 :            :         // ... or load it on demand from the
     413                 :            :         // underlying configuration layer.
     414                 :            :         // Note: NoSuchElementException is thrown automaticly here if
     415                 :            :         // item could not be loaded!
     416         [ +  + ]:         93 :         pIt = impl_loadItemOnDemand(eType, sItem);
     417                 :            :     }
     418                 :            : 
     419                 :            :     /* Workaround for #137955#
     420                 :            :        Draw types and filters are installed ... but draw was disabled during setup.
     421                 :            :        We must supress accessing these filters. Otherwise the office can crash.
     422                 :            :        Solution for the next major release: do not install those filters !
     423                 :            :      */
     424         [ +  + ]:      27778 :     if (eType == E_FILTER)
     425                 :            :     {
     426         [ +  - ]:      13415 :         CacheItem& rFilter = pIt->second;
     427                 :      13415 :         ::rtl::OUString sDocService;
     428         [ +  - ]:      13415 :         rFilter[PROPNAME_DOCUMENTSERVICE] >>= sDocService;
     429                 :            : 
     430                 :            :         // In Standalone-Impress the module WriterWeb is not installed
     431                 :            :         // but it is there to load help pages
     432                 :      13415 :         bool bIsHelpFilter = sItem == "writer_web_HTML_help";
     433                 :            : 
     434 [ +  - ][ -  + ]:      13415 :         if ( !bIsHelpFilter && !impl_isModuleInstalled(sDocService) )
         [ -  + ][ +  + ]
     435                 :            :         {
     436                 :          0 :             ::rtl::OUStringBuffer sMsg(256);
     437         [ #  # ]:          0 :             sMsg.appendAscii("The requested filter '"                                                               );
     438         [ #  # ]:          0 :             sMsg.append     (sItem                                                                                  );
     439         [ #  # ]:          0 :             sMsg.appendAscii("' exists ... but it shouldnt; because the corresponding OOo module was not installed.");
     440 [ #  # ][ #  # ]:          0 :             throw css::container::NoSuchElementException(sMsg.makeStringAndClear(), css::uno::Reference< css::uno::XInterface >());
     441                 :      13415 :         }
     442                 :            :     }
     443                 :            : 
     444 [ +  - ][ +  - ]:      27807 :     return pIt->second;
                 [ +  - ]
     445                 :            :     // <- SAFE
     446                 :            : }
     447                 :            : 
     448                 :            : 
     449                 :            : 
     450                 :          4 : void FilterCache::removeItem(      EItemType        eType,
     451                 :            :                              const ::rtl::OUString& sItem)
     452                 :            :     throw(css::uno::Exception)
     453                 :            : {
     454                 :            :     // SAFE ->
     455         [ +  - ]:          4 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     456                 :            : 
     457                 :            :     // search for right list
     458                 :            :     // An exception is thrown - "eType" is unknown.
     459                 :            :     // => rList will be valid everytimes next line is reached.
     460         [ +  - ]:          4 :     CacheItemList& rList = impl_getItemList(eType);
     461                 :            : 
     462         [ +  - ]:          4 :     CacheItemList::iterator pItem = rList.find(sItem);
     463 [ +  - ][ +  + ]:          4 :     if (pItem == rList.end())
     464         [ -  + ]:          2 :         pItem = impl_loadItemOnDemand(eType, sItem); // throws NoSuchELementException!
     465         [ +  - ]:          2 :     rList.erase(pItem);
     466                 :            : 
     467 [ +  - ][ +  - ]:          4 :     impl_addItem2FlushList(eType, sItem);
     468                 :          2 : }
     469                 :            : 
     470                 :            : 
     471                 :            : 
     472                 :          2 : void FilterCache::setItem(      EItemType        eType ,
     473                 :            :                           const ::rtl::OUString& sItem ,
     474                 :            :                           const CacheItem&       aValue)
     475                 :            :     throw(css::uno::Exception)
     476                 :            : {
     477                 :            :     // SAFE ->
     478         [ +  - ]:          2 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     479                 :            : 
     480                 :            :     // search for right list
     481                 :            :     // An exception is thrown - "eType" is unknown.
     482                 :            :     // => rList will be valid everytimes next line is reached.
     483         [ +  - ]:          2 :     CacheItemList& rList = impl_getItemList(eType);
     484                 :            : 
     485                 :            :     // name must be part of the property set too ... otherwhise our
     486                 :            :     // container query cant work correctly
     487         [ +  - ]:          2 :     CacheItem aItem = aValue;
     488 [ +  - ][ +  - ]:          2 :     aItem[PROPNAME_NAME] <<= sItem;
     489         [ +  - ]:          2 :     aItem.validateUINames(m_sActLocale);
     490                 :            : 
     491                 :            :     // remove implicit properties as e.g. FINALIZED or MANDATORY
     492                 :            :     // They cant be saved here and must be readed on demand later, if they are needed.
     493         [ +  - ]:          2 :     removeStatePropsFromItem(aItem);
     494                 :            : 
     495 [ +  - ][ +  - ]:          2 :     rList[sItem] = aItem;
     496                 :            : 
     497 [ +  - ][ +  - ]:          2 :     impl_addItem2FlushList(eType, sItem);
                 [ +  - ]
     498                 :          2 : }
     499                 :            : 
     500                 :            : //-----------------------------------------------
     501                 :          0 : void FilterCache::refreshItem(      EItemType        eType,
     502                 :            :                               const ::rtl::OUString& sItem)
     503                 :            :     throw(css::uno::Exception)
     504                 :            : {
     505                 :            :     // SAFE ->
     506         [ #  # ]:          0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     507 [ #  # ][ #  # ]:          0 :     impl_loadItemOnDemand(eType, sItem);
     508                 :          0 : }
     509                 :            : 
     510                 :            : 
     511                 :            : 
     512                 :      21077 : void FilterCache::addStatePropsToItem(      EItemType        eType,
     513                 :            :                                       const ::rtl::OUString& sItem,
     514                 :            :                                             CacheItem&       rItem)
     515                 :            :     throw(css::uno::Exception)
     516                 :            : {
     517                 :            :     // SAFE ->
     518         [ +  - ]:      21077 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     519                 :            : 
     520                 :            :     // Note: Opening of the configuration layer throws some exceptions
     521                 :            :     // if it failed. So we dont must check any reference here ...
     522                 :      21077 :     css::uno::Reference< css::container::XNameAccess > xPackage;
     523                 :      21077 :     css::uno::Reference< css::container::XNameAccess > xSet;
     524   [ +  +  +  +  :      21077 :     switch(eType)
                      - ]
     525                 :            :     {
     526                 :            :         case E_TYPE :
     527                 :            :             {
     528 [ +  - ][ +  - ]:       8463 :                 xPackage = css::uno::Reference< css::container::XNameAccess >(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW);
                 [ +  - ]
     529 [ +  - ][ +  - ]:       8463 :                 xPackage->getByName(CFGSET_TYPES) >>= xSet;
         [ +  - ][ +  - ]
     530                 :            :             }
     531                 :       8463 :             break;
     532                 :            : 
     533                 :            :         case E_FILTER :
     534                 :            :             {
     535 [ +  - ][ +  - ]:      10863 :                 xPackage = css::uno::Reference< css::container::XNameAccess >(impl_openConfig(E_PROVIDER_FILTERS), css::uno::UNO_QUERY_THROW);
                 [ +  - ]
     536 [ +  - ][ +  - ]:      10863 :                 xPackage->getByName(CFGSET_FILTERS) >>= xSet;
         [ +  - ][ +  - ]
     537                 :            :             }
     538                 :      10863 :             break;
     539                 :            : 
     540                 :            :         case E_FRAMELOADER :
     541                 :            :             {
     542                 :            :                 /* TODO
     543                 :            :                     Hack -->
     544                 :            :                         The default frame loader cant be located inside te normal set of frame loaders.
     545                 :            :                         Its an atomic property inside the misc cfg package. So we cant retrieve the information
     546                 :            :                         about FINALIZED and MANDATORY very easy ... :-(
     547                 :            :                         => set it to readonly/required everytimes :-)
     548                 :            :                 */
     549 [ +  - ][ +  - ]:       1747 :                 css::uno::Any   aDirectValue       = impl_getDirectCFGValue(CFGDIRECTKEY_DEFAULTFRAMELOADER);
     550                 :       1747 :                 ::rtl::OUString sDefaultFrameLoader;
     551 [ +  + ][ +  -  :       5241 :                 if (
             +  -  +  + ]
     552                 :       1747 :                     (aDirectValue >>= sDefaultFrameLoader) &&
     553                 :       1747 :                     (!sDefaultFrameLoader.isEmpty()      ) &&
     554                 :       1747 :                     (sItem.equals(sDefaultFrameLoader)   )
     555                 :            :                    )
     556                 :            :                 {
     557 [ +  - ][ +  - ]:       1707 :                     rItem[PROPNAME_FINALIZED] <<= sal_True;
                 [ +  - ]
     558 [ +  - ][ +  - ]:       1707 :                     rItem[PROPNAME_MANDATORY] <<= sal_True;
                 [ +  - ]
     559                 :      21077 :                     return;
     560                 :            :                 }
     561                 :            :                 /* <-- HACK */
     562                 :            : 
     563 [ +  - ][ +  - ]:         40 :                 xPackage = css::uno::Reference< css::container::XNameAccess >(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW);
                 [ +  - ]
     564 [ +  - ][ +  - ]:       1747 :                 xPackage->getByName(CFGSET_FRAMELOADERS) >>= xSet;
         [ +  - ][ +  + ]
         [ +  + ][ +  - ]
     565                 :            :             }
     566                 :       1747 :             break;
     567                 :            : 
     568                 :            :         case E_CONTENTHANDLER :
     569                 :            :             {
     570 [ +  - ][ +  - ]:          4 :                 xPackage = css::uno::Reference< css::container::XNameAccess >(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW);
                 [ +  - ]
     571 [ +  - ][ +  - ]:          4 :                 xPackage->getByName(CFGSET_CONTENTHANDLERS) >>= xSet;
         [ +  - ][ +  - ]
     572                 :            :             }
     573                 :          4 :             break;
     574                 :          0 :         default: break;
     575                 :            :     }
     576                 :            : 
     577                 :            :     try
     578                 :            :     {
     579                 :      19370 :         css::uno::Reference< css::beans::XProperty > xItem;
     580 [ +  - ][ +  - ]:      19370 :         xSet->getByName(sItem) >>= xItem;
                 [ +  - ]
     581 [ +  - ][ +  - ]:      19370 :         css::beans::Property aDescription = xItem->getAsProperty();
     582                 :            : 
     583                 :      19370 :         sal_Bool bFinalized = ((aDescription.Attributes & css::beans::PropertyAttribute::READONLY  ) == css::beans::PropertyAttribute::READONLY  );
     584                 :      19370 :         sal_Bool bMandatory = ((aDescription.Attributes & css::beans::PropertyAttribute::REMOVEABLE) != css::beans::PropertyAttribute::REMOVEABLE);
     585                 :            : 
     586 [ +  - ][ +  - ]:      19370 :         rItem[PROPNAME_FINALIZED] <<= bFinalized;
                 [ +  - ]
     587 [ +  - ][ +  - ]:      19370 :         rItem[PROPNAME_MANDATORY] <<= bMandatory;
                 [ +  - ]
     588                 :            :     }
     589   [ #  #  #  # ]:          0 :     catch(const css::container::NoSuchElementException&)
     590                 :            :     {
     591                 :            :         /*  Ignore exceptions for missing elements inside configuration.
     592                 :            :             May by the following reason exists:
     593                 :            :                 -   The item does not exists inside the new configuration package org.openoffice.TypeDetection - but
     594                 :            :                     we got it from the old package org.openoffice.Office/TypeDetection. We dont migrate such items
     595                 :            :                     automaticly to the new format. Because it will disturb e.g. the deinstallation of an external filter
     596                 :            :                     package. Because such external filter can remove the old file - but not the automaticly created new one ...
     597                 :            : 
     598                 :            :             => mark item as FINALIZED / MANDATORY, we dont support writing to the old format
     599                 :            :         */
     600   [ #  #  #  #  :          0 :         rItem[PROPNAME_FINALIZED] <<= sal_True;
                   #  # ]
     601   [ #  #  #  #  :          0 :         rItem[PROPNAME_MANDATORY] <<= sal_True;
                   #  # ]
     602 [ +  + ][ +  + ]:      21077 :     }
         [ +  - ][ +  + ]
     603                 :            : 
     604                 :            :     // <- SAFE
     605                 :            : }
     606                 :            : 
     607                 :            : 
     608                 :            : 
     609                 :          2 : void FilterCache::removeStatePropsFromItem(CacheItem& rItem)
     610                 :            :     throw(css::uno::Exception)
     611                 :            : {
     612                 :          2 :     CacheItem::iterator pIt;
     613 [ +  - ][ +  - ]:          2 :     pIt = rItem.find(PROPNAME_FINALIZED);
     614         [ +  - ]:          2 :     if (pIt != rItem.end())
     615         [ +  - ]:          2 :         rItem.erase(pIt);
     616 [ +  - ][ +  - ]:          2 :     pIt = rItem.find(PROPNAME_MANDATORY);
     617         [ +  - ]:          2 :     if (pIt != rItem.end())
     618         [ +  - ]:          2 :         rItem.erase(pIt);
     619                 :          2 : }
     620                 :            : 
     621                 :            : 
     622                 :            : 
     623                 :          2 : void FilterCache::flush()
     624                 :            :     throw(css::uno::Exception)
     625                 :            : {
     626                 :            :     // SAFE ->
     627         [ +  - ]:          2 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     628                 :            : 
     629                 :            :     // renew all dependencies and optimizations
     630         [ +  - ]:          2 :     impl_validateAndOptimize();
     631                 :            : 
     632         [ -  + ]:          2 :     if (m_lChangedTypes.size() > 0)
     633                 :            :     {
     634 [ #  # ][ #  # ]:          0 :         css::uno::Reference< css::container::XNameAccess > xConfig(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW);
     635                 :          0 :         css::uno::Reference< css::container::XNameAccess > xSet   ;
     636                 :            : 
     637 [ #  # ][ #  # ]:          0 :         xConfig->getByName(CFGSET_TYPES) >>= xSet;
         [ #  # ][ #  # ]
     638         [ #  # ]:          0 :         impl_flushByList(xSet, E_TYPE, m_lTypes, m_lChangedTypes);
     639                 :            : 
     640         [ #  # ]:          0 :         css::uno::Reference< css::util::XChangesBatch > xFlush(xConfig, css::uno::UNO_QUERY);
     641 [ #  # ][ #  # ]:          0 :         xFlush->commitChanges();
     642                 :            :     }
     643                 :            : 
     644         [ +  - ]:          2 :     if (m_lChangedFilters.size() > 0)
     645                 :            :     {
     646 [ +  - ][ +  - ]:          2 :         css::uno::Reference< css::container::XNameAccess > xConfig(impl_openConfig(E_PROVIDER_FILTERS), css::uno::UNO_QUERY_THROW);
     647                 :          2 :         css::uno::Reference< css::container::XNameAccess > xSet   ;
     648                 :            : 
     649 [ +  - ][ +  - ]:          2 :         xConfig->getByName(CFGSET_FILTERS) >>= xSet;
         [ +  - ][ +  - ]
     650         [ +  - ]:          2 :         impl_flushByList(xSet, E_FILTER, m_lFilters, m_lChangedFilters);
     651                 :            : 
     652         [ +  - ]:          2 :         css::uno::Reference< css::util::XChangesBatch > xFlush(xConfig, css::uno::UNO_QUERY);
     653 [ +  - ][ +  - ]:          2 :         xFlush->commitChanges();
     654         [ +  - ]:          2 :     }
     655                 :            : 
     656                 :            :     /*TODO FrameLoader/ContentHandler must be flushed here too ... */
     657                 :          2 : }
     658                 :            : 
     659                 :            : 
     660                 :            : 
     661                 :          2 : void FilterCache::impl_flushByList(const css::uno::Reference< css::container::XNameAccess >& xSet  ,
     662                 :            :                                          EItemType                                           eType ,
     663                 :            :                                    const CacheItemList&                                      rCache,
     664                 :            :                                    const OUStringList&                                       lItems)
     665                 :            :     throw(css::uno::Exception)
     666                 :            : {
     667         [ +  - ]:          2 :     css::uno::Reference< css::container::XNameContainer >   xAddRemoveSet = css::uno::Reference< css::container::XNameContainer >  (xSet, css::uno::UNO_QUERY);
     668         [ +  - ]:          2 :     css::uno::Reference< css::container::XNameReplace >     xReplaceeSet  = css::uno::Reference< css::container::XNameReplace >    (xSet, css::uno::UNO_QUERY);
     669         [ +  - ]:          2 :     css::uno::Reference< css::lang::XSingleServiceFactory > xFactory      = css::uno::Reference< css::lang::XSingleServiceFactory >(xSet, css::uno::UNO_QUERY);
     670                 :            : 
     671 [ +  - ][ +  + ]:          8 :     for (OUStringList::const_iterator pIt  = lItems.begin();
     672                 :          4 :                                       pIt != lItems.end()  ;
     673                 :            :                                     ++pIt                  )
     674                 :            :     {
     675                 :          2 :         const ::rtl::OUString& sItem  = *pIt;
     676         [ +  - ]:          2 :               EItemFlushState  eState = impl_specifyFlushOperation(xSet, rCache, sItem);
     677   [ -  -  -  + ]:          2 :         switch(eState)
     678                 :            :         {
     679                 :            :             case E_ITEM_REMOVED :
     680                 :            :             {
     681 [ #  # ][ #  # ]:          0 :                 xAddRemoveSet->removeByName(sItem);
     682                 :            :             }
     683                 :          0 :             break;
     684                 :            : 
     685                 :            :             case E_ITEM_ADDED :
     686                 :            :             {
     687 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< css::container::XNameReplace > xItem (xFactory->createInstance(), css::uno::UNO_QUERY);
                 [ #  # ]
     688                 :            : 
     689                 :            :                 // special case. no exception - but not a valid item => set must be finalized or mandatory!
     690                 :            :                 // Reject flush operation by throwing an exception. At least one item couldnt be flushed.
     691         [ #  # ]:          0 :                 if (!xItem.is())
     692                 :            :                     throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant add item. Set is finalized or mandatory!" )),
     693 [ #  # ][ #  # ]:          0 :                                               css::uno::Reference< css::uno::XInterface >()                                   );
     694                 :            : 
     695         [ #  # ]:          0 :                 CacheItemList::const_iterator pItem = rCache.find(sItem);
     696 [ #  # ][ #  # ]:          0 :                 impl_saveItem(xItem, eType, pItem->second);
     697 [ #  # ][ #  # ]:          0 :                 xAddRemoveSet->insertByName(sItem, css::uno::makeAny(xItem));
                 [ #  # ]
     698                 :            :             }
     699                 :          0 :             break;
     700                 :            : 
     701                 :            :             case E_ITEM_CHANGED :
     702                 :            :             {
     703                 :          0 :                 css::uno::Reference< css::container::XNameReplace > xItem;
     704 [ #  # ][ #  # ]:          0 :                 xSet->getByName(sItem) >>= xItem;
                 [ #  # ]
     705                 :            : 
     706                 :            :                 // special case. no exception - but not a valid item => it must be finalized or mandatory!
     707                 :            :                 // Reject flush operation by throwing an exception. At least one item couldnt be flushed.
     708         [ #  # ]:          0 :                 if (!xItem.is())
     709                 :            :                     throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant change item. Its finalized or mandatory!" )),
     710 [ #  # ][ #  # ]:          0 :                                               css::uno::Reference< css::uno::XInterface >()                                    );
     711                 :            : 
     712         [ #  # ]:          0 :                 CacheItemList::const_iterator pItem = rCache.find(sItem);
     713 [ #  # ][ #  # ]:          0 :                 impl_saveItem(xItem, eType, pItem->second);
     714                 :            :             }
     715                 :          0 :             break;
     716                 :          2 :             default: break;
     717                 :            :         }
     718                 :          2 :     }
     719                 :          2 : }
     720                 :            : 
     721                 :            : 
     722                 :            : 
     723                 :       2401 : void FilterCache::detectFlatForURL(const css::util::URL& aURL      ,
     724                 :            :                                          FlatDetection&  rFlatTypes) const
     725                 :            :     throw(css::uno::Exception)
     726                 :            : {
     727                 :            :     // extract extension from URL, so it can be used directly as key into our hash map!
     728                 :            :     // Note further: It must be converted to lower case, because the optimize hash
     729                 :            :     // (which maps extensions to types) work with lower case key strings!
     730         [ +  - ]:       2401 :     INetURLObject   aParser    (aURL.Main);
     731                 :            :     ::rtl::OUString sExtension = aParser.getExtension(INetURLObject::LAST_SEGMENT       ,
     732                 :            :                                                       sal_True                          ,
     733         [ +  - ]:       2401 :                                                       INetURLObject::DECODE_WITH_CHARSET);
     734                 :       2401 :     sExtension = sExtension.toAsciiLowerCase();
     735                 :            : 
     736                 :            :     // SAFE -> ----------------------------------
     737         [ +  - ]:       2401 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     738                 :            : 
     739                 :            :     //*******************************************
     740                 :            :     // i) Step over all well known URL pattern
     741                 :            :     //    and add registered types to the return list too
     742                 :            :     //    Do it as first one - because: if a type match by a
     743                 :            :     //    pattern a following deep detection can be supressed!
     744                 :            :     //    Further we can stop after first match ...
     745 [ +  - ][ +  + ]:      64966 :     for (CacheItemRegistration::const_iterator pPattReg  = m_lURLPattern2Types.begin();
     746         [ +  - ]:      32483 :                                                pPattReg != m_lURLPattern2Types.end()  ;
     747                 :            :                                              ++pPattReg                               )
     748                 :            :     {
     749 [ +  - ][ +  - ]:      30082 :         WildCard aPatternCheck(pPattReg->first);
     750 [ +  - ][ +  - ]:      30082 :         if (aPatternCheck.Matches(aURL.Main))
         [ +  - ][ +  + ]
     751                 :            :         {
     752         [ +  - ]:       1127 :             const OUStringList& rTypesForPattern = pPattReg->second;
     753                 :            : 
     754                 :       1127 :             FlatDetectionInfo aInfo;
     755                 :       1127 :             aInfo.sType = *(rTypesForPattern.begin());
     756                 :       1127 :             aInfo.bMatchByPattern = sal_True;
     757                 :            : 
     758         [ +  - ]:       1127 :             rFlatTypes.push_back(aInfo);
     759                 :            : //          return;
     760                 :            :         }
     761         [ +  - ]:      30082 :     }
     762                 :            : 
     763                 :            :     //*******************************************
     764                 :            :     // ii) search types matching to the given extension.
     765                 :            :     //     Copy every macthing type without changing its order!
     766                 :            :     //     Because preferred types was added as first one during
     767                 :            :     //     loading configuration.
     768         [ +  - ]:       2401 :     CacheItemRegistration::const_iterator pExtReg = m_lExtensions2Types.find(sExtension);
     769 [ +  + ][ +  - ]:       2401 :     if (pExtReg != m_lExtensions2Types.end())
     770                 :            :     {
     771         [ +  - ]:        967 :         const OUStringList& rTypesForExtension = pExtReg->second;
     772 [ +  - ][ +  + ]:       5232 :         for (OUStringList::const_iterator pIt  = rTypesForExtension.begin();
     773                 :       2616 :                                           pIt != rTypesForExtension.end()  ;
     774                 :            :                                         ++pIt                              )
     775                 :            :         {
     776                 :       1649 :             FlatDetectionInfo aInfo;
     777                 :       1649 :             aInfo.sType             = *pIt;
     778                 :       1649 :             aInfo.bMatchByExtension = sal_True;
     779                 :            : 
     780         [ +  - ]:       1649 :             rFlatTypes.push_back(aInfo);
     781                 :       1649 :         }
     782                 :            :     }
     783                 :            : 
     784 [ +  - ][ +  - ]:       2401 :     aLock.clear();
                 [ +  - ]
     785                 :            :     // <- SAFE ----------------------------------
     786                 :       2401 : }
     787                 :            : 
     788                 :       8204 : const CacheItemList& FilterCache::impl_getItemList(EItemType eType) const
     789                 :            : {
     790                 :            :     // SAFE -> ----------------------------------
     791         [ +  - ]:       8204 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     792                 :            : 
     793   [ +  +  +  +  :       8204 :     switch(eType)
                   +  - ]
     794                 :            :     {
     795                 :       4573 :         case E_TYPE           : return m_lTypes          ;
     796                 :        925 :         case E_FILTER         : return m_lFilters        ;
     797                 :       2377 :         case E_FRAMELOADER    : return m_lFrameLoaders   ;
     798                 :        163 :         case E_CONTENTHANDLER : return m_lContentHandlers;
     799                 :        166 :         case E_DETECTSERVICE  : return m_lDetectServices ;
     800                 :            : 
     801                 :            :     }
     802                 :            : 
     803                 :            :     throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unknown sub container requested." )),
     804 [ #  # ][ #  # ]:       8204 :                                             css::uno::Reference< css::uno::XInterface >()                      );
                 [ +  - ]
     805                 :            :     // <- SAFE ----------------------------------
     806                 :            : }
     807                 :            : 
     808                 :      35098 : CacheItemList& FilterCache::impl_getItemList(EItemType eType)
     809                 :            : {
     810                 :            :     // SAFE -> ----------------------------------
     811         [ +  - ]:      35098 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     812                 :            : 
     813   [ +  +  +  +  :      35098 :     switch(eType)
                   -  - ]
     814                 :            :     {
     815                 :      15090 :         case E_TYPE           : return m_lTypes          ;
     816                 :      14731 :         case E_FILTER         : return m_lFilters        ;
     817                 :       5259 :         case E_FRAMELOADER    : return m_lFrameLoaders   ;
     818                 :         18 :         case E_CONTENTHANDLER : return m_lContentHandlers;
     819                 :          0 :         case E_DETECTSERVICE  : return m_lDetectServices ;
     820                 :            : 
     821                 :            :     }
     822                 :            : 
     823                 :            :     throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unknown sub container requested." )),
     824 [ #  # ][ #  # ]:      35098 :                                             css::uno::Reference< css::uno::XInterface >()                      );
                 [ +  - ]
     825                 :            :     // <- SAFE ----------------------------------
     826                 :            : }
     827                 :            : 
     828                 :      20416 : css::uno::Reference< css::uno::XInterface > FilterCache::impl_openConfig(EConfigProvider eProvider)
     829                 :            :     throw(css::uno::Exception)
     830                 :            : {
     831         [ +  - ]:      20416 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     832                 :            : 
     833                 :      20416 :     ::rtl::OUString                              sPath      ;
     834                 :      20416 :     css::uno::Reference< css::uno::XInterface >* pConfig = 0;
     835                 :      20416 :     css::uno::Reference< css::uno::XInterface >  xOld       ;
     836                 :      20416 :     ::rtl::OString                               sRtlLog    ;
     837                 :            : 
     838   [ +  +  +  +  :      20416 :     switch(eProvider)
                      - ]
     839                 :            :     {
     840                 :            :         case E_PROVIDER_TYPES :
     841                 :            :         {
     842         [ +  + ]:       8970 :             if (m_xConfigTypes.is())
     843                 :       8843 :                 return m_xConfigTypes;
     844         [ +  - ]:        127 :             sPath           = CFGPACKAGE_TD_TYPES;
     845                 :        127 :             pConfig         = &m_xConfigTypes;
     846                 :        127 :             sRtlLog         = ::rtl::OString("framework (as96863) ::FilterCache::impl_openconfig(E_PROVIDER_TYPES)");
     847                 :            :         }
     848                 :        127 :         break;
     849                 :            : 
     850                 :            :         case E_PROVIDER_FILTERS :
     851                 :            :         {
     852         [ +  + ]:      11078 :             if (m_xConfigFilters.is())
     853                 :      10951 :                 return m_xConfigFilters;
     854         [ +  - ]:        127 :             sPath           = CFGPACKAGE_TD_FILTERS;
     855                 :        127 :             pConfig         = &m_xConfigFilters;
     856                 :        127 :             sRtlLog         = ::rtl::OString("framework (as96863) ::FilterCache::impl_openconfig(E_PROVIDER_FILTERS)");
     857                 :            :         }
     858                 :        127 :         break;
     859                 :            : 
     860                 :            :         case E_PROVIDER_OTHERS :
     861                 :            :         {
     862         [ +  + ]:        241 :             if (m_xConfigOthers.is())
     863                 :        128 :                 return m_xConfigOthers;
     864         [ +  - ]:        113 :             sPath   = CFGPACKAGE_TD_OTHERS;
     865                 :        113 :             pConfig = &m_xConfigOthers;
     866                 :        113 :             sRtlLog = ::rtl::OString("framework (as96863) ::FilterCache::impl_openconfig(E_PROVIDER_OTHERS)");
     867                 :            :         }
     868                 :        113 :         break;
     869                 :            : 
     870                 :            :         case E_PROVIDER_OLD :
     871                 :            :         {
     872                 :            :             // This special provider is used to work with
     873                 :            :             // the old configuration format only. Its not cached!
     874         [ +  - ]:        127 :             sPath   = CFGPACKAGE_TD_OLD;
     875                 :        127 :             pConfig = &xOld;
     876                 :        127 :             sRtlLog = ::rtl::OString("framework (as96863) ::FilterCache::impl_openconfig(E_PROVIDER_OLD)");
     877                 :            :         }
     878                 :        127 :         break;
     879                 :            : 
     880 [ #  # ][ #  # ]:          0 :         default : throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "These configuration node isnt supported here for open!" )), 0);
                 [ #  # ]
     881                 :            :     }
     882                 :            : 
     883                 :            :     {
     884                 :            :         RTL_LOGFILE_CONTEXT(aLog, sRtlLog.getStr());
     885                 :            :         *pConfig = impl_createConfigAccess(sPath    ,
     886                 :            :                                            sal_False,   // bReadOnly
     887 [ +  - ][ +  - ]:        494 :                                            sal_True );  // bLocalesMode
     888                 :            :     }
     889                 :            : 
     890                 :            : 
     891                 :            :     // Start listening for changes on that configuration access.
     892      [ +  +  + ]:        494 :     switch(eProvider)
     893                 :            :     {
     894                 :            :         case E_PROVIDER_TYPES:
     895                 :            :         {
     896         [ +  - ]:        127 :             m_xTypesChglisteners.set(new CacheUpdateListener(m_xSMGR, *this, *pConfig, FilterCache::E_TYPE));
     897         [ +  - ]:        127 :             m_xTypesChglisteners->startListening();
     898                 :            :         }
     899                 :        127 :         break;
     900                 :            :         case E_PROVIDER_FILTERS:
     901                 :            :         {
     902         [ +  - ]:        127 :             m_xFiltersChgListener.set(new CacheUpdateListener(m_xSMGR, *this, *pConfig, FilterCache::E_FILTER));
     903         [ +  - ]:        127 :             m_xFiltersChgListener->startListening();
     904                 :            :         }
     905                 :        127 :         break;
     906                 :            :         default:
     907                 :        240 :         break;
     908                 :            :     }
     909                 :            : 
     910         [ +  - ]:      20416 :     return *pConfig;
     911                 :            : }
     912                 :            : 
     913                 :            : 
     914                 :            : 
     915                 :       2706 : css::uno::Any FilterCache::impl_getDirectCFGValue(const ::rtl::OUString& sDirectKey)
     916                 :            : {
     917                 :       2706 :     ::rtl::OUString sRoot;
     918                 :       2706 :     ::rtl::OUString sKey ;
     919                 :            : 
     920   [ +  -  +  -  :       8118 :     if (
           -  + ][ -  + ]
     921         [ +  - ]:       2706 :         (!::utl::splitLastFromConfigurationPath(sDirectKey, sRoot, sKey)) ||
     922                 :       2706 :         (sRoot.isEmpty()                                             ) ||
     923                 :       2706 :         (sKey.isEmpty()                                              )
     924                 :            :        )
     925                 :          0 :         return css::uno::Any();
     926                 :            : 
     927                 :            :     css::uno::Reference< css::uno::XInterface > xCfg = impl_createConfigAccess(sRoot    ,
     928                 :            :                                                                                sal_True ,  // bReadOnly
     929         [ +  - ]:       2706 :                                                                                sal_False); // bLocalesMode
     930         [ -  + ]:       2706 :     if (!xCfg.is())
     931                 :          0 :         return css::uno::Any();
     932                 :            : 
     933         [ +  - ]:       2706 :     css::uno::Reference< css::container::XNameAccess > xAccess(xCfg, css::uno::UNO_QUERY);
     934         [ -  + ]:       2706 :     if (!xAccess.is())
     935                 :          0 :         return css::uno::Any();
     936                 :            : 
     937                 :       2706 :     css::uno::Any aValue;
     938                 :            :     try
     939                 :            :     {
     940 [ +  - ][ +  - ]:       2706 :         aValue = xAccess->getByName(sKey);
     941                 :            :     }
     942      [ #  #  # ]:          0 :     catch(const css::uno::RuntimeException&)
     943                 :          0 :         { throw; }
     944                 :            :     #if OSL_DEBUG_LEVEL > 0
     945                 :            :     catch(const css::uno::Exception& ex)
     946                 :            :     #else
     947         [ #  # ]:          0 :     catch(const css::uno::Exception&)
     948                 :            :     #endif
     949                 :            :         {
     950                 :            :             #if OSL_DEBUG_LEVEL > 0
     951                 :            :             OSL_FAIL(::rtl::OUStringToOString(ex.Message, RTL_TEXTENCODING_UTF8).getStr());
     952                 :            :             #endif
     953                 :          0 :             aValue.clear();
     954                 :            :         }
     955                 :            : 
     956                 :       2706 :     return aValue;
     957                 :            : }
     958                 :            : 
     959                 :            : 
     960                 :            : 
     961                 :       3200 : css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess(const ::rtl::OUString& sRoot       ,
     962                 :            :                                                                                        sal_Bool         bReadOnly   ,
     963                 :            :                                                                                        sal_Bool         bLocalesMode)
     964                 :            : {
     965                 :            :     // SAFE ->
     966         [ +  - ]:       3200 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     967                 :            : 
     968                 :       3200 :     css::uno::Reference< css::uno::XInterface > xCfg;
     969                 :            : 
     970                 :            :     try
     971                 :            :     {
     972                 :            :         css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
     973                 :            :             css::configuration::theDefaultProvider::get(
     974 [ +  - ][ +  - ]:       3200 :                 comphelper::getComponentContext(m_xSMGR)));
     975                 :            : 
     976         [ +  - ]:       3200 :         ::comphelper::SequenceAsVector< css::uno::Any > lParams;
     977                 :       3200 :         css::beans::NamedValue aParam;
     978                 :            : 
     979                 :            :         // set root path
     980         [ +  - ]:       3200 :         aParam.Name    = _FILTER_CONFIG_FROM_ASCII_("nodepath");
     981         [ +  - ]:       3200 :         aParam.Value <<= sRoot;
     982 [ +  - ][ +  - ]:       3200 :         lParams.push_back(css::uno::makeAny(aParam));
     983                 :            : 
     984                 :            :         // enable "all locales mode" ... if required
     985         [ +  + ]:       3200 :         if (bLocalesMode)
     986                 :            :         {
     987         [ +  - ]:        494 :             aParam.Name    = _FILTER_CONFIG_FROM_ASCII_("locale");
     988 [ +  - ][ +  - ]:        494 :             aParam.Value <<= _FILTER_CONFIG_FROM_ASCII_("*"     );
     989 [ +  - ][ +  - ]:        494 :             lParams.push_back(css::uno::makeAny(aParam));
     990                 :            :         }
     991                 :            : 
     992                 :            :         // open it
     993         [ +  + ]:       3200 :         if (bReadOnly)
     994 [ +  - ][ +  - ]:       2706 :             xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONACCESS, lParams.getAsConstList());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     995                 :            :         else
     996 [ +  - ][ +  - ]:        494 :             xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONUPDATEACCESS, lParams.getAsConstList());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     997                 :            : 
     998                 :            :         // If configuration could not be opened ... but factory method does not throwed an exception
     999                 :            :         // trigger throwing of our own CorruptedFilterConfigurationException.
    1000                 :            :         // Let message empty. The normal exception text show enough informations to the user.
    1001         [ -  + ]:       3200 :         if (! xCfg.is())
    1002                 :            :             throw css::uno::Exception(
    1003                 :            :                     _FILTER_CONFIG_FROM_ASCII_("Got NULL reference on opening configuration file ... but no exception."),
    1004 [ #  # ][ #  # ]:       3200 :                     css::uno::Reference< css::uno::XInterface >());
    1005                 :            :     }
    1006         [ #  # ]:          0 :     catch(const css::uno::Exception& ex)
    1007                 :            :     {
    1008                 :            :         throw css::document::CorruptedFilterConfigurationException(
    1009                 :            :                 rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1010                 :            :                 css::uno::Reference< css::uno::XInterface >(),
    1011         [ #  # ]:          0 :                 ex.Message);
    1012                 :            :     }
    1013                 :            : 
    1014         [ +  - ]:       3200 :     return xCfg;
    1015                 :            :     // <- SAFE
    1016                 :            : }
    1017                 :            : 
    1018                 :            : 
    1019                 :            : 
    1020                 :        578 : void FilterCache::impl_validateAndOptimize()
    1021                 :            :     throw(css::uno::Exception)
    1022                 :            : {
    1023                 :            :     // SAFE ->
    1024         [ +  - ]:        578 :     ::osl::ResettableMutexGuard aLock(m_aLock);
    1025                 :            : 
    1026                 :            :     RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::impl_validateAndOptimize");
    1027                 :            : 
    1028                 :            :     // First check if any filter or type could be readed
    1029                 :            :     // from the underlying configuration!
    1030                 :        578 :     sal_Bool bSomeTypesShouldExist   = ((m_eFillState & E_CONTAINS_STANDARD       ) == E_CONTAINS_STANDARD       );
    1031                 :        578 :     sal_Bool bAllFiltersShouldExist  = ((m_eFillState & E_CONTAINS_FILTERS        ) == E_CONTAINS_FILTERS        );
    1032                 :            : 
    1033                 :            : #if OSL_DEBUG_LEVEL > 0
    1034                 :            : 
    1035                 :            :     sal_Int32             nWarnings = 0;
    1036                 :            : 
    1037                 :            : //  sal_Bool bAllTypesShouldExist    = ((m_eFillState & E_CONTAINS_TYPES          ) == E_CONTAINS_TYPES          );
    1038                 :            :     sal_Bool bAllLoadersShouldExist  = ((m_eFillState & E_CONTAINS_FRAMELOADERS   ) == E_CONTAINS_FRAMELOADERS   );
    1039                 :            :     sal_Bool bAllHandlersShouldExist = ((m_eFillState & E_CONTAINS_CONTENTHANDLERS) == E_CONTAINS_CONTENTHANDLERS);
    1040                 :            : #endif
    1041                 :            : 
    1042   [ +  -  +  - ]:       1503 :     if (
           [ +  +  -  + ]
                 [ -  + ]
    1043                 :            :         (
    1044                 :            :             (bSomeTypesShouldExist) &&
    1045                 :        578 :             (m_lTypes.size() < 1  )
    1046                 :            :         ) ||
    1047                 :            :         (
    1048                 :            :             (bAllFiltersShouldExist) &&
    1049                 :        347 :             (m_lFilters.size() < 1 )
    1050                 :            :         )
    1051                 :            :        )
    1052                 :            :     {
    1053                 :            :         throw css::document::CorruptedFilterConfigurationException(
    1054                 :            :                 rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1055                 :            :                 css::uno::Reference< css::uno::XInterface >(),
    1056 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The list of types or filters is empty." )));
    1057                 :            :     }
    1058                 :            : 
    1059                 :            :     // Create a log for all detected problems, which
    1060                 :            :     // occur in the next few lines.
    1061                 :            :     // If there are some real errors throw a RuntimException!
    1062                 :            :     // If there are some warnings only, show an assertion.
    1063                 :        578 :     sal_Int32             nErrors   = 0;
    1064                 :        578 :     ::rtl::OUStringBuffer sLog(256);
    1065                 :            : 
    1066                 :        578 :     CacheItemList::iterator pIt;
    1067                 :            : 
    1068 [ +  - ][ +  + ]:      75772 :     for (pIt = m_lTypes.begin(); pIt != m_lTypes.end(); ++pIt)
                 [ +  - ]
    1069                 :            :     {
    1070         [ +  - ]:      75194 :         ::rtl::OUString sType = pIt->first;
    1071 [ +  - ][ +  - ]:      75194 :         CacheItem       aType = pIt->second;
    1072                 :            : 
    1073                 :            :         // create list of all known detect services / frame loader / content handler on demand
    1074                 :            :         // Because these informations are available as type properties!
    1075                 :      75194 :         ::rtl::OUString sDetectService;
    1076         [ +  - ]:      75194 :         aType[PROPNAME_DETECTSERVICE ] >>= sDetectService;
    1077         [ +  + ]:      75194 :         if (!sDetectService.isEmpty())
    1078         [ +  - ]:      69414 :             impl_resolveItem4TypeRegistration(&m_lDetectServices, sDetectService, sType);
    1079                 :            : 
    1080                 :            :         // get its registration for file Extensions AND(!) URLPattern ...
    1081                 :            :         // It doesnt matter if these items exists or if our
    1082                 :            :         // used index access create some default ones ...
    1083                 :            :         // only in case there is no filled set of Extensions AND
    1084                 :            :         // no filled set of URLPattern -> we must try to remove this invalid item
    1085                 :            :         // from this cache!
    1086         [ +  - ]:      75194 :         css::uno::Sequence< ::rtl::OUString > lExtensions;
    1087         [ +  - ]:      75194 :         css::uno::Sequence< ::rtl::OUString > lURLPattern;
    1088 [ +  - ][ +  - ]:      75194 :         aType[PROPNAME_EXTENSIONS] >>= lExtensions;
    1089 [ +  - ][ +  - ]:      75194 :         aType[PROPNAME_URLPATTERN] >>= lURLPattern;
    1090                 :      75194 :         sal_Int32 ce = lExtensions.getLength();
    1091                 :      75194 :         sal_Int32 cu = lURLPattern.getLength();
    1092                 :            : 
    1093                 :            : #if OSL_DEBUG_LEVEL > 0
    1094                 :            : 
    1095                 :            :         ::rtl::OUString sInternalTypeNameCheck;
    1096                 :            :         aType[PROPNAME_NAME] >>= sInternalTypeNameCheck;
    1097                 :            :         if (!sInternalTypeNameCheck.equals(sType))
    1098                 :            :         {
    1099                 :            :             sLog.appendAscii("Warning\t:\t");
    1100                 :            :             sLog.appendAscii("The type \"" );
    1101                 :            :             sLog.append     (sType         );
    1102                 :            :             sLog.appendAscii("\" does support the property \"Name\" correctly.\n");
    1103                 :            :             ++nWarnings;
    1104                 :            :         }
    1105                 :            : 
    1106                 :            :         if (!ce && !cu)
    1107                 :            :         {
    1108                 :            :             sLog.appendAscii("Warning\t:\t");
    1109                 :            :             sLog.appendAscii("The type \"" );
    1110                 :            :             sLog.append     (sType         );
    1111                 :            :             sLog.appendAscii("\" does not contain any URL pattern nor any extensions.\n");
    1112                 :            :             ++nWarnings;
    1113                 :            :         }
    1114                 :            : #endif
    1115                 :            : 
    1116                 :            :         // create an optimized registration for this type to
    1117                 :            :         // its set list of extensions/url pattern. If its a "normal" type
    1118                 :            :         // set it at the end of this optimized list. But if its
    1119                 :            :         // a "Preferred" one - set it to the front of this list.
    1120                 :            :         // Of course multiple "Preferred" registrations can occur
    1121                 :            :         // (they shouldn't - but they can!) ... Ignore it. The last
    1122                 :            :         // preferred type is useable in the same manner then every
    1123                 :            :         // other type!
    1124                 :      75194 :         sal_Bool bPreferred = sal_False;
    1125         [ +  - ]:      75194 :         aType[PROPNAME_PREFERRED] >>= bPreferred;
    1126                 :            : 
    1127                 :      75194 :         const ::rtl::OUString* pExtensions = lExtensions.getConstArray();
    1128         [ +  + ]:     179288 :         for (sal_Int32 e=0; e<ce; ++e)
    1129                 :            :         {
    1130                 :            :             // Note: We must be sure that address the right hash entry
    1131                 :            :             // does not depend from any upper/lower case problems ...
    1132                 :     104094 :             ::rtl::OUString sNormalizedExtension = pExtensions[e].toAsciiLowerCase();
    1133                 :            : 
    1134         [ +  - ]:     104094 :             OUStringList& lTypesForExtension = m_lExtensions2Types[sNormalizedExtension];
    1135 [ +  - ][ +  - ]:     104094 :             if (::std::find(lTypesForExtension.begin(), lTypesForExtension.end(), sType) != lTypesForExtension.end())
                 [ +  + ]
    1136                 :      81233 :                 continue;
    1137                 :            : 
    1138         [ +  + ]:      22861 :             if (bPreferred)
    1139         [ +  - ]:       4636 :                 lTypesForExtension.insert(lTypesForExtension.begin(), sType);
    1140                 :            :             else
    1141         [ +  - ]:      22861 :                 lTypesForExtension.push_back(sType);
    1142         [ +  + ]:     104094 :         }
    1143                 :            : 
    1144                 :      75194 :         const ::rtl::OUString* pURLPattern = lURLPattern.getConstArray();
    1145         [ +  + ]:      82446 :         for (sal_Int32 u=0; u<cu; ++u)
    1146                 :            :         {
    1147         [ +  - ]:       7252 :             OUStringList& lTypesForURLPattern = m_lURLPattern2Types[pURLPattern[u]];
    1148 [ +  - ][ +  - ]:       7252 :             if (::std::find(lTypesForURLPattern.begin(), lTypesForURLPattern.end(), sType) != lTypesForURLPattern.end())
                 [ +  + ]
    1149                 :       5664 :                 continue;
    1150                 :            : 
    1151         [ -  + ]:       1588 :             if (bPreferred)
    1152         [ #  # ]:          0 :                 lTypesForURLPattern.insert(lTypesForURLPattern.begin(), sType);
    1153                 :            :             else
    1154         [ +  - ]:       1588 :                 lTypesForURLPattern.push_back(sType);
    1155                 :            :         }
    1156                 :            : 
    1157                 :            : #if OSL_DEBUG_LEVEL > 0
    1158                 :            : 
    1159                 :            :         // Dont check cross references between types and filters, if
    1160                 :            :         // not all filters read from disk!
    1161                 :            :         // OK - this cache can read single filters on demand too ...
    1162                 :            :         // but then the fill state of this cache shouldnt be set to E_CONTAINS_FILTERS!
    1163                 :            :         if (!bAllFiltersShouldExist)
    1164                 :            :             continue;
    1165                 :            : 
    1166                 :            :         ::rtl::OUString sPrefFilter;
    1167                 :            :         aType[PROPNAME_PREFERREDFILTER] >>= sPrefFilter;
    1168                 :            :         if (sPrefFilter.isEmpty())
    1169                 :            :         {
    1170                 :            :             // OK - there is no filter for this type. But thats not an error.
    1171                 :            :             // May be it can be handled by a ContentHandler ...
    1172                 :            :             // But at this time its not guaranteed that there is any ContentHandler
    1173                 :            :             // or FrameLoader inside this cache ... but on disk ...
    1174                 :            :             sal_Bool bReferencedByLoader  = sal_True;
    1175                 :            :             sal_Bool bReferencedByHandler = sal_True;
    1176                 :            :             if (bAllLoadersShouldExist)
    1177                 :            :                 bReferencedByLoader = !impl_searchFrameLoaderForType(sType).isEmpty();
    1178                 :            : 
    1179                 :            :             if (bAllHandlersShouldExist)
    1180                 :            :                 bReferencedByHandler = !impl_searchContentHandlerForType(sType).isEmpty();
    1181                 :            : 
    1182                 :            :             if (
    1183                 :            :                 (!bReferencedByLoader ) &&
    1184                 :            :                 (!bReferencedByHandler)
    1185                 :            :                )
    1186                 :            :             {
    1187                 :            :                 sLog.appendAscii("Warning\t:\t"                                            );
    1188                 :            :                 sLog.appendAscii("The type \""                                             );
    1189                 :            :                 sLog.append     (sType                                                     );
    1190                 :            :                 sLog.appendAscii("\" isnt used by any filter, loader or content handler.\n");
    1191                 :            :                 ++nWarnings;
    1192                 :            :             }
    1193                 :            :         }
    1194                 :            : 
    1195                 :            :         if (!sPrefFilter.isEmpty())
    1196                 :            :         {
    1197                 :            :             CacheItemList::const_iterator pIt2 = m_lFilters.find(sPrefFilter);
    1198                 :            :             if (pIt2 == m_lFilters.end())
    1199                 :            :             {
    1200                 :            :                 if (bAllFiltersShouldExist)
    1201                 :            :                 {
    1202                 :            :                     ++nWarnings; // preferred filters can point to a non-installed office module ! no error ... it's a warning only .-(
    1203                 :            :                     sLog.appendAscii("error\t:\t");
    1204                 :            :                 }
    1205                 :            :                 else
    1206                 :            :                 {
    1207                 :            :                     ++nWarnings;
    1208                 :            :                     sLog.appendAscii("warning\t:\t");
    1209                 :            :                 }
    1210                 :            : 
    1211                 :            :                 sLog.appendAscii("The type \""                      );
    1212                 :            :                 sLog.append     (sType                              );
    1213                 :            :                 sLog.appendAscii("\" points to an invalid filter \"");
    1214                 :            :                 sLog.append     (sPrefFilter                        );
    1215                 :            :                 sLog.appendAscii("\".\n"                            );
    1216                 :            : 
    1217                 :            :                 continue;
    1218                 :            :             }
    1219                 :            : 
    1220                 :            :             CacheItem       aPrefFilter   = pIt2->second;
    1221                 :            :             ::rtl::OUString sFilterTypeReg;
    1222                 :            :             aPrefFilter[PROPNAME_TYPE] >>= sFilterTypeReg;
    1223                 :            :             if (sFilterTypeReg != sType)
    1224                 :            :             {
    1225                 :            :                 sLog.appendAscii("error\t:\t"                       );
    1226                 :            :                 sLog.appendAscii("The preferred filter \""          );
    1227                 :            :                 sLog.append     (sPrefFilter                        );
    1228                 :            :                 sLog.appendAscii("\" of type \""                    );
    1229                 :            :                 sLog.append     (sType                              );
    1230                 :            :                 sLog.appendAscii("is registered for another type \"");
    1231                 :            :                 sLog.append     (sFilterTypeReg                     );
    1232                 :            :                 sLog.appendAscii("\".\n"                            );
    1233                 :            :                 ++nErrors;
    1234                 :            :             }
    1235                 :            : 
    1236                 :            :             sal_Int32 nFlags = 0;
    1237                 :            :             aPrefFilter[PROPNAME_FLAGS] >>= nFlags;
    1238                 :            :             if ((nFlags & FLAGVAL_IMPORT) != FLAGVAL_IMPORT)
    1239                 :            :             {
    1240                 :            :                 sLog.appendAscii("error\t:\t"                   );
    1241                 :            :                 sLog.appendAscii("The preferred filter \""      );
    1242                 :            :                 sLog.append     (sPrefFilter                    );
    1243                 :            :                 sLog.appendAscii("\" of type \""                );
    1244                 :            :                 sLog.append     (sType                          );
    1245                 :            :                 sLog.appendAscii("\" is not an IMPORT filter!\n");
    1246                 :            :                 ++nErrors;
    1247                 :            :             }
    1248                 :            : 
    1249                 :            :             ::rtl::OUString sInternalFilterNameCheck;
    1250                 :            :             aPrefFilter[PROPNAME_NAME] >>= sInternalFilterNameCheck;
    1251                 :            :             if (!sInternalFilterNameCheck.equals(sPrefFilter))
    1252                 :            :             {
    1253                 :            :                 sLog.appendAscii("Warning\t:\t"  );
    1254                 :            :                 sLog.appendAscii("The filter \"" );
    1255                 :            :                 sLog.append     (sPrefFilter     );
    1256                 :            :                 sLog.appendAscii("\" does support the property \"Name\" correctly.\n");
    1257                 :            :                 ++nWarnings;
    1258                 :            :             }
    1259                 :            :         }
    1260                 :            : #endif
    1261 [ +  - ][ +  - ]:      75194 :     }
                 [ +  - ]
    1262                 :            : 
    1263                 :            :     // create dependencies between the global default frame loader
    1264                 :            :     // and all types (and of course if registered filters), which
    1265                 :            :     // does not registered for any other loader.
    1266 [ +  - ][ +  - ]:        578 :     css::uno::Any   aDirectValue       = impl_getDirectCFGValue(CFGDIRECTKEY_DEFAULTFRAMELOADER);
    1267                 :        578 :     ::rtl::OUString sDefaultFrameLoader;
    1268                 :            : 
    1269         [ -  + ]:       1156 :     if (
           [ +  -  -  + ]
    1270                 :        578 :         (!(aDirectValue >>= sDefaultFrameLoader)) ||
    1271                 :        578 :         (sDefaultFrameLoader.isEmpty()       )
    1272                 :            :        )
    1273                 :            :     {
    1274         [ #  # ]:          0 :         sLog.appendAscii("error\t:\t"                                );
    1275         [ #  # ]:          0 :         sLog.appendAscii("There is no valid default frame loader!?\n");
    1276                 :          0 :         ++nErrors;
    1277                 :            :     }
    1278                 :            : 
    1279                 :            :     // a) get list of all well known types
    1280                 :            :     // b) step over all well known frame loader services
    1281                 :            :     //    and remove all types from list a), which already
    1282                 :            :     //    referenced by a loader b)
    1283         [ +  - ]:        578 :     OUStringList lTypes = getItemNames(E_TYPE);
    1284 [ +  - ][ +  + ]:       4962 :     for (  pIt  = m_lFrameLoaders.begin();
    1285         [ +  - ]:       2481 :            pIt != m_lFrameLoaders.end()  ;
    1286                 :            :          ++pIt                           )
    1287                 :            :     {
    1288                 :            :         // Note: of course the default loader must be ignored here.
    1289                 :            :         // Because we replace its registration later completly with all
    1290                 :            :         // types, which are not referenced by any other loader.
    1291                 :            :         // So we can avaoid our code against the complexity of a diff!
    1292         [ +  - ]:       1903 :         ::rtl::OUString sLoader = pIt->first;
    1293         [ +  + ]:       1903 :         if (sLoader.equals(sDefaultFrameLoader))
    1294                 :        451 :             continue;
    1295                 :            : 
    1296         [ +  - ]:       1452 :         CacheItem&     rLoader   = pIt->second;
    1297         [ +  - ]:       1452 :         css::uno::Any& rTypesReg = rLoader[PROPNAME_TYPES];
    1298         [ +  - ]:       1452 :         OUStringList   lTypesReg (rTypesReg);
    1299                 :            : 
    1300 [ +  - ][ +  - ]:       8712 :         for (OUStringList::const_iterator pTypesReg  = lTypesReg.begin();
                 [ +  + ]
    1301                 :       4356 :                                           pTypesReg != lTypesReg.end()  ;
    1302                 :            :                                         ++pTypesReg                     )
    1303                 :            :         {
    1304         [ +  - ]:       2904 :             OUStringList::iterator pTypeCheck = ::std::find(lTypes.begin(), lTypes.end(), *pTypesReg);
    1305 [ +  - ][ +  + ]:       2904 :             if (pTypeCheck != lTypes.end())
    1306         [ +  - ]:       1815 :                 lTypes.erase(pTypeCheck);
    1307                 :            :         }
    1308         [ +  + ]:       1903 :     }
    1309                 :            : 
    1310         [ +  - ]:        578 :     CacheItem& rDefaultLoader = m_lFrameLoaders[sDefaultFrameLoader];
    1311 [ +  - ][ +  - ]:        578 :     rDefaultLoader[PROPNAME_NAME ] <<= sDefaultFrameLoader;
    1312 [ +  - ][ +  - ]:        578 :     rDefaultLoader[PROPNAME_TYPES] <<= lTypes.getAsConstList();
         [ +  - ][ +  - ]
    1313                 :            : 
    1314         [ +  - ]:        578 :     ::rtl::OUString sLogOut = sLog.makeStringAndClear();
    1315                 :            :     OSL_ENSURE(!nErrors, ::rtl::OUStringToOString(sLogOut,RTL_TEXTENCODING_UTF8).getStr());
    1316         [ -  + ]:        578 :     if (nErrors>0)
    1317                 :            :         throw css::document::CorruptedFilterConfigurationException(
    1318                 :            :                 rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1319                 :            :                 css::uno::Reference< css::uno::XInterface >(),
    1320         [ #  # ]:          0 :                 sLogOut);
    1321         [ +  - ]:        578 :     OSL_ENSURE(!nWarnings, ::rtl::OUStringToOString(sLogOut,RTL_TEXTENCODING_UTF8).getStr());
    1322                 :            : 
    1323                 :            :     // <- SAFE
    1324                 :        578 : }
    1325                 :            : 
    1326                 :            : 
    1327                 :            : 
    1328                 :          4 : void FilterCache::impl_addItem2FlushList(      EItemType        eType,
    1329                 :            :                                          const ::rtl::OUString& sItem)
    1330                 :            :     throw(css::uno::Exception)
    1331                 :            : {
    1332                 :          4 :     OUStringList* pList = 0;
    1333   [ -  +  -  -  :          4 :     switch(eType)
                   -  - ]
    1334                 :            :     {
    1335                 :            :         case E_TYPE :
    1336                 :          0 :                 pList = &m_lChangedTypes;
    1337                 :          0 :                 break;
    1338                 :            : 
    1339                 :            :         case E_FILTER :
    1340                 :          4 :                 pList = &m_lChangedFilters;
    1341                 :          4 :                 break;
    1342                 :            : 
    1343                 :            :         case E_FRAMELOADER :
    1344                 :          0 :                 pList = &m_lChangedFrameLoaders;
    1345                 :          0 :                 break;
    1346                 :            : 
    1347                 :            :         case E_CONTENTHANDLER :
    1348                 :          0 :                 pList = &m_lChangedContentHandlers;
    1349                 :          0 :                 break;
    1350                 :            : 
    1351                 :            :         case E_DETECTSERVICE :
    1352                 :          0 :                 pList = &m_lChangedDetectServices;
    1353                 :          0 :                 break;
    1354                 :            : 
    1355 [ #  # ][ #  # ]:          0 :         default : throw css::uno::Exception(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unsupported item type" )), 0);
                 [ #  # ]
    1356                 :            :     }
    1357                 :            : 
    1358 [ +  - ][ +  - ]:          4 :     OUStringList::const_iterator pItem = ::std::find(pList->begin(), pList->end(), sItem);
    1359 [ +  - ][ +  + ]:          4 :     if (pItem == pList->end())
    1360         [ +  - ]:          2 :         pList->push_back(sItem);
    1361                 :          4 : }
    1362                 :            : 
    1363                 :            : 
    1364                 :            : 
    1365                 :          2 : FilterCache::EItemFlushState FilterCache::impl_specifyFlushOperation(const css::uno::Reference< css::container::XNameAccess >& xSet ,
    1366                 :            :                                                                      const CacheItemList&                                      rList,
    1367                 :            :                                                                      const ::rtl::OUString&                                    sItem)
    1368                 :            :     throw(css::uno::Exception)
    1369                 :            : {
    1370                 :          2 :     sal_Bool bExistsInConfigLayer = xSet->hasByName(sItem);
    1371         [ +  - ]:          2 :     sal_Bool bExistsInMemory      = (rList.find(sItem) != rList.end());
    1372                 :            : 
    1373                 :          2 :     EItemFlushState eState( E_ITEM_UNCHANGED );
    1374                 :            : 
    1375                 :            :     // !? ... such situation can occur, if an item was added and(!) removed before it was flushed :-)
    1376 [ +  - ][ +  - ]:          2 :     if (!bExistsInConfigLayer && !bExistsInMemory)
    1377                 :          2 :         eState = E_ITEM_UNCHANGED;
    1378                 :            :     else
    1379 [ #  # ][ #  # ]:          0 :     if (!bExistsInConfigLayer && bExistsInMemory)
    1380                 :          0 :         eState = E_ITEM_ADDED;
    1381                 :            :     else
    1382 [ #  # ][ #  # ]:          0 :     if (bExistsInConfigLayer && bExistsInMemory)
    1383                 :          0 :         eState = E_ITEM_CHANGED;
    1384                 :            :     else
    1385 [ #  # ][ #  # ]:          0 :     if (bExistsInConfigLayer && !bExistsInMemory)
    1386                 :          0 :         eState = E_ITEM_REMOVED;
    1387                 :            : 
    1388                 :          2 :     return eState;
    1389                 :            : }
    1390                 :            : 
    1391                 :            : 
    1392                 :            : 
    1393                 :      69414 : void FilterCache::impl_resolveItem4TypeRegistration(      CacheItemList*   pList,
    1394                 :            :                                                     const ::rtl::OUString& sItem,
    1395                 :            :                                                     const ::rtl::OUString& sType)
    1396                 :            :     throw(css::uno::Exception)
    1397                 :            : {
    1398         [ +  - ]:      69414 :     CacheItem& rItem = (*pList)[sItem];
    1399                 :            :     // In case its a new created entry (automaticly done by the boost::unordered_map index operator!)
    1400                 :            :     // we must be shure, that this entry has its own name as property available.
    1401                 :            :     // Its needed later at our container interface!
    1402 [ +  - ][ +  - ]:      69414 :     rItem[PROPNAME_NAME] <<= sItem;
    1403                 :            : 
    1404 [ +  - ][ +  - ]:      69414 :     OUStringList lTypeRegs(rItem[PROPNAME_TYPES]);
    1405 [ +  - ][ +  + ]:      69414 :     if (::std::find(lTypeRegs.begin(), lTypeRegs.end(), sType) == lTypeRegs.end())
                 [ +  - ]
    1406                 :            :     {
    1407         [ +  - ]:      15241 :         lTypeRegs.push_back(sType);
    1408 [ +  - ][ +  - ]:      15241 :         rItem[PROPNAME_TYPES] <<= lTypeRegs.getAsConstList();
         [ +  - ][ +  - ]
    1409                 :      69414 :     }
    1410                 :      69414 : }
    1411                 :            : 
    1412                 :            : 
    1413                 :            : 
    1414                 :        574 : void FilterCache::impl_load(EFillState eRequiredState)
    1415                 :            :     throw(css::uno::Exception)
    1416                 :            : {
    1417                 :            :     // SAFE ->
    1418         [ +  - ]:        574 :     ::osl::ResettableMutexGuard aLock(m_aLock);
    1419                 :            : 
    1420                 :            :     // Attention: Detect services are part of the standard set!
    1421                 :            :     // So there is no need to handle it seperatly.
    1422                 :            : 
    1423                 :            :     // ------------------------------------------
    1424                 :            :     // a) The standard set of config value is needed.
    1425 [ +  + ][ +  + ]:        574 :     if (
    1426                 :            :         ((eRequiredState & E_CONTAINS_STANDARD) == E_CONTAINS_STANDARD) &&
    1427                 :            :         ((m_eFillState   & E_CONTAINS_STANDARD) != E_CONTAINS_STANDARD)
    1428                 :            :        )
    1429                 :            :     {
    1430                 :            :         // Attention! If config couldnt be opened successfully
    1431                 :            :         // and exception os thrown automaticly and must be forwarded
    1432                 :            :         // to our calli ...
    1433 [ +  - ][ +  - ]:        127 :         css::uno::Reference< css::container::XNameAccess > xTypes(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW);
    1434                 :            :         {
    1435                 :            :             RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::load std");
    1436         [ +  - ]:        127 :             impl_loadSet(xTypes, E_TYPE, E_READ_STANDARD, &m_lTypes);
    1437                 :        127 :         }
    1438                 :            :     }
    1439                 :            : 
    1440                 :            :     // ------------------------------------------
    1441                 :            :     // b) We need all type informations ...
    1442 [ +  + ][ +  + ]:        574 :     if (
    1443                 :            :         ((eRequiredState & E_CONTAINS_TYPES) == E_CONTAINS_TYPES) &&
    1444                 :            :         ((m_eFillState   & E_CONTAINS_TYPES) != E_CONTAINS_TYPES)
    1445                 :            :        )
    1446                 :            :     {
    1447                 :            :         // Attention! If config couldnt be opened successfully
    1448                 :            :         // and exception os thrown automaticly and must be forwarded
    1449                 :            :         // to our calli ...
    1450 [ +  - ][ +  - ]:        125 :         css::uno::Reference< css::container::XNameAccess > xTypes(impl_openConfig(E_PROVIDER_TYPES), css::uno::UNO_QUERY_THROW);
    1451                 :            :         {
    1452                 :            :             RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::load all types");
    1453         [ +  - ]:        125 :             impl_loadSet(xTypes, E_TYPE, E_READ_UPDATE, &m_lTypes);
    1454                 :        125 :         }
    1455                 :            :     }
    1456                 :            : 
    1457                 :            :     // ------------------------------------------
    1458                 :            :     // c) We need all filter informations ...
    1459 [ +  + ][ +  + ]:        574 :     if (
    1460                 :            :         ((eRequiredState & E_CONTAINS_FILTERS) == E_CONTAINS_FILTERS) &&
    1461                 :            :         ((m_eFillState   & E_CONTAINS_FILTERS) != E_CONTAINS_FILTERS)
    1462                 :            :        )
    1463                 :            :     {
    1464                 :            :         // Attention! If config couldnt be opened successfully
    1465                 :            :         // and exception os thrown automaticly and must be forwarded
    1466                 :            :         // to our calli ...
    1467 [ +  - ][ +  - ]:        125 :         css::uno::Reference< css::container::XNameAccess > xFilters(impl_openConfig(E_PROVIDER_FILTERS), css::uno::UNO_QUERY_THROW);
    1468                 :            :         {
    1469                 :            :             RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::load all filters");
    1470         [ +  - ]:        125 :             impl_loadSet(xFilters, E_FILTER, E_READ_ALL, &m_lFilters);
    1471                 :        125 :         }
    1472                 :            :     }
    1473                 :            : 
    1474                 :            :     // ------------------------------------------
    1475                 :            :     // c) We need all frame loader informations ...
    1476 [ +  + ][ +  + ]:        574 :     if (
    1477                 :            :         ((eRequiredState & E_CONTAINS_FRAMELOADERS) == E_CONTAINS_FRAMELOADERS) &&
    1478                 :            :         ((m_eFillState   & E_CONTAINS_FRAMELOADERS) != E_CONTAINS_FRAMELOADERS)
    1479                 :            :        )
    1480                 :            :     {
    1481                 :            :         // Attention! If config couldnt be opened successfully
    1482                 :            :         // and exception os thrown automaticly and must be forwarded
    1483                 :            :         // to our calli ...
    1484 [ +  - ][ +  - ]:        113 :         css::uno::Reference< css::container::XNameAccess > xLoaders(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW);
    1485                 :            :         {
    1486                 :            :             RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::load all frame loader");
    1487         [ +  - ]:        113 :             impl_loadSet(xLoaders, E_FRAMELOADER, E_READ_ALL, &m_lFrameLoaders);
    1488                 :        113 :         }
    1489                 :            :     }
    1490                 :            : 
    1491                 :            :     // ------------------------------------------
    1492                 :            :     // d) We need all content handler informations ...
    1493 [ +  + ][ +  + ]:        574 :     if (
    1494                 :            :         ((eRequiredState & E_CONTAINS_CONTENTHANDLERS) == E_CONTAINS_CONTENTHANDLERS) &&
    1495                 :            :         ((m_eFillState   & E_CONTAINS_CONTENTHANDLERS) != E_CONTAINS_CONTENTHANDLERS)
    1496                 :            :        )
    1497                 :            :     {
    1498                 :            :         // Attention! If config couldnt be opened successfully
    1499                 :            :         // and exception os thrown automaticly and must be forwarded
    1500                 :            :         // to our calli ...
    1501 [ +  - ][ +  - ]:         76 :         css::uno::Reference< css::container::XNameAccess > xHandlers(impl_openConfig(E_PROVIDER_OTHERS), css::uno::UNO_QUERY_THROW);
    1502                 :            :         {
    1503                 :            :             RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::FilterCache::load all content handler");
    1504         [ +  - ]:         76 :             impl_loadSet(xHandlers, E_CONTENTHANDLER, E_READ_ALL, &m_lContentHandlers);
    1505                 :         76 :         }
    1506                 :            :     }
    1507                 :            : 
    1508                 :            :     // update fill state. Note: its a bit field, which combines different parts.
    1509                 :        574 :     m_eFillState = (EFillState) ((sal_Int32)m_eFillState | (sal_Int32)eRequiredState);
    1510                 :            : 
    1511                 :            :     // any data readed?
    1512                 :            :     // yes! => validate it and update optimized structures.
    1513 [ +  - ][ +  - ]:        574 :     impl_validateAndOptimize();
    1514                 :            : 
    1515                 :            :     // <- SAFE
    1516                 :        574 : }
    1517                 :            : 
    1518                 :            : 
    1519                 :            : 
    1520                 :        566 : void FilterCache::impl_loadSet(const css::uno::Reference< css::container::XNameAccess >& xConfig,
    1521                 :            :                                      EItemType                                           eType  ,
    1522                 :            :                                      EReadOption                                         eOption,
    1523                 :            :                                      CacheItemList*                                      pCache )
    1524                 :            :     throw(css::uno::Exception)
    1525                 :            : {
    1526                 :            :     // get access to the right configuration set
    1527                 :        566 :     ::rtl::OUString sSetName;
    1528   [ +  +  +  +  :        566 :     switch(eType)
                      - ]
    1529                 :            :     {
    1530                 :            :         case E_TYPE :
    1531         [ +  - ]:        252 :             sSetName = CFGSET_TYPES;
    1532                 :        252 :             break;
    1533                 :            : 
    1534                 :            :         case E_FILTER :
    1535         [ +  - ]:        125 :             sSetName = CFGSET_FILTERS;
    1536                 :        125 :             break;
    1537                 :            : 
    1538                 :            :         case E_FRAMELOADER :
    1539         [ +  - ]:        113 :             sSetName = CFGSET_FRAMELOADERS;
    1540                 :        113 :             break;
    1541                 :            : 
    1542                 :            :         case E_CONTENTHANDLER :
    1543         [ +  - ]:         76 :             sSetName = CFGSET_CONTENTHANDLERS;
    1544                 :         76 :             break;
    1545                 :          0 :         default: break;
    1546                 :            :     }
    1547                 :            : 
    1548                 :        566 :     css::uno::Reference< css::container::XNameAccess > xSet;
    1549         [ +  - ]:        566 :     css::uno::Sequence< ::rtl::OUString >              lItems;
    1550                 :            : 
    1551                 :            :     try
    1552                 :            :     {
    1553 [ +  - ][ +  - ]:        566 :         css::uno::Any aVal = xConfig->getByName(sSetName);
    1554 [ +  - ][ +  - ]:        566 :         if (!(aVal >>= xSet) || !xSet.is())
         [ -  + ][ -  + ]
    1555                 :            :         {
    1556                 :          0 :             ::rtl::OUStringBuffer sMsg(256);
    1557         [ #  # ]:          0 :             sMsg.appendAscii("Could not open configuration set \"");
    1558         [ #  # ]:          0 :             sMsg.append     (sSetName                             );
    1559         [ #  # ]:          0 :             sMsg.appendAscii("\"."                                );
    1560                 :            :             throw css::uno::Exception(
    1561                 :            :                     sMsg.makeStringAndClear(),
    1562 [ #  # ][ #  # ]:          0 :                     css::uno::Reference< css::uno::XInterface >());
    1563                 :            :         }
    1564 [ +  - ][ +  - ]:        566 :         lItems = xSet->getElementNames();
         [ +  - ][ +  - ]
    1565                 :            :     }
    1566         [ #  # ]:          0 :     catch(const css::uno::Exception& ex)
    1567                 :            :     {
    1568                 :            :         throw css::document::CorruptedFilterConfigurationException(
    1569                 :            :                 rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1570                 :            :                 css::uno::Reference< css::uno::XInterface >(),
    1571         [ #  # ]:          0 :                 ex.Message);
    1572                 :            :     }
    1573                 :            : 
    1574                 :            :     // get names of all existing sub items of this set
    1575                 :            :     // step over it and fill internal cache structures.
    1576                 :            : 
    1577                 :            :     // But dont update optimized structures like e.g. hash
    1578                 :            :     // for mapping extensions to its types!
    1579                 :            : 
    1580                 :        566 :     const ::rtl::OUString* pItems = lItems.getConstArray();
    1581                 :        566 :           sal_Int32        c      = lItems.getLength();
    1582         [ +  + ]:      57738 :     for (sal_Int32 i=0; i<c; ++i)
    1583                 :            :     {
    1584         [ +  - ]:      57172 :         CacheItemList::iterator pItem = pCache->find(pItems[i]);
    1585      [ +  +  - ]:      57172 :         switch(eOption)
    1586                 :            :         {
    1587                 :            :             // a) read a standard set of properties only or read all
    1588                 :            :             case E_READ_STANDARD :
    1589                 :            :             case E_READ_ALL      :
    1590                 :            :             {
    1591                 :            :                 try
    1592                 :            :                 {
    1593 [ +  - ][ +  - ]:      40923 :                     (*pCache)[pItems[i]] = impl_loadItem(xSet, eType, pItems[i], eOption);
         [ +  - ][ +  - ]
    1594                 :            :                 }
    1595         [ #  # ]:          0 :                 catch(const css::uno::Exception& ex)
    1596                 :            :                 {
    1597                 :            :                     throw css::document::CorruptedFilterConfigurationException(
    1598                 :            :                             rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1599                 :            :                             css::uno::Reference< css::uno::XInterface >(),
    1600         [ #  # ]:          0 :                             ex.Message);
    1601                 :            :                 }
    1602                 :            :             }
    1603                 :      40923 :             break;
    1604                 :            : 
    1605                 :            :             // b) read optional properties only!
    1606                 :            :             //    All items must already exist inside our cache.
    1607                 :            :             //    But they must be updated.
    1608                 :            :             case E_READ_UPDATE :
    1609                 :            :             {
    1610 [ +  - ][ -  + ]:      16249 :                 if (pItem == pCache->end())
    1611                 :            :                 {
    1612                 :          0 :                     ::rtl::OUStringBuffer sMsg(256);
    1613         [ #  # ]:          0 :                     sMsg.appendAscii("item \""                 );
    1614         [ #  # ]:          0 :                     sMsg.append     (pItems[i]                 );
    1615         [ #  # ]:          0 :                     sMsg.appendAscii("\" not found for update!");
    1616                 :            :                     throw css::uno::Exception(sMsg.makeStringAndClear()                    ,
    1617 [ #  # ][ #  # ]:          0 :                                               css::uno::Reference< css::uno::XInterface >());
    1618                 :            :                 }
    1619                 :            :                 try
    1620                 :            :                 {
    1621         [ +  - ]:      16249 :                     CacheItem aItem = impl_loadItem(xSet, eType, pItems[i], eOption);
    1622 [ +  - ][ +  - ]:      16249 :                     pItem->second.update(aItem);
                 [ +  - ]
    1623                 :            :                 }
    1624         [ #  # ]:          0 :                 catch(const css::uno::Exception& ex)
    1625                 :            :                 {
    1626                 :            :                     throw css::document::CorruptedFilterConfigurationException(
    1627                 :            :                             rtl::OUString(MESSAGE_CORRUPTED_FILTERCONFIG),
    1628                 :            :                             css::uno::Reference< css::uno::XInterface >(),
    1629         [ #  # ]:          0 :                             ex.Message);
    1630                 :            :                 }
    1631                 :            :             }
    1632                 :      16249 :             break;
    1633                 :          0 :             default: break;
    1634                 :            :         }
    1635         [ +  - ]:        566 :     }
    1636                 :        566 : }
    1637                 :            : 
    1638                 :            : 
    1639                 :            : 
    1640                 :      40121 : void FilterCache::impl_readPatchUINames(const css::uno::Reference< css::container::XNameAccess >& xNode,
    1641                 :            :                                               CacheItem&                                          rItem)
    1642                 :            :     throw(css::uno::Exception)
    1643                 :            : {
    1644                 :            : 
    1645                 :            :     // SAFE -> ----------------------------------
    1646         [ +  - ]:      40121 :     ::osl::ResettableMutexGuard aLock(m_aLock);
    1647                 :      40121 :     ::rtl::OUString sFormatName    = m_sFormatName   ;
    1648                 :      40121 :     ::rtl::OUString sFormatVersion = m_sFormatVersion;
    1649                 :      40121 :     ::rtl::OUString sActLocale     = m_sActLocale    ;
    1650         [ +  - ]:      40121 :     aLock.clear();
    1651                 :            :     // <- SAFE ----------------------------------
    1652                 :            : 
    1653 [ +  - ][ +  - ]:      40121 :     css::uno::Any aVal = xNode->getByName(PROPNAME_UINAME);
    1654                 :      40121 :     css::uno::Reference< css::container::XNameAccess > xUIName;
    1655 [ -  + ][ #  # ]:      40121 :     if (!(aVal >>= xUIName) && !xUIName.is())
         [ -  + ][ +  - ]
    1656                 :            :         return;
    1657                 :            : 
    1658 [ +  - ][ +  - ]:      40121 :     const ::comphelper::SequenceAsVector< ::rtl::OUString >                 lLocales(xUIName->getElementNames());
         [ +  - ][ +  - ]
    1659                 :      40121 :           ::comphelper::SequenceAsVector< ::rtl::OUString >::const_iterator pLocale ;
    1660         [ +  - ]:      40121 :           ::comphelper::SequenceAsHashMap                                   lUINames;
    1661                 :            : 
    1662                 :      40121 :     const char FORMATNAME_VAR[] = "%productname%";
    1663                 :      40121 :     const char FORMATVERSION_VAR[] = "%formatversion%";
    1664                 :            :     // patch %PRODUCTNAME and %FORMATNAME
    1665 [ +  - ][ +  + ]:     153788 :     for (  pLocale  = lLocales.begin();
    1666                 :      76894 :            pLocale != lLocales.end()  ;
    1667                 :            :          ++pLocale                    )
    1668                 :            :     {
    1669                 :      36773 :         const ::rtl::OUString& sLocale = *pLocale;
    1670                 :            : 
    1671                 :      36773 :         ::rtl::OUString sValue;
    1672 [ +  - ][ +  - ]:      36773 :         xUIName->getByName(sLocale) >>= sValue;
    1673                 :            : 
    1674                 :            :         // replace %productname%
    1675                 :      36773 :         sal_Int32 nIndex = sValue.indexOf(FORMATNAME_VAR);
    1676         [ +  + ]:      38327 :         while(nIndex != -1)
    1677                 :            :         {
    1678                 :       1554 :             sValue = sValue.replaceAt(nIndex, RTL_CONSTASCII_LENGTH(FORMATNAME_VAR), sFormatName);
    1679                 :       1554 :             nIndex = sValue.indexOf(FORMATNAME_VAR, nIndex);
    1680                 :            :         }
    1681                 :            :         // replace %formatversion%
    1682                 :      36773 :         nIndex = sValue.indexOf(FORMATVERSION_VAR);
    1683         [ +  + ]:      38265 :         while(nIndex != -1)
    1684                 :            :         {
    1685                 :       1492 :             sValue = sValue.replaceAt(nIndex, RTL_CONSTASCII_LENGTH(FORMATVERSION_VAR), sFormatVersion);
    1686                 :       1492 :             nIndex = sValue.indexOf(FORMATVERSION_VAR, nIndex);
    1687                 :            :         }
    1688                 :            : 
    1689 [ +  - ][ +  - ]:      36773 :         lUINames[sLocale] <<= sValue;
    1690                 :      36773 :     }
    1691                 :            : 
    1692 [ +  - ][ +  - ]:      40121 :     aVal <<= lUINames.getAsConstPropertyValueList();
                 [ +  - ]
    1693         [ +  - ]:      40121 :     rItem[PROPNAME_UINAMES] = aVal;
    1694                 :            : 
    1695                 :            :     // find right UIName for current office locale
    1696                 :            :     // Use fallbacks too!
    1697         [ +  - ]:      40121 :     pLocale = ::comphelper::Locale::getFallback(lLocales, sActLocale);
    1698 [ +  - ][ +  + ]:      40121 :     if (pLocale == lLocales.end())
    1699                 :            :     {
    1700                 :            : #if OSL_DEBUG_LEVEL > 0
    1701                 :            :         if ( sActLocale == "en-US" )
    1702                 :            :             return;
    1703                 :            :         ::rtl::OUString sName = rItem.getUnpackedValueOrDefault(PROPNAME_NAME, ::rtl::OUString());
    1704                 :            : 
    1705                 :            :         ::rtl::OUStringBuffer sMsg(256);
    1706                 :            :         sMsg.appendAscii("Fallback scenario for filter or type '"           );
    1707                 :            :         sMsg.append     (sName                                              );
    1708                 :            :         sMsg.appendAscii("' and locale '"                                   );
    1709                 :            :         sMsg.append     (sActLocale                                         );
    1710                 :            :         sMsg.appendAscii("' failed. Please check your filter configuration.");
    1711                 :            : 
    1712                 :            :         OSL_FAIL(_FILTER_CONFIG_TO_ASCII_(sMsg.makeStringAndClear()));
    1713                 :            : #endif
    1714                 :            :         return;
    1715                 :            :     }
    1716                 :            : 
    1717                 :      36461 :     const ::rtl::OUString& sLocale = *pLocale;
    1718         [ +  - ]:      36461 :     ::comphelper::SequenceAsHashMap::const_iterator pUIName = lUINames.find(sLocale);
    1719         [ +  - ]:      36461 :     if (pUIName != lUINames.end())
    1720 [ +  - ][ +  - ]:      40121 :         rItem[PROPNAME_UINAME] = pUIName->second;
         [ +  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
    1721                 :            : }
    1722                 :            : 
    1723                 :            : 
    1724                 :            : 
    1725                 :          0 : void FilterCache::impl_savePatchUINames(const css::uno::Reference< css::container::XNameReplace >& xNode,
    1726                 :            :                                         const CacheItem&                                           rItem)
    1727                 :            :     throw(css::uno::Exception)
    1728                 :            : {
    1729         [ #  # ]:          0 :     css::uno::Reference< css::container::XNameContainer > xAdd  (xNode, css::uno::UNO_QUERY);
    1730         [ #  # ]:          0 :     css::uno::Reference< css::container::XNameAccess >    xCheck(xNode, css::uno::UNO_QUERY);
    1731                 :            : 
    1732 [ #  # ][ #  # ]:          0 :     css::uno::Sequence< css::beans::PropertyValue > lUINames = rItem.getUnpackedValueOrDefault(PROPNAME_UINAMES, css::uno::Sequence< css::beans::PropertyValue >());
                 [ #  # ]
    1733                 :          0 :     sal_Int32                                       c        = lUINames.getLength();
    1734                 :          0 :     const css::beans::PropertyValue*                pUINames = lUINames.getConstArray();
    1735                 :            : 
    1736         [ #  # ]:          0 :     for (sal_Int32 i=0; i<c; ++i)
    1737                 :            :     {
    1738 [ #  # ][ #  # ]:          0 :         if (xCheck->hasByName(pUINames[i].Name))
                 [ #  # ]
    1739 [ #  # ][ #  # ]:          0 :             xNode->replaceByName(pUINames[i].Name, pUINames[i].Value);
    1740                 :            :         else
    1741 [ #  # ][ #  # ]:          0 :             xAdd->insertByName(pUINames[i].Name, pUINames[i].Value);
    1742         [ #  # ]:          0 :     }
    1743                 :          0 : }
    1744                 :            : 
    1745                 :            : /*-----------------------------------------------
    1746                 :            :     TODO
    1747                 :            :         clarify, how the real problem behind the
    1748                 :            :         wrong constructed CacheItem instance (which
    1749                 :            :         will force a crash during destruction)
    1750                 :            :         can be solved ...
    1751                 :            : -----------------------------------------------*/
    1752                 :      57236 : CacheItem FilterCache::impl_loadItem(const css::uno::Reference< css::container::XNameAccess >& xSet   ,
    1753                 :            :                                            EItemType                                           eType  ,
    1754                 :            :                                      const ::rtl::OUString&                                    sItem  ,
    1755                 :            :                                            EReadOption                                         eOption)
    1756                 :            :     throw(css::uno::Exception)
    1757                 :            : {
    1758                 :            :     // try to get an API object, which points directly to the
    1759                 :            :     // requested item. If it fail an exception should occur and
    1760                 :            :     // break this operation. Of course returned API object must be
    1761                 :            :     // checked too.
    1762                 :      57236 :     css::uno::Reference< css::container::XNameAccess > xItem;
    1763                 :            :     #ifdef WORKAROUND_EXCEPTION_PROBLEM
    1764                 :            :     try
    1765                 :            :     {
    1766                 :            :     #endif
    1767 [ +  - ][ +  - ]:      57236 :         css::uno::Any aVal = xSet->getByName(sItem);
    1768 [ +  - ][ +  - ]:      57236 :         if (!(aVal >>= xItem) || !xItem.is())
         [ -  + ][ -  + ]
    1769                 :            :         {
    1770                 :          0 :             ::rtl::OUStringBuffer sMsg(256);
    1771         [ #  # ]:          0 :             sMsg.appendAscii("found corrupted item \"");
    1772         [ #  # ]:          0 :             sMsg.append     (sItem                    );
    1773         [ #  # ]:          0 :             sMsg.appendAscii("\"."                    );
    1774                 :            :             throw css::uno::Exception(sMsg.makeStringAndClear()                    ,
    1775 [ #  # ][ #  # ]:          0 :                                       css::uno::Reference< css::uno::XInterface >());
    1776                 :      57236 :         }
    1777                 :            :     #ifdef WORKAROUND_EXCEPTION_PROBLEM
    1778                 :            :     }
    1779         [ #  # ]:          0 :     catch(const css::container::NoSuchElementException&)
    1780                 :            :     {
    1781                 :          0 :         throw;
    1782                 :            :     }
    1783                 :            :     #endif
    1784                 :            : 
    1785                 :            :     // The internal name of an item must(!) be part of the property
    1786                 :            :     // set too. Of course its already used as key into the e.g. outside
    1787                 :            :     // used hash map ... but some of our API methods provide
    1788                 :            :     // this property set as result only. But the user of this CacheItem
    1789                 :            :     // should know, which value the key names has :-) ITS IMPORTANT!
    1790         [ +  - ]:      57236 :     CacheItem aItem;
    1791 [ +  - ][ +  - ]:      57236 :     aItem[PROPNAME_NAME] = css::uno::makeAny(sItem);
    1792   [ +  +  +  - ]:      57236 :     switch(eType)
    1793                 :            :     {
    1794                 :            :         //---------------------------------------
    1795                 :            :         case E_TYPE :
    1796                 :            :         {
    1797                 :            :             // read standard properties of a type
    1798 [ +  + ][ -  + ]:      32760 :             if (
    1799                 :            :                 (eOption == E_READ_STANDARD) ||
    1800                 :            :                 (eOption == E_READ_ALL     )
    1801                 :            :                )
    1802                 :            :             {
    1803 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_PREFERREDFILTER] = xItem->getByName(PROPNAME_PREFERREDFILTER);
                 [ +  - ]
    1804 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_DETECTSERVICE  ] = xItem->getByName(PROPNAME_DETECTSERVICE  );
                 [ +  - ]
    1805 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_URLPATTERN     ] = xItem->getByName(PROPNAME_URLPATTERN     );
                 [ +  - ]
    1806 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_EXTENSIONS     ] = xItem->getByName(PROPNAME_EXTENSIONS     );
                 [ +  - ]
    1807 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_PREFERRED      ] = xItem->getByName(PROPNAME_PREFERRED      );
                 [ +  - ]
    1808 [ +  - ][ +  - ]:      16511 :                 aItem[PROPNAME_CLIPBOARDFORMAT] = xItem->getByName(PROPNAME_CLIPBOARDFORMAT);
                 [ +  - ]
    1809                 :            :             }
    1810                 :            :             // read optional properties of a type
    1811                 :            :             // no else here! Is an additional switch ...
    1812 [ +  + ][ -  + ]:      32760 :             if (
    1813                 :            :                 (eOption == E_READ_UPDATE) ||
    1814                 :            :                 (eOption == E_READ_ALL   )
    1815                 :            :                )
    1816                 :            :             {
    1817 [ +  - ][ +  - ]:      16249 :                 aItem[PROPNAME_MEDIATYPE      ] = xItem->getByName(PROPNAME_MEDIATYPE      );
                 [ +  - ]
    1818         [ +  - ]:      16249 :                 impl_readPatchUINames(xItem, aItem);
    1819                 :            :             }
    1820                 :            :         }
    1821                 :      32760 :         break;
    1822                 :            : 
    1823                 :            :         //---------------------------------------
    1824                 :            :         case E_FILTER :
    1825                 :            :         {
    1826                 :            :             // read standard properties of a filter
    1827 [ +  - ][ +  - ]:      23872 :             if (
    1828                 :            :                 (eOption == E_READ_STANDARD) ||
    1829                 :            :                 (eOption == E_READ_ALL     )
    1830                 :            :                )
    1831                 :            :             {
    1832 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_TYPE             ] = xItem->getByName(PROPNAME_TYPE             );
                 [ +  - ]
    1833 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_FILEFORMATVERSION] = xItem->getByName(PROPNAME_FILEFORMATVERSION);
                 [ +  - ]
    1834 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_UICOMPONENT      ] = xItem->getByName(PROPNAME_UICOMPONENT      );
                 [ +  - ]
    1835 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_FILTERSERVICE    ] = xItem->getByName(PROPNAME_FILTERSERVICE    );
                 [ +  - ]
    1836 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_DOCUMENTSERVICE  ] = xItem->getByName(PROPNAME_DOCUMENTSERVICE  );
                 [ +  - ]
    1837 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_EXPORTEXTENSION  ] = xItem->getByName(PROPNAME_EXPORTEXTENSION  );
                 [ +  - ]
    1838                 :            : 
    1839                 :            :                 // special handling for flags! Convert it from a list of names to its
    1840                 :            :                 // int representation ...
    1841         [ +  - ]:      23872 :                 css::uno::Sequence< ::rtl::OUString > lFlagNames;
    1842 [ +  - ][ +  - ]:      23872 :                 if (xItem->getByName(PROPNAME_FLAGS) >>= lFlagNames)
         [ +  - ][ +  - ]
    1843 [ +  - ][ +  - ]:      23872 :                     aItem[PROPNAME_FLAGS] <<= FilterCache::impl_convertFlagNames2FlagField(lFlagNames);
         [ +  - ][ +  - ]
    1844                 :            :             }
    1845                 :            :             // read optional properties of a filter
    1846                 :            :             // no else here! Is an additional switch ...
    1847 [ +  - ][ +  - ]:      23872 :             if (
    1848                 :            :                 (eOption == E_READ_UPDATE) ||
    1849                 :            :                 (eOption == E_READ_ALL   )
    1850                 :            :                )
    1851                 :            :             {
    1852 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_USERDATA    ] = xItem->getByName(PROPNAME_USERDATA    );
                 [ +  - ]
    1853 [ +  - ][ +  - ]:      23872 :                 aItem[PROPNAME_TEMPLATENAME] = xItem->getByName(PROPNAME_TEMPLATENAME);
                 [ +  - ]
    1854                 :            : //TODO remove it if moving of filter uinames to type uinames
    1855                 :            : //       will be finished realy
    1856                 :            : #ifdef AS_ENABLE_FILTER_UINAMES
    1857         [ +  - ]:      23872 :                 impl_readPatchUINames(xItem, aItem);
    1858                 :            : #endif // AS_ENABLE_FILTER_UINAMES
    1859                 :            :             }
    1860                 :            :         }
    1861                 :      23872 :         break;
    1862                 :            : 
    1863                 :            :         //---------------------------------------
    1864                 :            :         case E_FRAMELOADER :
    1865                 :            :         case E_CONTENTHANDLER :
    1866                 :            :         {
    1867 [ +  - ][ +  - ]:        604 :             aItem[PROPNAME_TYPES] = xItem->getByName(PROPNAME_TYPES);
                 [ +  - ]
    1868                 :            :         }
    1869                 :        604 :         break;
    1870                 :          0 :         default: break;
    1871                 :            :     }
    1872                 :            : 
    1873                 :      57236 :     return aItem;
    1874                 :            : }
    1875                 :            : 
    1876                 :            : 
    1877                 :            : 
    1878                 :        351 : CacheItemList::iterator FilterCache::impl_loadItemOnDemand(      EItemType        eType,
    1879                 :            :                                                            const ::rtl::OUString& sItem)
    1880                 :            :     throw(css::uno::Exception)
    1881                 :            : {
    1882                 :        351 :     CacheItemList*                              pList   = 0;
    1883                 :        351 :     css::uno::Reference< css::uno::XInterface > xConfig    ;
    1884                 :        351 :     ::rtl::OUString                             sSet       ;
    1885                 :            : 
    1886   [ +  +  +  +  :        351 :     switch(eType)
                   -  - ]
    1887                 :            :     {
    1888                 :            :         case E_TYPE :
    1889                 :            :         {
    1890                 :        255 :             pList   = &m_lTypes;
    1891 [ +  - ][ +  - ]:        255 :             xConfig = impl_openConfig(E_PROVIDER_TYPES);
    1892         [ +  - ]:        255 :             sSet    = CFGSET_TYPES;
    1893                 :            :         }
    1894                 :        255 :         break;
    1895                 :            : 
    1896                 :            :         case E_FILTER :
    1897                 :            :         {
    1898                 :         88 :             pList   = &m_lFilters;
    1899 [ +  - ][ +  - ]:         88 :             xConfig = impl_openConfig(E_PROVIDER_FILTERS);
    1900         [ +  - ]:         88 :             sSet    = CFGSET_FILTERS;
    1901                 :            :         }
    1902                 :         88 :         break;
    1903                 :            : 
    1904                 :            :         case E_FRAMELOADER :
    1905                 :            :         {
    1906                 :          4 :             pList   = &m_lFrameLoaders;
    1907 [ +  - ][ +  - ]:          4 :             xConfig = impl_openConfig(E_PROVIDER_OTHERS);
    1908         [ +  - ]:          4 :             sSet    = CFGSET_FRAMELOADERS;
    1909                 :            :         }
    1910                 :          4 :         break;
    1911                 :            : 
    1912                 :            :         case E_CONTENTHANDLER :
    1913                 :            :         {
    1914                 :          4 :             pList   = &m_lContentHandlers;
    1915 [ +  - ][ +  - ]:          4 :             xConfig = impl_openConfig(E_PROVIDER_OTHERS);
    1916         [ +  - ]:          4 :             sSet    = CFGSET_CONTENTHANDLERS;
    1917                 :            :         }
    1918                 :          4 :         break;
    1919                 :            : 
    1920                 :            :         case E_DETECTSERVICE :
    1921                 :            :         {
    1922                 :            :             OSL_FAIL("Cant load detect services on demand. Who use this unsupported feature?");
    1923                 :            :         }
    1924                 :          0 :         break;
    1925                 :            :     }
    1926                 :            : 
    1927         [ +  - ]:        351 :     css::uno::Reference< css::container::XNameAccess > xRoot(xConfig, css::uno::UNO_QUERY_THROW);
    1928                 :        351 :     css::uno::Reference< css::container::XNameAccess > xSet ;
    1929 [ +  - ][ +  - ]:        351 :     xRoot->getByName(sSet) >>= xSet;
                 [ +  - ]
    1930                 :            : 
    1931         [ +  - ]:        351 :     CacheItemList::iterator pItemInCache  = pList->find(sItem);
    1932 [ +  - ][ +  - ]:        351 :     sal_Bool                bItemInConfig = xSet->hasByName(sItem);
    1933                 :            : 
    1934         [ +  + ]:        351 :     if (bItemInConfig)
    1935                 :            :     {
    1936 [ +  - ][ +  - ]:         64 :         (*pList)[sItem] = impl_loadItem(xSet, eType, sItem, E_READ_ALL);
         [ +  - ][ +  - ]
    1937                 :            :         _FILTER_CONFIG_LOG_2_("impl_loadItemOnDemand(%d, \"%s\") ... OK", (int)eType, _FILTER_CONFIG_TO_ASCII_(sItem).getStr())
    1938                 :            :     }
    1939                 :            :     else
    1940                 :            :     {
    1941 [ +  - ][ -  + ]:        287 :         if (pItemInCache != pList->end())
    1942         [ #  # ]:          0 :             pList->erase(pItemInCache);
    1943                 :            :         // OK - this item does not exists inside configuration.
    1944                 :            :         // And we already updated our internal cache.
    1945                 :            :         // But the outside code needs this NoSuchElementException
    1946                 :            :         // to know, that this item does notexists.
    1947                 :            :         // Nobody checks the iterator!
    1948         [ +  - ]:        287 :         throw css::container::NoSuchElementException();
    1949                 :            :     }
    1950                 :            : 
    1951         [ +  - ]:        351 :     return pList->find(sItem);
    1952                 :            : }
    1953                 :            : 
    1954                 :            : 
    1955                 :            : 
    1956                 :          0 : void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XNameReplace >& xItem,
    1957                 :            :                                       EItemType                                            eType,
    1958                 :            :                                 const CacheItem&                                           aItem)
    1959                 :            :     throw(css::uno::Exception)
    1960                 :            : {
    1961                 :          0 :     CacheItem::const_iterator pIt;
    1962   [ #  #  #  # ]:          0 :     switch(eType)
    1963                 :            :     {
    1964                 :            :         //---------------------------------------
    1965                 :            :         case E_TYPE :
    1966                 :            :         {
    1967         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_PREFERREDFILTER);
    1968         [ #  # ]:          0 :             if (pIt != aItem.end())
    1969 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_PREFERREDFILTER, pIt->second);
                 [ #  # ]
    1970         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_DETECTSERVICE);
    1971         [ #  # ]:          0 :             if (pIt != aItem.end())
    1972 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_DETECTSERVICE, pIt->second);
                 [ #  # ]
    1973         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_URLPATTERN);
    1974         [ #  # ]:          0 :             if (pIt != aItem.end())
    1975 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_URLPATTERN, pIt->second);
                 [ #  # ]
    1976         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_EXTENSIONS);
    1977         [ #  # ]:          0 :             if (pIt != aItem.end())
    1978 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_EXTENSIONS, pIt->second);
                 [ #  # ]
    1979         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_PREFERRED);
    1980         [ #  # ]:          0 :             if (pIt != aItem.end())
    1981 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_PREFERRED, pIt->second);
                 [ #  # ]
    1982         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_MEDIATYPE);
    1983         [ #  # ]:          0 :             if (pIt != aItem.end())
    1984 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_MEDIATYPE, pIt->second);
                 [ #  # ]
    1985         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_CLIPBOARDFORMAT);
    1986         [ #  # ]:          0 :             if (pIt != aItem.end())
    1987 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_CLIPBOARDFORMAT, pIt->second);
                 [ #  # ]
    1988                 :            : 
    1989                 :          0 :             css::uno::Reference< css::container::XNameReplace > xUIName;
    1990 [ #  # ][ #  # ]:          0 :             xItem->getByName(PROPNAME_UINAME) >>= xUIName;
                 [ #  # ]
    1991         [ #  # ]:          0 :             impl_savePatchUINames(xUIName, aItem);
    1992                 :            :         }
    1993                 :          0 :         break;
    1994                 :            : 
    1995                 :            :         //---------------------------------------
    1996                 :            :         case E_FILTER :
    1997                 :            :         {
    1998         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_TYPE);
    1999         [ #  # ]:          0 :             if (pIt != aItem.end())
    2000 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_TYPE, pIt->second);
                 [ #  # ]
    2001         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_FILEFORMATVERSION);
    2002         [ #  # ]:          0 :             if (pIt != aItem.end())
    2003 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_FILEFORMATVERSION, pIt->second);
                 [ #  # ]
    2004         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_UICOMPONENT);
    2005         [ #  # ]:          0 :             if (pIt != aItem.end())
    2006 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_UICOMPONENT, pIt->second);
                 [ #  # ]
    2007         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_FILTERSERVICE);
    2008         [ #  # ]:          0 :             if (pIt != aItem.end())
    2009 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_FILTERSERVICE, pIt->second);
                 [ #  # ]
    2010         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_DOCUMENTSERVICE);
    2011         [ #  # ]:          0 :             if (pIt != aItem.end())
    2012 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_DOCUMENTSERVICE, pIt->second);
                 [ #  # ]
    2013         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_USERDATA);
    2014         [ #  # ]:          0 :             if (pIt != aItem.end())
    2015 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_USERDATA, pIt->second);
                 [ #  # ]
    2016         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_TEMPLATENAME);
    2017         [ #  # ]:          0 :             if (pIt != aItem.end())
    2018 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_TEMPLATENAME, pIt->second);
                 [ #  # ]
    2019                 :            : 
    2020                 :            :             // special handling for flags! Convert it from an integer flag field back
    2021                 :            :             // to a list of names ...
    2022                 :            :             // But note: because we work directly on a reference to the cache item,
    2023                 :            :             // its not allowd to change the value here. We must work on a copy!
    2024         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_FLAGS);
    2025         [ #  # ]:          0 :             if (pIt != aItem.end())
    2026                 :            :             {
    2027                 :          0 :                 sal_Int32 nFlags = 0;
    2028         [ #  # ]:          0 :                 pIt->second >>= nFlags;
    2029                 :          0 :                 css::uno::Any aFlagNameList;
    2030 [ #  # ][ #  # ]:          0 :                 aFlagNameList <<= FilterCache::impl_convertFlagField2FlagNames(nFlags);
                 [ #  # ]
    2031 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_FLAGS, aFlagNameList);
    2032                 :            :             }
    2033                 :            : 
    2034                 :            : //TODO remove it if moving of filter uinames to type uinames
    2035                 :            : //       will be finished realy
    2036                 :            : #ifdef AS_ENABLE_FILTER_UINAMES
    2037                 :          0 :             css::uno::Reference< css::container::XNameReplace > xUIName;
    2038 [ #  # ][ #  # ]:          0 :             xItem->getByName(PROPNAME_UINAME) >>= xUIName;
                 [ #  # ]
    2039         [ #  # ]:          0 :             impl_savePatchUINames(xUIName, aItem);
    2040                 :            : #endif //  AS_ENABLE_FILTER_UINAMES
    2041                 :            :         }
    2042                 :          0 :         break;
    2043                 :            : 
    2044                 :            :         //---------------------------------------
    2045                 :            :         case E_FRAMELOADER :
    2046                 :            :         case E_CONTENTHANDLER :
    2047                 :            :         {
    2048         [ #  # ]:          0 :             pIt = aItem.find(PROPNAME_TYPES);
    2049         [ #  # ]:          0 :             if (pIt != aItem.end())
    2050 [ #  # ][ #  # ]:          0 :                 xItem->replaceByName(PROPNAME_TYPES, pIt->second);
                 [ #  # ]
    2051                 :            :         }
    2052                 :          0 :         break;
    2053                 :          0 :         default: break;
    2054                 :            :     }
    2055                 :          0 : }
    2056                 :            : 
    2057                 :            : /*-----------------------------------------------
    2058                 :            :     static! => no locks neccessary
    2059                 :            : -----------------------------------------------*/
    2060                 :          0 : css::uno::Sequence< ::rtl::OUString > FilterCache::impl_convertFlagField2FlagNames(sal_Int32 nFlags)
    2061                 :            : {
    2062         [ #  # ]:          0 :     OUStringList lFlagNames;
    2063                 :            : 
    2064 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_3RDPARTYFILTER   ) == FLAGVAL_3RDPARTYFILTER   ) lFlagNames.push_back(FLAGNAME_3RDPARTYFILTER   );
                 [ #  # ]
    2065 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_ALIEN            ) == FLAGVAL_ALIEN            ) lFlagNames.push_back(FLAGNAME_ALIEN            );
                 [ #  # ]
    2066 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_ASYNCHRON        ) == FLAGVAL_ASYNCHRON        ) lFlagNames.push_back(FLAGNAME_ASYNCHRON        );
                 [ #  # ]
    2067 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_BROWSERPREFERRED ) == FLAGVAL_BROWSERPREFERRED ) lFlagNames.push_back(FLAGNAME_BROWSERPREFERRED );
                 [ #  # ]
    2068 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_CONSULTSERVICE   ) == FLAGVAL_CONSULTSERVICE   ) lFlagNames.push_back(FLAGNAME_CONSULTSERVICE   );
                 [ #  # ]
    2069 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_DEFAULT          ) == FLAGVAL_DEFAULT          ) lFlagNames.push_back(FLAGNAME_DEFAULT          );
                 [ #  # ]
    2070 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_ENCRYPTION       ) == FLAGVAL_ENCRYPTION       ) lFlagNames.push_back(FLAGNAME_ENCRYPTION       );
                 [ #  # ]
    2071 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_EXPORT           ) == FLAGVAL_EXPORT           ) lFlagNames.push_back(FLAGNAME_EXPORT           );
                 [ #  # ]
    2072 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_IMPORT           ) == FLAGVAL_IMPORT           ) lFlagNames.push_back(FLAGNAME_IMPORT           );
                 [ #  # ]
    2073 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_INTERNAL         ) == FLAGVAL_INTERNAL         ) lFlagNames.push_back(FLAGNAME_INTERNAL         );
                 [ #  # ]
    2074 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_NOTINCHOOSER     ) == FLAGVAL_NOTINCHOOSER     ) lFlagNames.push_back(FLAGNAME_NOTINCHOOSER     );
                 [ #  # ]
    2075 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_NOTINFILEDIALOG  ) == FLAGVAL_NOTINFILEDIALOG  ) lFlagNames.push_back(FLAGNAME_NOTINFILEDIALOG  );
                 [ #  # ]
    2076 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_NOTINSTALLED     ) == FLAGVAL_NOTINSTALLED     ) lFlagNames.push_back(FLAGNAME_NOTINSTALLED     );
                 [ #  # ]
    2077 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_OWN              ) == FLAGVAL_OWN              ) lFlagNames.push_back(FLAGNAME_OWN              );
                 [ #  # ]
    2078 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_PACKED           ) == FLAGVAL_PACKED           ) lFlagNames.push_back(FLAGNAME_PACKED           );
                 [ #  # ]
    2079 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_PASSWORDTOMODIFY ) == FLAGVAL_PASSWORDTOMODIFY ) lFlagNames.push_back(FLAGNAME_PASSWORDTOMODIFY );
                 [ #  # ]
    2080 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_PREFERRED        ) == FLAGVAL_PREFERRED        ) lFlagNames.push_back(FLAGNAME_PREFERRED        );
                 [ #  # ]
    2081 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_STARTPRESENTATION) == FLAGVAL_STARTPRESENTATION) lFlagNames.push_back(FLAGNAME_STARTPRESENTATION);
                 [ #  # ]
    2082 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_READONLY         ) == FLAGVAL_READONLY         ) lFlagNames.push_back(FLAGNAME_READONLY         );
                 [ #  # ]
    2083 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_SUPPORTSSELECTION) == FLAGVAL_SUPPORTSSELECTION) lFlagNames.push_back(FLAGNAME_SUPPORTSSELECTION);
                 [ #  # ]
    2084 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_TEMPLATE         ) == FLAGVAL_TEMPLATE         ) lFlagNames.push_back(FLAGNAME_TEMPLATE         );
                 [ #  # ]
    2085 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_TEMPLATEPATH     ) == FLAGVAL_TEMPLATEPATH     ) lFlagNames.push_back(FLAGNAME_TEMPLATEPATH     );
                 [ #  # ]
    2086 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_USESOPTIONS      ) == FLAGVAL_USESOPTIONS      ) lFlagNames.push_back(FLAGNAME_USESOPTIONS      );
                 [ #  # ]
    2087 [ #  # ][ #  # ]:          0 :     if ((nFlags & FLAGVAL_COMBINED         ) == FLAGVAL_COMBINED         ) lFlagNames.push_back(FLAGNAME_COMBINED         );
                 [ #  # ]
    2088                 :            : 
    2089         [ #  # ]:          0 :     return lFlagNames.getAsConstList();
    2090                 :            : }
    2091                 :            : 
    2092                 :            : /*-----------------------------------------------
    2093                 :            :     static! => no locks neccessary
    2094                 :            : -----------------------------------------------*/
    2095                 :      23872 : sal_Int32 FilterCache::impl_convertFlagNames2FlagField(const css::uno::Sequence< ::rtl::OUString >& lNames)
    2096                 :            : {
    2097                 :      23872 :     sal_Int32 nField = 0;
    2098                 :            : 
    2099                 :      23872 :     const ::rtl::OUString* pNames = lNames.getConstArray();
    2100                 :      23872 :           sal_Int32        c      = lNames.getLength();
    2101         [ +  + ]:     119487 :     for (sal_Int32 i=0; i<c; ++i)
    2102                 :            :     {
    2103         [ +  + ]:      95615 :         if (pNames[i].equals(FLAGNAME_3RDPARTYFILTER))
    2104                 :            :         {
    2105                 :       7754 :             nField |= FLAGVAL_3RDPARTYFILTER;
    2106                 :       7754 :             continue;
    2107                 :            :         }
    2108         [ +  + ]:      87861 :         if (pNames[i].equals(FLAGNAME_ALIEN))
    2109                 :            :         {
    2110                 :      20817 :             nField |= FLAGVAL_ALIEN;
    2111                 :      20817 :             continue;
    2112                 :            :         }
    2113         [ +  + ]:      67044 :         if (pNames[i].equals(FLAGNAME_ASYNCHRON))
    2114                 :            :         {
    2115                 :        500 :             nField |= FLAGVAL_ASYNCHRON;
    2116                 :        500 :             continue;
    2117                 :            :         }
    2118         [ -  + ]:      66544 :         if (pNames[i].equals(FLAGNAME_BROWSERPREFERRED))
    2119                 :            :         {
    2120                 :          0 :             nField |= FLAGVAL_BROWSERPREFERRED;
    2121                 :          0 :             continue;
    2122                 :            :         }
    2123         [ -  + ]:      66544 :         if (pNames[i].equals(FLAGNAME_CONSULTSERVICE))
    2124                 :            :         {
    2125                 :          0 :             nField |= FLAGVAL_CONSULTSERVICE;
    2126                 :          0 :             continue;
    2127                 :            :         }
    2128         [ +  + ]:      66544 :         if (pNames[i].equals(FLAGNAME_DEFAULT))
    2129                 :            :         {
    2130                 :       1180 :             nField |= FLAGVAL_DEFAULT;
    2131                 :       1180 :             continue;
    2132                 :            :         }
    2133         [ +  + ]:      65364 :         if (pNames[i].equals(FLAGNAME_ENCRYPTION))
    2134                 :            :         {
    2135                 :       4431 :             nField |= FLAGVAL_ENCRYPTION;
    2136                 :       4431 :             continue;
    2137                 :            :         }
    2138         [ +  + ]:      60933 :         if (pNames[i].equals(FLAGNAME_EXPORT))
    2139                 :            :         {
    2140                 :      16813 :             nField |= FLAGVAL_EXPORT;
    2141                 :      16813 :             continue;
    2142                 :            :         }
    2143         [ +  + ]:      44120 :         if (pNames[i].equals(FLAGNAME_IMPORT))
    2144                 :            :         {
    2145                 :      16872 :             nField |= FLAGVAL_IMPORT;
    2146                 :      16872 :             continue;
    2147                 :            :         }
    2148         [ +  + ]:      27248 :         if (pNames[i].equals(FLAGNAME_INTERNAL))
    2149                 :            :         {
    2150                 :        125 :             nField |= FLAGVAL_INTERNAL;
    2151                 :        125 :             continue;
    2152                 :            :         }
    2153         [ +  + ]:      27123 :         if (pNames[i].equals(FLAGNAME_NOTINCHOOSER))
    2154                 :            :         {
    2155                 :        999 :             nField |= FLAGVAL_NOTINCHOOSER;
    2156                 :        999 :             continue;
    2157                 :            :         }
    2158         [ +  + ]:      26124 :         if (pNames[i].equals(FLAGNAME_NOTINFILEDIALOG))
    2159                 :            :         {
    2160                 :        874 :             nField |= FLAGVAL_NOTINFILEDIALOG;
    2161                 :        874 :             continue;
    2162                 :            :         }
    2163         [ -  + ]:      25250 :         if (pNames[i].equals(FLAGNAME_NOTINSTALLED))
    2164                 :            :         {
    2165                 :          0 :             nField |= FLAGVAL_NOTINSTALLED;
    2166                 :          0 :             continue;
    2167                 :            :         }
    2168         [ +  + ]:      25250 :         if (pNames[i].equals(FLAGNAME_OWN))
    2169                 :            :         {
    2170                 :       4055 :             nField |= FLAGVAL_OWN;
    2171                 :       4055 :             continue;
    2172                 :            :         }
    2173         [ -  + ]:      21195 :         if (pNames[i].equals(FLAGNAME_PACKED))
    2174                 :            :         {
    2175                 :          0 :             nField |= FLAGVAL_PACKED;
    2176                 :          0 :             continue;
    2177                 :            :         }
    2178         [ +  + ]:      21195 :         if (pNames[i].equals(FLAGNAME_PASSWORDTOMODIFY))
    2179                 :            :         {
    2180                 :       1544 :             nField |= FLAGVAL_PASSWORDTOMODIFY;
    2181                 :       1544 :             continue;
    2182                 :            :         }
    2183         [ +  + ]:      19651 :         if (pNames[i].equals(FLAGNAME_PREFERRED))
    2184                 :            :         {
    2185                 :       4972 :             nField |= FLAGVAL_PREFERRED;
    2186                 :       4972 :             continue;
    2187                 :            :         }
    2188         [ +  + ]:      14679 :         if (pNames[i].equals(FLAGNAME_STARTPRESENTATION))
    2189                 :            :         {
    2190                 :        375 :             nField |= FLAGVAL_STARTPRESENTATION;
    2191                 :        375 :             continue;
    2192                 :            :         }
    2193         [ +  + ]:      14304 :         if (pNames[i].equals(FLAGNAME_READONLY))
    2194                 :            :         {
    2195                 :        125 :             nField |= FLAGVAL_READONLY;
    2196                 :        125 :             continue;
    2197                 :            :         }
    2198         [ +  + ]:      14179 :         if (pNames[i].equals(FLAGNAME_SUPPORTSSELECTION))
    2199                 :            :         {
    2200                 :       4000 :             nField |= FLAGVAL_SUPPORTSSELECTION;
    2201                 :       4000 :             continue;
    2202                 :            :         }
    2203         [ +  + ]:      10179 :         if (pNames[i].equals(FLAGNAME_TEMPLATE))
    2204                 :            :         {
    2205                 :       5304 :             nField |= FLAGVAL_TEMPLATE;
    2206                 :       5304 :             continue;
    2207                 :            :         }
    2208         [ +  + ]:       4875 :         if (pNames[i].equals(FLAGNAME_TEMPLATEPATH))
    2209                 :            :         {
    2210                 :       2875 :             nField |= FLAGVAL_TEMPLATEPATH;
    2211                 :       2875 :             continue;
    2212                 :            :         }
    2213         [ +  + ]:       2000 :         if (pNames[i].equals(FLAGNAME_USESOPTIONS))
    2214                 :            :         {
    2215                 :       1750 :             nField |= FLAGVAL_USESOPTIONS;
    2216                 :       1750 :             continue;
    2217                 :            :         }
    2218         [ -  + ]:        250 :         if (pNames[i].equals(FLAGNAME_COMBINED))
    2219                 :            :         {
    2220                 :          0 :             nField |= FLAGVAL_COMBINED;
    2221                 :          0 :             continue;
    2222                 :            :         }
    2223                 :            :     }
    2224                 :            : 
    2225                 :      23872 :     return nField;
    2226                 :            : }
    2227                 :            : 
    2228                 :            : 
    2229                 :            : 
    2230                 :          0 : void FilterCache::impl_interpretDataVal4Type(const ::rtl::OUString& sValue,
    2231                 :            :                                                    sal_Int32        nProp ,
    2232                 :            :                                                    CacheItem&       rItem )
    2233                 :            : {
    2234   [ #  #  #  #  :          0 :     switch(nProp)
                   #  # ]
    2235                 :            :     {
    2236                 :            :         // Preferred
    2237                 :            :         case 0:     {
    2238         [ #  # ]:          0 :                         if (sValue.toInt32() == 1)
    2239 [ #  # ][ #  # ]:          0 :                             rItem[PROPNAME_PREFERRED] = css::uno::makeAny(sal_True);
    2240                 :            :                         else
    2241 [ #  # ][ #  # ]:          0 :                             rItem[PROPNAME_PREFERRED] = css::uno::makeAny(sal_False);
    2242                 :            :                     }
    2243                 :          0 :                     break;
    2244                 :            :         // MediaType
    2245 [ #  # ][ #  # ]:          0 :         case 1:     rItem[PROPNAME_MEDIATYPE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2246                 :          0 :                     break;
    2247                 :            :         // ClipboardFormat
    2248 [ #  # ][ #  # ]:          0 :         case 2:     rItem[PROPNAME_CLIPBOARDFORMAT] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2249                 :          0 :                     break;
    2250                 :            :         // URLPattern
    2251 [ #  # ][ #  # ]:          0 :         case 3:     rItem[PROPNAME_URLPATTERN] <<= impl_tokenizeString(sValue, (sal_Unicode)';').getAsConstList();
         [ #  # ][ #  # ]
    2252                 :          0 :                     break;
    2253                 :            :         // Extensions
    2254 [ #  # ][ #  # ]:          0 :         case 4:     rItem[PROPNAME_EXTENSIONS] <<= impl_tokenizeString(sValue, (sal_Unicode)';').getAsConstList();
         [ #  # ][ #  # ]
    2255                 :          0 :                     break;
    2256                 :            :     }
    2257                 :          0 : }
    2258                 :            : 
    2259                 :            : 
    2260                 :            : 
    2261                 :          0 : void FilterCache::impl_interpretDataVal4Filter(const ::rtl::OUString& sValue,
    2262                 :            :                                                      sal_Int32        nProp ,
    2263                 :            :                                                      CacheItem&       rItem )
    2264                 :            : {
    2265   [ #  #  #  #  :          0 :     switch(nProp)
          #  #  #  #  #  
                      # ]
    2266                 :            :     {
    2267                 :            :         // Order
    2268                 :            :         case 0:     {
    2269                 :          0 :                         sal_Int32 nOrder = sValue.toInt32();
    2270                 :            :                         if (nOrder > 0)
    2271                 :            :                         {
    2272                 :            :                             OSL_FAIL("FilterCache::impl_interpretDataVal4Filter()\nCant move Order value from filter to type on demand!\n");
    2273                 :            :                             _FILTER_CONFIG_LOG_2_("impl_interpretDataVal4Filter(%d, \"%s\") ... OK", (int)eType, _FILTER_CONFIG_TO_ASCII_(rItem).getStr())
    2274                 :            :                         }
    2275                 :            :                     }
    2276                 :          0 :                     break;
    2277                 :            :         // Type
    2278 [ #  # ][ #  # ]:          0 :         case 1:     rItem[PROPNAME_TYPE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2279                 :          0 :                     break;
    2280                 :            :         // DocumentService
    2281 [ #  # ][ #  # ]:          0 :         case 2:     rItem[PROPNAME_DOCUMENTSERVICE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2282                 :          0 :                     break;
    2283                 :            :         // FilterService
    2284 [ #  # ][ #  # ]:          0 :         case 3:     rItem[PROPNAME_FILTERSERVICE] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2285                 :          0 :                     break;
    2286                 :            :         // Flags
    2287 [ #  # ][ #  # ]:          0 :         case 4:     rItem[PROPNAME_FLAGS] <<= sValue.toInt32();
    2288                 :          0 :                     break;
    2289                 :            :         // UserData
    2290 [ #  # ][ #  # ]:          0 :         case 5:     rItem[PROPNAME_USERDATA] <<= impl_tokenizeString(sValue, (sal_Unicode)';').getAsConstList();
         [ #  # ][ #  # ]
    2291                 :          0 :                     break;
    2292                 :            :         // FileFormatVersion
    2293 [ #  # ][ #  # ]:          0 :         case 6:     rItem[PROPNAME_FILEFORMATVERSION] <<= sValue.toInt32();
    2294                 :          0 :                     break;
    2295                 :            :         // TemplateName
    2296 [ #  # ][ #  # ]:          0 :         case 7:     rItem[PROPNAME_TEMPLATENAME] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2297                 :          0 :                     break;
    2298                 :            :         // [optional!] UIComponent
    2299 [ #  # ][ #  # ]:          0 :         case 8:     rItem[PROPNAME_UICOMPONENT] <<= ::rtl::Uri::decode(sValue, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
    2300                 :          0 :                     break;
    2301                 :            :     }
    2302                 :          0 : }
    2303                 :            : 
    2304                 :            : /*-----------------------------------------------
    2305                 :            :     TODO work on a cache copy first, which can be flushed afterwards
    2306                 :            :          That would be usefully to gurantee a consistent cache.
    2307                 :            : -----------------------------------------------*/
    2308                 :        127 : void FilterCache::impl_readOldFormat()
    2309                 :            :     throw(css::uno::Exception)
    2310                 :            : {
    2311                 :            :     // Attention: Opening/Reading of this old configuration format has to be handled gracefully.
    2312                 :            :     // Its optional and shouldnt disturb our normal work!
    2313                 :            :     // E.g. we must check, if the package exists ...
    2314                 :            : 
    2315                 :        127 :     css::uno::Reference< css::container::XNameAccess > xCfg;
    2316                 :            :     try
    2317                 :            :     {
    2318         [ +  - ]:        127 :         css::uno::Reference< css::uno::XInterface > xInt = impl_openConfig(E_PROVIDER_OLD);
    2319 [ +  - ][ +  - ]:        127 :         xCfg = css::uno::Reference< css::container::XNameAccess >(xInt, css::uno::UNO_QUERY_THROW);
                 [ #  # ]
    2320                 :            :     }
    2321                 :            :     /* corrupt filter addon ? because it's external (optional) code .. we can ignore it. Addon wont work then ...
    2322                 :            :        but that seams to be acceptable.
    2323                 :            :        see #139088# for further informations
    2324                 :            :     */
    2325         [ #  # ]:          0 :     catch(const css::uno::Exception&)
    2326                 :        127 :         { return; }
    2327                 :            : 
    2328                 :        127 :     ::rtl::OUString TYPES_SET("Types");
    2329                 :            : 
    2330                 :            :     // May be there is no type set ...
    2331 [ +  - ][ +  - ]:        127 :     if (xCfg->hasByName(TYPES_SET))
                 [ +  - ]
    2332                 :            :     {
    2333                 :        127 :         css::uno::Reference< css::container::XNameAccess > xSet;
    2334 [ +  - ][ +  - ]:        127 :         xCfg->getByName(TYPES_SET) >>= xSet;
                 [ +  - ]
    2335 [ +  - ][ +  - ]:        127 :         const css::uno::Sequence< ::rtl::OUString > lItems = xSet->getElementNames();
    2336                 :        127 :         const ::rtl::OUString*                      pItems = lItems.getConstArray();
    2337         [ -  + ]:        127 :         for (sal_Int32 i=0; i<lItems.getLength(); ++i)
    2338 [ #  # ][ #  # ]:        127 :             m_lTypes[pItems[i]] = impl_readOldItem(xSet, E_TYPE, pItems[i]);
         [ #  # ][ #  # ]
                 [ +  - ]
    2339                 :            :     }
    2340                 :            : 
    2341                 :        127 :     ::rtl::OUString FILTER_SET("Filters");
    2342                 :            :     // May be there is no filter set ...
    2343 [ +  - ][ +  - ]:        127 :     if (xCfg->hasByName(FILTER_SET))
                 [ +  - ]
    2344                 :            :     {
    2345                 :        127 :         css::uno::Reference< css::container::XNameAccess > xSet;
    2346 [ +  - ][ +  - ]:        127 :         xCfg->getByName(FILTER_SET) >>= xSet;
                 [ +  - ]
    2347 [ +  - ][ +  - ]:        127 :         const css::uno::Sequence< ::rtl::OUString > lItems = xSet->getElementNames();
    2348                 :        127 :         const ::rtl::OUString*                      pItems = lItems.getConstArray();
    2349         [ -  + ]:        127 :         for (sal_Int32 i=0; i<lItems.getLength(); ++i)
    2350 [ #  # ][ #  # ]:        127 :             m_lFilters[pItems[i]] = impl_readOldItem(xSet, E_FILTER, pItems[i]);
         [ #  # ][ #  # ]
                 [ +  - ]
    2351         [ +  - ]:        127 :     }
    2352                 :            : }
    2353                 :            : 
    2354                 :            : 
    2355                 :            : 
    2356                 :          0 : CacheItem FilterCache::impl_readOldItem(const css::uno::Reference< css::container::XNameAccess >& xSet ,
    2357                 :            :                                               EItemType                                           eType,
    2358                 :            :                                         const ::rtl::OUString&                                    sItem)
    2359                 :            :     throw(css::uno::Exception)
    2360                 :            : {
    2361                 :          0 :     css::uno::Reference< css::container::XNameAccess > xItem;
    2362 [ #  # ][ #  # ]:          0 :     xSet->getByName(sItem) >>= xItem;
                 [ #  # ]
    2363         [ #  # ]:          0 :     if (!xItem.is())
    2364                 :            :         throw css::uno::Exception(
    2365                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant read old item." )),
    2366 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
    2367                 :            : 
    2368         [ #  # ]:          0 :     CacheItem aItem;
    2369 [ #  # ][ #  # ]:          0 :     aItem[PROPNAME_NAME] <<= sItem;
    2370                 :            : 
    2371                 :            :     // Installed flag ...
    2372                 :            :     // Isnt used any longer!
    2373                 :            : 
    2374                 :            :     // UIName
    2375         [ #  # ]:          0 :     impl_readPatchUINames(xItem, aItem);
    2376                 :            : 
    2377                 :            :     // Data
    2378                 :          0 :     ::rtl::OUString sData;
    2379         [ #  # ]:          0 :     OUStringList    lData;
    2380 [ #  # ][ #  # ]:          0 :     xItem->getByName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ))) >>= sData;
                 [ #  # ]
    2381 [ #  # ][ #  # ]:          0 :     lData = impl_tokenizeString(sData, (sal_Unicode)',');
    2382         [ #  # ]:          0 :     if (
           [ #  #  #  # ]
    2383                 :          0 :         (sData.isEmpty()) ||
    2384                 :          0 :         (lData.size()<1    )
    2385                 :            :        )
    2386                 :            :     {
    2387                 :            :         throw css::uno::Exception(
    2388                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant read old item property DATA." )),
    2389 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
    2390                 :            :     }
    2391                 :            : 
    2392                 :          0 :     sal_Int32 nProp = 0;
    2393 [ #  # ][ #  # ]:          0 :     for (OUStringList::const_iterator pProp  = lData.begin();
                 [ #  # ]
    2394                 :          0 :                                       pProp != lData.end()  ;
    2395                 :            :                                     ++pProp                 )
    2396                 :            :     {
    2397                 :          0 :         const ::rtl::OUString& sProp = *pProp;
    2398      [ #  #  # ]:          0 :         switch(eType)
    2399                 :            :         {
    2400                 :            :             case E_TYPE :
    2401         [ #  # ]:          0 :                 impl_interpretDataVal4Type(sProp, nProp, aItem);
    2402                 :          0 :                 break;
    2403                 :            : 
    2404                 :            :             case E_FILTER :
    2405         [ #  # ]:          0 :                 impl_interpretDataVal4Filter(sProp, nProp, aItem);
    2406                 :          0 :                 break;
    2407                 :          0 :             default: break;
    2408                 :            :         }
    2409                 :          0 :         ++nProp;
    2410                 :            :     }
    2411                 :            : 
    2412                 :          0 :     return aItem;
    2413                 :            : }
    2414                 :            : 
    2415                 :            : 
    2416                 :            : 
    2417                 :          0 : OUStringList FilterCache::impl_tokenizeString(const ::rtl::OUString& sData     ,
    2418                 :            :                                                     sal_Unicode      cSeperator)
    2419                 :            : {
    2420         [ #  # ]:          0 :     OUStringList lData  ;
    2421                 :          0 :     sal_Int32    nToken = 0;
    2422         [ #  # ]:          0 :     do
    2423                 :            :     {
    2424                 :          0 :         ::rtl::OUString sToken = sData.getToken(0, cSeperator, nToken);
    2425         [ #  # ]:          0 :         lData.push_back(sToken);
    2426                 :            :     }
    2427                 :            :     while(nToken >= 0);
    2428                 :          0 :     return lData;
    2429                 :            : }
    2430                 :            : 
    2431                 :            : #if OSL_DEBUG_LEVEL > 0
    2432                 :            : 
    2433                 :            : 
    2434                 :            : ::rtl::OUString FilterCache::impl_searchFrameLoaderForType(const ::rtl::OUString& sType) const
    2435                 :            : {
    2436                 :            :     CacheItemList::const_iterator pIt;
    2437                 :            :     for (  pIt  = m_lFrameLoaders.begin();
    2438                 :            :            pIt != m_lFrameLoaders.end()  ;
    2439                 :            :          ++pIt                           )
    2440                 :            :     {
    2441                 :            :         const ::rtl::OUString& sItem = pIt->first;
    2442                 :            :         ::comphelper::SequenceAsHashMap lProps(pIt->second);
    2443                 :            :         OUStringList                    lTypes(lProps[PROPNAME_TYPES]);
    2444                 :            : 
    2445                 :            :         if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end())
    2446                 :            :             return sItem;
    2447                 :            :     }
    2448                 :            : 
    2449                 :            :     return ::rtl::OUString();
    2450                 :            : }
    2451                 :            : 
    2452                 :            : 
    2453                 :            : 
    2454                 :            : ::rtl::OUString FilterCache::impl_searchContentHandlerForType(const ::rtl::OUString& sType) const
    2455                 :            : {
    2456                 :            :     CacheItemList::const_iterator pIt;
    2457                 :            :     for (  pIt  = m_lContentHandlers.begin();
    2458                 :            :            pIt != m_lContentHandlers.end()  ;
    2459                 :            :          ++pIt                              )
    2460                 :            :     {
    2461                 :            :         const ::rtl::OUString& sItem = pIt->first;
    2462                 :            :         ::comphelper::SequenceAsHashMap lProps(pIt->second);
    2463                 :            :         OUStringList                    lTypes(lProps[PROPNAME_TYPES]);
    2464                 :            : 
    2465                 :            :         if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end())
    2466                 :            :             return sItem;
    2467                 :            :     }
    2468                 :            : 
    2469                 :            :     return ::rtl::OUString();
    2470                 :            : }
    2471                 :            : #endif
    2472                 :            : 
    2473                 :            : 
    2474                 :            : 
    2475                 :      13390 : sal_Bool FilterCache::impl_isModuleInstalled(const ::rtl::OUString& sModule)
    2476                 :            : {
    2477                 :      13390 :     css::uno::Reference< css::container::XNameAccess > xCfg;
    2478                 :            : 
    2479                 :            :     // SAFE ->
    2480         [ +  - ]:      13390 :     ::osl::ResettableMutexGuard aLock(m_aLock);
    2481         [ +  + ]:      13390 :     if (! m_xModuleCfg.is())
    2482                 :            :     {
    2483                 :            :         m_xModuleCfg = css::uno::Reference< css::container::XNameAccess >(
    2484                 :            :                             ::comphelper::ConfigurationHelper::openConfig(
    2485                 :            :                                 m_xSMGR,
    2486                 :            :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Setup/Office/Factories" )),
    2487                 :            :                                 ::comphelper::ConfigurationHelper::E_READONLY),
    2488 [ +  - ][ +  - ]:        125 :                             css::uno::UNO_QUERY_THROW);
         [ +  - ][ +  - ]
    2489                 :            :     }
    2490                 :            : 
    2491         [ +  - ]:      13390 :     xCfg = m_xModuleCfg;
    2492         [ +  - ]:      13390 :     aLock.clear();
    2493                 :            :     // <- SAFE
    2494                 :            : 
    2495         [ +  - ]:      13390 :     if (xCfg.is())
    2496 [ +  - ][ +  - ]:      13390 :         return xCfg->hasByName(sModule);
    2497                 :            : 
    2498         [ +  - ]:      13390 :     return sal_False;
    2499                 :            : }
    2500                 :            : 
    2501                 :            :     } // namespace config
    2502                 :            : } // namespace filter
    2503                 :            : 
    2504                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10