summaryrefslogtreecommitdiff
path: root/sfx2/source/appl/sfxpicklist.cxx
diff options
context:
space:
mode:
authorMuhammad Haggag <mhaggag@gmail.com>2012-02-14 10:46:46 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-02-14 16:24:57 +0000
commit2e01faac3fa50f7036093583ae52f1584b3de55c (patch)
tree3076dcc848e0567258ae4900682634b2cc8eb894 /sfx2/source/appl/sfxpicklist.cxx
parent475d0c59c66fb7752d230f76130b17145aad0c12 (diff)
fdo#37775: Recent Documents not updated by Save & Save As
This patch changes LO behavior so that we update recent documents on file save, save as, save all, and close. The previous behavior was to only update the list on document close. = Changes = SfxPickList (sfxpicklist.cxx/hxx): . Extracted the logic to add a document to the "Recent Documents" list into a function of its own: AddDocumentToPickList - Simplified the logic used by removing the check of SfxObjectShell_impl::bWaitingForPickList (see SfxObjectShell_impl::bWaitingForPickList below for details) . Modified SfxPickList::Notify to call the aforementioned function on save, save-to, and save-as. SfxObjectShell::APISaveAs_Impl (objserv.cxx): . Modified it to allow picklist entry when doing "Save As". SfxObjectShell_impl::bWaitingForPickList (objstor.cxx, objxtor.cxx, objshimp.hxx): . Removed this flag. It was used to indicate that a document wants to be added to the picklist, then cleared after it's added. Since we now always add documents to the picklist on saving, we no longer need it. = Verification = The change is in sfx2, so it should apply to all LO apps. I verified the new behavior in both writer and calc with the following actions: . File->Save . File->Save As . File->Save All . File->Close
Diffstat (limited to 'sfx2/source/appl/sfxpicklist.cxx')
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx109
1 files changed, 65 insertions, 44 deletions
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index b0169a5a13a5..119873279b95 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -164,6 +164,52 @@ SfxPickList::PickListEntry* SfxPickList::GetPickListEntry( sal_uInt32 nIndex )
return 0;
}
+void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
+{
+ SfxMedium *pMed = pDocSh->GetMedium();
+ if( !pMed )
+ return;
+
+ // Unnamed Documents and embedded-Documents not in Picklist
+ if ( !pDocSh->HasName() ||
+ SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() )
+ return;
+
+ // Help not in History
+ INetURLObject aURL( pDocSh->IsDocShared() ? pDocSh->GetSharedFileURL() : ::rtl::OUString( pMed->GetOrigURL() ) );
+ if ( aURL.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
+ return;
+
+ // only add r/w document into picklist
+ if ( pDocSh->IsReadOnly() || !pMed->IsUpdatePickList() )
+ return;
+
+ // add no document that forbids this (for example Message-Body)
+ SFX_ITEMSET_ARG( pMed->GetItemSet(), pPicklistItem, SfxBoolItem, SID_PICKLIST, sal_False );
+ if ( pPicklistItem && !pPicklistItem->GetValue() )
+ return;
+
+ // ignore hidden documents
+ if ( !SfxViewFrame::GetFirst( pDocSh, sal_True ) )
+ return;
+
+ ::rtl::OUString aTitle = pDocSh->GetTitle(SFX_TITLE_PICKLIST);
+ ::rtl::OUString aFilter;
+ const SfxFilter* pFilter = pMed->GetOrigFilter();
+ if ( pFilter )
+ aFilter = pFilter->GetFilterName();
+
+ // add to svtool history options
+ SvtHistoryOptions().AppendItem( ePICKLIST,
+ aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
+ aFilter,
+ aTitle,
+ SfxStringEncode( aURL.GetPass() ) );
+
+ if ( aURL.GetProtocol() == INET_PROT_FILE )
+ Application::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::NO_DECODE ), (pFilter) ? pFilter->GetMimeType() : ::rtl::OUString() );
+}
+
SfxPickList& SfxPickList::Get()
{
static SfxPickList aUniqueInstance(SvtHistoryOptions().GetSize(ePICKLIST));
@@ -375,55 +421,30 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
break;
+ case SFX_EVENT_SAVEDOCDONE:
+ case SFX_EVENT_SAVEASDOCDONE:
+ case SFX_EVENT_SAVETODOCDONE:
case SFX_EVENT_CLOSEDOC:
{
- SfxMedium *pMed = pDocSh->GetMedium();
- if( !pMed )
- return;
-
- // Unnamed Documents and embedded-Documents not im Pickliste
- if ( !pDocSh->HasName() ||
- SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() )
- return;
-
- // Help not in History
- INetURLObject aURL( pDocSh->IsDocShared() ? pDocSh->GetSharedFileURL() : ::rtl::OUString( pMed->GetOrigURL() ) );
- if ( aURL.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
- return;
-
- // only add r/w document into picklist
- if ( pDocSh->IsReadOnly() || !pMed->IsUpdatePickList() )
- return;
-
- // add no document that forbids this (for example Message-Body)
- SFX_ITEMSET_ARG( pMed->GetItemSet(), pPicklistItem, SfxBoolItem, SID_PICKLIST, sal_False );
- if (
- (pPicklistItem && !pPicklistItem->GetValue()) ||
- (!(pDocSh->Get_Impl()->bWaitingForPicklist) )
- )
- return;
+ AddDocumentToPickList(pDocSh);
+ }
+ break;
- // ignore hidden documents
- if ( !SfxViewFrame::GetFirst( pDocSh, sal_True ) )
+ case SFX_EVENT_SAVEASDOC:
+ {
+ SfxMedium *pMedium = pDocSh->GetMedium();
+ if (!pMedium)
return;
- ::rtl::OUString aTitle = pDocSh->GetTitle(SFX_TITLE_PICKLIST);
- ::rtl::OUString aFilter;
- const SfxFilter* pFilter = pMed->GetOrigFilter();
- if ( pFilter )
- aFilter = pFilter->GetFilterName();
-
- // add to svtool history options
- SvtHistoryOptions().AppendItem( ePICKLIST,
- aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
- aFilter,
- aTitle,
- SfxStringEncode( aURL.GetPass() ) );
-
- pDocSh->Get_Impl()->bWaitingForPicklist = sal_False;
-
- if ( aURL.GetProtocol() == INET_PROT_FILE )
- Application::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::NO_DECODE ), (pFilter) ? pFilter->GetMimeType() : ::rtl::OUString() );
+ // We're starting a "Save As". Add the current document (if it's
+ // not a "new" document) to the "Recent Documents" list before we
+ // switch to the new path.
+ // If the current document is new, path will be empty.
+ rtl::OUString path = pMedium->GetOrigURL();
+ if (!path.isEmpty())
+ {
+ AddDocumentToPickList(pDocSh);
+ }
}
break;
}