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

Highlight all its child entries when a recurring element is selected.

Change-Id: I5d91d702fa0b55d9a9a63ef66a5ce243943e77a3
üst ec83990d
......@@ -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
......
......@@ -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;
......
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