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