Skip to content

Commit

Permalink
OLE update verification. Keep user in-the-know and query them.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/openoffice/branches/AOO414@1809153 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jimjag committed Sep 21, 2017
1 parent 404f132 commit 611fcda
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 22 deletions.
6 changes: 3 additions & 3 deletions main/comphelper/source/container/embeddedobjectcontainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ EmbeddedObjectContainer::EmbeddedObjectContainer()
pImpl = new EmbedImpl;
pImpl->mxStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
pImpl->mbOwnsStorage = true;
pImpl->mbUserAllowsLinkUpdate = false;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
}

Expand All @@ -136,7 +136,7 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
pImpl = new EmbedImpl;
pImpl->mxStorage = rStor;
pImpl->mbOwnsStorage = false;
pImpl->mbUserAllowsLinkUpdate = false;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
}

Expand All @@ -145,7 +145,7 @@ EmbeddedObjectContainer::EmbeddedObjectContainer( const uno::Reference < embed::
pImpl = new EmbedImpl;
pImpl->mxStorage = rStor;
pImpl->mbOwnsStorage = false;
pImpl->mbUserAllowsLinkUpdate = false;
pImpl->mbUserAllowsLinkUpdate = true;
pImpl->mpTempObjectContainer = 0;
pImpl->m_xModel = xModel;
}
Expand Down
6 changes: 5 additions & 1 deletion main/sc/source/core/data/documen2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ ScDocument::ScDocument( ScDocumentMode eMode,
if ( eMode == SCDOCMODE_DOCUMENT )
{
if ( pDocShell )
pLinkManager = new sfx2::LinkManager( pDocShell );
{
pLinkManager = new sfx2::LinkManager(pDocShell);
pLinkManager->SetAutoAskUpdateAllLinks();
}

xPoolHelper = new ScPoolHelper( this );

Expand Down Expand Up @@ -269,6 +272,7 @@ sfx2::LinkManager* ScDocument::GetLinkManager() const
if ( bAutoCalc && !pLinkManager && pShell)
{
pLinkManager = new sfx2::LinkManager( pShell );
pLinkManager->SetAutoAskUpdateAllLinks();
}
return pLinkManager;
}
Expand Down
11 changes: 11 additions & 0 deletions main/sfx2/inc/sfx2/linkmgr.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class SFX2_DLLPUBLIC LinkManager
SvLinkSources aServerTbl;

SfxObjectShell *pPersist; // LinkMgr muss vor SfxObjectShell freigegeben werden

sal_Bool mAutoAskUpdateAllLinks;
sal_Bool mUpdateAsked;
sal_Bool mAllowUpdate;

sal_Bool GetUserAllowsLinkUpdate(Window *pParent);
void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows);
protected:
sal_Bool InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
const String* pName = 0 );
Expand Down Expand Up @@ -105,6 +112,10 @@ public:

SvLinkSourceRef CreateObj( SvBaseLink* );


// Automatically ask user about update all links, on first insert
void SetAutoAskUpdateAllLinks();

void UpdateAllLinks( sal_Bool bAskUpdate = sal_True,
sal_Bool bCallErrHdl = sal_True,
sal_Bool bUpdateGrfLinks = sal_False,
Expand Down
66 changes: 48 additions & 18 deletions main/sfx2/source/appl/linkmgr2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ class SvxInternalLink : public sfx2::SvLinkSource
SV_IMPL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr )

LinkManager::LinkManager(SfxObjectShell* p)
: pPersist( p )
: pPersist(p),
mUpdateAsked(sal_False),
mAutoAskUpdateAllLinks(sal_False)
{
}


LinkManager::~LinkManager()
{
SvBaseLinkRef** ppRef = (SvBaseLinkRef**)aLinkTbl.GetData();
Expand Down Expand Up @@ -157,6 +158,12 @@ sal_Bool LinkManager::Insert( SvBaseLink* pLink )
SvBaseLinkRef* pTmp = new SvBaseLinkRef( pLink );
pLink->SetLinkManager( this );
aLinkTbl.Insert( pTmp, aLinkTbl.Count() );
Window *parent = GetPersist()->GetDialogParent();
if (mAutoAskUpdateAllLinks)
{
SetUserAllowsLinkUpdate(pLink, GetUserAllowsLinkUpdate(parent));
}

return sal_True;
}

Expand Down Expand Up @@ -268,6 +275,35 @@ sal_Bool LinkManager::GetDisplayNames( const SvBaseLink * pLink,
return bRet;
}

void LinkManager::SetAutoAskUpdateAllLinks()
{
mAutoAskUpdateAllLinks = sal_True;
}

sal_Bool LinkManager::GetUserAllowsLinkUpdate(Window *pParentWin)
{
if (!mUpdateAsked)
{
if (QueryBox(pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId(STR_QUERY_UPDATE_LINKS)).Execute() == RET_YES)
mAllowUpdate = sal_True;
else
mAllowUpdate = sal_False;
mUpdateAsked = sal_True;
}
return mAllowUpdate;
}

void LinkManager::SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows)
{
SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();

if (pShell)
{
comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
rEmbeddedObjectContainer.setUserAllowsLinkUpdate(allows);
}
}


void LinkManager::UpdateAllLinks(
sal_Bool bAskUpdate,
Expand Down Expand Up @@ -313,26 +349,20 @@ void LinkManager::UpdateAllLinks(
if( !pLink->IsVisible() ||
( !bUpdateGrfLinks && OBJECT_CLIENT_GRF == pLink->GetObjType() ))
continue;

if( bAskUpdate )

sal_Bool allows = sal_False;

if (bAskUpdate)
{
int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId( STR_QUERY_UPDATE_LINKS ) ).Execute();
SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
allows = GetUserAllowsLinkUpdate(pParentWin);
}

if(pShell)
{
comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
rEmbeddedObjectContainer.setUserAllowsLinkUpdate(RET_YES == nRet);
}
SetUserAllowsLinkUpdate(pLink, allows);
bAskUpdate = sal_False; // one time is OK

if (RET_YES != nRet)
{
return; // nothing should be updated
}
bAskUpdate = sal_False; // one time is OK
}
if (allows)
pLink->Update();

pLink->Update();
}
}

Expand Down

0 comments on commit 611fcda

Please sign in to comment.