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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Mar 8 08:09:56 PST 2012


 sw/source/core/inc/frame.hxx    |    3 +-
 sw/source/core/text/frmform.cxx |   49 ----------------------------------------
 sw/source/core/text/txtfly.cxx  |   36 ++++++++++++++---------------
 sw/source/core/text/xmldump.cxx |   44 +++++++++++++++++++++++++----------
 4 files changed, 52 insertions(+), 80 deletions(-)

New commits:
commit 1483c90ddc4a9f47b9a7da2d65da12f3e71cee60
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Mar 8 17:06:29 2012 +0100

    sw: SwTxtFrm formatting, cleaned up useless debug code and translated comments

diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index e417e84..1d1d444 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1772,26 +1772,6 @@ void SwTxtFrm::_Format( SwParaPortion *pPara )
 
 void SwTxtFrm::Format( const SwBorderAttrs * )
 {
-#if OSL_DEBUG_LEVEL > 1
-    const XubString aXXX = GetTxtNode()->GetTxt();
-    const SwTwips nDbgY = Frm().Top();
-    (void)nDbgY;
-    const SwPageFrm *pDbgPage = FindPageFrm();
-    const MSHORT nDbgPageNr = pDbgPage->GetPhyPageNum();
-    (void)nDbgPageNr;
-    // Um zu gucken, ob es einen Ftn-Bereich gibt.
-    const SwFrm *pDbgFtnCont = (const SwFrm*)(FindPageFrm()->FindFtnCont());
-    (void)pDbgFtnCont;
-
-    // nStopAt laesst sich vom CV bearbeiten.
-    static MSHORT nStopAt = 0;
-    if( nStopAt == GetFrmId() )
-    {
-        int i = GetFrmId();
-        (void)i;
-    }
-#endif
-
     SWRECTFN( this )
 
     CalcAdditionalFirstLineOffset();
@@ -1951,35 +1931,8 @@ void SwTxtFrm::Format( const SwBorderAttrs * )
     if ( pPara )
            pPara->SetPrepMustFit( sal_False );
 
-#if OSL_DEBUG_LEVEL > 1
-    // Hier ein Instrumentarium, um ungewoehnlichen Master/Follow-Kombinationen,
-    // insbesondere bei Fussnoten, auf die Schliche zu kommen
-    if( IsFollow() || GetFollow() )
-    {
-        SwTxtFrm *pTmpFrm = IsFollow() ? FindMaster() : this;
-        const SwPageFrm *pTmpPage = pTmpFrm->FindPageFrm();
-        MSHORT nPgNr = pTmpPage->GetPhyPageNum();
-        MSHORT nLast;
-        MSHORT nDummy = 0; // nur zum Breakpoint setzen
-        while( pTmpFrm->GetFollow() )
-        {
-            pTmpFrm = pTmpFrm->GetFollow();
-            nLast = nPgNr;
-            pTmpPage = pTmpFrm->FindPageFrm();
-            nPgNr = pTmpPage->GetPhyPageNum();
-            if( nLast > nPgNr )
-                ++nDummy; // schon fast eine Assertion wert
-            else if( nLast == nPgNr )
-                ++nDummy; // bei Spalten voellig normal, aber sonst!?
-            else if( nLast < nPgNr - 1 )
-                ++nDummy; // kann schon mal temporaer vorkommen
-        }
-    }
-#endif
-
     CalcBaseOfstForFly();
-    // OD 2004-03-17 #i11860#
-    _CalcHeightOfLastLine();
+    _CalcHeightOfLastLine(); // #i11860#
 }
 
 /*************************************************************************
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 0fc70b8..a3b4630 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -2013,16 +2013,16 @@ void SwTxtFly::CalcLeftMargin( SwRect &rFly,
     (rFly.*fnRect->fnSetLeft)( nLeft );
 }
 
-/*************************************************************************
- *                      SwTxtFly::FlyToRect()
- *
- * IN:  dokumentglobal  (rRect)
- * OUT: dokumentglobal  (return-Wert)
- * Liefert zu einem SwFlyFrm das von ihm in Anspruch genommene Rechteck
- * unter Beruecksichtigung der eingestellten Attribute fuer den Abstand
- * zum Text zurueck.
- *************************************************************************/
 // #i68520#
+/**
+  Computes the bounds of an anchored object. This takes the
+  object wrapping and contour into account.
+
+  @param pAnchoredObj the object for which to get the bounds
+  @param rLine the bounds of the line to format
+
+  @return the flying object bounds
+  */
 SwRect SwTxtFly::AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
                             const SwRect &rLine ) const
 {
@@ -2044,15 +2044,15 @@ SwRect SwTxtFly::AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
                                  // des Rahmens waechst.
     SwAnchoredObjList::size_type nFlyPos = GetPos( pAnchoredObj );
 
-    // Bei LEFT und RIGHT vergroessern wir das Rechteck.
-    // Hier gibt es einige Probleme, wenn mehrere Frames zu sehen sind.
-    // Zur Zeit wird nur der einfachste Fall angenommen:
-    // LEFT bedeutet, dass der Text links vom Frame fliessen soll,
-    // d.h. der Frame blaeht sich bis zum rechten Rand der Printarea
-    // oder bis zum naechsten Frame auf.
-    // Bei RIGHT ist es umgekehrt.
-    // Ansonsten wird immer der eingestellte Abstand zwischen Text
-    // und Frame aufaddiert.
+    // LEFT and RIGHT, we grow the rectangle.
+    // We have some problems, when several frames are to be seen.
+    // At the moment, only the easier case is assumed:
+    //  + LEFT means that the text muss flaw on the left of the frame,
+    //    that is that the trame expands to the right edge of the
+    //    print area or to the the next frame.
+    //  + RIGHT is the opposite.
+    // Otherwise the set distance between text and frame is always
+    // added up.
     switch( _GetSurroundForTextWrap( pAnchoredObj ) )
     {
         case SURROUND_LEFT :
commit e500deff4c2bc0d29626684039519a326388a778
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Mar 8 15:53:31 2012 +0100

    sw layout dump: replaced pointers by FrmIds and added frame bounds

diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 742a358..0939c63 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -909,7 +909,8 @@ public:
 public:
     /** if writer is NULL, dumps the layout structure as XML in layout.xml
       */
-    virtual void dumpAsXml(xmlTextWriterPtr writer = NULL );
+    virtual void dumpAsXml(xmlTextWriterPtr writer = NULL);
+    virtual void dumpInfosAsXml(xmlTextWriterPtr writer);
     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer);
     void dumpChildrenAsXml(xmlTextWriterPtr writer);
     bool IsCollapse() const;
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 3530753..3b0bfe4 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -28,6 +28,7 @@
  */
 
 #include "frame.hxx"
+#include "frmfmt.hxx"
 #include "sectfrm.hxx"
 #include "tabfrm.hxx"
 #include "txtfrm.hxx"
@@ -284,6 +285,10 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer )
 
         dumpAsXmlAttributes( writer );
 
+        xmlTextWriterStartElement( writer, BAD_CAST( "infos" ) );
+        dumpInfosAsXml( writer );
+        xmlTextWriterEndElement( writer );
+
         // Dump Anchored objects if any
         SwSortedObjs* pAnchored = GetDrawObjs();
         if ( pAnchored && pAnchored->Count( ) > 0 )
@@ -327,13 +332,28 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer )
         lcl_freeWriter( writer );
 }
 
+void SwFrm::dumpInfosAsXml( xmlTextWriterPtr writer )
+{
+    // output the Frm
+    xmlTextWriterStartElement( writer, BAD_CAST( "bounds" ) );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "left" ), "%ld", Frm().Left() );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "top" ), "%ld", Frm().Top() );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "width" ), "%ld", Frm().Width() );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "height" ), "%ld", Frm().Height() );
+    xmlTextWriterEndElement( writer );
+}
+
 void SwFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "next" ), "%p", GetNext() );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "prev" ), "%p", GetPrev() );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "upper" ), "%p", this->GetUpper() );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "lower" ), "%p", this->GetLower() );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "id" ), "%u", GetFrmId() );
+    if ( GetNext( ) )
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "next" ), "%u", GetNext()->GetFrmId() );
+    if ( GetPrev( ) )
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "prev" ), "%u", GetPrev()->GetFrmId() );
+    if ( GetUpper( ) )
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "upper" ), "%u", GetUpper()->GetFrmId() );
+    if ( GetLower( ) )
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "lower" ), "%u", GetLower()->GetFrmId() );
     if ( IsTxtFrm(  ) )
     {
         SwTxtFrm *pTxtFrm = ( SwTxtFrm * ) this;
@@ -358,10 +378,8 @@ void SwAnchoredObject::dumpAsXml( xmlTextWriterPtr writer )
         writer = lcl_createDefaultWriter();
 
     xmlTextWriterStartElement( writer, BAD_CAST( getElementName() ) );
-    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
     xmlTextWriterEndElement( writer );
 
-
     if ( bCreateWriter )
         lcl_freeWriter( writer );
 }
@@ -370,30 +388,30 @@ void SwTxtFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
     SwFrm::dumpAsXmlAttributes( writer );
     if ( HasFollow() )
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%p", GetFollow() );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%u", GetFollow()->GetFrmId() );
 
     if (m_pPrecede != NULL)
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%p", (SwTxtFrm*)m_pPrecede );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%u", static_cast<SwTxtFrm*>(m_pPrecede)->GetFrmId() );
 }
 
 void SwSectionFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
     SwFrm::dumpAsXmlAttributes( writer );
     if ( HasFollow() )
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%p", GetFollow() );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%u", GetFollow()->GetFrmId() );
 
     if (m_pPrecede != NULL)
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%p", (SwSectionFrm*)m_pPrecede );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%u", static_cast<SwSectionFrm*>( m_pPrecede )->GetFrmId() );
 }
 
 void SwTabFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
     SwFrm::dumpAsXmlAttributes( writer );
     if ( HasFollow() )
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%p", GetFollow() );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%u", GetFollow()->GetFrmId() );
 
     if (m_pPrecede != NULL)
-        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%p", (SwTabFrm*)m_pPrecede );
+        xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%u", static_cast<SwTabFrm*>( m_pPrecede )->GetFrmId() );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list