[Libreoffice-commits] .: 2 commits - sw/Library_sw.mk sw/source sw/util

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Apr 6 13:33:27 PDT 2011


 sw/Library_sw.mk                       |    1 
 sw/source/core/inc/dumpfilter.hxx      |   87 +++++++++++++
 sw/source/core/inc/frame.hxx           |    4 
 sw/source/core/layout/dumpfilter.cxx   |  208 +++++++++++++++++++++++++++++++++
 sw/source/core/layout/tabfrm.cxx       |    2 
 sw/source/core/text/porlin.hxx         |    3 
 sw/source/core/text/portxt.hxx         |    4 
 sw/source/core/text/xmldump.cxx        |   83 ++-----------
 sw/source/core/undo/SwUndoPageDesc.cxx |   20 ---
 sw/source/ui/docvw/edtwin.cxx          |   10 -
 sw/source/ui/uno/unofreg.cxx           |   17 ++
 sw/util/sw.component                   |    7 -
 12 files changed, 336 insertions(+), 110 deletions(-)

New commits:
commit 2ef2ae4fd058cfb51f9a07da7d7dc3d0db55503f
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Wed Apr 6 17:09:08 2011 +0200

    sw: create a layout dump filter to ease testing

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1ccedbd..6ebc1d5 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -282,6 +282,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/layout/calcmove \
     sw/source/core/layout/colfrm \
     sw/source/core/layout/dbg_lay \
+    sw/source/core/layout/dumpfilter \
     sw/source/core/layout/findfrm \
     sw/source/core/layout/flowfrm \
     sw/source/core/layout/fly \
