summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-11-28 23:22:28 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-11-29 16:34:43 -0500
commit764878deacb5018539ff5df71af8bf7e6677a93e (patch)
treecbbbd18529db5b5a937483342061d63e10f85618 /sc
parentec83990d247433feaba2e89b61430732d377b363 (diff)
Highlight all its child entries when a recurring element is selected.
Change-Id: I5d91d702fa0b55d9a9a63ef66a5ce243943e77a3
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/xmlsourcedlg.hxx3
-rw-r--r--sc/source/ui/xmlsource/xmlsourcedlg.cxx49
2 files changed, 52 insertions, 0 deletions
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index 1540b294cf94..9139a35c5753 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -19,6 +19,7 @@
#include "orcusxml.hxx"
#include <set>
+#include <vector>
#include <boost/scoped_ptr.hpp>
class ScDocument;
@@ -55,6 +56,7 @@ class ScXMLSourceDlg : public ScAnyRefDlg
ScOrcusXMLTreeParam maXMLParam;
std::set<const SvTreeListEntry*> maCellLinks;
std::set<const SvTreeListEntry*> maRangeLinks;
+ std::vector<SvTreeListEntry*> maSelectedEntries;
boost::scoped_ptr<ScOrcusXMLContext> mpXMLContext;
@@ -88,6 +90,7 @@ private:
void SetNonLinkable();
void SetSingleLinkable();
void SetRangeLinkable();
+ void SelectAllChildEntries(SvTreeListEntry& rEntry);
/**
* Check if any of its parents is linked or repeated. The passed entry is
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 7a3afd4a82e6..013ad69070e4 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -21,6 +21,7 @@
#include "tools/urlobj.hxx"
#include "svtools/svlbitm.hxx"
#include "svtools/treelistentry.hxx"
+#include "svtools/viewdataentry.hxx"
#include "sfx2/objsh.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -236,12 +237,44 @@ void ScXMLSourceDlg::HandleLoseFocus(Control* /*pCtrl*/)
{
}
+namespace {
+
+class UnselectEntry : std::unary_function<SvTreeListEntry*, void>
+{
+ SvTreeListBox& mrTree;
+ const SvTreeListEntry* mpCurrent;
+public:
+ UnselectEntry(SvTreeListBox& rTree, const SvTreeListEntry* pCur) : mrTree(rTree), mpCurrent(pCur) {}
+
+ void operator() (SvTreeListEntry* p)
+ {
+ if (p == mpCurrent)
+ return;
+
+ SvViewDataEntry* pView = mrTree.GetViewDataEntry(p);
+ if (!pView)
+ return;
+
+ pView->SetSelected(false);
+ mrTree.PaintEntry(p);
+ }
+};
+
+}
+
void ScXMLSourceDlg::TreeItemSelected()
{
SvTreeListEntry* pEntry = maLbTree.GetCurEntry();
if (!pEntry)
return;
+ if (!maSelectedEntries.empty())
+ {
+ // Unselect highlighted entries that are not currently selected.
+ std::for_each(maSelectedEntries.begin(), maSelectedEntries.end(), UnselectEntry(maLbTree, pEntry));
+ maSelectedEntries.clear();
+ }
+
ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry);
OSL_ASSERT(pUserData);
@@ -330,6 +363,7 @@ void ScXMLSourceDlg::RepeatElementSelected(SvTreeListEntry& rEntry)
return;
}
+ SelectAllChildEntries(rEntry);
SetRangeLinkable();
}
@@ -381,6 +415,21 @@ void ScXMLSourceDlg::SetRangeLinkable()
maRefBtn.Enable();
}
+void ScXMLSourceDlg::SelectAllChildEntries(SvTreeListEntry& rEntry)
+{
+ SvTreeListEntries& rChildren = rEntry.GetChildEntries();
+ SvTreeListEntries::iterator it = rChildren.begin(), itEnd = rChildren.end();
+ for (; it != itEnd; ++it)
+ {
+ SvTreeListEntry& r = *it;
+ SelectAllChildEntries(r); // select recursively.
+ SvViewDataEntry* p = maLbTree.GetViewDataEntry(&r);
+ p->SetSelected(true);
+ maLbTree.PaintEntry(&r);
+ maSelectedEntries.push_back(&r);
+ }
+}
+
bool ScXMLSourceDlg::IsParentDirty(SvTreeListEntry* pEntry) const
{
ScOrcusXMLTreeParam::EntryData* pUserData = NULL;