diff options
author | Armin Le Grand <alg@apache.org> | 2014-08-07 09:59:26 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-08-09 14:13:08 +0100 |
commit | d005acae3aa315921f2c331612131626c470bd22 (patch) | |
tree | af56821361fa3207f147ddf393b90ad98945cc85 | |
parent | bb8540a3b4fe0798669a1d355695c97d86ef58a0 (diff) |
Resolves: #i125386# secured user request and changed some bools to bitfield
(cherry picked from commit 5e3cbe056c19bea5018dbf1fd4b2bc8f8b030ff3)
Conflicts:
comphelper/inc/comphelper/embeddedobjectcontainer.hxx
comphelper/source/container/embeddedobjectcontainer.cxx
sfx2/source/appl/linkmgr2.cxx
svtools/source/misc/embedhlp.cxx
Change-Id: I7e9b20a87ca6afe8cb91c577860a6c6b72368ee9
-rw-r--r-- | comphelper/source/container/embeddedobjectcontainer.cxx | 36 | ||||
-rw-r--r-- | include/comphelper/embeddedobjectcontainer.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/linkmgr2.cxx | 12 | ||||
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 29 |
4 files changed, 62 insertions, 18 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index d614c1a725e9..e3696f1e4403 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -62,7 +62,10 @@ struct EmbedImpl uno::WeakReference < uno::XInterface > m_xModel; //EmbeddedObjectContainerNameMap maTempObjectContainer; //uno::Reference < embed::XStorage > mxTempStorage; - bool bOwnsStorage; + + /// bitfield + bool mbOwnsStorage : 1; + bool mbUserAllowsLinkUpdate : 1; const uno::Reference < embed::XStorage >& GetReplacements(); }; @@ -93,7 +96,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer() { pImpl = new EmbedImpl; pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); - pImpl->bOwnsStorage = true; + pImpl->mbOwnsStorage = true; + pImpl->mbUserAllowsLinkUpdate = true; pImpl->mpTempObjectContainer = 0; } @@ -101,7 +105,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed:: { pImpl = new EmbedImpl; pImpl->mxStorage = rStor; - pImpl->bOwnsStorage = false; + pImpl->mbOwnsStorage = false; + pImpl->mbUserAllowsLinkUpdate = true; pImpl->mpTempObjectContainer = 0; } @@ -109,7 +114,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed:: { pImpl = new EmbedImpl; pImpl->mxStorage = rStor; - pImpl->bOwnsStorage = false; + pImpl->mbOwnsStorage = false; + pImpl->mbUserAllowsLinkUpdate = true; pImpl->mpTempObjectContainer = 0; pImpl->m_xModel = xModel; } @@ -118,11 +124,11 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X { ReleaseImageSubStorage(); - if ( pImpl->bOwnsStorage ) + if ( pImpl->mbOwnsStorage ) pImpl->mxStorage->dispose(); pImpl->mxStorage = rStor; - pImpl->bOwnsStorage = false; + pImpl->mbOwnsStorage = false; } bool EmbeddedObjectContainer::CommitImageSubStorage() @@ -178,7 +184,7 @@ EmbeddedObjectContainer::~EmbeddedObjectContainer() { ReleaseImageSubStorage(); - if ( pImpl->bOwnsStorage ) + if ( pImpl->mbOwnsStorage ) pImpl->mxStorage->dispose(); delete pImpl->mpTempObjectContainer; @@ -1337,7 +1343,7 @@ bool EmbeddedObjectContainer::StoreAsChildren(bool _bOasisFormat,bool _bCreateEm xStream = GetGraphicStream( xObj, &aMediaType ); } - if ( !xStream.is() ) + if ( !xStream.is() && getUserAllowsLinkUpdate() ) { // the image must be regenerated // TODO/LATER: another aspect could be used @@ -1626,6 +1632,20 @@ bool EmbeddedObjectContainer::SetPersistentEntries(const uno::Reference< embed:: } return bError; } + +bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const +{ + return pImpl->mbUserAllowsLinkUpdate; +} + +void EmbeddedObjectContainer::setUserAllowsLinkUpdate(bool bNew) +{ + if(pImpl->mbUserAllowsLinkUpdate != bNew) + { + pImpl->mbUserAllowsLinkUpdate = bNew; + } +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx index 8895a8d09808..2c8e25f5e8a5 100644 --- a/include/comphelper/embeddedobjectcontainer.hxx +++ b/include/comphelper/embeddedobjectcontainer.hxx @@ -181,6 +181,9 @@ public: * \return <FALSE/> if no error occurred, otherwise <TRUE/>. */ bool SetPersistentEntries(const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true); + + bool getUserAllowsLinkUpdate() const; + void setUserAllowsLinkUpdate(bool bNew); }; } diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 501ec5457d00..c5e38888f4cc 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -329,7 +329,17 @@ void LinkManager::UpdateAllLinks( { int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_YES, SfxResId( STR_QUERY_UPDATE_LINKS ).toString() ).Execute(); if( RET_YES != nRet ) - return ; // nothing should be updated + { + SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); + + if(pShell) + { + comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer(); + rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); + } + + return ; // nothing should be updated + } bAskUpdate = false; // once is enough } diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index c1c3462a81c5..238ea0379201 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -604,19 +604,30 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const if ( !xStream.is() ) { SAL_INFO( "svtools.misc", "getting stream from object" ); - // update wanted or no stream in container storage available - xStream = GetGraphicReplacementStream(mpImpl->nViewAspect, mpImpl->mxObj, &mpImpl->aMediaType); + bool bUserAllowsLinkUpdate(true); + const comphelper::EmbeddedObjectContainer* pContainer = GetContainer(); - if ( xStream.is() ) + if(pContainer) { - if ( mpImpl->pContainer ) - mpImpl->pContainer->InsertGraphicStream( xStream, mpImpl->aPersistName, mpImpl->aMediaType ); + bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate(); + } - SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream ); - if ( pResult && bUpdate ) - mpImpl->bNeedUpdate = false; + if(bUserAllowsLinkUpdate) + { + // update wanted or no stream in container storage available + xStream = GetGraphicReplacementStream(mpImpl->nViewAspect, mpImpl->mxObj, &mpImpl->aMediaType); - return pResult; + if(xStream.is()) + { + if (mpImpl->pContainer) + mpImpl->pContainer->InsertGraphicStream(xStream,mpImpl->aPersistName,mpImpl->aMediaType); + + SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream ); + if (pResult && bUpdate) + mpImpl->bNeedUpdate = false; + + return pResult; + } } } |