diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-02-04 13:42:42 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-21 11:54:35 +0200 |
commit | 0dfe5dc1cef1a1f74de87908d05a5d4a7405d667 (patch) | |
tree | 82e4bbb589ff1cb009643bc900a94e659a67f719 | |
parent | g: we are not, in fact, in the BUILDDIR (diff) | |
download | core-0dfe5dc1cef1a1f74de87908d05a5d4a7405d667.tar.gz core-0dfe5dc1cef1a1f74de87908d05a5d4a7405d667.zip |
sw: fix crash in SwFrame::dumpAsXml()
when called from SfxObjectShell::GetPreviewMetaFile(), GetSfxViewShell()
is null apparently.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87984
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 60d37294291a2aaccc9fd84de49a7b9d30f2db0b)
Dump some more layout info as Xml
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90125
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
(cherry picked from commit 36f0a04d3caa176b20dccb10ff0bbcfb5cb8d893)
sw: dump sectionNodeIndex in layout.xml
useful to see if the sections are nested
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94882
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 27d7eedc1d3ea471f40d0a81bd4e957bdcf8d8d7)
cid#1464971 Dereference null return value
(cherry picked from commit 877ca303e675ae586caf2787d42756f1e1b22c98)
sw: fix names of SwFrameAreaDefinition flags in layout dump
These were renamed quite a while ago.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98853
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit ed62df4aa2b73164a1efc3b266d56cdbdf2dbf1a)
Handle input fields in layout/nodes dump
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100580
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
(cherry picked from commit e2c81bdf6f9f0ee3289bec7aa4ddb1f95b95382d)
sw: avoid crashing in SwFrame::dumpAsXmlAttributes()
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107521
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 5dbb0403b6f814129983963f5fea02208995270a)
sw: fix crash in SwAnchoredObject::dumpAsXml()
SwAnchoredObject::GetObjBoundRect() is const, so it's only idiomatic
that calling it reformats everything.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114757
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 569a06656e926dfb26d55958ee0f696aa9e5b7b0)
Change-Id: Id57472ae3041c7264bc904e1a68907c48e60ac96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136178
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/inc/swrect.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/bastyp/swrect.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/text/xmldump.cxx | 39 | ||||
-rw-r--r-- | sw/source/core/txtnode/txatbase.cxx | 2 |
4 files changed, 38 insertions, 18 deletions
diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx index 69b1f2ad781a..6cde3c3f01e7 100644 --- a/sw/inc/swrect.hxx +++ b/sw/inc/swrect.hxx @@ -26,6 +26,7 @@ #include "swdllapi.h" class SvStream; +typedef struct _xmlTextWriter* xmlTextWriterPtr; /// *Of course* Writer needs its own rectangles. /// This is half-open so m_Point.X() + m_Size.getWidth() is *not* included. @@ -104,7 +105,7 @@ public: // Output operator for debugging. friend SvStream& WriteSwRect( SvStream &rStream, const SwRect &rRect ); - + void dumpAsXmlAttributes(xmlTextWriterPtr writer) const; void Top_( const long nTop ); void Bottom_( const long nBottom ); diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index 1d53e6e7a71e..884c155003e2 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -19,6 +19,8 @@ #include <swrect.hxx> +#include <libxml/xmlwriter.h> + #ifdef DBG_UTIL #include <tools/stream.hxx> #endif @@ -218,6 +220,16 @@ void SwRect::SetUpperRightCorner( const Point& rNew ) void SwRect::SetLowerLeftCorner( const Point& rNew ) { m_Point = Point(rNew.X(), rNew.Y() - m_Size.getHeight()); } +void SwRect::dumpAsXmlAttributes(xmlTextWriterPtr writer) const +{ + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("left"), "%li", Left()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("top"), "%li", Top()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("width"), "%li", Width()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("height"), "%li", Height()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("bottom"), "%li", Bottom()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("right"), "%li", Right()); +} + #ifdef DBG_UTIL SvStream& WriteSwRect(SvStream &rStream, const SwRect &rRect) { diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx index 20f61111126a..b93577838258 100644 --- a/sw/source/core/text/xmldump.cxx +++ b/sw/source/core/text/xmldump.cxx @@ -67,6 +67,7 @@ class XmlPortionDumper:public SwPortionHandler case PortionType::Meta: return "PortionType::Meta"; case PortionType::FieldMark: return "PortionType::FieldMark"; case PortionType::FieldFormCheckbox: return "PortionType::FieldFormCheckbox"; + case PortionType::InputField: return "PortionType::InputField"; case PortionType::Expand: return "PortionType::Expand"; case PortionType::Blank: return "PortionType::Blank"; @@ -326,7 +327,7 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>)); while (pView) { - if (pView->GetObjectShell() == pRootFrame->GetCurrShell()->GetSfxViewShell()->GetObjectShell()) + if (pRootFrame->GetCurrShell()->GetSfxViewShell() && pView->GetObjectShell() == pRootFrame->GetCurrShell()->GetSfxViewShell()->GetObjectShell()) pView->dumpAsXml(writer); pView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>)); } @@ -343,6 +344,12 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidLayout"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidLayout()).getStr())); xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidContent"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidContent()).getStr())); xmlTextWriterEndElement(writer); + xmlTextWriterStartElement(writer, BAD_CAST("page_info")); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("phyNum"), "%d", pPageFrame->GetPhyPageNum()); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("virtNum"), "%d", pPageFrame->GetVirtPageNum()); + OUString aFormatName = pPageFrame->GetPageDesc()->GetName(); + xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("pageDesc"), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr())); + xmlTextWriterEndElement(writer); } if (IsTextFrame()) @@ -421,22 +428,16 @@ void SwFrame::dumpInfosAsXml( xmlTextWriterPtr writer ) const { // output the Frame xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "left" ), "%ld", getFrameArea().Left() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "top" ), "%ld", getFrameArea().Top() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "width" ), "%ld", getFrameArea().Width() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "height" ), "%ld", getFrameArea().Height() ); + getFrameArea().dumpAsXmlAttributes(writer); xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFixSize"), BAD_CAST(OString::boolean(HasFixSize()).getStr())); - xmlTextWriterWriteAttribute(writer, BAD_CAST("mbValidPos"), BAD_CAST(OString::boolean(isFrameAreaPositionValid()).getStr())); - xmlTextWriterWriteAttribute(writer, BAD_CAST("mbValidSize"), BAD_CAST(OString::boolean(isFrameAreaSizeValid()).getStr())); - xmlTextWriterWriteAttribute(writer, BAD_CAST("mbValidPrtArea"), BAD_CAST(OString::boolean(isFramePrintAreaValid()).getStr())); + xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaPositionValid"), BAD_CAST(OString::boolean(isFrameAreaPositionValid()).getStr())); + xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaSizeValid"), BAD_CAST(OString::boolean(isFrameAreaSizeValid()).getStr())); + xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFramePrintAreaValid"), BAD_CAST(OString::boolean(isFramePrintAreaValid()).getStr())); xmlTextWriterEndElement( writer ); - // output the Prt + // output the print area xmlTextWriterStartElement( writer, BAD_CAST( "prtBounds" ) ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "left" ), "%ld", getFramePrintArea().Left() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "top" ), "%ld", getFramePrintArea().Top() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "width" ), "%ld", getFramePrintArea().Width() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "height" ), "%ld", getFramePrintArea().Height() ); + getFramePrintArea().dumpAsXmlAttributes(writer); xmlTextWriterEndElement( writer ); } @@ -466,6 +467,12 @@ void SwFrame::dumpAsXmlAttributes( xmlTextWriterPtr writer ) const if (pFF->GetFollow()) xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("follow"), "%" SAL_PRIuUINT32, pFF->GetFollow()->GetFrameId() ); } + if (IsSctFrame()) + { + SwSectionFrame const*const pFrame(static_cast<SwSectionFrame const*>(this)); + SwSectionNode const*const pNode(pFrame->GetSection() ? pFrame->GetSection()->GetFormat()->GetSectionNode() : nullptr); + xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("sectionNodeIndex"), TMP_FORMAT, pNode ? pNode->GetIndex() : -1); + } if ( IsTextFrame( ) ) { const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this); @@ -515,10 +522,8 @@ void SwAnchoredObject::dumpAsXml( xmlTextWriterPtr writer ) const xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this ); xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "left" ), "%ld", GetObjBoundRect().Left() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "top" ), "%ld", GetObjBoundRect().Top() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "width" ), "%ld", GetObjBoundRect().Width() ); - xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "height" ), "%ld", GetObjBoundRect().Height() ); + // don't call GetObjBoundRect(), it modifies the layout + SwRect(GetDrawObj()->GetLastBoundRect()).dumpAsXmlAttributes(writer); xmlTextWriterEndElement( writer ); if (const SdrObject* pObject = GetDrawObj()) diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 188ec6f9a663..755391e940d7 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -152,9 +152,11 @@ void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter) const GetAutoFormat().dumpAsXml(pWriter); break; case RES_TXTATR_FIELD: + case RES_TXTATR_INPUTFIELD: GetFormatField().dumpAsXml(pWriter); break; default: + SAL_WARN("sw.core", "Unhandled TXTATR"); break; } |