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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon Sep 19 11:37:36 PDT 2011


 sw/source/core/inc/bodyfrm.hxx     |    1 
 sw/source/core/inc/colfrm.hxx      |    3 
 sw/source/core/inc/ftnfrm.hxx      |    1 
 sw/source/core/inc/pagefrm.hxx     |    2 
 sw/source/core/inc/sectfrm.hxx     |    2 
 sw/source/core/layout/paintfrm.cxx |  393 +++++++++++++++++++++++--------------
 6 files changed, 257 insertions(+), 145 deletions(-)

New commits:
commit 0803f08bb135ec52d58171279d95b9ef542bcabd
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 19 18:42:37 2011 +0200

    Page Break: draw a dashed line using the header/footer separator code

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 0e1ff5c..4fd60c3 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3265,32 +3265,27 @@ void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
     }
 }
 
-drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
-        const SwPageFrm* pPageFrm, double nLineY )
+drawinglayer::primitive2d::Primitive2DSequence lcl_CreateDashedIndicatorPrimitive(
+        basegfx::B2DPoint aStart, basegfx::B2DPoint aEnd,
+        basegfx::BColor aColor )
 {
-    // Adjust the Y-coordinate of the line to the header/footer box
     drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
 
-    basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
-    basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
-
-    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
-
     std::vector< double > aStrokePattern;
     basegfx::B2DPolygon aLinePolygon;
-    aLinePolygon.append( aLeft );
-    aLinePolygon.append( aRight );
+    aLinePolygon.append( aStart );
+    aLinePolygon.append( aEnd );
 
     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     if ( rSettings.GetHighContrastMode( ) )
     {
         // Only a solid line in high contrast mode
-        aLineColor = rSettings.GetDialogTextColor().getBColor();
+        aColor = rSettings.GetDialogTextColor().getBColor();
     }
     else
     {
         // Get a color for the contrast
-        basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
+        basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor );
         double nLuminance = aHslLine.getZ() * 2.5;
         if ( nLuminance == 0 )
             nLuminance = 0.5;
@@ -3318,7 +3313,7 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
             new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
                 basegfx::B2DPolyPolygon( aLinePolygon ),
-                drawinglayer::attribute::LineAttribute( aLineColor ),
+                drawinglayer::attribute::LineAttribute( aColor ),
                 drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
 
     aSeq[ aSeq.getLength( ) - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine );
@@ -3326,6 +3321,18 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     return aSeq;
 }
 
+drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
+        const SwPageFrm* pPageFrm, double nLineY )
+{
+    // Adjust the Y-coordinate of the line to the header/footer box
+    basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
+    basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
+
+    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
+
+    return lcl_CreateDashedIndicatorPrimitive( aLeft, aRight, aLineColor );
+}
+
 void SwPageFrm::PaintBreak( ) const
 {
     if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
@@ -3347,19 +3354,16 @@ void SwPageFrm::PaintBreak( ) const
                 double nYLineOffset = double( pPageFrm->Frm().Top() + pPrevPageFrm->Frm().Bottom() ) / 2.0;
                 SwRect aRect = pPageFrm->GetBoundRect();
 
-                // Draw the line
-                basegfx::B2DPolygon aLine;
-                aLine.append( basegfx::B2DPoint( double( aRect.Left() ), nYLineOffset ) );
-                aLine.append( basegfx::B2DPoint( double( aRect.Right() ), nYLineOffset ) );
-
-                basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
+                basegfx::BColor aColor = SwViewOption::GetPageBreakColor().getBColor();
 
-                drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
-                        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
-                                aLine, aLineColor );
+                // Draw the line
+                drawinglayer::primitive2d::Primitive2DSequence aSeq =
+                    lcl_CreateDashedIndicatorPrimitive(
+                        basegfx::B2DPoint( double( aRect.Left() ), nYLineOffset ),
+                        basegfx::B2DPoint( double( aRect.Right() ), nYLineOffset ),
+                        aColor );
 
-                drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
-                aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+                aSeq.realloc( aSeq.getLength() + 1 );
 
                 // Add the text above
                 rtl::OUString aBreakText = ResId::toString( SW_RES( STR_PAGE_BREAK ) );