diff --git a/sw/source/core/inc/dumpfilter.hxx b/sw/source/core/inc/dumpfilter.hxx
new file mode 100644
index 0000000..b2472c4
--- /dev/null
+++ b/sw/source/core/inc/dumpfilter.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Cedric Bosdonnat <cbosdonnat at novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef _LAYOUTDUMP_HXX
+#define _LAYOUTDUMP_HXX
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+namespace sw {
+
+    /** Implementation of UNO export service to dump the layout of the
+        document as XML. This filter should be mostly be used for testing
+        purpose.
+      */
+    class LayoutDumpFilter : public cppu::WeakImplHelper4
+                             <
+                               com::sun::star::document::XFilter,
+                               com::sun::star::document::XExporter,
+                               com::sun::star::lang::XInitialization,
+                               com::sun::star::lang::XServiceInfo
+                             >
+    {
+    protected:
+        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xSrcDoc;
+
+
+    public:
+       LayoutDumpFilter();
+       virtual ~LayoutDumpFilter();
+
+        // XFilter
+        virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+            throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL cancel(  )
+            throw (::com::sun::star::uno::RuntimeException);
+
+        // XExporter
+        virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+            throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+        // XInitialization
+        virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+            throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+        // XServiceInfo
+        virtual ::rtl::OUString SAL_CALL getImplementationName(  )
+            throw (::com::sun::star::uno::RuntimeException);
+        virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+            throw (::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+            throw (::com::sun::star::uno::RuntimeException);
+
+    };
+} // Namespace sw
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/dumpfilter.cxx b/sw/source/core/layout/dumpfilter.cxx
new file mode 100644
index 0000000..391da67
--- /dev/null
+++ b/sw/source/core/layout/dumpfilter.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Cedric Bosdonnat <cbosdonnat at novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "dumpfilter.hxx"
+
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <rootfrm.hxx>
+#include <unotxdoc.hxx>
+#include <unobaseclass.hxx>
+#include <cppuhelper/weak.hxx>
+#include <vcl/svapp.hxx>
+
+#include <comphelper/mediadescriptor.hxx>
+
+using namespace ::com::sun::star;
+
+::rtl::OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw( uno::RuntimeException )
+{
+    return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Writer.LayoutDump" ) );
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw( uno::RuntimeException )
+{
+    uno::Sequence< rtl::OUString > aSeq( 1 );
+    aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) );
+    return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance(
+                const uno::Reference< lang::XMultiServiceFactory > & )
+{
+    return static_cast< cppu::OWeakObject* >( new sw::LayoutDumpFilter( ) );
+}
+
+namespace
+{
+    int writeCallback( void* pContext, const char* sBuffer, int nLen )
+    {
+        int written = nLen;
+
+        // Actually write bytes to XOutputSream
+        try
+        {
+            uno::XInterface* pObj = ( uno::XInterface* )pContext;
+            uno::Reference< io::XOutputStream > xOut( pObj, uno::UNO_QUERY_THROW );
+
+            // Don't output the terminating \0 to the xml or the file will be invalid
+            uno::Sequence< sal_Int8 > seq( nLen );
+            strncpy( ( char * ) seq.getArray() , sBuffer, nLen );
+            xOut->writeBytes( seq );
+        }
+        catch ( uno::Exception )
+        {
+            written = -1;
+        }
+
+        return written;
+    }
+
+    int closeCallback( void* pContext )
+    {
+        int result = 0;
+        try
+        {
+            uno::XInterface* pObj = ( uno::XInterface* )pContext;
+            uno::Reference< io::XOutputStream > xOut( pObj, uno::UNO_QUERY_THROW );
+            xOut->closeOutput( );
+        }
+        catch ( uno::Exception )
+        {
+            result = -1;
+        }
+        return result;
+    }
+}
+
+namespace sw
+{
+
+    LayoutDumpFilter::LayoutDumpFilter( )
+    {
+    }
+
+    LayoutDumpFilter::~LayoutDumpFilter( )
+    {
+    }
+
+    // XFilter
+    sal_Bool LayoutDumpFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
+        throw (uno::RuntimeException)
+    {
+        sal_Bool bRet = sal_False;
+
+        comphelper::MediaDescriptor aMediaDesc = aDescriptor;
+
+        // Get the output stream
+        uno::Reference< io::XOutputStream > xOut = aMediaDesc.getUnpackedValueOrDefault(
+                comphelper::MediaDescriptor::PROP_OUTPUTSTREAM(),
+                uno::Reference< io::XOutputStream >() );
+
+        // Actually get the SwRootFrm to call dumpAsXml
+        uno::Reference< lang::XUnoTunnel > xDocTunnel( m_xSrcDoc, uno::UNO_QUERY );
+        SwXTextDocument* pXDoc = UnoTunnelGetImplementation< SwXTextDocument >( xDocTunnel );
+        if ( pXDoc )
+        {
+            SwRootFrm* pLayout = pXDoc->GetDocShell()->GetWrtShell()->GetLayout();
+
+            // Get sure that the whole layout is processed: set a visible area
+            // even though there isn't any need of it
+            pXDoc->GetDocShell()->GetWrtShell()->StartAction();
+            Rectangle aRect( 0, 0, 26000, 21000 );
+            pXDoc->GetDocShell()->SetVisArea( aRect );
+            pLayout->InvalidateAllCntnt( );
+            pXDoc->GetDocShell()->GetWrtShell()->EndAction();
+
+            // Dump the layout XML into the XOutputStream
+            xmlOutputBufferPtr outBuffer = xmlOutputBufferCreateIO(
+                    writeCallback, closeCallback, ( void* ) xOut.get(), NULL );
+
+            xmlTextWriterPtr writer = xmlNewTextWriter( outBuffer );
+            xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
+
+            // TODO This doesn't export the whole XML file, whereas dumpAsXML() does it nicely
+            pLayout->dumpAsXml( writer );
+
+            xmlTextWriterEndDocument( writer );
+            xmlFreeTextWriter( writer );
+
+            bRet = sal_True;
+        }
+
+        return bRet;
+    }
+
+    void LayoutDumpFilter::cancel(  ) throw (uno::RuntimeException)
+    {
+    }
+
+    // XExporter
+    void LayoutDumpFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
+        throw (lang::IllegalArgumentException, uno::RuntimeException)
+    {
+        m_xSrcDoc = xDoc;
+    }
+
+    // XInitialization
+    void LayoutDumpFilter::initialize( const uno::Sequence< uno::Any >& )
+        throw (uno::Exception, uno::RuntimeException)
+    {
+    }
+
+    // XServiceInfo
+    ::rtl::OUString LayoutDumpFilter::getImplementationName(  )
+        throw (uno::RuntimeException)
+    {
+        return LayoutDumpFilter_getImplementationName();
+    }
+
+    sal_Bool LayoutDumpFilter::supportsService( const ::rtl::OUString& rServiceName )
+        throw (uno::RuntimeException)
+    {
+        uno::Sequence< rtl::OUString > seqServiceNames = getSupportedServiceNames();
+        const rtl::OUString* pArray = seqServiceNames.getConstArray();
+        for ( sal_Int32 nCounter=0; nCounter < seqServiceNames.getLength(); nCounter++ )
+        {
+            if ( pArray[nCounter] == rServiceName )
+            {
+                return sal_True ;
+            }
+        }
+        return sal_False ;
+    }
+
+    uno::Sequence< ::rtl::OUString > LayoutDumpFilter::getSupportedServiceNames()
+        throw (uno::RuntimeException)
+    {
+        return LayoutDumpFilter_getSupportedServiceNames();
+    }
+
+} // Namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 949ffc4..4152901 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -128,21 +128,19 @@ class XmlPortionDumper:public SwPortionHandler
 
 };
 
