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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Sep 15 09:13:50 PDT 2011


 sw/source/core/inc/bodyfrm.hxx     |    1 
 sw/source/core/inc/layfrm.hxx      |    2 
 sw/source/core/inc/pagefrm.hrc     |    3 
 sw/source/core/inc/pagefrm.hxx     |    1 
 sw/source/core/layout/pagefrm.src  |    7 +
 sw/source/core/layout/paintfrm.cxx |  196 +++++++++++++++++++------------------
 sw/source/ui/docvw/edtwin.cxx      |    2 
 7 files changed, 117 insertions(+), 95 deletions(-)

New commits:
commit 289eaef6869a7c63c805f56aff387a216f0c4e83
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Sep 15 17:29:10 2011 +0200

    Page Break: Fixed columns boundaries and breaks rendering
    
    Merged the page and column breaks rendering: columns breaks are now
    easily visible. The column boundaries are shown as before using plain
    lines.
    
    Also fixed the breaks rendering for vertical layout

diff --git a/sw/source/core/inc/bodyfrm.hxx b/sw/source/core/inc/bodyfrm.hxx
index 1513cc1..0f1116b 100644
--- a/sw/source/core/inc/bodyfrm.hxx
+++ b/sw/source/core/inc/bodyfrm.hxx
@@ -46,6 +46,7 @@ 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/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index a939033..5300ba8 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -169,6 +169,8 @@ public:
 
     const SwFrm* GetLastLower() const;
     inline SwFrm* GetLastLower();
+
+    virtual void PaintBreak() const{ };
 };
 
 //Um doppelte Implementierung zu sparen wird hier ein bischen gecasted
diff --git a/sw/source/core/inc/pagefrm.hrc b/sw/source/core/inc/pagefrm.hrc
index b334dc8..381722e 100644
--- a/sw/source/core/inc/pagefrm.hrc
+++ b/sw/source/core/inc/pagefrm.hrc
@@ -33,10 +33,11 @@
 //  Bitmaps for page shadow
 #define BMP_PAGE_SHADOW_MASK                RC_PAGEFRM_BEGIN + 0
 #define STR_PAGE_BREAK                      RC_PAGEFRM_BEGIN + 1
+#define STR_COLUMN_BREAK                    RC_PAGEFRM_BEGIN + 2
 
 
 // If you add resources, don't forget to update this
-#define PAGEFRM_ACT_END           STR_PAGE_BREAK
+#define PAGEFRM_ACT_END           STR_COLUMN_BREAK
 
 // Sanity check
 #if PAGEFRM_ACT_END > RC_PAGEFRM_END
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index e2e7ef5..bc20f17 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -210,7 +210,6 @@ public:
     sal_Bool HasGrid() const { return bHasGrid; }
 
     void PaintDecorators( ) const;
-    void PaintBreak() const;
 
     //Zeilennummern usw malen
     void RefreshExtraData( const SwRect & ) const;
diff --git a/sw/source/core/layout/pagefrm.src b/sw/source/core/layout/pagefrm.src
index 4abb689..0159217 100644
--- a/sw/source/core/layout/pagefrm.src
+++ b/sw/source/core/layout/pagefrm.src
@@ -7,5 +7,10 @@ Bitmap BMP_PAGE_SHADOW_MASK
 
 String STR_PAGE_BREAK
 {
-    Text [ en-US ] = "Manual page break" ;
+    Text [ en-US ] = "Manual Page Break" ;
+};
+
+String STR_COLUMN_BREAK
+{
+    Text [ en-US ] = "Manual Column Break" ;
 };
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 54d2e5d..9fa4aae 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -162,7 +162,6 @@ using namespace ::com::sun::star;
 //werden.
 
 #define SUBCOL_PAGE     0x01    //Helplines of the page
-#define SUBCOL_BREAK    0x02    //Helpline for a page or column break
 #define SUBCOL_TAB      0x08    //Helplines inside tables
 #define SUBCOL_FLY      0x10    //Helplines inside fly frames
 #define SUBCOL_SECT     0x20    //Helplines inside sections
@@ -1011,7 +1010,6 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
                         case SUBCOL_FLY: pCol = &SwViewOption::GetObjectBoundariesColor(); break;
                         case SUBCOL_TAB: pCol = &SwViewOption::GetTableBoundariesColor(); break;
                         case SUBCOL_SECT: pCol = &SwViewOption::GetSectionBoundColor(); break;
-                        case SUBCOL_BREAK:    pCol = &SwViewOption::GetPageBreakColor(); break;
                     }
 
                     if ( pOut->GetFillColor() != *pCol )
@@ -2990,7 +2988,6 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                     pPage->RefreshExtraData( aPaintRect );
 
                 pPage->PaintDecorators( );
-                pPage->PaintBreak( );
 
                 if ( pSh->GetWin() )
                 {
@@ -3336,77 +3333,90 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     return aSeq;
 }
 
