26#include <libxml/xmlwriter.h>
39 return "PortionType::NONE";
41 return "PortionType::FlyCnt";
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";
63 return "PortionType::Text";
65 return "PortionType::Lay";
67 return "PortionType::Para";
69 return "PortionType::Hanging";
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";
93 return "PortionType::Expand";
95 return "PortionType::Blank";
97 return "PortionType::PostIts";
100 return "PortionType::Hyphen";
102 return "PortionType::HyphenStr";
104 return "PortionType::SoftHyphen";
106 return "PortionType::SoftHyphenStr";
108 return "PortionType::SoftHyphenComp";
111 return "PortionType::Field";
113 return "PortionType::Hidden";
115 return "PortionType::QuoVadis";
117 return "PortionType::ErgoSum";
119 return "PortionType::Combined";
121 return "PortionType::Footnote";
124 return "PortionType::FootnoteNum";
126 return "PortionType::Number";
128 return "PortionType::Bullet";
130 return "PortionType::GrfNum";
133 return "PortionType::Glue";
136 return "PortionType::Margin";
139 return "PortionType::Fix";
141 return "PortionType::Fly";
144 return "PortionType::Tab";
147 return "PortionType::TabRight";
149 return "PortionType::TabCenter";
151 return "PortionType::TabDecimal";
154 return "PortionType::TabLeft";
173 const char *
name =
nullptr;
186 if (
name !=
nullptr )
188 (void)xmlTextWriterStartElement( writer,
reinterpret_cast<const xmlChar *
>(
name) );
198 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"merged" ) );
199 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"paraPropsNodeIndex" ),
"%" SAL_PRIdINT32, sal_Int32(pMerged->
pParaPropsNode->
GetIndex()) );
200 for (
auto const& e : pMerged->
extents)
202 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"extent" ) );
203 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"txtNodeIndex" ),
"%" SAL_PRIdINT32, sal_Int32(e.pNode->GetIndex()) );
204 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"start" ),
"%" SAL_PRIdINT32, e.nStart );
205 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"end" ),
"%" SAL_PRIdINT32, e.nEnd );
206 (void)xmlTextWriterEndElement( writer );
208 (void)xmlTextWriterEndElement( writer );
212 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"infos" ) );
214 (void)xmlTextWriterEndElement( writer );
218 if ( pAnchored && pAnchored->
size() > 0 )
220 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"anchored" ) );
227 (void)xmlTextWriterEndElement( writer );
234 OUString aText = pTextFrame->
GetText( );
235 for (
int i = 0;
i < 32;
i++ )
237 aText = aText.replace(
i,
'*' );
239 auto nTextOffset =
static_cast<sal_Int32
>(pTextFrame->
GetOffset());
240 sal_Int32 nTextLength = aText.getLength() - nTextOffset;
243 nTextLength =
static_cast<sal_Int32
>(pTextFrameFollow->GetOffset() - pTextFrame->
GetOffset());
246 =
OUStringToOString(aText.subView(nTextOffset, nTextLength), RTL_TEXTENCODING_UTF8);
247 (void)xmlTextWriterWriteString( writer,
248 reinterpret_cast<const xmlChar *
>(aText8.getStr( )) );
251 (void)xmlTextWriterStartElement(writer, BAD_CAST(
"SwParaPortion"));
253 const OUString& rText = pTextFrame->
GetText();
254 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST(
"ptr"),
"%p", pPara);
256 if (pTextFrame->IsFollow())
262 (void)xmlTextWriterStartElement(writer, BAD_CAST(
"SwLineLayout"));
270 (void)xmlTextWriterEndElement(writer);
273 (void)xmlTextWriterEndElement(writer);
281 (void)xmlTextWriterEndElement( writer );
288 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"bounds" ) );
290 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"mbFixSize"), BAD_CAST(OString::boolean(
HasFixSize()).getStr()));
291 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"mbFrameAreaPositionValid"), BAD_CAST(OString::boolean(
isFrameAreaPositionValid()).getStr()));
292 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"mbFrameAreaSizeValid"), BAD_CAST(OString::boolean(
isFrameAreaSizeValid()).getStr()));
293 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"mbFramePrintAreaValid"), BAD_CAST(OString::boolean(
isFramePrintAreaValid()).getStr()));
294 (void)xmlTextWriterEndElement( writer );
297 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"prtBounds" ) );
299 (void)xmlTextWriterEndElement( writer );
304 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"ptr" ),
"%p", this );
305 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"id" ),
"%" SAL_PRIuUINT32,
GetFrameId() );
306 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"symbol" ),
"%s", BAD_CAST(
typeid( *this ).name( ) ) );
308 (
void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"next" ),
"%" SAL_PRIuUINT32,
GetNext()->
GetFrameId() );
310 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"prev" ),
"%" SAL_PRIuUINT32,
GetPrev()->
GetFrameId() );
312 (
void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"upper" ),
"%" SAL_PRIuUINT32,
GetUpper()->
GetFrameId() );
314 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"lower" ),
"%" SAL_PRIuUINT32,
GetLower()->
GetFrameId() );
318 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"ref"),
"%" SAL_PRIuUINT32, pFF->
GetRef()->
GetFrameId() );
320 (
void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"master"),
"%" SAL_PRIuUINT32, pFF->
GetMaster()->
GetFrameId() );
322 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"follow"),
"%" SAL_PRIuUINT32, pFF->
GetFollow()->
GetFrameId() );
328 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST(
"sectionNodeIndex"),
"%" SAL_PRIdINT32, pNode ? sal_Int32(pNode->
GetIndex()) : -1);
334 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"txtNodeIndex" ),
"%" SAL_PRIdINT32, sal_Int32(pTextNode->
GetIndex()) );
336 OString aMode =
"Horizontal";
349 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"WritingMode"), BAD_CAST(aMode.getStr()));
355 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"fmtName" ),
"%s", BAD_CAST(
OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
356 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"fmtPtr" ),
"%p", pHeadFootFrame->
GetFormat());
363 for ( ; pFrame !=
nullptr; pFrame = pFrame->
GetNext( ) )
371 (void)xmlTextWriterStartElement( writer, BAD_CAST(
getElementName() ) );
372 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"ptr" ),
"%p", this );
373 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"anchor-frame"), BAD_CAST(OString::number(
mpAnchorFrame->
GetFrameId()).getStr()));
375 if (pAnchorCharFrame)
377 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"anchor-char-frame"), BAD_CAST(OString::number(pAnchorCharFrame->
GetFrameId()).getStr()));
380 (void)xmlTextWriterStartElement( writer, BAD_CAST(
"bounds" ) );
383 (void)xmlTextWriterEndElement( writer );
388 (void)xmlTextWriterEndElement( writer );
393 (void)xmlTextWriterStartElement(writer, BAD_CAST(
"SwFont"));
394 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST(
"ptr"),
"%p",
this);
396 (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST(
"color"),
"%08" SAL_PRIxUINT32, sal_uInt32(
GetColor()));
397 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"height"), BAD_CAST(OString::number(
GetSize(
GetActual()).
Height()).getStr()));
398 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"width"), BAD_CAST(OString::number(
GetSize(
GetActual()).
Width()).getStr()));
400 std::stringstream ss;
402 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"weight"), BAD_CAST(ss.str().c_str()));
404 (void)xmlTextWriterEndElement(writer);
411 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"follow" ),
"%" SAL_PRIuUINT32,
GetFollow()->
GetFrameId() );
413 if (m_pPrecede !=
nullptr)
414 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"precede" ),
"%" SAL_PRIuUINT32,
static_cast<SwTextFrame*
>(m_pPrecede)->
GetFrameId() );
416 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST(
"offset"), BAD_CAST(OString::number(
static_cast<sal_Int32
>(
mnOffset)).getStr()));
423 if (m_pFollow !=
nullptr)
425 (void)xmlTextWriterWriteAttribute(
426 pWriter, BAD_CAST(
"follow"),
427 BAD_CAST(OString::number(m_pFollow->GetFrame().GetFrameId()).getStr()));
429 if (m_pPrecede !=
nullptr)
431 (void)xmlTextWriterWriteAttribute(
432 pWriter, BAD_CAST(
"precede"),
433 BAD_CAST(OString::number(m_pPrecede->GetFrame().GetFrameId()).getStr()));
441 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"follow" ),
"%" SAL_PRIuUINT32,
GetFollow()->
GetFrameId() );
443 if (m_pPrecede !=
nullptr)
444 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"precede" ),
"%" SAL_PRIuUINT32,
static_cast<SwSectionFrame*
>( m_pPrecede )->
GetFrameId() );
451 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"follow" ),
"%" SAL_PRIuUINT32,
GetFollow()->
GetFrameId() );
453 if (m_pPrecede !=
nullptr)
454 (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST(
"precede" ),
"%" SAL_PRIuUINT32,
static_cast<SwTabFrame*
>( m_pPrecede )->
GetFrameId() );
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,...
virtual const char * getElementName() const
The element name to show in the XML dump.
const SdrObject * GetDrawObj() const
SwFrame * mpAnchorFrame
Frame the object is anchored at.
void dumpAsXmlAttributes(xmlTextWriterPtr pWriter) const override
void dumpAsXml(xmlTextWriterPtr writer) const
const Size & GetSize(SwFontScript nWhich) const
SwFontScript GetActual() const
FontWeight GetWeight() const
const Color & GetColor() const
const SwRect & getFrameArea() const
bool isFrameAreaPositionValid() const
const SwRect & getFramePrintArea() const
bool isFramePrintAreaValid() const
bool isFrameAreaSizeValid() const
sal_uInt32 GetFrameId() const
Base class of the Writer layout elements.
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const
SwFrameType GetType() const
bool IsHeaderFrame() const
const SwSortedObjs * GetDrawObjs() const
void dumpInfosAsXml(xmlTextWriterPtr writer) const
bool IsFooterFrame() const
bool IsFootnoteFrame() const
SwLayoutFrame * GetUpper()
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
void dumpTopMostAsXml(xmlTextWriterPtr writer=nullptr) const
void dumpChildrenAsXml(xmlTextWriterPtr writer) const
virtual const SwFrameFormat * GetFormat() const
Collection of SwLinePortion instances, representing one line of text.
SwLinePortion * GetFirstPortion() const
Base class for anything that can be part of a line in the Writer layout.
void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText, TextFrameIndex nOffset) const
SwLinePortion * GetNextPortion() const
virtual void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &rOffset) const
SwNodeOffset GetIndex() const
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Of course Writer needs its own rectangles.
void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
const SwSectionFrame * GetFollow() const
A section node represents the start of a section on the UI, i.e.
SwSectionFormat * GetFormat()
class for collecting anchored objects
SwTabFrame is one table in the document layout, containing rows (which contain cells).
const SwTabFrame * GetFollow() const
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Represents the visualization of a paragraph.
SwTextFrame * GetFollow()
TextFrameIndex GetOffset() const
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
sw::MergedPara * GetMergedPara()
SwParaPortion * GetPara()
SwTextNode * GetTextNodeFirst()
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
SwTextNode is a paragraph in the document model.
struct _xmlTextWriter * xmlTextWriterPtr
EmbeddedObjectRef * pObject
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const char * PortionTypeToString(PortionType nType)
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
SwTextNode * pParaPropsNode
most paragraph properties are taken from the first non-empty node
std::vector< Extent > extents