diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-10-21 09:09:01 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-10-21 09:26:09 +0200 |
commit | 9387cca95176889d171a63a46cb2d0f6d59b3d1b (patch) | |
tree | 3376e8a7c16040de1e917ecfdd60f5c5f7101f5d | |
parent | b34f03271ed765795bb6131c733c3fba425b5425 (diff) |
tdf#95095: Implement "AvoidRecentDocs" property for loadComponentFromURL().
When "AvoidRecentDocs" is set to true, the loaded document is not added to the
recent documents list, avoiding the (a bit expensive) thumbnail creation.
Useful when loadComponentFromURL() is called from macros, or when LibreOffice
is controlled via UNO. See the bug for an example.
Change-Id: I99d516cae8b278199a01276686465f716b9b4cec
-rw-r--r-- | include/sfx2/objsh.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/appl/sfxpicklist.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 65 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 7 |
5 files changed, 39 insertions, 51 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index ff04e3c7f1d5..edbe6d10690d 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -216,6 +216,7 @@ private: bool bHasName :1; // sal_True := existing object, // sal_False := new object bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + bool mbAvoidRecentDocs; ///< Avoid adding to the recent documents list, if not necessary. bool CloseInternal(); private: @@ -463,6 +464,12 @@ public: bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted. + bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; } + + /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted. + void AvoidRecentDocs(bool bAvoid = true) { mbAvoidRecentDocs = bAvoid; } + // Transfer IFace void AbortImport(); bool IsAbortingImport() const; diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index 370049b80705..e96269de2bc1 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -161,6 +161,9 @@ SfxPickList::PickListEntry* SfxPickList::GetPickListEntry( sal_uInt32 nIndex ) void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh ) { + if (pDocSh->IsAvoidRecentDocs()) + return; + SfxMedium *pMed = pDocSh->GetMedium(); if( !pMed ) return; @@ -411,11 +414,6 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint ) break; case SFX_EVENT_OPENDOC: - { - AddDocumentToPickList(pDocSh); - } - break; - case SFX_EVENT_SAVEDOCDONE: case SFX_EVENT_SAVEASDOCDONE: case SFX_EVENT_SAVETODOCDONE: diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index e5207d06accf..6cc3b31ea68b 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -282,12 +282,13 @@ SfxObjectShell_Impl::~SfxObjectShell_Impl() SfxObjectShell::SfxObjectShell( const SfxModelFlags i_nCreationFlags ) - : pImp( new SfxObjectShell_Impl( *this ) ) - , pMedium(0) - , pStyleSheetPool(0) - , eCreateMode(SfxObjectCreateMode::STANDARD) - , bHasName( false ) - , bIsInGenerateThumbnail ( false ) + : pImp(new SfxObjectShell_Impl(*this)) + , pMedium(0) + , pStyleSheetPool(0) + , eCreateMode(SfxObjectCreateMode::STANDARD) + , bHasName(false) + , bIsInGenerateThumbnail (false) + , mbAvoidRecentDocs(false) { if (i_nCreationFlags & SfxModelFlags::EMBEDDED_OBJECT) eCreateMode = SfxObjectCreateMode::EMBEDDED; @@ -303,49 +304,25 @@ SfxObjectShell::SfxObjectShell( const SfxModelFlags i_nCreationFlags ) pImp->m_bDocRecoverySupport = false; } +/** Constructor of the class SfxObjectShell. - -// initializes a document from a file-description - -SfxObjectShell::SfxObjectShell -( - SfxObjectCreateMode eMode /* Purpose, io which the SfxObjectShell - is created: - - SfxObjectCreateMode::EMBEDDED (default) - as SO-Server from within another - Document - - SfxObjectCreateMode::STANDARD, - as a normal Document open stand-alone - - SfxObjectCreateMode::PREVIEW - to enable a Preview, if possible are - only little information is needed - - SfxObjectCreateMode::ORGANIZER - to be displayed in the Organizer, here - nothing of the contents is used */ -) - -/* [Description] - - Constructor of the class SfxObjectShell. + @param eMode Purpose, to which the SfxObjectShell is created: + SfxObjectCreateMode::EMBEDDED (default) as SO-Server from within another Document + SfxObjectCreateMode::STANDARD, as a normal Document open stand-alone + SfxObjectCreateMode::PREVIEW to enable a Preview, if possible are only little information is needed + SfxObjectCreateMode::ORGANIZER to be displayed in the Organizer, here nothing of the contents is used */ - -: pImp( new SfxObjectShell_Impl( *this ) ), - pMedium(0), - pStyleSheetPool(0), - eCreateMode(eMode), - bHasName( false ), - bIsInGenerateThumbnail ( false ) +SfxObjectShell::SfxObjectShell(SfxObjectCreateMode eMode) + : pImp(new SfxObjectShell_Impl(*this)) + , pMedium(0) + , pStyleSheetPool(0) + , eCreateMode(eMode) + , bHasName(false) + , bIsInGenerateThumbnail(false) + , mbAvoidRecentDocs(false) { } - - -// virtual destructor of typical base-class SfxObjectShell - SfxObjectShell::~SfxObjectShell() { diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 80d893e909ff..1ccfe7dbe5a5 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -529,7 +529,8 @@ void SfxFrameLoader_Impl::impl_removeLoaderArguments( ::comphelper::NamedValueCo ::comphelper::NamedValueCollection SfxFrameLoader_Impl::impl_extractViewCreationArgs( ::comphelper::NamedValueCollection& io_rDescriptor ) { const sal_Char* pKnownViewArgs[] = { - "JumpMark" + "JumpMark", + "AvoidRecentDocs" }; ::comphelper::NamedValueCollection aViewArgs; diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 2a63b2c58233..f8cfe0c3b3f6 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1350,8 +1350,13 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ) if ( !rFrame.IsInPlace() ) pViewFrame->Resize( true ); + ::comphelper::NamedValueCollection aViewArgs(getCreationArguments()); + + // sometimes we want to avoid adding to the recent documents + bool bAvoidRecentDocs = aViewArgs.getOrDefault("AvoidRecentDocs", false); + m_pData->m_pViewShell->GetObjectShell()->AvoidRecentDocs(bAvoidRecentDocs); + // if there's a JumpMark given, then, well, jump to it - ::comphelper::NamedValueCollection aViewArgs( getCreationArguments() ); const OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", OUString() ); const bool bHasJumpMark = !sJumpMark.isEmpty(); OSL_ENSURE( ( !m_pData->m_pViewShell->GetObjectShell()->IsLoading() ) |