-void SwPageFrm::PaintBreak( ) const
+void SwBodyFrm::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 = ContainsCntnt();
+        if ( pCnt && ( pCnt->IsPageBreak( sal_True ) || pCnt->IsColBreak( sal_True ) ) )
         {
-            const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt();
-            if ( pCnt && pCnt->IsPageBreak( 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
+            //    * Non-printing characters are shown, as this is more consistent
+            //      with other formatting marks
+            if ( !pGlobalShell->IsShowHeaderFooterSeparator() &&
+                  pGlobalShell->GetViewOptions( )->IsLineBreak( ) )
             {
-                // 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( ) )
-                {
-                    SwRect aRect( pCnt->Prt() );
-                    aRect.Pos() += pCnt->Frm().Pos();
+                SwRect aRect( pCnt->Prt() );
+                aRect.Pos() += pCnt->Frm().Pos();
 
-                    // Draw the line
-                    basegfx::B2DPolygon aLine;
+                // Draw the line
+                basegfx::B2DPolygon aLine;
+                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() ) ) );
+                }
+                else
+                {
+                    aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) );
+                    aLine.append( 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 );
-
-                    // 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 nTextXOff = ( aRect.Width() - aTextRect.GetWidth() ) / 2;
-
-                    basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
-                                aFontSize.getX(), aFontSize.getY(),
-                                aRect.Left() + nTextXOff, aRect.Top() ) );
-
-                    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 );
+                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 ) );
+                if ( !bPageBreak )
+                    aBreakText = ResId::toString( SW_RES( STR_COLUMN_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 = ( nWidth - aTextRect.GetWidth() ) / 2;
+
+                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 ) );
                 }
+
+                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 );
             }
         }
     }
@@ -6294,26 +6304,34 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreatePageAreaDelimiterPrimit
 }
 
 void SwBodyFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
-                                        const SwRect &/*rRect*/ ) const
+                                        const SwRect & rRect ) const
 {
-    if ( !pGlobalShell->IsHeaderFooterEdit() )
+    if ( IsPageBodyFrm() )
     {
-        SwRect aArea( Frm() );
-
-        // TODO include the footnote area if any
-        const SwFrm* pLay = pPage->Lower();
-        const SwFrm* pFtnCont = NULL;
-        while ( pLay->GetNext() && !pFtnCont )
+        if ( !pGlobalShell->IsHeaderFooterEdit() )
         {
-            if ( pLay->IsFtnContFrm( ) )
-                pFtnCont = pLay;
-            pLay = pLay->GetNext();
-        }
+            SwRect aArea( Frm() );
+
+            const SwFrm* pLay = pPage->Lower();
+            const SwFrm* pFtnCont = NULL;
+            while ( pLay->GetNext() && !pFtnCont )
+            {
+                if ( pLay->IsFtnContFrm( ) )
+                    pFtnCont = pLay;
+                pLay = pLay->GetNext();
+            }
 
-        if ( pFtnCont )
-            aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() );
+            if ( pFtnCont )
+                aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() );
 
-        ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) );
+            ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) );
+        }
+
+        PaintBreak();
+    }
+    else
+    {
+        SwLayoutFrm::PaintSubsidiaryLines( pPage, rRect );
     }
 }
 
@@ -6439,19 +6457,15 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
                 ::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 )
-                ::lcl_RefreshLine( this, pPage, aRT, aRB,
-                                   (bBreak && bVert) ? SUBCOL_BREAK : nSubColor,
-                                   pUsedSubsLines );
+            if ( aOriginal.Right() == nRight && ! ( bBreak && bVert ) )
+                ::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() )
+            if ( aOriginal.Top() == aOut.Top() && !( bBreak && !bVert ) )
                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
-                ::lcl_RefreshLine( this, pPage, aOut.Pos(), aRT,
-                                   (bBreak && !bVert) ? SUBCOL_BREAK : nSubColor,
-                                   pUsedSubsLines );
+                ::lcl_RefreshLine( this, pPage, aOut.Pos(), aRT, nSubColor, pUsedSubsLines );
             if ( aOriginal.Bottom() == nBottom )
                 ::lcl_RefreshLine( this, pPage, aLB, aRB, nSubColor,
                                    pUsedSubsLines );
@@ -6468,22 +6482,20 @@ 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 )
+            if ( aOriginal.Right() == nRight && ! ( bBreak && bVert ) )
             {
                 const SwRect aRect( aRT, aRB );
-                pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0,
-                        (bBreak && bVert) ? SUBCOL_BREAK : nSubColor );
+                pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0, nSubColor );
             }
         }
         // OD 14.11.2002 #104822# - adjust control for drawing top and bottom lines
         if ( !bCell || bNewTableModel || bVert )
         {
-            if ( aOriginal.Top() == aOut.Top() )
+            if ( aOriginal.Top() == aOut.Top() && ! ( bBreak && !bVert ) )
             {
                 // OD 14.11.2002 #104821# - in horizontal layout set page/column break at top
                 const SwRect aRect( aOut.Pos(), aRT );
-                pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0,
-                        (bBreak && !bVert) ? SUBCOL_BREAK : nSubColor );
+                pUsedSubsLines->AddLineRect( aRect, 0, SOLID, 0, nSubColor );
             }
             if ( aOriginal.Bottom() == nBottom )
             {
@@ -6492,6 +6504,8 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
             }
         }
     }
+
+    PaintBreak();
 }
 
 /*************************************************************************
commit 254b17ba2a143752b11efca26607e8c044604068
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Sep 15 11:37:38 2011 +0200

    Header/Footer: don't show the separators if mouse isn't over SwEditWin

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 8b1ccca..41d7761 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5405,7 +5405,7 @@ IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG )
 
 IMPL_LINK( SwEditWin, OverHeaderFooterHandler, Timer *, EMPTYARG )
 {
-    if ( !GetView().GetWrtShell().IsHeaderFooterEdit() )
+    if ( !GetView().GetWrtShell().IsHeaderFooterEdit() && IsMouseOver() )
     {
         // Toggle the Header/Footer separator
         sal_Bool bShown = GetView().GetWrtShell().IsShowHeaderFooterSeparator( );


More information about the Libreoffice-commits mailing list