summaryrefslogtreecommitdiff
path: root/sc/source/ui/xmlsource
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/source/ui/xmlsource
parentec83990d247433feaba2e89b61430732d377b363 (diff)
Highlight all its child entries when a recurring element is selected.
Change-Id: I5d91d702fa0b55d9a9a63ef66a5ce243943e77a3
Diffstat (limited to 'sc/source/ui/xmlsource')
-rw-r--r--sc/source/ui/xmlsource/xmlsourcedlg.cxx49
1 files changed, 49 insertions, 0 deletions
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;