[Libreoffice-commits] core.git: comphelper/source include/comphelper sd/source
Vishv Brahmbhatt
vishvbrahmbhatt19 at gmail.com
Fri Sep 13 07:26:59 PDT 2013
comphelper/source/misc/expandmacro.cxx | 24 +++---------------------
include/comphelper/expandmacro.hxx | 23 +----------------------
sd/source/core/CustomAnimationPreset.cxx | 14 ++------------
sd/source/core/TransitionPreset.cxx | 14 ++------------
sd/source/core/drawdoc.cxx | 6 ++----
5 files changed, 10 insertions(+), 71 deletions(-)
New commits:
commit 6fc6494aa9fea0b47fbf048998d7bd412ef478b1
Author: Vishv Brahmbhatt <vishvbrahmbhatt19 at gmail.com>
Date: Wed Sep 11 00:44:36 2013 +0530
Using macro expansion function for the remaining config entries.
Macro Expansion function is used in 'CustomAnimationPreset.cxx'
& 'TransitionPreset.cxx' to avoid code redundancy.Also appropriate
changes are to made to 'getExpandedFilePath' function.
Change-Id: I6b6ae068db3499fe2de2e78a884f9e0737577651
Reviewed-on: https://gerrit.libreoffice.org/5910
Reviewed-by: Thorsten Behrens <thb at documentfoundation.org>
Tested-by: Thorsten Behrens <thb at documentfoundation.org>
diff --git a/comphelper/source/misc/expandmacro.cxx b/comphelper/source/misc/expandmacro.cxx
index a7eae4b..86eb7c2 100644
--- a/comphelper/source/misc/expandmacro.cxx
+++ b/comphelper/source/misc/expandmacro.cxx
@@ -10,29 +10,17 @@
#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>
+#include <rtl/bootstrap.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:" ) )
@@ -44,16 +32,10 @@ namespace comphelper
aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
// expand macro string
- aFilename = xMacroExpander->expandMacros( aMacro );
- }
+ rtl::Bootstrap::expandMacros( aMacro);
- if( aFilename.startsWith( "file://" ) )
- {
- rtl::OUString aSysPath;
- if( osl_getSystemPathFromFileURL( aFilename.pData, &aSysPath.pData ) == osl_File_E_None )
- aFilename = aSysPath;
+ aFilename = aMacro;
}
-
return aFilename;
}
}
diff --git a/include/comphelper/expandmacro.hxx b/include/comphelper/expandmacro.hxx
index efd2552..d699a1a 100644
--- a/include/comphelper/expandmacro.hxx
+++ b/include/comphelper/expandmacro.hxx
@@ -29,29 +29,8 @@ namespace comphelper
@param path to operate on. Both system file path and file URIs are accepted.
- @return macro-expanded system file path.
+ @return macro-expanded file URI.
*/
COMPHELPER_DLLPUBLIC rtl::OUString getExpandedFilePath(const rtl::OUString& filepath);
-
- /**
- 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.
-
- Use this version if you have a local reference of a component
- context at hand, saves us the extra lookup.
-
- @param path to operate on. Both system file path and file URIs are accepted.
- @param xContext refers to the component context of the process.
-
- @return macro-expanded system file path.
- */
- COMPHELPER_DLLPUBLIC rtl::OUString getExpandedFilePath(const rtl::OUString& filepath,
- const ::com::sun::star::uno::Reference<css::uno::XComponentContext>& xContext);
}
#endif
diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index b03359b..9883027 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -33,6 +33,7 @@
#include <comphelper/string.hxx>
#include <unotools/pathoptions.hxx>
#include <tools/stream.hxx>
+#include <comphelper/expandmacro.hxx>
#include <tools/debug.hxx>
#include <rtl/uri.hxx>
@@ -291,8 +292,6 @@ Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFac
return xRootNode;
}
-#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
-
void CustomAnimationPresets::importEffects()
{
try
@@ -324,16 +323,7 @@ void CustomAnimationPresets::importEffects()
for( sal_Int32 i=0; i<aFiles.getLength(); ++i )
{
- OUString aURL = aFiles[i];
- if( aURL.startsWith( EXPAND_PROTOCOL ) )
- {
- // cut protocol
- OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
- // decode uric class chars
- aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- // expand macro string
- aURL = xMacroExpander->expandMacros( aMacro );
- }
+ OUString aURL = ::comphelper::getExpandedFilePath(aFiles[i]);
mxRootNode = implImportEffects( xServiceFactory, aURL );
diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx
index e7b6a9b..966ccde 100644
--- a/sd/source/core/TransitionPreset.cxx
+++ b/sd/source/core/TransitionPreset.cxx
@@ -31,6 +31,7 @@
#include <comphelper/processfactory.hxx>
#include <unotools/pathoptions.hxx>
#include <tools/stream.hxx>
+#include <comphelper/expandmacro.hxx>
#include <rtl/uri.hxx>
#include <rtl/instance.hxx>
@@ -134,8 +135,6 @@ bool TransitionPreset::importTransitionsFile( TransitionPresetList& rList,
return true;
}
-#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
-
bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList )
{
bool bRet = false;
@@ -174,16 +173,7 @@ bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList )
for( sal_Int32 i=0; i<aFiles.getLength(); ++i )
{
- OUString aURL = aFiles[i];
- if( aURL.startsWith( EXPAND_PROTOCOL ) )
- {
- // cut protocol
- OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
- // decode uric class chars
- aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- // expand macro string
- aURL = xMacroExpander->expandMacros( aMacro );
- }
+ OUString aURL = ::comphelper::getExpandedFilePath(aFiles[i]);
bRet |= importTransitionsFile( rList,
xServiceFactory,
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index e327215..2d23bbd 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -1000,8 +1000,7 @@ void SdDrawDocument::InitLayoutVector()
rtl::OUString sFilename;
for( sal_Int32 i=0; i < aFiles.getLength(); ++i )
{
- rtl::OUString filepath = aFiles[i];
- sFilename= ::comphelper::getExpandedFilePath(filepath,xContext);
+ sFilename = ::comphelper::getExpandedFilePath(aFiles[i]);
// load layout file into DOM
Reference< XMultiServiceFactory > xServiceFactory(
@@ -1030,8 +1029,7 @@ void SdDrawDocument::InitObjectVector()
rtl::OUString sFilename;
for( sal_Int32 i=0; i < aFiles.getLength(); ++i )
{
- rtl::OUString filepath = aFiles[i];
- sFilename= ::comphelper::getExpandedFilePath(filepath,xContext);
+ sFilename = ::comphelper::getExpandedFilePath(aFiles[i]);
// load presentation object file into DOM
Reference< XMultiServiceFactory > xServiceFactory(
More information about the Libreoffice-commits
mailing list