@@ -3387,8 +3391,8 @@ void SwPageFrm::PaintBreak( ) const
                             std::vector< double >(),
                             aFontAttr,
                             lang::Locale(),
-                            aLineColor );
-                aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+                            aColor );
+                aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pText );
 
                 ProcessPrimitives( aSeq );
             }
@@ -3423,28 +3427,22 @@ void SwColumnFrm::PaintBreak( ) const
                     aRect.Pos() += pCnt->Frm().Pos();
 
                     // Draw the line
-                    basegfx::B2DPolygon aLine;
+                    basegfx::B2DPoint aStart( double( aRect.Left() ), aRect.Top() );
+                    basegfx::B2DPoint aEnd( double( aRect.Right() ), aRect.Top() );
                     double nWidth = aRect.Width();
-                    if ( !IsVertical( ) )
-                    {
-                        aLine.append( basegfx::B2DPoint( double( aRect.Left() ), aRect.Top() ) );
-                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), aRect.Top() ) );
-                    }
-                    else
+                    if ( IsVertical( ) )
                     {
-                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
-                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Bottom() ) ) );
+                        aStart = basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) );
+                        aEnd = basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Bottom() ) );
                         nWidth = aRect.Height();
                     }
 
                     basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
 
-                    drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
-                            new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
-                                    aLine, aLineColor );
 
-                    drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
-                    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+                    drawinglayer::primitive2d::Primitive2DSequence aSeq =
+                        lcl_CreateDashedIndicatorPrimitive( aStart, aEnd, aLineColor );
+                    aSeq.realloc( aSeq.getLength( ) + 1 );
 
                     // Add the text above
                     rtl::OUString aBreakText = ResId::toString( SW_RES( STR_COLUMN_BREAK ) );
@@ -3479,7 +3477,7 @@ void SwColumnFrm::PaintBreak( ) const
                                 aFontAttr,
                                 lang::Locale(),
                                 aLineColor );
-                    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+                    aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pText );
 
                     ProcessPrimitives( aSeq );
                 }
commit 42ba2b6c03a74815d2041e554fea83350d554dd1
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 19 15:37:25 2011 +0200

    Text Boundaries: draw small inner corners for the columns areas
    
    Drawing small inner corners for the columns helps showing the columns
    without drawing a full rectangle and it is still compatible with the
    page and sections text boundaries.
    
    The whole subsidiary lines painting has been changed to call the method
    on all nested SwLayoutFrm. In order not to draw anything, simply
    override the method and do nothing in it: (almost) every object takes
    care of its boundaries.

diff --git a/sw/source/core/inc/bodyfrm.hxx b/sw/source/core/inc/bodyfrm.hxx
index 0f1116b..1513cc1 100644
--- a/sw/source/core/inc/bodyfrm.hxx
+++ b/sw/source/core/inc/bodyfrm.hxx
@@ -46,7 +46,6 @@ public:
 
     virtual void Paint( const SwRect&, const SwPrintData *pPrintData = NULL ) const;
     virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
-    virtual void PaintBreak() const;
 
     DECL_FIXEDMEMPOOL_NEWDEL(SwBodyFrm)
 };
diff --git a/sw/source/core/inc/colfrm.hxx b/sw/source/core/inc/colfrm.hxx
index 0485cdf..b3c3382 100644
--- a/sw/source/core/inc/colfrm.hxx
+++ b/sw/source/core/inc/colfrm.hxx
@@ -37,6 +37,9 @@ public:
     SwColumnFrm( SwFrmFmt*, SwFrm* );
     ~SwColumnFrm();
 
+    virtual void PaintBreak() const;
+    virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
+
     DECL_FIXEDMEMPOOL_NEWDEL(SwColumnFrm)
 };
 
diff --git a/sw/source/core/inc/ftnfrm.hxx b/sw/source/core/inc/ftnfrm.hxx
index 4c9d755..f1585b5 100644
--- a/sw/source/core/inc/ftnfrm.hxx
+++ b/sw/source/core/inc/ftnfrm.hxx
@@ -53,6 +53,7 @@ public:
     virtual void    Format( const SwBorderAttrs *pAttrs = 0 );
     virtual void    PaintBorder( const SwRect &, const SwPageFrm *pPage,
                                  const SwBorderAttrs & ) const;
