From 383a9c777f1e9d60584d3b1c26a1440e6bef3fa5 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 9 Apr 2012 13:43:22 +0300 Subject: s/pathes/paths/ --- filter/source/config/cache/cacheupdatelistener.cxx | 2 +- filter/source/config/cache/filtercache.cxx | 2 +- framework/inc/jobs/jobdispatch.hxx | 2 +- .../accelerators/acceleratorconfiguration.cxx | 2 +- .../source/fwi/classes/protocolhandlercache.cxx | 2 +- 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/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/fontcfg.cxx | 2 +- unotools/source/config/viewoptions.cxx | 2 +- 22 files changed, 510 insertions(+), 510 deletions(-) delete mode 100644 unotools/inc/unotools/configpathes.hxx create mode 100644 unotools/inc/unotools/configpaths.hxx delete mode 100644 unotools/source/config/configpathes.cxx create mode 100644 unotools/source/config/configpaths.cxx diff --git a/filter/source/config/cache/cacheupdatelistener.cxx b/filter/source/config/cache/cacheupdatelistener.cxx index 09997222e1fe..1e09df3ac435 100644 --- a/filter/source/config/cache/cacheupdatelistener.cxx +++ b/filter/source/config/cache/cacheupdatelistener.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include //_______________________________________________ diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 9c2481a48816..1da6f142bc38 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include #include diff --git a/framework/inc/jobs/jobdispatch.hxx b/framework/inc/jobs/jobdispatch.hxx index 78c1535192c0..b002332676f0 100644 --- a/framework/inc/jobs/jobdispatch.hxx +++ b/framework/inc/jobs/jobdispatch.hxx @@ -60,7 +60,7 @@ //_______________________________________ // other includes -#include +#include #include #include diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index ed3d0ca721fd..3fd5c72eac3b 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx index 229767cae71b..c7e1a8d06de4 100644 --- a/framework/source/fwi/classes/protocolhandlercache.cxx +++ b/framework/source/fwi/classes/protocolhandlercache.cxx @@ -51,7 +51,7 @@ // other includes //_________________________________________________________________________________________________________________ #include -#include +#include #include //_________________________________________________________________________________________________________________ diff --git a/framework/source/fwi/jobs/configaccess.cxx b/framework/source/fwi/jobs/configaccess.cxx index f39bda8e21d9..b6e13167d13b 100644 --- a/framework/source/fwi/jobs/configaccess.cxx +++ b/framework/source/fwi/jobs/configaccess.cxx @@ -46,7 +46,7 @@ //________________________________ // includes of other projects -#include +#include #include //________________________________ diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index d059fd45bca6..bf1925a76bed 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -46,7 +46,7 @@ //________________________________ // includes of other projects #include -#include +#include #include #include diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 9fe0b3da4061..e41c518ed27a 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -50,7 +50,7 @@ //________________________________ // includes of other projects -#include +#include #include #include diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx index 9bdd098a1d9a..8d74d71379ef 100644 --- a/framework/source/services/pathsettings.cxx +++ b/framework/source/services/pathsettings.cxx @@ -56,7 +56,7 @@ #include #include -#include +#include #include diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 7c8d59bf94eb..41fc23812908 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include //Any2Bool #include diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index f612aabd2fe1..6fc1a34f845d 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include //Any2Bool #include diff --git a/sw/source/ui/envelp/labelcfg.cxx b/sw/source/ui/envelp/labelcfg.cxx index 04a8695e0782..3ee9fe382070 100644 --- a/sw/source/ui/envelp/labelcfg.cxx +++ b/sw/source/ui/envelp/labelcfg.cxx @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index da53b60443f5..69708a12737f 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 5925034dc422..1812cb53dbdb 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 258ea01c97ec..000000000000 --- 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "unotools/unotoolsdllapi.h" - -#ifndef UNOTOOLS_CONFIGPATHES_HXX_INCLUDED -#define UNOTOOLS_CONFIGPATHES_HXX_INCLUDED -#include - -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.
- 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 _sInPath.
- If _sInPath 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 - _sInPath.
- If _sInPath could not be parsed as a valid - configuration path, this is set to _sInPath. - - @returns - , if a parent path could be set - , 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.
- 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 _sInPath.
- If _sInPath 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 _sPrefixPath, with both paths starting - from the same node (or both being absolute). - - @param _sPrefixPath - A configuration path.
- If this path is absolute, _sNestedPath should be absolute; - If this path is relative, _sNestedPath should be relative; - If this path is empty, _sNestedPath may start with a '/', - which is disregarded. - - @returns - , if _sPrefixPath is a prefix of _sNestedPath; - otherwise.
- If both paths are equal 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 _sPrefixPath, with both paths starting - from the same node (or both being absolute). - - @param _sPrefixPath - A configuration path.
- If this path is absolute, _sNestedPath must be absolute; - If this path is relative, _sNestedPath must be relative; - If this path is empty, _sNestedPath may start with a '/', - which is stripped. - - @returns - The remaining relative path from the target of _sPrefixPath - to the target of _sNestedPath.
- If _sPrefixPath is not a prefix of _sNestedPath, - _sNestedPath 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 - "*['']", where 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.
- - @returns - A one-level relative path to the element, of the form - "['']", where 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 000000000000..110263431f48 --- /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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "unotools/unotoolsdllapi.h" + +#ifndef UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#define UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#include + +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.
+ 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 _sInPath.
+ If _sInPath 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 + _sInPath.
+ If _sInPath could not be parsed as a valid + configuration path, this is set to _sInPath. + + @returns + , if a parent path could be set + , 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.
+ 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 _sInPath.
+ If _sInPath 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 _sPrefixPath, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.
+ If this path is absolute, _sNestedPath should be absolute; + If this path is relative, _sNestedPath should be relative; + If this path is empty, _sNestedPath may start with a '/', + which is disregarded. + + @returns + , if _sPrefixPath is a prefix of _sNestedPath; + otherwise.
+ If both paths are equal 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 _sPrefixPath, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.
+ If this path is absolute, _sNestedPath must be absolute; + If this path is relative, _sNestedPath must be relative; + If this path is empty, _sNestedPath may start with a '/', + which is stripped. + + @returns + The remaining relative path from the target of _sPrefixPath + to the target of _sNestedPath.
+ If _sPrefixPath is not a prefix of _sNestedPath, + _sNestedPath 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 + "*['']", where 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.
+ + @returns + A one-level relative path to the element, of the form + "['']", where 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 615eb03a777a..3aaeaf6dde61 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 #include #include diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index 68f6e92704df..9888490e2af8 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -28,7 +28,7 @@ #include -#include +#include #include #include #include diff --git a/unotools/source/config/configpathes.cxx b/unotools/source/config/configpathes.cxx deleted file mode 100644 index 8973e63cc8f5..000000000000 --- 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "unotools/configpathes.hxx" -#include -#include -#include - -//---------------------------------------------------------------------------- -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 000000000000..aa40b533ba20 --- /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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "unotools/configpaths.hxx" +#include +#include +#include + +//---------------------------------------------------------------------------- +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 f464f890f092..91aa696ed14e 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx index 444fc3ad0af0..0ec236d30a62 100644 --- a/unotools/source/config/viewoptions.cxx +++ b/unotools/source/config/viewoptions.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include -- cgit