sw layout xml dump: extract SwTable::dumpAsXml() from SwTableNode

The idea is that each class only dumps itself & what it owns, otherwise
the same info is dumped multiple times.

Change-Id: Ib21bd2d31aa0d70d58b2b8aa453e0ede788c7144
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146511
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna 2023-02-02 20:10:17 +01:00
parent a834bbad82
commit 2422e1b041
3 changed files with 20 additions and 11 deletions

View file

@ -357,6 +357,8 @@ public:
// it doesn't contain box content (except single empty nested tables of the boxes
// which could remain after deletion of text content of the selected table)
bool IsEmpty() const;
void dumpAsXml(xmlTextWriterPtr pWriter) const;
};
/// SwTableLine is one table row in the document model.

View file

@ -2488,17 +2488,7 @@ void SwTableNode::dumpAsXml(xmlTextWriterPtr pWriter) const
if (m_pTable)
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTable"));
(void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", m_pTable.get());
m_pTable->GetFrameFormat()->dumpAsXml(pWriter);
for (const auto& pLine : m_pTable->GetTabLines())
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTableLine"));
(void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pLine);
pLine->GetFrameFormat()->dumpAsXml(pWriter);
(void)xmlTextWriterEndElement(pWriter);
}
(void)xmlTextWriterEndElement(pWriter);
m_pTable->dumpAsXml(pWriter);
}
// (void)xmlTextWriterEndElement(pWriter); - it is a start node, so don't end, will make xml better nested

View file

@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <libxml/xmlwriter.h>
#include <hintids.hxx>
#include <hints.hxx>
#include <editeng/lrspitem.hxx>
@ -1610,6 +1612,21 @@ bool SwTable::IsDeleted() const
return true;
}
void SwTable::dumpAsXml(xmlTextWriterPtr pWriter) const
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTable"));
(void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
GetFrameFormat()->dumpAsXml(pWriter);
for (const auto& pLine : GetTabLines())
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTableLine"));
(void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pLine);
pLine->GetFrameFormat()->dumpAsXml(pWriter);
(void)xmlTextWriterEndElement(pWriter);
}
(void)xmlTextWriterEndElement(pWriter);
}
// TODO Set HasTextChangesOnly=true, if needed based on the redlines in the cells.
// At tracked row deletion, return with the newest deletion of the row or
// at tracked row insertion, return with the oldest insertion in the row, which