+    virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
             void    PaintLine( const SwRect &, const SwPageFrm * ) const;
 };
 
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 0610f82..0550c0a 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -210,6 +210,7 @@ public:
     sal_Bool HasGrid() const { return bHasGrid; }
 
     void PaintDecorators( ) const;
+    virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
     virtual void PaintBreak() const;
 
     //Zeilennummern usw malen
diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx
index 37840b5..7966b8e 100644
--- a/sw/source/core/inc/sectfrm.hxx
+++ b/sw/source/core/inc/sectfrm.hxx
@@ -76,6 +76,8 @@ public:
     void Init();
     virtual void  CheckDirection( sal_Bool bVert );
 
+    virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
+
     virtual void Cut();
     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 41c81b8..0e1ff5c 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -89,6 +89,7 @@
 #include <EnhancedPDFExportHelper.hxx>
 #include <bodyfrm.hxx>
 #include <hffrm.hxx>
+#include <colfrm.hxx>
 // <--
 // --> OD #i76669#
 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
@@ -3395,91 +3396,93 @@ void SwPageFrm::PaintBreak( ) const
     }
 }
 
-void SwBodyFrm::PaintBreak( ) const
+void SwColumnFrm::PaintBreak( ) const
 {
     if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
          !pGlobalShell->GetViewOptions()->IsPDFExport() &&
          !pGlobalShell->IsPreView() )
     {
-        const SwCntntFrm *pCnt = ContainsCntnt();
-        if ( pCnt && pCnt->IsPageBreak( sal_True ) )
-        {
-            const SwPageFrm* pPageFrm = FindPageFrm();
-            pPageFrm->PaintBreak();
-        }
-        else if ( pCnt && pCnt->IsColBreak( sal_True ) )
+        const SwFrm* pBodyFrm = Lower();
+        while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+            pBodyFrm = pBodyFrm->GetNext();
+
+        if ( pBodyFrm )
         {
-            // Paint the break only if:
-            //    * Not in header footer edition, to avoid conflicts with the
-            //      header/footer marker
-            //    * Non-printing characters are shown, as this is more consistent
-            //      with other formatting marks
-            if ( !pGlobalShell->IsShowHeaderFooterSeparator() &&
-                  pGlobalShell->GetViewOptions( )->IsLineBreak( ) )
+            const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt();
+            if ( pCnt && pCnt->IsColBreak( sal_True ) )
             {
-                SwRect aRect( pCnt->Prt() );
-                aRect.Pos() += pCnt->Frm().Pos();
-
-                // Draw the line
-                basegfx::B2DPolygon aLine;
-                double nWidth = aRect.Width();
-                if ( !IsVertical( ) )
+                // Paint the break only if:
+                //    * Not in header footer edition, to avoid conflicts with the
+                //      header/footer marker
+                //    * Non-printing characters are shown, as this is more consistent
+                //      with other formatting marks
+                if ( !pGlobalShell->IsShowHeaderFooterSeparator() &&
+                      pGlobalShell->GetViewOptions( )->IsLineBreak( ) )
                 {
-                    aLine.append( basegfx::B2DPoint( double( aRect.Left() ), aRect.Top() ) );
-                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), aRect.Top() ) );
-                }
-                else
-                {
-                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
-                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Bottom() ) ) );
-                    nWidth = aRect.Height();
-                }
+                    SwRect aRect( pCnt->Prt() );
+                    aRect.Pos() += pCnt->Frm().Pos();
 
-                basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
+                    // Draw the line
+                    basegfx::B2DPolygon aLine;
+                    double nWidth = aRect.Width();
+                    if ( !IsVertical( ) )
+                    {
+                        aLine.append( basegfx::B2DPoint( double( aRect.Left() ), aRect.Top() ) );
+                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), aRect.Top() ) );
+                    }
+                    else
+                    {
+                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
+                        aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Bottom() ) ) );
+                        nWidth = aRect.Height();
+                    }
 
