[Libreoffice-commits] .: sw/inc sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Apr 13 06:56:21 PDT 2011


 sw/inc/anchoreddrawobject.hxx   |    4 ++++
 sw/inc/anchoredobject.hxx       |   10 ++++++++++
 sw/source/core/inc/flyfrm.hxx   |    2 ++
 sw/source/core/text/xmldump.cxx |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+)

New commits:
commit 254f05fd2eb56426bdae4ba380609092fd2d5942
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Wed Apr 13 15:54:06 2011 +0200

    layout dumper: dump anchored objects too

diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx
index ae3a3b1..85e3911 100644
--- a/sw/inc/anchoreddrawobject.hxx
+++ b/sw/inc/anchoreddrawobject.hxx
@@ -193,6 +193,10 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
 
         // new Loop control
         void ValidateThis() { mbValidPos = true; }
+
+        /** The element name to show in the XML dump.
+          */
+        virtual const char* getElementName( ) { return "SwAnchoredDrawObject"; }
 };
 
 #endif
diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index 286561b..1d6167d 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -31,6 +31,7 @@
 #include <tools/rtti.hxx>
 #include <swtypes.hxx>
 #include <swrect.hxx>
+#include <libxml/xmlwriter.h>
 
 class SdrObject;
 class SwFrm;
@@ -551,6 +552,15 @@ class SW_DLLPUBLIC SwAnchoredObject
             @return Point - determined relative position
         */
         Point GetRelPosToLine() const;
+
+        /** Dump a bunch of useful data to an XML representation to ease
+            layout understanding, debugging and testing.
+          */
+        virtual void dumpAsXml( xmlTextWriterPtr pWriter );
+
+        /** The element name to show in the XML dump.
+          */
+        virtual const char* getElementName( ) { return "SwAnchoredObject"; }
 };
 
 // ============================================================================
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 1cdd817..4c2fb0d 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -282,6 +282,8 @@ public:
     // 'SwFlyFrmFmt *' after calls to this function. The casting is now done in this function.)
     virtual const SwFlyFrmFmt *GetFmt() const;
     virtual       SwFlyFrmFmt *GetFmt();
+
+    virtual void dumpAsXml( xmlTextWriterPtr writer ) { SwLayoutFrm::dumpAsXml( writer ); };
 };
 #endif
 
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 29e0b86..f91fbbc 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -35,6 +35,8 @@
 #include "porlin.hxx"
 #include "porlay.hxx"
 #include "portxt.hxx"
+#include "sortedobjs.hxx"
+#include <anchoredobject.hxx>
 #include <libxml/xmlwriter.h>
 #include <SwPortionHandler.hxx>
 
@@ -283,6 +285,22 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer )
 
         dumpAsXmlAttributes( writer );
 
+        // Dump Anchored objects if any
+        SwSortedObjs* pAnchored = GetDrawObjs();
+        if ( pAnchored && pAnchored->Count( ) > 0 )
+        {
+            xmlTextWriterStartElement( writer, BAD_CAST( "anchored" ) );
+
+            for ( sal_uInt32 i = 0, len = pAnchored->Count(); i < len; i++ )
+            {
+                SwAnchoredObject* pObject = (*pAnchored)[i];
+                pObject->dumpAsXml( writer );
+            }
+
+            xmlTextWriterEndElement( writer );
+        }
+
+        // Dump the children
         if ( IsTxtFrm(  ) )
         {
             SwTxtFrm *pTxtFrm = ( SwTxtFrm * ) this;
@@ -328,6 +346,21 @@ void SwFrm::dumpChildrenAsXml( xmlTextWriterPtr writer )
     }
 }
 
+void SwAnchoredObject::dumpAsXml( xmlTextWriterPtr writer )
+{
+    bool bCreateWriter = ( NULL == writer );
+    if ( bCreateWriter )
+        writer = lcl_createDefaultWriter();
+
+    xmlTextWriterStartElement( writer, BAD_CAST( getElementName() ) );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
+    xmlTextWriterEndElement( writer );
+
+
+    if ( bCreateWriter )
+        lcl_freeWriter( writer );
+}
+
 void SwTxtFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
     SwFrm::dumpAsXmlAttributes( writer );


More information about the Libreoffice-commits mailing list