filter/source/config/cache/cacheupdatelistener.cxx | 2 filter/source/config/cache/filtercache.cxx | 2 framework/inc/jobs/jobdispatch.hxx | 2 framework/source/accelerators/acceleratorconfiguration.cxx | 2 framework/source/fwi/classes/protocolhandlercache.cxx | 8 framework/source/fwi/jobs/configaccess.cxx | 2 framework/source/jobs/jobdata.cxx | 2 framework/source/jobs/jobexecutor.cxx | 2 framework/source/services/pathsettings.cxx | 2 svtools/source/config/colorcfg.cxx | 2 svtools/source/config/extcolorcfg.cxx | 2 sw/source/ui/envelp/labelcfg.cxx | 2 unotools/Library_utl.mk | 2 unotools/Package_inc.mk | 2 unotools/inc/unotools/configpathes.hxx | 183 ------- unotools/inc/unotools/configpaths.hxx | 183 +++++++ unotools/inc/unotools/pathoptions.hxx | 4 unotools/source/config/configitem.cxx | 2 unotools/source/config/confignode.cxx | 2 unotools/source/config/configpathes.cxx | 309 ------------- unotools/source/config/configpaths.cxx | 309 +++++++++++++ unotools/source/config/defaultoptions.cxx | 2 unotools/source/config/fontcfg.cxx | 2 unotools/source/config/pathoptions.cxx | 16 unotools/source/config/viewoptions.cxx | 2 25 files changed, 524 insertions(+), 524 deletions(-)
New commits: commit 238ad07d7aa56231ff1a6f812656f89f1c193d73 Author: Tor Lillqvist <t...@iki.fi> Date: Mon Apr 9 13:53:34 2012 +0300 s/pathes/paths/ diff --git a/unotools/inc/unotools/pathoptions.hxx b/unotools/inc/unotools/pathoptions.hxx index 2ed1178..d74e4ae 100644 --- a/unotools/inc/unotools/pathoptions.hxx +++ b/unotools/inc/unotools/pathoptions.hxx @@ -44,7 +44,7 @@ private: SvtPathOptions_Impl* pImp; public: - enum Pathes + enum Paths { PATH_ADDIN, PATH_AUTOCORRECT, @@ -129,7 +129,7 @@ public: String SubstituteVariable( const String& rVar ) const; String ExpandMacros( const String& rPath ) const; String UseVariable( const String& rVar ) const; - sal_Bool SearchFile( String& rIniFile, Pathes ePath = PATH_USERCONFIG ); + sal_Bool SearchFile( String& rIniFile, Paths ePath = PATH_USERCONFIG ); ::com::sun::star::lang::Locale GetLocale() const; sal_Bool IsReadonly() const; }; diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx index cb68c88..90261df 100644 --- a/unotools/source/config/defaultoptions.cxx +++ b/unotools/source/config/defaultoptions.cxx @@ -118,7 +118,7 @@ typedef String SvtDefaultOptions_Impl:: *PathStrPtr; struct PathToDefaultMapping_Impl { - SvtPathOptions::Pathes _ePath; + SvtPathOptions::Paths _ePath; PathStrPtr _pDefaultPath; }; diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx index f743bf7..4435830 100644 --- a/unotools/source/config/pathoptions.cxx +++ b/unotools/source/config/pathoptions.cxx @@ -130,7 +130,7 @@ class SvtPathOptions_Impl SvtPathOptions_Impl(); // get the paths, not const because of using a mutex - const String& GetPath( SvtPathOptions::Pathes ); + const String& GetPath( SvtPathOptions::Paths ); const String& GetAddinPath() { return GetPath( SvtPathOptions::PATH_ADDIN ); } const String& GetAutoCorrectPath() { return GetPath( SvtPathOptions::PATH_AUTOCORRECT ); } const String& GetAutoTextPath() { return GetPath( SvtPathOptions::PATH_AUTOTEXT ); } @@ -157,7 +157,7 @@ class SvtPathOptions_Impl const String& GetFingerprintPath() { return GetPath( SvtPathOptions::PATH_FINGERPRINT ); } // set the paths - void SetPath( SvtPathOptions::Pathes, const String& rNewPath ); + void SetPath( SvtPathOptions::Paths, const String& rNewPath ); void SetAddinPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_ADDIN, rPath ); } void SetAutoCorrectPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOCORRECT, rPath ); } void SetAutoTextPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOTEXT, rPath ); } @@ -197,7 +197,7 @@ static sal_Int32 nRefCount = 0; struct PropertyStruct { const char* pPropName; // The ascii name of the Office path - SvtPathOptions::Pathes ePath; // The enum value used by SvtPathOptions + SvtPathOptions::Paths ePath; // The enum value used by SvtPathOptions }; struct VarNameAttribute @@ -244,7 +244,7 @@ static VarNameAttribute aVarNameAttribute[] = // class SvtPathOptions_Impl --------------------------------------------- -const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath ) +const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath ) { if ( ePath >= SvtPathOptions::PATH_COUNT ) return m_aEmptyString; @@ -268,7 +268,7 @@ const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath ) ePath == SvtPathOptions::PATH_STORAGE ) { - // These office paths have to be converted to system pathes + // These office paths have to be converted to system pates utl::LocalFileHelper::ConvertURLToPhysicalName( aPathValue, aResult ); aPathValue = aResult; } @@ -283,7 +283,7 @@ const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath ) return m_aEmptyString; } -void SvtPathOptions_Impl::SetPath( SvtPathOptions::Pathes ePath, const String& rNewPath ) +void SvtPathOptions_Impl::SetPath( SvtPathOptions::Paths ePath, const String& rNewPath ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -457,7 +457,7 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() : aTempHashMap.insert( NameToHandleMap::value_type( aProperty.Name, aProperty.Handle )); } - // Create mapping between internal enum (SvtPathOptions::Pathes) and property handle + // Create mapping between internal enum (SvtPathOptions::Paths) and property handle sal_Int32 nCount = sizeof( aPropNames ) / sizeof( PropertyStruct ); sal_Int32 i; for ( i = 0; i < nCount; i++ ) @@ -866,7 +866,7 @@ String SvtPathOptions::UseVariable( const String& rPath ) const // ----------------------------------------------------------------------- -sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath ) +sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Paths ePath ) { // check parameter: empty inifile name? if ( !rIniFile.Len() ) commit 383a9c777f1e9d60584d3b1c26a1440e6bef3fa5 Author: Tor Lillqvist <t...@iki.fi> Date: Mon Apr 9 13:43:22 2012 +0300 s/pathes/paths/ diff --git a/filter/source/config/cache/cacheupdatelistener.cxx b/filter/source/config/cache/cacheupdatelistener.cxx index 0999722..1e09df3 100644 --- a/filter/source/config/cache/cacheupdatelistener.cxx +++ b/filter/source/config/cache/cacheupdatelistener.cxx @@ -35,7 +35,7 @@ #include <com/sun/star/util/XChangesNotifier.hpp> #include <com/sun/star/util/XRefreshable.hpp> #include <salhelper/singletonref.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustring.hxx> //_______________________________________________ diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 9c2481a..1da6f14 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -54,7 +54,7 @@ #include <comphelper/locale.hxx> #include <comphelper/processfactory.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/logfile.hxx> #include <rtl/uri.hxx> diff --git a/framework/inc/jobs/jobdispatch.hxx b/framework/inc/jobs/jobdispatch.hxx index 78c1535..b002332 100644 --- a/framework/inc/jobs/jobdispatch.hxx +++ b/framework/inc/jobs/jobdispatch.hxx @@ -60,7 +60,7 @@ //_______________________________________ // other includes -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <cppuhelper/weak.hxx> #include <rtl/ustring.hxx> diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index ed3d0ca..3fd5c72 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -63,7 +63,7 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> #include <comphelper/configurationhelper.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/logfile.hxx> #include <svtools/acceleratorexecute.hxx> #include <stdio.h> diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx index 229767c..c7e1a8d 100644 --- a/framework/source/fwi/classes/protocolhandlercache.cxx +++ b/framework/source/fwi/classes/protocolhandlercache.cxx @@ -51,7 +51,7 @@ // other includes //_________________________________________________________________________________________________________________ #include <tools/wldcrd.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> //_________________________________________________________________________________________________________________ diff --git a/framework/source/fwi/jobs/configaccess.cxx b/framework/source/fwi/jobs/configaccess.cxx index f39bda8..b6e1316 100644 --- a/framework/source/fwi/jobs/configaccess.cxx +++ b/framework/source/fwi/jobs/configaccess.cxx @@ -46,7 +46,7 @@ //________________________________ // includes of other projects -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> //________________________________ diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index d059fd4..bf1925a 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -46,7 +46,7 @@ //________________________________ // includes of other projects #include <tools/wldcrd.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 9fe0b3d..e41c518 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -50,7 +50,7 @@ //________________________________ // includes of other projects -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx index 9bdd098..8d74d71 100644 --- a/framework/source/services/pathsettings.cxx +++ b/framework/source/services/pathsettings.cxx @@ -56,7 +56,7 @@ #include <rtl/logfile.hxx> #include <comphelper/configurationhelper.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <fwkdllapi.h> diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 7c8d59b..41fc238 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -33,7 +33,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <unotools/configitem.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <com/sun/star/uno/Sequence.h> #include <svl/poolitem.hxx> //Any2Bool #include <svl/smplhint.hxx> diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index f612aab..6fc1a34 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -33,7 +33,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <tools/color.hxx> #include <unotools/configitem.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <com/sun/star/uno/Sequence.h> #include <svl/poolitem.hxx> //Any2Bool #include <svl/smplhint.hxx> diff --git a/sw/source/ui/envelp/labelcfg.cxx b/sw/source/ui/envelp/labelcfg.cxx index 04a8695..3ee9fe3 100644 --- a/sw/source/ui/envelp/labelcfg.cxx +++ b/sw/source/ui/envelp/labelcfg.cxx @@ -32,7 +32,7 @@ #include <labelcfg.hxx> #include <labimp.hxx> #include <comphelper/string.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <unomid.h> diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index da53b60..69708a1 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -78,7 +78,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\ unotools/source/config/configitem \ unotools/source/config/configmgr \ unotools/source/config/confignode \ - unotools/source/config/configpathes \ + unotools/source/config/configpaths \ unotools/source/config/configvaluecontainer \ unotools/source/config/defaultoptions \ unotools/source/config/docinfohelper \ diff --git a/unotools/Package_inc.mk b/unotools/Package_inc.mk index 5925034..1812cb5 100644 --- a/unotools/Package_inc.mk +++ b/unotools/Package_inc.mk @@ -43,7 +43,7 @@ $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/componentresmodule.h $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/configitem.hxx,unotools/configitem.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/configmgr.hxx,unotools/configmgr.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/confignode.hxx,unotools/confignode.hxx)) -$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/configpathes.hxx,unotools/configpathes.hxx)) +$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/configpaths.hxx,unotools/configpaths.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/configvaluecontainer.hxx,unotools/configvaluecontainer.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/datetime.hxx,unotools/datetime.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/defaultoptions.hxx,unotools/defaultoptions.hxx)) diff --git a/unotools/inc/unotools/configpathes.hxx b/unotools/inc/unotools/configpathes.hxx deleted file mode 100644 index 258ea01..0000000 --- a/unotools/inc/unotools/configpathes.hxx +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "unotools/unotoolsdllapi.h" - -#ifndef UNOTOOLS_CONFIGPATHES_HXX_INCLUDED -#define UNOTOOLS_CONFIGPATHES_HXX_INCLUDED -#include <sal/types.h> - -namespace rtl -{ - class OUString; -} - -//---------------------------------------------------------------------------- -namespace utl -{ -//---------------------------------------------------------------------------- - /** extract the local nodename and the parent nodepath - from a configuration path. - - @param _sInPath - A configuration path that is not an empty or root path.<BR/> - If this is not a valid configuration path, it is interpreted as - local name of a node. - - @param _rsOutPath - On exit: The configuration path obtained by dropping - the last level off <var>_sInPath</var>.<BR/> - If <var>_sInPath</var> could not be parsed as a valid - configuration path, this is set to an empty string. - - @param _rsLocalName - On exit: The plain (non-escaped) name of the node identified by - <var>_sInPath</var>. <BR/> - If <var>_sInPath</var> could not be parsed as a valid - configuration path, this is set to <var>_sInPath</var>. - - @returns - <TRUE/>, if a parent path could be set - <FALSE/>, if the path was a one-level path or an invalid path - - */ - UNOTOOLS_DLLPUBLIC sal_Bool splitLastFromConfigurationPath(::rtl::OUString const& _sInPath, - ::rtl::OUString& _rsOutPath, - ::rtl::OUString& _rsLocalName); - -//---------------------------------------------------------------------------- - /** extract the first nodename from a configuration path. - - @param _sInPath - A relative configuration path that is not empty.<BR/> - If this is not a valid configuration path, it is interpreted as - a single name of a node. - - @param _sOutPath - If non-null, contains the remainder of the path upon return. - - @returns - The plain (non-escaped) name of the node that is the first step - when traversing <var>_sInPath</var>.<BR/> - If <var>_sInPath</var> could not be parsed as a valid - configuration path, it is returned unaltered. - - */ - UNOTOOLS_DLLPUBLIC ::rtl::OUString extractFirstFromConfigurationPath( - ::rtl::OUString const& _sInPath, ::rtl::OUString* _sOutPath = 0); - -//---------------------------------------------------------------------------- - /** check whether a path is to a nested node with respect to a parent path. - - @param _sNestedPath - A configuration path that maybe points to a descendant of the node - identified by <var>_sPrefixPath</var>, with both paths starting - from the same node (or both being absolute). - - @param _sPrefixPath - A configuration path.<BR/> - If this path is absolute, <var>_sNestedPath</var> should be absolute; - If this path is relative, <var>_sNestedPath</var> should be relative; - If this path is empty, <var>_sNestedPath</var> may start with a '/', - which is disregarded. - - @returns - <TRUE/>, if <var>_sPrefixPath</var> is a prefix of <var>_sNestedPath</var>; - <FALSE/> otherwise.<BR/> - If both paths are equal <TRUE/> is returned. - - */ - sal_Bool isPrefixOfConfigurationPath(::rtl::OUString const& _sNestedPath, - ::rtl::OUString const& _sPrefixPath); - -//---------------------------------------------------------------------------- - /** get the relative path to a nested node with respect to a parent path. - - @param _sNestedPath - A configuration path that points to a descendant of the node - identified by <var>_sPrefixPath</var>, with both paths starting - from the same node (or both being absolute). - - @param _sPrefixPath - A configuration path.<BR/> - If this path is absolute, <var>_sNestedPath</var> must be absolute; - If this path is relative, <var>_sNestedPath</var> must be relative; - If this path is empty, <var>_sNestedPath</var> may start with a '/', - which is stripped. - - @returns - The remaining relative path from the target of <var>_sPrefixPath</var> - to the target of <var>_sNestedPath</var>.<BR/> - If <var>_sPrefixPath</var> is not a prefix of <var>_sNestedPath</var>, - <var>_sNestedPath</var> is returned unaltered. - - */ - UNOTOOLS_DLLPUBLIC ::rtl::OUString dropPrefixFromConfigurationPath(::rtl::OUString const& _sNestedPath, - ::rtl::OUString const& _sPrefixPath); - -//---------------------------------------------------------------------------- - /** Create a one-level relative configuration path from a set element name - without a known set element type. - - @param _sElementName - An arbitrary string that is to be interpreted as - name of a configuration set element. - - @returns - A one-level relative path to the element, of the form - "*['<Name>']", where <Name> is properly escaped. - - */ - UNOTOOLS_DLLPUBLIC ::rtl::OUString wrapConfigurationElementName(::rtl::OUString const& _sElementName); - -//---------------------------------------------------------------------------- - /** Create a one-level relative configuration path from a set element name - and a known set element type. - - @param _sElementName - An arbitrary string that is to be interpreted as - name of a configuration set element. - - @param _sTypeName - An string identifying the type of the element. Usually this is be - the name of the element-template of the set.<BR/> - - @returns - A one-level relative path to the element, of the form - "<Type>['<Name>']", where <Name> is properly escaped. - - */ - ::rtl::OUString wrapConfigurationElementName(::rtl::OUString const& _sElementName, - ::rtl::OUString const& _sTypeName); - -//---------------------------------------------------------------------------- -} // namespace utl -//---------------------------------------------------------------------------- - -#endif // UNOTOOLS_CONFIGPATHES_HXX_INCLUDED - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/inc/unotools/configpaths.hxx b/unotools/inc/unotools/configpaths.hxx new file mode 100644 index 0000000..1102634 --- /dev/null +++ b/unotools/inc/unotools/configpaths.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "unotools/unotoolsdllapi.h" + +#ifndef UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#define UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#include <sal/types.h> + +namespace rtl +{ + class OUString; +} + +//---------------------------------------------------------------------------- +namespace utl +{ +//---------------------------------------------------------------------------- + /** extract the local nodename and the parent nodepath + from a configuration path. + + @param _sInPath + A configuration path that is not an empty or root path.<BR/> + If this is not a valid configuration path, it is interpreted as + local name of a node. + + @param _rsOutPath + On exit: The configuration path obtained by dropping + the last level off <var>_sInPath</var>.<BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, this is set to an empty string. + + @param _rsLocalName + On exit: The plain (non-escaped) name of the node identified by + <var>_sInPath</var>. <BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, this is set to <var>_sInPath</var>. + + @returns + <TRUE/>, if a parent path could be set + <FALSE/>, if the path was a one-level path or an invalid path + + */ + UNOTOOLS_DLLPUBLIC sal_Bool splitLastFromConfigurationPath(::rtl::OUString const& _sInPath, + ::rtl::OUString& _rsOutPath, + ::rtl::OUString& _rsLocalName); + +//---------------------------------------------------------------------------- + /** extract the first nodename from a configuration path. + + @param _sInPath + A relative configuration path that is not empty.<BR/> + If this is not a valid configuration path, it is interpreted as + a single name of a node. + + @param _sOutPath + If non-null, contains the remainder of the path upon return. + + @returns + The plain (non-escaped) name of the node that is the first step + when traversing <var>_sInPath</var>.<BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, it is returned unaltered. + + */ + UNOTOOLS_DLLPUBLIC ::rtl::OUString extractFirstFromConfigurationPath( + ::rtl::OUString const& _sInPath, ::rtl::OUString* _sOutPath = 0); + +//---------------------------------------------------------------------------- + /** check whether a path is to a nested node with respect to a parent path. + + @param _sNestedPath + A configuration path that maybe points to a descendant of the node + identified by <var>_sPrefixPath</var>, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.<BR/> + If this path is absolute, <var>_sNestedPath</var> should be absolute; + If this path is relative, <var>_sNestedPath</var> should be relative; + If this path is empty, <var>_sNestedPath</var> may start with a '/', + which is disregarded. + + @returns + <TRUE/>, if <var>_sPrefixPath</var> is a prefix of <var>_sNestedPath</var>; + <FALSE/> otherwise.<BR/> + If both paths are equal <TRUE/> is returned. + + */ + sal_Bool isPrefixOfConfigurationPath(::rtl::OUString const& _sNestedPath, + ::rtl::OUString const& _sPrefixPath); + +//---------------------------------------------------------------------------- + /** get the relative path to a nested node with respect to a parent path. + + @param _sNestedPath + A configuration path that points to a descendant of the node + identified by <var>_sPrefixPath</var>, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.<BR/> + If this path is absolute, <var>_sNestedPath</var> must be absolute; + If this path is relative, <var>_sNestedPath</var> must be relative; + If this path is empty, <var>_sNestedPath</var> may start with a '/', + which is stripped. + + @returns + The remaining relative path from the target of <var>_sPrefixPath</var> + to the target of <var>_sNestedPath</var>.<BR/> + If <var>_sPrefixPath</var> is not a prefix of <var>_sNestedPath</var>, + <var>_sNestedPath</var> is returned unaltered. + + */ + UNOTOOLS_DLLPUBLIC ::rtl::OUString dropPrefixFromConfigurationPath(::rtl::OUString const& _sNestedPath, + ::rtl::OUString const& _sPrefixPath); + +//---------------------------------------------------------------------------- + /** Create a one-level relative configuration path from a set element name + without a known set element type. + + @param _sElementName + An arbitrary string that is to be interpreted as + name of a configuration set element. + + @returns + A one-level relative path to the element, of the form + "*['<Name>']", where <Name> is properly escaped. + + */ + UNOTOOLS_DLLPUBLIC ::rtl::OUString wrapConfigurationElementName(::rtl::OUString const& _sElementName); + +//---------------------------------------------------------------------------- + /** Create a one-level relative configuration path from a set element name + and a known set element type. + + @param _sElementName + An arbitrary string that is to be interpreted as + name of a configuration set element. + + @param _sTypeName + An string identifying the type of the element. Usually this is be + the name of the element-template of the set.<BR/> + + @returns + A one-level relative path to the element, of the form + "<Type>['<Name>']", where <Name> is properly escaped. + + */ + ::rtl::OUString wrapConfigurationElementName(::rtl::OUString const& _sElementName, + ::rtl::OUString const& _sTypeName); + +//---------------------------------------------------------------------------- +} // namespace utl +//---------------------------------------------------------------------------- + +#endif // UNOTOOLS_CONFIGPATHS_HXX_INCLUDED + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index 615eb03..3aaeaf6 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -28,7 +28,7 @@ #include "unotools/configitem.hxx" #include "unotools/configmgr.hxx" -#include "unotools/configpathes.hxx" +#include "unotools/configpaths.hxx" #include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp> diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index 68f6e92..9888490 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -28,7 +28,7 @@ #include <unotools/confignode.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <tools/diagnose_ex.h> #include <osl/diagnose.h> #include <com/sun/star/container/XHierarchicalName.hpp> diff --git a/unotools/source/config/configpathes.cxx b/unotools/source/config/configpathes.cxx deleted file mode 100644 index 8973e63..0000000 --- a/unotools/source/config/configpathes.cxx +++ /dev/null @@ -1,309 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "unotools/configpathes.hxx" -#include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> -#include <osl/diagnose.h> - -//---------------------------------------------------------------------------- -namespace utl -{ -//---------------------------------------------------------------------------- - - using ::rtl::OUString; - using ::rtl::OUStringBuffer; - -//---------------------------------------------------------------------------- - -static -void lcl_resolveCharEntities(OUString & aLocalString) -{ - sal_Int32 nEscapePos=aLocalString.indexOf('&'); - if (nEscapePos < 0) return; - - OUStringBuffer aResult; - sal_Int32 nStart = 0; - - do - { - sal_Unicode ch = 0; - if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("&"),nEscapePos)) - ch = '&'; - - else if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("'"),nEscapePos)) - ch = '\''; - - else if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("""),nEscapePos)) - ch = '"'; - - OSL_ENSURE(ch,"Configuration path contains '&' that is not part of a valid character escape"); - if (ch) - { - aResult.append(aLocalString.copy(nStart,nEscapePos-nStart)).append(ch); - - sal_Int32 nEscapeEnd=aLocalString.indexOf(';',nEscapePos); - nStart = nEscapeEnd+1; - nEscapePos=aLocalString.indexOf('&',nStart); - } - else - { - nEscapePos=aLocalString.indexOf('&',nEscapePos+1); - } - } - while ( nEscapePos > 0); - - aResult.append(aLocalString.copy(nStart)); - - aLocalString = aResult.makeStringAndClear(); -} - -//---------------------------------------------------------------------------- -sal_Bool splitLastFromConfigurationPath(OUString const& _sInPath, - OUString& _rsOutPath, - OUString& _rsLocalName) -{ - sal_Int32 nStart,nEnd; - - sal_Int32 nPos = _sInPath.getLength()-1; - - // strip trailing slash - if (nPos > 0 && _sInPath[ nPos ] == sal_Unicode('/')) - { - OSL_FAIL("Invalid config path: trailing '/' is not allowed"); - --nPos; - } - - // check for predicate ['xxx'] or ["yyy"] - if (nPos > 0 && _sInPath[ nPos ] == sal_Unicode(']')) - { - sal_Unicode chQuote = _sInPath[--nPos]; - - if (chQuote == '\'' || chQuote == '\"') - { - nEnd = nPos; - nPos = _sInPath.lastIndexOf(chQuote,nEnd); - nStart = nPos + 1; - --nPos; // nPos = rInPath.lastIndexOf('[',nPos); - } - else // allow [xxx] - { - nEnd = nPos + 1; - nPos = _sInPath.lastIndexOf('[',nEnd); - nStart = nPos + 1; - } - - OSL_ENSURE(nPos >= 0 && _sInPath[nPos] == '[', "Invalid config path: unmatched quotes or brackets"); - if (nPos >= 0 && _sInPath[nPos] == '[') - { - nPos = _sInPath.lastIndexOf('/',nPos); - } - else // defined behavior for invalid paths - { - nStart = 0, nEnd = _sInPath.getLength(); - nPos = -1; - } - - } - else - { - nEnd = nPos+1; - nPos = _sInPath.lastIndexOf('/',nEnd); - nStart = nPos + 1; - } - OSL_ASSERT( -1 <= nPos && - nPos < nStart && - nStart < nEnd && - nEnd <= _sInPath.getLength() ); - - OSL_ASSERT(nPos == -1 || _sInPath[nPos] == '/'); - OSL_ENSURE(nPos != 0 , "Invalid config child path: immediate child of root"); - - _rsLocalName = _sInPath.copy(nStart, nEnd-nStart); - _rsOutPath = (nPos > 0) ? _sInPath.copy(0,nPos) : OUString(); - lcl_resolveCharEntities(_rsLocalName); - - return nPos >= 0; -} - -//---------------------------------------------------------------------------- -OUString extractFirstFromConfigurationPath(OUString const& _sInPath, OUString* _sOutPath) -{ - sal_Int32 nSep = _sInPath.indexOf('/'); - sal_Int32 nBracket = _sInPath.indexOf('['); - - sal_Int32 nStart = nBracket + 1; - sal_Int32 nEnd = nSep; - - if (0 <= nBracket) // found a bracket-quoted relative path - { - if (nSep < 0 || nBracket < nSep) // and the separator comes after it - { - sal_Unicode chQuote = _sInPath[nStart]; - if (chQuote == '\'' || chQuote == '\"') - { - ++nStart; - nEnd = _sInPath.indexOf(chQuote, nStart+1); - nBracket = nEnd+1; - } - else - { - nEnd = _sInPath.indexOf(']',nStart); - nBracket = nEnd; - } - OSL_ENSURE(nEnd > nStart && _sInPath[nBracket] == ']', "Invalid config path: improper mismatch of quote or bracket"); - OSL_ENSURE((nBracket+1 == _sInPath.getLength() && nSep == -1) || (_sInPath[nBracket+1] == '/' && nSep == nBracket+1), "Invalid config path: brackets not followed by slash"); - } - else // ... but our initial element name is in simple form - nStart = 0; - } - - OUString sResult = (nEnd >= 0) ? _sInPath.copy(nStart, nEnd-nStart) : _sInPath; - lcl_resolveCharEntities(sResult); - - if (_sOutPath != 0) - { - *_sOutPath = (nSep >= 0) ? _sInPath.copy(nSep + 1) : OUString(); - } - - return sResult; -} - -//---------------------------------------------------------------------------- - -// find the position after the prefix in the nested path -static inline -sal_Int32 lcl_findPrefixEnd(OUString const& _sNestedPath, OUString const& _sPrefixPath) -{ - // TODO: currently handles only exact prefix matches - sal_Int32 nPrefixLength = _sPrefixPath.getLength(); - - OSL_ENSURE(nPrefixLength == 0 || _sPrefixPath[nPrefixLength-1] != '/', - "Cannot handle slash-terminated prefix paths"); - - sal_Bool bIsPrefix; - if (_sNestedPath.getLength() > nPrefixLength) - { - bIsPrefix = _sNestedPath[nPrefixLength] == '/' && - _sNestedPath.compareTo(_sPrefixPath,nPrefixLength) == 0; - ++nPrefixLength; - } - else if (_sNestedPath.getLength() == nPrefixLength) - { - bIsPrefix = _sNestedPath.equals(_sPrefixPath); - } - else - { - bIsPrefix = false; - } - - return bIsPrefix ? nPrefixLength : 0; -} - -//---------------------------------------------------------------------------- -sal_Bool isPrefixOfConfigurationPath(OUString const& _sNestedPath, - OUString const& _sPrefixPath) -{ - return _sPrefixPath.isEmpty() || lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) != 0; -} - -//---------------------------------------------------------------------------- -OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, - OUString const& _sPrefixPath) -{ - if ( sal_Int32 nPrefixEnd = lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) ) - { - return _sNestedPath.copy(nPrefixEnd); - } - else - { - OSL_ENSURE(_sPrefixPath.isEmpty(), "Path does not start with expected prefix"); - - return _sNestedPath; - } -} - -//---------------------------------------------------------------------------- -static -OUString lcl_wrapName(const OUString& _sContent, const OUString& _sType) -{ - const sal_Unicode * const pBeginContent = _sContent.getStr(); - const sal_Unicode * const pEndContent = pBeginContent + _sContent.getLength(); - - OSL_PRECOND(!_sType.isEmpty(), "Unexpected config type name: empty"); - OSL_PRECOND(pBeginContent <= pEndContent, "Invalid config name: empty"); - - if (pBeginContent == pEndContent) - return _sType; - - rtl::OUStringBuffer aNormalized(_sType.getLength() + _sContent.getLength() + 4); // reserve approximate size initially - - // prefix: type, opening bracket and quote - aNormalized.append( _sType ).appendAscii( RTL_CONSTASCII_STRINGPARAM("['") ); - - // content: copy over each char and handle escaping - for(const sal_Unicode* pCur = pBeginContent; pCur != pEndContent; ++pCur) - { - // append (escape if needed) - switch(*pCur) - { - case sal_Unicode('&') : aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("&") ); break; - case sal_Unicode('\''): aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("'") ); break; - case sal_Unicode('\"'): aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM(""") ); break; - - default: aNormalized.append( *pCur ); - } - } - - // suffix: closing quote and bracket - aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("']") ); - - return aNormalized.makeStringAndClear(); -} - -//---------------------------------------------------------------------------- - -OUString wrapConfigurationElementName(OUString const& _sElementName) -{ - return lcl_wrapName(_sElementName, OUString(RTL_CONSTASCII_USTRINGPARAM("*")) ); -} - -//---------------------------------------------------------------------------- - -OUString wrapConfigurationElementName(OUString const& _sElementName, - OUString const& _sTypeName) -{ - // todo: check that _sTypeName is valid - return lcl_wrapName(_sElementName, _sTypeName); -} - -//---------------------------------------------------------------------------- -} // namespace utl - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/configpaths.cxx b/unotools/source/config/configpaths.cxx new file mode 100644 index 0000000..aa40b53 --- /dev/null +++ b/unotools/source/config/configpaths.cxx @@ -0,0 +1,309 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "unotools/configpaths.hxx" +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> + +//---------------------------------------------------------------------------- +namespace utl +{ +//---------------------------------------------------------------------------- + + using ::rtl::OUString; + using ::rtl::OUStringBuffer; + +//---------------------------------------------------------------------------- + +static +void lcl_resolveCharEntities(OUString & aLocalString) +{ + sal_Int32 nEscapePos=aLocalString.indexOf('&'); + if (nEscapePos < 0) return; + + OUStringBuffer aResult; + sal_Int32 nStart = 0; + + do + { + sal_Unicode ch = 0; + if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("&"),nEscapePos)) + ch = '&'; + + else if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("'"),nEscapePos)) + ch = '\''; + + else if (aLocalString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("""),nEscapePos)) + ch = '"'; + + OSL_ENSURE(ch,"Configuration path contains '&' that is not part of a valid character escape"); + if (ch) + { + aResult.append(aLocalString.copy(nStart,nEscapePos-nStart)).append(ch); + + sal_Int32 nEscapeEnd=aLocalString.indexOf(';',nEscapePos); + nStart = nEscapeEnd+1; + nEscapePos=aLocalString.indexOf('&',nStart); + } + else + { + nEscapePos=aLocalString.indexOf('&',nEscapePos+1); + } + } + while ( nEscapePos > 0); + + aResult.append(aLocalString.copy(nStart)); + + aLocalString = aResult.makeStringAndClear(); +} + +//---------------------------------------------------------------------------- +sal_Bool splitLastFromConfigurationPath(OUString const& _sInPath, + OUString& _rsOutPath, + OUString& _rsLocalName) +{ + sal_Int32 nStart,nEnd; + + sal_Int32 nPos = _sInPath.getLength()-1; + + // strip trailing slash + if (nPos > 0 && _sInPath[ nPos ] == sal_Unicode('/')) + { + OSL_FAIL("Invalid config path: trailing '/' is not allowed"); + --nPos; + } + + // check for predicate ['xxx'] or ["yyy"] + if (nPos > 0 && _sInPath[ nPos ] == sal_Unicode(']')) + { + sal_Unicode chQuote = _sInPath[--nPos]; + + if (chQuote == '\'' || chQuote == '\"') + { + nEnd = nPos; + nPos = _sInPath.lastIndexOf(chQuote,nEnd); + nStart = nPos + 1; + --nPos; // nPos = rInPath.lastIndexOf('[',nPos); + } + else // allow [xxx] + { + nEnd = nPos + 1; + nPos = _sInPath.lastIndexOf('[',nEnd); + nStart = nPos + 1; + } + + OSL_ENSURE(nPos >= 0 && _sInPath[nPos] == '[', "Invalid config path: unmatched quotes or brackets"); + if (nPos >= 0 && _sInPath[nPos] == '[') + { + nPos = _sInPath.lastIndexOf('/',nPos); + } + else // defined behavior for invalid paths + { + nStart = 0, nEnd = _sInPath.getLength(); + nPos = -1; + } + + } + else + { + nEnd = nPos+1; + nPos = _sInPath.lastIndexOf('/',nEnd); + nStart = nPos + 1; + } + OSL_ASSERT( -1 <= nPos && + nPos < nStart && + nStart < nEnd && + nEnd <= _sInPath.getLength() ); + + OSL_ASSERT(nPos == -1 || _sInPath[nPos] == '/'); + OSL_ENSURE(nPos != 0 , "Invalid config child path: immediate child of root"); + + _rsLocalName = _sInPath.copy(nStart, nEnd-nStart); + _rsOutPath = (nPos > 0) ? _sInPath.copy(0,nPos) : OUString(); + lcl_resolveCharEntities(_rsLocalName); + + return nPos >= 0; +} + +//---------------------------------------------------------------------------- +OUString extractFirstFromConfigurationPath(OUString const& _sInPath, OUString* _sOutPath) +{ + sal_Int32 nSep = _sInPath.indexOf('/'); + sal_Int32 nBracket = _sInPath.indexOf('['); + + sal_Int32 nStart = nBracket + 1; + sal_Int32 nEnd = nSep; + + if (0 <= nBracket) // found a bracket-quoted relative path + { + if (nSep < 0 || nBracket < nSep) // and the separator comes after it + { + sal_Unicode chQuote = _sInPath[nStart]; + if (chQuote == '\'' || chQuote == '\"') + { + ++nStart; + nEnd = _sInPath.indexOf(chQuote, nStart+1); + nBracket = nEnd+1; + } + else + { + nEnd = _sInPath.indexOf(']',nStart); + nBracket = nEnd; + } + OSL_ENSURE(nEnd > nStart && _sInPath[nBracket] == ']', "Invalid config path: improper mismatch of quote or bracket"); + OSL_ENSURE((nBracket+1 == _sInPath.getLength() && nSep == -1) || (_sInPath[nBracket+1] == '/' && nSep == nBracket+1), "Invalid config path: brackets not followed by slash"); + } + else // ... but our initial element name is in simple form + nStart = 0; + } + + OUString sResult = (nEnd >= 0) ? _sInPath.copy(nStart, nEnd-nStart) : _sInPath; + lcl_resolveCharEntities(sResult); + + if (_sOutPath != 0) + { + *_sOutPath = (nSep >= 0) ? _sInPath.copy(nSep + 1) : OUString(); + } + + return sResult; +} + +//---------------------------------------------------------------------------- + +// find the position after the prefix in the nested path +static inline +sal_Int32 lcl_findPrefixEnd(OUString const& _sNestedPath, OUString const& _sPrefixPath) +{ + // TODO: currently handles only exact prefix matches + sal_Int32 nPrefixLength = _sPrefixPath.getLength(); + + OSL_ENSURE(nPrefixLength == 0 || _sPrefixPath[nPrefixLength-1] != '/', + "Cannot handle slash-terminated prefix paths"); + + sal_Bool bIsPrefix; + if (_sNestedPath.getLength() > nPrefixLength) + { + bIsPrefix = _sNestedPath[nPrefixLength] == '/' && + _sNestedPath.compareTo(_sPrefixPath,nPrefixLength) == 0; + ++nPrefixLength; + } + else if (_sNestedPath.getLength() == nPrefixLength) + { + bIsPrefix = _sNestedPath.equals(_sPrefixPath); + } + else + { + bIsPrefix = false; + } + + return bIsPrefix ? nPrefixLength : 0; +} + +//---------------------------------------------------------------------------- +sal_Bool isPrefixOfConfigurationPath(OUString const& _sNestedPath, + OUString const& _sPrefixPath) +{ + return _sPrefixPath.isEmpty() || lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) != 0; +} + +//---------------------------------------------------------------------------- +OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, + OUString const& _sPrefixPath) +{ + if ( sal_Int32 nPrefixEnd = lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) ) + { + return _sNestedPath.copy(nPrefixEnd); + } + else + { + OSL_ENSURE(_sPrefixPath.isEmpty(), "Path does not start with expected prefix"); + + return _sNestedPath; + } +} + +//---------------------------------------------------------------------------- +static +OUString lcl_wrapName(const OUString& _sContent, const OUString& _sType) +{ + const sal_Unicode * const pBeginContent = _sContent.getStr(); + const sal_Unicode * const pEndContent = pBeginContent + _sContent.getLength(); + + OSL_PRECOND(!_sType.isEmpty(), "Unexpected config type name: empty"); + OSL_PRECOND(pBeginContent <= pEndContent, "Invalid config name: empty"); + + if (pBeginContent == pEndContent) + return _sType; + + rtl::OUStringBuffer aNormalized(_sType.getLength() + _sContent.getLength() + 4); // reserve approximate size initially + + // prefix: type, opening bracket and quote + aNormalized.append( _sType ).appendAscii( RTL_CONSTASCII_STRINGPARAM("['") ); + + // content: copy over each char and handle escaping + for(const sal_Unicode* pCur = pBeginContent; pCur != pEndContent; ++pCur) + { + // append (escape if needed) + switch(*pCur) + { + case sal_Unicode('&') : aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("&") ); break; + case sal_Unicode('\''): aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("'") ); break; + case sal_Unicode('\"'): aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM(""") ); break; + + default: aNormalized.append( *pCur ); + } + } + + // suffix: closing quote and bracket + aNormalized.appendAscii( RTL_CONSTASCII_STRINGPARAM("']") ); + + return aNormalized.makeStringAndClear(); +} + +//---------------------------------------------------------------------------- + +OUString wrapConfigurationElementName(OUString const& _sElementName) +{ + return lcl_wrapName(_sElementName, OUString(RTL_CONSTASCII_USTRINGPARAM("*")) ); +} + +//---------------------------------------------------------------------------- + +OUString wrapConfigurationElementName(OUString const& _sElementName, + OUString const& _sTypeName) +{ + // todo: check that _sTypeName is valid + return lcl_wrapName(_sElementName, _sTypeName); +} + +//---------------------------------------------------------------------------- +} // namespace utl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index f464f89..91aa696 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -32,7 +32,7 @@ #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <unotools/syslocale.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/instance.hxx> diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx index 444fc3a..0ec236d 100644 --- a/unotools/source/config/viewoptions.cxx +++ b/unotools/source/config/viewoptions.cxx @@ -39,7 +39,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <rtl/ustrbuf.hxx> -#include <unotools/configpathes.hxx> +#include <unotools/configpaths.hxx> #include <comphelper/configurationhelper.hxx> #include <comphelper/processfactory.hxx> commit e1c10e673c0d1a72f6aa53c257c3aac5fc02f380 Author: Tor Lillqvist <t...@iki.fi> Date: Mon Apr 9 13:06:30 2012 +0300 s/pathes/paths/ diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx index 10a233d..229767c 100644 --- a/framework/source/fwi/classes/protocolhandlercache.cxx +++ b/framework/source/fwi/classes/protocolhandlercache.cxx @@ -248,9 +248,9 @@ void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern) HandlerCFGAccess::HandlerCFGAccess( const ::rtl::OUString& sPackage ) : ConfigItem( sPackage ) { - css::uno::Sequence< ::rtl::OUString > lListenPathes(1); - lListenPathes[0] = SETNAME_HANDLER; - EnableNotification(lListenPathes); + css::uno::Sequence< ::rtl::OUString > lListenPaths(1); + lListenPaths[0] = SETNAME_HANDLER; + EnableNotification(lListenPaths); } //_________________________________________________________________________________________________________________ _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits