diff options
-rw-r--r-- | sw/source/core/inc/bodyfrm.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/frame.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/layout/pagechg.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/text/makefile.mk | 1 | ||||
-rw-r--r-- | sw/source/core/text/porlay.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/porlin.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/text/portxt.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/xmldump.cxx | 294 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 19 | ||||
-rw-r--r-- | sw/util/makefile.mk | 15 |
10 files changed, 370 insertions, 4 deletions
diff --git a/sw/source/core/inc/bodyfrm.hxx b/sw/source/core/inc/bodyfrm.hxx index 02fe0c88c8..5694c0b118 100644 --- a/sw/source/core/inc/bodyfrm.hxx +++ b/sw/source/core/inc/bodyfrm.hxx @@ -44,6 +44,8 @@ protected: public: SwBodyFrm( SwFrmFmt* ); + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; + DECL_FIXEDMEMPOOL_NEWDEL(SwBodyFrm) }; diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 98436673a9..14cea936f2 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -33,6 +33,11 @@ #include "swrect.hxx" #include "calbck.hxx" // fuer SwClient +#if OSL_DEBUG_LEVEL > 1 +#include <libxml/encoding.h> +#include <libxml/xmlwriter.h> +#endif + class SwLayoutFrm; class SwRootFrm; class SwPageFrm; @@ -915,6 +920,10 @@ public: void ValidateThisAndAllLowers( const USHORT nStage ); public: +#if OSL_DEBUG_LEVEL > 1 + virtual void dumpAsXml(xmlTextWriterPtr writer); + void dumpChildrenAsXml(xmlTextWriterPtr writer); +#endif bool IsCollapse() const; }; diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index bf1ff812f7..ab5e523a58 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -189,6 +189,23 @@ void SwBodyFrm::Format( const SwBorderAttrs * ) bValidSize = bValidPrtArea = TRUE; } +void SwBodyFrm::Paint( const SwRect& rRect, const SwPrtOptions* ) const +{ +#if OSL_DEBUG_LAYOUT > 1 + fprintf( stderr, "SwBodyFrm::Paint()\n" ); +#endif + ViewShell *pSh = GetShell(); + OutputDevice* pOut = pSh->GetOut(); + pOut->Push(); + pOut->SetLineColor(Color(255, 0, 0)); + pOut->SetFillColor(COL_TRANSPARENT); + SwRect aRect(Frm().Left()+5, Frm().Top()+5, Frm().Width()-5, Frm().Height()-5); +// SwRect aRect = Frm(); + pOut->DrawRect(aRect.SVRect()); + pOut->Pop(); + SwLayoutFrm::Paint(rRect); +} + /************************************************************************* |* |* SwPageFrm::SwPageFrm(), ~SwPageFrm() diff --git a/sw/source/core/text/makefile.mk b/sw/source/core/text/makefile.mk index f7786a5a6b..8b943a82da 100644 --- a/sw/source/core/text/makefile.mk +++ b/sw/source/core/text/makefile.mk @@ -91,6 +91,7 @@ SLOFILES = \ .IF "$(DBG_LEVEL)">="2" SLOFILES += \ + $(SLO)$/xmldump.obj \ $(SLO)$/txtio.obj .ENDIF diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index c66852273c..5a90ac88c6 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -259,6 +259,8 @@ public: #if OSL_DEBUG_LEVEL > 1 void DebugPortions( SvStream &rOs, const XubString &rTxt, const xub_StrLen nStart ); //$ ostream + + void dumpLineAsXml(xmlTextWriter* writer, USHORT& ofs, String& aText); #endif OUTPUT_OPERATOR @@ -368,6 +370,10 @@ public: const SwDropPortion *FindDropPortion() const; +#if OSL_DEBUG_LEVEL > 1 + void dumpAsXml( xmlTextWriter* writer, SwTxtFrm* pTxtFrm ); +#endif + OUTPUT_OPERATOR DECL_FIXEDMEMPOOL_NEWDEL(SwParaPortion) }; diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx index 489ea594f2..a3ff1b40fe 100644 --- a/sw/source/core/text/porlin.hxx +++ b/sw/source/core/text/porlin.hxx @@ -30,6 +30,10 @@ #include "possiz.hxx" // SwPosSize +#if OSL_DEBUG_LEVEL > 1 +#include <libxml/xmlwriter.h> +#endif + class XubString; class SwTxtSizeInfo; class SwTxtPaintInfo; @@ -196,6 +200,9 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const; +#if OSL_DEBUG_LEVEL > 1 + void dumpPortionAsXml(USHORT 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 43ed29d7fc..2715c67356 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -67,6 +67,10 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const; +#if OSL_DEBUG_LEVEL > 1 + void dumpPortionAsXml(USHORT 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 new file mode 100644 index 0000000000..caa9dff467 --- /dev/null +++ b/sw/source/core/text/xmldump.cxx @@ -0,0 +1,294 @@ +/* + * 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): Florian Reuter <freuter@novell.com> + * Cedric Bosdonnat <cbosdonnat@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 "precompiled_sw.hxx" + +#include "frame.hxx" +#include "txtfrm.hxx" +#include "porlin.hxx" +#include "porlay.hxx" +#include "portxt.hxx" +#include <SwPortionHandler.hxx> + + + +class XmlPortionDumper:public SwPortionHandler +{ + private: + xmlTextWriterPtr writer; + USHORT ofs; + public: + + XmlPortionDumper( xmlTextWriterPtr some_writer ):writer( some_writer ), ofs( 0 ) + { + } + + virtual ~ XmlPortionDumper( ) + { + } + + /** + @param nLength + length of this portion in the model string + @param rText + text which is painted on-screen + */ + virtual void Text( USHORT nLength, + USHORT nType ) + { + ofs += nLength; + xmlTextWriterStartElement( writer, BAD_CAST( "Text" ) ); + xmlTextWriterWriteFormatAttribute( writer, + BAD_CAST( "nLength" ), + "%i", ( int ) nLength ); + xmlTextWriterWriteFormatAttribute( writer, + BAD_CAST( "nType" ), + "%i", ( int ) nType ); + xmlTextWriterEndElement( writer ); + } + + /** + @param nLength + length of this portion in the model string + @param rText + text which is painted on-screen + @param nType + type of this portion + */ + virtual void Special( USHORT nLength, + const String & rText, + USHORT nType ) + { + xmlTextWriterStartElement( writer, BAD_CAST( "Special" ) ); + xmlTextWriterWriteFormatAttribute( writer, + BAD_CAST( "nLength" ), + "%i", ( int ) nLength ); + xmlTextWriterWriteFormatAttribute( writer, + BAD_CAST( "nType" ), + "%i", ( int ) nType ); + rtl::OUString sText( rText ); + rtl::OString sText8 =::rtl::OUStringToOString( sText, + RTL_TEXTENCODING_UTF8 ); + xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "rText" ), + "%s", sText8.getStr( ) ); + + xmlTextWriterEndElement( writer ); + ofs += nLength; + } + + virtual void LineBreak( ) + { + xmlTextWriterStartElement( writer, BAD_CAST( "LineBreak" ) ); + xmlTextWriterEndElement( writer ); + } + + /** + * @param nLength + * number of 'model string' characters to be skipped + */ + virtual void Skip( USHORT nLength ) + { + xmlTextWriterStartElement( writer, BAD_CAST( "Skip" ) ); + xmlTextWriterWriteFormatAttribute( writer, + BAD_CAST( "nLength" ), + "%i", ( int ) nLength ); + xmlTextWriterEndElement( writer ); + ofs += nLength; + } + + virtual void Finish( ) + { + xmlTextWriterStartElement( writer, BAD_CAST( "Finish" ) ); + xmlTextWriterEndElement( writer ); + } + +}; + + +void SwTxtPortion::dumpPortionAsXml( xub_StrLen ofs, XubString & /*aText */, + xmlTextWriterPtr writer ) +{ + 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 ) + { + portion->dumpPortionAsXml( ofs, aText, writer ); + ofs += portion->GetLen( ); + portion = portion->GetPortion( ); + } + xmlTextWriterEndElement( writer ); +} + + +void SwParaPortion::dumpAsXml( xmlTextWriterPtr writer, SwTxtFrm * pTxtFrm ) +{ + xmlTextWriterStartElement( writer, BAD_CAST( "SwParaPortion" ) ); + SwParaPortion *pPara = this; + + if ( pPara && pTxtFrm ) + { + 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( ); + } + } + xmlTextWriterEndElement( writer ); +} + + +void SwFrm::dumpAsXml( xmlTextWriterPtr writer ) +{ + const char *name = NULL; + + switch ( GetType( ) ) + { + case FRM_ROOT: + name = "root"; + break; + case FRM_PAGE: + name = "page"; + break; + case FRM_COLUMN: + name = "column"; + break; + case FRM_HEADER: + name = "header"; + break; + case FRM_FOOTER: + name = "footer"; + break; + case FRM_FTNCONT: + name = "ftncont"; + break; + case FRM_FTN: + name = "ftn"; + break; + case FRM_BODY: + name = "body"; + break; + case FRM_FLY: + name = "fly"; + break; + case FRM_SECTION: + name = "section"; + break; + case FRM_UNUSED: + name = "unused"; + break; + case FRM_TAB: + name = "tab"; + break; + case FRM_ROW: + name = "row"; + break; + case FRM_CELL: + name = "cell"; + break; + case FRM_TXT: + name = "txt"; + break; + case FRM_NOTXT: + name = "txt"; + break; + }; + + if ( name != NULL ) + { + xmlTextWriterStartElement( writer, ( const xmlChar * ) name ); + if ( IsTxtFrm( ) ) + { + SwTxtFrm *pTxtFrm = ( SwTxtFrm * ) this; + rtl::OUString aTxt = pTxtFrm->GetTxt( ); + for ( int i = 0; i < 32; i++ ) + { + aTxt = aTxt.replace( i, '*' ); + } + rtl::OString aTxt8 =::rtl::OUStringToOString( aTxt, + RTL_TEXTENCODING_UTF8 ); + xmlTextWriterWriteString( writer, + ( const xmlChar * ) aTxt8.getStr( ) ); + XmlPortionDumper pdumper( writer ); + pTxtFrm->VisitPortions( pdumper ); + + } + else + { + dumpChildrenAsXml( writer ); + } + xmlTextWriterEndElement( writer ); + } +} + +void SwFrm::dumpChildrenAsXml( xmlTextWriterPtr writer ) +{ + SwFrm *pFrm = GetLower( ); + for ( ; pFrm != NULL; pFrm = pFrm->GetNext( ) ) + { + pFrm->dumpAsXml( writer ); + } +} diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index bf184f7ca5..2213afb0d6 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -140,6 +140,8 @@ #include <PostItMgr.hxx> +#include "../../core/inc/rootfrm.hxx" + using namespace sw::mark; using namespace ::com::sun::star; @@ -1335,6 +1337,23 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) BOOL bChkInsBlank = pQuickHlpData->bChkInsBlank; pQuickHlpData->bChkInsBlank = FALSE; +#if OSL_DEBUG_LEVEL > 1 + 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); + } + return; + } +#endif + KeyEvent aKeyEvent( rKEvt ); // look for vertical mappings if( !bIsDocReadOnly && !rSh.IsSelFrmMode() && !rSh.IsObjSelected() ) diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 4088abeae7..9b07ba1df6 100644 --- a/sw/util/makefile.mk +++ b/sw/util/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -114,14 +114,16 @@ SHL1STDLIBS+= \ $(UCBHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ - \ $(SALLIB) \ $(SALHELPERLIB) \ $(ICUUCLIB) \ - $(I18NUTILLIB) -SHL1STDLIBS+= \ + $(I18NUTILLIB) \ $(AVMEDIALIB) +.IF "$(DBG_LEVEL)">="2" +SHL1STDLIBS+= $(LIBXML2LIB) +.ENDIF + .IF "$(GUI)"=="WNT" SHL1STDLIBS+= $(ADVAPI32LIB) .ENDIF # WNT @@ -160,6 +162,8 @@ SHL2OBJS= $(SLO)$/swdetect.obj \ .IF "$(DBG_LEVEL)">="2" SHL2OBJS+= \ $(SLO)$/errhdl.obj +SHL2STDLIBS+= \ + $(LIBXML2LIB) .ENDIF SHL2DEPN+= makefile.mk @@ -192,6 +196,9 @@ SHL3STDLIBS= \ $(CPPULIB) \ $(SALLIB) \ $(SOTLIB) +.IF "$(DBG_LEVEL)">="2" +SHL3STDLIBS+= $(LIBXML2LIB) +.ENDIF SHL3LIBS= $(SLB)$/swui.lib LIB3TARGET = $(SLB)$/swui.lib |