-                drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
-                        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
-                                aLine, aLineColor );
+                    basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
 
-                drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
-                aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+                    drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
+                            new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+                                    aLine, aLineColor );
 
-                // Add the text above
-                rtl::OUString aBreakText = ResId::toString( SW_RES( STR_COLUMN_BREAK ) );
+                    drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
+                    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
 
-                basegfx::B2DVector aFontSize;
-                OutputDevice* pOut = pGlobalShell->GetOut();
-                Font aFont = pOut->GetSettings().GetStyleSettings().GetToolFont();
-                aFont.SetHeight( 8 * 20 );
-                pOut->SetFont( aFont );
-                drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
-                        aFontSize, aFont, false, false );
+                    // Add the text above
+                    rtl::OUString aBreakText = ResId::toString( SW_RES( STR_COLUMN_BREAK ) );
 
-                Rectangle aTextRect;
-                pOut->GetTextBoundRect( aTextRect, String( aBreakText ) );
-                long nTextOff = ( nWidth - aTextRect.GetWidth() ) / 2;
+                    basegfx::B2DVector aFontSize;
+                    OutputDevice* pOut = pGlobalShell->GetOut();
+                    Font aFont = pOut->GetSettings().GetStyleSettings().GetToolFont();
+                    aFont.SetHeight( 8 * 20 );
+                    pOut->SetFont( aFont );
+                    drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
+                            aFontSize, aFont, false, false );
 
-                basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
-                            aFontSize.getX(), aFontSize.getY(),
-                            aRect.Left() + nTextOff, aRect.Top() ) );
-                if ( IsVertical() )
-                {
-                    aTextMatrix = basegfx::B2DHomMatrix( basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix (
-                            aFontSize.getX(), aFontSize.getY(), 0.0, M_PI_2,
-                            aRect.Right(), aRect.Top() + nTextOff ) );
-                }
+                    Rectangle aTextRect;
+                    pOut->GetTextBoundRect( aTextRect, String( aBreakText ) );
+                    long nTextOff = ( nWidth - aTextRect.GetWidth() ) / 2;
 
-                drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
-                        new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
-                            aTextMatrix,
-                            aBreakText, 0, aBreakText.getLength(),
-                            std::vector< double >(),
-                            aFontAttr,
-                            lang::Locale(),
-                            aLineColor );
-                aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+                    basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                aFontSize.getX(), aFontSize.getY(),
+                                aRect.Left() + nTextOff, aRect.Top() ) );
+                    if ( IsVertical() )
+                    {
+                        aTextMatrix = basegfx::B2DHomMatrix( basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix (
+                                aFontSize.getX(), aFontSize.getY(), 0.0, M_PI_2,
+                                aRect.Right(), aRect.Top() + nTextOff ) );
+                    }
 
-                ProcessPrimitives( aSeq );
+                    drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
+                            new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+                                aTextMatrix,
+                                aBreakText, 0, aBreakText.getLength(),
+                                std::vector< double >(),
+                                aFontAttr,
+                                lang::Locale(),
+                                aLineColor );
+                    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+
+                    ProcessPrimitives( aSeq );
+                }
             }
         }
     }
