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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Tue Jul 5 00:59:48 PDT 2011


 sw/source/core/frmedt/feshview.cxx |   13 +-
 sw/source/core/inc/hffrm.hxx       |    2 
 sw/source/core/inc/pagefrm.hxx     |    2 
 sw/source/core/layout/paintfrm.cxx |  239 +++++++++++++++++++------------------
 4 files changed, 134 insertions(+), 122 deletions(-)

New commits:
commit 9cbd624bd5e583c8b1ed1c13f17fda0dc88b7025
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Jul 5 09:42:49 2011 +0200

    Header/Footer separators drawing moved to the SwPageFrm level
    
    Drawing the header / footer separator in the SwHeadFootFrm was needing
    a call to InvalidateWindows to have a clean drawing... but this
    introduced some too frequent redrawing of the headers and footers thus
    giving cursor blinking and useless cycles used.
    
    The new drawing is done by the SwPageFrm in the same way than the grid
    drawing. It also has the advantage than the separator is now drawn on
    top of everything else in the page.

diff --git a/sw/source/core/inc/hffrm.hxx b/sw/source/core/inc/hffrm.hxx
index 4933fa9..74e633d 100644
--- a/sw/source/core/inc/hffrm.hxx
+++ b/sw/source/core/inc/hffrm.hxx
@@ -46,8 +46,6 @@ public:
                              sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
     virtual SwTwips ShrinkFrm( SwTwips, 
                                sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
-
-    virtual void Paint( const SwRect&, SwPrintData const*const pPrintData = NULL ) const;
 };
 
 class SwHeaderFrm: public SwHeadFootFrm
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index e7c973c..89524e9 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -209,6 +209,8 @@ public:
     void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
     sal_Bool HasGrid() const { return bHasGrid; }
 
+    void PaintDecorators( OutputDevice* pOut ) const;
+
     //Zeilennummern usw malen
     void RefreshExtraData( const SwRect & ) const;
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 6e2fd09..c62190a 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3040,6 +3040,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                 if ( bExtraData )
                     pPage->RefreshExtraData( aPaintRect );
 
+                pPage->PaintDecorators( pSh->GetOut() );
+
                 if ( pSh->GetWin() )
                 {
                     pSubsLines->PaintSubsidiary( pSh->GetOut(), pLines );
@@ -3317,134 +3319,141 @@ void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
             ::lcl_EmergencyFormatFtnCont( (SwFtnContFrm*)pFrm->GetNext() );
 
         pFrm = pFrm->GetNext();
+
         if ( pFrm && (sal_True == (bCnt = pFrm->IsCntntFrm())) )
             pFrm->Calc();
     }
 }
 
