Update ooo320-m1
[ooovba.git] / applied_patches / 0590-normalize-template-paths-fix.diff
blobb67e16b599961f984d6da984e0dc6820bd63264b
1 fix template path bug
3 From: Thorsten Behrens <thb@openoffice.org>
6 ---
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 )
18 if ( nIndex != -1 )
20 return rtl::OUString(
21 - URL.replaceAt( nIndex,
22 - m_pOfficeDir->getLength(),
23 - m_aOfficeDirMacro ) );
24 + aCanonicalURL.replaceAt( nIndex,
25 + m_pOfficeDir->getLength(),
26 + m_aOfficeDirMacro ) );
28 else
30 @@ -217,9 +217,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL )
31 if ( nIndex != -1 )
33 return rtl::OUString(
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
47 @@ -51,6 +51,7 @@
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() )
66 + {
67 + xPropSet->getPropertyValue(
68 + rtl::OUString(
69 + RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) )
70 + >>= xCtx;
71 + }
73 + if ( xCtx.is() )
74 + {
75 + xCtx->getValueByName(
76 + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
77 + "/singletons/com.sun.star.util.theMacroExpander" ) ) )
78 + >>= xExpander;
80 + OSL_ENSURE( xExpander.is(),
81 + "Unable to obtain macro expander singleton!" );
82 + }
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() )
92 + {
93 + maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex,
94 + aPrefix.getLength(),
95 + rtl::OUString());
96 + maTemplateDirs[i] = xExpander->expandMacros( maTemplateDirs[i] );
97 + }
100 aValue <<= maTemplateDirs;