@@ -6149,33 +6152,8 @@ void SwPageFrm::RefreshSubsidiary( const SwRect &rRect ) const
 void SwLayoutFrm::RefreshLaySubsidiary( const SwPageFrm *pPage,
                                         const SwRect &rRect ) const
 {
-    const sal_Bool bNoLowerColumn = !Lower() || !Lower()->IsColumnFrm();
     const sal_Bool bSubsOpt   = IS_SUBS;
-    const sal_Bool bSubsTable = ((GetType() & (FRM_ROW | FRM_CELL)) && IS_SUBS_TABLE);
-    const sal_Bool bSubsOther = (GetType() & (FRM_HEADER | FRM_FOOTER | FRM_FTN )) && bSubsOpt;
-    const sal_Bool bSubsSect  = IsSctFrm() &&
-                                bNoLowerColumn &&
-                                IS_SUBS_SECTION;
-    const sal_Bool bSubsFly   = IS_SUBS_FLYS &&
-                                (GetType() & FRM_FLY) &&
-                                bNoLowerColumn &&
-                                (!Lower() || !Lower()->IsNoTxtFrm() ||
-                                 !((SwNoTxtFrm*)Lower())->HasAnimation());
-    sal_Bool bSubsBody = sal_False;
-    if ( GetType() & FRM_BODY )
-    {
-        if ( IsPageBodyFrm() )
-            bSubsBody = bSubsOpt && bNoLowerColumn;                                 //nur ohne Spalten
-        else    //Spaltenbody
-        {
-            if ( GetUpper()->GetUpper()->IsSctFrm() )
-                bSubsBody = IS_SUBS_SECTION;
-            else
-                bSubsBody = bSubsOpt;
-        }
-    }
-
-    if ( bSubsOther || bSubsSect  || bSubsBody || bSubsTable || bSubsFly )
+    if ( bSubsOpt )
         PaintSubsidiaryLines( pPage, rRect );
 
     const SwFrm *pLow = Lower();
@@ -6366,38 +6344,123 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreatePageAreaDelimiterPrimit
     return aSeq;
 }
 
-void SwBodyFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
-                                        const SwRect & rRect ) const
+drawinglayer::primitive2d::Primitive2DSequence lcl_CreateColumnAreaDelimiterPrimitives(
+        const SwRect& rRect )
 {
-    if ( IsPageBodyFrm() )
+    drawinglayer::primitive2d::Primitive2DSequence aSeq( 4 );
+
+    basegfx::BColor aLineColor = SwViewOption::GetDocBoundariesColor().getBColor();
+    double nLineLength = 100.0; // in Twips
+
+    Point aPoints[] = { rRect.TopLeft(), rRect.TopRight(), rRect.BottomRight(), rRect.BottomLeft() };
+    double aXOffDirs[] = { 1.0, -1.0, -1.0, 1.0 };
+    double aYOffDirs[] = { 1.0, 1.0, -1.0, -1.0 };
+
+    // Actually loop over the corners to create the two lines
+    for ( int i = 0; i < 4; i++ )
     {
-        if ( !pGlobalShell->IsHeaderFooterEdit() )
-        {
-            SwRect aArea( Frm() );
+        basegfx::B2DVector aHorizVector( aXOffDirs[i], 0.0 );
+        basegfx::B2DVector aVertVector( 0.0, aYOffDirs[i] );
 
-            const SwFrm* pLay = pPage->Lower();
-            const SwFrm* pFtnCont = NULL;
-            while ( pLay->GetNext() && !pFtnCont )
-            {
-                if ( pLay->IsFtnContFrm( ) )
-                    pFtnCont = pLay;
-                pLay = pLay->GetNext();
-            }
+        basegfx::B2DPoint aBPoint( aPoints[i].X(), aPoints[i].Y() );
 
-            if ( pFtnCont )
-                aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() );
+        basegfx::B2DPolygon aPolygon;
+        aPolygon.append( aBPoint + aHorizVector * nLineLength );
+        aPolygon.append( aBPoint );
+        aPolygon.append( aBPoint + aVertVector * nLineLength );
 
-            ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) );
+        drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
+            new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+                    aPolygon, aLineColor );
+        aSeq[i] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+    }
+
+    return aSeq;
+}
+
+void SwPageFrm::PaintSubsidiaryLines( const SwPageFrm *,
+                                        const SwRect & ) const
+{
+    if ( !pGlobalShell->IsHeaderFooterEdit() )
+    {
+        const SwFrm* pLay = Lower();
+        const SwFrm* pFtnCont = NULL;
+        const SwFrm* pPageBody = NULL;
+        while ( pLay && !( pFtnCont && pPageBody ) )
+        {
+            if ( pLay->IsFtnContFrm( ) )
+                pFtnCont = pLay;
+            if ( pLay->IsBodyFrm() )
+                pPageBody = pLay;
+            pLay = pLay->GetNext();
         }
 
-        PaintBreak();
+        SwRect aArea( pPageBody->Frm() );
+        if ( pFtnCont )
+            aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() );
+
+        ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) );
     }
