summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Driesner <cd@openoffice.org>2002-08-20 09:21:59 +0000
committerCarsten Driesner <cd@openoffice.org>2002-08-20 09:21:59 +0000
commita56ebe278ae13de0a2baa821e30c16b4f06a4191 (patch)
tree7987737f93d9ec004a77b5ab9c93dc4851b6deb1
parent8bdfc1a9efb7d17a4ca17bd179d9d7c33a397328 (diff)
#100825# New services for path settings and path substitution
-rw-r--r--framework/inc/helper/networkdomain.hxx79
-rw-r--r--framework/inc/services.h8
-rw-r--r--framework/inc/services/pathsettings.hxx318
-rw-r--r--framework/inc/services/substitutepathvars.hxx396
-rw-r--r--framework/source/helper/makefile.mk11
-rw-r--r--framework/source/helper/networkdomain.cxx317
-rw-r--r--framework/source/register/registertemp.cxx18
-rw-r--r--framework/source/services/makefile.mk12
-rw-r--r--framework/source/services/pathsettings.cxx1166
-rw-r--r--framework/source/services/substitutepathvars.cxx1488
-rw-r--r--framework/source/unotypes/fwl.xml24
-rw-r--r--framework/util/makefile.mk19
12 files changed, 3837 insertions, 19 deletions
diff --git a/framework/inc/helper/networkdomain.hxx b/framework/inc/helper/networkdomain.hxx
new file mode 100644
index 000000000000..4c570a3685ce
--- /dev/null
+++ b/framework/inc/helper/networkdomain.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * $RCSfile: networkdomain.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:09:28 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __FRAMEWORK_HELPER_NETWORKDOMAIN_HXX_
+#define __FRAMEWORK_HELPER_NETWORKDOMAIN_HXX_
+
+#include <rtl/ustring.hxx>
+
+namespace framework
+{
+
+class NetworkDomain
+{
+ public:
+ static rtl::OUString GetNTDomainName();
+ static rtl::OUString GetYPDomainName();
+};
+
+}
+
+#endif // __FRAMEWORK_HELPER_NETWORKDOMAIN_HXX_
diff --git a/framework/inc/services.h b/framework/inc/services.h
index 75f007b309fe..4634465d2be2 100644
--- a/framework/inc/services.h
+++ b/framework/inc/services.h
@@ -2,9 +2,9 @@
*
* $RCSfile: services.h,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: as $ $Date: 2002-08-12 11:40:36 $
+ * last change: $Author: cd $ $Date: 2002-08-20 10:15:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,6 +113,8 @@ namespace framework{
#define SERVICENAME_DISPATCHRECORDER DECLARE_ASCII("com.sun.star.frame.DispatchRecorder" )
#define SERVICENAME_SYSTEMSHELLEXECUTE DECLARE_ASCII("com.sun.star.system.SystemShellExecute" )
#define SERVICENAME_PROTOCOLHANDLER DECLARE_ASCII("com.sun.star.frame.ProtocolHandler" )
+#define SERVICENAME_SUBSTITUTEPATHVARIABLES DECLARE_ASCII("com.sun.star.util.PathSubstitution" )
+#define SERVICENAME_PATHSETTINGS DECLARE_ASCII("com.sun.star.util.PathSettings" )
//_________________________________________________________________________________________________________________
// used implementationnames by framework
@@ -140,6 +142,8 @@ namespace framework{
#define IMPLEMENTATIONNAME_MAILTODISPATCHER DECLARE_ASCII("com.sun.star.comp.framework.MailToDispatcher" )
#define IMPLEMENTATIONNAME_SERVICEHANDLER DECLARE_ASCII("com.sun.star.comp.framework.ServiceHandler" )
#define IMPLEMENTATIONNAME_UIINTERACTIONHANDLER DECLARE_ASCII("com.sun.star.comp.uui.UUIInteractionHandler" )
+#define IMPLEMENTATIONNAME_SUBSTITUTEPATHVARIABLES DECLARE_ASCII("com.sun.star.comp.framework.PathSubstitution" )
+#define IMPLEMENTATIONNAME_PATHSETTINGS DECLARE_ASCII("com.sun.star.comp.framework.PathSettings" )
} // namespace framework
diff --git a/framework/inc/services/pathsettings.hxx b/framework/inc/services/pathsettings.hxx
new file mode 100644
index 000000000000..e565e9c349c8
--- /dev/null
+++ b/framework/inc/services/pathsettings.hxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: pathsettings.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:10:29 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
+#define __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+
+#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
+#include <threadhelp/threadhelpbase.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_GENERIC_HXX_
+#include <macros/generic.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XINTERFACE_HXX_
+#include <macros/xinterface.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XTYPEPROVIDER_HXX_
+#include <macros/xtypeprovider.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XSERVICEINFO_HXX_
+#include <macros/xserviceinfo.hxx>
+#endif
+
+#ifndef __FRAMEWORK_STDTYPES_H_
+#include <stdtypes.h>
+#endif
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XSTRINGSUBSTITUTION_HPP_
+#include <com/sun/star/util/XStringSubstitution.hpp>
+#endif
+
+//_________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#include <cppuhelper/propshlp.hxx>
+#endif
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _UTL_CONFIGITEM_HXX_
+#include <unotools/configitem.hxx>
+#endif
+
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+
+
+namespace framework
+{
+
+struct PathSettingsNotify
+{
+ com::sun::star::uno::Sequence< rtl::OUString > aPathSettingsChanged;
+};
+
+struct PathSettingsData
+{
+ // ID's for the supported pathes. Must be sorted by name!!
+ enum PathSettingsId
+ {
+ PS_ADDINPATH,
+ PS_AUTOCORRECTPATH,
+ PS_AUTOTEXTPATH,
+ PS_BACKUPPATH,
+ PS_BASICPATH,
+ PS_BITMAPPATH,
+ PS_CONFIGPATH,
+ PS_DICTIONARYPATH,
+ PS_FAVORITESPATH,
+ PS_FILTERPATH,
+ PS_GALLERYPATH,
+ PS_GRAPHICPATH,
+ PS_HELPPATH,
+ PS_LINGUISTICPATH,
+ PS_MODULEPATH,
+ PS_PALETTEPATH,
+ PS_PLUGINPATH,
+ PS_STORAGEPATH,
+ PS_TEMPPATH,
+ PS_TEMPLATEPATH,
+ PS_UICONFIGPATH,
+ PS_USERCONFIGPATH,
+ PS_USERDICTIONARYPATH,
+ PS_WORKPATH,
+ PS_COUNT
+ };
+
+ void SetValue( PathSettingsId nId, rtl::OUString& aValue );
+ const rtl::OUString& GetValue( PathSettingsId nId ) const;
+
+ // Strings for all supported pathes
+ ::rtl::OUString m_aAddinPath;
+ ::rtl::OUString m_aAutoCorrectPath;
+ ::rtl::OUString m_aAutoTextPath;
+ ::rtl::OUString m_aBackupPath;
+ ::rtl::OUString m_aBasicPath;
+ ::rtl::OUString m_aBitmapPath;
+ ::rtl::OUString m_aConfigPath;
+ ::rtl::OUString m_aDictionaryPath;
+ ::rtl::OUString m_aFavoritesPath;
+ ::rtl::OUString m_aFilterPath;
+ ::rtl::OUString m_aGalleryPath;
+ ::rtl::OUString m_aGraphicPath;
+ ::rtl::OUString m_aHelpPath;
+ ::rtl::OUString m_aLinguisticPath;
+ ::rtl::OUString m_aModulePath;
+ ::rtl::OUString m_aPalettePath;
+ ::rtl::OUString m_aPluginPath;
+ ::rtl::OUString m_aStoragePath;
+ ::rtl::OUString m_aTempPath;
+ ::rtl::OUString m_aTemplatePath;
+ ::rtl::OUString m_aUIConfigPath;
+ ::rtl::OUString m_aUserConfigPath;
+ ::rtl::OUString m_aUserDictionaryPath;
+ ::rtl::OUString m_aWorkPath;
+
+ ::rtl::OUString m_aEmptyStr;
+};
+
+class PathSettings;
+class PathSettings_Impl : public utl::ConfigItem
+{
+ friend class PathSettings;
+
+ public:
+ PathSettings_Impl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xSMgr, const Link& aNotifyLink );
+ virtual ~PathSettings_Impl();
+
+ /** is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. */
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+
+ sal_Bool ReadConfigurationData( PathSettingsData& rSettingsData, const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ sal_Bool WriteConfigurationData( const PathSettingsData& rSettingsData, const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ sal_Bool CheckAndReplaceNewPathValue( PathSettingsData::PathSettingsId nId, rtl::OUString& aNewPathValue );
+
+ int GetHandleFromPropertyName( const rtl::OUString& aPropertyName );
+
+ private:
+ sal_Bool CheckPath( PathSettingsData::PathSettingsId nId, const rtl::OUString& aNewPathValue );
+
+ class PropToHandleHashMap : public ::std::hash_map< ::rtl::OUString,
+ PathSettingsData::PathSettingsId,
+ OUStringHashCode,
+ ::std::equal_to< ::rtl::OUString > >
+ {
+ public:
+ inline void free()
+ {
+ PropToHandleHashMap().swap( *this );
+ }
+ };
+
+ Link m_aListenerNotify ;
+ PropToHandleHashMap m_aPropNameToHandleMap ;
+ com::sun::star::uno::Reference< com::sun::star::util::XStringSubstitution > m_xPathVariableSubstitution ;
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xFactory ;
+};
+
+
+class PathSettings : // interfaces
+ public css::lang::XTypeProvider ,
+ public css::lang::XServiceInfo ,
+ // base classes
+ // Order is neccessary for right initialization!
+ private ThreadHelpBase ,
+ public ::cppu::OBroadcastHelper ,
+ public ::cppu::OPropertySetHelper ,
+ public ::cppu::OWeakObject
+{
+ friend class PathSettings_Impl;
+
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+ public:
+ PathSettings( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
+ virtual ~PathSettings( );
+
+ // XInterface, XTypeProvider, XServiceInfo
+ DECLARE_XINTERFACE
+ DECLARE_XTYPEPROVIDER
+ DECLARE_XSERVICEINFO
+
+
+ //-------------------------------------------------------------------------------------------------------------
+ // protected methods
+ //-------------------------------------------------------------------------------------------------------------
+ protected:
+
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue ,
+ css::uno::Any& aOldValue ,
+ sal_Int32 nHandle ,
+ const css::uno::Any& aValue )
+ throw( css::lang::IllegalArgumentException );
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
+ const css::uno::Any& aValue )
+ throw( css::uno::Exception );
+
+ virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue ,
+ sal_Int32 nHandle ) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( );
+
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ DECL_LINK( implts_ConfigurationNotify, PathSettingsNotify* );
+
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+ sal_Bool impl_tryToChangeProperty ( rtl::OUString sCurrentValue ,
+ const css::uno::Any& aNewValue ,
+ css::uno::Any& aOldValue ,
+ css::uno::Any& aConvertedValue )
+ throw( css::lang::IllegalArgumentException );
+
+ static const css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor();
+
+ // Members
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// reference to factory, which has create this instance
+ PathSettings_Impl m_aImpl ;
+ PathSettingsData m_aPathSettingsData ;
+};
+
+} // namespace framework
+
+#endif // __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
diff --git a/framework/inc/services/substitutepathvars.hxx b/framework/inc/services/substitutepathvars.hxx
new file mode 100644
index 000000000000..68622496c171
--- /dev/null
+++ b/framework/inc/services/substitutepathvars.hxx
@@ -0,0 +1,396 @@
+/*************************************************************************
+ *
+ * $RCSfile: substitutepathvars.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:10:30 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __FRAMEWORK_SERVICES_SUBSTPATHVARS_HXX_
+#define __FRAMEWORK_SERVICES_SUBSTPATHVARS_HXX_
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+
+#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
+#include <threadhelp/threadhelpbase.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_GENERIC_HXX_
+#include <macros/generic.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XINTERFACE_HXX_
+#include <macros/xinterface.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XTYPEPROVIDER_HXX_
+#include <macros/xtypeprovider.hxx>
+#endif
+
+#ifndef __FRAMEWORK_MACROS_XSERVICEINFO_HXX_
+#include <macros/xserviceinfo.hxx>
+#endif
+
+#ifndef __FRAMEWORK_STDTYPES_H_
+#include <stdtypes.h>
+#endif
+
+#ifndef __FRAMEWORK_CLASSES_WILDCARD_HXX_
+#include <classes/wildcard.hxx>
+#endif
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XSTRINGSUBSTITUTION_HPP_
+#include <com/sun/star/util/XStringSubstitution.hpp>
+#endif
+
+//_________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _UTL_CONFIGITEM_HXX_
+#include <unotools/configitem.hxx>
+#endif
+
+#ifndef _LINK_HXX
+#include <tools/link.hxx>
+#endif
+
+#ifndef _LANG_HXX
+#include <tools/lang.hxx>
+#endif
+
+#include <vector>
+#include <list>
+#include <hash_map>
+
+
+namespace framework
+{
+
+// Must be zero value based
+enum EnvironmentType
+{
+ ET_HOST = 0 ,
+ ET_YPDOMAIN ,
+ ET_DNSDOMAIN ,
+ ET_NTDOMAIN ,
+ ET_OS ,
+ ET_UNKNOWN ,
+ ET_COUNT
+};
+
+// Must be zero value based
+enum OperatingSystem
+{
+ OS_WINDOWS = 0,
+ OS_UNIX ,
+ OS_SOLARIS ,
+ OS_LINUX ,
+ OS_UNKNOWN ,
+ OS_COUNT
+};
+
+struct SubstituteRule
+{
+ SubstituteRule() {}
+ SubstituteRule( const rtl::OUString& aVarName,
+ const rtl::OUString& aValue,
+ const com::sun::star::uno::Any& aVal,
+ EnvironmentType aType ) :
+ aSubstVariable( aVarName ), aSubstValue( aValue ), aEnvValue( aVal ), aEnvType( aType ) {}
+
+ rtl::OUString aSubstVariable;
+ rtl::OUString aSubstValue;
+ com::sun::star::uno::Any aEnvValue;
+ EnvironmentType aEnvType;
+};
+
+struct SubstitutePathNotify
+{
+ const com::sun::star::uno::Sequence<rtl::OUString> aPropertyNames;
+};
+
+class SubstituteVariables : public ::std::hash_map< ::rtl::OUString,
+ SubstituteRule,
+ OUStringHashCode,
+ ::std::equal_to< ::rtl::OUString > >
+{
+ public:
+ inline void free()
+ {
+ SubstituteVariables().swap( *this );
+ }
+};
+
+typedef std::vector< SubstituteRule > SubstituteRuleVector;
+class SubstitutePathVariables_Impl : public utl::ConfigItem
+{
+ public:
+ SubstitutePathVariables_Impl( const Link& aNotifyLink );
+ virtual ~SubstitutePathVariables_Impl();
+
+ static OperatingSystem GetOperatingSystemFromString( const rtl::OUString& );
+ static EnvironmentType GetEnvTypeFromString( const rtl::OUString& );
+
+ void GetSharePointsRules( SubstituteVariables& aSubstVarMap );
+
+ /** is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. */
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+
+ private:
+ // Wrapper methods for low-level functions
+ OperatingSystem GetOperatingSystem();
+ const rtl::OUString& GetYPDomainName();
+ const rtl::OUString& GetDNSDomainName();
+ const rtl::OUString& GetNTDomainName();
+ const rtl::OUString& GetHostName();
+
+ sal_Bool FilterRuleSet( const SubstituteRuleVector& aRuleSet, SubstituteRule& aActiveRule );
+
+ void ReadSharePointsFromConfiguration( com::sun::star::uno::Sequence< rtl::OUString >& aSharePointsSeq );
+ void ReadSharePointRuleSetFromConfiguration( const rtl::OUString& aSharePointName,
+ const rtl::OUString& aSharePointNodeName,
+ SubstituteRuleVector& aRuleSet );
+
+ // Stored values for domains and host
+ sal_Bool m_bYPDomainRetrieved;
+ rtl::OUString m_aYPDomain;
+ sal_Bool m_bDNSDomainRetrieved;
+ rtl::OUString m_aDNSDomain;
+ sal_Bool m_bNTDomainRetrieved;
+ rtl::OUString m_aNTDomain;
+ sal_Bool m_bHostRetrieved;
+ rtl::OUString m_aHost;
+ sal_Bool m_bOSRetrieved;
+ OperatingSystem m_eOSType;
+
+ Link m_aListenerNotify;
+ const rtl::OUString m_aSharePointsNodeName;
+ const rtl::OUString m_aDirPropertyName;
+ const rtl::OUString m_aEnvPropertyName;
+ const rtl::OUString m_aLevelSep;
+};
+
+enum PreDefVariable
+{
+ PREDEFVAR_INST,
+ PREDEFVAR_PROG,
+ PREDEFVAR_USER,
+ PREDEFVAR_WORK,
+ PREDEFVAR_HOME,
+ PREDEFVAR_TEMP,
+ PREDEFVAR_LANG,
+ PREDEFVAR_LANGID,
+ PREDEFVAR_VLANG,
+ PREDEFVAR_INSTPATH,
+ PREDEFVAR_PROGPATH,
+ PREDEFVAR_USERPATH,
+ PREDEFVAR_INSTURL,
+ PREDEFVAR_PROGURL,
+ PREDEFVAR_USERURL,
+ PREDEFVAR_WORKDIRURL,
+ PREDEFVAR_COUNT
+};
+
+struct PredefinedPathVariables
+{
+ // Predefined variables supported by substitute variables
+ LanguageType m_eLanguageType; // Lanuage type of Office
+ rtl::OUString m_FixedVar[ PREDEFVAR_COUNT ]; // Variable value access by PreDefVariable
+ rtl::OUString m_FixedVarNames[ PREDEFVAR_COUNT ]; // Variable name access by PreDefVariable
+};
+
+struct ReSubstFixedVarOrder
+{
+ sal_Int32 nVarValueLength;
+ PreDefVariable eVariable;
+
+ bool ReSubstFixedVarOrder::operator< ( const ReSubstFixedVarOrder& aFixedVarOrder )
+ {
+ // Reverse operator< to have high to low ordering
+ return ( nVarValueLength > aFixedVarOrder.nVarValueLength );
+ }
+};
+
+struct ReSubstUserVarOrder
+{
+ sal_Int32 nVarValueLength;
+ rtl::OUString aVarName;
+
+ bool ReSubstUserVarOrder::operator< ( const ReSubstUserVarOrder& aUserVarOrder )
+ {
+ // Reverse operator< to have high to low ordering
+ return ( nVarValueLength > aUserVarOrder.nVarValueLength );
+ }
+};
+
+typedef std::list< ReSubstFixedVarOrder > ReSubstFixedVarOrderVector;
+typedef std::list< ReSubstUserVarOrder > ReSubstUserVarOrderVector;
+
+class WorkPathHelper_Impl : public utl::ConfigItem
+{
+ public:
+ WorkPathHelper_Impl();
+
+ rtl::OUString GetWorkPath();
+
+ private:
+ com::sun::star::uno::Sequence< rtl::OUString > m_aPathNameSeq;
+};
+
+class SubstitutePathVariables : public com::sun::star::lang::XTypeProvider ,
+ public com::sun::star::lang::XServiceInfo ,
+ public com::sun::star::util::XStringSubstitution,
+ private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
+ public ::cppu::OWeakObject
+{
+ friend class SubstitutePathVariables_Impl;
+
+ public:
+ SubstitutePathVariables( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+ virtual ~SubstitutePathVariables();
+
+ // XInterface, XTypeProvider, XServiceInfo
+ DECLARE_XINTERFACE
+ DECLARE_XTYPEPROVIDER
+ DECLARE_XSERVICEINFO
+
+ // XStringSubstitution
+ virtual rtl::OUString SAL_CALL substituteVariables( const ::rtl::OUString& aText, sal_Bool bSubstRequired )
+ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL reSubstituteVariables( const ::rtl::OUString& aText )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSubstituteVariableValue( const ::rtl::OUString& variable )
+ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ DECL_LINK( implts_ConfigurationNotify, SubstitutePathNotify* );
+
+ void SetPredefinedPathVariables( PredefinedPathVariables& );
+ rtl::OUString ConvertOSLtoUCBURL( const rtl::OUString& aOSLCompliantURL ) const;
+
+ // Special case (transient) values can change during runtime!
+ // Don't store them in the pre defined struct
+ rtl::OUString GetWorkVariableValue() const;
+ rtl::OUString GetPathVariableValue() const;
+
+ rtl::OUString GetHomeVariableValue() const;
+ rtl::OUString GetLanguageString( LanguageType eLanguageType ) const;
+
+ // XStringSubstitution implementation methods
+ rtl::OUString impl_substituteVariable( const ::rtl::OUString& aText, sal_Bool bSustRequired )
+ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ rtl::OUString impl_reSubstituteVariables( const ::rtl::OUString& aText )
+ throw (::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString impl_getSubstituteVariableValue( const ::rtl::OUString& variable )
+ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ private:
+ class VarNameToIndexMap : public std::hash_map< ::rtl::OUString,
+ PreDefVariable,
+ OUStringHashCode,
+ ::std::equal_to< ::rtl::OUString > >
+ {
+ inline void free()
+ {
+ VarNameToIndexMap().swap( *this );
+ }
+ };
+
+ // heavy used string
+ const rtl::OUString m_aVarStart;
+ const rtl::OUString m_aVarEnd;
+
+ VarNameToIndexMap m_aPreDefVarMap; // Mapping from pre-def variable names to enum for array access
+ SubstituteVariables m_aSubstVarMap; // Active rule set map indexed by variable name!
+ PredefinedPathVariables m_aPreDefVars; // All predefined variables
+ SubstitutePathVariables_Impl m_aImpl; // Implementation class that access the configuration
+ ReSubstFixedVarOrderVector m_aReSubstFixedVarOrder; // To speed up resubstitution fixed variables (order for lookup)
+ ReSubstUserVarOrderVector m_aReSubstUserVarOrder; // To speed up resubstitution user variables
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
+ WorkPathHelper_Impl m_aWorkPathHelper; // Helper class to get a substitution for $(workdirurl)
+};
+
+}
+
+#endif // __FRAMEWORK_SERVICES_SUBSTPATHVARS_HXX_
diff --git a/framework/source/helper/makefile.mk b/framework/source/helper/makefile.mk
index 2dd43b3d06aa..f79279ec4e83 100644
--- a/framework/source/helper/makefile.mk
+++ b/framework/source/helper/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.20 $
+# $Revision: 1.21 $
#
-# last change: $Author: as $ $Date: 2002-08-12 11:44:19 $
+# last change: $Author: cd $ $Date: 2002-08-20 10:16:01 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -91,10 +91,11 @@ SLOFILES= $(SLO)$/timerhelper.obj \
$(SLO)$/xmldocproperties.obj \
$(SLO)$/propertysetcontainer.obj \
$(SLO)$/actiontriggerhelper.obj \
- $(SLO)$/asyncloadthread.obj \
- $(SLO)$/componentloader.obj \
+ $(SLO)$/asyncloadthread.obj \
+ $(SLO)$/componentloader.obj \
$(SLO)$/loadeventlistener.obj \
- $(SLO)$/persistentwindowstate.obj
+ $(SLO)$/persistentwindowstate.obj \
+ $(SLO)$/networkdomain.obj
# --- Targets ------------------------------------------------------
diff --git a/framework/source/helper/networkdomain.cxx b/framework/source/helper/networkdomain.cxx
new file mode 100644
index 000000000000..e2b963ca4e27
--- /dev/null
+++ b/framework/source/helper/networkdomain.cxx
@@ -0,0 +1,317 @@
+/*************************************************************************
+ *
+ * $RCSfile: networkdomain.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:12:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __FRAMEWORK_HELPER_NETWORKDOMAIN_HXX_
+#include <helper/networkdomain.hxx>
+#endif
+
+namespace framework
+{
+
+#ifdef WNT
+//_________________________________________________________________________________________________________________
+// Windows
+//_________________________________________________________________________________________________________________
+
+#define UNICODE
+#include <windows.h>
+
+//_________________________________________________________________________________________________________________
+// Win NT, Win 2000, Win XP
+//_________________________________________________________________________________________________________________
+
+static DWORD WINAPI GetUserDomainW_NT( LPWSTR lpBuffer, DWORD nSize )
+{
+ return GetEnvironmentVariable( TEXT("USERDOMAIN"), lpBuffer, nSize );
+}
+
+//_________________________________________________________________________________________________________________
+// Win 9x,Win ME
+//_________________________________________________________________________________________________________________
+
+static DWORD WINAPI GetUserDomainW_WINDOWS( LPWSTR lpBuffer, DWORD nSize )
+{
+ HKEY hkeyLogon;
+ HKEY hkeyWorkgroup;
+ DWORD dwResult = 0;
+
+
+ if ( ERROR_SUCCESS == RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE,
+ TEXT("Network\\Logon"),
+ 0, KEY_READ, &hkeyLogon ) )
+ {
+ DWORD dwLogon = 0;
+ DWORD dwLogonSize = sizeof(dwLogon);
+ LONG lResult = RegQueryValueEx( hkeyLogon, TEXT("LMLogon"), 0, NULL, (LPBYTE)&dwLogon, &dwLogonSize );
+ RegCloseKey( hkeyLogon );
+
+ if ( dwLogon )
+ {
+ HKEY hkeyNetworkProvider;
+
+ if ( ERROR_SUCCESS == RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE,
+ TEXT("SYSTEM\\CurrentControlSet\\Services\\MSNP32\\NetworkProvider"),
+ 0, KEY_READ, &hkeyNetworkProvider ) )
+ {
+ DWORD dwBufferSize = nSize;
+ LONG lResult = RegQueryValueEx( hkeyNetworkProvider, TEXT("AuthenticatingAgent"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
+
+ if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
+ dwResult = dwBufferSize / sizeof(TCHAR);
+
+ RegCloseKey( hkeyNetworkProvider );
+ }
+ }
+ }
+ else if ( ERROR_SUCCESS == RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE,
+ TEXT("SYSTEM\\CurrentControlSet\\Services\\VxD\\VNETSUP"),
+ 0, KEY_READ, &hkeyWorkgroup ) )
+ {
+ DWORD dwBufferSize = nSize;
+ LONG lResult = RegQueryValueEx( hkeyWorkgroup, TEXT("Workgroup"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
+
+ if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
+ dwResult = dwBufferSize / sizeof(TCHAR);
+
+ RegCloseKey( hkeyWorkgroup );
+ }
+
+
+ return dwResult;
+}
+
+static rtl::OUString GetUserDomain()
+{
+ sal_Unicode aBuffer[256];
+
+ long nVersion = GetVersion();
+ DWORD nResult;
+
+ if ( nVersion < 0 )
+ nResult = GetUserDomainW_WINDOWS( aBuffer, sizeof( aBuffer ) );
+ else
+ nResult = GetUserDomainW_NT( aBuffer, sizeof( aBuffer ) );
+
+ if ( nResult > 0 )
+ return rtl::OUString( aBuffer );
+ else
+ return rtl::OUString();
+}
+
+//_________________________________________________________________________________________________________________
+// Windows
+//_________________________________________________________________________________________________________________
+
+rtl::OUString NetworkDomain::GetYPDomainName()
+{
+ return ::rtl::OUString();
+}
+
+rtl::OUString NetworkDomain::GetNTDomainName()
+{
+ return GetUserDomain();
+}
+
+#elif defined( UNIX )
+
+//_________________________________________________________________________________________________________________
+// Unix
+//_________________________________________________________________________________________________________________
+
+#if defined( SOLARIS )
+
+//_________________________________________________________________________________________________________________
+// Solaris
+//_________________________________________________________________________________________________________________
+
+#include <sys/systeminfo.h>
+
+static rtl_uString *getDomainName()
+{
+ /* Initialize and assume failure */
+ rtl_uString *ustrDomainName = NULL;
+
+ char szBuffer[256];
+
+ long nCopied = sizeof(szBuffer);
+ char *pBuffer = szBuffer;
+ long nBufSize;
+
+ do
+ {
+ nBufSize = nCopied;
+ nCopied = sysinfo( SI_SRPC_DOMAIN, pBuffer, nBufSize );
+
+ /* If nCopied is greater than buffersize we need to allocate
+ a buffer with suitable size */
+
+ if ( nCopied > nBufSize )
+ pBuffer = (char *)alloca( nCopied );
+
+ } while ( nCopied > nBufSize );
+
+ if ( -1 != nCopied )
+ {
+ rtl_string2uString(
+ &ustrDomainName,
+ pBuffer,
+ nCopied - 1,
+ osl_getThreadTextEncoding(),
+ OSTRING_TO_OUSTRING_CVTFLAGS );
+ }
+
+ return ustrDomainName;
+}
+
+#elif defined( LINUX ) /* endif SOLARIS */
+
+//_________________________________________________________________________________________________________________
+// Linux
+//_________________________________________________________________________________________________________________
+
+#include <unistd.h>
+#include <stdlib.h>
+
+static rtl_uString *getDomainName()
+{
+ /* Initialize and assume failure */
+ rtl_uString *ustrDomainName = NULL;
+
+ char *pBuffer;
+ int result;
+ size_t nBufSize = 0;
+
+ do
+ {
+ nBufSize += 256; /* Increase buffer size by steps of 256 bytes */
+ pBuffer = (char *)alloca( nBufSize );
+ result = getdomainname( pBuffer, nBufSize );
+ /* If buffersize in not large enough -1 is returned and errno
+ is set to EINVAL. This only applies to libc. With glibc the name
+ is truncated. */
+ } while ( -1 == result && EINVAL == errno );
+
+ if ( 0 == result )
+ {
+ rtl_string2uString(
+ &ustrDomainName,
+ pBuffer,
+ strlen( pBuffer ),
+ osl_getThreadTextEncoding(),
+ OSTRING_TO_OUSTRING_CVTFLAGS );
+ }
+
+ return ustrDomainName;
+}
+
+#else /* LINUX */
+
+//_________________________________________________________________________________________________________________
+// Other Unix
+//_________________________________________________________________________________________________________________
+
+static rtl_uString *getDomainName()
+{
+ return NULL;
+}
+
+#endif
+
+//_________________________________________________________________________________________________________________
+// Unix
+//_________________________________________________________________________________________________________________
+
+rtl::OUString NetworkDomain::GetYPDomainName()
+{
+ rtl_uString* pResult = getDomainName();
+ if ( pResult )
+ return rtl::OUString( pResult );
+ else
+ return rtl::OUString();
+}
+
+rtl::OUString NetworkDomain::GetNTDomainName()
+{
+ return ::rtl::OUString();
+}
+
+#else /* UNIX */
+
+//_________________________________________________________________________________________________________________
+// Other operating systems (non-Windows and non-Unix)
+//_________________________________________________________________________________________________________________
+
+rtl::OUString NetworkDomain::GetYPDomainName()
+{
+ return rtl::OUString();
+}
+
+rtl::OUString NetworkDomain::GetNTDomainName()
+{
+ return rtl::OUString();
+}
+
+#endif
+
+} // namespace framework
diff --git a/framework/source/register/registertemp.cxx b/framework/source/register/registertemp.cxx
index 3646162c0224..aa229e55b438 100644
--- a/framework/source/register/registertemp.cxx
+++ b/framework/source/register/registertemp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: registertemp.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: as $ $Date: 2001-07-02 13:40:08 $
+ * last change: $Author: cd $ $Date: 2002-08-20 10:19:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -111,6 +111,14 @@
#include <services/contenthandlerfactory.hxx>
#endif
+#ifndef __FRAMEWORK_SERVICES_SUBSTPATHVARS_HXX_
+#include <services/substitutepathvars.hxx>
+#endif
+
+#ifndef __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
+#include <services/pathsettings.hxx>
+#endif
+
COMPONENTGETIMPLEMENTATIONENVIRONMENT
COMPONENTWRITEINFO ( COMPONENTINFO( ::framework::MediaTypeDetectionHelper )
@@ -118,11 +126,15 @@ COMPONENTWRITEINFO ( COMPONENTINFO( ::framework::MediaTypeDetectionHelper
COMPONENTINFO( ::framework::FilterFactory )
COMPONENTINFO( ::framework::TypeDetection )
COMPONENTINFO( ::framework::ContentHandlerFactory )
+ COMPONENTINFO( ::framework::SubstitutePathVariables )
+ COMPONENTINFO( ::framework::PathSettings )
)
COMPONENTGETFACTORY ( IFFACTORY( ::framework::MediaTypeDetectionHelper ) else
IFFACTORY( ::framework::FrameLoaderFactory ) else
IFFACTORY( ::framework::FilterFactory ) else
IFFACTORY( ::framework::TypeDetection ) else
- IFFACTORY( ::framework::ContentHandlerFactory )
+ IFFACTORY( ::framework::ContentHandlerFactory ) else
+ IFFACTORY( ::framework::SubstitutePathVariables ) else
+ IFFACTORY( ::framework::PathSettings )
)
diff --git a/framework/source/services/makefile.mk b/framework/source/services/makefile.mk
index c3429b2108bb..f8b15a72b738 100644
--- a/framework/source/services/makefile.mk
+++ b/framework/source/services/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.11 $
+# $Revision: 1.12 $
#
-# last change: $Author: as $ $Date: 2002-05-23 12:54:24 $
+# last change: $Author: cd $ $Date: 2002-08-20 10:20:35 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -92,10 +92,12 @@ SLOFILES= \
$(SLO)$/attributelist.obj \
$(SLO)$/saxnamespacefilter.obj \
$(SLO)$/contenthandlerfactory.obj \
- $(SLO)$/jobexecutor.obj
+ $(SLO)$/jobexecutor.obj \
+ $(SLO)$/substitutepathvars.obj \
+ $(SLO)$/pathsettings.obj
-SRCFILES= logindialog.src \
- documentlist.src
+SRCFILES= logindialog.src \
+ documentlist.src
RESLIB1NAME= lgd
RESLIB1SRSFILES= $(SRS)$/$(TARGET).srs
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
new file mode 100644
index 000000000000..a144aafc91c4
--- /dev/null
+++ b/framework/source/services/pathsettings.cxx
@@ -0,0 +1,1166 @@
+/*************************************************************************
+ *
+ * $RCSfile: pathsettings.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:13:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+
+#ifndef __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
+#include <services/pathsettings.hxx>
+#endif
+
+#ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
+#include <threadhelp/resetableguard.hxx>
+#endif
+
+#ifndef __FRAMEWORK_SERVICES_H_
+#include <services.h>
+#endif
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+//_________________________________________________________________________________________________________________
+// includes of other projects
+//_________________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_PROPTYPEHLP_HXX
+#include <cppuhelper/proptypehlp.hxx>
+#endif
+
+#ifndef _UTL_CONFIGITEM_HXX_
+#include <unotools/configitem.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _TOOLS_STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#include <vector>
+
+//_________________________________________________________________________________________________________________
+// non exported const
+//_________________________________________________________________________________________________________________
+
+// ascii strings of the properties
+#define STRING_ASCII_ADDIN "Addin"
+#define STRING_ASCII_AUTOCORRECT "AutoCorrect"
+#define STRING_ASCII_AUTOTEXT "AutoText"
+#define STRING_ASCII_BACKUP "Backup"
+#define STRING_ASCII_BASIC "Basic"
+#define STRING_ASCII_BITMAP "Bitmap"
+#define STRING_ASCII_CONFIG "Config"
+#define STRING_ASCII_DICTIONARY "Dictionary"
+#define STRING_ASCII_FAVORITES "Favorite"
+#define STRING_ASCII_FILTER "Filter"
+#define STRING_ASCII_GALLERY "Gallery"
+#define STRING_ASCII_GRAPHIC "Graphic"
+#define STRING_ASCII_HELP "Help"
+#define STRING_ASCII_LINGUISTIC "Linguistic"
+#define STRING_ASCII_MODULE "Module"
+#define STRING_ASCII_PALETTE "Palette"
+#define STRING_ASCII_PLUGIN "Plugin"
+#define STRING_ASCII_STORAGE "Storage"
+#define STRING_ASCII_TEMP "Temp"
+#define STRING_ASCII_TEMPLATE "Template"
+#define STRING_ASCII_UICONFIG "UIConfig"
+#define STRING_ASCII_USERCONFIG "UserConfig"
+#define STRING_ASCII_USERDICTIONARY "UserDictionary"
+#define STRING_ASCII_WORK "Work"
+
+// name of properties
+#define PROPERTYNAME_ADDIN DECLARE_ASCII(STRING_ASCII_ADDIN)
+#define PROPERTYNAME_AUTOCORRECT DECLARE_ASCII(STRING_ASCII_AUTOCORRECT)
+#define PROPERTYNAME_AUTOTEXT DECLARE_ASCII(STRING_ASCII_AUTOTEXT)
+#define PROPERTYNAME_BACKUP DECLARE_ASCII(STRING_ASCII_BACKUP)
+#define PROPERTYNAME_BASIC DECLARE_ASCII(STRING_ASCII_BASIC)
+#define PROPERTYNAME_BITMAP DECLARE_ASCII(STRING_ASCII_BITMAP)
+#define PROPERTYNAME_CONFIG DECLARE_ASCII(STRING_ASCII_CONFIG)
+#define PROPERTYNAME_DICTIONARY DECLARE_ASCII(STRING_ASCII_DICTIONARY)
+#define PROPERTYNAME_FAVORITES DECLARE_ASCII(STRING_ASCII_FAVORITES)
+#define PROPERTYNAME_FILTER DECLARE_ASCII(STRING_ASCII_FILTER)
+#define PROPERTYNAME_GALLERY DECLARE_ASCII(STRING_ASCII_GALLERY)
+#define PROPERTYNAME_GRAPHIC DECLARE_ASCII(STRING_ASCII_GRAPHIC)
+#define PROPERTYNAME_HELP DECLARE_ASCII(STRING_ASCII_HELP)
+#define PROPERTYNAME_LINGUISTIC DECLARE_ASCII(STRING_ASCII_LINGUISTIC)
+#define PROPERTYNAME_MODULE DECLARE_ASCII(STRING_ASCII_MODULE)
+#define PROPERTYNAME_PALETTE DECLARE_ASCII(STRING_ASCII_PALETTE)
+#define PROPERTYNAME_PLUGIN DECLARE_ASCII(STRING_ASCII_PLUGIN)
+#define PROPERTYNAME_STORAGE DECLARE_ASCII(STRING_ASCII_STORAGE)
+#define PROPERTYNAME_TEMP DECLARE_ASCII(STRING_ASCII_TEMP)
+#define PROPERTYNAME_TEMPLATE DECLARE_ASCII(STRING_ASCII_TEMPLATE)
+#define PROPERTYNAME_UICONFIG DECLARE_ASCII(STRING_ASCII_UICONFIG)
+#define PROPERTYNAME_USERCONFIG DECLARE_ASCII(STRING_ASCII_USERCONFIG)
+#define PROPERTYNAME_USERDICTIONARY DECLARE_ASCII(STRING_ASCII_USERDICTIONARY)
+#define PROPERTYNAME_WORK DECLARE_ASCII(STRING_ASCII_WORK)
+
+
+// handle of properties
+#define PROPERTYHANDLE_ADDIN PathSettingsData::PS_ADDINPATH
+#define PROPERTYHANDLE_AUTOCORRECT PathSettingsData::PS_AUTOCORRECTPATH
+#define PROPERTYHANDLE_AUTOTEXT PathSettingsData::PS_AUTOTEXTPATH
+#define PROPERTYHANDLE_BACKUP PathSettingsData::PS_BACKUPPATH
+#define PROPERTYHANDLE_BASIC PathSettingsData::PS_BASICPATH
+#define PROPERTYHANDLE_BITMAP PathSettingsData::PS_BITMAPPATH
+#define PROPERTYHANDLE_CONFIG PathSettingsData::PS_CONFIGPATH
+#define PROPERTYHANDLE_DICTIONARY PathSettingsData::PS_DICTIONARYPATH
+#define PROPERTYHANDLE_FAVORITES PathSettingsData::PS_FAVORITESPATH
+#define PROPERTYHANDLE_FILTER PathSettingsData::PS_FILTERPATH
+#define PROPERTYHANDLE_GALLERY PathSettingsData::PS_GALLERYPATH
+#define PROPERTYHANDLE_GRAPHIC PathSettingsData::PS_GRAPHICPATH
+#define PROPERTYHANDLE_HELP PathSettingsData::PS_HELPPATH
+#define PROPERTYHANDLE_LINGUISTIC PathSettingsData::PS_LINGUISTICPATH
+#define PROPERTYHANDLE_MODULE PathSettingsData::PS_MODULEPATH
+#define PROPERTYHANDLE_PALETTE PathSettingsData::PS_PALETTEPATH
+#define PROPERTYHANDLE_PLUGIN PathSettingsData::PS_PLUGINPATH
+#define PROPERTYHANDLE_STORAGE PathSettingsData::PS_STORAGEPATH
+#define PROPERTYHANDLE_TEMP PathSettingsData::PS_TEMPPATH
+#define PROPERTYHANDLE_TEMPLATE PathSettingsData::PS_TEMPLATEPATH
+#define PROPERTYHANDLE_UICONFIG PathSettingsData::PS_UICONFIGPATH
+#define PROPERTYHANDLE_USERCONFIG PathSettingsData::PS_USERCONFIGPATH
+#define PROPERTYHANDLE_USERDICTIONARY PathSettingsData::PS_USERDICTIONARYPATH
+#define PROPERTYHANDLE_WORK PathSettingsData::PS_WORKPATH
+
+// count of ALL properties
+#define PROPERTYCOUNT PathSettingsData::PS_COUNT
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::util;
+
+//_________________________________________________________________________________________________________________
+// namespace
+//_________________________________________________________________________________________________________________
+
+namespace framework
+{
+
+static const char* aPropNames[] =
+{
+ STRING_ASCII_ADDIN, // PS_ADDIN
+ STRING_ASCII_AUTOCORRECT, // PS_AUTOCORRECT
+ STRING_ASCII_AUTOTEXT, // PS_AUTOTEXT
+ STRING_ASCII_BACKUP, // PS_BACKUP
+ STRING_ASCII_BASIC, // PS_BASIC
+ STRING_ASCII_BITMAP, // PS_BITMAP
+ STRING_ASCII_CONFIG, // PS_CONFIG
+ STRING_ASCII_DICTIONARY, // PS_DICTIONARY
+ STRING_ASCII_FAVORITES, // PS_FAVORITES
+ STRING_ASCII_FILTER, // PS_FILTER
+ STRING_ASCII_GALLERY, // PS_GALLERY
+ STRING_ASCII_GRAPHIC, // PS_GRAPHIC
+ STRING_ASCII_HELP, // PS_HELP
+ STRING_ASCII_LINGUISTIC, // PS_LINGUISTIC
+ STRING_ASCII_MODULE, // PS_MODULE
+ STRING_ASCII_PALETTE, // PS_PALETTE
+ STRING_ASCII_PLUGIN, // PS_PLUGIN
+ STRING_ASCII_STORAGE, // PS_STORAGE
+ STRING_ASCII_TEMP, // PS_TEMP
+ STRING_ASCII_TEMPLATE, // PS_TEMPLATE
+ STRING_ASCII_UICONFIG, // PS_USERCONFIG
+ STRING_ASCII_USERCONFIG, // PS_USERDICTIONARY
+ STRING_ASCII_USERDICTIONARY, // PS_UICONFIG
+ STRING_ASCII_WORK // PS_WORK
+};
+
+Sequence< rtl::OUString > GetPathPropertyNames()
+{
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< rtl::OUString > aNames( nCount );
+ rtl::OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = rtl::OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+//_________________________________________________________________________________________________________________
+// Implementation helper class
+//_________________________________________________________________________________________________________________
+//
+
+void PathSettingsData::SetValue( PathSettingsId nId, rtl::OUString& aValue )
+{
+ switch ( nId )
+ {
+ case PathSettingsData::PS_ADDINPATH: m_aAddinPath = aValue; break;
+ case PathSettingsData::PS_AUTOCORRECTPATH: m_aAutoCorrectPath = aValue; break;
+ case PathSettingsData::PS_AUTOTEXTPATH: m_aAutoTextPath = aValue; break;
+ case PathSettingsData::PS_BACKUPPATH: m_aBackupPath = aValue; break;
+ case PathSettingsData::PS_BASICPATH: m_aBasicPath = aValue; break;
+ case PathSettingsData::PS_BITMAPPATH: m_aBitmapPath = aValue; break;
+ case PathSettingsData::PS_CONFIGPATH: m_aConfigPath = aValue; break;
+ case PathSettingsData::PS_DICTIONARYPATH: m_aDictionaryPath = aValue; break;
+ case PathSettingsData::PS_FAVORITESPATH: m_aFavoritesPath = aValue; break;
+ case PathSettingsData::PS_FILTERPATH: m_aFilterPath = aValue; break;
+ case PathSettingsData::PS_GALLERYPATH: m_aGalleryPath = aValue; break;
+ case PathSettingsData::PS_GRAPHICPATH: m_aGraphicPath = aValue; break;
+ case PathSettingsData::PS_HELPPATH: m_aHelpPath = aValue; break;
+ case PathSettingsData::PS_LINGUISTICPATH: m_aLinguisticPath = aValue; break;
+ case PathSettingsData::PS_MODULEPATH: m_aModulePath = aValue; break;
+ case PathSettingsData::PS_PALETTEPATH: m_aPalettePath = aValue; break;
+ case PathSettingsData::PS_PLUGINPATH: m_aPluginPath = aValue; break;
+ case PathSettingsData::PS_STORAGEPATH: m_aStoragePath = aValue; break;
+ case PathSettingsData::PS_TEMPPATH: m_aTempPath = aValue; break;
+ case PathSettingsData::PS_TEMPLATEPATH: m_aTemplatePath = aValue; break;
+ case PathSettingsData::PS_USERCONFIGPATH: m_aUserConfigPath = aValue; break;
+ case PathSettingsData::PS_USERDICTIONARYPATH: m_aUserDictionaryPath = aValue; break;
+ case PathSettingsData::PS_WORKPATH: m_aWorkPath = aValue; break;
+ case PathSettingsData::PS_UICONFIGPATH: m_aUIConfigPath = aValue; break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to load a path" );
+ }
+}
+
+const rtl::OUString& PathSettingsData::GetValue( PathSettingsId nId ) const
+{
+ switch ( nId )
+ {
+ case PathSettingsData::PS_ADDINPATH: return m_aAddinPath;
+ case PathSettingsData::PS_AUTOCORRECTPATH: return m_aAutoCorrectPath;
+ case PathSettingsData::PS_AUTOTEXTPATH: return m_aAutoTextPath;
+ case PathSettingsData::PS_BACKUPPATH: return m_aBackupPath;
+ case PathSettingsData::PS_BASICPATH: return m_aBasicPath;
+ case PathSettingsData::PS_BITMAPPATH: return m_aBitmapPath;
+ case PathSettingsData::PS_CONFIGPATH: return m_aConfigPath;
+ case PathSettingsData::PS_DICTIONARYPATH: return m_aDictionaryPath;
+ case PathSettingsData::PS_FAVORITESPATH: return m_aFavoritesPath;
+ case PathSettingsData::PS_FILTERPATH: return m_aFilterPath;
+ case PathSettingsData::PS_GALLERYPATH: return m_aGalleryPath;
+ case PathSettingsData::PS_GRAPHICPATH: return m_aGraphicPath;
+ case PathSettingsData::PS_HELPPATH: return m_aHelpPath;
+ case PathSettingsData::PS_LINGUISTICPATH: return m_aLinguisticPath;
+ case PathSettingsData::PS_MODULEPATH: return m_aModulePath;
+ case PathSettingsData::PS_PALETTEPATH: return m_aPalettePath;
+ case PathSettingsData::PS_PLUGINPATH: return m_aPluginPath;
+ case PathSettingsData::PS_STORAGEPATH: return m_aStoragePath;
+ case PathSettingsData::PS_TEMPPATH: return m_aTempPath;
+ case PathSettingsData::PS_TEMPLATEPATH: return m_aTemplatePath;
+ case PathSettingsData::PS_USERCONFIGPATH: return m_aUserConfigPath;
+ case PathSettingsData::PS_USERDICTIONARYPATH: return m_aUserDictionaryPath;
+ case PathSettingsData::PS_WORKPATH: return m_aWorkPath;
+ case PathSettingsData::PS_UICONFIGPATH: return m_aUIConfigPath;
+
+ default:
+ DBG_ERRORFILE( "invalid index to load a path" );
+ return m_aEmptyStr;
+ }
+}
+
+
+PathSettings_Impl::PathSettings_Impl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xSMgr, const Link& aNotifyLink ) :
+ utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Path/Current" ))),
+ m_aListenerNotify( aNotifyLink ),
+ m_xFactory( xSMgr )
+{
+ m_xPathVariableSubstitution = Reference< XStringSubstitution >( m_xFactory->createInstance(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.PathSubstitution" ))), UNO_QUERY );
+
+ // Create a hash map to have a quick way to find the handle of a property name!
+ for ( sal_Int32 n = 0; n < PROPERTYCOUNT; n++ )
+ m_aPropNameToHandleMap.insert( PropToHandleHashMap::value_type(
+ rtl::OUString::createFromAscii( aPropNames[n] ), (PathSettingsData::PathSettingsId)n ) );
+}
+
+PathSettings_Impl::~PathSettings_Impl()
+{
+}
+
+int PathSettings_Impl::GetHandleFromPropertyName( const rtl::OUString& aPropertyName )
+{
+
+ PropToHandleHashMap::const_iterator pIter = m_aPropNameToHandleMap.find( aPropertyName );
+ if ( pIter != m_aPropNameToHandleMap.end() )
+ return pIter->second;
+ else
+ return -1;
+}
+
+sal_Bool PathSettings_Impl::ReadConfigurationData( PathSettingsData& rSettingsData, const Sequence< rtl::OUString >& aNames )
+{
+ Sequence< Any > aValues = GetProperties( aNames );
+ const rtl::OUString* pNames = aNames.getConstArray();
+ const Any* pValues = aValues.getConstArray();
+
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == aNames.getLength() )
+ {
+ rtl::OUString aTempStr, aFullPath;
+
+ for ( int n = 0; n < aNames.getLength(); n++ )
+ {
+ if ( pValues[n].hasValue() )
+ {
+ switch ( pValues[n].getValueTypeClass() )
+ {
+ case ::com::sun::star::uno::TypeClass_STRING :
+ {
+ // single pathes
+ if ( pValues[n] >>= aTempStr )
+ aFullPath = m_xPathVariableSubstitution->substituteVariables( aTempStr, sal_False );
+ else
+ {
+ DBG_ERRORFILE( "any operator >>= failed" );
+ }
+ break;
+ }
+
+ case ::com::sun::star::uno::TypeClass_SEQUENCE :
+ {
+ // multi pathes
+ aFullPath = rtl::OUString();
+ Sequence < rtl::OUString > aList;
+ if ( pValues[n] >>= aList )
+ {
+ sal_Int32 nCount = aList.getLength();
+ for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
+ {
+ aTempStr = m_xPathVariableSubstitution->substituteVariables( aList[ nPosition ], sal_False );
+ aFullPath += aTempStr;
+ if ( nPosition < nCount-1 )
+ aFullPath += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(";") );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "Unknown property name used!!" );
+ }
+ break;
+ }
+
+ default:
+ {
+ DBG_ERROR( "Unknown property name used!!" );
+ }
+ }
+
+ // Get property handle for the property name and set value
+ int nProp = GetHandleFromPropertyName( pNames[n] );
+ if ( nProp >= 0 )
+ rSettingsData.SetValue( (PathSettingsData::PathSettingsId)nProp, aFullPath );
+ else
+ DBG_ERROR( "Unknown property name used!!" );
+ }
+ }
+ }
+
+ return sal_True;
+}
+
+sal_Bool PathSettings_Impl::WriteConfigurationData( const PathSettingsData& rSettingsData, const Sequence< rtl::OUString >& aNames )
+{
+ rtl::OUString aTempStr;
+ const rtl::OUString* pNames = aNames.getConstArray();
+ Sequence< Any > aValues( aNames.getLength() );
+ Any* pValues = aValues.getArray();
+ const Type& rType = ::getBooleanCppuType();
+
+ for ( int n = 0; n < aNames.getLength(); n++ )
+ {
+ sal_Bool bList = sal_False;
+
+ // Get property handle for the property name
+ int nProp = GetHandleFromPropertyName( pNames[n] );
+ if ( nProp >= 0 )
+ {
+ switch ( nProp )
+ {
+ // multi pathes
+ case PathSettingsData::PS_AUTOCORRECTPATH:
+ case PathSettingsData::PS_AUTOTEXTPATH:
+ case PathSettingsData::PS_BASICPATH:
+ case PathSettingsData::PS_GALLERYPATH:
+ case PathSettingsData::PS_PLUGINPATH:
+ case PathSettingsData::PS_TEMPLATEPATH:
+ case PathSettingsData::PS_UICONFIGPATH:
+ bList = sal_True;
+ }
+
+ aTempStr = rSettingsData.GetValue( (PathSettingsData::PathSettingsId)nProp );
+
+ if ( bList )
+ {
+ String aFullPath( aTempStr );
+ USHORT nCount = aFullPath.GetTokenCount(), nIdx = 0;
+ if ( nCount > 0 )
+ {
+ sal_Int32 nPos = 0;
+ Sequence < rtl::OUString > aList( nCount );
+ while ( STRING_NOTFOUND != nIdx )
+ aList[nPos++] = m_xPathVariableSubstitution->reSubstituteVariables( aFullPath.GetToken( 0, ';', nIdx ) );
+ pValues[n] <<= aList;
+ }
+ }
+ else
+ {
+ pValues[n] <<= m_xPathVariableSubstitution->reSubstituteVariables( aTempStr );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "Unknown property name used!!" );
+ return sal_False;
+ }
+ }
+
+ PutProperties( aNames, aValues );
+ return sal_True;
+}
+
+sal_Bool PathSettings_Impl::CheckPath( PathSettingsData::PathSettingsId nId, const rtl::OUString& aNewPathValue )
+{
+ // Check the new path value
+ sal_Bool bList = sal_False;
+ sal_Bool bValueOk = sal_False;
+
+ switch ( nId )
+ {
+ // multi pathes
+ case PathSettingsData::PS_AUTOCORRECTPATH:
+ case PathSettingsData::PS_AUTOTEXTPATH:
+ case PathSettingsData::PS_BASICPATH:
+ case PathSettingsData::PS_GALLERYPATH:
+ case PathSettingsData::PS_PLUGINPATH:
+ case PathSettingsData::PS_TEMPLATEPATH:
+ case PathSettingsData::PS_UICONFIGPATH:
+ bList = sal_True;
+ }
+
+ if ( bList )
+ {
+ String aFullPath( aNewPathValue );
+ USHORT nCount = aFullPath.GetTokenCount(), nIdx = 0;
+ if ( nCount > 0 )
+ {
+ bValueOk = sal_True;
+ while ( STRING_NOTFOUND != nIdx && bValueOk )
+ bValueOk = !( INetURLObject( aFullPath.GetToken( 0, ';', nIdx ) ).HasError() );
+ }
+ }
+ else
+ bValueOk = !( INetURLObject( aNewPathValue ).HasError() );
+
+ return bValueOk;
+}
+
+// Checks if we have a valid URL otherwise it tries to substitute the value to support variables setting for a path setting!
+sal_Bool PathSettings_Impl::CheckAndReplaceNewPathValue( PathSettingsData::PathSettingsId nId, rtl::OUString& aNewPathValue )
+{
+ sal_Bool bValueOk = CheckPath( nId, aNewPathValue );
+
+ if ( !bValueOk )
+ {
+ rtl::OUString aResult;
+
+ // Support the usage of path variables set through setPropertyValue
+ try
+ {
+ aResult = m_xPathVariableSubstitution->substituteVariables( aNewPathValue, sal_True );
+ }
+ catch( com::sun::star::container::NoSuchElementException& )
+ {
+ // Substitution doesn't work => don't try further and give up
+ bValueOk = sal_False;
+ }
+
+ if ( bValueOk )
+ {
+ bValueOk = CheckPath( nId, aResult );
+ if ( bValueOk )
+ aNewPathValue = aResult;
+ }
+ }
+
+ return bValueOk;
+}
+
+void PathSettings_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames )
+{
+ if ( m_aListenerNotify.IsSet() )
+ m_aListenerNotify.Call( this );
+}
+
+
+//_________________________________________________________________________________________________________________
+// Implementation service class
+//_________________________________________________________________________________________________________________
+//
+
+DEFINE_XINTERFACE_5 ( PathSettings ,
+ OWeakObject ,
+ DIRECT_INTERFACE( css::lang::XTypeProvider ),
+ DIRECT_INTERFACE( css::lang::XServiceInfo ),
+ DIRECT_INTERFACE( css::beans::XPropertySet ),
+ DIRECT_INTERFACE( css::beans::XFastPropertySet ),
+ DIRECT_INTERFACE( css::beans::XMultiPropertySet )
+ )
+
+DEFINE_XTYPEPROVIDER_5 ( PathSettings ,
+ css::lang::XTypeProvider ,
+ css::lang::XServiceInfo ,
+ css::beans::XPropertySet ,
+ css::beans::XFastPropertySet ,
+ css::beans::XMultiPropertySet
+ )
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( PathSettings ,
+ ::cppu::OWeakObject ,
+ SERVICENAME_PATHSETTINGS ,
+ IMPLEMENTATIONNAME_PATHSETTINGS
+ )
+
+DEFINE_INIT_SERVICE ( PathSettings,
+ {
+ /*Attention
+ I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
+ to create a new instance of this class by our own supported service factory.
+ see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
+ */
+ }
+ )
+
+/*-************************************************************************************************************//**
+ @short standard constructor to create instance by factory
+ @descr This constructor initialize a new instance of this class by valid factory,
+ and will be set valid values on his member and baseclasses.
+
+ @attention a) Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you
+ will get over this. (e.g. using of your reference as parameter to initialize some member)
+ Do such things in DEFINE_INIT_SERVICE() method, which is called automaticly after your ctor!!!
+ b) Baseclass OBroadcastHelper is a typedef in namespace cppu!
+ The microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper.
+ If we write it without a namespace or expand the typedef to OBrodcastHelperVar<...> -> it will be OK!?
+ I don't know why! (other compiler not tested .. but it works!)
+
+ @seealso method DEFINE_INIT_SERVICE()
+
+ @param "xFactory" is the multi service manager, which create this instance.
+ The value must be different from NULL!
+ @return -
+
+ @onerror We throw an ASSERT in debug version or do nothing in relaese version.
+*//*-*************************************************************************************************************/
+PathSettings::PathSettings( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
+ // Init baseclasses first
+ // Attention: Don't change order of initialization!
+ // ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member!
+ // We must garant right initialization and a valid value of this to initialize other baseclasses!
+ : ThreadHelpBase ( )
+ , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType > ( m_aLock.getShareableOslMutex() )
+ , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
+ , ::cppu::OWeakObject ( )
+ // Init member
+ , m_xFactory ( xFactory )
+ , m_aImpl ( xFactory, LINK( this, PathSettings, implts_ConfigurationNotify ) )
+{
+ // Read initialy the configuration data
+ m_aImpl.ReadConfigurationData( m_aPathSettingsData, GetPathPropertyNames() );
+}
+
+
+/*-************************************************************************************************************//**
+ @short standard destructor
+ @descr This one do NOTHING! Use dispose() instaed of this.
+
+ @seealso method dispose()
+
+ @param -
+ @return -
+
+ @onerror -
+*//*-*************************************************************************************************************/
+PathSettings::~PathSettings()
+{
+}
+
+/*-************************************************************************************************************//**
+ @short try to convert a property value
+ @descr This method is called from helperclass "OPropertySetHelper".
+ Don't use this directly!
+ You must try to convert the value of given propertyhandle and
+ return results of this operation. This will be used to ask vetoable
+ listener. If no listener has a veto, we will change value realy!
+ ( in method setFastPropertyValue_NoBroadcast(...) )
+
+ @attention Methods of OPropertySethelper are safed by using our shared osl mutex! (see ctor!)
+ So we must use different locks to make our implementation threadsafe.
+
+ @seealso class OPropertySetHelper
+ @seealso method setFastPropertyValue_NoBroadcast()
+ @seealso method impl_tryToChangeProperty()
+
+ @param "aConvertedValue" new converted value of property
+ @param "aOldValue" old value of property
+ @param "nHandle" handle of property
+ @param "aValue" new value of property
+ @return sal_True if value will be changed, sal_FALSE otherway
+
+ @onerror IllegalArgumentException, if you call this with an invalid argument
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+sal_Bool SAL_CALL PathSettings::convertFastPropertyValue( css::uno::Any& aConvertedValue ,
+ css::uno::Any& aOldValue ,
+ sal_Int32 nHandle ,
+ const css::uno::Any& aValue ) throw( css::lang::IllegalArgumentException )
+{
+ // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException for us !!!
+
+ // Initialize state with FALSE !!!
+ // (Handle can be invalid)
+ sal_Bool bReturn = sal_False;
+
+ switch( nHandle )
+ {
+ case PROPERTYHANDLE_ADDIN : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aAddinPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_AUTOCORRECT : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aAutoCorrectPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_AUTOTEXT : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aAutoTextPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_BACKUP : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aBackupPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_BASIC : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aBasicPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_BITMAP : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aBitmapPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_CONFIG : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aConfigPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_DICTIONARY : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aDictionaryPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_FAVORITES : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aFavoritesPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_FILTER : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aFilterPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_GALLERY : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aGalleryPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_GRAPHIC : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aGraphicPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_HELP : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aHelpPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_LINGUISTIC : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aLinguisticPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_MODULE : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aModulePath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_PALETTE : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aPalettePath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_PLUGIN : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aPluginPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_STORAGE : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aStoragePath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_TEMP : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aTempPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_TEMPLATE : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aTemplatePath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_UICONFIG : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aUIConfigPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_USERCONFIG : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aUserConfigPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_USERDICTIONARY: bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aUserDictionaryPath, aValue, aOldValue, aConvertedValue );
+ break;
+ case PROPERTYHANDLE_WORK : bReturn = impl_tryToChangeProperty( m_aPathSettingsData.m_aWorkPath, aValue, aOldValue, aConvertedValue );
+ break;
+ }
+
+ // Return state of operation.
+ return bReturn ;
+}
+
+/*-************************************************************************************************************//**
+ @short set value of a bound property
+ @descr This method is calling from helperclass "OPropertySetHelper".
+ Don't use this directly!
+ Handle and value are valid everyway! You must set the new value only.
+ After this, baseclass send messages to all listener automaticly.
+
+ @seealso class OPropertySetHelper
+
+ @param "nHandle" handle of property to change
+ @param "aValue" new value of property
+ @return -
+
+ @onerror An exception is thrown.
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+void SAL_CALL PathSettings::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
+ const css::uno::Any& aValue )
+throw( css::uno::Exception )
+{
+ sal_Bool bValueValid = sal_False;
+ rtl::OUString aPropertyName;
+ rtl::OUString aNewValue;
+
+ // Check value before setting it
+ aValue >>= aNewValue;
+ if ( !m_aImpl.CheckAndReplaceNewPathValue( (PathSettingsData::PathSettingsId)nHandle, aNewValue ))
+ {
+ rtl::OUString aInvalidURL( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "This is not a valid file URL: " )));
+ aInvalidURL += aNewValue;
+ throw css::lang::IllegalArgumentException( aInvalidURL, (cppu::OWeakObject *)this, 0 );
+ }
+
+ switch( nHandle )
+ {
+ case PROPERTYHANDLE_ADDIN : m_aPathSettingsData.m_aAddinPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_ADDIN] );
+ break;
+ case PROPERTYHANDLE_AUTOCORRECT : m_aPathSettingsData.m_aAutoCorrectPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_AUTOCORRECT] );
+ break;
+ case PROPERTYHANDLE_AUTOTEXT : m_aPathSettingsData.m_aAutoTextPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_AUTOTEXT] );
+ break;
+ case PROPERTYHANDLE_BACKUP : m_aPathSettingsData.m_aBackupPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_BACKUP] );
+ break;
+ case PROPERTYHANDLE_BASIC : m_aPathSettingsData.m_aBasicPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_BASIC] );
+ break;
+ case PROPERTYHANDLE_BITMAP : m_aPathSettingsData.m_aBitmapPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_BITMAP] );
+ break;
+ case PROPERTYHANDLE_CONFIG : m_aPathSettingsData.m_aConfigPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_CONFIG] );
+ break;
+ case PROPERTYHANDLE_DICTIONARY : m_aPathSettingsData.m_aDictionaryPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_DICTIONARY] );
+ break;
+ case PROPERTYHANDLE_FAVORITES : m_aPathSettingsData.m_aFavoritesPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_FAVORITES] );
+ break;
+ case PROPERTYHANDLE_FILTER : m_aPathSettingsData.m_aFilterPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_FILTER] );
+ break;
+ case PROPERTYHANDLE_GALLERY : m_aPathSettingsData.m_aGalleryPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_GALLERY] );
+ break;
+ case PROPERTYHANDLE_GRAPHIC : m_aPathSettingsData.m_aGraphicPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_GRAPHIC] );
+ break;
+ case PROPERTYHANDLE_HELP : m_aPathSettingsData.m_aHelpPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_HELP] );
+ break;
+ case PROPERTYHANDLE_LINGUISTIC : m_aPathSettingsData.m_aLinguisticPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_LINGUISTIC] );
+ break;
+ case PROPERTYHANDLE_MODULE : m_aPathSettingsData.m_aModulePath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_MODULE] );
+ break;
+ case PROPERTYHANDLE_PALETTE : m_aPathSettingsData.m_aPalettePath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_PALETTE] );
+ break;
+ case PROPERTYHANDLE_PLUGIN : m_aPathSettingsData.m_aPluginPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_PLUGIN] );
+ break;
+ case PROPERTYHANDLE_STORAGE : m_aPathSettingsData.m_aStoragePath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_STORAGE] );
+ break;
+ case PROPERTYHANDLE_TEMP : m_aPathSettingsData.m_aTempPath = aNewValue;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_TEMP] );
+ break;
+ case PROPERTYHANDLE_TEMPLATE : aValue >>= m_aPathSettingsData.m_aTemplatePath;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_TEMPLATE] );
+ break;
+ case PROPERTYHANDLE_UICONFIG : aValue >>= m_aPathSettingsData.m_aUIConfigPath;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_UICONFIG] );
+ break;
+ case PROPERTYHANDLE_USERCONFIG : aValue >>= m_aPathSettingsData.m_aUserConfigPath;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_USERCONFIG] );
+ break;
+ case PROPERTYHANDLE_USERDICTIONARY: aValue >>= m_aPathSettingsData.m_aUserDictionaryPath;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_USERDICTIONARY] );
+ break;
+ case PROPERTYHANDLE_WORK : aValue >>= m_aPathSettingsData.m_aWorkPath;
+ aPropertyName = rtl::OUString::createFromAscii( aPropNames[PROPERTYHANDLE_WORK] );
+ break;
+ }
+
+ Sequence< rtl::OUString > aProperties( 1 );
+ aProperties[0] = aPropertyName;
+ m_aImpl.WriteConfigurationData( m_aPathSettingsData, aProperties );
+}
+
+/*-************************************************************************************************************//**
+ @short get value of a bound property
+ @descr This method is calling from helperclass "OPropertySetHelper".
+ Don't use this directly!
+
+ @attention We don't need any mutex or lock here ... We use threadsafe container or methods here only!
+
+ @seealso class OPropertySetHelper
+
+ @param "nHandle" handle of property to change
+ @param "aValue" current value of property
+ @return -
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+void SAL_CALL PathSettings::getFastPropertyValue( css::uno::Any& aValue ,
+ sal_Int32 nHandle ) const
+{
+ switch( nHandle )
+ {
+ case PROPERTYHANDLE_ADDIN : aValue <<= m_aPathSettingsData.m_aAddinPath;
+ break;
+ case PROPERTYHANDLE_AUTOCORRECT : aValue <<= m_aPathSettingsData.m_aAutoCorrectPath;
+ break;
+ case PROPERTYHANDLE_AUTOTEXT : aValue <<= m_aPathSettingsData.m_aAutoTextPath;
+ break;
+ case PROPERTYHANDLE_BACKUP : aValue <<= m_aPathSettingsData.m_aBackupPath;
+ break;
+ case PROPERTYHANDLE_BASIC : aValue <<= m_aPathSettingsData.m_aBasicPath;
+ break;
+ case PROPERTYHANDLE_BITMAP : aValue <<= m_aPathSettingsData.m_aBitmapPath;
+ break;
+ case PROPERTYHANDLE_CONFIG : aValue <<= m_aPathSettingsData.m_aConfigPath;
+ break;
+ case PROPERTYHANDLE_DICTIONARY : aValue <<= m_aPathSettingsData.m_aDictionaryPath;
+ break;
+ case PROPERTYHANDLE_FAVORITES : aValue <<= m_aPathSettingsData.m_aFavoritesPath;
+ break;
+ case PROPERTYHANDLE_FILTER : aValue <<= m_aPathSettingsData.m_aFilterPath;
+ break;
+ case PROPERTYHANDLE_GALLERY : aValue <<= m_aPathSettingsData.m_aGalleryPath;
+ break;
+ case PROPERTYHANDLE_GRAPHIC : aValue <<= m_aPathSettingsData.m_aGraphicPath;
+ break;
+ case PROPERTYHANDLE_HELP : aValue <<= m_aPathSettingsData.m_aHelpPath;
+ break;
+ case PROPERTYHANDLE_LINGUISTIC : aValue <<= m_aPathSettingsData.m_aLinguisticPath;
+ break;
+ case PROPERTYHANDLE_MODULE : aValue <<= m_aPathSettingsData.m_aModulePath;
+ break;
+ case PROPERTYHANDLE_PALETTE : aValue <<= m_aPathSettingsData.m_aPalettePath;
+ break;
+ case PROPERTYHANDLE_PLUGIN : aValue <<= m_aPathSettingsData.m_aPluginPath;
+ break;
+ case PROPERTYHANDLE_STORAGE : aValue <<= m_aPathSettingsData.m_aStoragePath;
+ break;
+ case PROPERTYHANDLE_TEMP : aValue <<= m_aPathSettingsData.m_aTempPath;
+ break;
+ case PROPERTYHANDLE_TEMPLATE : aValue <<= m_aPathSettingsData.m_aTemplatePath;
+ break;
+ case PROPERTYHANDLE_UICONFIG : aValue <<= m_aPathSettingsData.m_aUIConfigPath;
+ break;
+ case PROPERTYHANDLE_USERCONFIG : aValue <<= m_aPathSettingsData.m_aUserConfigPath;
+ break;
+ case PROPERTYHANDLE_USERDICTIONARY: aValue <<= m_aPathSettingsData.m_aUserDictionaryPath;
+ break;
+ case PROPERTYHANDLE_WORK : aValue <<= m_aPathSettingsData.m_aWorkPath;
+ break;
+ }
+}
+
+/*-************************************************************************************************************//**
+ @short test, if a property will change his value
+ @descr These methods will test, if a property will change his current value, with given parameter.
+ We use a helperclass for properties. These class promote this behaviour.
+ We implement a helper function for every property-type!
+
+ @seealso method convertFastPropertyValue()
+
+ @param "...Property" , the property with his current value
+ @param "aNewValue" , new value for property
+ @param "aOldValue" , old value of property as Any for convertFastPropertyValue
+ @param "aConvertedValue" , new value of property as Any for convertFastPropertyValue(it can be the old one, if nothing is changed!)
+ @return sal_True ,if value will be changed
+ @return sal_FALSE ,otherwise.
+
+ @onerror IllegalArgumentException, if convert failed.
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+sal_Bool PathSettings::impl_tryToChangeProperty( rtl::OUString sCurrentValue ,
+ const css::uno::Any& aNewValue ,
+ css::uno::Any& aOldValue ,
+ css::uno::Any& aConvertedValue )
+throw( css::lang::IllegalArgumentException )
+{
+ // Set default return value if method failed.
+ sal_Bool bReturn = sal_False;
+ // Get new value from any.
+ // IllegalArgumentException() can be thrown!
+ rtl::OUString sValue ;
+ cppu::convertPropertyValue( sValue, aNewValue );
+
+ // If value change ...
+ if( sValue != sCurrentValue )
+ {
+ // ... set information of change.
+ aOldValue <<= sCurrentValue ;
+ aConvertedValue <<= sValue ;
+ // Return OK - "value will be change ..."
+ bReturn = sal_True;
+ }
+ else
+ {
+ // ... clear information of return parameter!
+ aOldValue.clear () ;
+ aConvertedValue.clear () ;
+ // Return NOTHING - "value will not be change ..."
+ bReturn = sal_False;
+ }
+
+ return bReturn;
+}
+
+/*-************************************************************************************************************//**
+ @short return structure and information about bound properties
+ @descr This method is calling from helperclass "OPropertySetHelper".
+ Don't use this directly!
+
+ @attention You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
+ Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
+ So we could have two different mutex/lock mechanism at the same object.
+
+ @seealso class OPropertySetHelper
+
+ @param -
+ @return structure with property-informations
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+::cppu::IPropertyArrayHelper& SAL_CALL PathSettings::getInfoHelper()
+{
+ // Optimize this method !
+ // We initialize a static variable only one time. And we don't must use a mutex at every call!
+ // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
+ static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
+
+ if( pInfoHelper == NULL )
+ {
+ // Ready for multithreading
+ ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ // Control this pointer again, another instance can be faster then these!
+ if( pInfoHelper == NULL )
+ {
+ // Define static member to give structure of properties to baseclass "OPropertySetHelper".
+ // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
+ // "sal_True" say: Table is sorted by name.
+ static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
+ pInfoHelper = &aInfoHelper;
+ }
+ }
+
+ return(*pInfoHelper);
+}
+
+/*-************************************************************************************************************//**
+ @short return propertysetinfo
+ @descr You can call this method to get information about transient properties
+ of this object.
+
+ @attention You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
+ Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
+ So we could have two different mutex/lock mechanism at the same object.
+
+ @seealso class OPropertySetHelper
+ @seealso interface XPropertySet
+ @seealso interface XMultiPropertySet
+
+ @param -
+ @return reference to object with information [XPropertySetInfo]
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL PathSettings::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
+{
+ // Optimize this method !
+ // We initialize a static variable only one time. And we don't must use a mutex at every call!
+ // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
+ static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL;
+
+ if( pInfo == NULL )
+ {
+ // Ready for multithreading
+ ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ // Control this pointer again, another instance can be faster then these!
+ if( pInfo == NULL )
+ {
+ // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
+ // (Use method "getInfoHelper()".)
+ static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ pInfo = &xInfo;
+ }
+ }
+
+ return (*pInfo);
+}
+
+/*-************************************************************************************************************//**
+ @short create table with information about properties
+ @descr We use a helper class to support properties. These class need some information about this.
+ These method create a new static description table with name, type, r/w-flags and so on ...
+
+ @seealso class OPropertySetHelper
+ @seealso method getInfoHelper()
+
+ @param -
+ @return Static table with information about properties.
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+const css::uno::Sequence< css::beans::Property > PathSettings::impl_getStaticPropertyDescriptor()
+{
+ // Create a new static property array to initialize sequence!
+ // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
+ // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
+ // It's necessary for methods of OPropertySetHelper.
+ // ATTENTION:
+ // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
+ static const css::beans::Property pProperties[] =
+ {
+ css::beans::Property( PROPERTYNAME_ADDIN , PROPERTYHANDLE_ADDIN , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_AUTOCORRECT , PROPERTYHANDLE_AUTOCORRECT , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_AUTOTEXT , PROPERTYHANDLE_AUTOTEXT , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_BACKUP , PROPERTYHANDLE_BACKUP , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_BASIC , PROPERTYHANDLE_BASIC , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_BITMAP , PROPERTYHANDLE_BITMAP , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_CONFIG , PROPERTYHANDLE_CONFIG , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_DICTIONARY , PROPERTYHANDLE_DICTIONARY , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_FAVORITES , PROPERTYHANDLE_FAVORITES , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_FILTER , PROPERTYHANDLE_FILTER , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_GALLERY , PROPERTYHANDLE_GALLERY , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_GRAPHIC , PROPERTYHANDLE_GRAPHIC , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_HELP , PROPERTYHANDLE_HELP , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_LINGUISTIC , PROPERTYHANDLE_LINGUISTIC , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_MODULE , PROPERTYHANDLE_MODULE , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_PALETTE , PROPERTYHANDLE_PALETTE , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_PLUGIN , PROPERTYHANDLE_PLUGIN , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_STORAGE , PROPERTYHANDLE_STORAGE , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_TEMP , PROPERTYHANDLE_TEMP , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_TEMPLATE , PROPERTYHANDLE_TEMPLATE , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_UICONFIG , PROPERTYHANDLE_UICONFIG , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_USERCONFIG , PROPERTYHANDLE_USERCONFIG , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_USERDICTIONARY , PROPERTYHANDLE_USERDICTIONARY , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND ),
+ css::beans::Property( PROPERTYNAME_WORK , PROPERTYHANDLE_WORK , ::getCppuType((rtl::OUString*)NULL), css::beans::PropertyAttribute::BOUND )
+ };
+
+ // Use it to initialize sequence!
+ static const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, PROPERTYCOUNT );
+ // Return static "PropertyDescriptor"
+ return lPropertyDescriptor;
+}
+
+IMPL_LINK( PathSettings, implts_ConfigurationNotify, PathSettingsNotify*, pPathSettingsNotify )
+{
+ if ( pPathSettingsNotify != NULL )
+ {
+ Sequence< ::rtl::OUString >& rSettingsChanged = pPathSettingsNotify->aPathSettingsChanged;
+ std::vector< int > aHandleVector( rSettingsChanged.getLength() );
+ PathSettingsData aNewPathSettings;
+
+ {
+ // Thread-safe reading from configuration
+ ResetableGuard aGuard( m_aLock );
+ m_aImpl.ReadConfigurationData( aNewPathSettings, rSettingsChanged );
+
+ const rtl::OUString* pNames = rSettingsChanged.getConstArray();
+ for ( sal_Int32 i = 0; i < rSettingsChanged.getLength(); i++ )
+ {
+ int nHandle = m_aImpl.GetHandleFromPropertyName( pNames[i] );
+ if ( nHandle >= 0 )
+ aHandleVector.push_back( nHandle );
+ }
+ }
+
+ // Set the values through our API implementation to have automically listener notifications
+ for ( sal_uInt32 i = 0; i < aHandleVector.size(); i++ )
+ {
+ Any aAny;
+ aAny <<= aNewPathSettings.GetValue( (PathSettingsData::PathSettingsId)aHandleVector[i] );
+ setPropertyValue( rtl::OUString::createFromAscii( aPropNames[ aHandleVector[i] ]), aAny );
+ }
+ }
+
+ return 0;
+}
+
+} // namespace framework
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
new file mode 100644
index 000000000000..841117f5594f
--- /dev/null
+++ b/framework/source/services/substitutepathvars.cxx
@@ -0,0 +1,1488 @@
+/*************************************************************************
+ *
+ * $RCSfile: substitutepathvars.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cd $ $Date: 2002-08-20 10:13:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+
+#ifndef __FRAMEWORK_SERVICES_SUBSTPATHVARS_HXX_
+#include "services/substitutepathvars.hxx"
+#endif
+
+#ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
+#include <threadhelp/resetableguard.hxx>
+#endif
+
+#ifndef __FRAMEWORK_HELPER_NETWORKDOMAIN_HXX_
+#include <helper/networkdomain.hxx>
+#endif
+
+#ifndef __FRAMEWORK_SERVICES_H_
+#include "services.h"
+#endif
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+//_________________________________________________________________________________________________________________
+// includes of other projects
+//_________________________________________________________________________________________________________________
+
+#ifndef _UTL_CONFIGITEM_HXX_
+#include <unotools/configitem.hxx>
+#endif
+
+#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
+#include <unotools/localfilehelper.hxx>
+#endif
+
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+
+#ifndef _UTL_BOOTSTRAP_HXX_
+#include <unotools/bootstrap.hxx>
+#endif
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+#ifndef _OSL_SECURITY_HXX_
+#include <osl/security.hxx>
+#endif
+
+#ifndef _OSL_SOCKET_HXX_
+#include <osl/socket.hxx>
+#endif
+
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#ifndef _ISOLANG_HXX
+#include <tools/isolang.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _TOOLS_RESMGR_HXX
+#include <tools/resmgr.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+//_________________________________________________________________________________________________________________
+// Defines
+//_________________________________________________________________________________________________________________
+//
+
+#define STRPOS_NOTFOUND (sal_Int32)-1
+
+#define ASCII_STR( val ) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( val ))
+
+#define SEARCHPATH_DELIMITER ';'
+
+// Variable start/end characters
+#define SIGN_STARTVARIABLE ASCII_STR("$(")
+#define SIGN_ENDVARIABLE ASCII_STR(")")
+
+// Strings to replace $(vlang)
+#define REPLACEMENT_ARABIC ASCII_STR("arabic")
+#define REPLACEMENT_CZECH ASCII_STR("czech")
+#define REPLACEMENT_DANISH ASCII_STR("danish")
+#define REPLACEMENT_DUTCH ASCII_STR("dutch")
+#define REPLACEMENT_ENGLISH ASCII_STR("english")
+#define REPLACEMENT_ENGLISH_UK ASCII_STR("english_uk")
+#define REPLACEMENT_FINNISH ASCII_STR("finnish")
+#define REPLACEMENT_FRENCH ASCII_STR("french")
+#define REPLACEMENT_GERMAN ASCII_STR("german")
+#define REPLACEMENT_GREEK ASCII_STR("greek")
+#define REPLACEMENT_HEBREW ASCII_STR("hebrew")
+#define REPLACEMENT_ITALIAN ASCII_STR("italian")
+#define REPLACEMENT_JAPANESE ASCII_STR("japanese")
+#define REPLACEMENT_KOREAN ASCII_STR("korean")
+#define REPLACEMENT_POLISH ASCII_STR("polish")
+#define REPLACEMENT_RUSSIAN ASCII_STR("russian")
+#define REPLACEMENT_SLOVAK ASCII_STR("slovak")
+#define REPLACEMENT_SPANISH ASCII_STR("spanish")
+#define REPLACEMENT_SWEDISH ASCII_STR("swedish")
+#define REPLACEMENT_TURKISH ASCII_STR("turkish")
+#define REPLACEMENT_NORWEGIAN ASCII_STR("norwegian")
+#define REPLACEMENT_HUNGARIAN ASCII_STR("hungarian")
+//#define REPLACEMENT_BULGARIAN ASCII_STR("bulgarian")
+#define REPLACEMENT_CHINESE_TRADITIONAL ASCII_STR("chinese_traditional")
+#define REPLACEMENT_CHINESE_SIMPLIFIED ASCII_STR("chinese_simplified")
+#define REPLACEMENT_PORTUGUESE ASCII_STR("portuguese")
+#define REPLACEMENT_PORTUGUESE_BRAZILIAN ASCII_STR("portuguese_brazilian")
+#define REPLACEMENT_THAI ASCII_STR("thai")
+#define REPLACEMENT_CATALAN ASCII_STR("catalan")
+
+// Length of SUBSTITUTE_... to replace it with real values.
+#define REPLACELENGTH_INST 7
+#define REPLACELENGTH_PROG 7
+#define REPLACELENGTH_USER 7
+#define REPLACELENGTH_WORK 7
+#define REPLACELENGTH_HOME 7
+#define REPLACELENGTH_TEMP 7
+#define REPLACELENGTH_INSTPATH 11
+#define REPLACELENGTH_PROGPATH 11
+#define REPLACELENGTH_USERPATH 11
+#define REPLACELENGTH_INSTURL 10
+#define REPLACELENGTH_PROGURL 10
+#define REPLACELENGTH_USERURL 10
+#define REPLACELENGTH_PATH 7
+#define REPLACELENGTH_LANG 7
+#define REPLACELENGTH_LANGID 9
+#define REPLACELENGTH_VLANG 8
+#define REPLACELENGTH_WORKDIRURL 13
+
+// Name of the pre defined path variables
+#define VARIABLE_INST "$(inst)"
+#define VARIABLE_PROG "$(prog)"
+#define VARIABLE_USER "$(user)"
+#define VARIABLE_WORK "$(work)"
+#define VARIABLE_HOME "$(home)"
+#define VARIABLE_TEMP "$(temp)"
+#define VARIABLE_PATH "$(path)"
+#define VARIABLE_LANG "$(lang)"
+#define VARIABLE_LANGID "$(langid)"
+#define VARIABLE_VLANG "$(vlang)"
+#define VARIABLE_INSTPATH "$(instpath)"
+#define VARIABLE_PROGPATH "$(progpath)"
+#define VARIABLE_USERPATH "$(userpath)"
+#define VARIABLE_INSTURL "$(insturl)"
+#define VARIABLE_PROGURL "$(progurl)"
+#define VARIABLE_USERURL "$(userurl)"
+#define VARIABLE_WORKDIRURL "$(workdirurl)"
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::util;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+
+//_________________________________________________________________________________________________________________
+// Namespace
+//_________________________________________________________________________________________________________________
+//
+
+namespace framework
+{
+
+struct FixedVariable
+{
+ const char* pVarName;
+ PreDefVariable nEnumValue;
+ int nStrLen;
+};
+
+struct TableEntry
+{
+ const char* pOSString;
+ int nStrLen;
+};
+
+// Table with valid operating system strings
+// Name of the os as char* and the length
+// of the string
+static TableEntry aOSTable[OS_COUNT] =
+{
+ { "WINDOWS" , 7 },
+ { "UNIX" , 4 },
+ { "SOLARIS" , 7 },
+ { "LINUX" , 5 },
+ { "" , 0 } // unknown
+};
+
+// Table with valid environment variables
+// Name of the environment type as a char* and
+// the length of the string.
+static TableEntry aEnvTable[ET_COUNT] =
+{
+ { "HOST" , 4 },
+ { "YPDOMAIN" , 8 },
+ { "DNSDOMAIN" , 9 },
+ { "NTDOMAIN" , 8 },
+ { "OS" , 2 },
+ { "" , 0 } // unknown
+};
+
+// Priority table for the environment types. Lower numbers define
+// a higher priority. Equal numbers has the same priority that means
+// that the first match wins!!
+static sal_Int16 aEnvPrioTable[ET_COUNT] =
+{
+ 1, // ET_HOST
+ 2, // ET_IPDOMAIN
+ 2, // ET_DNSDOMAIN
+ 2, // ET_NTDOMAIN
+ 3, // ET_OS
+ 99, // ET_UNKNOWN
+};
+
+// Table with all fixed/predefined variables supported.
+static FixedVariable aFixedVarTable[] =
+{
+ { VARIABLE_INST, PREDEFVAR_INST, REPLACELENGTH_INST },
+ { VARIABLE_PROG, PREDEFVAR_PROG, REPLACELENGTH_PROG },
+ { VARIABLE_USER, PREDEFVAR_USER, REPLACELENGTH_USER },
+ { VARIABLE_WORK, PREDEFVAR_WORK, REPLACELENGTH_WORK }, // Special variable (transient)!
+ { VARIABLE_HOME, PREDEFVAR_HOME, REPLACELENGTH_HOME },
+ { VARIABLE_TEMP, PREDEFVAR_TEMP, REPLACELENGTH_TEMP },
+ { VARIABLE_LANG, PREDEFVAR_LANG, REPLACELENGTH_LANG },
+ { VARIABLE_LANGID, PREDEFVAR_LANGID, REPLACELENGTH_LANGID },
+ { VARIABLE_VLANG, PREDEFVAR_VLANG, REPLACELENGTH_VLANG },
+ { VARIABLE_INSTPATH, PREDEFVAR_INSTPATH, REPLACELENGTH_INSTPATH },
+ { VARIABLE_PROGPATH, PREDEFVAR_PROGPATH, REPLACELENGTH_PROGPATH },
+ { VARIABLE_USERPATH, PREDEFVAR_USERPATH, REPLACELENGTH_USERPATH },
+ { VARIABLE_INSTURL, PREDEFVAR_INSTURL, REPLACELENGTH_INSTURL },
+ { VARIABLE_PROGURL, PREDEFVAR_PROGURL, REPLACELENGTH_PROGURL },
+ { VARIABLE_USERURL, PREDEFVAR_USERURL, REPLACELENGTH_USERURL },
+ { VARIABLE_WORKDIRURL, PREDEFVAR_WORKDIRURL, REPLACELENGTH_WORKDIRURL } // Special variable (transient) and don't use for resubstitution!
+};
+
+//_________________________________________________________________________________________________________________
+// Implementation helper classes
+//_________________________________________________________________________________________________________________
+//
+
+WorkPathHelper_Impl::WorkPathHelper_Impl() :
+ utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Path/Current" ))),
+ m_aPathNameSeq( 1 )
+{
+ m_aPathNameSeq[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Work" ));
+}
+
+rtl::OUString WorkPathHelper_Impl::GetWorkPath()
+{
+ rtl::OUString aWorkPath;
+ Sequence< Any > aValues = GetProperties( m_aPathNameSeq );
+
+ if ( aValues.getLength() == 1 && aValues[0].hasValue() )
+ aValues[0] >>= aWorkPath;
+
+ return aWorkPath;
+}
+
+
+OperatingSystem SubstitutePathVariables_Impl::GetOperatingSystemFromString( const rtl::OUString& aOSString )
+{
+ for ( int i = 0; i < OS_COUNT; i++ )
+ {
+ if ( aOSString.equalsIgnoreAsciiCaseAsciiL( aOSTable[i].pOSString, aOSTable[i].nStrLen ))
+ return (OperatingSystem)i;
+ }
+
+ return OS_UNKNOWN;
+}
+
+EnvironmentType SubstitutePathVariables_Impl::GetEnvTypeFromString( const rtl::OUString& aEnvTypeString )
+{
+ for ( int i = 0; i < ET_COUNT; i++ )
+ {
+ if ( aEnvTypeString.equalsIgnoreAsciiCaseAsciiL( aEnvTable[i].pOSString, aEnvTable[i].nStrLen ))
+ return (EnvironmentType)i;
+ }
+
+ return ET_UNKNOWN;
+}
+
+SubstitutePathVariables_Impl::SubstitutePathVariables_Impl( const Link& aNotifyLink ) :
+ utl::ConfigItem( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Substitution" ))),
+ m_aListenerNotify( aNotifyLink ),
+ m_aSharePointsNodeName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SharePoints" ))),
+ m_aDirPropertyName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/Directory" ))),
+ m_aEnvPropertyName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/Environment" ))),
+ m_aLevelSep( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ))),
+ m_bYPDomainRetrieved( sal_False ),
+ m_bDNSDomainRetrieved( sal_False ),
+ m_bNTDomainRetrieved( sal_False ),
+ m_bHostRetrieved( sal_False ),
+ m_bOSRetrieved( sal_False )
+{
+}
+
+SubstitutePathVariables_Impl::~SubstitutePathVariables_Impl()
+{
+}
+
+void SubstitutePathVariables_Impl::GetSharePointsRules( SubstituteVariables& aSubstVarMap )
+{
+ Sequence< rtl::OUString > aSharePointNames;
+ ReadSharePointsFromConfiguration( aSharePointNames );
+
+ if ( aSharePointNames.getLength() > 0 )
+ {
+ sal_Int32 nSharePoints = 0;
+
+ // Read SharePoints container from configuration
+ while ( nSharePoints < aSharePointNames.getLength() )
+ {
+ rtl::OUString aSharePointNodeName( m_aSharePointsNodeName );
+ aSharePointNodeName += rtl::OUString::createFromAscii( "/" );
+ aSharePointNodeName += aSharePointNames[ nSharePoints ];
+
+ SubstituteRuleVector aRuleSet;
+ ReadSharePointRuleSetFromConfiguration( aSharePointNames[ nSharePoints ], aSharePointNodeName, aRuleSet );
+ if ( aRuleSet.size() > 0 )
+ {
+ // We have at minimum one rule. Filter the correct rule out of the rule set
+ // and put into our SubstituteVariable map
+ SubstituteRule aActiveRule;
+ if ( FilterRuleSet( aRuleSet, aActiveRule ))
+ {
+ // We have found an active rule
+ aActiveRule.aSubstVariable = aSharePointNames[ nSharePoints ];
+ aSubstVarMap.insert( SubstituteVariables::value_type(
+ aActiveRule.aSubstVariable, aActiveRule ));
+ }
+ }
+
+ ++nSharePoints;
+ }
+ }
+}
+
+void SubstitutePathVariables_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames )
+{
+ // NOT implemented yet!
+}
+
+//_________________________________________________________________________________________________________________
+// private methods
+//_________________________________________________________________________________________________________________
+//
+
+OperatingSystem SubstitutePathVariables_Impl::GetOperatingSystem()
+{
+ if ( !m_bOSRetrieved )
+ {
+#ifdef SOLARIS
+ m_eOSType = OS_SOLARIS;
+#elif defined LINUX
+ m_eOSType = OS_LINUX;
+#elif defined WIN32
+ m_eOSType = OS_WINDOWS;
+#elif defined UNIX
+ m_eOSType = OS_UNIX;
+#else
+ m_eOSType = OS_UNKNOWN;
+#endif
+ m_bOSRetrieved = sal_True;
+ }
+
+ return m_eOSType;
+}
+
+const rtl::OUString& SubstitutePathVariables_Impl::GetYPDomainName()
+{
+ if ( !m_bYPDomainRetrieved )
+ {
+ m_aYPDomain = NetworkDomain::GetYPDomainName().toAsciiLowerCase();
+ m_bYPDomainRetrieved = sal_True;
+ }
+
+ return m_aYPDomain;
+}
+
+const rtl::OUString& SubstitutePathVariables_Impl::GetDNSDomainName()
+{
+ if ( !m_bDNSDomainRetrieved )
+ {
+ rtl::OUString aTemp;
+ osl::SocketAddr aSockAddr;
+ oslSocketResult aResult;
+
+ rtl::OUString aHostName = GetHostName();
+ osl::SocketAddr::resolveHostname( aHostName, aSockAddr );
+ aTemp = aSockAddr.getHostname( &aResult );
+
+ // DNS domain name begins after the first "."
+ sal_Int32 nIndex = aTemp.indexOf( '.' );
+ if ( nIndex >= 0 && aTemp.getLength() > nIndex+1 )
+ m_aDNSDomain = aTemp.copy( nIndex+1 ).toAsciiLowerCase();
+ else
+ m_aDNSDomain = rtl::OUString();
+
+ m_bDNSDomainRetrieved = sal_True;
+ }
+
+ return m_aDNSDomain;
+}
+
+const rtl::OUString& SubstitutePathVariables_Impl::GetNTDomainName()
+{
+ if ( !m_bNTDomainRetrieved )
+ {
+ m_aNTDomain = NetworkDomain::GetNTDomainName().toAsciiLowerCase();
+ m_bNTDomainRetrieved = sal_True;
+ }
+
+ return m_aNTDomain;
+}
+
+const rtl::OUString& SubstitutePathVariables_Impl::GetHostName()
+{
+ if ( !m_bHostRetrieved )
+ {
+ rtl::OUString aHostName;
+ oslSocketResult aSocketResult;
+
+ m_aHost = osl::SocketAddr::getLocalHostname( &aSocketResult ).toAsciiLowerCase();
+ }
+
+ return m_aHost;
+}
+
+sal_Bool SubstitutePathVariables_Impl::FilterRuleSet( const SubstituteRuleVector& aRuleSet, SubstituteRule& aActiveRule )
+{
+ sal_Bool bResult = sal_False;
+
+ if ( aRuleSet.size() >= 1 )
+ {
+ Wildcard aPatternMatch;
+ sal_Int16 nPrioCurrentRule = aEnvPrioTable[ ET_UNKNOWN ];
+ for ( sal_Int32 nIndex = 0; nIndex < (sal_Int32)aRuleSet.size(); nIndex++ )
+ {
+ const SubstituteRule& aRule = aRuleSet[nIndex];
+ EnvironmentType eEnvType = aRule.aEnvType;
+
+ // Check if environment type has a higher priority than current one!
+ if ( nPrioCurrentRule > aEnvPrioTable[eEnvType] )
+ {
+ switch ( eEnvType )
+ {
+ case ET_HOST:
+ {
+ rtl::OUString aHost = GetHostName();
+ rtl::OUString aHostStr;
+ aRule.aEnvValue >>= aHostStr;
+ aHostStr = aHostStr.toAsciiLowerCase();
+
+ // Pattern match if domain environment match
+ sal_Bool bMatch = aPatternMatch.match( aHost, aHostStr );
+ if ( bMatch )
+ {
+ aActiveRule = aRule;
+ bResult = sal_True;
+ nPrioCurrentRule = aEnvPrioTable[eEnvType];
+ }
+ }
+ break;
+
+ case ET_YPDOMAIN:
+ case ET_DNSDOMAIN:
+ case ET_NTDOMAIN:
+ {
+ rtl::OUString aDomain;
+ rtl::OUString aDomainStr;
+ aRule.aEnvValue >>= aDomainStr;
+ aDomainStr = aDomainStr.toAsciiLowerCase();
+
+ // Retrieve the correct domain value
+ if ( eEnvType == ET_YPDOMAIN )
+ aDomain = GetYPDomainName();
+ else if ( eEnvType == ET_DNSDOMAIN )
+ aDomain = GetDNSDomainName();
+ else
+ aDomain = GetNTDomainName();
+
+ // Pattern match if domain environment match
+ sal_Bool bMatch = aPatternMatch.match( aDomain, aDomainStr );
+ if ( bMatch )
+ {
+ aActiveRule = aRule;
+ bResult = sal_True;
+ nPrioCurrentRule = aEnvPrioTable[eEnvType];
+ }
+ }
+ break;
+
+ case ET_OS:
+ {
+ // No pattern matching for OS type
+ OperatingSystem eOSType = GetOperatingSystem();
+
+ sal_Int16 nValue;
+ aRule.aEnvValue >>= nValue;
+
+ sal_Bool bUnix = ( eOSType == OS_LINUX ) || ( eOSType == OS_SOLARIS );
+ OperatingSystem eRuleOSType = (OperatingSystem)nValue;
+
+ // Match if OS identical or rule is set to UNIX and OS is LINUX/SOLARIS!
+ if (( eRuleOSType == eOSType ) || ( eRuleOSType == OS_UNIX && bUnix ))
+ {
+ aActiveRule = aRule;
+ bResult = sal_True;
+ nPrioCurrentRule = aEnvPrioTable[eEnvType];
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return bResult;
+}
+
+void SubstitutePathVariables_Impl::ReadSharePointsFromConfiguration( Sequence< rtl::OUString >& aSharePointsSeq )
+{
+ //returns all the names of all share point nodes
+ aSharePointsSeq = GetNodeNames( m_aSharePointsNodeName );
+}
+
+void SubstitutePathVariables_Impl::ReadSharePointRuleSetFromConfiguration(
+ const rtl::OUString& aSharePointName,
+ const rtl::OUString& aSharePointNodeName,
+ SubstituteRuleVector& rRuleSet )
+{
+ Sequence< rtl::OUString > aSharePointMappingsNodeNames = GetNodeNames( aSharePointNodeName );
+
+ sal_Int32 nSharePointMapping = 0;
+ while ( nSharePointMapping < aSharePointMappingsNodeNames.getLength() )
+ {
+ rtl::OUString aSharePointMapping( aSharePointNodeName );
+ aSharePointMapping += m_aLevelSep;
+ aSharePointMapping += aSharePointMappingsNodeNames[ nSharePointMapping ];
+
+ // Read SharePointMapping
+ Sequence< rtl::OUString > aSharePointMappingNodeNames = GetNodeNames( aSharePointMapping );
+
+ rtl::OUString aDirValue;
+ rtl::OUString aDirProperty( aSharePointMapping );
+ aDirProperty += m_aDirPropertyName;
+
+ // Read only the directory property
+ Sequence< rtl::OUString > aDirPropertySeq( 1 );
+ aDirPropertySeq[0] = aDirProperty;
+
+ Sequence< Any > aValueSeq = GetProperties( aDirPropertySeq );
+ if ( aValueSeq.getLength() == 1 )
+ aValueSeq[0] >>= aDirValue;
+
+ // Read the environment setting
+ rtl::OUString aEnvUsed;
+ rtl::OUString aEnvProperty( aSharePointMapping );
+ aEnvProperty += m_aEnvPropertyName;
+ Sequence< rtl::OUString > aEnvironmentVariable = GetNodeNames( aEnvProperty );
+
+ // Filter the property which has a value set
+ Sequence< rtl::OUString > aEnvUsedPropertySeq( aEnvironmentVariable.getLength() );
+
+ rtl::OUString aEnvUsePropNameTemplate( aEnvProperty );
+ aEnvUsePropNameTemplate += m_aLevelSep;
+
+ for ( sal_Int32 nProperty = 0; nProperty < aEnvironmentVariable.getLength(); nProperty++ )
+ aEnvUsedPropertySeq[nProperty] = rtl::OUString( aEnvUsePropNameTemplate + aEnvironmentVariable[nProperty] );
+
+ Sequence< Any > aEnvUsedValueSeq;
+ aEnvUsedValueSeq = GetProperties( aEnvUsedPropertySeq );
+
+ rtl::OUString aEnvUsedValue;
+ for ( sal_Int32 nIndex = 0; nIndex < aEnvironmentVariable.getLength(); nIndex++ )
+ {
+ if ( aEnvUsedValueSeq[nIndex] >>= aEnvUsedValue )
+ {
+ aEnvUsed = aEnvironmentVariable[nIndex];
+ break;
+ }
+ }
+
+ // Decode the environment and optional the operatng system settings
+ Any aEnvValue;
+ EnvironmentType eEnvType = GetEnvTypeFromString( aEnvUsed );
+ if ( eEnvType == ET_OS )
+ {
+ OperatingSystem eOSType = GetOperatingSystemFromString( aEnvUsedValue );
+ aEnvValue <<= (sal_Int16)eOSType;
+ }
+ else
+ aEnvValue <<= aEnvUsedValue;
+
+ // Create rule struct and push it into the rule set
+ SubstituteRule aRule( aSharePointName, aDirValue, aEnvValue, eEnvType );
+ rRuleSet.push_back( aRule );
+
+ ++nSharePointMapping;
+ }
+}
+
+//*****************************************************************************************************************
+// XInterface, XTypeProvider, XServiceInfo
+//*****************************************************************************************************************
+DEFINE_XINTERFACE_3 ( SubstitutePathVariables ,
+ OWeakObject ,
+ DIRECT_INTERFACE( css::lang::XTypeProvider ),
+ DIRECT_INTERFACE( css::lang::XServiceInfo ),
+ DIRECT_INTERFACE( css::util::XStringSubstitution )
+ )
+
+DEFINE_XTYPEPROVIDER_3 ( SubstitutePathVariables ,
+ css::lang::XTypeProvider ,
+ css::lang::XServiceInfo ,
+ css::util::XStringSubstitution
+ )
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( SubstitutePathVariables ,
+ ::cppu::OWeakObject ,
+ SERVICENAME_SUBSTITUTEPATHVARIABLES ,
+ IMPLEMENTATIONNAME_SUBSTITUTEPATHVARIABLES
+ )
+
+DEFINE_INIT_SERVICE ( SubstitutePathVariables, {} )
+
+
+SubstitutePathVariables::SubstitutePathVariables( const Reference< XMultiServiceFactory >& xServiceManager ) :
+ ThreadHelpBase(),
+ m_aImpl( LINK( this, SubstitutePathVariables, implts_ConfigurationNotify )),
+ m_aVarStart( SIGN_STARTVARIABLE ),
+ m_aVarEnd( SIGN_ENDVARIABLE ),
+ m_xServiceManager( xServiceManager )
+{
+ SetPredefinedPathVariables( m_aPreDefVars );
+ m_aImpl.GetSharePointsRules( m_aSubstVarMap );
+
+ // Init the predefined/fixed variable to index hash map
+ for ( int i = 0; i < PREDEFVAR_COUNT; i++ )
+ {
+ // Store variable name into struct of predefined/fixed variables
+ m_aPreDefVars.m_FixedVarNames[i] = rtl::OUString::createFromAscii( aFixedVarTable[i].pVarName );
+
+ // Create hash map entry
+ m_aPreDefVarMap.insert( VarNameToIndexMap::value_type(
+ m_aPreDefVars.m_FixedVarNames[i], aFixedVarTable[i].nEnumValue ) );
+ }
+
+ // Sort predefined/fixed variable to path length
+ for ( i = 0; i < PREDEFVAR_COUNT; i++ )
+ {
+ if ( i != PREDEFVAR_WORKDIRURL )
+ {
+ // Special path variables, don't include into automatic resubstituion search!
+ // $(workdirurl) is not allowed to resubstitute! This variable is the value of path settings entry
+ // and it could be possible that it will be resubstituted by itself!!
+ // Example: WORK_PATH=c:\test, $(workdirurl)=WORK_PATH => WORK_PATH=$(workdirurl) and this cannot be substituted!
+ ReSubstFixedVarOrder aFixedVar;
+ aFixedVar.eVariable = aFixedVarTable[i].nEnumValue;
+ aFixedVar.nVarValueLength = m_aPreDefVars.m_FixedVar[(sal_Int32)aFixedVar.eVariable].getLength();
+ m_aReSubstFixedVarOrder.push_back( aFixedVar );
+ }
+ }
+ m_aReSubstFixedVarOrder.sort();
+
+ // Sort user variables to path length
+ SubstituteVariables::const_iterator pIter;
+ for ( pIter = m_aSubstVarMap.begin(); pIter != m_aSubstVarMap.end(); pIter++ )
+ {
+ ReSubstUserVarOrder aUserOrderVar;
+ rtl::OUStringBuffer aStrBuffer( pIter->second.aSubstVariable.getLength() );
+ aStrBuffer.append( m_aVarStart );
+ aStrBuffer.append( pIter->second.aSubstVariable );
+ aStrBuffer.append( m_aVarEnd );
+ aUserOrderVar.aVarName = aStrBuffer.makeStringAndClear();
+ aUserOrderVar.nVarValueLength = pIter->second.aSubstVariable.getLength();
+ m_aReSubstUserVarOrder.push_back( aUserOrderVar );
+ }
+ m_aReSubstUserVarOrder.sort();
+}
+
+SubstitutePathVariables::~SubstitutePathVariables()
+{
+}
+
+// XStringSubstitution
+rtl::OUString SAL_CALL SubstitutePathVariables::substituteVariables( const ::rtl::OUString& aText, sal_Bool bSubstRequired )
+throw ( NoSuchElementException, RuntimeException )
+{
+ ResetableGuard aLock( m_aLock );
+ return impl_substituteVariable( aText, bSubstRequired );
+}
+
+rtl::OUString SAL_CALL SubstitutePathVariables::reSubstituteVariables( const ::rtl::OUString& aText )
+throw ( RuntimeException )
+{
+ ResetableGuard aLock( m_aLock );
+ return impl_reSubstituteVariables( aText );
+}
+
+rtl::OUString SAL_CALL SubstitutePathVariables::getSubstituteVariableValue( const ::rtl::OUString& aVariable )
+throw ( NoSuchElementException, RuntimeException )
+{
+ ResetableGuard aLock( m_aLock );
+ return impl_getSubstituteVariableValue( aVariable );
+}
+
+//_________________________________________________________________________________________________________________
+// protected methods
+//_________________________________________________________________________________________________________________
+//
+
+IMPL_LINK( SubstitutePathVariables, implts_ConfigurationNotify, SubstitutePathNotify*, pSubstVarNotify )
+{
+ /* SAFE AREA ----------------------------------------------------------------------------------------------- */
+ ResetableGuard aLock( m_aLock );
+
+ return 0;
+}
+
+rtl::OUString SubstitutePathVariables::ConvertOSLtoUCBURL( const rtl::OUString& aOSLCompliantURL ) const
+{
+ String aResult;
+ rtl::OUString aTemp;
+
+ osl::FileBase::getSystemPathFromFileURL( aOSLCompliantURL, aTemp );
+ utl::LocalFileHelper::ConvertPhysicalNameToURL( aTemp, aResult );
+
+ // Not all OSL URL's can be mapped to UCB URL's!
+ if ( aResult.Len() == 0 )
+ return aOSLCompliantURL;
+ else
+ return rtl::OUString( aResult );
+}
+
+rtl::OUString SubstitutePathVariables::GetWorkVariableValue() const
+{
+ osl::Security aSecurity;
+ rtl::OUString aHomePath;
+
+ aSecurity.getHomeDir( aHomePath );
+ return ConvertOSLtoUCBURL( aHomePath );
+}
+
+rtl::OUString SubstitutePathVariables::GetHomeVariableValue() const
+{
+ osl::Security aSecurity;
+ rtl::OUString aConfigPath;
+ aSecurity.getConfigDir( aConfigPath );
+ return ConvertOSLtoUCBURL( aConfigPath );
+}
+
+rtl::OUString SubstitutePathVariables::GetPathVariableValue() const
+{
+ return rtl::OUString::createFromAscii( getenv( "path" ) );
+}
+
+rtl::OUString SubstitutePathVariables::GetLanguageString( LanguageType aLanguageType ) const
+{
+ rtl::OUString aLangStr;
+
+ switch ( aLanguageType )
+ {
+ case LANGUAGE_ARABIC :
+ case LANGUAGE_ARABIC_IRAQ :
+ case LANGUAGE_ARABIC_EGYPT :
+ case LANGUAGE_ARABIC_LIBYA :
+ case LANGUAGE_ARABIC_ALGERIA :
+ case LANGUAGE_ARABIC_MOROCCO :
+ case LANGUAGE_ARABIC_TUNISIA :
+ case LANGUAGE_ARABIC_OMAN :
+ case LANGUAGE_ARABIC_YEMEN :
+ case LANGUAGE_ARABIC_SYRIA :
+ case LANGUAGE_ARABIC_JORDAN :
+ case LANGUAGE_ARABIC_LEBANON :
+ case LANGUAGE_ARABIC_KUWAIT :
+ case LANGUAGE_ARABIC_UAE :
+ case LANGUAGE_ARABIC_BAHRAIN :
+ case LANGUAGE_ARABIC_QATAR : aLangStr = REPLACEMENT_ARABIC;
+ break ;
+
+ case LANGUAGE_CZECH : aLangStr = REPLACEMENT_CZECH;
+ break ;
+
+ case LANGUAGE_DANISH : aLangStr = REPLACEMENT_DANISH;
+ break ;
+
+ case LANGUAGE_DUTCH :
+ case LANGUAGE_DUTCH_BELGIAN : aLangStr = REPLACEMENT_DUTCH;
+ break ;
+
+ case LANGUAGE_ENGLISH :
+ case LANGUAGE_ENGLISH_AUS :
+ case LANGUAGE_ENGLISH_CAN :
+ case LANGUAGE_ENGLISH_NZ :
+ case LANGUAGE_ENGLISH_EIRE :
+ case LANGUAGE_ENGLISH_SAFRICA :
+ case LANGUAGE_ENGLISH_JAMAICA :
+ case LANGUAGE_ENGLISH_CARRIBEAN :
+ case LANGUAGE_ENGLISH_BELIZE :
+ case LANGUAGE_ENGLISH_TRINIDAD :
+ case LANGUAGE_ENGLISH_ZIMBABWE :
+ case LANGUAGE_ENGLISH_PHILIPPINES :
+ case LANGUAGE_ENGLISH_US : aLangStr = REPLACEMENT_ENGLISH;
+ break ;
+
+ case LANGUAGE_ENGLISH_UK : aLangStr = REPLACEMENT_ENGLISH_UK;
+ break ;
+
+ case LANGUAGE_FINNISH : aLangStr = REPLACEMENT_FINNISH;
+ break ;
+
+ case LANGUAGE_FRENCH :
+ case LANGUAGE_FRENCH_BELGIAN :
+ case LANGUAGE_FRENCH_CANADIAN :
+ case LANGUAGE_FRENCH_SWISS :
+ case LANGUAGE_FRENCH_LUXEMBOURG :
+ case LANGUAGE_FRENCH_MONACO : aLangStr = REPLACEMENT_FRENCH;
+ break ;
+
+ case LANGUAGE_GERMAN :
+ case LANGUAGE_GERMAN_SWISS :
+ case LANGUAGE_GERMAN_AUSTRIAN :
+ case LANGUAGE_GERMAN_LUXEMBOURG :
+ case LANGUAGE_GERMAN_LIECHTENSTEIN : aLangStr = REPLACEMENT_GERMAN;
+ break ;
+
+ case LANGUAGE_GREEK : aLangStr = REPLACEMENT_GREEK;
+ break ;
+
+ case LANGUAGE_HEBREW : aLangStr = REPLACEMENT_HEBREW;
+ break ;
+
+ case LANGUAGE_ITALIAN :
+ case LANGUAGE_ITALIAN_SWISS : aLangStr = REPLACEMENT_ITALIAN;
+ break ;
+
+ case LANGUAGE_JAPANESE : aLangStr = REPLACEMENT_JAPANESE;
+ break ;
+
+ case LANGUAGE_KOREAN :
+ case LANGUAGE_KOREAN_JOHAB : aLangStr = REPLACEMENT_KOREAN;
+ break ;
+
+ case LANGUAGE_POLISH : aLangStr = REPLACEMENT_POLISH;
+ break ;
+
+ case LANGUAGE_RUSSIAN : aLangStr = REPLACEMENT_RUSSIAN;
+ break ;
+
+ case LANGUAGE_SLOVAK : aLangStr = REPLACEMENT_SLOVAK;
+ break ;
+
+ case LANGUAGE_SPANISH :
+ case LANGUAGE_SPANISH_MEXICAN :
+ case LANGUAGE_SPANISH_MODERN :
+ case LANGUAGE_SPANISH_GUATEMALA :
+ case LANGUAGE_SPANISH_COSTARICA :
+ case LANGUAGE_SPANISH_PANAMA :
+ case LANGUAGE_SPANISH_DOMINICAN_REPUBLIC:
+ case LANGUAGE_SPANISH_VENEZUELA :
+ case LANGUAGE_SPANISH_COLOMBIA :
+ case LANGUAGE_SPANISH_PERU :
+ case LANGUAGE_SPANISH_ARGENTINA :
+ case LANGUAGE_SPANISH_ECUADOR :
+ case LANGUAGE_SPANISH_CHILE :
+ case LANGUAGE_SPANISH_URUGUAY :
+ case LANGUAGE_SPANISH_PARAGUAY :
+ case LANGUAGE_SPANISH_BOLIVIA :
+ case LANGUAGE_SPANISH_EL_SALVADOR :
+ case LANGUAGE_SPANISH_HONDURAS :
+ case LANGUAGE_SPANISH_NICARAGUA :
+ case LANGUAGE_SPANISH_PUERTO_RICO : aLangStr = REPLACEMENT_SPANISH;
+ break ;
+
+ case LANGUAGE_SWEDISH :
+ case LANGUAGE_SWEDISH_FINLAND : aLangStr = REPLACEMENT_SWEDISH;
+ break ;
+
+ case LANGUAGE_TURKISH : aLangStr = REPLACEMENT_TURKISH;
+ break ;
+
+ case LANGUAGE_NORWEGIAN :
+ case LANGUAGE_NORWEGIAN_BOKMAL :
+ case LANGUAGE_NORWEGIAN_NYNORSK : aLangStr = REPLACEMENT_NORWEGIAN;
+ break ;
+
+ case LANGUAGE_HUNGARIAN : aLangStr = REPLACEMENT_HUNGARIAN;
+ break ;
+
+ /* case LANGUAGE_BULGARIAN : aLangStr = REPLACEMENT_BULGARIAN;
+ break ; */
+
+ case LANGUAGE_CHINESE_TRADITIONAL : aLangStr = REPLACEMENT_CHINESE_TRADITIONAL;
+ break ;
+
+ case LANGUAGE_CHINESE_SIMPLIFIED : aLangStr = REPLACEMENT_CHINESE_SIMPLIFIED;
+ break ;
+
+ case LANGUAGE_PORTUGUESE : aLangStr = REPLACEMENT_PORTUGUESE;
+ break ;
+
+ case LANGUAGE_PORTUGUESE_BRAZILIAN : aLangStr = REPLACEMENT_PORTUGUESE_BRAZILIAN;
+ break ;
+
+ case LANGUAGE_THAI : aLangStr = REPLACEMENT_THAI;
+ break ;
+
+ case LANGUAGE_CATALAN : aLangStr = REPLACEMENT_CATALAN;
+ break ;
+
+ default : // fallback for L10N-framework => ISO-Code
+ {
+ String rLangStr;
+ String rCountry;
+ ConvertLanguageToIsoNames( aLanguageType, rLangStr, rCountry);
+ if ( rCountry.Len()) {
+ rLangStr += String::CreateFromAscii( "-" );
+ rLangStr += rCountry;
+ }
+ aLangStr = rLangStr;
+ }
+ break ;
+ }
+
+ return aLangStr;
+}
+
+rtl::OUString SubstitutePathVariables::impl_substituteVariable( const ::rtl::OUString& rText, sal_Bool bSubstRequired )
+throw ( NoSuchElementException, RuntimeException )
+{
+ // This is maximal recursive depth supported!
+ const sal_Int32 nMaxRecursiveDepth = 8;
+
+ rtl::OUString aWorkText = rText;
+ rtl::OUString aResult;
+
+ // Use vector with strings to detect endless recursions!
+ std::vector< rtl::OUString > aEndlessRecursiveDetector;
+
+ // Search for first occure of "$(...".
+ sal_Int32 nDepth = 0;
+ sal_Int32 bSubstitutionCompleted = sal_False;
+ sal_Int32 nPosition = aWorkText.indexOf( m_aVarStart ); // = first position of "$(" in string
+ sal_Int32 nLength = 0; // = count of letters from "$(" to ")" in string
+ sal_Bool bVarNotSubstituted = sal_False;
+
+ // Have we found any variable like "$(...)"?
+ if ( nPosition != STRPOS_NOTFOUND )
+ {
+ // Yes; Get length of found variable.
+ // If no ")" was found - nLength is set to 0 by default! see before.
+ sal_Int32 nEndPosition = aWorkText.indexOf( m_aVarEnd, nPosition );
+ if ( nEndPosition != STRPOS_NOTFOUND )
+ nLength = nEndPosition - nPosition + 1;
+ }
+
+ // Is there something to replace ?
+ sal_Bool bWorkRetrieved = sal_False;
+ sal_Bool bWorkDirURLRetrieved = sal_False;
+ while ( !bSubstitutionCompleted && nDepth < nMaxRecursiveDepth )
+ {
+ while ( ( nPosition != STRPOS_NOTFOUND ) && ( nLength > 3 ) ) // "$(" ")"
+ {
+ // YES; Get the next variable for replace.
+ sal_Int32 nReplaceLength = 0;
+ rtl::OUString aReplacement;
+ rtl::OUString aSubString = aWorkText.copy( nPosition, nLength );
+
+ // Path variables are not case sensitive!
+ aSubString = aSubString.toAsciiLowerCase();
+ VarNameToIndexMap::const_iterator pIter = m_aPreDefVarMap.find( aSubString );
+ if ( pIter != m_aPreDefVarMap.end() )
+ {
+ // Fixed/Predefined variable found
+ PreDefVariable nIndex = (PreDefVariable)pIter->second;
+
+ // Determine variable value and length from array/table
+ if ( nIndex == PREDEFVAR_WORK && !bWorkRetrieved )
+ {
+ // Transient value, retrieve it again
+ m_aPreDefVars.m_FixedVar[ (PreDefVariable)nIndex ] = GetWorkVariableValue();
+ bWorkRetrieved = sal_True;
+ }
+ else if ( nIndex == PREDEFVAR_WORKDIRURL && !bWorkDirURLRetrieved )
+ {
+ // Transient value, retrieve it again
+ m_aPreDefVars.m_FixedVar[ (PreDefVariable)nIndex ] = m_aWorkPathHelper.GetWorkPath();
+ bWorkDirURLRetrieved = sal_True;
+ }
+
+ aReplacement = m_aPreDefVars.m_FixedVar[ (PreDefVariable)nIndex ];
+ nReplaceLength = nLength;
+ }
+ else
+ {
+ // Extract the variable name and try to find in the user defined variable set
+ rtl::OUString aVarName = aSubString.copy( 2, nLength-3 );
+ SubstituteVariables::const_iterator pIter = m_aSubstVarMap.find( aVarName );
+ if ( pIter != m_aSubstVarMap.end() )
+ {
+ // found!
+ aReplacement = pIter->second.aSubstValue;
+ nReplaceLength = nLength;
+ }
+ }
+
+ // Have we found something to replace?
+ if ( nReplaceLength > 0 )
+ {
+ // Yes ... then do it.
+ aWorkText = aWorkText.replaceAt( nPosition, nReplaceLength, aReplacement );
+ }
+ else
+ {
+ // Variable not known
+ bVarNotSubstituted = sal_False;
+ nPosition += nLength;
+ }
+
+ // Step after replaced text! If no text was replaced (unknown variable!),
+ // length of aReplacement is 0 ... and we don't step then.
+ nPosition += aReplacement.getLength();
+
+ // We must control index in string before call something at OUString!
+ // The OUString-implementation don't do it for us :-( but the result is not defined otherwise.
+ if ( nPosition + 1 > aWorkText.getLength() )
+ {
+ // Position is out of range. Break loop!
+ nPosition = STRPOS_NOTFOUND;
+ nLength = 0;
+ }
+ else
+ {
+ // Else; Position is valid. Search for next variable to replace.
+ nPosition = aWorkText.indexOf( m_aVarStart, nPosition );
+ // Have we found any variable like "$(...)"?
+ if ( nPosition != STRPOS_NOTFOUND )
+ {
+ // Yes; Get length of found variable. If no ")" was found - nLength must set to 0!
+ nLength = 0;
+ sal_Int32 nEndPosition = aWorkText.indexOf( m_aVarEnd, nPosition );
+ if ( nEndPosition != STRPOS_NOTFOUND )
+ nLength = nEndPosition - nPosition + 1;
+ }
+ }
+ }
+
+ nPosition = aWorkText.indexOf( m_aVarStart );
+ if ( nPosition == -1 )
+ {
+ bSubstitutionCompleted = sal_True;
+ break; // All variables are substituted
+ }
+ else
+ {
+ // Check for recursion
+ for ( sal_Int32 i=0; i < (sal_Int32)aEndlessRecursiveDetector.size(); i++ )
+ {
+ if ( aEndlessRecursiveDetector[i] == aWorkText )
+ {
+ if ( bVarNotSubstituted )
+ break; // Not all variables could be substituted!
+ else
+ {
+ nDepth = nMaxRecursiveDepth;
+ break; // Recursion detected!
+ }
+ }
+ }
+
+ aEndlessRecursiveDetector.push_back( aWorkText );
+
+ // Initialize values for next
+ sal_Int32 nEndPosition = aWorkText.indexOf( m_aVarEnd, nPosition );
+ if ( nEndPosition != STRPOS_NOTFOUND )
+ nLength = nEndPosition - nPosition + 1;
+ bVarNotSubstituted = sal_False;
+ ++nDepth;
+ }
+ }
+
+ // Fill return value with result
+ if ( bSubstitutionCompleted )
+ {
+ // Substitution successfull!
+ aResult = aWorkText;
+ }
+ else
+ {
+ // Substitution not successfull!
+ if ( nDepth == nMaxRecursiveDepth )
+ {
+ // recursion depth reached!
+ if ( bSubstRequired )
+ {
+ rtl::OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Endless recursion detected. Cannot substitute variables!" ));
+ throw NoSuchElementException( aMsg, (cppu::OWeakObject *)this );
+ }
+ else
+ aResult = rText;
+ }
+ else
+ {
+ // variable in text but unknwon!
+ if ( bSubstRequired )
+ {
+ rtl::OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Unknown variable found!" ));
+ throw NoSuchElementException( aMsg, (cppu::OWeakObject *)this );
+ }
+ else
+ aResult = aWorkText;
+ }
+ }
+
+ return aResult;
+}
+
+rtl::OUString SubstitutePathVariables::impl_reSubstituteVariables( const ::rtl::OUString& rURL )
+throw ( RuntimeException )
+{
+ rtl::OUString aURL;
+
+ INetURLObject aUrl( rURL );
+ if ( !aUrl.HasError() )
+ aURL = aUrl.GetMainURL( INetURLObject::NO_DECODE );
+ else
+ {
+ // Convert a system path to a UCB compliant URL before resubstitution
+ rtl::OUString aTemp;
+ if ( osl::FileBase::getFileURLFromSystemPath( rURL, aTemp ) == osl::FileBase::E_None )
+ {
+ aTemp = ConvertOSLtoUCBURL( aTemp );
+ if ( aTemp.getLength() )
+ aURL = INetURLObject( aTemp ).GetMainURL( INetURLObject::NO_DECODE );
+ else
+ return rURL;
+ }
+ else
+ {
+ // rURL is not a valid URL nor a osl system path. Give up and return error!
+ return rURL;
+ }
+ }
+
+ // Due to a recursive definition this code must exchange variables with variables!
+ sal_Bool bResubstitutionCompleted = sal_False;
+ sal_Bool bVariableFound = sal_False;
+ sal_Int32 nURLLen = aURL.getLength();
+
+ // Get transient predefined path variable $(work) value before starting resubstitution
+ m_aPreDefVars.m_FixedVar[ PREDEFVAR_WORK ] = GetWorkVariableValue();
+
+ while ( !bResubstitutionCompleted )
+ {
+ ReSubstFixedVarOrderVector::const_iterator pIterFixed;
+ for ( pIterFixed = m_aReSubstFixedVarOrder.begin(); pIterFixed != m_aReSubstFixedVarOrder.end(); pIterFixed++ )
+ {
+ rtl::OUString aValue = m_aPreDefVars.m_FixedVar[ (sal_Int32)pIterFixed->eVariable ];
+ sal_Int32 nPos = aURL.indexOf( aValue );
+ if ( nPos >= 0 )
+ {
+ sal_Bool bMatch = sal_True;
+ if ( pIterFixed->eVariable == PREDEFVAR_LANG ||
+ pIterFixed->eVariable == PREDEFVAR_LANGID ||
+ pIterFixed->eVariable == PREDEFVAR_VLANG )
+ {
+ // Special path variables as they can occur in the middle of a path. Only match if they
+ // describe a whole directory and not only a substring of a directory!
+ const sal_Unicode* pStr = aURL.getStr();
+
+ if ( nPos > 0 )
+ bMatch = ( aURL[ nPos-1 ] == '/' );
+
+ if ( bMatch )
+ {
+ if ( nPos + aValue.getLength() < aURL.getLength() )
+ bMatch = ( pStr[ nPos + aValue.getLength() ] == '/' );
+ }
+ }
+
+ if ( bMatch )
+ {
+ rtl::OUStringBuffer aStrBuffer( aURL.getLength() );
+ aStrBuffer.append( aURL.copy( 0, nPos ) );
+ aStrBuffer.append( m_aPreDefVars.m_FixedVarNames[ (sal_Int32)pIterFixed->eVariable ] ); // Get the variable name for struct var name array!
+ aStrBuffer.append( aURL.copy( nPos + aValue.getLength(), ( aURL.getLength() - ( nPos + aValue.getLength() )) ));
+ aURL = aStrBuffer.makeStringAndClear();
+ bVariableFound = sal_True; // Resubstitution not finished yet!
+ break;
+ }
+ }
+ }
+
+ // This part can be iteratered more than one time as variables can contain variables again!
+ ReSubstUserVarOrderVector::const_iterator pIterUser;
+ for ( pIterUser = m_aReSubstUserVarOrder.begin(); pIterUser != m_aReSubstUserVarOrder.end(); pIterUser++ )
+ {
+ rtl::OUString aVarValue = pIterUser->aVarName;
+ sal_Int32 nPos = aURL.indexOf( aVarValue );
+ if ( nPos >= 0 )
+ {
+ rtl::OUStringBuffer aStrBuffer( aURL.getLength() );
+ aStrBuffer.append( aURL.copy( 0, nPos ) );
+ aStrBuffer.append( m_aVarStart );
+ aStrBuffer.append( aVarValue );
+ aStrBuffer.append( m_aVarEnd );
+ aStrBuffer.append( aURL.copy( nPos + aVarValue.getLength(), ( aURL.getLength() - ( nPos + aVarValue.getLength() )) ));
+ aURL = aStrBuffer.makeStringAndClear();
+ bVariableFound = sal_True; // Resubstitution not finished yet!
+ }
+ }
+
+ if ( !bVariableFound )
+ bResubstitutionCompleted = sal_True;
+ else
+ bVariableFound = sal_False; // Next resubstitution
+ }
+
+ return aURL;
+}
+
+// This method support both request schemes "$("<varname>")" or "<varname>".
+::rtl::OUString SubstitutePathVariables::impl_getSubstituteVariableValue( const ::rtl::OUString& rVariable )
+throw ( NoSuchElementException, RuntimeException )
+{
+ rtl::OUString aVariable;
+
+ sal_Int32 nPos = rVariable.indexOf( m_aVarStart );
+ if ( nPos == -1 )
+ {
+ // Prepare variable name before hash map access
+ rtl::OUStringBuffer aStrBuffer( rVariable.getLength() + m_aVarStart.getLength() + m_aVarEnd.getLength() );
+ aStrBuffer.append( m_aVarStart );
+ aStrBuffer.append( rVariable );
+ aStrBuffer.append( m_aVarEnd );
+ aVariable = aStrBuffer.makeStringAndClear();
+ }
+
+ VarNameToIndexMap::const_iterator pIter = m_aPreDefVarMap.find( ( nPos == -1 ) ? aVariable : rVariable );
+
+ // Fixed/Predefined variable
+ if ( pIter != m_aPreDefVarMap.end() )
+ {
+ PreDefVariable nIndex = (PreDefVariable)pIter->second;
+ return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex];
+ }
+ else
+ {
+ // Prepare variable name before hash map access
+ if ( nPos >= 0 )
+ {
+ if ( rVariable.getLength() > 3 )
+ aVariable = rVariable.copy( 2, rVariable.getLength() - 3 );
+ else
+ {
+ rtl::OUString aExceptionText( RTL_CONSTASCII_USTRINGPARAM( "Unknown variable!" ));
+ throw NoSuchElementException();
+ }
+ }
+ else
+ aVariable = rVariable;
+
+ // User defined variable
+ SubstituteVariables::const_iterator pIter = m_aSubstVarMap.find( aVariable );
+ if ( pIter != m_aSubstVarMap.end() )
+ {
+ // found!
+ return pIter->second.aSubstValue;
+ }
+
+ rtl::OUString aExceptionText( RTL_CONSTASCII_USTRINGPARAM( "Unknown variable!" ));
+ throw NoSuchElementException( aExceptionText, (cppu::OWeakObject *)this );
+ }
+
+ // SAFE-IMPOSSIBLE CASE!
+ return rtl::OUString();
+}
+
+void SubstitutePathVariables::SetPredefinedPathVariables( PredefinedPathVariables& aPreDefPathVariables )
+{
+ utl::ConfigManager* pCfgMgr = utl::ConfigManager::GetConfigManager();
+
+ Any aAny;
+ ::rtl::OUString aOfficePath;
+ ::rtl::OUString aUserPath;
+ ::rtl::OUString aTmp;
+ ::rtl::OUString aTmp2;
+ String aResult;
+
+ // Get inspath and userpath from bootstrap mechanism in every case as file URL
+ ::utl::Bootstrap::PathStatus aState;
+ ::rtl::OUString sVal ;
+
+ aState = utl::Bootstrap::locateBaseInstallation( sVal );
+ if( aState==::utl::Bootstrap::PATH_EXISTS )
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTPATH ] = ConvertOSLtoUCBURL( sVal );
+ else
+ LOG_ERROR( "SubstitutePathVariables::SetPredefinedPathVariables", "Bootstrap code has no value for instpath!");
+
+ aState = utl::Bootstrap::locateUserData( sVal );
+ if( aState == ::utl::Bootstrap::PATH_EXISTS )
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERPATH ] = ConvertOSLtoUCBURL( sVal );
+ else
+ LOG_ERROR( "SubstitutePathVariables::SetPredefinedPathVariables", "Bootstrap code has no value for userpath");
+
+ // Get insturl and userurl from configuration (xml files)
+ // But if they doesn't exist (e.g. is true for fat office!) use instpath and userpath instead of this.
+ // Set $(inst), $(instpath), $(insturl)
+ aAny = pCfgMgr->GetDirectConfigProperty( utl::ConfigManager::OFFICEINSTALLURL );
+ if ( !aAny.hasValue() || ( aAny >>= aOfficePath ) )
+ {
+ // "OFFICEINSTALLURL" is a UCB compatible URL for the office installation directory
+ // in the Webtop this MUST be set, in FATOffice it is the osl URL of the instpath
+ if ( aOfficePath.getLength() )
+ {
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTPATH ] = aOfficePath;
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTURL ] = aOfficePath;
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INST ] = aOfficePath;
+ }
+ else
+ {
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTURL ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTPATH ];
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INST ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_INSTPATH ];
+ }
+ }
+ else
+ LOG_ERROR( "SubstitutePathVariables::SetPredefinedPathVariables", "Wrong any typ for office install URL!" );
+
+ // Get the user installation directory
+ // Set $(user), $(userpath), $(userurl)
+ aAny = pCfgMgr->GetDirectConfigProperty( utl::ConfigManager::USERINSTALLURL );
+ if ( !aAny.hasValue() || ( aAny >>= aUserPath ) )
+ {
+ if ( aUserPath.getLength() )
+ {
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERPATH ] = aUserPath;
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERURL ] = aUserPath;
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USER ] = aUserPath;
+ }
+ else
+ {
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERURL ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERPATH ];
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USER ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_USERPATH ];
+ }
+ }
+ else
+ LOG_ERROR( "SubstitutePathVariables::SetPredefinedPathVariables", "Wrong any type for user install URL!" );
+
+ // Detect the program directory
+ // Set $(prog), $(progpath), $(progurl)
+ rtl::OUString aProgName;
+ ::vos::OStartupInfo aInfo;
+ aInfo.getExecutableFile( aProgName );
+ sal_Int32 lastIndex = aProgName.lastIndexOf('/');
+ if ( lastIndex >= 0 )
+ {
+ ::rtl::OUString aTmpProgPath;
+ aTmp = aProgName.copy( 0, lastIndex );
+ INetURLObject aObj( aTmp );
+
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_PROGPATH ] = ConvertOSLtoUCBURL( aObj.GetMainURL(INetURLObject::NO_DECODE) );
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_PROGURL ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_PROGPATH ];
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_PROG ] = aPreDefPathVariables.m_FixedVar[ PREDEFVAR_PROGPATH ];
+ }
+
+ // Detect the language type of the current office
+ aPreDefPathVariables.m_eLanguageType = LANGUAGE_ENGLISH_US;
+ Any aLocale = utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty( utl::ConfigManager::LOCALE );
+ rtl::OUString aLocaleStr;
+ if ( aLocale >>= aLocaleStr )
+ aPreDefPathVariables.m_eLanguageType = ConvertIsoStringToLanguage( aLocaleStr );
+ else
+ {
+ LOG_ERROR( "SubstitutePathVariables::SetPredefinedPathVariables", "Wrong Any type for language!" );
+ }
+
+ // Set $(lang)
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_LANG ] = ConvertOSLtoUCBURL(
+ rtl::OUString::createFromAscii( ResMgr::GetLang( aPreDefPathVariables.m_eLanguageType, 0 ) ));
+
+ // Set $(vlang)
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_VLANG ] = GetLanguageString( aPreDefPathVariables.m_eLanguageType );
+
+ // Set $(langid)
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_LANGID ] = rtl::OUString::valueOf( (sal_Int32)aPreDefPathVariables.m_eLanguageType );
+
+ // Set the other pre defined path variables
+ // Set $(work)
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_WORK ] = GetWorkVariableValue();
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_HOME ] = GetHomeVariableValue();
+
+ // Set $(workdirurl) this is the value of the path PATH_WORK which doesn't make sense
+ // anymore because the path settings service has this value! It can deliver this value more
+ // quickly than the substitution service!
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_WORKDIRURL ] = m_aWorkPathHelper.GetWorkPath();
+
+ // Set $(temp)
+ osl::FileBase::getTempDirURL( aTmp );
+ aPreDefPathVariables.m_FixedVar[ PREDEFVAR_TEMP ] = ConvertOSLtoUCBURL( aTmp );
+}
+
+} // namespace framework
diff --git a/framework/source/unotypes/fwl.xml b/framework/source/unotypes/fwl.xml
index dcd583f9e321..e45d72f1f168 100644
--- a/framework/source/unotypes/fwl.xml
+++ b/framework/source/unotypes/fwl.xml
@@ -67,6 +67,30 @@
<supported-service> com.sun.star.frame.MediaTypeDetectionHelper </supported-service>
</component-description>
+ <component-description>
+ <author> Carsten Driesner </author>
+ <name> com.sun.star.comp.framework.SubstituteVariables </name>
+ <description>
+ Supports the substitution and resubstitution of path and language variables.
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service> com.sun.star.frame.PathSubstitution </supported-service>
+ </component-description>
+
+ <component-description>
+ <author> Carsten Driesner </author>
+ <name> com.sun.star.comp.framework.PathSettings </name>
+ <description>
+ Supports the access to the Office internal path settings.
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service> com.sun.star.frame.PathSettings </supported-service>
+ </component-description>
+
<project-build-dependency> cppu </project-build-dependency>
<project-build-dependency> cppuhelper </project-build-dependency>
<project-build-dependency> comphelper </project-build-dependency>
diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk
index 114cc9d13660..b9a0fdd01521 100644
--- a/framework/util/makefile.mk
+++ b/framework/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.65 $
+# $Revision: 1.66 $
#
-# last change: $Author: as $ $Date: 2002-08-15 06:52:13 $
+# last change: $Author: cd $ $Date: 2002-08-20 10:21:59 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -88,7 +88,8 @@ LIB1OBJFILES= $(SLO)$/wildcard.obj \
$(SLO)$/transactionmanager.obj \
$(SLO)$/filtercache.obj \
$(SLO)$/filtercachedata.obj \
- $(SLO)$/protocolhandlercache.obj
+ $(SLO)$/protocolhandlercache.obj \
+ $(SLO)$/networkdomain.obj
# --- export library for sfx2 -------------------------------------------------
@@ -135,6 +136,14 @@ SHL1STDLIBS= $(CPPULIB) \
$(TOOLSLIB) \
$(UNOTOOLSLIB)
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS+=\
+ uwinapi.lib \
+ unicows.lib \
+ advapi32.lib \
+ kernel32.lib
+.ENDIF
+
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
@@ -181,7 +190,9 @@ SHL3OBJS= $(SLO)$/contenthandlerfactory.obj \
$(SLO)$/frameloaderfactory.obj \
$(SLO)$/mediatypedetectionhelper.obj\
$(SLO)$/registertemp.obj \
- $(SLO)$/typedetection.obj
+ $(SLO)$/typedetection.obj \
+ $(SLO)$/substitutepathvars.obj \
+ $(SLO)$/pathsettings.obj
SHL3STDLIBS= $(CPPULIB) \
$(CPPUHELPERLIB) \