-#if OSL_DEBUG_LEVEL > 1
-
 namespace
 {
     xmlTextWriterPtr lcl_createDefaultWriter()
     {
         xmlTextWriterPtr writer = xmlNewTextWriterFilename( "layout.xml", 0 );
-        xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
+        xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
         return writer;
     }
 
     void lcl_freeWriter( xmlTextWriterPtr writer )
     {
-       xmlTextWriterEndDocument(writer);
-       xmlFreeTextWriter( writer );
+        xmlTextWriterEndDocument( writer );
+        xmlFreeTextWriter( writer );
     }
 }
 
@@ -264,6 +262,4 @@ void SwTxtFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
         xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%p", GetFollow() );
 }
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unofreg.cxx b/sw/source/ui/uno/unofreg.cxx
index 2382a65..c6fc4d9 100644
--- a/sw/source/ui/uno/unofreg.cxx
+++ b/sw/source/ui/uno/unofreg.cxx
@@ -130,7 +130,12 @@ extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames(
 extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
 extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
 
-// --> OD 2007-05-24 #i73788#
+// Layout dump filter
+extern uno::Sequence< OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw();
+extern OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// #i73788#
 #include "cppuhelper/implementationentry.hxx"
 namespace comp_FinalThreadManager {
 
@@ -141,9 +146,7 @@ com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL _crea
     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context );
 
 }
-// <--
 
-//
 #ifdef __cplusplus
 extern "C"
 {
@@ -362,6 +365,14 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
                 SwUnoModule_createInstance,
                 SwUnoModule_getSupportedServiceNames() );
         }
+        else if( LayoutDumpFilter_getImplementationName().equalsAsciiL(
+                                                    pImplName, nImplNameLen ) )
+        {
+            xFactory = ::cppu::createSingleFactory( xMSF,
+                LayoutDumpFilter_getImplementationName(),
+                LayoutDumpFilter_createInstance,
+                LayoutDumpFilter_getSupportedServiceNames() );
+        }
         else if( comp_FinalThreadManager::_getImplementationName().equalsAsciiL(
                                                     pImplName, nImplNameLen ) )
         {
diff --git a/sw/util/sw.component b/sw/util/sw.component
index e76cec6..7f73777 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -25,9 +25,7 @@
 * for a copy of the LGPLv3 License.
 *
 **********************************************************************-->
-
-<component loader="com.sun.star.loader.SharedLibrary"
-    xmlns="http://openoffice.org/2010/uno-components">
+<component xmlns="http://openoffice.org/2010/uno-components" loader="com.sun.star.loader.SharedLibrary">
   <implementation name="SwXAutoTextContainer">
     <service name="com.sun.star.text.AutoTextContainer"/>
   </implementation>
@@ -101,4 +99,7 @@
   <implementation name="com.sun.star.util.comp.FinalThreadManager">
     <service name="com.sun.star.util.JobManager"/>
   </implementation>
+  <implementation name="com.sun.star.comp.Writer.LayoutDump">
+    <service name="com.sun.star.comp.Writer.LayoutDump"/>
+  </implementation>
 </component>
commit 16431d950e573101ff8eb31c054346422d18c516
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Fri Apr 1 15:14:14 2011 +0200

    sw: move all layout dumping in the SwFrm::dumpAsXml to allow calls from gdb

diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index c4e0977..88d9b13 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -906,7 +906,9 @@ public:
 
 public:
 #if OSL_DEBUG_LEVEL > 1
-    virtual void dumpAsXml(xmlTextWriterPtr writer);
+    /** if writer is NULL, dumps the layout structure as XML in layout.xml
+      */
+    virtual void dumpAsXml(xmlTextWriterPtr writer = NULL );
     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer);
     void dumpChildrenAsXml(xmlTextWriterPtr writer);
 #endif
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 93cbfc3..aaa73ca 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1568,7 +1568,7 @@ bool SwCntntFrm::CalcLowers( SwLayoutFrm* pLay, const SwLayoutFrm* pDontLeave,
                     }
 
 #if OSL_DEBUG_LEVEL > 1
