[Libreoffice-commits] .: Branch 'feature/calc-xml-source' - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 12 18:47:12 PDT 2012


 sc/inc/orcusxml.hxx                     |    2 ++
 sc/source/core/tool/orcusxml.cxx        |    2 +-
 sc/source/ui/xmlsource/xmlsourcedlg.cxx |   22 +++++++++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit c4b0a72e246c2915339e3e5e0d3140944c48aa36
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Oct 12 21:47:20 2012 -0400

    Keep track of linked cell positions.
    
    Change-Id: I33e39e53b618270561ba7bfc236e8d8558bccffa

diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index d615ab6..4fa223e 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -11,6 +11,7 @@
 #define __SC_ORCUSXML_HXX__
 
 #include "scdllapi.h"
+#include "address.hxx"
 #include "vcl/image.hxx"
 
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -28,6 +29,7 @@ struct ScOrcusXMLTreeParam
     struct EntryData
     {
         EntryType meType;
+        ScAddress maLinkedPos; /// linked cell position (invalid if unlinked)
 
         SC_DLLPUBLIC EntryData(EntryType eType);
     };
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index 4e9ef80..c5e0ac1 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -12,7 +12,7 @@
 #include "svtools/treelistbox.hxx"
 
 ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) :
-    meType(eType) {}
+    meType(eType), maLinkedPos(ScAddress::INITIALIZE_INVALID) {}
 
 ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(SvLBoxEntry& rEntry)
 {
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index c4fb781..561f98d 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -88,6 +88,17 @@ void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
     OUString aStr;
     rRange.aStart.Format(aStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention());
     mpActiveEdit->SetRefString(aStr);
+
+    // Set this address to currently selected tree item.
+    SvLBoxEntry* pEntry = maLbTree.GetCurEntry();
+    if (!pEntry)
+        return;
+
+    ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry);
+    if (!pUserData)
+        return;
+
+    pUserData->maLinkedPos = rRange.aStart;
 }
 
 void ScXMLSourceDlg::Deactivate()
@@ -188,10 +199,19 @@ void ScXMLSourceDlg::TreeItemSelected()
         return;
 
     ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry);
-
     if (!pUserData)
         return;
 
+    const ScAddress& rPos = pUserData->maLinkedPos;
+    if (rPos.IsValid())
+    {
+        OUString aStr;
+        rPos.Format(aStr, SCA_ABS_3D, mpDoc, mpDoc->GetAddressConvention());
+        maRefEdit.SetRefString(aStr);
+    }
+    else
+        maRefEdit.SetRefString(OUString());
+
     switch (pUserData->meType)
     {
         case ScOrcusXMLTreeParam::Attribute:


More information about the Libreoffice-commits mailing list