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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Sep 7 01:51:06 PDT 2011


 sw/source/core/inc/pagefrm.hrc     |    3 +-
 sw/source/core/layout/pagefrm.src  |    5 ++++
 sw/source/core/layout/paintfrm.cxx |   40 ++++++++++++++++++++++++++++++++-----
 3 files changed, 42 insertions(+), 6 deletions(-)

New commits:
commit 2f375ff51cba6d7f70a433bb254f34c8bb5a6bec
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Sep 7 10:42:16 2011 +0200

    Fixed build error about double conversion

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 5f18cf9..e3146af 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -6251,14 +6251,14 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreatePageAreaDelimiterPrimit
     double nLineLength = 200.0; // in Twips
 
     Point aPoints[] = { rRect.TopLeft(), rRect.TopRight(), rRect.BottomRight(), rRect.BottomLeft() };
-    int aXOffDirs[] = { -1, 1, 1, -1 };
-    int aYOffDirs[] = { -1, -1, 1, 1 };
+    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++ )
     {
-        basegfx::B2DVector aHorizVector( double( aXOffDirs[i] ), 0.0 );
-        basegfx::B2DVector aVertVector( 0.0, double( aYOffDirs[i] ) );
+        basegfx::B2DVector aHorizVector( aXOffDirs[i], 0.0 );
+        basegfx::B2DVector aVertVector( 0.0, aYOffDirs[i] );
 
         basegfx::B2DPoint aBPoint( aPoints[i].X(), aPoints[i].Y() );
 
commit c7a557cc4ff3c8e32ffe414f6b6fd7b62e7bf077
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Sep 7 10:25:33 2011 +0200

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

diff --git a/sw/source/core/inc/pagefrm.hrc b/sw/source/core/inc/pagefrm.hrc
index b8f89e0..b334dc8 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 4b0c4b2..4abb689 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 4177191..5f18cf9 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 );
             }
         }


More information about the Libreoffice-commits mailing list