-                    OSL_FAIL( "LoopControl in SwCntntFrm::CalcLowers" )
+                    OSL_FAIL( "LoopControl in SwCntntFrm::CalcLowers" );
 #endif
                 }
             }
diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx
index 8d9693f..6a45c56 100644
--- a/sw/source/core/text/porlin.hxx
+++ b/sw/source/core/text/porlin.hxx
@@ -200,9 +200,6 @@ public:
     // Accessibility: pass information about this portion to the PortionHandler
     virtual void HandlePortion( SwPortionHandler& rPH ) const;
 
-#if OSL_DEBUG_LEVEL > 1
-    void dumpPortionAsXml(sal_uInt16 ofs, String& aText, xmlTextWriter* writer);
-#endif
     OUTPUT_OPERATOR
 };
 
diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx
index 5fe9a93..43ed29d 100644
--- a/sw/source/core/text/portxt.hxx
+++ b/sw/source/core/text/portxt.hxx
@@ -67,10 +67,6 @@ public:
     // Accessibility: pass information about this portion to the PortionHandler
     virtual void HandlePortion( SwPortionHandler& rPH ) const;
 
-#if OSL_DEBUG_LEVEL > 1
-    void dumpPortionAsXml(sal_uInt16 ofs, String& aText, xmlTextWriter* writer);
-#endif
-
     OUTPUT_OPERATOR
     DECL_FIXEDMEMPOOL_NEWDEL(SwTxtPortion)
 };
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 3209fba..949ffc4 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -130,80 +130,28 @@ class XmlPortionDumper:public SwPortionHandler
 
 #if OSL_DEBUG_LEVEL > 1
 
-void SwTxtPortion::dumpPortionAsXml( xub_StrLen ofs, XubString & /*aText */,
-                                     xmlTextWriterPtr writer )
+namespace
 {
-    xmlTextWriterStartElement( writer, BAD_CAST( "SwTxtPortion" ) );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ofs" ), "%i", ofs );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "len" ), "%i",
-                                       ( int ) this->GetLen(  ) );
-
-    xmlTextWriterEndElement( writer );
-}
-
-void SwLinePortion::dumpPortionAsXml( xub_StrLen ofs, XubString & /*aText */,
-                                      xmlTextWriterPtr writer )
-{
-    xmlTextWriterStartElement( writer, BAD_CAST( "SwLinePortion" ) );
-    xmlTextWriterWriteFormatAttribute( writer,
-                                       BAD_CAST( "nWhichPor" ),
-                                       "%04X",
-                                       ( int ) this->GetWhichPor(  ) );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ofs" ), "%i", ofs );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "len" ), "%i",
-                                       ( int ) this->GetLen(  ) );
-    xmlTextWriterEndElement( writer );
-}
-
-void SwLineLayout::dumpLineAsXml( xmlTextWriterPtr writer,
-                                  xub_StrLen & ofs, XubString & aText )
-{                               // not used any longer...
-    xmlTextWriterStartElement( writer, BAD_CAST( "SwLineLayout" ) );
-    SwLinePortion *portion = this;
-    while ( portion != NULL )
+    xmlTextWriterPtr lcl_createDefaultWriter()
     {
-        portion->dumpPortionAsXml( ofs, aText, writer );
-        ofs += portion->GetLen(  );
-        portion = portion->GetPortion(  );
+        xmlTextWriterPtr writer = xmlNewTextWriterFilename( "layout.xml", 0 );
+        xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
+        return writer;
     }
-    xmlTextWriterEndElement( writer );
-}
-
-
-void SwParaPortion::dumpAsXml( xmlTextWriterPtr writer, SwTxtFrm * pTxtFrm )
-{
-    xmlTextWriterStartElement( writer, BAD_CAST( "SwParaPortion" ) );
-    SwParaPortion *pPara = this;
 
-    if ( pPara && pTxtFrm )
+    void lcl_freeWriter( xmlTextWriterPtr writer )
     {
-        xub_StrLen ofs = 0;
-        XubString & aText = ( String & ) pTxtFrm->GetTxt(  );
-        if ( pTxtFrm->IsFollow(  ) )
-            ofs += pTxtFrm->GetOfst(  );
-
-        SwLineLayout *pLine = pPara;
-        while ( pLine )
-        {
-            xmlTextWriterStartElement( writer, BAD_CAST( "line" ) );
-            SwLinePortion *pPor = pLine->GetFirstPortion(  );
-            while ( pPor )
-            {
-                pPor->dumpPortionAsXml( ofs, aText, writer );
-                ofs += pPor->GetLen(  );
-                pPor = pPor->GetPortion(  );
-            }
-
-            xmlTextWriterEndElement( writer );  // line
-            pLine = pLine->GetNext(  );
-        }
+       xmlTextWriterEndDocument(writer);
+       xmlFreeTextWriter( writer );
     }
-    xmlTextWriterEndElement( writer );
 }
 
