Kaydet (Commit) b2570e4a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Useful error message when DDE link update fails.

When the document contains DDE links to other documents, upon opening
you'll be asked whether you want to update the links.  When the
source documents are not open, however, the update fails, and all the
formula cells being updated become #N/A.  Not good.

With this change, when a DDE update fails, it skips updating the
formula cells that contains the DDE linkage (thus avoiding the #N/A
error) and instead, shows an error message telling the user that the
DDE link update has failed.
üst 1d2d9a28
......@@ -640,7 +640,7 @@ public:
bool HasDdeLinks() const;
bool HasAreaLinks() const;
void UpdateExternalRefLinks(Window* pWin);
void UpdateDdeLinks();
void UpdateDdeLinks(Window* pWin);
void UpdateAreaLinks();
// originating DDE links
......
......@@ -1014,7 +1014,8 @@
#define SCSTR_SET_TAB_BG_COLOR (STR_START + 403)
#define SCSTR_NO_TAB_BG_COLOR (STR_START + 404)
#define SCSTR_EXTDOC_NOT_LOADED (STR_START + 405)
#define SCSTR_DDEDOC_NOT_LOADED (STR_START + 405)
#define SCSTR_EXTDOC_NOT_LOADED (STR_START + 406)
#define STR_END (SCSTR_EXTDOC_NOT_LOADED)
......
......@@ -1070,7 +1070,7 @@ void ScDocument::UpdateExternalRefLinks(Window* pWin)
}
}
void ScDocument::UpdateDdeLinks()
void ScDocument::UpdateDdeLinks(Window* pWin)
{
if (GetLinkManager())
{
......@@ -1080,14 +1080,34 @@ void ScDocument::UpdateDdeLinks()
// falls das Updaten laenger dauert, erstmal alle Werte
// zuruecksetzen, damit nichts altes (falsches) stehen bleibt
sal_Bool bAny = false;
bool bAny = false;
for (i=0; i<nCount; i++)
{
::sfx2::SvBaseLink* pBase = *rLinks[i];
if (pBase->ISA(ScDdeLink))
ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
if (pDdeLink)
{
((ScDdeLink*)pBase)->ResetValue();
bAny = sal_True;
if (pDdeLink->Update())
bAny = true;
else
{
// Update failed. Notify the user.
rtl::OUString aFile = pDdeLink->GetTopic();
rtl::OUString aElem = pDdeLink->GetItem();
rtl::OUString aType = pDdeLink->GetAppl();
rtl::OUStringBuffer aBuf;
aBuf.append(String(ScResId(SCSTR_DDEDOC_NOT_LOADED)));
aBuf.appendAscii("\n\n");
aBuf.appendAscii("Source : ");
aBuf.append(aFile);
aBuf.appendAscii("\nElement : ");
aBuf.append(aElem);
aBuf.appendAscii("\nType : ");
aBuf.append(aType);
ErrorBox aBox(pWin, WB_OK, aBuf.makeStringAndClear());
aBox.Execute();
}
}
}
if (bAny)
......@@ -1101,13 +1121,6 @@ void ScDocument::UpdateDdeLinks()
// (z.B. mit Invalidate am Window), muss hier ein Update erzwungen werden.
}
// nun wirklich updaten...
for (i=0; i<nCount; i++)
{
::sfx2::SvBaseLink* pBase = *rLinks[i];
if (pBase->ISA(ScDdeLink))
((ScDdeLink*)pBase)->TryUpdate(); // bei DDE-Links TryUpdate statt Update
}
pLinkManager->CloseCachedComps();
}
}
......
......@@ -493,7 +493,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
{
ReloadTabLinks();
aDocument.UpdateExternalRefLinks(GetActiveDialogParent());
aDocument.UpdateDdeLinks();
aDocument.UpdateDdeLinks(GetActiveDialogParent());
aDocument.UpdateAreaLinks();
//! Test, ob Fehler
......
......@@ -855,6 +855,11 @@ String SCSTR_WARN_ME_IN_FUTURE_CHECK
Text [ en-US ] = "Warn me about this in the future.";
};
String SCSTR_DDEDOC_NOT_LOADED
{
Text [ en-US ] = "The following DDE source could not be updated possibly because the source document was not open. Please launch the source document and try again." ;
};
String SCSTR_EXTDOC_NOT_LOADED
{
Text [ en-US ] = "The following external file could not be loaded. Data linked from this file did not get updated." ;
......
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