[Libreoffice-commits] core.git: 2 commits - include/test sw/inc sw/qa sw/source test/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Dec 19 00:05:32 PST 2014


 include/test/mtfxmldump.hxx         |    4 ++--
 sw/inc/fmtcntnt.hxx                 |    2 ++
 sw/qa/extras/uiwriter/uiwriter.cxx  |    2 +-
 sw/source/core/docnode/nodedump.cxx |   10 +++-------
 sw/source/core/layout/atrfrm.cxx    |    8 ++++++++
 test/source/mtfxmldump.cxx          |    7 ++++---
 6 files changed, 20 insertions(+), 13 deletions(-)

New commits:
commit 9071c5070cbcf6bba00285cdd9b062e961a10287
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 19 09:04:41 2014 +0100

    Factor out SwFmtCntnt::dumpAsXml() from nodedump
    
    Change-Id: I6adcaa8534efefa474d489125d3fb95f150e3e89

diff --git a/sw/inc/fmtcntnt.hxx b/sw/inc/fmtcntnt.hxx
index c4efe4f..a33b545 100644
--- a/sw/inc/fmtcntnt.hxx
+++ b/sw/inc/fmtcntnt.hxx
@@ -44,6 +44,8 @@ public:
 
     const SwNodeIndex *GetCntntIdx() const { return pStartNode; }
     void SetNewCntntIdx( const SwNodeIndex *pIdx );
+
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 inline const SwFmtCntnt &SwAttrSet::GetCntnt(bool bInP) const
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index f6cd7f8..c0cda75 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -423,6 +423,9 @@ void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
             case RES_CHRATR_FONTSIZE:
                 static_cast<const SvxFontHeightItem*>(pItem)->dumpAsXml(writer);
                 break;
+            case RES_CNTNT:
+                static_cast<const SwFmtCntnt*>(pItem)->dumpAsXml(writer);
+                break;
             default: bDone = false; break;
         }
         if (bDone)
@@ -437,13 +440,6 @@ void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
         boost::optional<OString> oValue;
         switch (pItem->Which())
         {
-            case RES_CNTNT:
-            {
-                pWhich = "content";
-                const SwFmtCntnt* pCntnt = static_cast<const SwFmtCntnt*>(pItem);
-                oValue = "node index: " + OString::number(pCntnt->GetCntntIdx()->GetNode().GetIndex());
-                break;
-            }
             case RES_FRM_SIZE:
             {
                 pWhich = "frame size";
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 43f6666..dbf0caa 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -555,6 +555,14 @@ SfxPoolItem*  SwFmtCntnt::Clone( SfxItemPool* ) const
     return new SwFmtCntnt( *this );
 }
 
+void SwFmtCntnt::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swFmtCntnt"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startNode"), BAD_CAST(OString::number(pStartNode->GetNode().GetIndex()).getStr()));
+    xmlTextWriterEndElement(pWriter);
+}
+
 // Partially implemented inline in hxx
 SwFmtPageDesc::SwFmtPageDesc( const SwFmtPageDesc &rCpy )
     : SfxPoolItem( RES_PAGEDESC ),
commit 93bb2101197c1ff64a5cc3ab9ffa64f66c0d9641
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 19 09:04:31 2014 +0100

    Let MetafileXmlDump::dumpAndParse() take a const GDIMetaFile
    
    So the const_cast<> in CppunitTest_sw_uiwriter can go away.
    
    Change-Id: Id7d4234154cd6bed43cb5270b50208061038dcf7

diff --git a/include/test/mtfxmldump.hxx b/include/test/mtfxmldump.hxx
index 997d023..5c21765 100644
--- a/include/test/mtfxmldump.hxx
+++ b/include/test/mtfxmldump.hxx
@@ -23,7 +23,7 @@ class OOO_DLLPUBLIC_TEST MetafileXmlDump
 {
     std::vector<bool> maFilter;
 
-    void writeXml(GDIMetaFile& rMetaFile, XmlWriter& rWriter);
+    void writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter);
 
 public:
     MetafileXmlDump();
@@ -39,7 +39,7 @@ public:
         pTempStreamName - this is useful when creating the test, to dump the
         file for examination.
     */
-    xmlDocPtr dumpAndParse(GDIMetaFile& rMetaFile, const OUString& rTempStreamName = OUString());
+    xmlDocPtr dumpAndParse(const GDIMetaFile& rMetaFile, const OUString& rTempStreamName = OUString());
 };
 
 #endif
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8073a43..0813dec 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -789,7 +789,7 @@ void SwUiWriterTest::testFdo87448()
     ReadGraphic(aStream, aGraphic);
     const GDIMetaFile& rMetaFile = aGraphic.GetGDIMetaFile();
     MetafileXmlDump dumper;
-    xmlDocPtr pXmlDoc = dumper.dumpAndParse(const_cast<GDIMetaFile&>(rMetaFile));
+    xmlDocPtr pXmlDoc = dumper.dumpAndParse(rMetaFile);
 
     // The first polyline in the document has a number of points to draw arcs,
     // the last one jumps back to the start, so we call "end" the last but one.
diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx
index 43098d0..ee89658 100644
--- a/test/source/mtfxmldump.cxx
+++ b/test/source/mtfxmldump.cxx
@@ -231,7 +231,7 @@ void MetafileXmlDump::filterAllActionTypes()
     maFilter.assign(constMaxActionType, true);
 }
 
-xmlDocPtr MetafileXmlDump::dumpAndParse(GDIMetaFile& rMetaFile, const OUString& rTempStreamName)
+xmlDocPtr MetafileXmlDump::dumpAndParse(const GDIMetaFile& rMetaFile, const OUString& rTempStreamName)
 {
     boost::scoped_ptr<SvStream> pStream;
 
@@ -256,10 +256,11 @@ xmlDocPtr MetafileXmlDump::dumpAndParse(GDIMetaFile& rMetaFile, const OUString&
     return pDoc;
 }
 
-void MetafileXmlDump::writeXml(GDIMetaFile& rMetaFile, XmlWriter& rWriter)
+void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter)
 {
-    for(MetaAction* pAction = rMetaFile.FirstAction(); pAction != NULL; pAction = rMetaFile.NextAction())
+    for(size_t nAction = 0; nAction < rMetaFile.GetActionSize(); ++nAction)
     {
+        MetaAction* pAction = rMetaFile.GetAction(nAction);
         const sal_uInt16 nActionType = pAction->GetType();
         if (maFilter[nActionType])
             continue;


More information about the Libreoffice-commits mailing list