summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-03-03 07:59:47 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-03-03 09:54:18 +0000
commit70d0281bbd36c25b5251f4e1c99507084659db90 (patch)
tree598d50a7ed98f7bf57e3fd55dc8efa02a80bfed4
parente66632b023ee1cf25a381536f53458f631964bb8 (diff)
sw layout xml dump: extract SwPageFrame::dumpAsXml() from SwFrame
Avoids an ugly static downcast. Change-Id: I66f59409788f04e03c8c36bb12dc4ba7d3446663 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148159 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/source/core/inc/pagefrm.hxx2
-rw-r--r--sw/source/core/layout/pagechg.cxx58
-rw-r--r--sw/source/core/text/xmldump.cxx41
3 files changed, 60 insertions, 41 deletions
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 88004bb7ccb3..cd2f14f5e885 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -346,6 +346,8 @@ public:
const SwHeaderFrame* GetHeaderFrame() const;
const SwFooterFrame* GetFooterFrame() const;
+
+ void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
};
inline SwContentFrame *SwPageFrame::FindFirstBodyContent()
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index adbcd85f4b37..152368d9d913 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -2589,6 +2589,64 @@ const SwFooterFrame* SwPageFrame::GetFooterFrame() const
return nullptr;
}
+void SwPageFrame::dumpAsXml(xmlTextWriterPtr writer) const
+{
+ (void)xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>("page"));
+ dumpAsXmlAttributes(writer);
+
+ (void)xmlTextWriterStartElement(writer, BAD_CAST("page_status"));
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyLayout"), BAD_CAST(OString::boolean(!IsInvalidFlyLayout()).getStr()));
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyContent"), BAD_CAST(OString::boolean(!IsInvalidFlyContent()).getStr()));
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyInCnt"), BAD_CAST(OString::boolean(!IsInvalidFlyInCnt()).getStr()));
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidLayout"), BAD_CAST(OString::boolean(!IsInvalidLayout()).getStr()));
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidContent"), BAD_CAST(OString::boolean(!IsInvalidContent()).getStr()));
+ (void)xmlTextWriterEndElement(writer);
+ (void)xmlTextWriterStartElement(writer, BAD_CAST("page_info"));
+ (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("phyNum"), "%d", GetPhyPageNum());
+ (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("virtNum"), "%d", GetVirtPageNum());
+ OUString aFormatName = GetPageDesc()->GetName();
+ (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("pageDesc"), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
+ (void)xmlTextWriterEndElement(writer);
+ if (auto const* pObjs = GetSortedObjs())
+ {
+ (void)xmlTextWriterStartElement(writer, BAD_CAST("sorted_objs"));
+ for (SwAnchoredObject const*const pObj : *pObjs)
+ { // just print pointer, full details will be printed on its anchor frame
+ // this nonsense is needed because of multiple inheritance
+ if (SwFlyFrame const* pFly = pObj->DynCastFlyFrame())
+ {
+ (void)xmlTextWriterStartElement(writer, BAD_CAST("fly"));
+ (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pFly);
+ }
+ else
+ {
+ (void)xmlTextWriterStartElement(writer, BAD_CAST(pObj->getElementName()));
+ (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pObj);
+ }
+ (void)xmlTextWriterEndElement(writer);
+ }
+ (void)xmlTextWriterEndElement(writer);
+ }
+
+ (void)xmlTextWriterStartElement(writer, BAD_CAST("infos"));
+ dumpInfosAsXml(writer);
+ (void)xmlTextWriterEndElement(writer);
+ const SwSortedObjs* pAnchored = GetDrawObjs();
+ if ( pAnchored && pAnchored->size() > 0 )
+ {
+ (void)xmlTextWriterStartElement( writer, BAD_CAST( "anchored" ) );
+
+ for (SwAnchoredObject* pObject : *pAnchored)
+ {
+ pObject->dumpAsXml( writer );
+ }
+
+ (void)xmlTextWriterEndElement( writer );
+ }
+ dumpChildrenAsXml(writer);
+ (void)xmlTextWriterEndElement(writer);
+}
+
SwTextGridItem const* GetGridItem(SwPageFrame const*const pPage)
{
if (pPage && pPage->HasGrid())
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index f9f3f8a757eb..f204b5c6d32a 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -174,9 +174,6 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
switch ( GetType( ) )
{
- case SwFrameType::Page:
- name = "page";
- break;
case SwFrameType::Column:
name = "column";
break;
@@ -225,44 +222,6 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
dumpAsXmlAttributes( writer );
- if (IsPageFrame())
- {
- const SwPageFrame* pPageFrame = static_cast<const SwPageFrame*>(this);
- (void)xmlTextWriterStartElement(writer, BAD_CAST("page_status"));
- (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyLayout"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyLayout()).getStr()));
- (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyContent"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyContent()).getStr()));
- (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyInCnt"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyInCnt()).getStr()));
- (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidLayout"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidLayout()).getStr()));
- (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidContent"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidContent()).getStr()));
- (void)xmlTextWriterEndElement(writer);
- (void)xmlTextWriterStartElement(writer, BAD_CAST("page_info"));
- (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("phyNum"), "%d", pPageFrame->GetPhyPageNum());
- (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("virtNum"), "%d", pPageFrame->GetVirtPageNum());
- OUString aFormatName = pPageFrame->GetPageDesc()->GetName();
- (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("pageDesc"), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
- (void)xmlTextWriterEndElement(writer);
- if (auto const* pObjs = pPageFrame->GetSortedObjs())
- {
- (void)xmlTextWriterStartElement(writer, BAD_CAST("sorted_objs"));
- for (SwAnchoredObject const*const pObj : *pObjs)
- { // just print pointer, full details will be printed on its anchor frame
- // this nonsense is needed because of multiple inheritance
- if (SwFlyFrame const* pFly = pObj->DynCastFlyFrame())
- {
- (void)xmlTextWriterStartElement(writer, BAD_CAST("fly"));
- (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pFly);
- }
- else
- {
- (void)xmlTextWriterStartElement(writer, BAD_CAST(pObj->getElementName()));
- (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pObj);
- }
- (void)xmlTextWriterEndElement(writer);
- }
- (void)xmlTextWriterEndElement(writer);
- }
- }
-
if (IsTextFrame())
{
const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this);