2002-08-20 04:21:59 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* $RCSfile: pathsettings.hxx,v $
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2006-07-21 04:34:23 -05:00
|
|
|
* $Revision: 1.6 $
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2006-07-21 04:34:23 -05:00
|
|
|
* last change: $Author: kz $ $Date: 2006-07-21 10:34:23 $
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* 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.
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* 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.
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
2005-09-08 18:33:03 -05:00
|
|
|
* 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
|
2002-08-20 04:21:59 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
2003-03-25 11:22:13 -06:00
|
|
|
#ifndef __FRAMEWORK_PROPERTIES_H_
|
|
|
|
#include <properties.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRAMEWORK_STDTYPES_H_
|
|
|
|
#include <stdtypes.h>
|
|
|
|
#endif
|
|
|
|
|
2002-08-20 04:21:59 -05:00
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// 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
|
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XCHANGESLISTENER_HPP_
|
|
|
|
#include <com/sun/star/util/XChangesListener.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
|
|
|
|
2002-08-20 04:21:59 -05:00
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// 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
|
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
#ifndef _COMPHELPER_SEQUENCEASVECTOR_HXX_
|
|
|
|
#include <comphelper/sequenceasvector.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* enable it if you whish to migrate old user settings (using the old cfg schema) on demand ....
|
|
|
|
disable it in case only the new schema must be used.
|
|
|
|
*/
|
|
|
|
#define MIGRATE_OLD_USER_PATHES
|
|
|
|
|
2002-08-20 04:21:59 -05:00
|
|
|
namespace framework
|
|
|
|
{
|
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
class PathSettings : public css::lang::XTypeProvider ,
|
|
|
|
public css::lang::XServiceInfo ,
|
|
|
|
public css::util::XChangesListener , // => XEventListener
|
|
|
|
// base classes
|
|
|
|
// Order is neccessary for right initialization!
|
|
|
|
private ThreadHelpBase ,
|
|
|
|
public ::cppu::OBroadcastHelper ,
|
|
|
|
public ::cppu::OPropertySetHelper , // => XPropertySet / XFastPropertySet / XMultiPropertySet
|
|
|
|
public ::cppu::OWeakObject // => XWeak, XInterface
|
2002-08-20 04:21:59 -05:00
|
|
|
{
|
2006-07-13 06:03:39 -05:00
|
|
|
struct PathInfo
|
|
|
|
{
|
|
|
|
public:
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
PathInfo()
|
2006-07-21 04:34:23 -05:00
|
|
|
: sPathName ()
|
2006-07-13 06:03:39 -05:00
|
|
|
, lInternalPaths()
|
|
|
|
, lUserPaths ()
|
2006-07-21 04:34:23 -05:00
|
|
|
, sWritePath ()
|
|
|
|
, bIsSinglePath (sal_False)
|
2006-07-13 06:03:39 -05:00
|
|
|
{}
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-21 04:34:23 -05:00
|
|
|
PathInfo(const PathInfo& rCopy)
|
|
|
|
{
|
|
|
|
takeOver(rCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void takeOver(const PathInfo& rCopy)
|
|
|
|
{
|
|
|
|
sPathName = rCopy.sPathName;
|
|
|
|
lInternalPaths = rCopy.lInternalPaths;
|
|
|
|
lUserPaths = rCopy.lUserPaths;
|
|
|
|
sWritePath = rCopy.sWritePath;
|
|
|
|
bIsSinglePath = rCopy.bIsSinglePath;
|
|
|
|
}
|
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/// an internal name describing this path
|
|
|
|
::rtl::OUString sPathName;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/// contains all paths, which are used internaly - but are not visible for the user.
|
|
|
|
OUStringList lInternalPaths;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/// contains all paths configured by the user
|
|
|
|
OUStringList lUserPaths;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/// this special path is used to generate feature depending content there
|
|
|
|
::rtl::OUString sWritePath;
|
2006-07-21 04:34:23 -05:00
|
|
|
|
|
|
|
/// indicates real single pathes, which uses WritePath property only
|
|
|
|
sal_Bool bIsSinglePath;
|
2006-07-13 06:03:39 -05:00
|
|
|
};
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
typedef BaseHash< PathSettings::PathInfo > PathHash;
|
|
|
|
|
|
|
|
enum EChangeOp
|
|
|
|
{
|
|
|
|
E_UNDEFINED,
|
|
|
|
E_ADDED,
|
|
|
|
E_CHANGED,
|
|
|
|
E_REMOVED
|
|
|
|
};
|
2003-03-25 11:22:13 -06:00
|
|
|
|
|
|
|
// ______________________________________
|
2006-07-13 06:03:39 -05:00
|
|
|
// member
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
private:
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** reference to factory, which has create this instance. */
|
|
|
|
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** list of all path variables and her corresponding values. */
|
|
|
|
PathSettings::PathHash m_lPaths;
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** describes all properties available on our interface.
|
|
|
|
Will be generated on demand based on our path list m_lPaths. */
|
|
|
|
css::uno::Sequence< css::beans::Property > m_lPropDesc;
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** helper needed to (re-)substitute all internal save path values. */
|
|
|
|
css::uno::Reference< css::util::XStringSubstitution > m_xSubstitution;
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** provides access to the old configuration schema (which will be migrated on demand). */
|
|
|
|
css::uno::Reference< css::container::XNameAccess > m_xCfgOld;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** provides access to the new configuration schema. */
|
|
|
|
css::uno::Reference< css::container::XNameAccess > m_xCfgNew;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
::cppu::OPropertyArrayHelper* m_pPropHelp;
|
2003-03-25 11:22:13 -06:00
|
|
|
|
|
|
|
// ___________________________________________
|
|
|
|
// interface
|
2002-08-20 04:21:59 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2003-03-25 11:22:13 -06:00
|
|
|
/** initialize a new instance of this class.
|
|
|
|
Attention: It's neccessary for right function of this class, that the order of base
|
|
|
|
classes is the right one. Because we transfer information from one base to another
|
|
|
|
during this ctor runs! */
|
2006-07-13 06:03:39 -05:00
|
|
|
PathSettings(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
|
2003-03-25 11:22:13 -06:00
|
|
|
|
|
|
|
/** free all used ressources ... if it was not already done. */
|
|
|
|
virtual ~PathSettings();
|
|
|
|
|
|
|
|
/** declaration of XInterface, XTypeProvider, XServiceInfo */
|
2006-06-19 05:00:54 -05:00
|
|
|
FWK_DECLARE_XINTERFACE
|
|
|
|
FWK_DECLARE_XTYPEPROVIDER
|
2002-08-20 04:21:59 -05:00
|
|
|
DECLARE_XSERVICEINFO
|
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
// css::util::XChangesListener
|
|
|
|
virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent) throw (css::uno::RuntimeException);
|
|
|
|
|
|
|
|
// css::lang::XEventListener
|
|
|
|
virtual void SAL_CALL disposing(const css::lang::EventObject& aSource)
|
|
|
|
throw(css::uno::RuntimeException);
|
|
|
|
|
|
|
|
using ::cppu::OPropertySetHelper::disposing;
|
|
|
|
|
2003-03-25 11:22:13 -06:00
|
|
|
// ___________________________________________
|
|
|
|
// helper
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2003-03-25 11:22:13 -06:00
|
|
|
private:
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** read all configured paths and create all needed internal structures. */
|
|
|
|
void impl_readAll();
|
|
|
|
|
|
|
|
/** read a path info using the old cfg schema.
|
|
|
|
This is needed for "migration on demand" reasons only.
|
|
|
|
Can be removed for next major release .-) */
|
|
|
|
OUStringList impl_readOldFormat(const ::rtl::OUString& sPath);
|
|
|
|
|
|
|
|
/** read a path info using the new cfg schema. */
|
|
|
|
PathSettings::PathInfo impl_readNewFormat(const ::rtl::OUString& sPath);
|
|
|
|
|
|
|
|
/** filter "real user defined paths" from the old configuration schema
|
|
|
|
and set it as UserPaths on the new schema.
|
|
|
|
Can be removed with new major release ... */
|
|
|
|
#ifdef MIGRATE_OLD_USER_PATHES
|
|
|
|
void impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
|
|
|
|
const OUStringList& lOld );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** reload one path directly from the new configuration schema (because
|
|
|
|
it was updated by any external code) */
|
|
|
|
PathSettings::EChangeOp impl_updatePath(const ::rtl::OUString& sPath ,
|
|
|
|
sal_Bool bNotifyListener);
|
|
|
|
|
|
|
|
/** replace all might existing placeholder variables inside the given path ...
|
|
|
|
or check if the given path value uses paths, which can be replaced with predefined
|
|
|
|
placeholder variables ...
|
|
|
|
*/
|
|
|
|
void impl_subst( OUStringList& lVals ,
|
|
|
|
const css::uno::Reference< css::util::XStringSubstitution >& xSubst ,
|
|
|
|
sal_Bool bReSubst);
|
|
|
|
|
|
|
|
void impl_subst(PathSettings::PathInfo& aPath ,
|
|
|
|
sal_Bool bReSubst);
|
|
|
|
|
|
|
|
|
|
|
|
/** converts our new string list schema to the old ";" seperated schema ... */
|
|
|
|
::rtl::OUString impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath ) const;
|
|
|
|
OUStringList impl_convertOldStyle2Path(const ::rtl::OUString& sOldStylePath) const;
|
|
|
|
|
|
|
|
/** remove still known paths from the given lList argument.
|
|
|
|
So real user defined paths can be extracted from the list of
|
|
|
|
fix internal paths !
|
|
|
|
*/
|
|
|
|
void impl_purgeKnownPaths(const PathSettings::PathInfo& rPath,
|
|
|
|
OUStringList& lList);
|
|
|
|
|
|
|
|
/** rebuild the member m_lPropDesc using the path list m_lPaths. */
|
|
|
|
void impl_rebuildPropertyDescriptor();
|
|
|
|
|
|
|
|
/** provides direct access to the list of path values
|
|
|
|
using it's internal property id.
|
|
|
|
*/
|
|
|
|
css::uno::Any impl_getPathValue( sal_Int32 nID ) const;
|
|
|
|
void impl_setPathValue( sal_Int32 nID ,
|
|
|
|
const css::uno::Any& aVal);
|
|
|
|
|
|
|
|
/** check the given handle and return the corresponding PathInfo reference.
|
|
|
|
These reference can be used then directly to manipulate these path. */
|
|
|
|
PathSettings::PathInfo* impl_getPathAccess (sal_Int32 nHandle);
|
|
|
|
const PathSettings::PathInfo* impl_getPathAccessConst(sal_Int32 nHandle) const;
|
|
|
|
|
|
|
|
/** it checks, if the given path value seams to be a valid URL or system path. */
|
|
|
|
sal_Bool impl_isValidPath(const ::rtl::OUString& sPath) const;
|
|
|
|
sal_Bool impl_isValidPath(const OUStringList& lPath) const;
|
|
|
|
|
|
|
|
void impl_storePath(const PathSettings::PathInfo& aPath);
|
|
|
|
|
|
|
|
css::uno::Sequence< sal_Int32 > impl_mapPathName2IDList(const ::rtl::OUString& sPath);
|
|
|
|
|
|
|
|
void impl_notifyPropListener( PathSettings::EChangeOp eOp ,
|
|
|
|
const ::rtl::OUString& sPath ,
|
|
|
|
const PathSettings::PathInfo* pPathOld,
|
|
|
|
const PathSettings::PathInfo* pPathNew);
|
|
|
|
|
|
|
|
|
2002-08-20 04:21:59 -05:00
|
|
|
// OPropertySetHelper
|
|
|
|
virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue ,
|
|
|
|
css::uno::Any& aOldValue ,
|
|
|
|
sal_Int32 nHandle ,
|
2003-03-25 11:22:13 -06:00
|
|
|
const css::uno::Any& aValue ) throw(css::lang::IllegalArgumentException);
|
2002-08-20 04:21:59 -05:00
|
|
|
virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
|
2003-03-25 11:22:13 -06:00
|
|
|
const css::uno::Any& aValue ) throw(css::uno::Exception);
|
2006-06-19 05:00:54 -05:00
|
|
|
using cppu::OPropertySetHelper::getFastPropertyValue;
|
2002-08-20 04:21:59 -05:00
|
|
|
virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue ,
|
|
|
|
sal_Int32 nHandle ) const;
|
|
|
|
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( );
|
2003-03-25 11:22:13 -06:00
|
|
|
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo ( ) throw(::com::sun::star::uno::RuntimeException);
|
2002-08-20 04:21:59 -05:00
|
|
|
|
2006-07-13 06:03:39 -05:00
|
|
|
/** factory methods to guarantee right (but on demand) initialized members ... */
|
|
|
|
css::uno::Reference< css::util::XStringSubstitution > fa_getSubstitution();
|
|
|
|
css::uno::Reference< css::container::XNameAccess > fa_getCfgOld();
|
|
|
|
css::uno::Reference< css::container::XNameAccess > fa_getCfgNew();
|
2002-08-20 04:21:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace framework
|
|
|
|
|
|
|
|
#endif // __FRAMEWORK_SERVICES_PATHSETTINGS_HXX_
|