diff -urd sfx2/source.orig/appl/sfxpicklist.cxx sfx2/source/appl/sfxpicklist.cxx --- sfx2/source.orig/appl/sfxpicklist.cxx 2008-04-15 14:18:30.000000000 +0000 +++ sfx2/source/appl/sfxpicklist.cxx 2009-02-12 15:58:42.000000000 +0000 @@ -391,19 +391,18 @@ } break; - case SFX_EVENT_OPENDOC: + case SFX_EVENT_SAVEASDOCDONE: { SfxMedium *pMed = pDocSh->GetMedium(); if( !pMed ) return; - // unbenannt-Docs und embedded-Docs nicht in History - if ( !pDocSh->HasName() || - SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() ) + // embedded docs should not be saved to history + if ( SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() ) return; - // Hilfe nicht in History - INetURLObject aURL( pDocSh->IsDocShared() ? pDocSh->GetSharedFileURL() : ::rtl::OUString( pMed->GetOrigURL() ) ); + // Help documents are not saved to history + INetURLObject aURL( pDocSh->IsDocShared() ? pDocSh->GetSharedFileURL() : ::rtl::OUString( pMed->GetOrigURL() ) ); if ( aURL.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP ) return; @@ -413,31 +412,65 @@ if ( pFilter ) aFilter = pFilter->GetFilterName(); + // Now add into picklist (File->Recent Documents) if required + + // 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; + + // ignore hidden documents + if ( !SfxViewFrame::GetFirst( pDocSh, 0, TRUE ) ) + return; + // add to svtool history options - SvtHistoryOptions().AppendItem( eHISTORY, + 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 ) + SystemShell::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::NO_DECODE ), (pFilter) ? pFilter->GetMimeType() : String() ); } break; - case SFX_EVENT_CLOSEDOC: - { - SfxMedium *pMed = pDocSh->GetMedium(); - if( !pMed ) - return; + case SFX_EVENT_OPENDOC: + { + SfxMedium *pMed = pDocSh->GetMedium(); + if( !pMed ) + return; - // unbenannt-Docs und embedded-Docs nicht in Pickliste - if ( !pDocSh->HasName() || - SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() ) - return; + // untitled and embedded docs should not be saved to history + if ( !pDocSh->HasName() || + SFX_CREATE_MODE_STANDARD != pDocSh->GetCreateMode() ) + return; - // Hilfe nicht in History + // Help documents are not saved to history INetURLObject aURL( pDocSh->IsDocShared() ? pDocSh->GetSharedFileURL() : ::rtl::OUString( pMed->GetOrigURL() ) ); if ( aURL.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP ) 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( eHISTORY, + aURL.GetURLNoPass( INetURLObject::NO_DECODE ), + aFilter, + aTitle, + SfxStringEncode( aURL.GetPass() ) ); + + // Now add into picklist (File->Recent Documents) if required + // only add r/w document into picklist if ( pDocSh->IsReadOnly() || !pMed->IsUpdatePickList() ) return; @@ -454,12 +487,6 @@ if ( !SfxViewFrame::GetFirst( pDocSh, 0, 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 ),