diff options
-rw-r--r-- | comphelper/Library_comphelper.mk | 2 | ||||
-rw-r--r-- | comphelper/source/misc/expandmacro.cxx | 41 | ||||
-rw-r--r-- | comphelper/source/misc/getexpandeduri.cxx | 32 | ||||
-rw-r--r-- | include/comphelper/expandmacro.hxx | 36 | ||||
-rw-r--r-- | include/comphelper/getexpandeduri.hxx | 41 | ||||
-rw-r--r-- | sd/inc/pch/precompiled_sd.hxx | 1 | ||||
-rw-r--r-- | sd/source/core/CustomAnimationPreset.cxx | 4 | ||||
-rw-r--r-- | sd/source/core/TransitionPreset.cxx | 4 | ||||
-rw-r--r-- | sd/source/core/drawdoc.cxx | 6 |
9 files changed, 81 insertions, 86 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk index 271a95bc5a6e..7a263c9b5b60 100644 --- a/comphelper/Library_comphelper.mk +++ b/comphelper/Library_comphelper.mk @@ -88,7 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/documentiologring \ comphelper/source/misc/evtlistenerhlp \ comphelper/source/misc/evtmethodhelper \ - comphelper/source/misc/expandmacro \ + comphelper/source/misc/getexpandeduri \ comphelper/source/misc/instancelocker \ comphelper/source/misc/interaction \ comphelper/source/misc/listenernotification \ diff --git a/comphelper/source/misc/expandmacro.cxx b/comphelper/source/misc/expandmacro.cxx deleted file mode 100644 index 86eb7c21183e..000000000000 --- a/comphelper/source/misc/expandmacro.cxx +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <comphelper/expandmacro.hxx> - -#include <com/sun/star/uno/Reference.hxx> -#include <rtl/ustring.hxx> -#include <rtl/uri.hxx> -#include <rtl/bootstrap.hxx> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace comphelper -{ - rtl::OUString getExpandedFilePath(const rtl::OUString& filepath) - { - rtl::OUString aFilename = filepath; - - if( aFilename.startsWith( "vnd.sun.star.expand:" ) ) - { - // cut protocol - rtl::OUString aMacro( aFilename.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) ); - - // decode uric class chars - aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - - // expand macro string - rtl::Bootstrap::expandMacros( aMacro); - - aFilename = aMacro; - } - return aFilename; - } -} diff --git a/comphelper/source/misc/getexpandeduri.cxx b/comphelper/source/misc/getexpandeduri.cxx new file mode 100644 index 000000000000..796400f1da9d --- /dev/null +++ b/comphelper/source/misc/getexpandeduri.cxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/uri/XVndSunStarExpandUrlReference.hpp> +#include <com/sun/star/util/theMacroExpander.hpp> +#include <comphelper/getexpandeduri.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +OUString comphelper::getExpandedUri( + css::uno::Reference<css::uno::XComponentContext> const & context, + OUString const & uri) +{ + css::uno::Reference<css::uri::XVndSunStarExpandUrlReference> ref( + css::uri::UriReferenceFactory::create(context)->parse(uri), + css::uno::UNO_QUERY); + return ref.is() + ? ref->expand(css::util::theMacroExpander::get(context)) : uri; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/comphelper/expandmacro.hxx b/include/comphelper/expandmacro.hxx deleted file mode 100644 index e85c55b42046..000000000000 --- a/include/comphelper/expandmacro.hxx +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_COMPHELPER_EXPANDMACRO_HXX -#define INCLUDED_COMPHELPER_EXPANDMACRO_HXX - -#include <rtl/ustring.hxx> -#include <comphelper/comphelperdllapi.h> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/XComponentContext.hpp> - -namespace comphelper -{ - /** - A helper function to get expanded version of macro for filepaths. - - If the given path is prefixed by "vnd.sun.star.expand:", this - function substitutes contained macro references. It then always - returns a system file path, if necessary converting file - URIs. Example: - vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR gets - converted to e.g. /usr/lib64/libreoffice/share. - - @param path to operate on. Both system file path and file URIs are accepted. - - @return macro-expanded file URI. - */ - COMPHELPER_DLLPUBLIC rtl::OUString getExpandedFilePath(const rtl::OUString& filepath); -} -#endif diff --git a/include/comphelper/getexpandeduri.hxx b/include/comphelper/getexpandeduri.hxx new file mode 100644 index 000000000000..9da095821e66 --- /dev/null +++ b/include/comphelper/getexpandeduri.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_COMPHELPER_GETEXPANDEDURI_HXX +#define INCLUDED_COMPHELPER_GETEXPANDEDURI_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <comphelper/comphelperdllapi.h> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + +namespace comphelper { + +/** + A helper function to expand vnd.sun.star.expand URLs. + + If the given URI is a vnd.sun.star.expand URL, it is expanded (using the + given component context's com.sun.star.util.theMacroExpander); otherwise it + is returned unchanged. +*/ +COMPHELPER_DLLPUBLIC OUString getExpandedUri( + css::uno::Reference<css::uno::XComponentContext> const & context, + OUString const & uri); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx index a0915549f4bf..e182a24e77c5 100644 --- a/sd/inc/pch/precompiled_sd.hxx +++ b/sd/inc/pch/precompiled_sd.hxx @@ -355,7 +355,6 @@ #include <comphelper/anytostring.hxx> #include <comphelper/classids.hxx> #include <comphelper/documentconstants.hxx> -#include <comphelper/expandmacro.hxx> #include <comphelper/extract.hxx> #include <comphelper/genericpropertyset.hxx> #include <comphelper/namedvaluecollection.hxx> diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 00216a7c4f7b..f86940f7ca31 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -29,12 +29,12 @@ #include <com/sun/star/presentation/EffectPresetClass.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <unotools/streamwrap.hxx> +#include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/random.hxx> #include <comphelper/string.hxx> #include <unotools/pathoptions.hxx> #include <tools/stream.hxx> -#include <comphelper/expandmacro.hxx> #include <tools/debug.hxx> #include <rtl/uri.hxx> @@ -324,7 +324,7 @@ void CustomAnimationPresets::importEffects() for( sal_Int32 i=0; i<aFiles.getLength(); ++i ) { - OUString aURL = ::comphelper::getExpandedFilePath(aFiles[i]); + OUString aURL = comphelper::getExpandedUri(xContext, aFiles[i]); mxRootNode = implImportEffects( xServiceFactory, aURL ); diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx index 25edfd618070..d7bc31ed4788 100644 --- a/sd/source/core/TransitionPreset.cxx +++ b/sd/source/core/TransitionPreset.cxx @@ -28,10 +28,10 @@ #include <vcl/svapp.hxx> #include <osl/mutex.hxx> #include <unotools/streamwrap.hxx> +#include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <unotools/pathoptions.hxx> #include <tools/stream.hxx> -#include <comphelper/expandmacro.hxx> #include <rtl/uri.hxx> #include <rtl/instance.hxx> @@ -170,7 +170,7 @@ bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList ) for( sal_Int32 i=0; i<aFiles.getLength(); ++i ) { - OUString aURL = ::comphelper::getExpandedFilePath(aFiles[i]); + OUString aURL = comphelper::getExpandedUri(xContext, aFiles[i]); bRet |= importTransitionsFile( rList, xServiceFactory, diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 8b47fe751ac1..f18436c45c89 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -55,6 +55,7 @@ #include <editeng/outlobj.hxx> #include <unotools/saveopt.hxx> #include <comphelper/extract.hxx> +#include <comphelper/getexpandeduri.hxx> #include <i18nlangtag/mslangid.hxx> #include <i18nlangtag/languagetag.hxx> #include <unotools/charclass.hxx> @@ -72,7 +73,6 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/ustring.hxx> #include <rtl/uri.hxx> -#include <comphelper/expandmacro.hxx> #include <editeng/outliner.hxx> #include "drawdoc.hxx" @@ -989,7 +989,7 @@ void SdDrawDocument::InitLayoutVector() rtl::OUString sFilename; for( sal_Int32 i=0; i < aFiles.getLength(); ++i ) { - sFilename = ::comphelper::getExpandedFilePath(aFiles[i]); + sFilename = comphelper::getExpandedUri(xContext, aFiles[i]); // load layout file into DOM Reference< XMultiServiceFactory > xServiceFactory( @@ -1025,7 +1025,7 @@ void SdDrawDocument::InitObjectVector() rtl::OUString sFilename; for( sal_Int32 i=0; i < aFiles.getLength(); ++i ) { - sFilename = ::comphelper::getExpandedFilePath(aFiles[i]); + sFilename = comphelper::getExpandedUri(xContext, aFiles[i]); // load presentation object file into DOM Reference< XMultiServiceFactory > xServiceFactory( |