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