LCOV - code coverage report
Current view: top level - sw/source/core/docnode - nodedump.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 479 0.0 %
Date: 2014-04-14 Functions: 0 22 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "doc.hxx"
      11             : #include "ndtxt.hxx"
      12             : #include "MarkManager.hxx"
      13             : #include "docary.hxx"
      14             : #include "switerator.hxx"
      15             : #include "fmtfld.hxx"
      16             : #include "docufld.hxx"
      17             : #include "txatbase.hxx"
      18             : #include "fmtautofmt.hxx"
      19             : #include "fmtcntnt.hxx"
      20             : #include "charfmt.hxx"
      21             : #include "frmfmt.hxx"
      22             : #include "fmtanchr.hxx"
      23             : #include "fmtsrnd.hxx"
      24             : #include "paratr.hxx"
      25             : #include "redline.hxx"
      26             : #include <swmodule.hxx>
      27             : #include <svl/itemiter.hxx>
      28             : #include <svl/intitem.hxx>
      29             : #include <editeng/charrotateitem.hxx>
      30             : #include <editeng/rsiditem.hxx>
      31             : #include <editeng/fontitem.hxx>
      32             : #include <editeng/fhgtitem.hxx>
      33             : #include <editeng/editobj.hxx>
      34             : #include <editeng/outlobj.hxx>
      35             : #include <svx/xdef.hxx>
      36             : #include <svx/svdpage.hxx>
      37             : #include <svx/svdmodel.hxx>
      38             : #include <svx/xfillit0.hxx>
      39             : #include <tools/datetimeutils.hxx>
      40             : 
      41             : #include <libxml/encoding.h>
      42             : #include <libxml/xmlwriter.h>
      43             : #include <boost/optional.hpp>
      44             : #include <rtl/strbuf.hxx>
      45             : 
      46             : namespace
      47             : {
      48             : 
      49             : // Small helper class to ensure that we write to nodes.xml if nothing
      50             : // has been explicitly specified.
      51             : // Always use at the beginning of dumpAsXml().
      52             : // Also, there are some functions to save typing.
      53             : class WriterHelper
      54             : {
      55             : public:
      56             :     WriterHelper( xmlTextWriterPtr );
      57             :     ~WriterHelper();
      58             :     operator xmlTextWriterPtr();
      59             :     void startElement( const char* element );
      60             :     void endElement();
      61             :     void writeFormatAttribute( const char* attribute, const char* format, ... )
      62             : #ifdef LIBXML_ATTR_FORMAT
      63             :         LIBXML_ATTR_FORMAT(3,4)
      64             : #endif
      65             :         ;
      66             : private:
      67             :     xmlTextWriterPtr writer;
      68             :     bool owns;
      69             : };
      70             : 
      71           0 : WriterHelper::WriterHelper( xmlTextWriterPtr w )
      72             :     : writer( w )
      73           0 :     , owns( false )
      74             : {
      75           0 :     if( writer == NULL )
      76             :     {
      77           0 :         writer = xmlNewTextWriterFilename( "nodes.xml", 0 );
      78           0 :         xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
      79           0 :         owns = true;
      80             :     }
      81           0 : }
      82             : 
      83           0 : WriterHelper::~WriterHelper()
      84             : {
      85           0 :     if( owns )
      86             :     {
      87           0 :         xmlTextWriterEndDocument( writer );
      88           0 :         xmlFreeTextWriter( writer );
      89             :     }
      90           0 : }
      91             : 
      92           0 : WriterHelper::operator xmlTextWriterPtr()
      93             : {
      94           0 :     return writer;
      95             : }
      96             : 
      97           0 : void WriterHelper::startElement( const char* element )
      98             : {
      99           0 :     xmlTextWriterStartElement( writer, BAD_CAST( element ));
     100           0 : }
     101             : 
     102           0 : void WriterHelper::endElement()
     103             : {
     104           0 :     xmlTextWriterEndElement( writer );
     105           0 : }
     106             : 
     107           0 : void WriterHelper::writeFormatAttribute( const char* attribute, const char* format, ... )
     108             : {
     109             :     va_list va;
     110           0 :     va_start( va, format );
     111           0 :     xmlTextWriterWriteVFormatAttribute( writer, BAD_CAST( attribute ), format, va );
     112           0 :     va_end( va );
     113           0 : }
     114             : 
     115             : // Hack: somehow conversion from "..." to va_list does
     116             : // bomb on two string litterals in the format.
     117             : static const char* TMP_FORMAT = "%" SAL_PRIuUINTPTR;
     118             : static const char* TMP_FORMAT_I32 = "%" SAL_PRIdINT32;
     119             : 
     120             : }
     121             : 
     122           0 : void lcl_dumpSdrModel(WriterHelper& writer, const SdrModel* pModel)
     123             : {
     124           0 :     writer.startElement("sdrModel");
     125           0 :     writer.writeFormatAttribute("ptr", "%p", pModel);
     126           0 :     if (pModel)
     127             :     {
     128           0 :         const SdrPage* pPage = pModel->GetPage(0);
     129           0 :         writer.startElement("sdrPage");
     130           0 :         writer.writeFormatAttribute("ptr", "%p", pPage);
     131           0 :         if (pPage)
     132             :         {
     133           0 :             sal_Int32 nObjCount = pPage->GetObjCount();
     134           0 :             for (sal_Int32 i = 0; i < nObjCount; ++i)
     135             :             {
     136           0 :                 const SdrObject* pObject = pPage->GetObj(i);
     137           0 :                 writer.startElement("sdrObject");
     138           0 :                 writer.writeFormatAttribute("ptr", "%p", pObject);
     139           0 :                 if (pObject)
     140             :                 {
     141           0 :                     writer.writeFormatAttribute("symbol", "%s", BAD_CAST(typeid(*pObject).name()));
     142           0 :                     writer.writeFormatAttribute("name", "%s", BAD_CAST(OUStringToOString(pObject->GetName(), RTL_TEXTENCODING_UTF8).getStr()));
     143           0 :                     writer.writeFormatAttribute("title", "%s", BAD_CAST(OUStringToOString(pObject->GetTitle(), RTL_TEXTENCODING_UTF8).getStr()));
     144           0 :                     writer.writeFormatAttribute("description", "%s", BAD_CAST(OUStringToOString(pObject->GetDescription(), RTL_TEXTENCODING_UTF8).getStr()));
     145             : 
     146           0 :                     const OutlinerParaObject* pOutliner = pObject->GetOutlinerParaObject();
     147           0 :                     writer.startElement("outliner");
     148           0 :                     writer.writeFormatAttribute("ptr", "%p", pOutliner);
     149           0 :                     if (pOutliner)
     150             :                     {
     151           0 :                         const EditTextObject& rEditObj = pOutliner->GetTextObject();
     152           0 :                         sal_Int32 nPara = rEditObj.GetParagraphCount();
     153           0 :                         for (sal_Int32 j = 0; j < nPara; ++j)
     154             :                         {
     155           0 :                             writer.startElement("paragraph");
     156           0 :                             xmlTextWriterWriteString(writer, BAD_CAST(OUStringToOString(rEditObj.GetText(j), RTL_TEXTENCODING_UTF8).getStr()));
     157           0 :                             writer.endElement();
     158             :                         }
     159             :                     }
     160           0 :                     writer.endElement();
     161             :                 }
     162           0 :                 writer.endElement();
     163             :             }
     164             :         }
     165           0 :         writer.endElement();
     166             :     }
     167           0 :     writer.endElement();
     168           0 : }
     169             : 
     170           0 : void SwDoc::dumpAsXml( xmlTextWriterPtr w )
     171             : {
     172           0 :     WriterHelper writer( w );
     173           0 :     writer.startElement( "doc" );
     174           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     175           0 :     m_pNodes->dumpAsXml( writer );
     176           0 :     mpMarkManager->dumpAsXml( writer );
     177           0 :     mpFldTypes->dumpAsXml( writer );
     178           0 :     mpTxtFmtCollTbl->dumpAsXml( writer );
     179           0 :     mpCharFmtTbl->dumpAsXml( writer );
     180           0 :     mpSpzFrmFmtTbl->dumpAsXml( writer );
     181           0 :     mpNumRuleTbl->dumpAsXml( writer );
     182           0 :     mpRedlineTbl->dumpAsXml( writer );
     183           0 :     mpExtraRedlineTbl->dumpAsXml( writer );
     184           0 :     lcl_dumpSdrModel( writer, mpDrawModel );
     185           0 :     writer.endElement();
     186           0 : }
     187             : 
     188             : namespace sw {
     189             : namespace mark {
     190           0 : void MarkManager::dumpAsXml( xmlTextWriterPtr w )
     191             : {
     192           0 :     WriterHelper writer(w);
     193           0 :     writer.startElement("markManager");
     194           0 :     writer.startElement("fieldmarks");
     195           0 :     for (const_iterator_t it = m_vFieldmarks.begin(); it != m_vFieldmarks.end(); ++it)
     196             :     {
     197           0 :         pMark_t pMark = *it;
     198           0 :         writer.startElement("fieldmark");
     199           0 :         writer.writeFormatAttribute("startNode", TMP_FORMAT, pMark->GetMarkStart().nNode.GetIndex());
     200           0 :         writer.writeFormatAttribute("startOffset", TMP_FORMAT_I32, pMark->GetMarkStart().nContent.GetIndex());
     201           0 :         writer.writeFormatAttribute("endNode", TMP_FORMAT, pMark->GetMarkEnd().nNode.GetIndex());
     202           0 :         writer.writeFormatAttribute("endOffset", TMP_FORMAT_I32, pMark->GetMarkEnd().nContent.GetIndex());
     203           0 :         OString txt8 = OUStringToOString(pMark->GetName(), RTL_TEXTENCODING_UTF8);
     204           0 :         writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
     205           0 :         writer.endElement();
     206           0 :     }
     207           0 :     writer.endElement();
     208             : 
     209           0 :     writer.startElement("annotationmarks");
     210           0 :     for (const_iterator_t it = m_vAnnotationMarks.begin(); it != m_vAnnotationMarks.end(); ++it)
     211             :     {
     212           0 :         pMark_t pMark = *it;
     213           0 :         writer.startElement("annotationmark");
     214           0 :         writer.writeFormatAttribute("startNode", TMP_FORMAT, pMark->GetMarkStart().nNode.GetIndex());
     215           0 :         writer.writeFormatAttribute("startOffset", TMP_FORMAT_I32, pMark->GetMarkStart().nContent.GetIndex());
     216           0 :         writer.writeFormatAttribute("endNode", TMP_FORMAT, pMark->GetMarkEnd().nNode.GetIndex());
     217           0 :         writer.writeFormatAttribute("endOffset", TMP_FORMAT_I32, pMark->GetMarkEnd().nContent.GetIndex());
     218           0 :         OString txt8 = OUStringToOString(pMark->GetName(), RTL_TEXTENCODING_UTF8);
     219           0 :         writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
     220           0 :         writer.endElement();
     221           0 :     }
     222           0 :     writer.endElement();
     223           0 :     writer.endElement();
     224           0 : }
     225             : } // namespace mark
     226             : } // namespace sw
     227             : 
     228           0 : void SwFldTypes::dumpAsXml( xmlTextWriterPtr w )
     229             : {
     230           0 :     WriterHelper writer(w);
     231           0 :     writer.startElement("swfldtypes");
     232           0 :     sal_uInt16 nCount = size();
     233           0 :     for (sal_uInt16 nType = 0; nType < nCount; ++nType)
     234             :     {
     235           0 :         const SwFieldType *pCurType = (*this)[nType];
     236           0 :         SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
     237           0 :         for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
     238             :         {
     239           0 :             writer.startElement("swfmtfld");
     240           0 :             writer.writeFormatAttribute("ptr", "%p", pCurFldFmt);
     241           0 :             writer.writeFormatAttribute("pTxtAttr", "%p", pCurFldFmt->GetTxtFld());
     242           0 :             const char* name = "???";
     243           0 :             switch(pCurFldFmt->GetField()->GetTyp()->Which())
     244             :             {
     245           0 :                 case RES_PAGENUMBERFLD: name = "swpagenumberfield"; break;
     246           0 :                 case RES_POSTITFLD: name = "swpostitfield"; break;
     247           0 :                 case RES_DATETIMEFLD: name = "swdatetimefield"; break;
     248             :                 default:
     249             :                     SAL_INFO("sw.core", "unhandled field type " << pCurFldFmt->GetField()->GetTyp()->Which());
     250           0 :                     break;
     251             :             }
     252           0 :             writer.startElement(name);
     253           0 :             writer.writeFormatAttribute("ptr", "%p", pCurFldFmt->GetField());
     254           0 :             if (pCurFldFmt->GetField()->GetTyp()->Which() == RES_POSTITFLD)
     255             :             {
     256           0 :                 const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetField());
     257           0 :                 OString txt8 = OUStringToOString(pField->GetName(), RTL_TEXTENCODING_UTF8);
     258           0 :                 writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
     259             :             }
     260           0 :             writer.endElement();
     261           0 :             writer.endElement();
     262             :         }
     263           0 :     }
     264           0 :     writer.endElement();
     265           0 : }
     266             : 
     267           0 : void SwNodes::dumpAsXml( xmlTextWriterPtr w )
     268             : {
     269           0 :     WriterHelper writer( w );
     270           0 :     writer.startElement( "swnodes" );
     271           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     272           0 :     for( unsigned int i = 0; i < Count(); ++i )
     273             :     {
     274           0 :         ( *this )[ i ]->dumpAsXml( writer );
     275             :     }
     276           0 :     writer.endElement();
     277           0 : }
     278             : 
     279           0 : void SwNode::dumpAsXml( xmlTextWriterPtr w )
     280             : {
     281           0 :     WriterHelper writer( w );
     282           0 :     const char* name = "???";
     283           0 :     switch( GetNodeType())
     284             :     {
     285             :         case ND_ENDNODE:
     286           0 :             name = "end";
     287           0 :             break;
     288             :         case ND_STARTNODE:
     289             :         case ND_TEXTNODE:
     290           0 :             abort(); // overridden
     291             :         case ND_TABLENODE:
     292           0 :             name = "table";
     293           0 :             break;
     294             :         case ND_GRFNODE:
     295           0 :             name = "grf";
     296           0 :             break;
     297             :         case ND_OLENODE:
     298           0 :             name = "ole";
     299           0 :             break;
     300             :     }
     301           0 :     writer.startElement( name );
     302           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     303           0 :     writer.writeFormatAttribute( "index", TMP_FORMAT, GetIndex() );
     304           0 :     writer.endElement();
     305           0 :     if( GetNodeType() == ND_ENDNODE )
     306           0 :         writer.endElement(); // end start node
     307           0 : }
     308             : 
     309           0 : void SwStartNode::dumpAsXml( xmlTextWriterPtr w )
     310             : {
     311           0 :     WriterHelper writer( w );
     312           0 :     const char* name = "???";
     313           0 :     switch( GetNodeType() )
     314             :     {
     315             :         case ND_TABLENODE:
     316           0 :             name = "table";
     317           0 :             break;
     318             :         case ND_SECTIONNODE:
     319           0 :             name = "section";
     320           0 :             break;
     321             :         default:
     322           0 :             switch( GetStartNodeType())
     323             :             {
     324             :                 case SwNormalStartNode:
     325           0 :                     name = "start";
     326           0 :                     break;
     327             :                 case SwTableBoxStartNode:
     328           0 :                     name = "tablebox";
     329           0 :                     break;
     330             :                 case SwFlyStartNode:
     331           0 :                     name = "fly";
     332           0 :                     break;
     333             :                 case SwFootnoteStartNode:
     334           0 :                     name = "footnote";
     335           0 :                     break;
     336             :                 case SwHeaderStartNode:
     337           0 :                     name = "header";
     338           0 :                     break;
     339             :                 case SwFooterStartNode:
     340           0 :                     name = "footer";
     341           0 :                     break;
     342             :             }
     343           0 :             break;
     344             :     }
     345           0 :     writer.startElement( name );
     346           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     347           0 :     writer.writeFormatAttribute( "index", TMP_FORMAT, GetIndex() );
     348             :     // writer.endElement(); - it is a start node, so don't end, will make xml better nested
     349           0 : }
     350             : 
     351           0 : void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
     352             : {
     353           0 :     SfxItemIter aIter(*pSet);
     354           0 :     const SfxPoolItem* pItem = aIter.FirstItem();
     355           0 :     while (pItem)
     356             :     {
     357           0 :         writer.startElement("item");
     358           0 :         writer.writeFormatAttribute("whichId", TMP_FORMAT, pItem->Which());
     359           0 :         const char* pWhich = 0;
     360           0 :         boost::optional<OString> oValue;
     361           0 :         switch (pItem->Which())
     362             :         {
     363           0 :             case RES_CHRATR_POSTURE: pWhich = "character posture"; break;
     364           0 :             case RES_CHRATR_WEIGHT: pWhich = "character weight"; break;
     365           0 :             case RES_CHRATR_CJK_POSTURE: pWhich = "character cjk posture"; break;
     366           0 :             case RES_CHRATR_CJK_WEIGHT: pWhich = "character cjk weight"; break;
     367           0 :             case RES_CHRATR_CTL_POSTURE: pWhich = "character ctl posture"; break;
     368           0 :             case RES_CHRATR_CTL_WEIGHT: pWhich = "character ctl weight"; break;
     369             :             case RES_CHRATR_RSID:
     370             :             {
     371           0 :                 pWhich = "character rsid";
     372           0 :                 css::uno::Any aAny;
     373           0 :                 static_cast<const SvxRsidItem*>(pItem)->QueryValue(aAny);
     374           0 :                 oValue = OString::number(aAny.get<sal_uInt32>());
     375           0 :                 break;
     376             :             }
     377           0 :             case RES_CHRATR_ROTATE: pWhich = "character rotation"; oValue = OString::number(static_cast<const SvxCharRotateItem*>(pItem)->GetValue()); break;
     378           0 :             case RES_PARATR_OUTLINELEVEL: pWhich = "paragraph outline level"; oValue = OString::number(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); break;
     379           0 :             case RES_PARATR_NUMRULE: pWhich = "paragraph numbering rule"; oValue = OUStringToOString(static_cast<const SwNumRuleItem*>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8); break;
     380           0 :             case RES_CHRATR_FONT: pWhich = "character font"; oValue = OUStringToOString(static_cast<const SvxFontItem*>(pItem)->GetFamilyName(), RTL_TEXTENCODING_UTF8); break;
     381           0 :             case RES_CHRATR_BACKGROUND: pWhich = "character background"; break;
     382           0 :             case RES_CHRATR_CTL_FONT: pWhich = "character ctl font"; break;
     383             :             case RES_CHRATR_FONTSIZE:
     384             :             {
     385           0 :                 pWhich = "character font size";
     386           0 :                 const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
     387           0 :                 oValue = "nHeight: " + OString::number(pFontHeightItem->GetHeight()) + ", nProp: " + OString::number(pFontHeightItem->GetProp());
     388           0 :                 break;
     389             :             }
     390             :             case RES_CNTNT:
     391             :             {
     392           0 :                 pWhich = "frame content";
     393           0 :                 const SwFmtCntnt* pCntnt = static_cast<const SwFmtCntnt*>(pItem);
     394           0 :                 oValue = "node index: " + OString::number(pCntnt->GetCntntIdx()->GetNode().GetIndex());
     395           0 :                 break;
     396             :             }
     397             :             case RES_FRM_SIZE:
     398             :             {
     399           0 :                 pWhich = "frame size";
     400           0 :                 break;
     401             :             }
     402             :             case RES_VERT_ORIENT:
     403             :             {
     404           0 :                 pWhich = "frame vertical orientation";
     405           0 :                 break;
     406             :             }
     407             :             case RES_HORI_ORIENT:
     408             :             {
     409           0 :                 pWhich = "frame horizontal orientation";
     410           0 :                 break;
     411             :             }
     412             :             case RES_ANCHOR:
     413             :             {
     414           0 :                 pWhich = "frame anchor";
     415           0 :                 const SwFmtAnchor* pAnchor = static_cast<const SwFmtAnchor*>(pItem);
     416           0 :                 const SwPosition* pPosition = pAnchor->GetCntntAnchor();
     417           0 :                 if (pPosition)
     418           0 :                     oValue = "node index: " + OString::number(pPosition->nNode.GetNode().GetIndex()) + ", index: " + OString::number(pPosition->nContent.GetIndex());
     419           0 :                 break;
     420             :             }
     421             :             case RES_SURROUND:
     422             :             {
     423           0 :                 pWhich = "frame surround";
     424           0 :                 const SwFmtSurround* pSurround = static_cast<const SwFmtSurround*>(pItem);
     425           0 :                 switch (pSurround->GetSurround())
     426             :                 {
     427             :                 case SURROUND_NONE:
     428           0 :                     oValue = "none";
     429           0 :                     break;
     430             :                 case SURROUND_THROUGHT:
     431           0 :                     oValue = "throught";
     432           0 :                     break;
     433             :                 case SURROUND_PARALLEL:
     434           0 :                     oValue = "parallel";
     435           0 :                     break;
     436             :                 case SURROUND_IDEAL:
     437           0 :                     oValue = "ideal";
     438           0 :                     break;
     439             :                 case SURROUND_LEFT:
     440           0 :                     oValue = "left";
     441           0 :                     break;
     442             :                 case SURROUND_RIGHT:
     443           0 :                     oValue = "right";
     444           0 :                     break;
     445             :                 case SURROUND_END:
     446           0 :                     oValue = "end";
     447           0 :                     break;
     448             :                 }
     449           0 :                 break;
     450             :             }
     451             :             case RES_FOLLOW_TEXT_FLOW:
     452             :             {
     453           0 :                 pWhich = "frame follow text flow";
     454           0 :                 break;
     455             :             }
     456             :             case RES_WRAP_INFLUENCE_ON_OBJPOS:
     457             :             {
     458           0 :                 pWhich = "frame wrap influence on object position";
     459           0 :                 break;
     460             :             }
     461             :             case XATTR_FILLSTYLE:
     462             :             {
     463           0 :                 pWhich = "fill style";
     464           0 :                 const XFillStyleItem* pFillStyleItem = static_cast<const XFillStyleItem*>(pItem);
     465           0 :                 switch (pFillStyleItem->GetValue())
     466             :                 {
     467             :                 case XFILL_NONE:
     468           0 :                     oValue = "none";
     469           0 :                     break;
     470             :                 case XFILL_SOLID:
     471           0 :                     oValue = "solid";
     472           0 :                     break;
     473             :                 case XFILL_GRADIENT:
     474           0 :                     oValue = "gradient";
     475           0 :                     break;
     476             :                 case XFILL_HATCH:
     477           0 :                     oValue = "hatch";
     478           0 :                     break;
     479             :                 case XFILL_BITMAP:
     480           0 :                     oValue = "bitmap";
     481           0 :                     break;
     482             :                 }
     483           0 :                 break;
     484             :             }
     485             :         }
     486           0 :         if (pWhich)
     487           0 :             writer.writeFormatAttribute("which", "%s", BAD_CAST(pWhich));
     488           0 :         if (oValue)
     489           0 :             writer.writeFormatAttribute("value", "%s", BAD_CAST(oValue->getStr()));
     490           0 :         pItem = aIter.NextItem();
     491           0 :         writer.endElement();
     492           0 :     }
     493           0 : }
     494             : 
     495           0 : void SwFrmFmts::dumpAsXml(xmlTextWriterPtr w)
     496             : {
     497           0 :     WriterHelper writer(w);
     498           0 :     if (size())
     499             :     {
     500           0 :         writer.startElement("swfrmfmts");
     501           0 :         for (size_t i = 0; i < size(); ++i)
     502             :         {
     503           0 :             SwFrmFmt* pFmt = static_cast<SwFrmFmt*>(GetFmt(i));
     504           0 :             writer.startElement("swfrmfmt");
     505           0 :             OString aName = OUStringToOString(pFmt->GetName(), RTL_TEXTENCODING_UTF8);
     506           0 :             writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
     507             : 
     508           0 :             lcl_dumpSfxItemSet(writer, &pFmt->GetAttrSet());
     509           0 :             writer.endElement();
     510           0 :         }
     511           0 :         writer.endElement();
     512           0 :     }
     513           0 : }
     514             : 
     515           0 : void SwCharFmts::dumpAsXml(xmlTextWriterPtr w)
     516             : {
     517           0 :     WriterHelper writer(w);
     518           0 :     if (size())
     519             :     {
     520           0 :         writer.startElement("swcharfmts");
     521           0 :         for (size_t i = 0; i < size(); ++i)
     522             :         {
     523           0 :             SwCharFmt* pFmt = static_cast<SwCharFmt*>(GetFmt(i));
     524           0 :             writer.startElement("swcharfmt");
     525           0 :             OString aName = OUStringToOString(pFmt->GetName(), RTL_TEXTENCODING_UTF8);
     526           0 :             writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
     527             : 
     528           0 :             lcl_dumpSfxItemSet(writer, &pFmt->GetAttrSet());
     529           0 :             writer.endElement();
     530           0 :         }
     531           0 :         writer.endElement();
     532           0 :     }
     533           0 : }
     534             : 
     535           0 : void SwTxtFmtColls::dumpAsXml(xmlTextWriterPtr w)
     536             : {
     537           0 :     WriterHelper writer(w);
     538           0 :     if (size())
     539             :     {
     540           0 :         writer.startElement("swtxtfmtcolls");
     541           0 :         for (size_t i = 0; i < size(); ++i)
     542             :         {
     543           0 :             SwTxtFmtColl* pColl = static_cast<SwTxtFmtColl*>(GetFmt(i));
     544           0 :             writer.startElement("swtxtfmtcoll");
     545           0 :             OString aName = OUStringToOString(pColl->GetName(), RTL_TEXTENCODING_UTF8);
     546           0 :             writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
     547             : 
     548           0 :             lcl_dumpSfxItemSet(writer, &pColl->GetAttrSet());
     549           0 :             writer.endElement();
     550           0 :         }
     551           0 :         writer.endElement();
     552           0 :     }
     553           0 : }
     554             : 
     555           0 : void SwNumRule::dumpAsXml(xmlTextWriterPtr w)
     556             : {
     557           0 :      WriterHelper writer(w);
     558           0 :      writer.startElement("swnumrule");
     559           0 :      OString aName = OUStringToOString(GetName(), RTL_TEXTENCODING_UTF8);
     560           0 :      writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
     561           0 :      writer.writeFormatAttribute("isautorule", TMP_FORMAT, IsAutoRule());
     562           0 :      if (GetPoolFmtId() != USHRT_MAX)
     563           0 :          writer.writeFormatAttribute("poolfmtid", TMP_FORMAT, GetPoolFmtId());
     564           0 :      writer.endElement();
     565           0 : }
     566             : 
     567           0 : void SwNumRuleTbl::dumpAsXml(xmlTextWriterPtr w)
     568             : {
     569           0 :     if (!empty())
     570             :     {
     571           0 :         WriterHelper writer(w);
     572           0 :         writer.startElement("swnumruletbl");
     573           0 :         for (size_t i = 0; i < size(); ++i)
     574           0 :             operator[](i)->dumpAsXml(w);
     575           0 :         writer.endElement();
     576             :     }
     577           0 : }
     578             : 
     579           0 : void SwTxtNode::dumpAsXml( xmlTextWriterPtr w )
     580             : {
     581           0 :     WriterHelper writer( w );
     582           0 :     writer.startElement( "text" );
     583           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     584           0 :     writer.writeFormatAttribute( "index", TMP_FORMAT, GetIndex() );
     585           0 :     OUString txt = GetTxt();
     586           0 :     for( int i = 0; i < 32; ++i )
     587           0 :         txt = txt.replace( i, '*' );
     588           0 :     OString txt8 = OUStringToOString( txt, RTL_TEXTENCODING_UTF8 );
     589           0 :     writer.startElement("inner_text");
     590           0 :     xmlTextWriterWriteString( writer, BAD_CAST( txt8.getStr()));
     591           0 :     writer.endElement( );
     592             : 
     593           0 :     if (GetFmtColl())
     594             :     {
     595           0 :         SwTxtFmtColl* pColl = static_cast<SwTxtFmtColl*>(GetFmtColl());
     596           0 :         writer.startElement("swtxtfmtcoll");
     597           0 :         OString aName = OUStringToOString(pColl->GetName(), RTL_TEXTENCODING_UTF8);
     598           0 :         writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
     599           0 :         writer.endElement();
     600             :     }
     601             : 
     602           0 :     if (HasSwAttrSet())
     603             :     {
     604           0 :         writer.startElement("attrset");
     605           0 :         const SwAttrSet& rAttrSet = GetSwAttrSet();
     606           0 :         lcl_dumpSfxItemSet(writer, &rAttrSet);
     607           0 :         writer.endElement();
     608             :     }
     609             : 
     610           0 :     if (HasHints())
     611             :     {
     612           0 :         writer.startElement("hints");
     613           0 :         SwpHints& rHints = GetSwpHints();
     614           0 :         for (sal_uInt16 i = 0; i < rHints.Count(); ++i)
     615             :         {
     616           0 :             writer.startElement("hint");
     617           0 :             SwTxtAttr* pHint = rHints.GetTextHint(i);
     618             : 
     619           0 :             if (pHint->GetStart())
     620           0 :                 writer.writeFormatAttribute("start", TMP_FORMAT, *pHint->GetStart());
     621           0 :             if (pHint->GetEnd())
     622           0 :                 writer.writeFormatAttribute("end", TMP_FORMAT, *pHint->GetEnd());
     623             : 
     624           0 :             const char* pWhich = "???";
     625           0 :             switch (pHint->Which())
     626             :             {
     627             :                 case RES_TXTATR_AUTOFMT:
     628           0 :                     pWhich = "autofmt";
     629           0 :                     break;
     630             :                 case RES_TXTATR_ANNOTATION:
     631           0 :                     pWhich = "annotation";
     632           0 :                     break;
     633             :                 default:
     634           0 :                     break;
     635             :             }
     636           0 :             writer.writeFormatAttribute("which", "%s", BAD_CAST(pWhich));
     637             : 
     638           0 :             if (pHint->Which() == RES_TXTATR_AUTOFMT)
     639             :             {
     640           0 :                 boost::shared_ptr<SfxItemSet> const pSet(pHint->GetAutoFmt().GetStyleHandle());
     641           0 :                 writer.startElement("autofmt");
     642           0 :                 lcl_dumpSfxItemSet(writer, pSet.get());
     643           0 :                 writer.endElement();
     644             :             }
     645             : 
     646           0 :             writer.endElement();
     647             :         }
     648           0 :         writer.endElement();
     649             :     }
     650           0 :     if (GetNumRule())
     651           0 :         GetNumRule()->dumpAsXml(w);
     652             : 
     653           0 :     writer.endElement();
     654           0 : }
     655             : 
     656           0 : void SwRedlineTbl::dumpAsXml( xmlTextWriterPtr w )
     657             : {
     658           0 :     WriterHelper writer( w );
     659             : 
     660           0 :     writer.startElement( "swredlinetbl" );
     661           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     662             : 
     663           0 :     const SwRedlineTbl& redlineTbl = (*this);
     664             : 
     665           0 :     for( sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos )
     666             :     {
     667           0 :         const SwRangeRedline* pRedline = redlineTbl[ nCurRedlinePos ];
     668             : 
     669           0 :         writer.startElement( "swredline" );
     670           0 :         writer.writeFormatAttribute( "ptr", "%p", pRedline );
     671             : 
     672           0 :         OString aId( OString::number( pRedline->GetSeqNo() ) );
     673           0 :         const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedline->GetAuthor() ) );
     674           0 :         OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
     675           0 :         OString aDate( DateTimeToOString( pRedline->GetTimeStamp() ) );
     676           0 :         OString sRedlineType;
     677           0 :         switch( pRedline->GetType() )
     678             :         {
     679             :             case nsRedlineType_t::REDLINE_INSERT:
     680           0 :                 sRedlineType = "REDLINE_INSERT";
     681           0 :                 break;
     682             :             case nsRedlineType_t::REDLINE_DELETE:
     683           0 :                 sRedlineType = "REDLINE_DELETE";
     684           0 :                 break;
     685             :             case nsRedlineType_t::REDLINE_FORMAT:
     686           0 :                 sRedlineType = "REDLINE_FORMAT";
     687           0 :                 break;
     688             :             default:
     689           0 :                 sRedlineType = "UNKNOWN";
     690           0 :                 break;
     691             :         };
     692           0 :         writer.writeFormatAttribute( "id", "%s", BAD_CAST(aId.getStr()) );
     693           0 :         writer.writeFormatAttribute( "author", "%s", BAD_CAST(aAuthor.getStr()) );
     694           0 :         writer.writeFormatAttribute( "date", "%s", BAD_CAST(aDate.getStr()) );
     695           0 :         writer.writeFormatAttribute( "type", "%s", BAD_CAST(sRedlineType.getStr()) );
     696             :         {
     697           0 :             const SwPosition* pStart = pRedline->Start();
     698             : 
     699           0 :             writer.startElement( "swposition_start" );
     700             :             //writer.writeFormatAttribute( "ptr", "%p", pStart );
     701             :             {
     702           0 :                 const SwNodeIndex pStartNodeIndex = pStart->nNode;
     703             :                 //writer.startElement( "swnodeindex" );
     704             :                 //writer.writeFormatAttribute( "ptr", "%p", &pStartNodeIndex );
     705             :                 {
     706           0 :                     const SwNode&     pStartSwNode      = pStartNodeIndex.GetNode();
     707             :                     //writer.startElement( "swnode" );
     708             :                     //writer.writeFormatAttribute( "ptr", "%p", &pStartSwNode );
     709             :                     //writer.writeFormatAttribute( "type", "%d", pStartSwNode.GetNodeType() );
     710             :                     //writer.endElement( );    // swnode
     711           0 :                     writer.writeFormatAttribute( "swnode_type", TMP_FORMAT, pStartSwNode.GetNodeType() );
     712             : 
     713           0 :                     writer.writeFormatAttribute( "paragraph_index", "%d", (int)pStartNodeIndex.GetIndex() );
     714             : 
     715           0 :                     const SwIndex&    pStartContent   = pStart->nContent;
     716             :                     //writer.startElement( "swindex" );
     717             :                     //writer.writeFormatAttribute( "ptr", "%p", &pStartContent );
     718             :                     //writer.writeFormatAttribute( "content_index", "%d", pStartContent.GetIndex() );
     719             :                     //writer.endElement( );    // swindex
     720           0 :                     writer.writeFormatAttribute( "character_index", TMP_FORMAT_I32, pStartContent.GetIndex() );
     721           0 :                 }
     722             :                 //writer.endElement( );    // swnodeindex
     723             :             }
     724           0 :             writer.endElement( );    // swposition_start
     725             : 
     726             :             const SwPosition* pEnd;
     727           0 :             bool bEndIsMark = false;
     728           0 :             if ( pStart == pRedline->GetPoint() )
     729             :             {
     730             :                 // End = Mark
     731           0 :                 pEnd = pRedline->GetMark();
     732           0 :                 bEndIsMark = true;
     733             :             }
     734             :             else
     735             :             {
     736             :                 // End = Point
     737           0 :                 pEnd = pRedline->GetPoint();
     738             :             }
     739             : 
     740           0 :             writer.startElement( "swposition_end" );
     741             :             //writer.writeFormatAttribute( "ptr", "%p", pStart );
     742             :             {
     743           0 :                 const SwNodeIndex pEndNodeIndex = pEnd->nNode;
     744             :                 //writer.startElement( "swnodeindex" );
     745             :                 //writer.writeFormatAttribute( "ptr", "%p", &pEndNodeIndex );
     746             :                 {
     747           0 :                     const SwNode&     pEndSwNode      = pEndNodeIndex.GetNode();
     748             :                     //writer.startElement( "swnode" );
     749             :                     //writer.writeFormatAttribute( "ptr", "%p", &pEndSwNode );
     750             :                     //writer.writeFormatAttribute( "type", "%d", pEndSwNode.GetNodeType() );
     751             :                     //writer.endElement( );    // swnode
     752           0 :                     writer.writeFormatAttribute( "swnode_type", TMP_FORMAT, pEndSwNode.GetNodeType() );
     753             : 
     754           0 :                     writer.writeFormatAttribute( "paragraph_index", "%d", (int)pEndNodeIndex.GetIndex() );
     755             : 
     756           0 :                     const SwIndex&    pEndContent   = pEnd->nContent;
     757             :                     //writer.startElement( "swindex" );
     758             :                     //writer.writeFormatAttribute( "ptr", "%p", &pEndContent );
     759             :                     //writer.writeFormatAttribute( "content_index", "%d", pEndContent.GetIndex() );
     760             :                     //writer.endElement( );    // swindex
     761           0 :                     writer.writeFormatAttribute( "character_index", TMP_FORMAT_I32, pEndContent.GetIndex() );
     762           0 :                 }
     763             :                 //writer.endElement( );    // swnodeindex
     764             :             }
     765           0 :             writer.writeFormatAttribute( "end_is", "%s", BAD_CAST(bEndIsMark ? "mark" : "point"));
     766           0 :             writer.endElement( );    // swposition_end
     767             : 
     768             :             //const SwRedlineData& aRedlineData = pRedline->GetRedlineData();
     769           0 :             const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData();
     770           0 :             writer.startElement( "extra_redline_data" );
     771             :             {
     772           0 :                 const SwRedlineExtraData_FmtColl*           pExtraData_FmtColl           = dynamic_cast<const SwRedlineExtraData_FmtColl*>(pExtraRedlineData);
     773           0 :                 const SwRedlineExtraData_Format*            pExtraData_Format            = dynamic_cast<const SwRedlineExtraData_Format*>(pExtraRedlineData);
     774           0 :                 const SwRedlineExtraData_FormattingChanges* pExtraData_FormattingChanges = dynamic_cast<const SwRedlineExtraData_FormattingChanges*>(pExtraRedlineData);
     775           0 :                 if (pExtraData_FmtColl)
     776           0 :                     writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "fmt coll" ) );
     777           0 :                 else if (pExtraData_Format)
     778           0 :                     writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "format" ) );
     779           0 :                 else if (pExtraData_FormattingChanges)
     780           0 :                     writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "formatting changes" ) );
     781             :                 else
     782           0 :                     writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "UNKNOWN" ) );
     783             :             }
     784           0 :             writer.endElement( );    // extra_redline_data
     785             :         }
     786             : 
     787           0 :         writer.endElement( );    // extra_redline_data
     788           0 :     }
     789             : 
     790           0 :     writer.endElement( );    // swredlinetbl
     791           0 : }
     792             : 
     793           0 : void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w )
     794             : {
     795           0 :     WriterHelper writer( w );
     796             : 
     797           0 :     writer.startElement( "swextraredlinetbl" );
     798           0 :     writer.writeFormatAttribute( "ptr", "%p", this );
     799             : 
     800           0 :     const SwExtraRedlineTbl& extraRedlineTbl = (*this);
     801             : 
     802           0 :     for( sal_uInt16 nCurExtraRedlinePos = 0; nCurExtraRedlinePos < GetSize(); ++nCurExtraRedlinePos )
     803             :     {
     804           0 :         const SwExtraRedline* pExtraRedline = extraRedlineTbl.GetRedline( nCurExtraRedlinePos );
     805             : 
     806           0 :         writer.startElement( "swextraredline" );
     807             :         {
     808           0 :             const SwTableRowRedline*           pTableRowRedline           = dynamic_cast<const SwTableRowRedline*>(pExtraRedline);
     809           0 :             const SwTableCellRedline*          pTableCellRedline          = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
     810           0 :             if (pTableRowRedline)
     811           0 :                 writer.writeFormatAttribute( "extra_redline_type", "%s", BAD_CAST( "table row" ) );
     812           0 :             else if (pTableCellRedline)
     813           0 :                 writer.writeFormatAttribute( "extra_redline_type", "%s", BAD_CAST( "table cell" ) );
     814             :             else
     815           0 :                 writer.writeFormatAttribute( "extra_redline_type", "%s", BAD_CAST( "UNKNOWN" ) );
     816             :         }
     817           0 :         writer.endElement( );    // extra_redline_data
     818             :     }
     819             : 
     820           0 :     writer.endElement( );    // swextraredlinetbl
     821           0 : }
     822             : 
     823             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10