summaryrefslogtreecommitdiff
path: root/sc/source/ui/xmlsource
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-10-12 23:42:27 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-11-28 13:28:26 -0500
commit8cb7229b3179d9cea0d360079bb051445bc1cdf9 (patch)
tree75db9d25260598e2e044960cd7167cffec42230f /sc/source/ui/xmlsource
parent468dd7eebb8ceb35692660584b70de1af36fa59b (diff)
Handle selection of repeat element.
Change-Id: I73eb83fbbd6deb39ba3e736410b8d5b50f3dffaa
Diffstat (limited to 'sc/source/ui/xmlsource')
-rw-r--r--sc/source/ui/xmlsource/xmlsourcedlg.cxx50
1 files changed, 45 insertions, 5 deletions
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 75cba634e045..e6f39e3df7df 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -267,12 +267,26 @@ void ScXMLSourceDlg::DefaultElementSelected(SvLBoxEntry& rEntry)
void ScXMLSourceDlg::RepeatElementSelected(SvLBoxEntry& rEntry)
{
- // TODO: Check all its child elements / attributes and make sure non of
- // them are linked or repeat elements. In the future we will support
- // range linking of repeat element who has another repeat elements. But
- // first I need to support that in orcus.
+ // Check all its parents first.
- SetNonLinkable();
+ if (IsParentDirty(&rEntry))
+ {
+ SetNonLinkable();
+ return;
+ }
+
+ // Check all its child elements / attributes and make sure non of them are
+ // linked or repeat elements. In the future we will support range linking
+ // of repeat element who has another repeat elements. But first I need to
+ // support that scenario in orcus.
+
+ if (IsChildrenDirty(&rEntry))
+ {
+ SetNonLinkable();
+ return;
+ }
+
+ SetRangeLinkable();
}
void ScXMLSourceDlg::AttributeSelected(SvLBoxEntry& rEntry)
@@ -346,6 +360,32 @@ bool ScXMLSourceDlg::IsParentDirty(SvLBoxEntry* pEntry) const
return false;
}
+bool ScXMLSourceDlg::IsChildrenDirty(SvLBoxEntry* pEntry) const
+{
+ ScOrcusXMLTreeParam::EntryData* pUserData = NULL;
+ for (SvLBoxEntry* pChild = maLbTree.FirstChild(pEntry); pChild; pChild = maLbTree.NextSibling(pChild))
+ {
+ pUserData = ScOrcusXMLTreeParam::getUserData(*pChild);
+ OSL_ASSERT(pUserData);
+ if (pUserData->maLinkedPos.IsValid())
+ // Already linked.
+ return true;
+
+ if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat)
+ // We don't support linking of nested repeat elements (yet).
+ return true;
+
+ if (pUserData->meType == ScOrcusXMLTreeParam::ElementDefault)
+ {
+ // Check recursively.
+ if (IsChildrenDirty(pChild))
+ return true;
+ }
+ }
+
+ return false;
+}
+
IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl)
{
HandleGetFocus(pCtrl);