-void SwHeadFootFrm::Paint( const SwRect& rRect, SwPrintData const*const pPrintData ) const
+drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
+        OutputDevice* pOut, drawinglayer::processor2d::BaseProcessor2D* pProcessor,
+        double nLeft, double nRight, double nLineY,
+        bool bHeader, const String& rStyleName )
+{
+    drawinglayer::primitive2d::Primitive2DSequence aSeq( 4 );
+
+    basegfx::B2DPoint aLeft ( nLeft, nLineY );
+    basegfx::B2DPoint aRight( nRight, nLineY );
+
+    // Compute the text to show
+    String aText = SW_RESSTR( STR_HEADER );
+    if ( !bHeader )
+        aText = SW_RESSTR( STR_FOOTER );
+    aText += rStyleName;
+
+    // Colors
+    basegfx::BColor aLineColor( 3.0 / 255.0, 105.0 / 255.0, 163.0 / 255.0 );
+    basegfx::BColor aFillColor( 170.0 / 255.0, 220.0 / 255.0, 247.0 / 255.0 );
+
+    // 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 );
+
+    drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
+            new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
+                basegfx::B2DPolyPolygon( aLinePolygon ),
+                drawinglayer::attribute::LineAttribute( aLineColor, 20.0 ),
+                drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+
+    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+
+    // Compute the text primitive
+    basegfx::B2DVector aFontSize;
+
+    Font aFont = pOut->GetSettings().GetStyleSettings().GetAppFont();
+    aFont.SetHeight( 8 * 20 ); // 8pt to twips
+
+    drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
+            aFontSize, aFont, false, false );
+
+    FontMetric aFontMetric = pOut->GetFontMetric( aFont );
+
+    double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + 70.0;
+    if ( !bHeader )
+        nTextOffsetY = - aFontMetric.GetDescent() - 70.0;
+    basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
+                aFontSize.getX(), aFontSize.getY(),
+                nLeft + 80.0, nLineY + nTextOffsetY ) );
+
+
+    drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
+            new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+                aTextMatrix,
+                aText, 0, aText.Len(),
+                std::vector< double >(),
+                aFontAttr,
+                lang::Locale(),
+                aLineColor );
+    aSeq[3] = drawinglayer::primitive2d::Primitive2DReference( pText );
+    basegfx::B2DRange aTextRange = pText->getB2DRange( pProcessor->getViewInformation2D() );
+
+    // Draw the polygon around the flag
+    basegfx::B2DPolygon aFlagPolygon;
+    basegfx::B2DVector aFlagVector( 0, 1 );
+
+    double nFlagHeight = aTextRange.getMaxY() - nLineY + 60.0;
+
+    if ( !bHeader )
+    {
+        aFlagVector = - aFlagVector;
+        nFlagHeight = nLineY - aTextRange.getMinY() + 60.0;
+    }
+    basegfx::B2DPoint aStartPt( aTextRange.getMinX() - 60.0, nLineY );
+    aFlagPolygon.append( aStartPt );
+    basegfx::B2DPoint aNextPt = aStartPt + aFlagVector * ( nFlagHeight );
+    aFlagPolygon.append( aNextPt );
+    aNextPt += ( aTextRange.getWidth() + 120.0 ) * basegfx::B2DVector( 1, 0 );
+    aFlagPolygon.append( aNextPt );
+    aNextPt.setY( nLineY );
+    aFlagPolygon.append( aNextPt );
+
+    // Compute the flag background color primitive
+    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
+            new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+                basegfx::B2DPolyPolygon( aFlagPolygon ),
+                aFillColor ) );
+
+    drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pBoxLine =
+        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+            aFlagPolygon, aLineColor );
+    aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( pBoxLine );
+
+    return aSeq;
+}
+
+void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const
 {
-    if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
-         !pGlobalShell->GetViewOptions()->IsPDFExport() &&
-         !pGlobalShell->IsPreView() &&
-         pGlobalShell->IsHeaderFooterEdit( ) )
+    const SwLayoutFrm* pBody = FindBodyCont();
+    if ( pBody )
     {
-        double nLineY = double( rRect.Bottom() );
-        String aText = SW_RESSTR( STR_HEADER );
+        SwRect aBodyRect( pBody->Frm() );
 
-        if ( IsFooterFrm( ) )
+        if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
+             !pGlobalShell->GetViewOptions()->IsPDFExport() &&
+             !pGlobalShell->IsPreView() &&
+             pGlobalShell->IsHeaderFooterEdit( ) )
         {
-            nLineY = double( rRect.Top() );
-            aText = SW_RESSTR( STR_FOOTER );
-        }
-
-        const String aStyleName = FindPageFrm()->GetPageDesc()->GetName();
-        aText += aStyleName;
-
-        drawinglayer::primitive2d::Primitive2DSequence aSeq( 4 );
-        drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
-
-        // Colors
-        basegfx::BColor aLineColor( 3.0 / 255.0, 105.0 / 255.0, 163.0 / 255.0 );
-        basegfx::BColor aFillColor( 170.0 / 255.0, 220.0 / 255.0, 247.0 / 255.0 );
-
-        // 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( basegfx::B2DPoint( double( rRect.Left() ), nLineY ) );
-        aLinePolygon.append( basegfx::B2DPoint( double( rRect.Right() ), nLineY ) );
+            const String aStyleName = FindPageFrm()->GetPageDesc()->GetName();
+            drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
 
-        drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
-                new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
-                    basegfx::B2DPolyPolygon( aLinePolygon ),
-                    drawinglayer::attribute::LineAttribute( aLineColor, 20.0 ),
-                    drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+            pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
+                        pOut, pProcessor, double( Frm().Left() ), double( Frm().Right() ),
+                        double( aBodyRect.Top() ), true, aStyleName ) );
 
-        aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+            pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
+                        pOut, pProcessor, double( Frm().Left() ), double( Frm().Right() ),
+                        double( aBodyRect.Bottom() ), false, aStyleName ) );
 
