2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-10-24 10:56:40 +00:00
/*************************************************************************
*
2008-04-10 19:00:24 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-10-24 10:56:40 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2000-10-24 10:56:40 +00:00
*
2008-04-10 19:00:24 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-10-24 10:56:40 +00:00
*
2008-04-10 19:00:24 +00:00
* This file is part of OpenOffice . org .
2000-10-24 10:56:40 +00:00
*
2008-04-10 19:00:24 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2000-10-24 10:56:40 +00:00
*
2008-04-10 19:00:24 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2000-10-24 10:56:40 +00:00
*
2008-04-10 19:00:24 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-10-24 10:56:40 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-17 13:27:25 +00:00
2000-10-24 10:56:40 +00:00
2009-10-06 07:38:24 +02:00
# include <unotools/moduleoptions.hxx>
2004-01-28 18:06:32 +00:00
# include <comphelper/sequenceashashmap.hxx>
2000-10-24 10:56:40 +00:00
# include <unotools/configmgr.hxx>
# include <unotools/configitem.hxx>
2011-11-14 11:49:31 +01:00
# include <comphelper/processfactory.hxx>
2001-08-22 12:06:35 +00:00
# include <osl/diagnose.h>
2004-01-28 18:06:32 +00:00
# include <rtl/ustrbuf.hxx>
2004-11-15 16:22:49 +00:00
# include <rtl/logfile.hxx>
2011-04-03 21:34:16 +01:00
# include <rtl/instance.hxx>
2000-10-24 10:56:40 +00:00
# include <com/sun/star/uno/Any.hxx>
# include <com/sun/star/uno/Sequence.hxx>
2001-08-22 12:06:35 +00:00
# include <com/sun/star/beans/PropertyValue.hpp>
2004-01-28 18:06:32 +00:00
# include <com/sun/star/container/XNameAccess.hpp>
# include <com/sun/star/lang/XMultiServiceFactory.hpp>
# include <com/sun/star/lang/XServiceInfo.hpp>
# include <com/sun/star/document/XTypeDetection.hpp>
2004-07-05 09:37:40 +00:00
# include <com/sun/star/util/XStringSubstitution.hpp>
2004-11-15 16:22:49 +00:00
# include "itemholder1.hxx"
2000-10-24 10:56:40 +00:00
//_________________________________________________________________________________________________________________
// namespaces
//_________________________________________________________________________________________________________________
2004-01-28 18:06:32 +00:00
# ifndef css
namespace css = : : com : : sun : : star ;
2001-08-22 12:06:35 +00:00
# endif
2000-10-24 10:56:40 +00:00
//_________________________________________________________________________________________________________________
// const
//_________________________________________________________________________________________________________________
2000-11-01 11:01:31 +00:00
/*-************************************************************************************************************/ /**
2001-08-22 12:06:35 +00:00
@ descr These values are used to define neccessary keys from our configuration management to support
all functionality of these implementation .
2000-11-01 11:01:31 +00:00
It ' s a fast way to make changes if some keys change his name or location !
2001-08-22 12:06:35 +00:00
Property handle are neccessary to specify right position in return list of configuration
2000-11-01 11:01:31 +00:00
for asked values . We ask it with a list of properties to get his values . The returned list
2001-08-22 12:06:35 +00:00
has the same order like our given name list !
e . g . :
NAMELIST [ PROPERTYHANDLE_xxx ] = > VALUELIST [ PROPERTYHANDLE_xxx ]
2000-11-01 11:01:31 +00:00
*/ /*-*************************************************************************************************************/
2001-08-22 12:06:35 +00:00
# define ROOTNODE_FACTORIES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Setup / Office / Factories" ))
# define PATHSEPERATOR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" / " ))
2003-04-04 16:21:41 +00:00
// Attention: The property "ooSetupFactoryEmptyDocumentURL" is read from configuration but not used! There is
// special code that uses hard coded strings to return them.
2001-08-22 12:06:35 +00:00
# define PROPERTYNAME_SHORTNAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName" ))
# define PROPERTYNAME_TEMPLATEFILE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryTemplateFile" ))
# define PROPERTYNAME_WINDOWATTRIBUTES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryWindowAttributes"))
# define PROPERTYNAME_EMPTYDOCUMENTURL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryEmptyDocumentURL"))
2004-04-29 15:47:31 +00:00
# define PROPERTYNAME_DEFAULTFILTER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryDefaultFilter" ))
2001-08-22 12:06:35 +00:00
# define PROPERTYNAME_ICON ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryIcon" ))
# define PROPERTYHANDLE_SHORTNAME 0
# define PROPERTYHANDLE_TEMPLATEFILE 1
# define PROPERTYHANDLE_WINDOWATTRIBUTES 2
# define PROPERTYHANDLE_EMPTYDOCUMENTURL 3
2004-04-29 15:47:31 +00:00
# define PROPERTYHANDLE_DEFAULTFILTER 4
# define PROPERTYHANDLE_ICON 5
2001-08-22 12:06:35 +00:00
2004-04-29 15:47:31 +00:00
# define PROPERTYCOUNT 6
2001-08-22 12:06:35 +00:00
# define FACTORYNAME_WRITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ))
# define FACTORYNAME_WRITERWEB ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.WebDocument" ))
# define FACTORYNAME_WRITERGLOBAL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalDocument" ))
# define FACTORYNAME_CALC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ))
# define FACTORYNAME_DRAW ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument" ))
# define FACTORYNAME_IMPRESS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"))
# define FACTORYNAME_MATH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.formula.FormulaProperties" ))
2007-05-22 18:32:45 +00:00
# define FACTORYNAME_CHART ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument" ))
2005-02-17 10:15:28 +00:00
# define FACTORYNAME_DATABASE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument" ))
2004-02-25 16:31:10 +00:00
# define FACTORYNAME_STARTMODULE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule" ))
2001-08-22 12:06:35 +00:00
2004-08-02 13:35:04 +00:00
# define FACTORYCOUNT 10
2000-11-01 11:01:31 +00:00
/*-************************************************************************************************************/ /**
2001-08-22 12:06:35 +00:00
@ descr This struct hold information about one factory . We declare a complete array which can hold infos
for all well known factories . Values of enum " EFactory " (see header!) are directly used as index!
So we can support a fast access on these informations .
2000-11-01 11:01:31 +00:00
*/ /*-*************************************************************************************************************/
2001-08-22 12:06:35 +00:00
struct FactoryInfo
{
public :
2001-09-27 06:39:50 +00:00
//---------------------------------------------------------------------------------------------------------
2001-08-22 12:06:35 +00:00
// initialize empty struct
FactoryInfo ( )
{
free ( ) ;
2004-07-05 09:37:40 +00:00
// @@@ should be supplied from outside!
2011-11-14 11:49:31 +01:00
xSMgr = : : comphelper : : getProcessServiceFactory ( ) ;
2001-08-22 12:06:35 +00:00
}
2000-11-01 11:01:31 +00:00
2001-09-27 06:39:50 +00:00
//---------------------------------------------------------------------------------------------------------
2001-08-22 12:06:35 +00:00
// easy way to reset struct member!
void free ( )
{
2001-09-27 06:39:50 +00:00
bInstalled = sal_False ;
sFactory = : : rtl : : OUString ( ) ;
sShortName = : : rtl : : OUString ( ) ;
sTemplateFile = : : rtl : : OUString ( ) ;
sWindowAttributes = : : rtl : : OUString ( ) ;
sEmptyDocumentURL = : : rtl : : OUString ( ) ;
2004-04-29 15:47:31 +00:00
sDefaultFilter = : : rtl : : OUString ( ) ;
2001-09-27 06:39:50 +00:00
nIcon = 0 ;
bChangedTemplateFile = sal_False ;
bChangedWindowAttributes = sal_False ;
bChangedEmptyDocumentURL = sal_False ;
2006-10-06 09:35:18 +00:00
bChangedDefaultFilter = sal_False ;
2001-09-27 06:39:50 +00:00
bChangedIcon = sal_False ;
2006-10-06 09:35:18 +00:00
bDefaultFilterReadonly = sal_False ;
2001-08-22 12:06:35 +00:00
}
2000-11-01 11:01:31 +00:00
2001-09-27 06:39:50 +00:00
//---------------------------------------------------------------------------------------------------------
// returns list of properties, which has changed only!
// We use given value of sNodeBase to build full qualified pathes ...
// Last sign of it must be "/". Beacuse we use it directly, without any additional things!
css : : uno : : Sequence < css : : beans : : PropertyValue > getChangedProperties ( const : : rtl : : OUString & sNodeBase )
{
// a) reserve memory for max. count of changed properties
// b) add names and values of changed ones only and count it
// c) resize return list by using count
css : : uno : : Sequence < css : : beans : : PropertyValue > lProperties ( 4 ) ;
sal_Int8 nRealyChanged = 0 ;
if ( bChangedTemplateFile = = sal_True )
{
2004-07-05 09:37:40 +00:00
lProperties [ nRealyChanged ] . Name = sNodeBase + PROPERTYNAME_TEMPLATEFILE ;
if ( sTemplateFile . getLength ( ) > 0 )
{
lProperties [ nRealyChanged ] . Value
< < = getStringSubstitution ( )
- > reSubstituteVariables ( sTemplateFile ) ;
}
else
{
lProperties [ nRealyChanged ] . Value < < = sTemplateFile ;
}
2001-09-27 06:39:50 +00:00
+ + nRealyChanged ;
}
if ( bChangedWindowAttributes = = sal_True )
{
lProperties [ nRealyChanged ] . Name = sNodeBase + PROPERTYNAME_WINDOWATTRIBUTES ;
lProperties [ nRealyChanged ] . Value < < = sWindowAttributes ;
+ + nRealyChanged ;
}
if ( bChangedEmptyDocumentURL = = sal_True )
{
lProperties [ nRealyChanged ] . Name = sNodeBase + PROPERTYNAME_EMPTYDOCUMENTURL ;
lProperties [ nRealyChanged ] . Value < < = sEmptyDocumentURL ;
+ + nRealyChanged ;
}
2004-04-29 15:47:31 +00:00
if ( bChangedDefaultFilter = = sal_True )
{
lProperties [ nRealyChanged ] . Name = sNodeBase + PROPERTYNAME_DEFAULTFILTER ;
lProperties [ nRealyChanged ] . Value < < = sDefaultFilter ;
+ + nRealyChanged ;
}
2001-09-27 06:39:50 +00:00
if ( bChangedIcon = = sal_True )
{
lProperties [ nRealyChanged ] . Name = sNodeBase + PROPERTYNAME_ICON ;
lProperties [ nRealyChanged ] . Value < < = nIcon ;
+ + nRealyChanged ;
}
// Don't forget to reset changed flags! Otherwise we save it again and again and ...
bChangedTemplateFile = sal_False ;
bChangedWindowAttributes = sal_False ;
bChangedEmptyDocumentURL = sal_False ;
2004-04-29 15:47:31 +00:00
bChangedDefaultFilter = sal_False ;
2001-09-27 06:39:50 +00:00
bChangedIcon = sal_False ;
lProperties . realloc ( nRealyChanged ) ;
return lProperties ;
}
//---------------------------------------------------------------------------------------------------------
// We must support setting AND marking of changed values.
// That's why we can't make our member public. We must use get/set/init methods
// to control access on it!
sal_Bool getInstalled ( ) const { return bInstalled ; } ;
: : rtl : : OUString getFactory ( ) const { return sFactory ; } ;
: : rtl : : OUString getShortName ( ) const { return sShortName ; } ;
: : rtl : : OUString getTemplateFile ( ) const { return sTemplateFile ; } ;
: : rtl : : OUString getWindowAttributes ( ) const { return sWindowAttributes ; } ;
2004-04-29 15:47:31 +00:00
: : rtl : : OUString getDefaultFilter ( ) const { return sDefaultFilter ; } ;
2004-11-15 16:22:49 +00:00
sal_Bool isDefaultFilterReadonly ( ) const { return bDefaultFilterReadonly ; }
2001-09-27 06:39:50 +00:00
sal_Int32 getIcon ( ) const { return nIcon ; } ;
//---------------------------------------------------------------------------------------------------------
// If you call set-methods - we check for changes of valkues and mark it.
// But if you whish to set it without that ... you must initialize it!
void initInstalled ( sal_Bool bNewInstalled ) { bInstalled = bNewInstalled ; }
void initFactory ( const : : rtl : : OUString & sNewFactory ) { sFactory = sNewFactory ; }
void initShortName ( const : : rtl : : OUString & sNewShortName ) { sShortName = sNewShortName ; }
void initWindowAttributes ( const : : rtl : : OUString & sNewWindowAttributes ) { sWindowAttributes = sNewWindowAttributes ; }
void initEmptyDocumentURL ( const : : rtl : : OUString & sNewEmptyDocumentURL ) { sEmptyDocumentURL = sNewEmptyDocumentURL ; }
2004-04-29 15:47:31 +00:00
void initDefaultFilter ( const : : rtl : : OUString & sNewDefaultFilter ) { sDefaultFilter = sNewDefaultFilter ; }
void setDefaultFilterReadonly ( const sal_Bool bVal ) { bDefaultFilterReadonly = bVal ; }
2001-09-27 06:39:50 +00:00
void initIcon ( sal_Int32 nNewIcon ) { nIcon = nNewIcon ; }
2004-07-05 09:37:40 +00:00
//---------------------------------------------------------------------------------------------------------
void initTemplateFile ( const : : rtl : : OUString & sNewTemplateFile )
{
if ( sNewTemplateFile . getLength ( ) > 0 )
{
sTemplateFile
= getStringSubstitution ( )
- > substituteVariables ( sNewTemplateFile , sal_False ) ;
}
else
{
sTemplateFile = sNewTemplateFile ;
}
}
2001-09-27 06:39:50 +00:00
//---------------------------------------------------------------------------------------------------------
void setTemplateFile ( const : : rtl : : OUString & sNewTemplateFile )
{
if ( sTemplateFile ! = sNewTemplateFile )
{
sTemplateFile = sNewTemplateFile ;
bChangedTemplateFile = sal_True ;
}
} ;
//---------------------------------------------------------------------------------------------------------
void setWindowAttributes ( const : : rtl : : OUString & sNewWindowAttributes )
{
if ( sWindowAttributes ! = sNewWindowAttributes )
{
sWindowAttributes = sNewWindowAttributes ;
bChangedWindowAttributes = sal_True ;
}
} ;
2004-04-29 15:47:31 +00:00
//---------------------------------------------------------------------------------------------------------
void setDefaultFilter ( const : : rtl : : OUString & sNewDefaultFilter )
{
if ( sDefaultFilter ! = sNewDefaultFilter )
{
sDefaultFilter = sNewDefaultFilter ;
bChangedDefaultFilter = sal_True ;
}
} ;
2001-09-27 06:39:50 +00:00
private :
2004-07-05 09:37:40 +00:00
css : : uno : : Reference < css : : util : : XStringSubstitution > getStringSubstitution ( )
{
if ( ! xSubstVars . is ( ) )
{
xSubstVars
= css : : uno : : Reference < css : : util : : XStringSubstitution > (
xSMgr - > createInstance (
: : rtl : : OUString (
RTL_CONSTASCII_USTRINGPARAM (
" com.sun.star.util.PathSubstitution " ) ) ) ,
css : : uno : : UNO_QUERY ) ;
if ( ! xSubstVars . is ( ) )
throw css : : uno : : RuntimeException (
: : rtl : : OUString (
RTL_CONSTASCII_USTRINGPARAM (
" Cannot instanciate service "
" com.sun.star.util.PathSubstitution " ) ) ,
css : : uno : : Reference < css : : uno : : XInterface > ( ) ) ;
}
return xSubstVars ;
}
2001-09-27 06:39:50 +00:00
sal_Bool bInstalled ;
: : rtl : : OUString sFactory ;
: : rtl : : OUString sShortName ;
: : rtl : : OUString sTemplateFile ;
: : rtl : : OUString sWindowAttributes ;
: : rtl : : OUString sEmptyDocumentURL ;
2004-04-29 15:47:31 +00:00
: : rtl : : OUString sDefaultFilter ;
2001-09-27 06:39:50 +00:00
sal_Int32 nIcon ;
sal_Bool bChangedTemplateFile : 1 ;
sal_Bool bChangedWindowAttributes : 1 ;
sal_Bool bChangedEmptyDocumentURL : 1 ;
2004-04-29 15:47:31 +00:00
sal_Bool bChangedDefaultFilter : 1 ;
2001-09-27 06:39:50 +00:00
sal_Bool bChangedIcon : 1 ;
2004-04-29 15:47:31 +00:00
sal_Bool bDefaultFilterReadonly : 1 ;
2004-07-05 09:37:40 +00:00
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMgr ;
css : : uno : : Reference < css : : util : : XStringSubstitution > xSubstVars ;
2001-08-22 12:06:35 +00:00
} ;
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
typedef FactoryInfo FactoryInfoList [ FACTORYCOUNT ] ;
2000-11-01 11:01:31 +00:00
/*-************************************************************************************************************/ /**
2001-08-22 12:06:35 +00:00
@ short IMPL data container for wrapper class SvtModulOptions !
@ descr These class is used as a static data container of class SvtModuleOptions . The hold it by using
a refcount and make it threadsafe by using an osl mutex . So we don ' t must do anything for that .
We can implement pure functionality to read / write configuration data only .
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
@ implements -
@ base ConfigItem
2000-10-24 10:56:40 +00:00
2001-08-22 12:06:35 +00:00
@ devstatus ready to use
@ threadsafe no
*/ /*-*************************************************************************************************************/
class SvtModuleOptions_Impl : public : : utl : : ConfigItem
2000-10-24 10:56:40 +00:00
{
//-------------------------------------------------------------------------------------------------------------
// public methods
//-------------------------------------------------------------------------------------------------------------
public :
//---------------------------------------------------------------------------------------------------------
// constructor / destructor
//---------------------------------------------------------------------------------------------------------
2004-11-15 16:22:49 +00:00
SvtModuleOptions_Impl ( SvtModuleOptions * pOutsideClass ) ;
2000-10-24 10:56:40 +00:00
~ SvtModuleOptions_Impl ( ) ;
//---------------------------------------------------------------------------------------------------------
// overloaded methods of baseclass
//---------------------------------------------------------------------------------------------------------
2001-08-22 12:06:35 +00:00
virtual void Notify ( const css : : uno : : Sequence < : : rtl : : OUString > & lPropertyNames ) ;
virtual void Commit ( ) ;
2000-10-24 10:56:40 +00:00
//---------------------------------------------------------------------------------------------------------
// public interface
//---------------------------------------------------------------------------------------------------------
2001-08-22 12:06:35 +00:00
sal_Bool IsModuleInstalled ( SvtModuleOptions : : EModule eModule ) const ;
2003-09-19 07:10:39 +00:00
: : com : : sun : : star : : uno : : Sequence < : : rtl : : OUString > GetAllServiceNames ( ) ;
2001-08-22 12:06:35 +00:00
: : rtl : : OUString GetFactoryName ( SvtModuleOptions : : EFactory eFactory ) const ;
: : rtl : : OUString GetFactoryShortName ( SvtModuleOptions : : EFactory eFactory ) const ;
: : rtl : : OUString GetFactoryStandardTemplate ( SvtModuleOptions : : EFactory eFactory ) const ;
: : rtl : : OUString GetFactoryEmptyDocumentURL ( SvtModuleOptions : : EFactory eFactory ) const ;
2004-04-29 15:47:31 +00:00
: : rtl : : OUString GetFactoryDefaultFilter ( SvtModuleOptions : : EFactory eFactory ) const ;
sal_Bool IsDefaultFilterReadonly ( SvtModuleOptions : : EFactory eFactory ) const ;
2001-08-22 12:06:35 +00:00
sal_Int32 GetFactoryIcon ( SvtModuleOptions : : EFactory eFactory ) const ;
static sal_Bool ClassifyFactoryByName ( const : : rtl : : OUString & sName ,
SvtModuleOptions : : EFactory & eFactory ) ;
void SetFactoryStandardTemplate ( SvtModuleOptions : : EFactory eFactory ,
const : : rtl : : OUString & sTemplate ) ;
2004-04-29 15:47:31 +00:00
void SetFactoryDefaultFilter ( SvtModuleOptions : : EFactory eFactory ,
const : : rtl : : OUString & sFilter ) ;
2004-11-15 16:22:49 +00:00
void MakeReadonlyStatesAvailable ( ) ;
2000-10-24 10:56:40 +00:00
//-------------------------------------------------------------------------------------------------------------
// private methods
//-------------------------------------------------------------------------------------------------------------
private :
2001-08-22 12:06:35 +00:00
static css : : uno : : Sequence < : : rtl : : OUString > impl_ExpandSetNames ( const css : : uno : : Sequence < : : rtl : : OUString > & lSetNames ) ;
void impl_Read ( const css : : uno : : Sequence < : : rtl : : OUString > & lSetNames ) ;
2000-10-24 10:56:40 +00:00
2001-08-22 12:06:35 +00:00
//-------------------------------------------------------------------------------------------------------------
// private types
//-------------------------------------------------------------------------------------------------------------
private :
2000-10-24 10:56:40 +00:00
//-------------------------------------------------------------------------------------------------------------
// private member
//-------------------------------------------------------------------------------------------------------------
private :
2001-08-22 12:06:35 +00:00
FactoryInfoList m_lFactories ;
2004-11-15 16:22:49 +00:00
sal_Bool m_bReadOnlyStatesWellKnown ;
SvtModuleOptions * m_pOutsideClass ;
2000-10-24 10:56:40 +00:00
} ;
//_________________________________________________________________________________________________________________
// definitions
//_________________________________________________________________________________________________________________
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short default ctor
@ descr We open our configuration here and read all neccessary values from it .
These values are cached till everyone call Commit ( ) . Then we write changed ones back to cfg .
@ seealso baseclass ConfigItem
@ seealso method impl_Read ( )
@ param -
@ return -
@ onerror -
@ threadsafe no
*/ /*-*************************************************************************************************************/
2004-11-15 16:22:49 +00:00
SvtModuleOptions_Impl : : SvtModuleOptions_Impl ( SvtModuleOptions * pOutsideClass )
2001-08-22 12:06:35 +00:00
: : : utl : : ConfigItem ( ROOTNODE_FACTORIES )
2004-11-15 16:22:49 +00:00
, m_bReadOnlyStatesWellKnown ( sal_False )
, m_pOutsideClass ( pOutsideClass )
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
// First initialize list of factory infos! Otherwise we couldnt gurantee right working of these class.
for ( sal_Int32 nFactory = 0 ; nFactory < FACTORYCOUNT ; + + nFactory )
m_lFactories [ nFactory ] . free ( ) ;
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
// Get name list of all existing set node names in configuration to read her properties in impl_Read().
// These list is a list of long names of our factories.
const css : : uno : : Sequence < : : rtl : : OUString > lFactories = GetNodeNames ( : : rtl : : OUString ( ) ) ;
impl_Read ( lFactories ) ;
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
// Enable notification for changes by using configuration directly.
// So we can update our internal values immediatly.
EnableNotification ( lFactories ) ;
}
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short default dtor
@ descr If any values of our cache was modified we should write it back to configuration .
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
@ attention Don ' t forget to call " SetModified() " method of base class ConfigItem if any interface method
of this class modify internal member list m_lFactories ! Otherwise Commit ( ) will never be called ! ! !
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
@ seealso baseclass ConfigItem
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
@ param -
@ return -
@ onerror -
@ threadsafe no
*/ /*-*************************************************************************************************************/
SvtModuleOptions_Impl : : ~ SvtModuleOptions_Impl ( )
{
if ( IsModified ( ) = = sal_True )
{
Commit ( ) ;
2001-06-22 12:06:16 +00:00
}
2001-08-22 12:06:35 +00:00
}
2001-06-22 12:06:16 +00:00
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short called for notify of configmanager
@ descr These method is called from the ConfigManager before application ends or from the
PropertyChangeListener if the sub tree broadcasts changes . You must update our
internal values .
2000-10-24 10:56:40 +00:00
2001-08-22 12:06:35 +00:00
@ attention We are registered for pure set node names only . So we can use our internal method " impl_Read() " to
update our info list . Because - these method expand given name list to full qualified property list
and use it to read the values . These values are filled into our internal member list m_lFactories
at right position .
@ seealso method impl_Read ( )
@ param " lNames " is the list of set node entries which should be updated .
@ return -
@ onerror -
@ threadsafe no
*/ /*-*************************************************************************************************************/
2006-06-19 19:47:22 +00:00
void SvtModuleOptions_Impl : : Notify ( const css : : uno : : Sequence < : : rtl : : OUString > & )
2001-08-22 12:06:35 +00:00
{
2011-03-19 14:11:09 +01:00
OSL_FAIL ( " SvtModuleOptions_Impl::Notify() \n Not implemented yet! \n " ) ;
2001-08-22 12:06:35 +00:00
}
/*-****************************************************************************************************/ /**
@ short write changes to configuration
@ descr These method writes the changed values into the sub tree
and should always called in our destructor to guarantee consistency of config data .
@ attention We clear complete set in configuration first and write it completly new ! So we don ' t must
distinguish between existing , added or removed elements . Our internal cached values
are the only and right ones .
@ seealso baseclass ConfigItem
@ param -
@ return -
2000-10-24 10:56:40 +00:00
2001-08-22 12:06:35 +00:00
@ onerror -
@ threadsafe no
*/ /*-*****************************************************************************************************/
void SvtModuleOptions_Impl : : Commit ( )
{
2001-09-27 06:39:50 +00:00
// Reserve memory for ALL possible factory properties!
// Step over all factories and get her realy changed values only.
// Build list of these ones and use it for commit.
css : : uno : : Sequence < css : : beans : : PropertyValue > lCommitProperties ( FACTORYCOUNT * PROPERTYCOUNT ) ;
FactoryInfo * pInfo = NULL ;
sal_Int32 nRealCount = 0 ;
: : rtl : : OUString sBasePath ;
2001-08-22 12:06:35 +00:00
for ( sal_Int32 nFactory = 0 ; nFactory < FACTORYCOUNT ; + + nFactory )
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
pInfo = & ( m_lFactories [ nFactory ] ) ;
2001-09-27 06:39:50 +00:00
// These path is used to build full qualified property names ....
// See pInfo->getChangedProperties() for further informations
sBasePath = PATHSEPERATOR + pInfo - > getFactory ( ) + PATHSEPERATOR ;
2004-04-29 15:47:31 +00:00
const css : : uno : : Sequence < css : : beans : : PropertyValue > lChangedProperties = pInfo - > getChangedProperties ( sBasePath ) ;
const css : : beans : : PropertyValue * pChangedProperties = lChangedProperties . getConstArray ( ) ;
sal_Int32 nPropertyCount = lChangedProperties . getLength ( ) ;
2001-09-27 06:39:50 +00:00
for ( sal_Int32 nProperty = 0 ; nProperty < nPropertyCount ; + + nProperty )
2000-10-24 10:56:40 +00:00
{
2004-04-29 15:47:31 +00:00
lCommitProperties [ nRealCount ] = pChangedProperties [ nProperty ] ;
2001-09-27 06:39:50 +00:00
+ + nRealCount ;
2000-10-24 10:56:40 +00:00
}
}
2001-09-27 06:39:50 +00:00
// Resize commit list to real size.
// If nothing to do - suppress calling of configuration ...
// It could be to expensive :-)
if ( nRealCount > 0 )
{
lCommitProperties . realloc ( nRealCount ) ;
SetSetProperties ( : : rtl : : OUString ( ) , lCommitProperties ) ;
}
2001-08-22 12:06:35 +00:00
}
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
/*-****************************************************************************************************/ /**
@ short access method to get internal values
@ descr These methods implement easy access to our internal values .
You give us right enum value to specify which module interest you . . . we return right information .
2000-11-03 08:45:51 +00:00
2001-08-22 12:06:35 +00:00
@ attention Some poeple use any value as enum . . . but we support in header specified values only !
We use it directly as index in our internal list . If enum value isn ' t right - we crash with an
" index out of range " ! ! ! Please use me right - otherwise there is no guarantee .
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
@ seealso -
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
@ param " eModule " , index in list - specify module
@ param " eFactory " , index in list - specify factory
@ param " sTemplate " , set new standard template for these factory
@ return Queried information .
2001-05-25 09:44:06 +00:00
2001-08-22 12:06:35 +00:00
@ onerror We return default values . ( mostly " not installed " ! )
@ threadsafe no
*/ /*-*****************************************************************************************************/
sal_Bool SvtModuleOptions_Impl : : IsModuleInstalled ( SvtModuleOptions : : EModule eModule ) const
{
sal_Bool bInstalled = sal_False ;
switch ( eModule )
{
2007-08-30 15:43:26 +00:00
case SvtModuleOptions : : E_SWRITER : bInstalled = m_lFactories [ SvtModuleOptions : : E_WRITER ] . getInstalled ( ) ;
break ;
case SvtModuleOptions : : E_SWEB : bInstalled = m_lFactories [ SvtModuleOptions : : E_WRITERWEB ] . getInstalled ( ) ;
break ;
case SvtModuleOptions : : E_SGLOBAL : bInstalled = m_lFactories [ SvtModuleOptions : : E_WRITERGLOBAL ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2001-09-27 06:39:50 +00:00
case SvtModuleOptions : : E_SCALC : bInstalled = m_lFactories [ SvtModuleOptions : : E_CALC ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2001-09-27 06:39:50 +00:00
case SvtModuleOptions : : E_SDRAW : bInstalled = m_lFactories [ SvtModuleOptions : : E_DRAW ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2001-09-27 06:39:50 +00:00
case SvtModuleOptions : : E_SIMPRESS : bInstalled = m_lFactories [ SvtModuleOptions : : E_IMPRESS ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2001-09-27 06:39:50 +00:00
case SvtModuleOptions : : E_SMATH : bInstalled = m_lFactories [ SvtModuleOptions : : E_MATH ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2001-09-27 06:39:50 +00:00
case SvtModuleOptions : : E_SCHART : bInstalled = m_lFactories [ SvtModuleOptions : : E_CHART ] . getInstalled ( ) ;
2001-08-22 12:06:35 +00:00
break ;
2004-02-25 16:31:10 +00:00
case SvtModuleOptions : : E_SSTARTMODULE : bInstalled = m_lFactories [ SvtModuleOptions : : E_STARTMODULE ] . getInstalled ( ) ;
break ;
2001-08-22 12:06:35 +00:00
case SvtModuleOptions : : E_SBASIC : bInstalled = sal_True ; // Couldn't be deselected by setup yet!
break ;
2005-06-21 12:17:56 +00:00
case SvtModuleOptions : : E_SDATABASE : bInstalled = m_lFactories [ SvtModuleOptions : : E_DATABASE ] . getInstalled ( ) ;
2004-08-02 13:35:04 +00:00
break ;
2001-08-22 12:06:35 +00:00
}
return bInstalled ;
2000-10-24 10:56:40 +00:00
}
2003-09-19 07:10:39 +00:00
: : com : : sun : : star : : uno : : Sequence < : : rtl : : OUString > SvtModuleOptions_Impl : : GetAllServiceNames ( )
{
sal_uInt32 nCount = 0 ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITER ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITERWEB ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITERGLOBAL ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SCALC ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SDRAW ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SIMPRESS ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SCHART ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SMATH ] . getInstalled ( ) )
nCount + + ;
if ( m_lFactories [ SvtModuleOptions : : E_SBASIC ] . getInstalled ( ) )
nCount + + ;
2004-08-02 13:35:04 +00:00
if ( m_lFactories [ SvtModuleOptions : : E_SDATABASE ] . getInstalled ( ) )
nCount + + ;
2003-09-19 07:10:39 +00:00
css : : uno : : Sequence < : : rtl : : OUString > aRet ( nCount ) ;
sal_Int32 n = 0 ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITER ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_WRITER ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITERWEB ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_WRITERWEB ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_WRITERGLOBAL ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_WRITERGLOBAL ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SCALC ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SCALC ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SDRAW ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SDRAW ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SIMPRESS ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SIMPRESS ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SCHART ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SCHART ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SMATH ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SMATH ] . getFactory ( ) ;
if ( m_lFactories [ SvtModuleOptions : : E_SBASIC ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SBASIC ] . getFactory ( ) ;
2004-08-02 13:35:04 +00:00
if ( m_lFactories [ SvtModuleOptions : : E_SDATABASE ] . getInstalled ( ) )
aRet [ n + + ] = m_lFactories [ SvtModuleOptions : : E_SDATABASE ] . getFactory ( ) ;
2003-09-19 07:10:39 +00:00
return aRet ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions_Impl : : GetFactoryName ( SvtModuleOptions : : EFactory eFactory ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : rtl : : OUString sName ;
2000-11-01 11:01:31 +00:00
2001-08-22 12:06:35 +00:00
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
2000-11-01 11:01:31 +00:00
{
2001-09-27 06:39:50 +00:00
sName = m_lFactories [ eFactory ] . getFactory ( ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
return sName ;
2000-11-01 11:01:31 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions_Impl : : GetFactoryShortName ( SvtModuleOptions : : EFactory eFactory ) const
{
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
// But it's good to plan further possibilities!
//return m_lFactories[eFactory].sShortName;
: : rtl : : OUString sShortName ;
switch ( eFactory )
{
case SvtModuleOptions : : E_WRITER : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " swriter " ) ) ;
break ;
case SvtModuleOptions : : E_WRITERWEB : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " swriter/web " ) ) ;
break ;
case SvtModuleOptions : : E_WRITERGLOBAL : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " swriter/GlobalDocument " ) ) ;
break ;
case SvtModuleOptions : : E_CALC : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " scalc " ) ) ;
break ;
case SvtModuleOptions : : E_DRAW : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " sdraw " ) ) ;
break ;
case SvtModuleOptions : : E_IMPRESS : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " simpress " ) ) ;
break ;
case SvtModuleOptions : : E_MATH : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " smath " ) ) ;
break ;
case SvtModuleOptions : : E_CHART : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " schart " ) ) ;
break ;
2001-12-03 16:49:23 +00:00
case SvtModuleOptions : : E_BASIC : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " sbasic " ) ) ;
break ;
2004-08-02 13:35:04 +00:00
case SvtModuleOptions : : E_DATABASE : sShortName = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " sdatabase " ) ) ;
break ;
2006-06-19 19:47:22 +00:00
default :
2011-02-26 10:38:15 +01:00
OSL_FAIL ( " unknown factory " ) ;
2006-06-19 19:47:22 +00:00
break ;
2001-08-22 12:06:35 +00:00
}
2001-12-03 16:49:23 +00:00
2001-08-22 12:06:35 +00:00
return sShortName ;
}
2000-11-01 11:01:31 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions_Impl : : GetFactoryStandardTemplate ( SvtModuleOptions : : EFactory eFactory ) const
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
: : rtl : : OUString sFile ;
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
2000-11-01 11:01:31 +00:00
{
2001-09-27 06:39:50 +00:00
sFile = m_lFactories [ eFactory ] . getTemplateFile ( ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
return sFile ;
2000-11-01 11:01:31 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions_Impl : : GetFactoryEmptyDocumentURL ( SvtModuleOptions : : EFactory eFactory ) const
{
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
// But it's good to plan further possibilities!
2001-09-27 06:39:50 +00:00
//return m_lFactories[eFactory].getEmptyDocumentURL();
2001-08-22 12:06:35 +00:00
: : rtl : : OUString sURL ;
switch ( eFactory )
{
case SvtModuleOptions : : E_WRITER : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/swriter " ) ) ;
break ;
case SvtModuleOptions : : E_WRITERWEB : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/swriter/web " ) ) ;
break ;
case SvtModuleOptions : : E_WRITERGLOBAL : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/swriter/GlobalDocument " ) ) ;
break ;
case SvtModuleOptions : : E_CALC : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/scalc " ) ) ;
break ;
case SvtModuleOptions : : E_DRAW : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/sdraw " ) ) ;
break ;
2004-11-16 15:08:33 +00:00
case SvtModuleOptions : : E_IMPRESS : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/simpress?slot=6686 " ) ) ;
2001-08-22 12:06:35 +00:00
break ;
case SvtModuleOptions : : E_MATH : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/smath " ) ) ;
break ;
case SvtModuleOptions : : E_CHART : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/schart " ) ) ;
break ;
2001-12-03 16:49:23 +00:00
case SvtModuleOptions : : E_BASIC : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/sbasic " ) ) ;
break ;
2005-03-10 16:04:17 +00:00
case SvtModuleOptions : : E_DATABASE : sURL = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " private:factory/sdatabase?Interactive " ) ) ;
2004-08-02 13:35:04 +00:00
break ;
2006-06-19 19:47:22 +00:00
default :
2011-02-26 10:38:15 +01:00
OSL_FAIL ( " unknown factory " ) ;
2006-06-19 19:47:22 +00:00
break ;
2001-08-22 12:06:35 +00:00
}
return sURL ;
}
2004-04-29 15:47:31 +00:00
//*****************************************************************************************************************
: : rtl : : OUString SvtModuleOptions_Impl : : GetFactoryDefaultFilter ( SvtModuleOptions : : EFactory eFactory ) const
{
: : rtl : : OUString sDefaultFilter ;
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
{
sDefaultFilter = m_lFactories [ eFactory ] . getDefaultFilter ( ) ;
}
return sDefaultFilter ;
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions_Impl : : IsDefaultFilterReadonly ( SvtModuleOptions : : EFactory eFactory ) const
{
sal_Bool bRet = sal_False ;
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
{
bRet = m_lFactories [ eFactory ] . isDefaultFilterReadonly ( ) ;
}
return bRet ;
}
2000-11-01 11:01:31 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
sal_Int32 SvtModuleOptions_Impl : : GetFactoryIcon ( SvtModuleOptions : : EFactory eFactory ) const
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
sal_Int32 nIcon = 0 ;
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
2000-11-01 11:01:31 +00:00
{
2001-09-27 06:39:50 +00:00
nIcon = m_lFactories [ eFactory ] . getIcon ( ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
return nIcon ;
2000-11-01 11:01:31 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
void SvtModuleOptions_Impl : : SetFactoryStandardTemplate ( SvtModuleOptions : : EFactory eFactory ,
const : : rtl : : OUString & sTemplate )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
2000-11-01 11:01:31 +00:00
{
2001-09-27 06:39:50 +00:00
m_lFactories [ eFactory ] . setTemplateFile ( sTemplate ) ;
2001-08-22 12:06:35 +00:00
SetModified ( ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
}
2004-04-29 15:47:31 +00:00
//*****************************************************************************************************************
void SvtModuleOptions_Impl : : SetFactoryDefaultFilter ( SvtModuleOptions : : EFactory eFactory ,
const : : rtl : : OUString & sFilter )
{
if ( eFactory > = 0 & & eFactory < FACTORYCOUNT )
{
m_lFactories [ eFactory ] . setDefaultFilter ( sFilter ) ;
SetModified ( ) ;
}
}
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short return list of key names of ouer configuration management which represent our module tree
@ descr You give use a list of current existing set node names . . and we expand it for all
well known properties which are neccessary for this implementation .
These full expanded list should be used to get values of this properties .
@ seealso ctor
@ param -
@ return List of all relative addressed properties of given set entry names .
@ onerror List will be empty .
@ threadsafe no
*/ /*-*************************************************************************************************************/
css : : uno : : Sequence < : : rtl : : OUString > SvtModuleOptions_Impl : : impl_ExpandSetNames ( const css : : uno : : Sequence < : : rtl : : OUString > & lSetNames )
{
sal_Int32 nCount = lSetNames . getLength ( ) ;
css : : uno : : Sequence < : : rtl : : OUString > lPropNames ( nCount * PROPERTYCOUNT ) ;
2004-04-29 15:47:31 +00:00
: : rtl : : OUString * pPropNames = lPropNames . getArray ( ) ;
2001-08-22 12:06:35 +00:00
sal_Int32 nPropStart = 0 ;
for ( sal_Int32 nName = 0 ; nName < nCount ; + + nName )
2000-11-01 11:01:31 +00:00
{
2004-04-29 15:47:31 +00:00
pPropNames [ nPropStart + PROPERTYHANDLE_SHORTNAME ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_SHORTNAME ;
pPropNames [ nPropStart + PROPERTYHANDLE_TEMPLATEFILE ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE ;
pPropNames [ nPropStart + PROPERTYHANDLE_WINDOWATTRIBUTES ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES ;
pPropNames [ nPropStart + PROPERTYHANDLE_EMPTYDOCUMENTURL ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL ;
pPropNames [ nPropStart + PROPERTYHANDLE_DEFAULTFILTER ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_DEFAULTFILTER ;
pPropNames [ nPropStart + PROPERTYHANDLE_ICON ] = lSetNames [ nName ] + PATHSEPERATOR + PROPERTYNAME_ICON ;
2001-08-22 12:06:35 +00:00
nPropStart + = PROPERTYCOUNT ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
return lPropNames ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short helper to classify given factory by name
@ descr Every factory has his own long and short name . So we can match right enum value for internal using .
2010-07-29 10:56:19 +08:00
@ attention We change in / out parameter " eFactory " in every case ! But you should use it only , if return value is sal_True !
2001-08-22 12:06:35 +00:00
Algorithm : Set out - parameter to propably value . . . and check the longname .
If it match with these factory - break operation and return true AND right set parameter .
Otherwise try next one and so on . If no factory was found return false . Out parameter eFactory
is set to last tried value but shouldn ' t be used ! Because our return value is false !
@ seealso -
@ param " sLongName " , long name of factory , which should be classified
@ return " eFactory " , right enum value , which match given long name
and true for successfully classification , false otherwise
@ onerror We return false .
@ threadsafe no
*/ /*-*************************************************************************************************************/
sal_Bool SvtModuleOptions_Impl : : ClassifyFactoryByName ( const : : rtl : : OUString & sName , SvtModuleOptions : : EFactory & eFactory )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
sal_Bool bState ;
eFactory = SvtModuleOptions : : E_WRITER ;
bState = ( sName = = FACTORYNAME_WRITER ) ;
if ( bState = = sal_False )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_WRITERWEB ;
bState = ( sName = = FACTORYNAME_WRITERWEB ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_WRITERGLOBAL ;
bState = ( sName = = FACTORYNAME_WRITERGLOBAL ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
2000-11-03 08:45:51 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_CALC ;
bState = ( sName = = FACTORYNAME_CALC ) ;
2000-11-03 08:45:51 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
2000-11-03 08:45:51 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_DRAW ;
bState = ( sName = = FACTORYNAME_DRAW ) ;
2000-11-03 08:45:51 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_IMPRESS ;
bState = ( sName = = FACTORYNAME_IMPRESS ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
2000-11-01 11:01:31 +00:00
{
2001-08-22 12:06:35 +00:00
eFactory = SvtModuleOptions : : E_MATH ;
bState = ( sName = = FACTORYNAME_MATH ) ;
2000-11-01 11:01:31 +00:00
}
2001-08-22 12:06:35 +00:00
// no else!
if ( bState = = sal_False )
{
eFactory = SvtModuleOptions : : E_CHART ;
bState = ( sName = = FACTORYNAME_CHART ) ;
}
2004-02-25 16:31:10 +00:00
// no else!
if ( bState = = sal_False )
2004-08-02 13:35:04 +00:00
{
eFactory = SvtModuleOptions : : E_DATABASE ;
bState = ( sName = = FACTORYNAME_DATABASE ) ;
}
// no else!
if ( bState = = sal_False )
2004-02-25 16:31:10 +00:00
{
eFactory = SvtModuleOptions : : E_STARTMODULE ;
bState = ( sName = = FACTORYNAME_STARTMODULE ) ;
}
2001-08-22 12:06:35 +00:00
return bState ;
2000-10-24 10:56:40 +00:00
}
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short read factory configuration
@ descr Give us a list of pure factory names ( long names ! ) which can be used as
direct set node names . . . and we read her property values and fill internal list .
These method can be used by initial reading at ctor and later updating by " Notify() " .
@ seealso ctor
@ seealso method Notify ( )
@ param " lFactories " is the list of set node entries which should be readed .
@ return -
@ onerror We do nothing .
@ threadsafe no
*/ /*-*************************************************************************************************************/
void SvtModuleOptions_Impl : : impl_Read ( const css : : uno : : Sequence < : : rtl : : OUString > & lFactories )
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
// Expand every set node name in lFactories to full qualified pathes to his properties
// and get right values from configuration.
const css : : uno : : Sequence < : : rtl : : OUString > lProperties = impl_ExpandSetNames ( lFactories ) ;
2004-11-15 16:22:49 +00:00
const css : : uno : : Sequence < css : : uno : : Any > lValues = GetProperties ( lProperties ) ;
2001-08-22 12:06:35 +00:00
// Safe impossible cases.
// We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names!
OSL_ENSURE ( ! ( lProperties . getLength ( ) ! = lValues . getLength ( ) ) , " SvtModuleOptions_Impl::impl_Read() \n I miss some values of configuration keys! \n " ) ;
// Algorithm: We step over all given factory names and classify it. These enum value can be used as direct index
// in our member list m_lFactories! VAriable nPropertyStart marks start position of every factory
// and her properties in expanded property/value list. The defines PROPERTHANDLE_xxx are used as offset values
// added to nPropertyStart. So we can address every property relative in these lists.
// If we found any valid values ... we reset all existing informations for corresponding m_lFactories-entry and
// use a pointer to these struct in memory directly to set new values.
// But we set it only, if bInstalled is true. Otherwise all other values of a factory can be undeclared .. They
// shouldn't be used then.
// Attention: If a propertyset of a factory will be ignored we must step to next start position of next factory infos!
// see "nPropertyStart += PROPERTYCOUNT" ...
sal_Int32 nPropertyStart = 0 ;
sal_Int32 nNodeCount = lFactories . getLength ( ) ;
FactoryInfo * pInfo = NULL ;
SvtModuleOptions : : EFactory eFactory ;
2004-11-15 16:22:49 +00:00
2001-08-22 12:06:35 +00:00
for ( sal_Int32 nSetNode = 0 ; nSetNode < nNodeCount ; + + nSetNode )
{
2004-11-15 16:22:49 +00:00
const : : rtl : : OUString & sFactoryName = lFactories [ nSetNode ] ;
2001-08-22 12:06:35 +00:00
if ( ClassifyFactoryByName ( sFactoryName , eFactory ) = = sal_True )
{
2004-04-29 15:47:31 +00:00
: : rtl : : OUString sTemp ;
2007-01-18 13:11:45 +00:00
sal_Int32 nTemp = 0 ;
2004-04-29 15:47:31 +00:00
2001-08-22 12:06:35 +00:00
pInfo = & ( m_lFactories [ eFactory ] ) ;
pInfo - > free ( ) ;
2001-09-27 06:39:50 +00:00
pInfo - > initInstalled ( sal_True ) ;
pInfo - > initFactory ( sFactoryName ) ;
2004-04-29 15:47:31 +00:00
if ( lValues [ nPropertyStart + PROPERTYHANDLE_SHORTNAME ] > > = sTemp )
pInfo - > initShortName ( sTemp ) ;
if ( lValues [ nPropertyStart + PROPERTYHANDLE_TEMPLATEFILE ] > > = sTemp )
pInfo - > initTemplateFile ( sTemp ) ;
if ( lValues [ nPropertyStart + PROPERTYHANDLE_WINDOWATTRIBUTES ] > > = sTemp )
pInfo - > initWindowAttributes ( sTemp ) ;
if ( lValues [ nPropertyStart + PROPERTYHANDLE_EMPTYDOCUMENTURL ] > > = sTemp )
pInfo - > initEmptyDocumentURL ( sTemp ) ;
if ( lValues [ nPropertyStart + PROPERTYHANDLE_DEFAULTFILTER ] > > = sTemp )
pInfo - > initDefaultFilter ( sTemp ) ;
if ( lValues [ nPropertyStart + PROPERTYHANDLE_ICON ] > > = nTemp )
pInfo - > initIcon ( nTemp ) ;
2001-08-22 12:06:35 +00:00
}
nPropertyStart + = PROPERTYCOUNT ;
}
2000-10-24 10:56:40 +00:00
}
2004-11-15 16:22:49 +00:00
//*****************************************************************************************************************
void SvtModuleOptions_Impl : : MakeReadonlyStatesAvailable ( )
{
if ( m_bReadOnlyStatesWellKnown )
return ;
css : : uno : : Sequence < : : rtl : : OUString > lFactories = GetNodeNames ( : : rtl : : OUString ( ) ) ;
sal_Int32 c = lFactories . getLength ( ) ;
sal_Int32 i = 0 ;
for ( i = 0 ; i < c ; + + i )
{
: : rtl : : OUStringBuffer sPath ( 256 ) ;
sPath . append ( lFactories [ i ] ) ;
sPath . append ( PATHSEPERATOR ) ;
sPath . append ( PROPERTYNAME_DEFAULTFILTER ) ;
lFactories [ i ] = sPath . makeStringAndClear ( ) ;
}
css : : uno : : Sequence < sal_Bool > lReadonlyStates = GetReadOnlyStates ( lFactories ) ;
for ( i = 0 ; i < c ; + + i )
{
: : rtl : : OUString & rFactoryName = lFactories [ i ] ;
SvtModuleOptions : : EFactory eFactory ;
if ( ! ClassifyFactoryByName ( rFactoryName , eFactory ) )
continue ;
FactoryInfo & rInfo = m_lFactories [ eFactory ] ;
rInfo . setDefaultFilterReadonly ( lReadonlyStates [ i ] ) ;
}
m_bReadOnlyStatesWellKnown = sal_True ;
}
2001-08-22 12:06:35 +00:00
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
// initialize static member
// DON'T DO IT IN YOUR HEADER!
// see definition for further informations
//*****************************************************************************************************************
SvtModuleOptions_Impl * SvtModuleOptions : : m_pDataContainer = NULL ;
sal_Int32 SvtModuleOptions : : m_nRefCount = 0 ;
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short standard constructor and destructor
@ descr This will initialize an instance with default values . We initialize / deinitialize our static data
container and create a static mutex , which is used for threadsafe code in further time of this object .
@ seealso method impl_GetOwnStaticMutex ( )
@ param -
@ return -
@ onerror -
@ threadsafe yes
*/ /*-*************************************************************************************************************/
2000-10-24 10:56:40 +00:00
SvtModuleOptions : : SvtModuleOptions ( )
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
2000-10-24 10:56:40 +00:00
+ + m_nRefCount ;
2001-08-22 12:06:35 +00:00
if ( m_nRefCount = = 1 )
2000-10-24 10:56:40 +00:00
{
2009-10-06 07:38:24 +02:00
RTL_LOGFILE_CONTEXT ( aLog , " unotools ( ??? ) ::SvtModuleOptions_Impl::ctor() " ) ;
2004-11-15 16:22:49 +00:00
m_pDataContainer = new SvtModuleOptions_Impl ( this ) ;
2005-11-11 07:52:26 +00:00
ItemHolder1 : : holdConfigItem ( E_MODULEOPTIONS ) ;
2000-10-24 10:56:40 +00:00
}
}
//*****************************************************************************************************************
SvtModuleOptions : : ~ SvtModuleOptions ( )
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
2000-10-24 10:56:40 +00:00
- - m_nRefCount ;
2001-08-22 12:06:35 +00:00
if ( m_nRefCount = = 0 )
2000-10-24 10:56:40 +00:00
{
delete m_pDataContainer ;
m_pDataContainer = NULL ;
}
}
2001-08-22 12:06:35 +00:00
/*-************************************************************************************************************/ /**
@ short access to configuration data
@ descr This methods allow read / write access to configuration values .
They are threadsafe . All calls are forwarded to impl - data - container . See there for further informations !
@ seealso method impl_GetOwnStaticMutex ( )
@ param -
@ return -
@ onerror -
@ threadsafe yes
*/ /*-*************************************************************************************************************/
sal_Bool SvtModuleOptions : : IsModuleInstalled ( EModule eModule ) const
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( eModule ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions : : GetFactoryName ( EFactory eFactory ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryName ( eFactory ) ;
2000-10-24 10:56:40 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions : : GetFactoryShortName ( EFactory eFactory ) const
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryShortName ( eFactory ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions : : GetFactoryStandardTemplate ( EFactory eFactory ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryStandardTemplate ( eFactory ) ;
2000-10-24 10:56:40 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
: : rtl : : OUString SvtModuleOptions : : GetFactoryEmptyDocumentURL ( EFactory eFactory ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryEmptyDocumentURL ( eFactory ) ;
2000-10-24 10:56:40 +00:00
}
2004-04-29 15:47:31 +00:00
//*****************************************************************************************************************
: : rtl : : OUString SvtModuleOptions : : GetFactoryDefaultFilter ( EFactory eFactory ) const
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryDefaultFilter ( eFactory ) ;
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions : : IsDefaultFilterReadonly ( EFactory eFactory ) const
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
2004-11-15 16:22:49 +00:00
m_pDataContainer - > MakeReadonlyStatesAvailable ( ) ;
2004-04-29 15:47:31 +00:00
return m_pDataContainer - > IsDefaultFilterReadonly ( eFactory ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
sal_Int32 SvtModuleOptions : : GetFactoryIcon ( EFactory eFactory ) const
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetFactoryIcon ( eFactory ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
sal_Bool SvtModuleOptions : : ClassifyFactoryByName ( const : : rtl : : OUString & sName ,
EFactory & eFactory )
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
// We don't need any mutex here ... because we don't use any member here!
return SvtModuleOptions_Impl : : ClassifyFactoryByName ( sName , eFactory ) ;
2000-10-24 10:56:40 +00:00
}
//*****************************************************************************************************************
2001-08-22 12:06:35 +00:00
void SvtModuleOptions : : SetFactoryStandardTemplate ( EFactory eFactory ,
const : : rtl : : OUString & sTemplate )
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
m_pDataContainer - > SetFactoryStandardTemplate ( eFactory , sTemplate ) ;
}
2004-04-29 15:47:31 +00:00
//*****************************************************************************************************************
void SvtModuleOptions : : SetFactoryDefaultFilter ( EFactory eFactory ,
const : : rtl : : OUString & sFilter )
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
m_pDataContainer - > SetFactoryDefaultFilter ( eFactory , sFilter ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsMath ( ) const
2001-08-22 12:06:35 +00:00
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SMATH ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsChart ( ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SCHART ) ;
2000-10-24 10:56:40 +00:00
}
2000-11-03 08:45:51 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsCalc ( ) const
2001-08-22 12:06:35 +00:00
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SCALC ) ;
}
2000-11-03 08:45:51 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsDraw ( ) const
2000-11-03 08:45:51 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SDRAW ) ;
2000-11-03 08:45:51 +00:00
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsWriter ( ) const
2001-08-22 12:06:35 +00:00
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SWRITER ) ;
}
2000-10-24 10:56:40 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsImpress ( ) const
2000-10-24 10:56:40 +00:00
{
2001-08-22 12:06:35 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SIMPRESS ) ;
2000-10-24 10:56:40 +00:00
}
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsBasicIDE ( ) const
2001-08-22 12:06:35 +00:00
{
return sal_True ;
}
2004-08-02 13:35:04 +00:00
//*****************************************************************************************************************
2006-06-19 19:47:22 +00:00
sal_Bool SvtModuleOptions : : IsDataBase ( ) const
2004-08-02 13:35:04 +00:00
{
2006-08-14 10:45:43 +00:00
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsModuleInstalled ( E_SDATABASE ) ;
2004-08-02 13:35:04 +00:00
}
2001-08-22 12:06:35 +00:00
2011-04-03 21:34:16 +01:00
namespace
{
class theModuleOptionsMutex : public rtl : : Static < osl : : Mutex , theModuleOptionsMutex > { } ;
}
2001-08-22 12:06:35 +00:00
/*-****************************************************************************************************/ /**
@ short return a reference to a static mutex
@ descr These class is threadsafe .
We create a static mutex only for one time and use it to protect our refcount and container
member !
@ seealso -
@ param -
@ return A reference to a static mutex member .
@ onerror -
@ threadsafe yes
*/ /*-*****************************************************************************************************/
: : osl : : Mutex & SvtModuleOptions : : impl_GetOwnStaticMutex ( )
2000-10-24 10:56:40 +00:00
{
2011-04-03 21:34:16 +01:00
return theModuleOptionsMutex : : get ( ) ;
2000-10-24 10:56:40 +00:00
}
2001-12-03 16:49:23 +00:00
: : rtl : : OUString SvtModuleOptions : : GetModuleName ( EModule eModule ) const
{
switch ( eModule )
{
2010-11-22 22:54:33 +01:00
case SvtModuleOptions : : E_SWRITER : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Writer " ) ) ; }
case SvtModuleOptions : : E_SWEB : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Web " ) ) ; }
case SvtModuleOptions : : E_SGLOBAL : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Global " ) ) ; }
case SvtModuleOptions : : E_SCALC : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Calc " ) ) ; }
case SvtModuleOptions : : E_SDRAW : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Draw " ) ) ; }
case SvtModuleOptions : : E_SIMPRESS : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Impress " ) ) ; }
case SvtModuleOptions : : E_SMATH : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Math " ) ) ; }
case SvtModuleOptions : : E_SCHART : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Chart " ) ) ; }
case SvtModuleOptions : : E_SBASIC : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Basic " ) ) ; }
case SvtModuleOptions : : E_SDATABASE : { return : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Database " ) ) ; }
2006-06-19 19:47:22 +00:00
default :
2011-02-26 10:38:15 +01:00
OSL_FAIL ( " unknown module " ) ;
2006-06-19 19:47:22 +00:00
break ;
2001-12-03 16:49:23 +00:00
}
return : : rtl : : OUString ( ) ;
}
2004-04-29 15:47:31 +00:00
/*-----------------------------------------------
07.03 .2004 15 : 03
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SvtModuleOptions : : EFactory SvtModuleOptions : : ClassifyFactoryByShortName ( const : : rtl : : OUString & sName )
{
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " swriter " ) ) )
2004-04-29 15:47:31 +00:00
return E_WRITER ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsIgnoreAsciiCaseAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " swriter/Web " ) ) ) // sometimes they are registerd for swriter/web :-(
2004-04-29 15:47:31 +00:00
return E_WRITERWEB ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsIgnoreAsciiCaseAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " swriter/GlobalDocument " ) ) ) // sometimes they are registerd for swriter/globaldocument :-(
2004-04-29 15:47:31 +00:00
return E_WRITERGLOBAL ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " scalc " ) ) )
2004-04-29 15:47:31 +00:00
return E_CALC ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " sdraw " ) ) )
2004-04-29 15:47:31 +00:00
return E_DRAW ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " simpress " ) ) )
2004-04-29 15:47:31 +00:00
return E_IMPRESS ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " schart " ) ) )
2004-04-29 15:47:31 +00:00
return E_CHART ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " smath " ) ) )
2004-04-29 15:47:31 +00:00
return E_MATH ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " sbasic " ) ) )
2004-04-29 15:47:31 +00:00
return E_BASIC ;
2011-01-17 10:36:01 +00:00
if ( sName . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( " sdatabase " ) ) )
2005-06-21 12:17:56 +00:00
return E_DATABASE ;
2004-04-29 15:47:31 +00:00
return E_UNKNOWN_FACTORY ;
}
2004-01-28 18:06:32 +00:00
/*-----------------------------------------------
31.07 .2003 10 : 41
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SvtModuleOptions : : EFactory SvtModuleOptions : : ClassifyFactoryByServiceName ( const : : rtl : : OUString & sName )
{
if ( sName . equals ( FACTORYNAME_WRITERGLOBAL ) )
return E_WRITERGLOBAL ;
if ( sName . equals ( FACTORYNAME_WRITERWEB ) )
return E_WRITERWEB ;
if ( sName . equals ( FACTORYNAME_WRITER ) )
return E_WRITER ;
if ( sName . equals ( FACTORYNAME_CALC ) )
return E_CALC ;
if ( sName . equals ( FACTORYNAME_DRAW ) )
return E_DRAW ;
if ( sName . equals ( FACTORYNAME_IMPRESS ) )
return E_IMPRESS ;
if ( sName . equals ( FACTORYNAME_MATH ) )
return E_MATH ;
if ( sName . equals ( FACTORYNAME_CHART ) )
return E_CHART ;
2004-08-02 13:35:04 +00:00
if ( sName . equals ( FACTORYNAME_DATABASE ) )
return E_DATABASE ;
2004-01-28 18:06:32 +00:00
return E_UNKNOWN_FACTORY ;
}
/*-----------------------------------------------
31.07 .2003 14 : 39
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SvtModuleOptions : : EFactory SvtModuleOptions : : ClassifyFactoryByURL ( const : : rtl : : OUString & sURL ,
const css : : uno : : Sequence < css : : beans : : PropertyValue > & lMediaDescriptor )
{
2011-11-14 11:49:31 +01:00
css : : uno : : Reference < css : : lang : : XMultiServiceFactory > xSMGR = : : comphelper : : getProcessServiceFactory ( ) ;
2004-01-28 18:06:32 +00:00
if ( ! xSMGR . is ( ) )
return E_UNKNOWN_FACTORY ;
css : : uno : : Reference < css : : container : : XNameAccess > xFilterCfg ;
2004-04-29 15:47:31 +00:00
css : : uno : : Reference < css : : container : : XNameAccess > xTypeCfg ;
2004-01-28 18:06:32 +00:00
try
{
xFilterCfg = css : : uno : : Reference < css : : container : : XNameAccess > (
2010-11-22 22:54:33 +01:00
xSMGR - > createInstance ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.document.FilterFactory " ) ) ) , css : : uno : : UNO_QUERY ) ;
2004-04-29 15:47:31 +00:00
xTypeCfg = css : : uno : : Reference < css : : container : : XNameAccess > (
2010-11-22 22:54:33 +01:00
xSMGR - > createInstance ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.document.TypeDetection " ) ) ) , css : : uno : : UNO_QUERY ) ;
2004-01-28 18:06:32 +00:00
}
catch ( const css : : uno : : RuntimeException & )
{ throw ; }
catch ( const css : : uno : : Exception & )
{ return E_UNKNOWN_FACTORY ; }
: : comphelper : : SequenceAsHashMap stlDesc ( lMediaDescriptor ) ;
// is there already a filter inside the descriptor?
2010-11-22 22:54:33 +01:00
: : rtl : : OUString sFilterName = stlDesc . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " FilterName " ) ) , : : rtl : : OUString ( ) ) ;
2004-01-28 18:06:32 +00:00
if ( sFilterName . getLength ( ) )
{
try
{
: : comphelper : : SequenceAsHashMap stlFilterProps ( xFilterCfg - > getByName ( sFilterName ) ) ;
2010-11-22 22:54:33 +01:00
: : rtl : : OUString sDocumentService = stlFilterProps . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " DocumentService " ) ) , : : rtl : : OUString ( ) ) ;
2004-01-28 18:06:32 +00:00
SvtModuleOptions : : EFactory eApp = SvtModuleOptions : : ClassifyFactoryByServiceName ( sDocumentService ) ;
if ( eApp ! = E_UNKNOWN_FACTORY )
return eApp ;
}
catch ( const css : : uno : : RuntimeException & )
{ throw ; }
catch ( const css : : uno : : Exception & )
{ /* do nothing here ... may the following code can help!*/ }
}
// is there already a type inside the descriptor?
2010-11-22 22:54:33 +01:00
: : rtl : : OUString sTypeName = stlDesc . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " TypeName " ) ) , : : rtl : : OUString ( ) ) ;
2004-01-28 18:06:32 +00:00
if ( ! sTypeName . getLength ( ) )
{
// no :-(
// start flat detection of URL
2004-04-29 15:47:31 +00:00
css : : uno : : Reference < css : : document : : XTypeDetection > xDetect ( xTypeCfg , css : : uno : : UNO_QUERY ) ;
2004-01-28 18:06:32 +00:00
sTypeName = xDetect - > queryTypeByURL ( sURL ) ;
}
if ( ! sTypeName . getLength ( ) )
return E_UNKNOWN_FACTORY ;
// yes - there is a type info
2004-04-29 15:47:31 +00:00
// Try to find the preferred filter.
2004-01-28 18:06:32 +00:00
try
{
2004-04-29 15:47:31 +00:00
: : comphelper : : SequenceAsHashMap stlTypeProps ( xTypeCfg - > getByName ( sTypeName ) ) ;
2010-11-22 22:54:33 +01:00
: : rtl : : OUString sPreferredFilter = stlTypeProps . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " PreferredFilter " ) ) , : : rtl : : OUString ( ) ) ;
2004-04-29 15:47:31 +00:00
: : comphelper : : SequenceAsHashMap stlFilterProps ( xFilterCfg - > getByName ( sPreferredFilter ) ) ;
2010-11-22 22:54:33 +01:00
: : rtl : : OUString sDocumentService = stlFilterProps . getUnpackedValueOrDefault ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " DocumentService " ) ) , : : rtl : : OUString ( ) ) ;
2004-04-29 15:47:31 +00:00
SvtModuleOptions : : EFactory eApp = SvtModuleOptions : : ClassifyFactoryByServiceName ( sDocumentService ) ;
if ( eApp ! = E_UNKNOWN_FACTORY )
return eApp ;
2004-01-28 18:06:32 +00:00
}
catch ( const css : : uno : : RuntimeException & )
{ throw ; }
catch ( const css : : uno : : Exception & )
{ /* do nothing here ... may the following code can help!*/ }
// no filter/no type/no detection result => no fun :-)
return E_UNKNOWN_FACTORY ;
}
/*-----------------------------------------------
31.07 .2003 10 : 41
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SvtModuleOptions : : EFactory SvtModuleOptions : : ClassifyFactoryByModel ( const css : : uno : : Reference < css : : frame : : XModel > & xModel )
{
css : : uno : : Reference < css : : lang : : XServiceInfo > xInfo ( xModel , css : : uno : : UNO_QUERY ) ;
if ( ! xInfo . is ( ) )
return E_UNKNOWN_FACTORY ;
const css : : uno : : Sequence < : : rtl : : OUString > lServices = xInfo - > getSupportedServiceNames ( ) ;
const : : rtl : : OUString * pServices = lServices . getConstArray ( ) ;
for ( sal_Int32 i = 0 ; i < lServices . getLength ( ) ; + + i )
{
SvtModuleOptions : : EFactory eApp = SvtModuleOptions : : ClassifyFactoryByServiceName ( pServices [ i ] ) ;
if ( eApp ! = E_UNKNOWN_FACTORY )
return eApp ;
}
return E_UNKNOWN_FACTORY ;
}
2003-09-19 07:10:39 +00:00
: : com : : sun : : star : : uno : : Sequence < : : rtl : : OUString > SvtModuleOptions : : GetAllServiceNames ( )
{
: : osl : : MutexGuard aGuard ( impl_GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > GetAllServiceNames ( ) ;
}
2001-12-03 16:49:23 +00:00
2003-09-19 07:10:39 +00:00
: : rtl : : OUString SvtModuleOptions : : GetDefaultModuleName ( )
{
: : rtl : : OUString aModule ;
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SWRITER ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_WRITER ) ;
else
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SCALC ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_CALC ) ;
else
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SIMPRESS ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_IMPRESS ) ;
else
2007-08-30 15:43:26 +00:00
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SDATABASE ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_DATABASE ) ;
2003-09-19 07:10:39 +00:00
else
2007-08-30 15:43:26 +00:00
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SDRAW ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_DRAW ) ;
2003-09-19 07:10:39 +00:00
else
2007-08-30 15:43:26 +00:00
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SWEB ) )
2003-09-19 07:10:39 +00:00
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_WRITERWEB ) ;
2007-08-30 15:43:26 +00:00
else
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SGLOBAL ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_WRITERGLOBAL ) ;
else
if ( m_pDataContainer - > IsModuleInstalled ( SvtModuleOptions : : E_SMATH ) )
aModule = m_pDataContainer - > GetFactoryShortName ( SvtModuleOptions : : E_MATH ) ;
2003-09-19 07:10:39 +00:00
return aModule ;
}
2007-08-30 15:43:26 +00:00
2010-10-14 08:27:31 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */