LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/unotools/source/config - moduleoptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 254 577 44.0 %
Date: 2013-07-09 Functions: 46 71 64.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10