summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@novell.com>2011-04-28 16:03:56 +0200
committerPetr Mladek <pmladek@suse.cz>2011-04-28 16:03:56 +0200
commitdaaafd7762088585679ca4298ebdf47e190680c8 (patch)
treece9f92a3ee27014caa04972eb6ddee0a8421745a
parent796bd6da745128e24eec6cf386ae8a9469c03307 (diff)
normalize-template-paths-fix.diff: allow to install templates from extensions
expand path placeholders early in template dialog (bnc#512146)
-rw-r--r--sfx2/source/doc/doctemplates.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index f903911422..f786e5c15e 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyContainer.hpp>
#include <com/sun/star/beans/StringPair.hpp>
+#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/container/XContainerQuery.hpp>
#include <com/sun/star/document/XTypeDetection.hpp>
#include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
@@ -593,11 +594,45 @@ void SfxDocTplService_Impl::getDirList()
maTemplateDirs = Sequence< OUString >( nCount );
+ uno::Reference< XComponentContext > xCtx;
+ uno::Reference< util::XMacroExpander > xExpander;
+ uno::Reference< XPropertySet > xPropSet( mxFactory, UNO_QUERY );
+ const rtl::OUString aPrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.expand:" ) );
+
+ if ( xPropSet.is() )
+ {
+ xPropSet->getPropertyValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) )
+ >>= xCtx;
+ }
+
+ if ( xCtx.is() )
+ {
+ xCtx->getValueByName(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/com.sun.star.util.theMacroExpander" ) ) )
+ >>= xExpander;
+
+ OSL_ENSURE( xExpander.is(),
+ "Unable to obtain macro expander singleton!" );
+ }
+
for ( sal_uInt16 i=0; i<nCount; i++ )
{
aURL.SetSmartProtocol( INET_PROT_FILE );
aURL.SetURL( aDirs.GetToken( i, C_DELIM ) );
maTemplateDirs[i] = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ sal_Int32 nIndex = maTemplateDirs[i].indexOf( aPrefix );
+ if ( nIndex != -1 && xExpander.is() )
+ {
+ maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex,
+ aPrefix.getLength(),
+ rtl::OUString());
+ maTemplateDirs[i] = xExpander->expandMacros( maTemplateDirs[i] );
+ }
}
aValue <<= maTemplateDirs;