-    else
+
+    PaintBreak();
+}
+
+void SwColumnFrm::PaintSubsidiaryLines( const SwPageFrm *,
+                                        const SwRect & ) const
+{
+    const SwFrm* pLay = Lower();
+    const SwFrm* pFtnCont = NULL;
+    const SwFrm* pColBody = NULL;
+    while ( pLay && !( pFtnCont && pColBody ) )
+    {
+        if ( pLay->IsFtnContFrm( ) )
+            pFtnCont = pLay;
+        if ( pLay->IsBodyFrm() )
+            pColBody = pLay;
+        pLay = pLay->GetNext();
+    }
+
+    SwRect aArea( pColBody->Frm() );
+
+    // #i3662# - enlarge top of column body frame's printing area
+    // in sections to top of section frame.
+    const bool bColInSection =  GetUpper()->IsSctFrm();
+    if ( bColInSection )
+    {
+        if ( IsVertical() )
+            aArea.Right( GetUpper()->Frm().Right() );
+        else
+            aArea.Top( GetUpper()->Frm().Top() );
+    }
+
+    if ( pFtnCont )
+        aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() );
+
+    ::SwAlignRect( aArea, pGlobalShell );
+
+    ProcessPrimitives( lcl_CreateColumnAreaDelimiterPrimitives( aArea ) );
+
+    PaintBreak();
+}
+
+void SwSectionFrm::PaintSubsidiaryLines( const SwPageFrm * pPage,
+                                        const SwRect & rRect ) const
+{
+    const sal_Bool bNoLowerColumn = !Lower() || !Lower()->IsColumnFrm();
+    if ( bNoLowerColumn )
     {
         SwLayoutFrm::PaintSubsidiaryLines( pPage, rRect );
     }
 }
 
+/** The SwBodyFrm doesn't print any subsidiary line: it's bounds are painted
+    either by the parent page or the parent column frame.
+  */
+void SwBodyFrm::PaintSubsidiaryLines( const SwPageFrm *,
+                                        const SwRect & ) const
+{
+}
+
 void SwHeadFootFrm::PaintSubsidiaryLines( const SwPageFrm *, const SwRect & ) const
 {
     if ( pGlobalShell->IsHeaderFooterEdit() )
@@ -6416,6 +6479,14 @@ void SwFtnFrm::PaintSubsidiaryLines( const SwPageFrm *,
 {
 }
 
+/** This method is overridden in order to have no subsidiary lines
+    around the footnotes containers.
+  */
+void SwFtnContFrm::PaintSubsidiaryLines( const SwPageFrm *,
+                                        const SwRect & ) const
+{
+}
+
 void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
                                         const SwRect &rRect ) const
 {
@@ -6449,19 +6520,6 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
     if ( !bUseFrmArea )
         aOriginal.Pos() += Frm().Pos();
 
-    // OD 13.02.2003 #i3662# - enlarge top of column body frame's printing area
-    // in sections to top of section frame.
-    const bool bColBodyInSection = IsBodyFrm() &&
-                                   !IsPageBodyFrm() &&
-                                   GetUpper()->GetUpper()->IsSctFrm();
-    if ( bColBodyInSection )
-    {
-        if ( IsVertical() )
-            aOriginal.Right( GetUpper()->GetUpper()->Frm().Right() );
-        else
-            aOriginal.Top( GetUpper()->GetUpper()->Frm().Top() );
-    }
-
     ::SwAlignRect( aOriginal, pGlobalShell );
 
     if ( !aOriginal.IsOver( rRect ) )
@@ -6469,13 +6527,6 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
 
     SwRect aOut( aOriginal );
     aOut._Intersection( rRect );
-    // OD 13.02.2003 #i3662# - do not intersect *enlarged* column body frame's
-    // printing area with the paint area of the body frame. Otherwise enlargement
-    // will get lost.
-    if ( !bColBodyInSection )
-    {
-        aOut.Intersection( PaintArea() );
-    }
 
     const SwTwips nRight = aOut.Right();
     const SwTwips nBottom= aOut.Bottom();
@@ -6488,18 +6539,6 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
                      ( IsInSct() ? SUBCOL_SECT :
                      ( IsInFly() ? SUBCOL_FLY : SUBCOL_PAGE ) );
 
-    // OD 05.11.2002 #102406# - body frames are responsible for page/column breaks.
-    sal_Bool bBreak = sal_False;
-    if ( IsBodyFrm() )
-    {
-        const SwCntntFrm *pCnt = ContainsCntnt();
-        if ( pCnt )
-        {
-            // OD 05.11.2002 #102406# - adjust setting of <bBreak>.
-            bBreak = ( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) );
-        }
-    }
-
     // OD 18.11.2002 #99672# - collect body, header, footer, footnote and section
     // sub-lines in <pSpecSubsLine> array.
     const bool bSpecialSublines = IsBodyFrm() || IsHeaderFrm() || IsFooterFrm() ||
@@ -6517,16 +6556,15 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
         if ( !bCell || bNewTableModel || !bVert )
         {
             if ( aOriginal.Left() == aOut.Left() )
-                ::lcl_RefreshLine( this, pPage, aOut.Pos(), aLB, nSubColor,
-                                   pUsedSubsLines );
+                ::lcl_RefreshLine( this, pPage, aOut.Pos(), aLB, nSubColor, pUsedSubsLines );
             // OD 14.11.2002 #104821# - in vertical layout set page/column break at right
-            if ( aOriginal.Right() == nRight && ! ( bBreak && bVert ) )
+            if ( aOriginal.Right() == nRight )
                 ::lcl_RefreshLine( this, pPage, aRT, aRB, nSubColor, pUsedSubsLines );
         }
         // OD 14.11.2002 #104822# - adjust control for drawing top and bottom lines
         if ( !bCell || bNewTableModel || bVert )
         {
-            if ( aOriginal.Top() == aOut.Top() && !( bBreak && !bVert ) )
+            if ( aOriginal.Top() == aOut.Top() )
                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
                 ::lcl_RefreshLine( this, pPage, aOut.Pos(), aRT, nSubColor, pUsedSubsLines );
             if ( aOriginal.Bottom() == nBottom )
@@ -6545,7 +6583,7 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
                 pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0, nSubColor );
             }
             // OD 14.11.2002 #104821# - in vertical layout set page/column break at right
