[Libreoffice-commits] .: sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Jun 6 18:32:00 PDT 2011


 sc/inc/document.hxx              |    2 +-
 sc/inc/sc.hrc                    |    3 ++-
 sc/source/core/data/documen8.cxx |   37 +++++++++++++++++++++++++------------
 sc/source/ui/docshell/docsh4.cxx |    2 +-
 sc/source/ui/src/scstring.src    |    5 +++++
 5 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit c29bbabaf7d807f9f2341c95cf6193f236aad350
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Jun 6 21:27:35 2011 -0400

    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.

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9426393..2b79111 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -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
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index ac00c69..dbee75b 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -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)
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index c8e5fda..8b2d2cd 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -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();
     }
 }
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index b35c1fe..dc86080 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -493,7 +493,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
                 {
                     ReloadTabLinks();
                     aDocument.UpdateExternalRefLinks(GetActiveDialogParent());
-                    aDocument.UpdateDdeLinks();
+                    aDocument.UpdateDdeLinks(GetActiveDialogParent());
                     aDocument.UpdateAreaLinks();
 
                     //! Test, ob Fehler
diff --git a/sc/source/ui/src/scstring.src b/sc/source/ui/src/scstring.src
index 42582f7..af09c65 100644
--- a/sc/source/ui/src/scstring.src
+++ b/sc/source/ui/src/scstring.src
@@ -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." ;


More information about the Libreoffice-commits mailing list