diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-12-03 16:14:48 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-12-03 16:15:27 +0100 |
commit | b9ca4de9852d44382f499e078d887421ec8ee46b (patch) | |
tree | 59c553c7f8295093a357f00042c041fbee3957b6 /comphelper | |
parent | 6abdd2d963740afaac0b744f7b96d75ce375bd49 (diff) |
From ill-named comphelper::getExpandedFilePath to comphelper::getExpanedUri
Change-Id: I749d78d115f641b2ac18cd6eb483c69a22ee210c
Diffstat (limited to 'comphelper')
-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 |
3 files changed, 33 insertions, 42 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: */ |