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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Sep 1 03:12:32 PDT 2011


 sw/source/core/layout/layact.cxx   |   20 -------
 sw/source/core/layout/paintfrm.cxx |  102 ++++++++++++++++++++++++++-----------
 2 files changed, 75 insertions(+), 47 deletions(-)

New commits:
commit ca2568e30a5a9154dc17bdc2efed4e2cf3027885
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Aug 30 18:44:05 2011 +0200

    fdo#40344: reverted commit 6f7bd9
    
    The tweak had side effect and is now useless with the new way of
    painting the separators.

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index aa1b561..70bfd1a 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1790,25 +1790,7 @@ sal_Bool SwLayAction::FormatCntnt( const SwPageFrm *pPage )
     const ViewShell *pSh = pRoot->GetCurrShell();
     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
 
-    // Check if there is a footer frame and if it's in an invalid state.
-    // In such a case, redraw the whole page to properly update the
-    // header/footer decorators
-    const SwFrm *pLay = pPage->Lower();
-    bool bPaintWholePage = false;
-
-    if ( pLay )
-    {
-        while ( pLay->GetNext() )
-            pLay = pLay->GetNext();
-
-        if ( pLay->IsFooterFrm() )
-        {
-            bPaintWholePage = true;
-            pImp->GetShell()->AddPaintRect( pPage->Frm() );
-        }
-    }
-
-    while ( !bPaintWholePage && pCntnt && pPage->IsAnLower( pCntnt ) )
+    while ( pCntnt && pPage->IsAnLower( pCntnt ) )
     {
         //Wenn der Cntnt sich eh nicht veraendert koennen wir ein paar
         //Abkuerzungen nutzen.
commit 093087968725584087dda01801a5355c98591310
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Aug 30 18:39:19 2011 +0200

    Header/Footer: separator drawing changes
    
    According to Christoph's ideas, here are changes to the separators:
      * labels moved to the right of the page instead of the left
      * the label background color computation has been improved to handle
        more cases
      * the separator line has been removed when there is a header or footer
      * the label is now sticking to the bottom/top of the header/footer

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 61068a0..c8138aa 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -42,6 +42,7 @@
 #include <editeng/prntitem.hxx>
 #include <editeng/boxitem.hxx>
 #include <editeng/shaditem.hxx>
+#include <editeng/ulspitem.hxx>
 #include <svx/framelink.hxx>
 #include <vcl/graph.hxx>
 #include <svx/svdpagv.hxx>
@@ -125,6 +126,8 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/color/bcolortools.hxx>
 
+#include <algorithm>
+
 using namespace ::editeng;
 using namespace ::com::sun::star;
 
@@ -3301,13 +3304,23 @@ void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 
 drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
         OutputDevice* pOut, drawinglayer::processor2d::BaseProcessor2D* pProcessor,
-        double nLeft, double nRight, double nLineY,
-        bool bHeader, const String& rStyleName )
+        const SwPageFrm* pPageFrm, double nLabelRight, double nLineY,
+        bool bHeader, const String& rStyleName, const SwFrm* pFrm )
 {
-    drawinglayer::primitive2d::Primitive2DSequence aSeq( 4 );
+    // Adjust the Y-coordinate of the line to the header/footer box
+    if ( pFrm )
+    {
+        const SwFrmFmt* pFmt = ((const SwLayoutFrm*)pFrm)->GetFmt();
+        if ( bHeader )
+            nLineY -= pFmt->GetULSpace().GetLower();
+        else
+            nLineY += pFmt->GetULSpace().GetUpper();
+    }
+
+    drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
 
-    basegfx::B2DPoint aLeft ( nLeft, nLineY );
-    basegfx::B2DPoint aRight( nRight, nLineY );
+    basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
+    basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
 
     // Compute the text to show
     String aText = SW_RESSTR( STR_HEADER );
@@ -3318,27 +3331,41 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     // Colors
     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
     basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
-    aHslLine.setZ( aHslLine.getZ( ) * 2.5 );
+    double nLuminance = aHslLine.getZ() * 2.5;
+    if ( nLuminance == 0 )
+        nLuminance = 0.5;
+    else if ( nLuminance >= 1.0 )
+        nLuminance = aHslLine.getZ() * 0.4;
+    aHslLine.setZ( nLuminance );
     basegfx::BColor aFillColor = basegfx::tools::hsl2rgb( aHslLine );
 
-    // Dashed line in twips
-    std::vector< double > aStrokePattern;
-    aStrokePattern.push_back( 110 );
-    aStrokePattern.push_back( 110 );
+    // Only draw the dashed line for unexisting header / footers
+    if ( !pFrm )
+    {
+        aSeq.realloc( 4 );
+
+        // Dashed line in twips
+        std::vector< double > aStrokePattern;
+        aStrokePattern.push_back( 110 );
+        aStrokePattern.push_back( 110 );
 
 
-    // Compute the dashed line primitive
-    basegfx::B2DPolygon aLinePolygon;
-    aLinePolygon.append( aLeft );
-    aLinePolygon.append( aRight );
+        // Compute the dashed line primitive
+        basegfx::B2DPolygon aLinePolygon;
+        aLinePolygon.append( aLeft );
+        aLinePolygon.append( aRight );
 
-    drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
-            new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
-                basegfx::B2DPolyPolygon( aLinePolygon ),
-                drawinglayer::attribute::LineAttribute( aLineColor, 20.0 ),
-                drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+        drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
+                new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
+                    basegfx::B2DPolyPolygon( aLinePolygon ),
+                    drawinglayer::attribute::LineAttribute( aLineColor, 20.0 ),
+                    drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+
+        aSeq[3] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+    }
 
-    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+    const SwRect& rVisArea = pPageFrm->getRootFrm()->GetCurrShell()->VisArea();
+    double nVisRight = rVisArea.Right();
 
     // Compute the text primitive
     basegfx::B2DVector aFontSize;
@@ -3346,6 +3373,12 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     Font aFont = pOut->GetSettings().GetStyleSettings().GetAppFont();
     aFont.SetHeight( 8 * 20 ); // 8pt to twips
 
+    // Compute the text width
+    const Font& rOldFont = pOut->GetFont();
+    pOut->SetFont( aFont );
+    double nTextWidth = pOut->GetTextWidth( aText );
+    pOut->SetFont( rOldFont );
+
     drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
             aFontSize, aFont, false, false );
 
@@ -3356,7 +3389,7 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
         nTextOffsetY = - aFontMetric.GetDescent() - 70.0;
     basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
                 aFontSize.getX(), aFontSize.getY(),
-                nLeft + 80.0, nLineY + nTextOffsetY ) );
+                std::min( nLabelRight, nVisRight ) - nTextWidth - 80.0, nLineY + nTextOffsetY ) );
 
 
     drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
@@ -3367,7 +3400,7 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
                 aFontAttr,
                 lang::Locale(),
                 aLineColor );
-    aSeq[3] = drawinglayer::primitive2d::Primitive2DReference( pText );
+    aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( pText );
     basegfx::B2DRange aTextRange = pText->getB2DRange( pProcessor->getViewInformation2D() );
 
     // Draw the polygon around the flag
@@ -3399,7 +3432,7 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pBoxLine =
         new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
             aFlagPolygon, aLineColor );
-    aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( pBoxLine );
+    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pBoxLine );
 
     return aSeq;
 }
@@ -3416,16 +3449,29 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const
              !pGlobalShell->IsPreView() &&
              pGlobalShell->IsHeaderFooterEdit( ) )
         {
-            const String aStyleName = FindPageFrm()->GetPageDesc()->GetName();
+            const String aStyleName = GetPageDesc()->GetName();
             drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
 
+            // Header
+            const SwFrm* pHeaderFrm = Lower();
+            if ( !pHeaderFrm->IsHeaderFrm() )
+                pHeaderFrm = NULL;
+
+            double nLabelRight = aBodyRect.Right();
             pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
-                        pOut, pProcessor, double( Frm().Left() ), double( Frm().Right() ),
-                        double( aBodyRect.Top() ), true, aStyleName ) );
+                        pOut, pProcessor, this, nLabelRight,
+                        double( aBodyRect.Top() ), true, aStyleName, pHeaderFrm ) );
+
+            // Footer
+            const SwFrm* pFooterFrm = Lower();
+            while ( pFooterFrm->GetNext() )
+                pFooterFrm = pFooterFrm->GetNext();
+            if ( !pFooterFrm->IsFooterFrm() )
+                pFooterFrm = NULL;
 
             pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
-                        pOut, pProcessor, double( Frm().Left() ), double( Frm().Right() ),
-                        double( aBodyRect.Bottom() ), false, aStyleName ) );
+                        pOut, pProcessor, this, nLabelRight,
+                        double( aBodyRect.Bottom() ), false, aStyleName, pFooterFrm ) );
 
             delete pProcessor;
         }


More information about the Libreoffice-commits mailing list