diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-04-01 15:14:14 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-04-06 22:32:33 +0200 |
commit | c7abb549be89f71505e3daf0bc03f55565c7d150 (patch) | |
tree | 583ff070aa00a4e9753283d3e46f6aa510a2626a /sw | |
parent | 763da667935a1f2955076cc6c326771ceb0c4cbb (diff) |
sw: move all layout dumping in the SwFrm::dumpAsXml to allow calls from gdb
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/frame.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/porlin.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/text/portxt.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/xmldump.cxx | 79 | ||||
-rw-r--r-- | sw/source/core/undo/SwUndoPageDesc.cxx | 20 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 10 |
7 files changed, 22 insertions, 100 deletions
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 8252a8d68f63..f8504ec01700 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 08f756d65b87..54f1e664f5a8 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 a4f887113173..d9b44dd7cee2 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 8a201cf1f87e..7f9d12efd32a 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 3209fbadac52..949ffc485d1c 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 2b6494003109..54d494565e57 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 c78cedad805c..5e07e75afd8d 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 |