-            if ( aOriginal.Right() == nRight && ! ( bBreak && bVert ) )
+            if ( aOriginal.Right() == nRight )
             {
                 const SwRect aRect( aRT, aRB );
                 pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0, nSubColor );
@@ -6554,7 +6592,7 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
         // OD 14.11.2002 #104822# - adjust control for drawing top and bottom lines
         if ( !bCell || bNewTableModel || bVert )
         {
-            if ( aOriginal.Top() == aOut.Top() && ! ( bBreak && !bVert ) )
+            if ( aOriginal.Top() == aOut.Top() )
             {
                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
                 const SwRect aRect( aOut.Pos(), aRT );
@@ -6567,8 +6605,6 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
             }
         }
     }
-
-    PaintBreak();
 }
 
 /*************************************************************************
commit b0bcdb79130c2c8dd0875855f063f150e585a103
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 19 12:59:27 2011 +0200

    Header/Footer: draw page breaks between the two pages and in all cases

diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index bc20f17..0610f82 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -210,6 +210,7 @@ public:
     sal_Bool HasGrid() const { return bHasGrid; }
 
     void PaintDecorators( ) const;
+    virtual void PaintBreak() const;
 
     //Zeilennummern usw malen
     void RefreshExtraData( const SwRect & ) const;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index d923b55..41c81b8 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3325,6 +3325,76 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     return aSeq;
 }
 
+void SwPageFrm::PaintBreak( ) const
+{
+    if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
+         !pGlobalShell->GetViewOptions()->IsPDFExport() &&
+         !pGlobalShell->IsPreView() )
+    {
+        const SwFrm* pBodyFrm = Lower();
+        while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
+            pBodyFrm = pBodyFrm->GetNext();
+
+        if ( pBodyFrm )
+        {
+            const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt();
+            if ( pCnt && pCnt->IsPageBreak( sal_True ) )
+            {
+                const SwPageFrm* pPageFrm = FindPageFrm();
+                const SwPageFrm* pPrevPageFrm = static_cast< const SwPageFrm* >( pPageFrm->GetPrev() );
+
+                double nYLineOffset = double( pPageFrm->Frm().Top() + pPrevPageFrm->Frm().Bottom() ) / 2.0;
+                SwRect aRect = pPageFrm->GetBoundRect();
+
+                // Draw the line
+                basegfx::B2DPolygon aLine;
+                aLine.append( basegfx::B2DPoint( double( aRect.Left() ), nYLineOffset ) );
+                aLine.append( basegfx::B2DPoint( double( aRect.Right() ), nYLineOffset ) );
+
+                basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor();
+
+                drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine =
+                        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+                                aLine, aLineColor );
+
+                drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
+                aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+
+                // Add the text above
+                rtl::OUString aBreakText = ResId::toString( SW_RES( STR_PAGE_BREAK ) );
+
+                basegfx::B2DVector aFontSize;
+                OutputDevice* pOut = pGlobalShell->GetOut();
+                Font aFont = pOut->GetSettings().GetStyleSettings().GetToolFont();
+                aFont.SetHeight( 8 * 20 );
+                pOut->SetFont( aFont );
+                drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
+                        aFontSize, aFont, false, false );
+
+                Rectangle aTextRect;
+                pOut->GetTextBoundRect( aTextRect, String( aBreakText ) );
+                long nTextOff = ( aRect.Width() - aTextRect.GetWidth() ) / 2;
+
+                basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
+                            aFontSize.getX(), aFontSize.getY(),
+                            aRect.Left() + nTextOff, nYLineOffset ) );
+
+                drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
+                        new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+                            aTextMatrix,
+                            aBreakText, 0, aBreakText.getLength(),
+                            std::vector< double >(),
+                            aFontAttr,
+                            lang::Locale(),
+                            aLineColor );
+                aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pText );
+
+                ProcessPrimitives( aSeq );
+            }
+        }
+    }
+}
+
 void SwBodyFrm::PaintBreak( ) const
 {
     if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
@@ -3332,10 +3402,13 @@ void SwBodyFrm::PaintBreak( ) const
          !pGlobalShell->IsPreView() )
     {
         const SwCntntFrm *pCnt = ContainsCntnt();
-        if ( pCnt && ( pCnt->IsPageBreak( sal_True ) || pCnt->IsColBreak( sal_True ) ) )
+        if ( pCnt && pCnt->IsPageBreak( sal_True ) )
+        {
+            const SwPageFrm* pPageFrm = FindPageFrm();
+            pPageFrm->PaintBreak();
+        }
+        else if ( pCnt && pCnt->IsColBreak( sal_True ) )
         {
-            bool bPageBreak = pCnt->IsPageBreak( sal_True );
-
             // Paint the break only if:
             //    * Not in header footer edition, to avoid conflicts with the
             //      header/footer marker
@@ -3352,8 +3425,8 @@ void SwBodyFrm::PaintBreak( ) const
                 double nWidth = aRect.Width();
                 if ( !IsVertical( ) )
                 {
-                    aLine.append( basegfx::B2DPoint( double( aRect.Left() ), double( aRect.Top() ) ) );
-                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
+                    aLine.append( basegfx::B2DPoint( double( aRect.Left() ), aRect.Top() ) );
+                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), aRect.Top() ) );
                 }
                 else
                 {
@@ -3372,9 +3445,7 @@ void SwBodyFrm::PaintBreak( ) const
                 aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
 
                 // Add the text above
-                rtl::OUString aBreakText = ResId::toString( SW_RES( STR_PAGE_BREAK ) );
-                if ( !bPageBreak )
-                    aBreakText = ResId::toString( SW_RES( STR_COLUMN_BREAK ) );
+                rtl::OUString aBreakText = ResId::toString( SW_RES( STR_COLUMN_BREAK ) );
 
                 basegfx::B2DVector aFontSize;
                 OutputDevice* pOut = pGlobalShell->GetOut();


More information about the Libreoffice-commits mailing list