-        // Compute the text primitive
-        basegfx::B2DVector aFontSize;
-
-        OutputDevice* pOut = pGlobalShell->GetOut();
-        Font aFont = pOut->GetSettings().GetStyleSettings().GetAppFont();
-        aFont.SetHeight( 8 * 20 ); // 8pt to twips
-
-        drawinglayer::attribute::FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
-                aFontSize, aFont, false, false );
-
-        FontMetric aFontMetric = pOut->GetFontMetric( aFont );
-
-        double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + 70.0;
-        if ( IsFooterFrm( ) )
-            nTextOffsetY = - aFontMetric.GetDescent() - 70.0;
-        basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
-                    aFontSize.getX(), aFontSize.getY(),
-                    rRect.Left() + 80.0, nLineY + nTextOffsetY ) );
-
-
-        drawinglayer::primitive2d::TextSimplePortionPrimitive2D * pText =
-                new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
-                    aTextMatrix,
-                    aText, 0, aText.Len(),
-                    std::vector< double >(),
-                    aFontAttr,
-                    lang::Locale(),
-                    aLineColor );
-        aSeq[3] = drawinglayer::primitive2d::Primitive2DReference( pText );
-        basegfx::B2DRange aTextRange = pText->getB2DRange( pProcessor->getViewInformation2D() );
-
-        // Draw the polygon around the flag
-        basegfx::B2DPolygon aFlagPolygon;
-        basegfx::B2DVector aFlagVector( 0, 1 );
-
-        double nFlagHeight = aTextRange.getMaxY() - nLineY + 60.0;
-
-        if ( IsFooterFrm( ) )
-        {
-            aFlagVector = - aFlagVector;
-            nFlagHeight = nLineY - aTextRange.getMinY() + 60.0;
+            delete pProcessor;
         }
-        basegfx::B2DPoint aStartPt( aTextRange.getMinX() - 60.0, nLineY );
-        aFlagPolygon.append( aStartPt );
-        basegfx::B2DPoint aNextPt = aStartPt + aFlagVector * ( nFlagHeight );
-        aFlagPolygon.append( aNextPt );
-        aNextPt += ( aTextRange.getWidth() + 120.0 ) * basegfx::B2DVector( 1, 0 );
-        aFlagPolygon.append( aNextPt );
-        aNextPt.setY( nLineY );
-        aFlagPolygon.append( aNextPt );
-
-        // Compute the flag background color primitive
-        aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
-                new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
-                    basegfx::B2DPolyPolygon( aFlagPolygon ),
-                    aFillColor ) );
-
-        drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pBoxLine =
-            new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
-                aFlagPolygon, aLineColor );
-        aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( pBoxLine );
-
-
-        // Compute the range to invalidate
-        basegfx::B2DRange aDrawRange = pLine->getB2DRange( pProcessor->getViewInformation2D() );
-        aDrawRange.expand( aTextRange );
-        aDrawRange.expand( pBoxLine->getB2DRange( pProcessor->getViewInformation2D() ) );
-
-        Rectangle aPaintRect(
-                long( aDrawRange.getMinX() ), long( aDrawRange.getMinY() ),
-                long( aDrawRange.getMaxX() ), long( aDrawRange.getMaxY() ) );
-
-        pGlobalShell->InvalidateWindows( aPaintRect );
-
-        pProcessor->process( aSeq );
-        delete pProcessor;
-    }
-    SwLayoutFrm::Paint( rRect, pPrintData );
+    }
 }
 
 /** FlyFrm::IsBackgroundTransparent - for feature #99657#
commit 78f4c40c91c37cd14603adc6b220abce8e0240db
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Jul 4 11:00:37 2011 +0200

    Fixed crash when selecting objs anchored at page

diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 1b38068..9166661 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1196,12 +1196,15 @@ sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
 
             // Don't select header / footer objects in body edition and vice-versa
             SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
-            const SwPosition& rPos = pContact->GetCntntAnchor();
-            bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
-            if ( ( IsHeaderFooterEdit() && !bInHdrFtr ) ||
-                 ( !IsHeaderFooterEdit() && bInHdrFtr ) )
+            if ( !pContact->ObjAnchoredAtPage() )
             {
-                bRet = sal_False;
+                const SwPosition& rPos = pContact->GetCntntAnchor();
+                bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
+                if ( ( IsHeaderFooterEdit() && !bInHdrFtr ) ||
+                     ( !IsHeaderFooterEdit() && bInHdrFtr ) )
+                {
+                    bRet = sal_False;
+                }
             }
 
             if ( bRet )


More information about the Libreoffice-commits mailing list