Kaydet (Commit) 5e3cbe05 authored tarafından Armin Le Grand's avatar Armin Le Grand

i125386 secured user request and changed some bools to bitfield

üst a02eb39b
......@@ -178,6 +178,9 @@ sal_Bool RemoveEmbeddedObject( const ::com::sun::star::uno::Reference
* \return <FALSE/> if no error occurred, otherwise <TRUE/>.
*/
sal_Bool SetPersistentEntries(const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);
bool getUserAllowsLinkUpdate() const;
void setUserAllowsLinkUpdate(bool bNew);
};
}
......
......@@ -92,7 +92,10 @@ struct EmbedImpl
uno::WeakReference < uno::XInterface > m_xModel;
//EmbeddedObjectContainerNameMap maTempObjectContainer;
//uno::Reference < embed::XStorage > mxTempStorage;
sal_Bool bOwnsStorage;
/// bitfield
bool mbOwnsStorage : 1;
bool mbUserAllowsLinkUpdate : 1;
const uno::Reference < embed::XStorage >& GetReplacements();
};
......@@ -123,7 +126,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer()
{
pImpl = new EmbedImpl;
pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
pImpl->bOwnsStorage = sal_True;
pImpl->mbOwnsStorage = true;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
}
......@@ -131,7 +135,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
{
pImpl = new EmbedImpl;
pImpl->mxStorage = rStor;
pImpl->bOwnsStorage = sal_False;
pImpl->mbOwnsStorage = false;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
}
......@@ -139,7 +144,8 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
{
pImpl = new EmbedImpl;
pImpl->mxStorage = rStor;
pImpl->bOwnsStorage = sal_False;
pImpl->mbOwnsStorage = false;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
pImpl->m_xModel = xModel;
}
......@@ -148,11 +154,11 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X
{
ReleaseImageSubStorage();
if ( pImpl->bOwnsStorage )
if ( pImpl->mbOwnsStorage )
pImpl->mxStorage->dispose();
pImpl->mxStorage = rStor;
pImpl->bOwnsStorage = sal_False;
pImpl->mbOwnsStorage = false;
}
sal_Bool EmbeddedObjectContainer::CommitImageSubStorage()
......@@ -208,7 +214,7 @@ EmbeddedObjectContainer::~EmbeddedObjectContainer()
{
ReleaseImageSubStorage();
if ( pImpl->bOwnsStorage )
if ( pImpl->mbOwnsStorage )
pImpl->mxStorage->dispose();
delete pImpl->mpTempObjectContainer;
......@@ -1401,7 +1407,7 @@ sal_Bool EmbeddedObjectContainer::StoreAsChildren(sal_Bool _bOasisFormat,sal_Boo
xStream = GetGraphicStream( xObj, &aMediaType );
}
if ( !xStream.is() )
if ( !xStream.is() && getUserAllowsLinkUpdate() )
{
// the image must be regenerated
// TODO/LATER: another aspect could be used
......@@ -1685,4 +1691,18 @@ sal_Bool EmbeddedObjectContainer::SetPersistentEntries(const uno::Reference< emb
}
return bError;
}
bool EmbeddedObjectContainer::getUserAllowsLinkUpdate() const
{
return pImpl->mbUserAllowsLinkUpdate;
}
void EmbeddedObjectContainer::setUserAllowsLinkUpdate(bool bNew)
{
if(pImpl->mbUserAllowsLinkUpdate != bNew)
{
pImpl->mbUserAllowsLinkUpdate = bNew;
}
}
}
......@@ -318,7 +318,17 @@ void LinkManager::UpdateAllLinks(
{
int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_YES, SfxResId( STR_QUERY_UPDATE_LINKS ) ).Execute();
if( RET_YES != nRet )
{
SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
if(pShell)
{
comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
}
return ; // es soll nichts geupdatet werden
}
bAskUpdate = sal_False; // einmal reicht
}
......
......@@ -709,19 +709,30 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( sal_Bool bUpdate ) const
if ( !xStream.is() )
{
RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" );
// update wanted or no stream in container storage available
xStream = GetGraphicReplacementStream( mpImp->nViewAspect, mxObj, &mpImp->aMediaType );
bool bUserAllowsLinkUpdate(true);
const comphelper::EmbeddedObjectContainer* pContainer = GetContainer();
if ( xStream.is() )
if(pContainer)
{
if ( mpImp->pContainer )
mpImp->pContainer->InsertGraphicStream( xStream, mpImp->aPersistName, mpImp->aMediaType );
bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate();
}
SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
if ( pResult && bUpdate )
mpImp->bNeedUpdate = sal_False;
if(bUserAllowsLinkUpdate)
{
// update wanted or no stream in container storage available
xStream = GetGraphicReplacementStream(mpImp->nViewAspect,mxObj,&mpImp->aMediaType);
return pResult;
if(xStream.is())
{
if(mpImp->pContainer)
mpImp->pContainer->InsertGraphicStream(xStream,mpImp->aPersistName,mpImp->aMediaType);
SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
if ( pResult && bUpdate )
mpImp->bNeedUpdate = sal_False;
return pResult;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment