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