-
 void SwFrm::dumpAsXml( xmlTextWriterPtr writer )
 {
+    bool bCreateWriter = ( NULL == writer );
+    if ( bCreateWriter )
+        writer = lcl_createDefaultWriter();
+
     const char *name = NULL;
 
     switch ( GetType(  ) )
@@ -286,6 +234,9 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer )
         }
         xmlTextWriterEndElement( writer );
     }
+
+    if ( bCreateWriter )
+        lcl_freeWriter( writer );
 }
 
 void SwFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
index c8f9b0c..cb79448 100644
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
@@ -41,12 +41,12 @@
 #include <fmtcntnt.hxx>
 #include <fmthdft.hxx>
 
-#ifdef DEBUG
+#if OSL_DEBUG_LEVEL > 1
 #include <ndindex.hxx>
 #endif
 
 
-#ifdef DEBUG
+#if OSL_DEBUG_LEVEL > 1
 // Pure debug help function to have a quick look at the header/footer attributes.
 void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
 {
@@ -64,10 +64,6 @@ void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
         SwFrmFmt* pHeaderFmt = rHead.GetHeaderFmt();
         if( pHeaderFmt )
         {
-            nHeaderCount = pHeaderFmt->GetClientCount();
-            {
-                int nHeaderCount = 0;
-            }
             const SwFmtCntnt* pCntnt = &pHeaderFmt->GetCntnt();
             if( pCntnt->GetCntntIdx() )
                 nHeaderMaster = pCntnt->GetCntntIdx()->GetIndex();
@@ -77,10 +73,6 @@ void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
         SwFrmFmt* pLeftHeaderFmt = rLeftHead.GetHeaderFmt();
         if( pLeftHeaderFmt )
         {
-            nLeftHeaderCount = pLeftHeaderFmt->GetClientCount();
-            {
-                int nLeftHeaderCount = 0;
-            }
             const SwFmtCntnt* pLeftCntnt = &pLeftHeaderFmt->GetCntnt();
             if( pLeftCntnt->GetCntntIdx() )
                 nHeaderLeft = pLeftCntnt->GetCntntIdx()->GetIndex();
@@ -93,10 +85,6 @@ void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
         SwFrmFmt* pFooterFmt = rFoot.GetFooterFmt();
         if( pFooterFmt )
         {
-            nFooterCount = pFooterFmt->GetClientCount();
-            {
-                int nFooterCount = 0;
-            }
             const SwFmtCntnt* pCntnt = &pFooterFmt->GetCntnt();
             if( pCntnt->GetCntntIdx() )
                 nFooterMaster = pCntnt->GetCntntIdx()->GetIndex();
@@ -106,10 +94,6 @@ void DebugHeaderFooterContent( const SwPageDesc& rPageDesc )
         SwFrmFmt* pLeftFooterFmt = rLeftFoot.GetFooterFmt();
         if( pLeftFooterFmt )
         {
-            nLeftFooterCount = pLeftFooterFmt->GetClientCount();
-            {
-                int nLeftFooterCount = 0;
-            }
             const SwFmtCntnt* pLeftCntnt = &pLeftFooterFmt->GetCntnt();
             if( pLeftCntnt->GetCntntIdx() )
                 nFooterLeft = pLeftCntnt->GetCntntIdx()->GetIndex();
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 4710481..8bed836 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -1284,15 +1284,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
     if (rKEvt.GetKeyCode().GetCode() == KEY_F12)
     {
         SwRootFrm* pLayout = GetView().GetDocShell()->GetWrtShell()->GetLayout();
-        xmlTextWriterPtr writer = xmlNewTextWriterFilename("layout.xml", 0);
-        if (writer!=NULL)
-        {
-            printf("dumping layout in \"layout.xml\"\n");
-            xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
-            pLayout->dumpAsXml(writer);
-            xmlTextWriterEndDocument(writer);
-            xmlFreeTextWriter(writer);
-        }
+        pLayout->dumpAsXml( );
         return;
     }
 #endif


More information about the Libreoffice-commits mailing list