summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/documen2.cxx6
-rw-r--r--sfx2/inc/sfx2/linkmgr.hxx10
-rw-r--r--sfx2/source/appl/linkmgr2.cxx66
3 files changed, 63 insertions, 19 deletions
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index f3914008756d..58de13973f57 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -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 );
@@ -269,6 +272,7 @@ sfx2::LinkManager* ScDocument::GetLinkManager() const
if ( bAutoCalc && !pLinkManager && pShell)
{
pLinkManager = new sfx2::LinkManager( pShell );
+ pLinkManager->SetAutoAskUpdateAllLinks();
}
return pLinkManager;
}
diff --git a/sfx2/inc/sfx2/linkmgr.hxx b/sfx2/inc/sfx2/linkmgr.hxx
index 6e37aa2809bf..7bb58ee015ca 100644
--- a/sfx2/inc/sfx2/linkmgr.hxx
+++ b/sfx2/inc/sfx2/linkmgr.hxx
@@ -54,6 +54,13 @@ class SFX2_DLLPUBLIC LinkManager
SvLinkSources aServerTbl;
SfxObjectShell *pPersist; // LinkMgr has to be deallocated before SfxObjectShell
+
+ 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 );
@@ -140,6 +147,9 @@ public:
const ::com::sun::star::uno::Any & rValue,
Graphic& rGrf );
+ // Automatically ask user about update all links, on first insert
+ void SetAutoAskUpdateAllLinks();
+
private:
LinkManager( const LinkManager& );
LinkManager& operator=( const LinkManager& );
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index f6b00ded0ea9..80795e68b206 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -65,11 +65,12 @@ public:
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();
@@ -143,6 +144,7 @@ void LinkManager::Remove( sal_uInt16 nPos, sal_uInt16 nCnt )
sal_Bool LinkManager::Insert( SvBaseLink* pLink )
{
+
// do not insert links double
for( sal_uInt16 n = 0; n < aLinkTbl.Count(); ++n )
{
@@ -157,6 +159,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;
}
@@ -268,6 +276,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,
@@ -313,25 +350,18 @@ void LinkManager::UpdateAllLinks(
( !bUpdateGrfLinks && OBJECT_CLIENT_GRF == pLink->GetObjType() ))
continue;
- if( bAskUpdate )
- {
- int nRet = QueryBox( pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId( STR_QUERY_UPDATE_LINKS ) ).Execute();
- SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
+ sal_Bool allows = sal_True;
- if(pShell)
- {
- comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
- rEmbeddedObjectContainer.setUserAllowsLinkUpdate(RET_YES == nRet);
- }
-
- if (RET_YES != nRet)
- {
- return; // nothing should be updated
- }
- bAskUpdate = sal_False; // one time is OK
+ if (bAskUpdate)
+ {
+ allows = GetUserAllowsLinkUpdate(pParentWin);
}
- pLink->Update();
+ SetUserAllowsLinkUpdate(pLink, allows);
+ bAskUpdate = sal_False; // one time is OK
+
+ if (allows)
+ pLink->Update();
}
}