From c7a557cc4ff3c8e32ffe414f6b6fd7b62e7bf077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Wed, 7 Sep 2011 10:25:33 +0200 Subject: [PATCH] Sw page break: added a text above the line to explain the visualization --- sw/source/core/inc/pagefrm.hrc | 3 ++- sw/source/core/layout/pagefrm.src | 5 +++++ sw/source/core/layout/paintfrm.cxx | 32 +++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/sw/source/core/inc/pagefrm.hrc b/sw/source/core/inc/pagefrm.hrc index b8f89e091c15..b334dc8ea1b9 100644 --- a/sw/source/core/inc/pagefrm.hrc +++ b/sw/source/core/inc/pagefrm.hrc @@ -32,10 +32,11 @@ // Bitmaps for page shadow #define BMP_PAGE_SHADOW_MASK RC_PAGEFRM_BEGIN + 0 +#define STR_PAGE_BREAK RC_PAGEFRM_BEGIN + 1 // If you add resources, don't forget to update this -#define PAGEFRM_ACT_END BMP_PAGE_SHADOW_MASK +#define PAGEFRM_ACT_END STR_PAGE_BREAK // Sanity check #if PAGEFRM_ACT_END > RC_PAGEFRM_END diff --git a/sw/source/core/layout/pagefrm.src b/sw/source/core/layout/pagefrm.src index 4b0c4b2df7cb..4abb6891f997 100644 --- a/sw/source/core/layout/pagefrm.src +++ b/sw/source/core/layout/pagefrm.src @@ -4,3 +4,8 @@ Bitmap BMP_PAGE_SHADOW_MASK { File = "page-shadow-mask.png"; }; + +String STR_PAGE_BREAK +{ + Text [ en-US ] = "Manual page break" ; +}; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 4177191b9592..5f18cf9ba41f 100755 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3335,6 +3335,7 @@ void SwPageFrm::PaintBreak( ) const SwRect aRect( pCnt->Prt() ); aRect.Pos() += pCnt->Frm().Pos(); + // Draw the line basegfx::B2DPolygon aLine; aLine.append( basegfx::B2DPoint( double( aRect.Left() ), double( aRect.Top() ) ) ); aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) ); @@ -3345,9 +3346,38 @@ void SwPageFrm::PaintBreak( ) const new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( aLine, aLineColor ); - drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 ); + 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 ); } }