Kaydet (Commit) b9ca4de9 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

From ill-named comphelper::getExpandedFilePath to comphelper::getExpanedUri

Change-Id: I749d78d115f641b2ac18cd6eb483c69a22ee210c
üst 6abdd2d9
......@@ -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 \
......
......@@ -7,30 +7,26 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_COMPHELPER_EXPANDMACRO_HXX
#define INCLUDED_COMPHELPER_EXPANDMACRO_HXX
#include <sal/config.h>
#include <rtl/ustring.hxx>
#include <comphelper/comphelperdllapi.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>
namespace comphelper
OUString comphelper::getExpandedUri(
css::uno::Reference<css::uno::XComponentContext> const & context,
OUString const & uri)
{
/**
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);
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;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,35 +7,35 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <comphelper/expandmacro.hxx>
#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 <rtl/uri.hxx>
#include <rtl/bootstrap.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
#include <sal/types.h>
namespace comphelper
{
rtl::OUString getExpandedFilePath(const rtl::OUString& filepath)
{
rtl::OUString aFilename = filepath;
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
if( aFilename.startsWith( "vnd.sun.star.expand:" ) )
{
// cut protocol
rtl::OUString aMacro( aFilename.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) );
namespace comphelper {
// decode uric class chars
aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
/**
A helper function to expand vnd.sun.star.expand URLs.
// expand macro string
rtl::Bootstrap::expandMacros( aMacro);
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);
aFilename = aMacro;
}
return aFilename;
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -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>
......
......@@ -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 );
......
......@@ -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,
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment