summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorVishv Brahmbhatt <vishvbrahmbhatt19@gmail.com>2013-08-28 01:52:17 +0530
committerThorsten Behrens <tbehrens@suse.com>2013-09-10 13:14:30 +0200
commitd50bd55c5d78dc10d40be502f8d6638bcc0ce890 (patch)
treee65f13d467edd623699ebcbb3c6ae30f98eeae7b /comphelper
parentSome clean up (diff)
downloadcore-d50bd55c5d78dc10d40be502f8d6638bcc0ce890.tar.gz
core-d50bd55c5d78dc10d40be502f8d6638bcc0ce890.zip
Parsing master presentation objects from 'objectlist.xml'
Parsing the property values of master presentation objects. Also new functions added to comphelper module for expanding filepaths macro to appropriate system file paths(for configuration files present at 'Impress.xcs') Change-Id: If0381a12155673e85103ddb5d51c34ae53fe2ecb
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/Library_comphelper.mk1
-rw-r--r--comphelper/source/misc/expandmacro.cxx59
2 files changed, 60 insertions, 0 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk
index 09a68895f81f..4b303386b953 100644
--- a/comphelper/Library_comphelper.mk
+++ b/comphelper/Library_comphelper.mk
@@ -86,6 +86,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/ihwrapnofilter \
comphelper/source/misc/instancelocker \
comphelper/source/misc/interaction \
diff --git a/comphelper/source/misc/expandmacro.cxx b/comphelper/source/misc/expandmacro.cxx
new file mode 100644
index 000000000000..a7eae4b12548
--- /dev/null
+++ b/comphelper/source/misc/expandmacro.cxx
@@ -0,0 +1,59 @@
+/* -*- 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 <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/theMacroExpander.hpp>
+#include <rtl/ustring.hxx>
+#include <rtl/uri.hxx>
+#include <osl/file.h>
+#include <comphelper/processfactory.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+namespace comphelper
+{
+ rtl::OUString getExpandedFilePath(const rtl::OUString& filepath)
+ {
+ const Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ return getExpandedFilePath(filepath, xContext);
+ }
+
+ rtl::OUString getExpandedFilePath(const rtl::OUString& filepath, const Reference<XComponentContext>& xContext)
+ {
+ Reference< util::XMacroExpander > xMacroExpander = util::theMacroExpander::get( xContext );
+
+ 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
+ aFilename = xMacroExpander->expandMacros( aMacro );
+ }
+
+ if( aFilename.startsWith( "file://" ) )
+ {
+ rtl::OUString aSysPath;
+ if( osl_getSystemPathFromFileURL( aFilename.pData, &aSysPath.pData ) == osl_File_E_None )
+ aFilename = aSysPath;
+ }
+
+ return aFilename;
+ }
+}