Sw page break: added a text above the line to explain the visualization

This commit is contained in:
Cédric Bosdonnat 2011-09-07 10:25:33 +02:00
parent 3f62165fd4
commit c7a557cc4f
3 changed files with 38 additions and 2 deletions

View file

@ -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

View file

@ -4,3 +4,8 @@ Bitmap BMP_PAGE_SHADOW_MASK
{
File = "page-shadow-mask.png";
};
String STR_PAGE_BREAK
{
Text [ en-US ] = "Manual page break" ;
};

View file

@ -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 );
}
}