3 From: Thorsten Behrens <thb@openoffice.org>
8 .../officeinstallationdirectories.cxx | 12 +++----
9 sfx2/source/doc/doctemplates.cxx | 35 ++++++++++++++++++++
10 2 files changed, 41 insertions(+), 6 deletions(-)
13 diff --git comphelper/source/officeinstdir/officeinstallationdirectories.cxx comphelper/source/officeinstdir/officeinstallationdirectories.cxx
14 index cd09ff6..bcbae52 100644
15 --- comphelper/source/officeinstdir/officeinstallationdirectories.cxx
16 +++ comphelper/source/officeinstdir/officeinstallationdirectories.cxx
17 @@ -207,9 +207,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL )
21 - URL.replaceAt( nIndex,
22 - m_pOfficeDir->getLength(),
23 - m_aOfficeDirMacro ) );
24 + aCanonicalURL.replaceAt( nIndex,
25 + m_pOfficeDir->getLength(),
26 + m_aOfficeDirMacro ) );
30 @@ -217,9 +217,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL )
34 - URL.replaceAt( nIndex,
35 - m_pUserDir->getLength(),
36 - m_aUserDirMacro ) );
37 + aCanonicalURL.replaceAt( nIndex,
38 + m_pUserDir->getLength(),
39 + m_aUserDirMacro ) );
43 diff --git sfx2/source/doc/doctemplates.cxx sfx2/source/doc/doctemplates.cxx
44 index c23ef53..63734a5 100644
45 --- sfx2/source/doc/doctemplates.cxx
46 +++ sfx2/source/doc/doctemplates.cxx
48 #include <com/sun/star/beans/XPropertySetInfo.hpp>
49 #include <com/sun/star/beans/XPropertyContainer.hpp>
50 #include <com/sun/star/beans/StringPair.hpp>
51 +#include <com/sun/star/util/XMacroExpander.hpp>
52 #include <com/sun/star/container/XContainerQuery.hpp>
53 #include <com/sun/star/document/XTypeDetection.hpp>
54 #include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
55 @@ -601,11 +602,45 @@ void SfxDocTplService_Impl::getDirList()
57 maTemplateDirs = Sequence< OUString >( nCount );
59 + uno::Reference< XComponentContext > xCtx;
60 + uno::Reference< util::XMacroExpander > xExpander;
61 + uno::Reference< XPropertySet > xPropSet( mxFactory, UNO_QUERY );
62 + const rtl::OUString aPrefix(
63 + RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.expand:" ) );
65 + if ( xPropSet.is() )
67 + xPropSet->getPropertyValue(
69 + RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) )
75 + xCtx->getValueByName(
76 + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
77 + "/singletons/com.sun.star.util.theMacroExpander" ) ) )
80 + OSL_ENSURE( xExpander.is(),
81 + "Unable to obtain macro expander singleton!" );
84 for ( USHORT i=0; i<nCount; i++ )
86 aURL.SetSmartProtocol( INET_PROT_FILE );
87 aURL.SetURL( aDirs.GetToken( i, C_DELIM ) );
88 maTemplateDirs[i] = aURL.GetMainURL( INetURLObject::NO_DECODE );
90 + sal_Int32 nIndex = maTemplateDirs[i].indexOf( aPrefix );
91 + if ( nIndex != -1 && xExpander.is() )
93 + maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex,
94 + aPrefix.getLength(),
96 + maTemplateDirs[i] = xExpander->expandMacros( maTemplateDirs[i] );
100 aValue <<= maTemplateDirs;