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 <svx/svdobj.hxx>
30 
31 #include "porlay.hxx"
32 
34 {
35  switch (nType)
36  {
37  case PortionType::NONE:
38  return "PortionType::NONE";
40  return "PortionType::FlyCnt";
41 
42  case PortionType::Hole:
43  return "PortionType::Hole";
45  return "PortionType::TempEnd";
46  case PortionType::Break:
47  return "PortionType::Break";
48  case PortionType::Kern:
49  return "PortionType::Kern";
50  case PortionType::Arrow:
51  return "PortionType::Arrow";
52  case PortionType::Multi:
53  return "PortionType::Multi";
55  return "PortionType::HiddenText";
57  return "PortionType::ControlChar";
59  return "PortionType::Bookmark";
60 
61  case PortionType::Text:
62  return "PortionType::Text";
63  case PortionType::Lay:
64  return "PortionType::Lay";
65  case PortionType::Para:
66  return "PortionType::Para";
68  return "PortionType::Hanging";
69 
70  case PortionType::Drop:
71  return "PortionType::Drop";
72  case PortionType::Tox:
73  return "PortionType::Tox";
75  return "PortionType::IsoTox";
76  case PortionType::Ref:
77  return "PortionType::Ref";
79  return "PortionType::IsoRef";
80  case PortionType::Meta:
81  return "PortionType::Meta";
83  return "PortionType::ContentControl";
85  return "PortionType::FieldMark";
87  return "PortionType::FieldFormCheckbox";
89  return "PortionType::InputField";
90 
92  return "PortionType::Expand";
93  case PortionType::Blank:
94  return "PortionType::Blank";
96  return "PortionType::PostIts";
97 
99  return "PortionType::Hyphen";
101  return "PortionType::HyphenStr";
103  return "PortionType::SoftHyphen";
105  return "PortionType::SoftHyphenStr";
107  return "PortionType::SoftHyphenComp";
108 
109  case PortionType::Field:
110  return "PortionType::Field";
111  case PortionType::Hidden:
112  return "PortionType::Hidden";
114  return "PortionType::QuoVadis";
116  return "PortionType::ErgoSum";
118  return "PortionType::Combined";
120  return "PortionType::Footnote";
121 
123  return "PortionType::FootnoteNum";
124  case PortionType::Number:
125  return "PortionType::Number";
126  case PortionType::Bullet:
127  return "PortionType::Bullet";
128  case PortionType::GrfNum:
129  return "PortionType::GrfNum";
130 
131  case PortionType::Glue:
132  return "PortionType::Glue";
133 
134  case PortionType::Margin:
135  return "PortionType::Margin";
136 
137  case PortionType::Fix:
138  return "PortionType::Fix";
139  case PortionType::Fly:
140  return "PortionType::Fly";
141 
142  case PortionType::Table:
143  return "PortionType::Table";
144 
146  return "PortionType::TabRight";
148  return "PortionType::TabCenter";
150  return "PortionType::TabDecimal";
151 
153  return "PortionType::TabLeft";
154  default:
155  return "Unknown";
156  }
157 }
158 
159 namespace {
160 
161 class XmlPortionDumper:public SwPortionHandler
162 {
163  private:
164  xmlTextWriterPtr m_Writer;
165  TextFrameIndex m_Ofs;
166  const OUString& m_rText;
167  OUString m_aLine;
168 
169  public:
170  explicit XmlPortionDumper(xmlTextWriterPtr some_writer, const OUString& rText)
171  : m_Writer(some_writer)
172  , m_Ofs(0)
173  , m_rText(rText)
174  {
175  }
176 
183  virtual void Text( TextFrameIndex nLength,
184  PortionType nType,
185  sal_Int32 nHeight,
186  sal_Int32 nWidth) override
187  {
188  (void)xmlTextWriterStartElement(m_Writer, BAD_CAST("Text"));
189  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nLength"), "%i",
190  static_cast<int>(static_cast<sal_Int32>(nLength)));
191  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nType"), "%s",
192  sw::PortionTypeToString(nType));
193  if (nHeight > 0)
194  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nHeight"), "%i",
195  static_cast<int>(nHeight));
196  if (nWidth > 0)
197  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nWidth"), "%i",
198  static_cast<int>(nWidth));
199  if (nLength > TextFrameIndex(0))
200  (void)xmlTextWriterWriteAttribute(
201  m_Writer, BAD_CAST("Portion"),
202  BAD_CAST(m_rText.copy(sal_Int32(m_Ofs), sal_Int32(nLength)).toUtf8().getStr()));
203 
204  (void)xmlTextWriterEndElement(m_Writer);
205  m_aLine += m_rText.subView(sal_Int32(m_Ofs), sal_Int32(nLength));
206  m_Ofs += nLength;
207  }
208 
219  virtual void Special( TextFrameIndex nLength,
220  const OUString & rText,
221  PortionType nType,
222  sal_Int32 nHeight,
223  sal_Int32 nWidth,
224  const SwFont* pFont ) override
225  {
226  (void)xmlTextWriterStartElement(m_Writer, BAD_CAST("Special"));
227  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nLength"), "%i",
228  static_cast<int>(static_cast<sal_Int32>(nLength)));
229  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nType"), "%s",
230  sw::PortionTypeToString(nType));
231  OString sText8 = OUStringToOString( rText, RTL_TEXTENCODING_UTF8 );
232  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("rText"), "%s", sText8.getStr());
233 
234  if (nHeight > 0)
235  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nHeight"), "%i",
236  static_cast<int>(nHeight));
237 
238  if (nWidth > 0)
239  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nWidth"), "%i",
240  static_cast<int>(nWidth));
241 
242  if (pFont)
243  pFont->dumpAsXml(m_Writer);
244 
245  (void)xmlTextWriterEndElement(m_Writer);
246  m_aLine += rText;
247  m_Ofs += nLength;
248  }
249 
250  virtual void LineBreak( sal_Int32 nWidth ) override
251  {
252  (void)xmlTextWriterStartElement(m_Writer, BAD_CAST("LineBreak"));
253  if (nWidth > 0)
254  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nWidth"), "%i",
255  static_cast<int>(nWidth));
256  if (!m_aLine.isEmpty())
257  {
258  (void)xmlTextWriterWriteAttribute(m_Writer, BAD_CAST("Line"),
259  BAD_CAST(m_aLine.toUtf8().getStr()));
260  m_aLine.clear();
261  }
262  (void)xmlTextWriterEndElement(m_Writer);
263  }
264 
269  virtual void Skip( TextFrameIndex nLength ) override
270  {
271  (void)xmlTextWriterStartElement(m_Writer, BAD_CAST("Skip"));
272  (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nLength"), "%i",
273  static_cast<int>(static_cast<sal_Int32>(nLength)));
274  (void)xmlTextWriterEndElement(m_Writer);
275  m_Ofs += nLength;
276  }
277 
278  virtual void Finish( ) override
279  {
280  (void)xmlTextWriterStartElement(m_Writer, BAD_CAST("Finish"));
281  (void)xmlTextWriterEndElement(m_Writer);
282  }
283 
284 };
285 
286  xmlTextWriterPtr lcl_createDefaultWriter()
287  {
288  xmlTextWriterPtr writer = xmlNewTextWriterFilename( "layout.xml", 0 );
289  xmlTextWriterSetIndent(writer,1);
290  (void)xmlTextWriterSetIndentString(writer, BAD_CAST(" "));
291  (void)xmlTextWriterStartDocument( writer, nullptr, nullptr, nullptr );
292  return writer;
293  }
294 
295  void lcl_freeWriter( xmlTextWriterPtr writer )
296  {
297  (void)xmlTextWriterEndDocument( writer );
298  xmlFreeTextWriter( writer );
299  }
300 }
301 
303 {
304  const SwFrame* pFrame = this;
305  while (pFrame->GetUpper())
306  {
307  pFrame = pFrame->GetUpper();
308  }
309 
310  pFrame->dumpAsXml(writer);
311 }
312 
314 {
315  bool bCreateWriter = ( nullptr == writer );
316  if ( bCreateWriter )
317  writer = lcl_createDefaultWriter();
318 
319  const char *name = nullptr;
320 
321  switch ( GetType( ) )
322  {
323  case SwFrameType::Root:
324  name = "root";
325  break;
326  case SwFrameType::Page:
327  name = "page";
328  break;
329  case SwFrameType::Column:
330  name = "column";
331  break;
332  case SwFrameType::Header:
333  name = "header";
334  break;
335  case SwFrameType::Footer:
336  name = "footer";
337  break;
339  name = "ftncont";
340  break;
341  case SwFrameType::Ftn:
342  name = "ftn";
343  break;
344  case SwFrameType::Body:
345  name = "body";
346  break;
347  case SwFrameType::Fly:
348  name = "fly";
349  break;
351  name = "section";
352  break;
353  case SwFrameType::Tab:
354  name = "tab";
355  break;
356  case SwFrameType::Row:
357  name = "row";
358  break;
359  case SwFrameType::Cell:
360  name = "cell";
361  break;
362  case SwFrameType::Txt:
363  name = "txt";
364  break;
365  case SwFrameType::NoTxt:
366  name = "notxt";
367  break;
368  default: break;
369  }
370 
371  if ( name != nullptr )
372  {
373  (void)xmlTextWriterStartElement( writer, reinterpret_cast<const xmlChar *>(name) );
374 
375  dumpAsXmlAttributes( writer );
376 
377  if (IsRootFrame())
378  {
379  const SwRootFrame* pRootFrame = static_cast<const SwRootFrame*>(this);
380  (void)xmlTextWriterStartElement(writer, BAD_CAST("sfxViewShells"));
381  SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>));
382  while (pView)
383  {
384  if (pRootFrame->GetCurrShell()->GetSfxViewShell() && pView->GetObjectShell() == pRootFrame->GetCurrShell()->GetSfxViewShell()->GetObjectShell())
385  pView->dumpAsXml(writer);
386  pView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>));
387  }
388  (void)xmlTextWriterEndElement(writer);
389  }
390 
391  if (IsPageFrame())
392  {
393  const SwPageFrame* pPageFrame = static_cast<const SwPageFrame*>(this);
394  (void)xmlTextWriterStartElement(writer, BAD_CAST("page_status"));
395  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyLayout"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyLayout()).getStr()));
396  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyContent"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyContent()).getStr()));
397  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidFlyInCnt"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidFlyInCnt()).getStr()));
398  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidLayout"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidLayout()).getStr()));
399  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("ValidContent"), BAD_CAST(OString::boolean(!pPageFrame->IsInvalidContent()).getStr()));
400  (void)xmlTextWriterEndElement(writer);
401  (void)xmlTextWriterStartElement(writer, BAD_CAST("page_info"));
402  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("phyNum"), "%d", pPageFrame->GetPhyPageNum());
403  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("virtNum"), "%d", pPageFrame->GetVirtPageNum());
404  OUString aFormatName = pPageFrame->GetPageDesc()->GetName();
405  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("pageDesc"), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
406  (void)xmlTextWriterEndElement(writer);
407  if (auto const* pObjs = pPageFrame->GetSortedObjs())
408  {
409  (void)xmlTextWriterStartElement(writer, BAD_CAST("sorted_objs"));
410  for (SwAnchoredObject const*const pObj : *pObjs)
411  { // just print pointer, full details will be printed on its anchor frame
412  // this nonsense is needed because of multiple inheritance
413  if (SwFlyFrame const* pFly = pObj->DynCastFlyFrame())
414  {
415  (void)xmlTextWriterStartElement(writer, BAD_CAST("fly"));
416  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pFly);
417  }
418  else
419  {
420  (void)xmlTextWriterStartElement(writer, BAD_CAST(pObj->getElementName()));
421  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pObj);
422  }
423  (void)xmlTextWriterEndElement(writer);
424  }
425  (void)xmlTextWriterEndElement(writer);
426  }
427  }
428 
429  if (IsTextFrame())
430  {
431  const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this);
432  sw::MergedPara const*const pMerged(pTextFrame->GetMergedPara());
433  if (pMerged)
434  {
435  (void)xmlTextWriterStartElement( writer, BAD_CAST( "merged" ) );
436  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "paraPropsNodeIndex" ), "%" SAL_PRIdINT32, sal_Int32(pMerged->pParaPropsNode->GetIndex()) );
437  for (auto const& e : pMerged->extents)
438  {
439  (void)xmlTextWriterStartElement( writer, BAD_CAST( "extent" ) );
440  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "txtNodeIndex" ), "%" SAL_PRIdINT32, sal_Int32(e.pNode->GetIndex()) );
441  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "start" ), "%" SAL_PRIdINT32, e.nStart );
442  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "end" ), "%" SAL_PRIdINT32, e.nEnd );
443  (void)xmlTextWriterEndElement( writer );
444  }
445  (void)xmlTextWriterEndElement( writer );
446  }
447  }
448 
449  if (IsCellFrame())
450  {
451  SwCellFrame const* pCellFrame(static_cast<SwCellFrame const*>(this));
452  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "rowspan" ), "%ld", pCellFrame->GetLayoutRowSpan() );
453  }
454 
455  (void)xmlTextWriterStartElement( writer, BAD_CAST( "infos" ) );
456  dumpInfosAsXml( writer );
457  (void)xmlTextWriterEndElement( writer );
458 
459  // Dump Anchored objects if any
460  const SwSortedObjs* pAnchored = GetDrawObjs();
461  if ( pAnchored && pAnchored->size() > 0 )
462  {
463  (void)xmlTextWriterStartElement( writer, BAD_CAST( "anchored" ) );
464 
465  for (SwAnchoredObject* pObject : *pAnchored)
466  {
467  pObject->dumpAsXml( writer );
468  }
469 
470  (void)xmlTextWriterEndElement( writer );
471  }
472 
473  // Dump the children
474  if ( IsTextFrame( ) )
475  {
476  const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this);
477  OUString aText = pTextFrame->GetText( );
478  for ( int i = 0; i < 32; i++ )
479  {
480  aText = aText.replace( i, '*' );
481  }
482  OString aText8 =OUStringToOString( aText,
483  RTL_TEXTENCODING_UTF8 );
484  (void)xmlTextWriterWriteString( writer,
485  reinterpret_cast<const xmlChar *>(aText8.getStr( )) );
486  XmlPortionDumper pdumper( writer, aText );
487  pTextFrame->VisitPortions( pdumper );
488  if (const SwParaPortion* pPara = pTextFrame->GetPara())
489  {
490  (void)xmlTextWriterStartElement(writer, BAD_CAST("SwParaPortion"));
491  TextFrameIndex nOffset(0);
492  const OUString& rText = pTextFrame->GetText();
493  pPara->dumpAsXmlAttributes(writer, rText, nOffset);
494  const SwLineLayout* pLine = pPara;
495  if (pTextFrame->IsFollow())
496  {
497  nOffset += pTextFrame->GetOffset();
498  }
499  while (pLine)
500  {
501  (void)xmlTextWriterStartElement(writer, BAD_CAST("SwLineLayout"));
502  pLine->dumpAsXmlAttributes(writer, rText, nOffset);
503  const SwLinePortion* pPor = pLine->GetFirstPortion();
504  while (pPor)
505  {
506  pPor->dumpAsXml(writer, rText, nOffset);
507  pPor = pPor->GetNextPortion();
508  }
509  (void)xmlTextWriterEndElement(writer);
510  pLine = pLine->GetNext();
511  }
512  (void)xmlTextWriterEndElement(writer);
513  }
514 
515  }
516  else
517  {
518  dumpChildrenAsXml( writer );
519  }
520  (void)xmlTextWriterEndElement( writer );
521  }
522 
523  if ( bCreateWriter )
524  lcl_freeWriter( writer );
525 }
526 
528 {
529  // output the Frame
530  (void)xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) );
532  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFixSize"), BAD_CAST(OString::boolean(HasFixSize()).getStr()));
533  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaPositionValid"), BAD_CAST(OString::boolean(isFrameAreaPositionValid()).getStr()));
534  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFrameAreaSizeValid"), BAD_CAST(OString::boolean(isFrameAreaSizeValid()).getStr()));
535  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("mbFramePrintAreaValid"), BAD_CAST(OString::boolean(isFramePrintAreaValid()).getStr()));
536  (void)xmlTextWriterEndElement( writer );
537 
538  // output the print area
539  (void)xmlTextWriterStartElement( writer, BAD_CAST( "prtBounds" ) );
541  (void)xmlTextWriterEndElement( writer );
542 }
543 
545 {
546  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
547  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "id" ), "%" SAL_PRIuUINT32, GetFrameId() );
548  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "symbol" ), "%s", BAD_CAST( typeid( *this ).name( ) ) );
549  if ( GetNext( ) )
550  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "next" ), "%" SAL_PRIuUINT32, GetNext()->GetFrameId() );
551  if ( GetPrev( ) )
552  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "prev" ), "%" SAL_PRIuUINT32, GetPrev()->GetFrameId() );
553  if ( GetUpper( ) )
554  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "upper" ), "%" SAL_PRIuUINT32, GetUpper()->GetFrameId() );
555  if ( GetLower( ) )
556  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "lower" ), "%" SAL_PRIuUINT32, GetLower()->GetFrameId() );
557  if (IsFootnoteFrame())
558  {
559  SwFootnoteFrame const*const pFF(static_cast<SwFootnoteFrame const*>(this));
560  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("ref"), "%" SAL_PRIuUINT32, pFF->GetRef()->GetFrameId() );
561  if (pFF->GetMaster())
562  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("master"), "%" SAL_PRIuUINT32, pFF->GetMaster()->GetFrameId() );
563  if (pFF->GetFollow())
564  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("follow"), "%" SAL_PRIuUINT32, pFF->GetFollow()->GetFrameId() );
565  }
566  if (IsSctFrame())
567  {
568  SwSectionFrame const*const pFrame(static_cast<SwSectionFrame const*>(this));
569  SwSectionNode const*const pNode(pFrame->GetSection() ? pFrame->GetSection()->GetFormat()->GetSectionNode() : nullptr);
570  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("sectionNodeIndex"), "%" SAL_PRIdINT32, pNode ? sal_Int32(pNode->GetIndex()) : -1);
571  }
572  if ( IsTextFrame( ) )
573  {
574  const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this);
575  const SwTextNode *pTextNode = pTextFrame->GetTextNodeFirst();
576  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "txtNodeIndex" ), "%" SAL_PRIdINT32, sal_Int32(pTextNode->GetIndex()) );
577 
578  OString aMode = "Horizontal";
579  if (IsVertLRBT())
580  {
581  aMode = "VertBTLR";
582  }
583  else if (IsVertLR())
584  {
585  aMode = "VertLR";
586  }
587  else if (IsVertical())
588  {
589  aMode = "Vertical";
590  }
591  (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("WritingMode"), BAD_CAST(aMode.getStr()));
592  }
593  if (IsHeaderFrame() || IsFooterFrame())
594  {
595  const SwHeadFootFrame *pHeadFootFrame = static_cast<const SwHeadFootFrame*>(this);
596  OUString aFormatName = pHeadFootFrame->GetFormat()->GetName();
597  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "fmtName" ), "%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
598  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "fmtPtr" ), "%p", pHeadFootFrame->GetFormat());
599  }
600 }
601 
603 {
604  const SwFrame *pFrame = GetLower( );
605  for ( ; pFrame != nullptr; pFrame = pFrame->GetNext( ) )
606  {
607  pFrame->dumpAsXml( writer );
608  }
609 }
610 
612 {
613  bool bCreateWriter = ( nullptr == writer );
614  if ( bCreateWriter )
615  writer = lcl_createDefaultWriter();
616 
617  (void)xmlTextWriterStartElement( writer, BAD_CAST( getElementName() ) );
618  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
619 
620  (void)xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) );
621  // don't call GetObjBoundRect(), it modifies the layout
622  SwRect(GetDrawObj()->GetLastBoundRect()).dumpAsXmlAttributes(writer);
623  (void)xmlTextWriterEndElement( writer );
624 
625  if (const SdrObject* pObject = GetDrawObj())
626  pObject->dumpAsXml(writer);
627 
628  (void)xmlTextWriterEndElement( writer );
629 
630  if ( bCreateWriter )
631  lcl_freeWriter( writer );
632 }
633 
635 {
636  (void)xmlTextWriterStartElement(writer, BAD_CAST("SwFont"));
637  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", this);
638  // do not use Color::AsRGBHexString() as that omits the transparency
639  (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("color"), "%08" SAL_PRIxUINT32, sal_uInt32(GetColor()));
640  (void)xmlTextWriterEndElement(writer);
641 }
642 
644 {
646  if ( HasFollow() )
647  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
648 
649  if (m_pPrecede != nullptr)
650  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwTextFrame*>(m_pPrecede)->GetFrameId() );
651 }
652 
654 {
656  if ( HasFollow() )
657  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
658 
659  if (m_pPrecede != nullptr)
660  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwSectionFrame*>( m_pPrecede )->GetFrameId() );
661 }
662 
664 {
666  if ( HasFollow() )
667  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%" SAL_PRIuUINT32, GetFollow()->GetFrameId() );
668 
669  if (m_pPrecede != nullptr)
670  (void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwTabFrame*>( m_pPrecede )->GetFrameId() );
671 }
672 
673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:314
virtual const SwFlyFrame * DynCastFlyFrame() const override
Definition: fly.cxx:2977
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
bool IsFollow() const
Definition: flowfrm.hxx:166
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:564
bool IsRootFrame() const
Definition: frame.hxx:1174
SwLineLayout * GetNext()
Definition: porlay.hxx:159
const char * PortionTypeToString(PortionType nType)
Definition: xmldump.cxx:33
SwFrameType GetType() const
Definition: frame.hxx:519
void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText, TextFrameIndex nOffset) const
Definition: porlin.cxx:330
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:46
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:451
bool HasFollow() const
Definition: flowfrm.hxx:165
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const
Definition: xmldump.cxx:313
SwSectionFormat * GetFormat()
Definition: section.hxx:336
bool IsCellFrame() const
Definition: frame.hxx:1226
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:446
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1296
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:663
void dumpAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:634
EmbeddedObjectRef * pObject
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
virtual void Text(TextFrameIndex nLength, PortionType nType, sal_Int32 nHeight=0, sal_Int32 nWidth=0)=0
(empty) destructor
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:250
bool IsFootnoteFrame() const
Definition: frame.hxx:1202
const OUString & GetName() const
Definition: pagedesc.hxx:196
bool IsVertLRBT() const
Definition: frame.hxx:983
virtual void Finish()=0
end of paragraph.
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
wrapper class for the positioning of Writer fly frames and drawing objects
bool IsInvalidFlyInCnt() const
Definition: pagefrm.hxx:233
const SwRect & getFrameArea() const
Definition: frame.hxx:179
SwSectionNode * GetSectionNode()
Definition: section.cxx:922
const OUString & GetName() const
Definition: format.hxx:131
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
bool IsTextFrame() const
Definition: frame.hxx:1234
virtual void LineBreak(sal_Int32 nWidth)=0
line break.
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:957
bool IsSctFrame() const
Definition: frame.hxx:1214
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Dump a bunch of useful data to an XML representation to ease layout understanding, debugging and testing.
Definition: xmldump.cxx:611
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:856
tools::Long GetLayoutRowSpan() const
Definition: tabfrm.cxx:5639
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:439
bool IsInvalidContent() const
Definition: pagefrm.hxx:235
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType, sal_Int32 nHeight=0, sal_Int32 nWidth=0, const SwFont *pFont=nullptr)=0
special portion.
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
virtual void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &rOffset) const
Definition: porlin.cxx:321
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:458
bool IsInvalidFlyContent() const
Definition: pagefrm.hxx:232
virtual const char * getElementName() const
The element name to show in the XML dump.
void dumpChildrenAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:602
const SdrObject * GetDrawObj() const
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:132
int i
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:78
void dumpAsXml(xmlTextWriterPtr pWriter) const override
See SfxViewShell::dumpAsXml().
Definition: viewprt.cxx:268
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:173
size_t size() const
Definition: sortedobjs.cxx:43
void dumpTopMostAsXml(xmlTextWriterPtr writer=nullptr) const
Definition: xmldump.cxx:302
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
SwNodeOffset GetIndex() const
Definition: node.hxx:292
SwLinePortion * GetFirstPortion() const
Definition: porlay.cxx:827
SwSection * GetSection()
Definition: sectfrm.hxx:97
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
bool isFramePrintAreaValid() const
Definition: frame.hxx:168
PortionType
Definition: txttypes.hxx:23
SwFrame * GetPrev()
Definition: frame.hxx:677
SwFlowFrame * m_pPrecede
Definition: flowfrm.hxx:118
bool isFrameAreaPositionValid() const
Definition: frame.hxx:166
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:643
bool HasFixSize() const
Definition: frame.hxx:670
bool isFrameAreaSizeValid() const
Definition: frame.hxx:167
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
const Color & GetColor() const
Definition: swfont.hxx:277
A page of the document layout.
Definition: pagefrm.hxx:57
const SwFootnoteFrame * GetMaster() const
Definition: ftnfrm.hxx:119
bool IsInvalidFlyLayout() const
Definition: pagefrm.hxx:231
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:51
void dumpInfosAsXml(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:527
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool IsVertLR() const
Definition: frame.hxx:979
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
Definition: xmldump.cxx:544
const SwFootnoteFrame * GetFollow() const
Definition: ftnfrm.hxx:116
const SwContentFrame * GetRef() const
Definition: ftnfrm.cxx:2906
SwFrame * GetLower()
Definition: findfrm.cxx:194
bool IsPageFrame() const
Definition: frame.hxx:1178
const char * name
virtual void Skip(TextFrameIndex nLength)=0
skip characters.
const SwTabFrame * GetFollow() const
Definition: tabfrm.hxx:250
virtual SfxObjectShell * GetObjectShell() override
bool IsVertical() const
Definition: frame.hxx:973
struct _xmlTextWriter * xmlTextWriterPtr
OString m_aLine
void VisitPortions(SwPortionHandler &rPH) const
Visit all portions for Accessibility.
Definition: txtfrm.cxx:3887
SwLinePortion * GetNextPortion() const
Definition: porlin.hxx:74
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:206
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
class for collecting anchored objects
Definition: sortedobjs.hxx:48
bool IsFooterFrame() const
Definition: frame.hxx:1194
sal_uInt32 GetFrameId() const
Definition: frame.hxx:174
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
bool IsInvalidLayout() const
Definition: pagefrm.hxx:234
Definition: view.hxx:144
void dumpAsXmlAttributes(xmlTextWriterPtr writer) const
Definition: swrect.cxx:178
virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override
Definition: xmldump.cxx:653
bool IsHeaderFrame() const
Definition: frame.hxx:1190
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:399
SwFrame * GetNext()
Definition: frame.hxx:676
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo