LibreOffice Module sw (master) 1
xmldump.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include <frame.hxx>
11#include <frmfmt.hxx>
12#include <ftnfrm.hxx>
13#include <sectfrm.hxx>
14#include <tabfrm.hxx>
15#include <pagefrm.hxx>
16#include <txtfrm.hxx>
17#include <cellfrm.hxx>
18#include <flyfrm.hxx>
19#include <hffrm.hxx>
20#include <rootfrm.hxx>
21#include <ndtxt.hxx>
22#include <sortedobjs.hxx>
23#include <swfont.hxx>
24#include <txttypes.hxx>
25#include <anchoredobject.hxx>
26#include <libxml/xmlwriter.h>
27#include <SwPortionHandler.hxx>
28#include <view.hxx>
29#include <flyfrms.hxx>
30#include <svx/svdobj.hxx>
31
32#include "porlay.hxx"
33
35{
36 switch (nType)
37 {
39 return "PortionType::NONE";
41 return "PortionType::FlyCnt";
42
44 return "PortionType::Hole";
46 return "PortionType::TempEnd";
48 return "PortionType::Break";
50 return "PortionType::Kern";
52 return "PortionType::Arrow";
54 return "PortionType::Multi";
56 return "PortionType::HiddenText";
58 return "PortionType::ControlChar";
60 return "PortionType::Bookmark";
61
63 return "PortionType::Text";
65 return "PortionType::Lay";
67 return "PortionType::Para";
69 return "PortionType::Hanging";
70
72 return "PortionType::Drop";
74 return "PortionType::Tox";
76 return "PortionType::IsoTox";
78 return "PortionType::Ref";
80 return "PortionType::IsoRef";
82 return "PortionType::Meta";
84 return "PortionType::ContentControl";
86 return "PortionType::FieldMark";
88 return "PortionType::FieldFormCheckbox";
90 return "PortionType::InputField";
91
93 return "PortionType::Expand";
95 return "PortionType::Blank";
97 return "PortionType::PostIts";
98
100 return "PortionType::Hyphen";
102 return "PortionType::HyphenStr";
104 return "PortionType::SoftHyphen";
106 return "PortionType::SoftHyphenStr";
108 return "PortionType::SoftHyphenComp";
109
111 return "PortionType::Field";
113 return "PortionType::Hidden";
115 return "PortionType::QuoVadis";
117 return "PortionType::ErgoSum";
119 return "PortionType::Combined";
121 return "PortionType::Footnote";
122
124 return "PortionType::FootnoteNum";
126 return "PortionType::Number";
128 return "PortionType::Bullet";
130 return "PortionType::GrfNum";
131
133 return "PortionType::Glue";
134
136 return "PortionType::Margin";
137
138 case PortionType::Fix:
139 return "PortionType::Fix";
140 case PortionType::Fly:
141 return "PortionType::Fly";
142
143 case PortionType::Tab:
144 return "PortionType::Tab";
145
147 return "PortionType::TabRight";
149 return "PortionType::TabCenter";
151 return "PortionType::TabDecimal";
152
154 return "PortionType::TabLeft";
155 default:
156 return "Unknown";
157 }
158}
159
161{
162 const SwFrame* pFrame = this;
163 while (pFrame->GetUpper())
164 {
165 pFrame = pFrame->GetUpper();
166 }
167
168 pFrame->dumpAsXml(writer);
169}
170
172{
173 // output the Frame
174 (void)xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) );
176 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFixSize"), BAD_CAST(OString::boolean(HasFixSize()).getStr()));
177 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaPositionValid"), BAD_CAST(OString::boolean(isFrameAreaPositionValid()).getStr()));
178 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaSizeValid"), BAD_CAST(OString::boolean(isFrameAreaSizeValid()).getStr()));
179 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFramePrintAreaValid"), BAD_CAST(OString::boolean(isFramePrintAreaValid()).getStr()));
180 (void)xmlTextWriterEndElement( writer );
181
182 // output the print area
183 (void)xmlTextWriterStartElement( writer, BAD_CAST( "prtBounds" ) );
185 (void)xmlTextWriterEndElement( writer );
186}
187
189{
190 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
191 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "id" ), "%" SAL_PRIuUINT32, GetFrameId() );
192 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "symbol" ), "%s", BAD_CAST( typeid( *this ).name( ) ) );
193 if ( GetNext( ) )
194 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "next" ), "%" SAL_PRIuUINT32, GetNext()->GetFrameId() );
195 if ( GetPrev( ) )
196 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "prev" ), "%" SAL_PRIuUINT32, GetPrev()->GetFrameId() );
197 if ( GetUpper( ) )
198 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "upper" ), "%" SAL_PRIuUINT32, GetUpper()->GetFrameId() );
199 if ( GetLower( ) )
200 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "lower" ), "%" SAL_PRIuUINT32, GetLower()->GetFrameId() );
201 if (IsFootnoteFrame())
202 {
203 SwFootnoteFrame const*const pFF(static_cast<SwFootnoteFrame const*>(this));
204 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("ref"), "%" SAL_PRIuUINT32, pFF->GetRef()->GetFrameId() );
205 if (pFF->GetMaster())
206 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("master"), "%" SAL_PRIuUINT32, pFF->GetMaster()->GetFrameId() );
207 if (pFF->GetFollow())
208 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("follow"), "%" SAL_PRIuUINT32, pFF->GetFollow()->GetFrameId() );
209 }
210 if (IsSctFrame())
211 {
212 SwSectionFrame const*const pFrame(static_cast<SwSectionFrame const*>(this));
213 SwSectionNode const*const pNode(pFrame->GetSection() ? pFrame->GetSection()->GetFormat()->GetSectionNode() : nullptr);
214 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("sectionNodeIndex"), "%" SAL_PRIdINT32, pNode ? sal_Int32(pNode->GetIndex()) : -1);
215 }
216 if ( IsTextFrame( ) )
217 {
218 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this);
219 const SwTextNode *pTextNode = pTextFrame->GetTextNodeFirst();
220 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "txtNodeIndex" ), "%" SAL_PRIdINT32, sal_Int32(pTextNode->GetIndex()) );
221
222 OString aMode = "Horizontal";
223 if (IsVertLRBT())
224 {
225 aMode = "VertBTLR";
226 }
227 else if (IsVertLR())
228 {
229 aMode = "VertLR";
230 }
231 else if (IsVertical())
232 {
233 aMode = "Vertical";
234 }
235 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("WritingMode"), BAD_CAST(aMode.getStr()));
236 }
237 if (IsHeaderFrame() || IsFooterFrame())
238 {
239 const SwHeadFootFrame *pHeadFootFrame = static_cast<const SwHeadFootFrame*>(this);
240 OUString aFormatName = pHeadFootFrame->GetFormat()->GetName();
241 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "fmtName" ), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
242 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "fmtPtr" ), "%p", pHeadFootFrame->GetFormat());
243 }
244}
245
247{
248 const SwFrame *pFrame = GetLower( );
249 for ( ; pFrame != nullptr; pFrame = pFrame->GetNext( ) )
250 {
251 pFrame->dumpAsXml( writer );
252 }
253}
254
256{
257 (void)xmlTextWriterStartElement( writer, BAD_CAST( getElementName() ) );
258 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
259 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("anchor-frame"), BAD_CAST(OString::number(mpAnchorFrame->GetFrameId()).getStr()));
260 if (mpPageFrame)
261 {
262 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("page-frame"), BAD_CAST(OString::number(mpPageFrame->GetFrameId()).getStr()));
263 }
264 SwTextFrame* pAnchorCharFrame = const_cast<SwAnchoredObject*>(this)->FindAnchorCharFrame();
265 if (pAnchorCharFrame)
266 {
267 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("anchor-char-frame"), BAD_CAST(OString::number(pAnchorCharFrame->GetFrameId()).getStr()));
268 }
269
270 (void)xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) );
271 // don't call GetObjBoundRect(), it modifies the layout
272 SwRect(GetDrawObj()->GetLastBoundRect()).dumpAsXmlAttributes(writer);
273 (void)xmlTextWriterEndElement( writer );
274
275 if (const SdrObject* pObject = GetDrawObj())
276 pObject->dumpAsXml(writer);
277
278 (void)xmlTextWriterEndElement( writer );
279}
280
282{
283 (void)xmlTextWriterStartElement(writer, BAD_CAST("SwFont"));
284 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", this);
285 // do not use Color::AsRGBHexString() as that omits the transparency
286 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("color"), "%08" SAL_PRIxUINT32, sal_uInt32(GetColor()));
287 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("height"), BAD_CAST(OString::number(GetSize(GetActual()).Height()).getStr()));
288 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("width"), BAD_CAST(OString::number(GetSize(GetActual()).Width()).getStr()));
289 {
290 std::stringstream ss;
291 ss << GetWeight();
292 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("weight"), BAD_CAST(ss.str().c_str()));
293 }
294 (void)xmlTextWriterEndElement(writer);
295}
296
298{
300 if ( HasFollow() )
301 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
302
303 if (m_pPrecede != nullptr)
304 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwTextFrame*>(m_pPrecede)->GetFrameId() );
305
306 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("offset"), BAD_CAST(OString::number(static_cast<sal_Int32>(mnOffset)).getStr()));
307}
308
310{
312
313 if (m_pFollow != nullptr)
314 {
315 (void)xmlTextWriterWriteAttribute(
316 pWriter, BAD_CAST("follow"),
317 BAD_CAST(OString::number(m_pFollow->GetFrame().GetFrameId()).getStr()));
318 }
319 if (m_pPrecede != nullptr)
320 {
321 (void)xmlTextWriterWriteAttribute(
322 pWriter, BAD_CAST("precede"),
323 BAD_CAST(OString::number(m_pPrecede->GetFrame().GetFrameId()).getStr()));
324 }
325}
326
328{
330 if ( HasFollow() )
331 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
332
333 if (m_pPrecede != nullptr)
334 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwSectionFrame*>( m_pPrecede )->GetFrameId() );
335}
336
338{
340 if ( HasFollow() )
341 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
342
343 if (m_pPrecede != nullptr)
344 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwTabFrame*>( m_pPrecede )->GetFrameId() );
345}
346
347/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
wrapper class for the positioning of Writer fly frames and drawing objects
SwTextFrame * FindAnchorCharFrame()
get frame, which contains the anchor character, if the object is anchored at-character or as-characte...
virtual void dumpAsXml(xmlTextWriterPtr pWriter=nullptr) const
Dump a bunch of useful data to an XML representation to ease layout understanding,...
Definition: xmldump.cxx:255
virtual const char * getElementName() const
The element name to show in the XML dump.
SwPageFrame * mpPageFrame
const SdrObject * GetDrawObj() const
SwFrame * mpAnchorFrame
Frame the object is anchored at.
void dumpAsXmlAttributes(xmlTextWriterPtr pWriter) const override
Definition: xmldump.cxx:309
void dumpAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:281
const Size & GetSize(SwFontScript nWhich) const
Definition: swfont.hxx:209
SwFontScript GetActual() const
Definition: swfont.hxx:187
FontWeight GetWeight() const
Definition: swfont.hxx:288
const Color & GetColor() const
Definition: swfont.hxx:280
Represents one footnote or endnote in the layout.
Definition: ftnfrm.hxx:84
const SwFootnoteFrame * GetFollow() const
Definition: ftnfrm.hxx:120
const SwFootnoteFrame * GetMaster() const
Definition: ftnfrm.hxx:123
const SwContentFrame * GetRef() const
Definition: ftnfrm.cxx:2909
const OUString & GetName() const
Definition: format.hxx:131
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaPositionValid() const
Definition: frame.hxx:166
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
bool isFramePrintAreaValid() const
Definition: frame.hxx:168
bool isFrameAreaSizeValid() const
Definition: frame.hxx:167
sal_uInt32 GetFrameId() const
Definition: frame.hxx:174
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
SwFrame * GetNext()
Definition: frame.hxx:682
bool HasFixSize() const
Definition: frame.hxx:676
bool IsVertLRBT() const
Definition: frame.hxx:989
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const =0
bool IsHeaderFrame() const
Definition: frame.hxx:1196
SwFrame * GetLower()
Definition: findfrm.cxx:196
void dumpInfosAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:171
bool IsFooterFrame() const
Definition: frame.hxx:1200
bool IsFootnoteFrame() const
Definition: frame.hxx:1208
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:188
bool IsVertical() const
Definition: frame.hxx:979
void dumpTopMostAsXml(xmlTextWriterPtr writer=nullptr) const
Definition: xmldump.cxx:160
SwFrame * GetPrev()
Definition: frame.hxx:683
bool IsSctFrame() const
Definition: frame.hxx:1220
bool IsVertLR() const
Definition: frame.hxx:985
void dumpChildrenAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:246
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:401
SwNodeOffset GetIndex() const
Definition: node.hxx:312
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
Definition: swrect.cxx:178
SwSectionNode * GetSectionNode()
Definition: section.cxx:923
SwSection * GetSection()
Definition: sectfrm.hxx:97
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:327
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:174
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
SwSectionFormat * GetFormat()
Definition: section.hxx:341
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:49
const SwTabFrame * GetFollow() const
Definition: tabfrm.hxx:255
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:337
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:889
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:297
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:472
TextFrameIndex mnOffset
Definition: txtfrm.hxx:207
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
struct _xmlTextWriter * xmlTextWriterPtr
EmbeddedObjectRef * pObject
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const char * PortionTypeToString(PortionType nType)
Definition: xmldump.cxx:34
QPRO_FUNC_TYPE nType
PortionType
Definition: txttypes.hxx:24