ofz#24404 row insert attempt in table with same table already in the row
Change-Id: I0f52de029600b182e479af3bdf56da7ea2c2ef01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99691 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
parent
b18a2228ad
commit
b1dc1c740e
3 changed files with 21 additions and 1 deletions
|
@ -125,6 +125,8 @@ public:
|
|||
*/
|
||||
virtual void ToXml(IXFStream *pStrm) override;
|
||||
|
||||
bool HierarchyContains(const XFContent *pContent) const;
|
||||
|
||||
private:
|
||||
std::vector< rtl::Reference<XFContent> > m_aContents;
|
||||
};
|
||||
|
|
|
@ -80,6 +80,24 @@ void XFContentContainer::Add(const OUString& text)
|
|||
Add(xTC.get());
|
||||
}
|
||||
|
||||
bool XFContentContainer::HierarchyContains(const XFContent *pContent) const
|
||||
{
|
||||
if (pContent == this)
|
||||
return true;
|
||||
|
||||
for (int i = 0, nCount = GetCount(); i < nCount; i++)
|
||||
{
|
||||
rtl::Reference<XFContent> xContent = GetContent(i);
|
||||
if (xContent.get() == pContent)
|
||||
return true;
|
||||
const XFContentContainer *pChildCont = dynamic_cast<const XFContentContainer*>(xContent.get());
|
||||
if (pChildCont && pChildCont->HierarchyContains(pContent))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int XFContentContainer::GetCount() const
|
||||
{
|
||||
return m_aContents.size();
|
||||
|
|
|
@ -88,7 +88,7 @@ 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)
|
||||
if (pFirstCell->GetSubTable() == this || pFirstCell->HierarchyContains(this))
|
||||
throw std::runtime_error("table is a subtable of itself");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue