LCOV - code coverage report
Current view: top level - unotools/source/config - moduleoptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 258 580 44.5 %
Date: 2012-08-25 Functions: 47 72 65.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 159 702 22.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <unotools/moduleoptions.hxx>
      22                 :            : #include <comphelper/sequenceashashmap.hxx>
      23                 :            : #include <unotools/configmgr.hxx>
      24                 :            : #include <unotools/configitem.hxx>
      25                 :            : #include <comphelper/componentcontext.hxx>
      26                 :            : #include <comphelper/processfactory.hxx>
      27                 :            : #include <osl/diagnose.h>
      28                 :            : #include <rtl/ustrbuf.hxx>
      29                 :            : 
      30                 :            : #include <rtl/logfile.hxx>
      31                 :            : #include <rtl/instance.hxx>
      32                 :            : #include <com/sun/star/uno/Any.hxx>
      33                 :            : #include <com/sun/star/uno/Sequence.hxx>
      34                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      35                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      36                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      37                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      38                 :            : #include <com/sun/star/document/XTypeDetection.hpp>
      39                 :            : #include <com/sun/star/util/PathSubstitution.hpp>
      40                 :            : #include <com/sun/star/util/XStringSubstitution.hpp>
      41                 :            : 
      42                 :            : #include "itemholder1.hxx"
      43                 :            : 
      44                 :            : //_________________________________________________________________________________________________________________
      45                 :            : //  namespaces
      46                 :            : //_________________________________________________________________________________________________________________
      47                 :            : 
      48                 :            : #ifndef css
      49                 :            : namespace css = ::com::sun::star;
      50                 :            : #endif
      51                 :            : 
      52                 :            : /*-************************************************************************************************************//**
      53                 :            :     @descr          These values are used to define neccessary keys from our configuration management to support
      54                 :            :                     all functionality of these implementation.
      55                 :            :                     It's a fast way to make changes if some keys change his name or location!
      56                 :            : 
      57                 :            :                     Property handle are neccessary to specify right position in return list of configuration
      58                 :            :                     for asked values. We ask it with a list of properties to get his values. The returned list
      59                 :            :                     has the same order like our given name list!
      60                 :            :                     e.g.:
      61                 :            :                             NAMELIST[ PROPERTYHANDLE_xxx ] => VALUELIST[ PROPERTYHANDLE_xxx ]
      62                 :            : *//*-*************************************************************************************************************/
      63                 :            : #define ROOTNODE_FACTORIES                  ::rtl::OUString("Setup/Office/Factories"        )
      64                 :            : #define PATHSEPERATOR                       ::rtl::OUString("/"                             )
      65                 :            : 
      66                 :            : // Attention: The property "ooSetupFactoryEmptyDocumentURL" is read from configuration but not used! There is
      67                 :            : //            special code that uses hard coded strings to return them.
      68                 :            : #define PROPERTYNAME_SHORTNAME              ::rtl::OUString("ooSetupFactoryShortName"       )
      69                 :            : #define PROPERTYNAME_TEMPLATEFILE           ::rtl::OUString("ooSetupFactoryTemplateFile"    )
      70                 :            : #define PROPERTYNAME_WINDOWATTRIBUTES       ::rtl::OUString("ooSetupFactoryWindowAttributes")
      71                 :            : #define PROPERTYNAME_EMPTYDOCUMENTURL       ::rtl::OUString("ooSetupFactoryEmptyDocumentURL")
      72                 :            : #define PROPERTYNAME_DEFAULTFILTER          ::rtl::OUString("ooSetupFactoryDefaultFilter"   )
      73                 :            : #define PROPERTYNAME_ICON                   ::rtl::OUString("ooSetupFactoryIcon"            )
      74                 :            : 
      75                 :            : #define PROPERTYHANDLE_SHORTNAME            0
      76                 :            : #define PROPERTYHANDLE_TEMPLATEFILE         1
      77                 :            : #define PROPERTYHANDLE_WINDOWATTRIBUTES     2
      78                 :            : #define PROPERTYHANDLE_EMPTYDOCUMENTURL     3
      79                 :            : #define PROPERTYHANDLE_DEFAULTFILTER        4
      80                 :            : #define PROPERTYHANDLE_ICON                 5
      81                 :            : 
      82                 :            : #define PROPERTYCOUNT                       6
      83                 :            : 
      84                 :            : #define FACTORYNAME_WRITER                  ::rtl::OUString("com.sun.star.text.TextDocument"                )
      85                 :            : #define FACTORYNAME_WRITERWEB               ::rtl::OUString("com.sun.star.text.WebDocument"                 )
      86                 :            : #define FACTORYNAME_WRITERGLOBAL            ::rtl::OUString("com.sun.star.text.GlobalDocument"              )
      87                 :            : #define FACTORYNAME_CALC                    ::rtl::OUString("com.sun.star.sheet.SpreadsheetDocument"        )
      88                 :            : #define FACTORYNAME_DRAW                    ::rtl::OUString("com.sun.star.drawing.DrawingDocument"          )
      89                 :            : #define FACTORYNAME_IMPRESS                 ::rtl::OUString("com.sun.star.presentation.PresentationDocument")
      90                 :            : #define FACTORYNAME_MATH                    ::rtl::OUString("com.sun.star.formula.FormulaProperties"        )
      91                 :            : #define FACTORYNAME_CHART                   ::rtl::OUString("com.sun.star.chart2.ChartDocument"             )
      92                 :            : #define FACTORYNAME_DATABASE                ::rtl::OUString("com.sun.star.sdb.OfficeDatabaseDocument"       )
      93                 :            : #define FACTORYNAME_STARTMODULE             ::rtl::OUString("com.sun.star.frame.StartModule"                )
      94                 :            : 
      95                 :            : #define FACTORYCOUNT                        10
      96                 :            : 
      97                 :            : /*-************************************************************************************************************//**
      98                 :            :     @descr  This struct hold information about one factory. We declare a complete array which can hold infos
      99                 :            :             for all well known factories. Values of enum "EFactory" (see header!) are directly used as index!
     100                 :            :             So we can support a fast access on these informations.
     101                 :            : *//*-*************************************************************************************************************/
     102                 :       1310 : struct FactoryInfo
     103                 :            : {
     104                 :            :     public:
     105                 :            :         //---------------------------------------------------------------------------------------------------------
     106                 :            :         // initialize empty struct
     107                 :       1310 :         FactoryInfo()
     108                 :       1310 :         {
     109                 :       1310 :             free();
     110                 :            :             // @@@ should be supplied from outside!
     111 [ +  - ][ +  - ]:       1310 :             xSMgr = ::comphelper::getProcessServiceFactory();
     112                 :       1310 :         }
     113                 :            : 
     114                 :            :         //---------------------------------------------------------------------------------------------------------
     115                 :            :         // easy way to reset struct member!
     116                 :       3858 :         void free()
     117                 :            :         {
     118                 :       3858 :             bInstalled                  = sal_False         ;
     119                 :       3858 :             sFactory                    = ::rtl::OUString() ;
     120                 :       3858 :             sShortName                  = ::rtl::OUString() ;
     121                 :       3858 :             sTemplateFile               = ::rtl::OUString() ;
     122                 :       3858 :             sWindowAttributes           = ::rtl::OUString() ;
     123                 :       3858 :             sEmptyDocumentURL           = ::rtl::OUString() ;
     124                 :       3858 :             sDefaultFilter              = ::rtl::OUString() ;
     125                 :       3858 :             nIcon                       = 0                 ;
     126                 :       3858 :             bChangedTemplateFile        = sal_False         ;
     127                 :       3858 :             bChangedWindowAttributes    = sal_False         ;
     128                 :       3858 :             bChangedEmptyDocumentURL    = sal_False         ;
     129                 :       3858 :             bChangedDefaultFilter       = sal_False         ;
     130                 :       3858 :             bChangedIcon                = sal_False         ;
     131                 :       3858 :             bDefaultFilterReadonly      = sal_False         ;
     132                 :       3858 :         }
     133                 :            : 
     134                 :            :         //---------------------------------------------------------------------------------------------------------
     135                 :            :         // returns list of properties, which has changed only!
     136                 :            :         // We use given value of sNodeBase to build full qualified paths ...
     137                 :            :         // Last sign of it must be "/". Beacuse we use it directly, without any additional things!
     138                 :          0 :         css::uno::Sequence< css::beans::PropertyValue > getChangedProperties( const ::rtl::OUString& sNodeBase )
     139                 :            :         {
     140                 :            :             // a) reserve memory for max. count of changed properties
     141                 :            :             // b) add names and values of changed ones only and count it
     142                 :            :             // c) resize return list by using count
     143                 :          0 :             css::uno::Sequence< css::beans::PropertyValue > lProperties   ( 4 );
     144                 :          0 :             sal_Int8                                        nRealyChanged = 0  ;
     145                 :            : 
     146         [ #  # ]:          0 :             if( bChangedTemplateFile == sal_True )
     147                 :            :             {
     148         [ #  # ]:          0 :                 lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_TEMPLATEFILE;
     149                 :            : 
     150         [ #  # ]:          0 :                 if ( !sTemplateFile.isEmpty() )
     151                 :            :                 {
     152         [ #  # ]:          0 :                     lProperties[nRealyChanged].Value
     153                 :            :                         <<= getStringSubstitution()
     154 [ #  # ][ #  # ]:          0 :                             ->reSubstituteVariables( sTemplateFile );
         [ #  # ][ #  # ]
     155                 :            :                 }
     156                 :            :                 else
     157                 :            :                 {
     158 [ #  # ][ #  # ]:          0 :                     lProperties[nRealyChanged].Value <<= sTemplateFile;
     159                 :            :                 }
     160                 :            : 
     161                 :          0 :                 ++nRealyChanged;
     162                 :            :             }
     163         [ #  # ]:          0 :             if( bChangedWindowAttributes == sal_True )
     164                 :            :             {
     165         [ #  # ]:          0 :                 lProperties[nRealyChanged].Name    = sNodeBase + PROPERTYNAME_WINDOWATTRIBUTES;
     166 [ #  # ][ #  # ]:          0 :                 lProperties[nRealyChanged].Value <<= sWindowAttributes;
     167                 :          0 :                 ++nRealyChanged;
     168                 :            :             }
     169         [ #  # ]:          0 :             if( bChangedEmptyDocumentURL == sal_True )
     170                 :            :             {
     171         [ #  # ]:          0 :                 lProperties[nRealyChanged].Name    = sNodeBase + PROPERTYNAME_EMPTYDOCUMENTURL;
     172 [ #  # ][ #  # ]:          0 :                 lProperties[nRealyChanged].Value <<= sEmptyDocumentURL;
     173                 :          0 :                 ++nRealyChanged;
     174                 :            :             }
     175         [ #  # ]:          0 :             if( bChangedDefaultFilter == sal_True )
     176                 :            :             {
     177         [ #  # ]:          0 :                 lProperties[nRealyChanged].Name    = sNodeBase + PROPERTYNAME_DEFAULTFILTER;
     178 [ #  # ][ #  # ]:          0 :                 lProperties[nRealyChanged].Value <<= sDefaultFilter;
     179                 :          0 :                 ++nRealyChanged;
     180                 :            :             }
     181         [ #  # ]:          0 :             if( bChangedIcon == sal_True )
     182                 :            :             {
     183         [ #  # ]:          0 :                 lProperties[nRealyChanged].Name    = sNodeBase + PROPERTYNAME_ICON;
     184 [ #  # ][ #  # ]:          0 :                 lProperties[nRealyChanged].Value <<= nIcon;
     185                 :          0 :                 ++nRealyChanged;
     186                 :            :             }
     187                 :            : 
     188                 :            :             // Don't forget to reset changed flags! Otherwise we save it again and again and ...
     189                 :          0 :             bChangedTemplateFile        = sal_False         ;
     190                 :          0 :             bChangedWindowAttributes    = sal_False         ;
     191                 :          0 :             bChangedEmptyDocumentURL    = sal_False         ;
     192                 :          0 :             bChangedDefaultFilter       = sal_False         ;
     193                 :          0 :             bChangedIcon                = sal_False         ;
     194                 :            : 
     195         [ #  # ]:          0 :             lProperties.realloc( nRealyChanged );
     196                 :          0 :             return lProperties;
     197                 :            :         }
     198                 :            : 
     199                 :            :         //---------------------------------------------------------------------------------------------------------
     200                 :            :         // We must support setting AND marking of changed values.
     201                 :            :         // That's why we can't make our member public. We must use get/set/init methods
     202                 :            :         // to control access on it!
     203                 :      27856 :         sal_Bool            getInstalled        () const { return bInstalled;         };
     204                 :         10 :         ::rtl::OUString     getFactory          () const { return sFactory;           };
     205                 :            :         ::rtl::OUString     getShortName        () const { return sShortName;         };
     206                 :       1093 :         ::rtl::OUString     getTemplateFile     () const { return sTemplateFile;      };
     207                 :            :         ::rtl::OUString     getWindowAttributes () const { return sWindowAttributes;  };
     208                 :         10 :         ::rtl::OUString     getDefaultFilter    () const { return sDefaultFilter;     };
     209                 :          0 :         sal_Bool            isDefaultFilterReadonly() const { return bDefaultFilterReadonly; }
     210                 :       1761 :         sal_Int32           getIcon             () const { return nIcon;              };
     211                 :            : 
     212                 :            :         //---------------------------------------------------------------------------------------------------------
     213                 :            :         // If you call set-methods - we check for changes of valkues and mark it.
     214                 :            :         // But if you whish to set it without that ... you must initialize it!
     215                 :       1238 :         void initInstalled        ( sal_Bool               bNewInstalled        ) { bInstalled        = bNewInstalled        ; }
     216                 :       1238 :         void initFactory          ( const ::rtl::OUString& sNewFactory          ) { sFactory          = sNewFactory          ; }
     217                 :       1238 :         void initShortName        ( const ::rtl::OUString& sNewShortName        ) { sShortName        = sNewShortName        ; }
     218                 :       1118 :         void initWindowAttributes ( const ::rtl::OUString& sNewWindowAttributes ) { sWindowAttributes = sNewWindowAttributes ; }
     219                 :       1116 :         void initEmptyDocumentURL ( const ::rtl::OUString& sNewEmptyDocumentURL ) { sEmptyDocumentURL = sNewEmptyDocumentURL ; }
     220                 :       1116 :         void initDefaultFilter    ( const ::rtl::OUString& sNewDefaultFilter    ) { sDefaultFilter    = sNewDefaultFilter    ; }
     221                 :          0 :         void setDefaultFilterReadonly( const sal_Bool bVal){bDefaultFilterReadonly = bVal;}
     222                 :       1238 :         void initIcon             ( sal_Int32              nNewIcon             ) { nIcon             = nNewIcon             ; }
     223                 :            : 
     224                 :            :         //---------------------------------------------------------------------------------------------------------
     225                 :       1116 :         void initTemplateFile( const ::rtl::OUString& sNewTemplateFile )
     226                 :            :         {
     227         [ -  + ]:       1116 :             if ( !sNewTemplateFile.isEmpty() )
     228                 :            :             {
     229                 :            :                 sTemplateFile
     230                 :            :                     = getStringSubstitution()
     231 [ #  # ][ #  # ]:          0 :                         ->substituteVariables( sNewTemplateFile, sal_False );
     232                 :            :             }
     233                 :            :             else
     234                 :            :             {
     235                 :       1116 :                 sTemplateFile = sNewTemplateFile;
     236                 :            :             }
     237                 :       1116 :         }
     238                 :            : 
     239                 :            :         //---------------------------------------------------------------------------------------------------------
     240                 :          0 :         void setTemplateFile( const ::rtl::OUString& sNewTemplateFile )
     241                 :            :         {
     242         [ #  # ]:          0 :             if( sTemplateFile != sNewTemplateFile )
     243                 :            :             {
     244                 :          0 :                 sTemplateFile        = sNewTemplateFile;
     245                 :          0 :                 bChangedTemplateFile = sal_True        ;
     246                 :            :             }
     247                 :          0 :         };
     248                 :            : 
     249                 :            :         //---------------------------------------------------------------------------------------------------------
     250                 :            :         void setWindowAttributes( const ::rtl::OUString& sNewWindowAttributes )
     251                 :            :         {
     252                 :            :             if( sWindowAttributes != sNewWindowAttributes )
     253                 :            :             {
     254                 :            :                 sWindowAttributes        = sNewWindowAttributes;
     255                 :            :                 bChangedWindowAttributes = sal_True            ;
     256                 :            :             }
     257                 :            :         };
     258                 :            : 
     259                 :            :         //---------------------------------------------------------------------------------------------------------
     260                 :          0 :         void setDefaultFilter( const ::rtl::OUString& sNewDefaultFilter )
     261                 :            :         {
     262         [ #  # ]:          0 :             if( sDefaultFilter != sNewDefaultFilter )
     263                 :            :             {
     264                 :          0 :                 sDefaultFilter       = sNewDefaultFilter;
     265                 :          0 :                 bChangedDefaultFilter = sal_True         ;
     266                 :            :             }
     267                 :          0 :         };
     268                 :            : 
     269                 :            :     private:
     270                 :          0 :         css::uno::Reference< css::util::XStringSubstitution > getStringSubstitution()
     271                 :            :         {
     272         [ #  # ]:          0 :             if ( !xSubstVars.is() )
     273                 :            :             {
     274 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< css::uno::XComponentContext > xContext( comphelper::ComponentContext(xSMgr).getUNOContext() );
                 [ #  # ]
     275                 :            :                 xSubstVars
     276                 :            :                     = css::uno::Reference< css::util::XStringSubstitution >(
     277 [ #  # ][ #  # ]:          0 :                         css::util::PathSubstitution::create(xContext) );
     278                 :            :             }
     279                 :          0 :             return xSubstVars;
     280                 :            :         }
     281                 :            : 
     282                 :            :         sal_Bool            bInstalled                      ;
     283                 :            :         ::rtl::OUString     sFactory                        ;
     284                 :            :         ::rtl::OUString     sShortName                      ;
     285                 :            :         ::rtl::OUString     sTemplateFile                   ;
     286                 :            :         ::rtl::OUString     sWindowAttributes               ;
     287                 :            :         ::rtl::OUString     sEmptyDocumentURL               ;
     288                 :            :         ::rtl::OUString     sDefaultFilter                  ;
     289                 :            :         sal_Int32           nIcon                           ;
     290                 :            : 
     291                 :            :         sal_Bool            bChangedTemplateFile        :1  ;
     292                 :            :         sal_Bool            bChangedWindowAttributes    :1  ;
     293                 :            :         sal_Bool            bChangedEmptyDocumentURL    :1  ;
     294                 :            :         sal_Bool            bChangedDefaultFilter       :1  ;
     295                 :            :         sal_Bool            bChangedIcon                :1  ;
     296                 :            :         sal_Bool            bDefaultFilterReadonly      :1  ;
     297                 :            : 
     298                 :            :         css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr;
     299                 :            :         css::uno::Reference< css::util::XStringSubstitution >  xSubstVars;
     300                 :            : };
     301                 :            : 
     302                 :            : typedef FactoryInfo   FactoryInfoList[FACTORYCOUNT];
     303                 :            : 
     304                 :            : /*-************************************************************************************************************//**
     305                 :            :     @short          IMPL data container for wrapper class SvtModulOptions!
     306                 :            :     @descr          These class is used as a static data container of class SvtModuleOptions. The hold it by using
     307                 :            :                     a refcount and make it threadsafe by using an osl mutex. So we don't must do anything for that.
     308                 :            :                     We can implement pure functionality to read/write configuration data only.
     309                 :            : 
     310                 :            :     @implements     -
     311                 :            :     @base           ConfigItem
     312                 :            : 
     313                 :            :     @devstatus      ready to use
     314                 :            :     @threadsafe     no
     315                 :            : *//*-*************************************************************************************************************/
     316                 :            : class SvtModuleOptions_Impl : public ::utl::ConfigItem
     317                 :            : {
     318                 :            :     //-------------------------------------------------------------------------------------------------------------
     319                 :            :     //  public methods
     320                 :            :     //-------------------------------------------------------------------------------------------------------------
     321                 :            :     public:
     322                 :            :         //---------------------------------------------------------------------------------------------------------
     323                 :            :         //  constructor / destructor
     324                 :            :         //---------------------------------------------------------------------------------------------------------
     325                 :            :          SvtModuleOptions_Impl();
     326                 :            :         ~SvtModuleOptions_Impl();
     327                 :            : 
     328                 :            :         //---------------------------------------------------------------------------------------------------------
     329                 :            :         //  overloaded methods of baseclass
     330                 :            :         //---------------------------------------------------------------------------------------------------------
     331                 :            :         virtual void Notify( const css::uno::Sequence< ::rtl::OUString >& lPropertyNames );
     332                 :            :         virtual void Commit(                                                             );
     333                 :            : 
     334                 :            :         //---------------------------------------------------------------------------------------------------------
     335                 :            :         //  public interface
     336                 :            :         //---------------------------------------------------------------------------------------------------------
     337                 :            :         sal_Bool        IsModuleInstalled         (       SvtModuleOptions::EModule     eModule    ) const;
     338                 :            :         ::com::sun::star::uno::Sequence < ::rtl::OUString > GetAllServiceNames();
     339                 :            :         ::rtl::OUString GetFactoryName            (       SvtModuleOptions::EFactory    eFactory   ) const;
     340                 :            :         ::rtl::OUString GetFactoryShortName       (       SvtModuleOptions::EFactory    eFactory   ) const;
     341                 :            :         ::rtl::OUString GetFactoryStandardTemplate(       SvtModuleOptions::EFactory    eFactory   ) const;
     342                 :            :         ::rtl::OUString GetFactoryEmptyDocumentURL(       SvtModuleOptions::EFactory    eFactory   ) const;
     343                 :            :         ::rtl::OUString GetFactoryDefaultFilter   (       SvtModuleOptions::EFactory    eFactory   ) const;
     344                 :            :         sal_Bool        IsDefaultFilterReadonly(          SvtModuleOptions::EFactory eFactory      ) const;
     345                 :            :         sal_Int32       GetFactoryIcon            (       SvtModuleOptions::EFactory    eFactory   ) const;
     346                 :            :         static sal_Bool ClassifyFactoryByName     ( const ::rtl::OUString&              sName      ,
     347                 :            :                                                           SvtModuleOptions::EFactory&   eFactory   );
     348                 :            :         void            SetFactoryStandardTemplate(       SvtModuleOptions::EFactory    eFactory   ,
     349                 :            :                                                     const ::rtl::OUString&              sTemplate  );
     350                 :            :         void            SetFactoryDefaultFilter   (       SvtModuleOptions::EFactory    eFactory   ,
     351                 :            :                                                     const ::rtl::OUString&              sFilter    );
     352                 :            :         void            MakeReadonlyStatesAvailable();
     353                 :            : 
     354                 :            :     //-------------------------------------------------------------------------------------------------------------
     355                 :            :     //  private methods
     356                 :            :     //-------------------------------------------------------------------------------------------------------------
     357                 :            :     private:
     358                 :            :         static css::uno::Sequence< ::rtl::OUString > impl_ExpandSetNames ( const css::uno::Sequence< ::rtl::OUString >& lSetNames   );
     359                 :            :                void                                  impl_Read           ( const css::uno::Sequence< ::rtl::OUString >& lSetNames   );
     360                 :            : 
     361                 :            :     //-------------------------------------------------------------------------------------------------------------
     362                 :            :     //  private types
     363                 :            :     //-------------------------------------------------------------------------------------------------------------
     364                 :            :     private:
     365                 :            : 
     366                 :            :     //-------------------------------------------------------------------------------------------------------------
     367                 :            :     //  private member
     368                 :            :     //-------------------------------------------------------------------------------------------------------------
     369                 :            :     private:
     370                 :            :         FactoryInfoList     m_lFactories;
     371                 :            :         sal_Bool            m_bReadOnlyStatesWellKnown;
     372                 :            : };
     373                 :            : 
     374                 :            : /*-************************************************************************************************************//**
     375                 :            :     @short      default ctor
     376                 :            :     @descr      We open our configuration here and read all neccessary values from it.
     377                 :            :                 These values are cached till everyone call Commit(). Then we write changed ones back to cfg.
     378                 :            : 
     379                 :            :     @seealso    baseclass ConfigItem
     380                 :            :     @seealso    method impl_Read()
     381                 :            : 
     382                 :            :     @param      -
     383                 :            :     @return     -
     384                 :            : 
     385                 :            :     @onerror    -
     386                 :            :     @threadsafe no
     387                 :            : *//*-*************************************************************************************************************/
     388                 :        131 : SvtModuleOptions_Impl::SvtModuleOptions_Impl()
     389                 :            :     :   ::utl::ConfigItem( ROOTNODE_FACTORIES )
     390 [ +  - ][ +  - ]:       1441 :     ,   m_bReadOnlyStatesWellKnown( sal_False )
           [ +  +  #  #  
                   #  # ]
     391                 :            : {
     392                 :            :     // First initialize list of factory infos! Otherwise we couldnt gurantee right working of these class.
     393         [ +  + ]:       1441 :     for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
     394                 :       1310 :         m_lFactories[nFactory].free();
     395                 :            : 
     396                 :            :     // Get name list of all existing set node names in configuration to read her properties in impl_Read().
     397                 :            :     // These list is a list of long names of our factories.
     398         [ +  - ]:        131 :     const css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames( ::rtl::OUString() );
     399         [ +  - ]:        131 :     impl_Read( lFactories );
     400                 :            : 
     401                 :            :     // Enable notification for changes by using configuration directly.
     402                 :            :     // So we can update our internal values immediatly.
     403 [ +  - ][ +  - ]:        131 :     EnableNotification( lFactories );
     404   [ #  #  #  # ]:        131 : }
     405                 :            : 
     406                 :            : /*-************************************************************************************************************//**
     407                 :            :     @short      default dtor
     408                 :            :     @descr      If any values of our cache was modified we should write it back to configuration.
     409                 :            : 
     410                 :            :     @attention  Don't forget to call "SetModified()" method of base class ConfigItem if any interface method
     411                 :            :                 of this class modify internal member list m_lFactories! Otherwise Commit() will never be called!!!
     412                 :            : 
     413                 :            :     @seealso    baseclass ConfigItem
     414                 :            : 
     415                 :            :     @param      -
     416                 :            :     @return     -
     417                 :            : 
     418                 :            :     @onerror    -
     419                 :            :     @threadsafe no
     420                 :            : *//*-*************************************************************************************************************/
     421         [ +  - ]:       1441 : SvtModuleOptions_Impl::~SvtModuleOptions_Impl()
     422                 :            : {
     423 [ +  - ][ -  + ]:        131 :     if( IsModified() == sal_True )
     424                 :            :     {
     425         [ #  # ]:          0 :         Commit();
     426                 :            :     }
     427 [ +  - ][ +  + ]:       1703 : }
                 [ -  + ]
           [ #  #  #  # ]
     428                 :            : 
     429                 :            : /*-************************************************************************************************************//**
     430                 :            :     @short      called for notify of configmanager
     431                 :            :     @descr      These method is called from the ConfigManager before application ends or from the
     432                 :            :                 PropertyChangeListener if the sub tree broadcasts changes. You must update our
     433                 :            :                 internal values.
     434                 :            : 
     435                 :            :     @attention  We are registered for pure set node names only. So we can use our internal method "impl_Read()" to
     436                 :            :                 update our info list. Because - these method expand given name list to full qualified property list
     437                 :            :                 and use it to read the values. These values are filled into our internal member list m_lFactories
     438                 :            :                 at right position.
     439                 :            : 
     440                 :            :     @seealso    method impl_Read()
     441                 :            : 
     442                 :            :     @param      "lNames" is the list of set node entries which should be updated.
     443                 :            :     @return     -
     444                 :            : 
     445                 :            :     @onerror    -
     446                 :            :     @threadsafe no
     447                 :            : *//*-*************************************************************************************************************/
     448                 :          0 : void SvtModuleOptions_Impl::Notify( const css::uno::Sequence< ::rtl::OUString >& )
     449                 :            : {
     450                 :            :     OSL_FAIL( "SvtModuleOptions_Impl::Notify()\nNot implemented yet!\n" );
     451                 :          0 : }
     452                 :            : 
     453                 :            : /*-****************************************************************************************************//**
     454                 :            :     @short      write changes to configuration
     455                 :            :     @descr      These method writes the changed values into the sub tree
     456                 :            :                 and should always called in our destructor to guarantee consistency of config data.
     457                 :            : 
     458                 :            :     @attention  We clear complete set in configuration first and write it completly new! So we don't must
     459                 :            :                 distinguish between existing, added or removed elements. Our internal cached values
     460                 :            :                 are the only and right ones.
     461                 :            : 
     462                 :            :     @seealso    baseclass ConfigItem
     463                 :            : 
     464                 :            :     @param      -
     465                 :            :     @return     -
     466                 :            : 
     467                 :            :     @onerror    -
     468                 :            :     @threadsafe no
     469                 :            : *//*-*****************************************************************************************************/
     470                 :          0 : void SvtModuleOptions_Impl::Commit()
     471                 :            : {
     472                 :            :     // Reserve memory for ALL possible factory properties!
     473                 :            :     // Step over all factories and get her realy changed values only.
     474                 :            :     // Build list of these ones and use it for commit.
     475         [ #  # ]:          0 :     css::uno::Sequence< css::beans::PropertyValue > lCommitProperties( FACTORYCOUNT*PROPERTYCOUNT );
     476                 :          0 :     FactoryInfo*                                    pInfo            = NULL                        ;
     477                 :          0 :     sal_Int32                                       nRealCount       = 0                           ;
     478                 :          0 :     ::rtl::OUString                                 sBasePath                                      ;
     479         [ #  # ]:          0 :     for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
     480                 :            :     {
     481                 :          0 :         pInfo = &(m_lFactories[nFactory]);
     482                 :            : 
     483                 :            :         // These path is used to build full qualified property names ....
     484                 :            :         // See pInfo->getChangedProperties() for further informations
     485                 :          0 :         sBasePath  = PATHSEPERATOR + pInfo->getFactory() + PATHSEPERATOR;
     486                 :            : 
     487         [ #  # ]:          0 :         const css::uno::Sequence< css::beans::PropertyValue > lChangedProperties = pInfo->getChangedProperties ( sBasePath );
     488                 :          0 :         const css::beans::PropertyValue*                      pChangedProperties = lChangedProperties.getConstArray();
     489                 :          0 :         sal_Int32                                             nPropertyCount     = lChangedProperties.getLength();
     490         [ #  # ]:          0 :         for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
     491                 :            :         {
     492         [ #  # ]:          0 :             lCommitProperties[nRealCount] = pChangedProperties[nProperty];
     493                 :          0 :             ++nRealCount;
     494                 :            :         }
     495         [ #  # ]:          0 :     }
     496                 :            :     // Resize commit list to real size.
     497                 :            :     // If nothing to do - suppress calling of configuration ...
     498                 :            :     // It could be to expensive :-)
     499         [ #  # ]:          0 :     if( nRealCount > 0 )
     500                 :            :     {
     501         [ #  # ]:          0 :         lCommitProperties.realloc( nRealCount );
     502 [ #  # ][ #  # ]:          0 :         SetSetProperties( ::rtl::OUString(), lCommitProperties );
                 [ #  # ]
     503         [ #  # ]:          0 :     }
     504                 :          0 : }
     505                 :            : 
     506                 :            : /*-****************************************************************************************************//**
     507                 :            :     @short      access method to get internal values
     508                 :            :     @descr      These methods implement easy access to our internal values.
     509                 :            :                 You give us right enum value to specify which module interest you ... we return right information.
     510                 :            : 
     511                 :            :     @attention  Some poeple use any value as enum ... but we support in header specified values only!
     512                 :            :                 We use it directly as index in our internal list. If enum value isn't right - we crash with an
     513                 :            :                 "index out of range"!!! Please use me right - otherwise there is no guarantee.
     514                 :            : 
     515                 :            :     @seealso    -
     516                 :            : 
     517                 :            :     @param      "eModule"  , index in list - specify module
     518                 :            :     @param      "eFactory" , index in list - specify factory
     519                 :            :     @param      "sTemplate", set new standard template for these factory
     520                 :            :     @return     Queried information.
     521                 :            : 
     522                 :            :     @onerror    We return default values. (mostly "not installed"!)
     523                 :            :     @threadsafe no
     524                 :            : *//*-*****************************************************************************************************/
     525                 :      27856 : sal_Bool SvtModuleOptions_Impl::IsModuleInstalled( SvtModuleOptions::EModule eModule ) const
     526                 :            : {
     527                 :      27856 :     sal_Bool bInstalled = sal_False;
     528   [ +  -  -  +  :      27856 :     switch( eModule )
          +  +  +  +  +  
                -  +  - ]
     529                 :            :     {
     530                 :       2048 :         case SvtModuleOptions::E_SWRITER    :   bInstalled = m_lFactories[SvtModuleOptions::E_WRITER].getInstalled();
     531                 :       2048 :                                                 break;
     532                 :          0 :         case SvtModuleOptions::E_SWEB       :   bInstalled = m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled();
     533                 :          0 :                                                 break;
     534                 :          0 :         case SvtModuleOptions::E_SGLOBAL    :   bInstalled = m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled();
     535                 :          0 :                                                 break;
     536                 :       6387 :         case SvtModuleOptions::E_SCALC      :   bInstalled = m_lFactories[SvtModuleOptions::E_CALC].getInstalled();
     537                 :       6387 :                                                 break;
     538                 :         77 :         case SvtModuleOptions::E_SDRAW      :   bInstalled = m_lFactories[SvtModuleOptions::E_DRAW].getInstalled();
     539                 :         77 :                                                 break;
     540                 :         87 :         case SvtModuleOptions::E_SIMPRESS   :   bInstalled = m_lFactories[SvtModuleOptions::E_IMPRESS].getInstalled();
     541                 :         87 :                                                 break;
     542                 :       6387 :         case SvtModuleOptions::E_SMATH      :   bInstalled = m_lFactories[SvtModuleOptions::E_MATH].getInstalled();
     543                 :       6387 :                                                 break;
     544                 :       6669 :         case SvtModuleOptions::E_SCHART     :   bInstalled = m_lFactories[SvtModuleOptions::E_CHART].getInstalled();
     545                 :       6669 :                                                 break;
     546                 :       3124 :         case SvtModuleOptions::E_SSTARTMODULE :   bInstalled = m_lFactories[SvtModuleOptions::E_STARTMODULE].getInstalled();
     547                 :       3124 :                                                 break;
     548                 :          0 :         case SvtModuleOptions::E_SBASIC     :   bInstalled = sal_True; // Couldn't be deselected by setup yet!
     549                 :          0 :                                                 break;
     550                 :       3077 :         case SvtModuleOptions::E_SDATABASE  :   bInstalled = m_lFactories[SvtModuleOptions::E_DATABASE].getInstalled();
     551                 :       3077 :                                                 break;
     552                 :            :     }
     553                 :            : 
     554                 :      27856 :     return bInstalled;
     555                 :            : }
     556                 :            : 
     557                 :          0 : ::com::sun::star::uno::Sequence < ::rtl::OUString > SvtModuleOptions_Impl::GetAllServiceNames()
     558                 :            : {
     559                 :          0 :     sal_uInt32 nCount=0;
     560         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_WRITER].getInstalled() )
     561                 :          0 :         nCount++;
     562         [ #  # ]:          0 :     if ( m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled() )
     563                 :          0 :         nCount++;
     564         [ #  # ]:          0 :     if ( m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled() )
     565                 :          0 :         nCount++;
     566         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SCALC].getInstalled() )
     567                 :          0 :         nCount++;
     568         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SDRAW].getInstalled() )
     569                 :          0 :         nCount++;
     570         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SIMPRESS].getInstalled() )
     571                 :          0 :         nCount++;
     572         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SCHART].getInstalled() )
     573                 :          0 :         nCount++;
     574         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SMATH].getInstalled() )
     575                 :          0 :         nCount++;
     576         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SBASIC].getInstalled() )
     577                 :          0 :         nCount++;
     578         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SDATABASE].getInstalled() )
     579                 :          0 :         nCount++;
     580                 :            : 
     581                 :          0 :     css::uno::Sequence < ::rtl::OUString > aRet( nCount );
     582                 :          0 :     sal_Int32 n=0;
     583         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_WRITER].getInstalled() )
     584         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITER].getFactory();
     585         [ #  # ]:          0 :     if ( m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled() )
     586         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITERWEB].getFactory();
     587         [ #  # ]:          0 :     if ( m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled() )
     588         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getFactory();
     589         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SCALC].getInstalled() )
     590         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SCALC].getFactory();
     591         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SDRAW].getInstalled() )
     592         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SDRAW].getFactory();
     593         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SIMPRESS].getInstalled() )
     594         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SIMPRESS].getFactory();
     595         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SCHART].getInstalled() )
     596         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SCHART].getFactory();
     597         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SMATH].getInstalled() )
     598         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SMATH].getFactory();
     599         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SBASIC].getInstalled() )
     600         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SBASIC].getFactory();
     601         [ #  # ]:          0 :     if( m_lFactories[SvtModuleOptions::E_SDATABASE].getInstalled() )
     602         [ #  # ]:          0 :         aRet[n++] = m_lFactories[SvtModuleOptions::E_SDATABASE].getFactory();
     603                 :            : 
     604                 :          0 :     return aRet;
     605                 :            : }
     606                 :            : 
     607                 :            : //*****************************************************************************************************************
     608                 :         10 : ::rtl::OUString SvtModuleOptions_Impl::GetFactoryName( SvtModuleOptions::EFactory eFactory ) const
     609                 :            : {
     610                 :         10 :     ::rtl::OUString sName;
     611                 :            : 
     612 [ +  - ][ +  - ]:         10 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     613                 :            :     {
     614                 :         10 :         sName = m_lFactories[eFactory].getFactory();
     615                 :            :     }
     616                 :            : 
     617                 :         10 :     return sName;
     618                 :            : }
     619                 :            : 
     620                 :            : //*****************************************************************************************************************
     621                 :       1187 : ::rtl::OUString SvtModuleOptions_Impl::GetFactoryShortName( SvtModuleOptions::EFactory eFactory ) const
     622                 :            : {
     623                 :            :     // Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
     624                 :            :     //            But it's good to plan further possibilities!
     625                 :            : 
     626                 :            :     //return m_lFactories[eFactory].sShortName;
     627                 :            : 
     628                 :       1187 :     ::rtl::OUString sShortName;
     629   [ +  -  -  -  :       1187 :     switch( eFactory )
          -  -  -  -  -  
                   -  - ]
     630                 :            :     {
     631                 :       1187 :         case SvtModuleOptions::E_WRITER        :  sShortName = ::rtl::OUString("swriter");
     632                 :       1187 :                                                   break;
     633                 :          0 :         case SvtModuleOptions::E_WRITERWEB     :  sShortName = ::rtl::OUString("swriter/web");
     634                 :          0 :                                                   break;
     635                 :          0 :         case SvtModuleOptions::E_WRITERGLOBAL  :  sShortName = ::rtl::OUString("swriter/GlobalDocument");
     636                 :          0 :                                                   break;
     637                 :          0 :         case SvtModuleOptions::E_CALC          :  sShortName = ::rtl::OUString("scalc");
     638                 :          0 :                                                   break;
     639                 :          0 :         case SvtModuleOptions::E_DRAW          :  sShortName = ::rtl::OUString("sdraw");
     640                 :          0 :                                                   break;
     641                 :          0 :         case SvtModuleOptions::E_IMPRESS       :  sShortName = ::rtl::OUString("simpress");
     642                 :          0 :                                                   break;
     643                 :          0 :         case SvtModuleOptions::E_MATH          :  sShortName = ::rtl::OUString("smath");
     644                 :          0 :                                                   break;
     645                 :          0 :         case SvtModuleOptions::E_CHART         :  sShortName = ::rtl::OUString("schart");
     646                 :          0 :                                                   break;
     647                 :          0 :         case SvtModuleOptions::E_BASIC         :  sShortName = ::rtl::OUString("sbasic");
     648                 :          0 :                                                   break;
     649                 :          0 :         case SvtModuleOptions::E_DATABASE     :  sShortName = ::rtl::OUString("sdatabase");
     650                 :          0 :                                                   break;
     651                 :            :         default:
     652                 :            :             OSL_FAIL( "unknown factory" );
     653                 :          0 :             break;
     654                 :            :     }
     655                 :            : 
     656                 :       1187 :     return sShortName;
     657                 :            : }
     658                 :            : 
     659                 :            : //*****************************************************************************************************************
     660                 :       1093 : ::rtl::OUString SvtModuleOptions_Impl::GetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ) const
     661                 :            : {
     662                 :       1093 :     ::rtl::OUString sFile;
     663                 :            : 
     664 [ +  - ][ +  - ]:       1093 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     665                 :            :     {
     666                 :       1093 :         sFile = m_lFactories[eFactory].getTemplateFile();
     667                 :            :     }
     668                 :            : 
     669                 :       1093 :     return sFile;
     670                 :            : }
     671                 :            : 
     672                 :            : //*****************************************************************************************************************
     673                 :          0 : ::rtl::OUString SvtModuleOptions_Impl::GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory eFactory ) const
     674                 :            : {
     675                 :            :     // Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
     676                 :            :     //            But it's good to plan further possibilities!
     677                 :            : 
     678                 :            :     //return m_lFactories[eFactory].getEmptyDocumentURL();
     679                 :            : 
     680                 :          0 :     ::rtl::OUString sURL;
     681   [ #  #  #  #  :          0 :     switch( eFactory )
          #  #  #  #  #  
                   #  # ]
     682                 :            :     {
     683                 :          0 :         case SvtModuleOptions::E_WRITER        :  sURL = ::rtl::OUString("private:factory/swriter");
     684                 :          0 :                                                   break;
     685                 :          0 :         case SvtModuleOptions::E_WRITERWEB     :  sURL = ::rtl::OUString("private:factory/swriter/web");
     686                 :          0 :                                                   break;
     687                 :          0 :         case SvtModuleOptions::E_WRITERGLOBAL  :  sURL = ::rtl::OUString("private:factory/swriter/GlobalDocument");
     688                 :          0 :                                                   break;
     689                 :          0 :         case SvtModuleOptions::E_CALC          :  sURL = ::rtl::OUString("private:factory/scalc");
     690                 :          0 :                                                   break;
     691                 :          0 :         case SvtModuleOptions::E_DRAW          :  sURL = ::rtl::OUString("private:factory/sdraw");
     692                 :          0 :                                                   break;
     693                 :          0 :         case SvtModuleOptions::E_IMPRESS       :  sURL = ::rtl::OUString("private:factory/simpress?slot=6686");
     694                 :          0 :                                                   break;
     695                 :          0 :         case SvtModuleOptions::E_MATH          :  sURL = ::rtl::OUString("private:factory/smath");
     696                 :          0 :                                                   break;
     697                 :          0 :         case SvtModuleOptions::E_CHART         :  sURL = ::rtl::OUString("private:factory/schart");
     698                 :          0 :                                                   break;
     699                 :          0 :         case SvtModuleOptions::E_BASIC         :  sURL = ::rtl::OUString("private:factory/sbasic");
     700                 :          0 :                                                   break;
     701                 :          0 :         case SvtModuleOptions::E_DATABASE     :  sURL = ::rtl::OUString("private:factory/sdatabase?Interactive");
     702                 :          0 :                                                   break;
     703                 :            :         default:
     704                 :            :             OSL_FAIL( "unknown factory" );
     705                 :          0 :             break;
     706                 :            :     }
     707                 :          0 :     return sURL;
     708                 :            : }
     709                 :            : 
     710                 :            : //*****************************************************************************************************************
     711                 :         10 : ::rtl::OUString SvtModuleOptions_Impl::GetFactoryDefaultFilter( SvtModuleOptions::EFactory eFactory ) const
     712                 :            : {
     713                 :         10 :     ::rtl::OUString sDefaultFilter;
     714                 :            : 
     715 [ +  - ][ +  - ]:         10 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     716                 :            :     {
     717                 :         10 :         sDefaultFilter = m_lFactories[eFactory].getDefaultFilter();
     718                 :            :     }
     719                 :         10 :     return sDefaultFilter;
     720                 :            : }
     721                 :            : //*****************************************************************************************************************
     722                 :          0 : sal_Bool SvtModuleOptions_Impl::IsDefaultFilterReadonly( SvtModuleOptions::EFactory eFactory   ) const
     723                 :            : {
     724                 :          0 :     sal_Bool bRet = sal_False;
     725 [ #  # ][ #  # ]:          0 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     726                 :            :     {
     727                 :          0 :         bRet = m_lFactories[eFactory].isDefaultFilterReadonly();
     728                 :            :     }
     729                 :          0 :     return bRet;
     730                 :            : }
     731                 :            : 
     732                 :            : //*****************************************************************************************************************
     733                 :       1761 : sal_Int32 SvtModuleOptions_Impl::GetFactoryIcon( SvtModuleOptions::EFactory eFactory ) const
     734                 :            : {
     735                 :       1761 :     sal_Int32 nIcon = 0;
     736                 :            : 
     737 [ +  - ][ +  - ]:       1761 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     738                 :            :     {
     739                 :       1761 :         nIcon = m_lFactories[eFactory].getIcon();
     740                 :            :     }
     741                 :            : 
     742                 :       1761 :     return nIcon;
     743                 :            : }
     744                 :            : 
     745                 :            : //*****************************************************************************************************************
     746                 :          0 : void SvtModuleOptions_Impl::SetFactoryStandardTemplate(       SvtModuleOptions::EFactory eFactory   ,
     747                 :            :                                                         const ::rtl::OUString&           sTemplate  )
     748                 :            : {
     749 [ #  # ][ #  # ]:          0 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     750                 :            :     {
     751                 :          0 :         m_lFactories[eFactory].setTemplateFile( sTemplate );
     752                 :          0 :         SetModified();
     753                 :            :     }
     754                 :          0 : }
     755                 :            : 
     756                 :            : //*****************************************************************************************************************
     757                 :          0 : void SvtModuleOptions_Impl::SetFactoryDefaultFilter(       SvtModuleOptions::EFactory eFactory,
     758                 :            :                                                      const ::rtl::OUString&           sFilter )
     759                 :            : {
     760 [ #  # ][ #  # ]:          0 :     if( eFactory>=0 && eFactory<FACTORYCOUNT )
     761                 :            :     {
     762                 :          0 :         m_lFactories[eFactory].setDefaultFilter( sFilter );
     763                 :          0 :         SetModified();
     764                 :            :     }
     765                 :          0 : }
     766                 :            : 
     767                 :            : /*-************************************************************************************************************//**
     768                 :            :     @short      return list of key names of ouer configuration management which represent our module tree
     769                 :            :     @descr      You give use a list of current existing set node names .. and we expand it for all
     770                 :            :                 well known properties which are neccessary for this implementation.
     771                 :            :                 These full expanded list should be used to get values of this properties.
     772                 :            : 
     773                 :            :     @seealso    ctor
     774                 :            : 
     775                 :            :     @param      -
     776                 :            :     @return     List of all relative addressed properties of given set entry names.
     777                 :            : 
     778                 :            :     @onerror    List will be empty.
     779                 :            :     @threadsafe no
     780                 :            : *//*-*************************************************************************************************************/
     781                 :        131 : css::uno::Sequence< ::rtl::OUString > SvtModuleOptions_Impl::impl_ExpandSetNames( const css::uno::Sequence< ::rtl::OUString >& lSetNames )
     782                 :            : {
     783                 :        131 :     sal_Int32                             nCount     = lSetNames.getLength() ;
     784                 :        131 :     css::uno::Sequence< ::rtl::OUString > lPropNames ( nCount*PROPERTYCOUNT );
     785         [ +  - ]:        131 :     ::rtl::OUString*                      pPropNames = lPropNames.getArray() ;
     786                 :        131 :     sal_Int32                             nPropStart = 0                     ;
     787                 :            : 
     788         [ +  + ]:       2791 :     for( sal_Int32 nName=0; nName<nCount; ++nName )
     789                 :            :     {
     790                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME       ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_SHORTNAME       ;
     791                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE    ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE    ;
     792                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES;
     793                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL;
     794                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_DEFAULTFILTER   ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_DEFAULTFILTER   ;
     795                 :       2660 :         pPropNames[nPropStart+PROPERTYHANDLE_ICON            ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_ICON            ;
     796                 :       2660 :         nPropStart += PROPERTYCOUNT;
     797                 :            :     }
     798                 :            : 
     799                 :        131 :     return lPropNames;
     800                 :            : }
     801                 :            : 
     802                 :            : /*-************************************************************************************************************//**
     803                 :            :     @short      helper to classify given factory by name
     804                 :            :     @descr      Every factory has his own long and short name. So we can match right enum value for internal using.
     805                 :            : 
     806                 :            :     @attention  We change in/out parameter "eFactory" in every case! But you should use it only, if return value is sal_True!
     807                 :            :                 Algorithm:  Set out-parameter to propably value ... and check the longname.
     808                 :            :                             If it match with these factory - break operation and return true AND right set parameter.
     809                 :            :                             Otherwise try next one and so on. If no factory was found return false. Out parameter eFactory
     810                 :            :                             is set to last tried value but shouldn't be used! Because our return value is false!
     811                 :            : 
     812                 :            :     @seealso    -
     813                 :            : 
     814                 :            :     @param      "sLongName" , long name of factory, which should be classified
     815                 :            :     @return     "eFactory"  , right enum value, which match given long name
     816                 :            :                 and true for successfully classification, false otherwise
     817                 :            : 
     818                 :            :     @onerror    We return false.
     819                 :            :     @threadsafe no
     820                 :            : *//*-*************************************************************************************************************/
     821                 :       2660 : sal_Bool SvtModuleOptions_Impl::ClassifyFactoryByName( const ::rtl::OUString& sName, SvtModuleOptions::EFactory& eFactory )
     822                 :            : {
     823                 :            :     sal_Bool bState;
     824                 :            : 
     825                 :       2660 :     eFactory = SvtModuleOptions::E_WRITER     ;
     826                 :       2660 :     bState   = ( sName == FACTORYNAME_WRITER );
     827                 :            : 
     828         [ +  + ]:       2660 :     if( bState == sal_False )
     829                 :            :     {
     830                 :       2538 :         eFactory = SvtModuleOptions::E_WRITERWEB     ;
     831                 :       2538 :         bState   = ( sName == FACTORYNAME_WRITERWEB );
     832                 :            :     }
     833                 :            :     // no else!
     834         [ +  + ]:       2660 :     if( bState == sal_False )
     835                 :            :     {
     836                 :       2407 :         eFactory = SvtModuleOptions::E_WRITERGLOBAL     ;
     837                 :       2407 :         bState   = ( sName == FACTORYNAME_WRITERGLOBAL );
     838                 :            :     }
     839                 :            :     // no else!
     840         [ +  + ]:       2660 :     if( bState == sal_False )
     841                 :            :     {
     842                 :       2285 :         eFactory = SvtModuleOptions::E_CALC     ;
     843                 :       2285 :         bState   = ( sName == FACTORYNAME_CALC );
     844                 :            :     }
     845                 :            :     // no else!
     846         [ +  + ]:       2660 :     if( bState == sal_False )
     847                 :            :     {
     848                 :       2163 :         eFactory = SvtModuleOptions::E_DRAW     ;
     849                 :       2163 :         bState   = ( sName == FACTORYNAME_DRAW );
     850                 :            :     }
     851                 :            :     // no else!
     852         [ +  + ]:       2660 :     if( bState == sal_False )
     853                 :            :     {
     854                 :       2041 :         eFactory = SvtModuleOptions::E_IMPRESS     ;
     855                 :       2041 :         bState   = ( sName == FACTORYNAME_IMPRESS );
     856                 :            :     }
     857                 :            :     // no else!
     858         [ +  + ]:       2660 :     if( bState == sal_False )
     859                 :            :     {
     860                 :       1919 :         eFactory = SvtModuleOptions::E_MATH     ;
     861                 :       1919 :         bState   = ( sName == FACTORYNAME_MATH );
     862                 :            :     }
     863                 :            :     // no else!
     864         [ +  + ]:       2660 :     if( bState == sal_False )
     865                 :            :     {
     866                 :       1797 :         eFactory = SvtModuleOptions::E_CHART     ;
     867                 :       1797 :         bState   = ( sName == FACTORYNAME_CHART );
     868                 :            :     }
     869                 :            :     // no else!
     870         [ +  + ]:       2660 :     if( bState == sal_False )
     871                 :            :     {
     872                 :       1666 :         eFactory = SvtModuleOptions::E_DATABASE     ;
     873                 :       1666 :         bState   = ( sName == FACTORYNAME_DATABASE );
     874                 :            :     }
     875                 :            :     // no else!
     876         [ +  + ]:       2660 :     if( bState == sal_False )
     877                 :            :     {
     878                 :       1544 :         eFactory = SvtModuleOptions::E_STARTMODULE    ;
     879                 :       1544 :         bState   = ( sName == FACTORYNAME_STARTMODULE);
     880                 :            :     }
     881                 :            : 
     882                 :       2660 :     return bState;
     883                 :            : }
     884                 :            : 
     885                 :            : /*-************************************************************************************************************//**
     886                 :            :     @short      read factory configuration
     887                 :            :     @descr      Give us a list of pure factory names (long names!) which can be used as
     888                 :            :                 direct set node names ... and we read her property values and fill internal list.
     889                 :            :                 These method can be used by initial reading at ctor and later updating by "Notify()".
     890                 :            : 
     891                 :            :     @seealso    ctor
     892                 :            :     @seealso    method Notify()
     893                 :            : 
     894                 :            :     @param      "lFactories" is the list of set node entries which should be readed.
     895                 :            :     @return     -
     896                 :            : 
     897                 :            :     @onerror    We do nothing.
     898                 :            :     @threadsafe no
     899                 :            : *//*-*************************************************************************************************************/
     900                 :        131 : void SvtModuleOptions_Impl::impl_Read( const css::uno::Sequence< ::rtl::OUString >& lFactories )
     901                 :            : {
     902                 :            :     // Expand every set node name in lFactories to full qualified paths to his properties
     903                 :            :     // and get right values from configuration.
     904         [ +  - ]:        131 :     const css::uno::Sequence< ::rtl::OUString > lProperties = impl_ExpandSetNames( lFactories  );
     905         [ +  - ]:        131 :     const css::uno::Sequence< css::uno::Any >   lValues     = GetProperties( lProperties );
     906                 :            : 
     907                 :            :     // Safe impossible cases.
     908                 :            :     // We need values from ALL configuration keys.
     909                 :            :     // Follow assignment use order of values in relation to our list of key names!
     910                 :            :     OSL_ENSURE( !(lProperties.getLength()!=lValues.getLength()), "SvtModuleOptions_Impl::impl_Read()\nI miss some values of configuration keys!\n" );
     911                 :            : 
     912                 :            :     // Algorithm:   We step over all given factory names and classify it. These enum value can be used as direct index
     913                 :            :     //              in our member list m_lFactories! VAriable nPropertyStart marks start position of every factory
     914                 :            :     //              and her properties in expanded property/value list. The defines PROPERTHANDLE_xxx are used as offset values
     915                 :            :     //              added to nPropertyStart. So we can address every property relative in these lists.
     916                 :            :     //              If we found any valid values ... we reset all existing informations for corresponding m_lFactories-entry and
     917                 :            :     //              use a pointer to these struct in memory directly to set new values.
     918                 :            :     //              But we set it only, if bInstalled is true. Otherwise all other values of a factory can be undeclared .. They
     919                 :            :     //              shouldn't be used then.
     920                 :            :     // Attention:   If a propertyset of a factory will be ignored we must step to next start position of next factory infos!
     921                 :            :     //              see "nPropertyStart += PROPERTYCOUNT" ...
     922                 :            : 
     923                 :        131 :     sal_Int32                   nPropertyStart  = 0                     ;
     924                 :        131 :     sal_Int32                   nNodeCount      = lFactories.getLength();
     925                 :        131 :     FactoryInfo*                pInfo           = NULL                  ;
     926                 :            :     SvtModuleOptions::EFactory  eFactory                                ;
     927                 :            : 
     928         [ +  + ]:       2791 :     for( sal_Int32 nSetNode=0; nSetNode<nNodeCount; ++nSetNode )
     929                 :            :     {
     930                 :       2660 :         const ::rtl::OUString& sFactoryName = lFactories[nSetNode];
     931 [ +  + ][ +  - ]:       2660 :         if( ClassifyFactoryByName( sFactoryName, eFactory ) == sal_True )
     932                 :            :         {
     933                 :       1238 :             ::rtl::OUString sTemp;
     934                 :       1238 :             sal_Int32       nTemp = 0;
     935                 :            : 
     936                 :       1238 :             pInfo = &(m_lFactories[eFactory]);
     937                 :       1238 :             pInfo->free();
     938                 :            : 
     939                 :       1238 :             pInfo->initInstalled( sal_True     );
     940                 :       1238 :             pInfo->initFactory  ( sFactoryName );
     941                 :            : 
     942         [ +  - ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_SHORTNAME] >>= sTemp)
     943                 :       1238 :                 pInfo->initShortName( sTemp );
     944         [ +  + ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE] >>= sTemp)
     945         [ +  - ]:       1116 :                 pInfo->initTemplateFile( sTemp );
     946         [ +  + ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES] >>= sTemp)
     947                 :       1118 :                 pInfo->initWindowAttributes( sTemp );
     948         [ +  + ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] >>= sTemp)
     949                 :       1116 :                 pInfo->initEmptyDocumentURL( sTemp );
     950         [ +  + ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_DEFAULTFILTER   ] >>= sTemp)
     951                 :       1116 :                 pInfo->initDefaultFilter( sTemp );
     952         [ +  - ]:       1238 :             if (lValues[nPropertyStart+PROPERTYHANDLE_ICON] >>= nTemp)
     953                 :       1238 :                 pInfo->initIcon( nTemp );
     954                 :            :         }
     955                 :       2660 :         nPropertyStart += PROPERTYCOUNT;
     956 [ +  - ][ +  - ]:        131 :     }
     957                 :        131 : }
     958                 :            : 
     959                 :            : //*****************************************************************************************************************
     960                 :          0 : void SvtModuleOptions_Impl::MakeReadonlyStatesAvailable()
     961                 :            : {
     962         [ #  # ]:          0 :     if (m_bReadOnlyStatesWellKnown)
     963                 :          0 :         return;
     964                 :            : 
     965         [ #  # ]:          0 :     css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames(::rtl::OUString());
     966                 :          0 :     sal_Int32 c = lFactories.getLength();
     967                 :          0 :     sal_Int32 i = 0;
     968         [ #  # ]:          0 :     for (i=0; i<c; ++i)
     969                 :            :     {
     970                 :          0 :         ::rtl::OUStringBuffer sPath(256);
     971 [ #  # ][ #  # ]:          0 :         sPath.append(lFactories[i]             );
     972         [ #  # ]:          0 :         sPath.append(PATHSEPERATOR             );
     973         [ #  # ]:          0 :         sPath.append(PROPERTYNAME_DEFAULTFILTER);
     974                 :            : 
     975 [ #  # ][ #  # ]:          0 :         lFactories[i] = sPath.makeStringAndClear();
     976                 :          0 :     }
     977                 :            : 
     978         [ #  # ]:          0 :     css::uno::Sequence< sal_Bool > lReadonlyStates = GetReadOnlyStates(lFactories);
     979         [ #  # ]:          0 :     for (i=0; i<c; ++i)
     980                 :            :     {
     981         [ #  # ]:          0 :         ::rtl::OUString&            rFactoryName = lFactories[i];
     982                 :            :         SvtModuleOptions::EFactory  eFactory                    ;
     983                 :            : 
     984 [ #  # ][ #  # ]:          0 :         if (!ClassifyFactoryByName(rFactoryName, eFactory))
     985                 :          0 :             continue;
     986                 :            : 
     987                 :          0 :         FactoryInfo& rInfo = m_lFactories[eFactory];
     988         [ #  # ]:          0 :         rInfo.setDefaultFilterReadonly(lReadonlyStates[i]);
     989                 :            :     }
     990                 :            : 
     991 [ #  # ][ #  # ]:          0 :     m_bReadOnlyStatesWellKnown = sal_True;
     992                 :            : }
     993                 :            : 
     994                 :            : //*****************************************************************************************************************
     995                 :            : //  initialize static member
     996                 :            : //  DON'T DO IT IN YOUR HEADER!
     997                 :            : //  see definition for further informations
     998                 :            : //*****************************************************************************************************************
     999                 :            : SvtModuleOptions_Impl*  SvtModuleOptions::m_pDataContainer  = NULL  ;
    1000                 :            : sal_Int32               SvtModuleOptions::m_nRefCount       = 0     ;
    1001                 :            : 
    1002                 :            : /*-************************************************************************************************************//**
    1003                 :            :     @short      standard constructor and destructor
    1004                 :            :     @descr      This will initialize an instance with default values. We initialize/deinitialize our static data
    1005                 :            :                 container and create a static mutex, which is used for threadsafe code in further time of this object.
    1006                 :            : 
    1007                 :            :     @seealso    method impl_GetOwnStaticMutex()
    1008                 :            : 
    1009                 :            :     @param      -
    1010                 :            :     @return     -
    1011                 :            : 
    1012                 :            :     @onerror    -
    1013                 :            :     @threadsafe yes
    1014                 :            : *//*-*************************************************************************************************************/
    1015                 :      30828 : SvtModuleOptions::SvtModuleOptions()
    1016                 :            : {
    1017 [ +  - ][ +  - ]:      30828 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1018                 :      30828 :     ++m_nRefCount;
    1019         [ +  + ]:      30828 :     if( m_nRefCount == 1 )
    1020                 :            :     {
    1021                 :            :         RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtModuleOptions_Impl::ctor()");
    1022 [ +  - ][ +  - ]:        131 :         m_pDataContainer = new SvtModuleOptions_Impl();
    1023                 :            : 
    1024         [ +  - ]:        131 :         ItemHolder1::holdConfigItem(E_MODULEOPTIONS);
    1025         [ +  - ]:      30828 :     }
    1026                 :      30828 : }
    1027                 :            : 
    1028                 :            : //*****************************************************************************************************************
    1029                 :      30828 : SvtModuleOptions::~SvtModuleOptions()
    1030                 :            : {
    1031 [ +  - ][ +  - ]:      30828 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1032                 :      30828 :     --m_nRefCount;
    1033         [ +  + ]:      30828 :     if( m_nRefCount == 0 )
    1034                 :            :     {
    1035 [ +  - ][ +  - ]:        131 :         delete m_pDataContainer;
    1036                 :        131 :         m_pDataContainer = NULL;
    1037         [ +  - ]:      30828 :     }
    1038         [ -  + ]:      30959 : }
    1039                 :            : 
    1040                 :            : /*-************************************************************************************************************//**
    1041                 :            :     @short      access to configuration data
    1042                 :            :     @descr      This methods allow read/write access to configuration values.
    1043                 :            :                 They are threadsafe. All calls are forwarded to impl-data-container. See there for further informations!
    1044                 :            : 
    1045                 :            :     @seealso    method impl_GetOwnStaticMutex()
    1046                 :            : 
    1047                 :            :     @param      -
    1048                 :            :     @return     -
    1049                 :            : 
    1050                 :            :     @onerror    -
    1051                 :            :     @threadsafe yes
    1052                 :            : *//*-*************************************************************************************************************/
    1053                 :       6401 : sal_Bool SvtModuleOptions::IsModuleInstalled( EModule eModule ) const
    1054                 :            : {
    1055 [ +  - ][ +  - ]:       6401 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1056         [ +  - ]:       6401 :     return m_pDataContainer->IsModuleInstalled( eModule );
    1057                 :            : }
    1058                 :            : 
    1059                 :            : //*****************************************************************************************************************
    1060                 :         10 : ::rtl::OUString SvtModuleOptions::GetFactoryName( EFactory eFactory ) const
    1061                 :            : {
    1062 [ +  - ][ +  - ]:         10 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1063         [ +  - ]:         10 :     return m_pDataContainer->GetFactoryName( eFactory );
    1064                 :            : }
    1065                 :            : 
    1066                 :            : //*****************************************************************************************************************
    1067                 :         10 : ::rtl::OUString SvtModuleOptions::GetFactoryShortName( EFactory eFactory ) const
    1068                 :            : {
    1069 [ +  - ][ +  - ]:         10 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1070 [ +  - ][ +  - ]:         10 :     return m_pDataContainer->GetFactoryShortName( eFactory );
    1071                 :            : }
    1072                 :            : 
    1073                 :            : //*****************************************************************************************************************
    1074                 :       1093 : ::rtl::OUString SvtModuleOptions::GetFactoryStandardTemplate( EFactory eFactory ) const
    1075                 :            : {
    1076 [ +  - ][ +  - ]:       1093 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1077         [ +  - ]:       1093 :     return m_pDataContainer->GetFactoryStandardTemplate( eFactory );
    1078                 :            : }
    1079                 :            : 
    1080                 :            : //*****************************************************************************************************************
    1081                 :          0 : ::rtl::OUString SvtModuleOptions::GetFactoryEmptyDocumentURL( EFactory eFactory ) const
    1082                 :            : {
    1083 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1084 [ #  # ][ #  # ]:          0 :     return m_pDataContainer->GetFactoryEmptyDocumentURL( eFactory );
    1085                 :            : }
    1086                 :            : 
    1087                 :            : //*****************************************************************************************************************
    1088                 :         10 : ::rtl::OUString SvtModuleOptions::GetFactoryDefaultFilter( EFactory eFactory ) const
    1089                 :            : {
    1090 [ +  - ][ +  - ]:         10 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1091         [ +  - ]:         10 :     return m_pDataContainer->GetFactoryDefaultFilter( eFactory );
    1092                 :            : }
    1093                 :            : //*****************************************************************************************************************
    1094                 :          0 : sal_Bool SvtModuleOptions::IsDefaultFilterReadonly( EFactory eFactory   ) const
    1095                 :            : {
    1096 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1097         [ #  # ]:          0 :     m_pDataContainer->MakeReadonlyStatesAvailable();
    1098         [ #  # ]:          0 :     return m_pDataContainer->IsDefaultFilterReadonly( eFactory );
    1099                 :            : }
    1100                 :            : //*****************************************************************************************************************
    1101                 :       1761 : sal_Int32 SvtModuleOptions::GetFactoryIcon( EFactory eFactory ) const
    1102                 :            : {
    1103 [ +  - ][ +  - ]:       1761 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1104         [ +  - ]:       1761 :     return m_pDataContainer->GetFactoryIcon( eFactory );
    1105                 :            : }
    1106                 :            : 
    1107                 :            : //*****************************************************************************************************************
    1108                 :          0 : sal_Bool SvtModuleOptions::ClassifyFactoryByName( const ::rtl::OUString& sName    ,
    1109                 :            :                                                         EFactory&        eFactory )
    1110                 :            : {
    1111                 :            :     // We don't need any mutex here ... because we don't use any member here!
    1112                 :          0 :     return SvtModuleOptions_Impl::ClassifyFactoryByName( sName, eFactory );
    1113                 :            : }
    1114                 :            : 
    1115                 :            : //*****************************************************************************************************************
    1116                 :          0 : void SvtModuleOptions::SetFactoryStandardTemplate(       EFactory         eFactory   ,
    1117                 :            :                                                    const ::rtl::OUString& sTemplate  )
    1118                 :            : {
    1119 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1120 [ #  # ][ #  # ]:          0 :     m_pDataContainer->SetFactoryStandardTemplate( eFactory, sTemplate );
    1121                 :          0 : }
    1122                 :            : 
    1123                 :            : //*****************************************************************************************************************
    1124                 :          0 : void SvtModuleOptions::SetFactoryDefaultFilter(       EFactory         eFactory,
    1125                 :            :                                                 const ::rtl::OUString& sFilter )
    1126                 :            : {
    1127 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1128 [ #  # ][ #  # ]:          0 :     m_pDataContainer->SetFactoryDefaultFilter( eFactory, sFilter );
    1129                 :          0 : }
    1130                 :            : 
    1131                 :            : //*****************************************************************************************************************
    1132                 :       6385 : sal_Bool SvtModuleOptions::IsMath() const
    1133                 :            : {
    1134 [ +  - ][ +  - ]:       6385 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1135         [ +  - ]:       6385 :     return m_pDataContainer->IsModuleInstalled( E_SMATH );
    1136                 :            : }
    1137                 :            : 
    1138                 :            : //*****************************************************************************************************************
    1139                 :       6669 : sal_Bool SvtModuleOptions::IsChart() const
    1140                 :            : {
    1141 [ +  - ][ +  - ]:       6669 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1142         [ +  - ]:       6669 :     return m_pDataContainer->IsModuleInstalled( E_SCHART );
    1143                 :            : }
    1144                 :            : 
    1145                 :            : //*****************************************************************************************************************
    1146                 :       6385 : sal_Bool SvtModuleOptions::IsCalc() const
    1147                 :            : {
    1148 [ +  - ][ +  - ]:       6385 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1149         [ +  - ]:       6385 :     return m_pDataContainer->IsModuleInstalled( E_SCALC );
    1150                 :            : }
    1151                 :            : 
    1152                 :            : //*****************************************************************************************************************
    1153                 :         75 : sal_Bool SvtModuleOptions::IsDraw() const
    1154                 :            : {
    1155 [ +  - ][ +  - ]:         75 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1156         [ +  - ]:         75 :     return m_pDataContainer->IsModuleInstalled( E_SDRAW );
    1157                 :            : }
    1158                 :            : 
    1159                 :            : //*****************************************************************************************************************
    1160                 :        679 : sal_Bool SvtModuleOptions::IsWriter() const
    1161                 :            : {
    1162 [ +  - ][ +  - ]:        679 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1163         [ +  - ]:        679 :     return m_pDataContainer->IsModuleInstalled( E_SWRITER );
    1164                 :            : }
    1165                 :            : 
    1166                 :            : //*****************************************************************************************************************
    1167                 :         85 : sal_Bool SvtModuleOptions::IsImpress() const
    1168                 :            : {
    1169 [ +  - ][ +  - ]:         85 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1170         [ +  - ]:         85 :     return m_pDataContainer->IsModuleInstalled( E_SIMPRESS );
    1171                 :            : }
    1172                 :            : 
    1173                 :            : //*****************************************************************************************************************
    1174                 :          0 : sal_Bool SvtModuleOptions::IsBasicIDE() const
    1175                 :            : {
    1176                 :          0 :     return sal_True;
    1177                 :            : }
    1178                 :            : //*****************************************************************************************************************
    1179                 :          0 : sal_Bool SvtModuleOptions::IsDataBase() const
    1180                 :            : {
    1181 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1182         [ #  # ]:          0 :     return m_pDataContainer->IsModuleInstalled( E_SDATABASE );
    1183                 :            : }
    1184                 :            : 
    1185                 :            : namespace
    1186                 :            : {
    1187                 :            :     class theModuleOptionsMutex : public rtl::Static<osl::Mutex, theModuleOptionsMutex> {};
    1188                 :            : }
    1189                 :            : /*-****************************************************************************************************//**
    1190                 :            :     @short      return a reference to a static mutex
    1191                 :            :     @descr      These class is threadsafe.
    1192                 :            :                 We create a static mutex only for one time and use it to protect our refcount and container
    1193                 :            :                 member!
    1194                 :            : 
    1195                 :            :     @seealso    -
    1196                 :            : 
    1197                 :            :     @param      -
    1198                 :            :     @return     A reference to a static mutex member.
    1199                 :            : 
    1200                 :            :     @onerror    -
    1201                 :            :     @threadsafe yes
    1202                 :            : *//*-*****************************************************************************************************/
    1203                 :      91219 : ::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex()
    1204                 :            : {
    1205                 :      91219 :     return theModuleOptionsMutex::get();
    1206                 :            : }
    1207                 :            : 
    1208                 :          0 : ::rtl::OUString SvtModuleOptions::GetModuleName( EModule eModule ) const
    1209                 :            : {
    1210   [ #  #  #  #  :          0 :     switch( eModule )
          #  #  #  #  #  
                   #  # ]
    1211                 :            :     {
    1212                 :          0 :         case SvtModuleOptions::E_SWRITER    :   { return ::rtl::OUString("Writer"); }
    1213                 :          0 :         case SvtModuleOptions::E_SWEB       :   { return ::rtl::OUString("Web"); }
    1214                 :          0 :         case SvtModuleOptions::E_SGLOBAL    :   { return ::rtl::OUString("Global"); }
    1215                 :          0 :         case SvtModuleOptions::E_SCALC      :   { return ::rtl::OUString("Calc"); }
    1216                 :          0 :         case SvtModuleOptions::E_SDRAW      :   { return ::rtl::OUString("Draw"); }
    1217                 :          0 :         case SvtModuleOptions::E_SIMPRESS   :   { return ::rtl::OUString("Impress"); }
    1218                 :          0 :         case SvtModuleOptions::E_SMATH      :   { return ::rtl::OUString("Math"); }
    1219                 :          0 :         case SvtModuleOptions::E_SCHART     :   { return ::rtl::OUString("Chart"); }
    1220                 :          0 :         case SvtModuleOptions::E_SBASIC     :   { return ::rtl::OUString("Basic"); }
    1221                 :          0 :         case SvtModuleOptions::E_SDATABASE  :   { return ::rtl::OUString("Database"); }
    1222                 :            :         default:
    1223                 :            :             OSL_FAIL( "unknown module" );
    1224                 :          0 :             break;
    1225                 :            :     }
    1226                 :            : 
    1227                 :          0 :     return ::rtl::OUString();
    1228                 :            : }
    1229                 :            : 
    1230                 :          0 : SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByShortName(const ::rtl::OUString& sName)
    1231                 :            : {
    1232         [ #  # ]:          0 :     if ( sName == "swriter" )
    1233                 :          0 :         return E_WRITER;
    1234         [ #  # ]:          0 :     if (sName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("swriter/Web"))) // sometimes they are registerd for swriter/web :-(
    1235                 :          0 :         return E_WRITERWEB;
    1236         [ #  # ]:          0 :     if (sName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("swriter/GlobalDocument"))) // sometimes they are registerd for swriter/globaldocument :-(
    1237                 :          0 :         return E_WRITERGLOBAL;
    1238         [ #  # ]:          0 :     if ( sName == "scalc" )
    1239                 :          0 :         return E_CALC;
    1240         [ #  # ]:          0 :     if ( sName == "sdraw" )
    1241                 :          0 :         return E_DRAW;
    1242         [ #  # ]:          0 :     if ( sName == "simpress" )
    1243                 :          0 :         return E_IMPRESS;
    1244         [ #  # ]:          0 :     if ( sName == "schart" )
    1245                 :          0 :         return E_CHART;
    1246         [ #  # ]:          0 :     if ( sName == "smath" )
    1247                 :          0 :         return E_MATH;
    1248         [ #  # ]:          0 :     if ( sName == "sbasic" )
    1249                 :          0 :         return E_BASIC;
    1250         [ #  # ]:          0 :     if ( sName == "sdatabase" )
    1251                 :          0 :         return E_DATABASE;
    1252                 :            : 
    1253                 :          0 :     return E_UNKNOWN_FACTORY;
    1254                 :            : }
    1255                 :            : 
    1256                 :      10294 : SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByServiceName(const ::rtl::OUString& sName)
    1257                 :            : {
    1258         [ -  + ]:      10294 :     if (sName.equals(FACTORYNAME_WRITERGLOBAL))
    1259                 :          0 :         return E_WRITERGLOBAL;
    1260         [ +  + ]:      10294 :     if (sName.equals(FACTORYNAME_WRITERWEB))
    1261                 :          6 :         return E_WRITERWEB;
    1262         [ +  + ]:      10288 :     if (sName.equals(FACTORYNAME_WRITER))
    1263                 :       2162 :         return E_WRITER;
    1264         [ +  + ]:       8126 :     if (sName.equals(FACTORYNAME_CALC))
    1265                 :        465 :         return E_CALC;
    1266         [ +  + ]:       7661 :     if (sName.equals(FACTORYNAME_DRAW))
    1267                 :        240 :         return E_DRAW;
    1268         [ +  + ]:       7421 :     if (sName.equals(FACTORYNAME_IMPRESS))
    1269                 :         70 :         return E_IMPRESS;
    1270         [ +  + ]:       7351 :     if (sName.equals(FACTORYNAME_MATH))
    1271                 :       1790 :         return E_MATH;
    1272         [ +  + ]:       5561 :     if (sName.equals(FACTORYNAME_CHART))
    1273                 :         61 :         return E_CHART;
    1274         [ +  + ]:       5500 :     if (sName.equals(FACTORYNAME_DATABASE))
    1275                 :        348 :         return E_DATABASE;
    1276                 :            : 
    1277                 :      10294 :     return E_UNKNOWN_FACTORY;
    1278                 :            : }
    1279                 :            : 
    1280                 :          0 : SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByURL(const ::rtl::OUString&                                 sURL            ,
    1281                 :            :                                                                   const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor)
    1282                 :            : {
    1283         [ #  # ]:          0 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
    1284         [ #  # ]:          0 :     if (!xSMGR.is())
    1285                 :          0 :         return E_UNKNOWN_FACTORY;
    1286                 :            : 
    1287                 :          0 :     css::uno::Reference< css::container::XNameAccess > xFilterCfg;
    1288                 :          0 :     css::uno::Reference< css::container::XNameAccess > xTypeCfg ;
    1289                 :            :     try
    1290                 :            :     {
    1291                 :            :         xFilterCfg = css::uno::Reference< css::container::XNameAccess >(
    1292 [ #  # ][ #  # ]:          0 :             xSMGR->createInstance(::rtl::OUString("com.sun.star.document.FilterFactory")), css::uno::UNO_QUERY);
         [ #  # ][ #  # ]
    1293                 :            :         xTypeCfg = css::uno::Reference< css::container::XNameAccess >(
    1294 [ #  # ][ #  # ]:          0 :             xSMGR->createInstance(::rtl::OUString("com.sun.star.document.TypeDetection")), css::uno::UNO_QUERY);
         [ #  # ][ #  # ]
    1295                 :            :     }
    1296      [ #  #  # ]:          0 :     catch(const css::uno::RuntimeException&)
    1297                 :          0 :         { throw; }
    1298         [ #  # ]:          0 :     catch(const css::uno::Exception&)
    1299                 :          0 :         { return E_UNKNOWN_FACTORY; }
    1300                 :            : 
    1301         [ #  # ]:          0 :     ::comphelper::SequenceAsHashMap stlDesc(lMediaDescriptor);
    1302                 :            : 
    1303                 :            :     // is there already a filter inside the descriptor?
    1304         [ #  # ]:          0 :     ::rtl::OUString sFilterName = stlDesc.getUnpackedValueOrDefault(::rtl::OUString("FilterName"), ::rtl::OUString());
    1305         [ #  # ]:          0 :     if (!sFilterName.isEmpty())
    1306                 :            :     {
    1307                 :            :         try
    1308                 :            :         {
    1309 [ #  # ][ #  # ]:          0 :             ::comphelper::SequenceAsHashMap stlFilterProps   (xFilterCfg->getByName(sFilterName));
                 [ #  # ]
    1310         [ #  # ]:          0 :             ::rtl::OUString                 sDocumentService = stlFilterProps.getUnpackedValueOrDefault(::rtl::OUString("DocumentService"), ::rtl::OUString());
    1311         [ #  # ]:          0 :             SvtModuleOptions::EFactory      eApp             = SvtModuleOptions::ClassifyFactoryByServiceName(sDocumentService);
    1312                 :            : 
    1313         [ #  # ]:          0 :             if (eApp != E_UNKNOWN_FACTORY)
    1314 [ #  # ][ #  # ]:          0 :                 return eApp;
                 [ #  # ]
    1315                 :            :         }
    1316      [ #  #  # ]:          0 :         catch(const css::uno::RuntimeException&)
    1317                 :          0 :             { throw; }
    1318         [ #  # ]:          0 :         catch(const css::uno::Exception&)
    1319                 :            :             { /* do nothing here ... may the following code can help!*/ }
    1320                 :            :     }
    1321                 :            : 
    1322                 :            :     // is there already a type inside the descriptor?
    1323         [ #  # ]:          0 :     ::rtl::OUString sTypeName = stlDesc.getUnpackedValueOrDefault(::rtl::OUString("TypeName"), ::rtl::OUString());
    1324         [ #  # ]:          0 :     if (sTypeName.isEmpty())
    1325                 :            :     {
    1326                 :            :         // no :-(
    1327                 :            :         // start flat detection of URL
    1328         [ #  # ]:          0 :         css::uno::Reference< css::document::XTypeDetection > xDetect(xTypeCfg, css::uno::UNO_QUERY);
    1329 [ #  # ][ #  # ]:          0 :         sTypeName = xDetect->queryTypeByURL(sURL);
    1330                 :            :     }
    1331                 :            : 
    1332         [ #  # ]:          0 :     if (sTypeName.isEmpty())
    1333                 :          0 :         return E_UNKNOWN_FACTORY;
    1334                 :            : 
    1335                 :            :     // yes - there is a type info
    1336                 :            :     // Try to find the preferred filter.
    1337                 :            :     try
    1338                 :            :     {
    1339 [ #  # ][ #  # ]:          0 :         ::comphelper::SequenceAsHashMap stlTypeProps     (xTypeCfg->getByName(sTypeName));
                 [ #  # ]
    1340         [ #  # ]:          0 :         ::rtl::OUString                 sPreferredFilter = stlTypeProps.getUnpackedValueOrDefault(::rtl::OUString("PreferredFilter"), ::rtl::OUString());
    1341 [ #  # ][ #  # ]:          0 :         ::comphelper::SequenceAsHashMap stlFilterProps   (xFilterCfg->getByName(sPreferredFilter));
                 [ #  # ]
    1342         [ #  # ]:          0 :         ::rtl::OUString                 sDocumentService = stlFilterProps.getUnpackedValueOrDefault(::rtl::OUString("DocumentService"), ::rtl::OUString());
    1343         [ #  # ]:          0 :         SvtModuleOptions::EFactory      eApp             = SvtModuleOptions::ClassifyFactoryByServiceName(sDocumentService);
    1344                 :            : 
    1345         [ #  # ]:          0 :         if (eApp != E_UNKNOWN_FACTORY)
    1346 [ #  # ][ #  # ]:          0 :             return eApp;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1347                 :            :     }
    1348      [ #  #  # ]:          0 :     catch(const css::uno::RuntimeException&)
    1349                 :          0 :         { throw; }
    1350         [ #  # ]:          0 :     catch(const css::uno::Exception&)
    1351                 :            :         { /* do nothing here ... may the following code can help!*/ }
    1352                 :            : 
    1353                 :            :     // no filter/no type/no detection result => no fun :-)
    1354         [ #  # ]:          0 :     return E_UNKNOWN_FACTORY;
    1355                 :            : }
    1356                 :            : 
    1357                 :       4039 : SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel >& xModel)
    1358                 :            : {
    1359         [ +  - ]:       4039 :     css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
    1360         [ -  + ]:       4039 :     if (!xInfo.is())
    1361                 :          0 :         return E_UNKNOWN_FACTORY;
    1362                 :            : 
    1363 [ +  - ][ +  - ]:       4039 :     const css::uno::Sequence< ::rtl::OUString > lServices = xInfo->getSupportedServiceNames();
    1364                 :       4039 :     const ::rtl::OUString*                      pServices = lServices.getConstArray();
    1365                 :            : 
    1366         [ +  - ]:       9191 :     for (sal_Int32 i=0; i<lServices.getLength() ; ++i)
    1367                 :            :     {
    1368         [ +  - ]:       9191 :         SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(pServices[i]);
    1369         [ +  + ]:       9191 :         if (eApp != E_UNKNOWN_FACTORY)
    1370                 :       4039 :             return eApp;
    1371                 :            :     }
    1372                 :            : 
    1373         [ +  - ]:       4039 :     return E_UNKNOWN_FACTORY;
    1374                 :            : }
    1375                 :            : 
    1376                 :          0 : ::com::sun::star::uno::Sequence < ::rtl::OUString > SvtModuleOptions::GetAllServiceNames()
    1377                 :            : {
    1378 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
    1379 [ #  # ][ #  # ]:          0 :     return m_pDataContainer->GetAllServiceNames();
    1380                 :            : }
    1381                 :            : 
    1382                 :       1177 : ::rtl::OUString SvtModuleOptions::GetDefaultModuleName()
    1383                 :            : {
    1384                 :       1177 :     ::rtl::OUString aModule;
    1385         [ +  - ]:       1177 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SWRITER))
    1386         [ +  - ]:       1177 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITER);
    1387                 :            :     else
    1388         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SCALC))
    1389         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_CALC);
    1390                 :            :     else
    1391         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SIMPRESS))
    1392         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_IMPRESS);
    1393                 :            :     else
    1394         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
    1395         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_DATABASE);
    1396                 :            :     else
    1397         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SDRAW))
    1398         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_DRAW);
    1399                 :            :     else
    1400         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SWEB))
    1401         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITERWEB);
    1402                 :            :     else
    1403         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SGLOBAL))
    1404         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITERGLOBAL);
    1405                 :            :     else
    1406         [ #  # ]:          0 :     if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SMATH))
    1407         [ #  # ]:          0 :         aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_MATH);
    1408                 :       1177 :     return aModule;
    1409                 :            : }
    1410                 :            : 
    1411                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10