summaryrefslogtreecommitdiff
path: root/lotuswordpro/source
diff options
context:
space:
mode:
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcell.cxx2
-rw-r--r--lotuswordpro/source/filter/xfilter/xftable.cxx32
2 files changed, 32 insertions, 2 deletions
diff --git a/lotuswordpro/source/filter/xfilter/xfcell.cxx b/lotuswordpro/source/filter/xfilter/xfcell.cxx
index bbfde6eab9f3..dfc5889db652 100644
--- a/lotuswordpro/source/filter/xfilter/xfcell.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfcell.cxx
@@ -157,7 +157,7 @@ OUString XFCell::GetCellName()
return name;
}
-void XFCell::ToXml(IXFStream *pStrm)
+void XFCell::ToXml(IXFStream *pStrm)
{
IXFAttrList *pAttrList = pStrm->GetAttrList();
diff --git a/lotuswordpro/source/filter/xfilter/xftable.cxx b/lotuswordpro/source/filter/xfilter/xftable.cxx
index 6acb1b21a35f..4326f218b1e2 100644
--- a/lotuswordpro/source/filter/xfilter/xftable.cxx
+++ b/lotuswordpro/source/filter/xfilter/xftable.cxx
@@ -81,6 +81,30 @@ void XFTable::SetColumnStyle(sal_Int32 col, const OUString& style)
m_aColumns[col] = style;
}
+bool XFTable::ContainsTable(const XFTable* pTable) const
+{
+ for (auto const& elem : m_aRows)
+ {
+ const XFRow *pRow = elem.second.get();
+
+ for (sal_Int32 i = 0; i < pRow->GetCellCount(); ++i)
+ {
+ const XFCell* pCell = pRow->GetCell(i + 1); //starts at 1, not 0
+ if (const XFTable* pSubTable = pCell->GetSubTable())
+ {
+ if (pSubTable == pTable)
+ return true;
+ if (pTable->ContainsTable(pTable))
+ return true;
+ }
+ if (pCell->HierarchyContains(pTable))
+ return true;
+ }
+ }
+
+ return false;
+}
+
void XFTable::AddRow(rtl::Reference<XFRow> const & rRow)
{
assert(rRow);
@@ -88,8 +112,14 @@ void XFTable::AddRow(rtl::Reference<XFRow> const & rRow)
for (sal_Int32 i = 0; i < rRow->GetCellCount(); ++i)
{
XFCell* pFirstCell = rRow->GetCell(i + 1); //starts at 1, not 0
- if (pFirstCell->GetSubTable() == this || pFirstCell->HierarchyContains(this))
+ if (const XFTable* pSubTable = pFirstCell->GetSubTable())
+ {
+ if (pSubTable == this || pSubTable->ContainsTable(this))
+ throw std::runtime_error("table is a subtable of itself");
+ }
+ if (pFirstCell->HierarchyContains(this))
throw std::runtime_error("table is a subtable of itself");
+
}
int row = rRow->GetRow();