[Libreoffice-commits] core.git: comphelper/Library_comphelper.mk comphelper/source include/comphelper sd/inc sd/source

Stephan Bergmann sbergman at redhat.com
Wed Dec 3 07:15:55 PST 2014


 comphelper/Library_comphelper.mk          |    2 -
 comphelper/source/misc/expandmacro.cxx    |   41 ------------------------------
 comphelper/source/misc/getexpandeduri.cxx |   32 +++++++++++++++++++++++
 include/comphelper/expandmacro.hxx        |   36 --------------------------
 include/comphelper/getexpandeduri.hxx     |   41 ++++++++++++++++++++++++++++++
 sd/inc/pch/precompiled_sd.hxx             |    1 
 sd/source/core/CustomAnimationPreset.cxx  |    4 +-
 sd/source/core/TransitionPreset.cxx       |    4 +-
 sd/source/core/drawdoc.cxx                |    6 ++--
 9 files changed, 81 insertions(+), 86 deletions(-)

New commits:
commit b9ca4de9852d44382f499e078d887421ec8ee46b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Dec 3 16:14:48 2014 +0100

    From ill-named comphelper::getExpandedFilePath to comphelper::getExpanedUri
    
    Change-Id: I749d78d115f641b2ac18cd6eb483c69a22ee210c

diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk
index 271a95b..7a263c9 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 86eb7c2..0000000
--- 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 0000000..796400f
--- /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 e85c55b..0000000
--- 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 0000000..9da0958
--- /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 a091554..e182a24 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 00216a7..f86940f 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 25edfd6..d7bc31e 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 8b47fe7..f18436c 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(


More information about the Libreoffice-commits mailing list