summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/objsh.hxx3
-rw-r--r--sfx2/source/doc/doctemplates.cxx35
-rw-r--r--sfx2/source/doc/objstor.cxx24
3 files changed, 53 insertions, 9 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx
index a3ad4fbf917c..48f938626e6e 100644
--- a/sfx2/inc/sfx2/objsh.hxx
+++ b/sfx2/inc/sfx2/objsh.hxx
@@ -228,6 +228,9 @@ protected:
/// template method, called by FlushDocInfo; this implementation is empty
virtual void DoFlushDocInfo();
+ // helper method
+ void AddToRecentlyUsedList();
+
public:
TYPEINFO();
SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH)
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 03897b24531a..dedc88f183b5 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;
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d570e0b3e028..954df88eb949 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -797,15 +797,7 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed )
&& !( pPreviewItem && pPreviewItem->GetValue() )
&& !( pHiddenItem && pHiddenItem->GetValue() ) )
{
- INetURLObject aUrl( pMedium->GetOrigURL() );
-
- if ( aUrl.GetProtocol() == INET_PROT_FILE )
- {
- const SfxFilter* pOrgFilter = pMedium->GetOrigFilter();
- Application::AddToRecentDocumentList(
- aUrl.GetURLNoPass( INetURLObject::NO_DECODE ),
- (pOrgFilter) ? pOrgFilter->GetMimeType() : String() );
- }
+ AddToRecentlyUsedList();
}
}
@@ -2121,9 +2113,23 @@ sal_Bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
pMedium->ClearBackup_Impl();
pMedium->LockOrigFileOnDemand( sal_True, sal_False );
+ AddToRecentlyUsedList();
+
return bOk;
}
+void SfxObjectShell::AddToRecentlyUsedList()
+{
+ INetURLObject aUrl( pMedium->GetOrigURL() );
+
+ if ( aUrl.GetProtocol() == INET_PROT_FILE )
+ {
+ const SfxFilter* pOrgFilter = pMedium->GetOrigFilter();
+ Application::AddToRecentDocumentList( aUrl.GetURLNoPass( INetURLObject::NO_DECODE ),
+ (pOrgFilter) ? pOrgFilter->GetMimeType() : String() );
+ }
+}
+
//-------------------------------------------------------------------------
sal_Bool SfxObjectShell::ConvertFrom