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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Tue Sep 20 08:01:52 PDT 2011


 sw/Library_sw.mk                       |    1 
 sw/source/core/layout/paintfrm.cxx     |   28 -------
 sw/source/ui/docvw/DashedLine.cxx      |  116 +++++++++++++++++++++++++++++++++
 sw/source/ui/docvw/HeaderFooterWin.cxx |   24 ++++++
 sw/source/ui/docvw/edtwin.cxx          |    9 +-
 sw/source/ui/inc/DashedLine.hxx        |   49 +++++++++++++
 sw/source/ui/inc/HeaderFooterWin.hxx   |    5 +
 7 files changed, 201 insertions(+), 31 deletions(-)

New commits:
commit 5b01db236ec80c4e01dad93488eccb3da2eb387b
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Sep 20 16:53:16 2011 +0200

    Header/Footer: Fixed a few separators rendering problems
    
    Bugs fixed:
     + Some of the separators weren't hidden (zooming out and then zooming
       in is an example)
     + The footer separator wasn't properly placed under footnotes
    containers if there was no footer.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index c443ace..f3db985 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2980,8 +2980,6 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                 if ( bExtraData )
                     pPage->RefreshExtraData( aPaintRect );
 
-                pPage->PaintDecorators( );
-
                 if ( pSh->GetWin() )
                 {
                     pSubsLines->PaintSubsidiary( pSh->GetOut(), pLines );
@@ -3006,6 +3004,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                     pSh->DLPostPaint2(true);
                 }
             }
+
+            pPage->PaintDecorators( );
         }
         else if ( bBookMode && pSh->GetWin() && !pSh->GetDoc()->GetDocShell()->IsInPlaceActive() )
         {
@@ -3505,7 +3505,7 @@ void SwPageFrm::PaintDecorators( ) const
 
                 // Footer
                 const SwFrm* pFtnContFrm = Lower();
-                while ( pFtnContFrm->GetNext() )
+                while ( pFtnContFrm )
                 {
                     if ( pFtnContFrm->IsFtnContFrm() )
                         aBodyRect.AddBottom( pFtnContFrm->Frm().Bottom() - aBodyRect.Bottom() );
commit 589f754e7c2fa6d62fb8a8b566757c9cf5bea893
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Sep 20 15:22:02 2011 +0200

    Header/Footer: move the separator line painting to a Window control
    
    This avoids drawing control things on the document OutputDevice and
    helps keeping them properly refreshed without refreshing the whole
    document layout.

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 35b2b03..709b4b5 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -583,6 +583,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/ui/docvw/AnchorOverlayObject \
     sw/source/ui/docvw/AnnotationMenuButton \
     sw/source/ui/docvw/AnnotationWin \
+    sw/source/ui/docvw/DashedLine \
     sw/source/ui/docvw/PostItMgr \
     sw/source/ui/docvw/ShadowOverlayObject \
     sw/source/ui/docvw/SidebarTxtControl \
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 4fd60c3..c443ace 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3321,18 +3321,6 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateDashedIndicatorPrimitiv
     return aSeq;
 }
 
-drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
-        const SwPageFrm* pPageFrm, double nLineY )
-{
-    // Adjust the Y-coordinate of the line to the header/footer box
-    basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
-    basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
-
-    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
-
-    return lcl_CreateDashedIndicatorPrimitive( aLeft, aRight, aLineColor );
-}
-
 void SwPageFrm::PaintBreak( ) const
 {
     if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
@@ -3503,8 +3491,6 @@ void SwPageFrm::PaintDecorators( ) const
                  !pGlobalShell->IsPreView() &&
                  pGlobalShell->IsShowHeaderFooterSeparator( ) )
             {
-                drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
-
                 // Header
                 const SwFrm* pHeaderFrm = Lower();
                 if ( !pHeaderFrm->IsHeaderFrm() )
@@ -3517,9 +3503,6 @@ void SwPageFrm::PaintDecorators( ) const
                 Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff ) );
                 rEditWin.SetHeaderFooterControl( this, true, nOutputOff );
 
-                pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
-                            this, double( nHeaderYOff ) ) );
-
                 // Footer
                 const SwFrm* pFtnContFrm = Lower();
                 while ( pFtnContFrm->GetNext() )
@@ -3532,11 +3515,6 @@ void SwPageFrm::PaintDecorators( ) const
                 long nFooterYOff = aBodyRect.Bottom();
                 nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff ) );
                 rEditWin.SetHeaderFooterControl( this, false, nOutputOff );
-
-                pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
-                            this, double( nFooterYOff ) ) );
-
-                delete pProcessor;
             }
         }
     }
diff --git a/sw/source/ui/docvw/DashedLine.cxx b/sw/source/ui/docvw/DashedLine.cxx
new file mode 100644
index 0000000..a4a09da
--- /dev/null
+++ b/sw/source/ui/docvw/DashedLine.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 SUSE <cbosdonnat at suse.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <DashedLine.hxx>
+
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <vcl/svapp.hxx>
+
+SwDashedLine::SwDashedLine( Window* pParent, const basegfx::BColor& rColor ) :
+    FixedLine( pParent, WB_DIALOGCONTROL | WB_HORZ ),
+    m_aColor( rColor )
+{
+}
+
+SwDashedLine::~SwDashedLine( )
+{
+}
+
+void SwDashedLine::Paint( const Rectangle& )
+{
+    const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
+    drawinglayer::processor2d::BaseProcessor2D * pProcessor =
+        sdr::contact::createBaseProcessor2DFromOutputDevice(
+                    *this, aNewViewInfos );
+
+    // Compute the start and end points
+    const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+    double nHalfWidth = double( aRect.Top() + aRect.Bottom() ) / 2.0;
+
+    basegfx::B2DPoint aStart( double( aRect.Left() ), nHalfWidth );
+    basegfx::B2DPoint aEnd( double( aRect.Right() ), nHalfWidth );
+
+    basegfx::B2DPolygon aPolygon;
+    aPolygon.append( aStart );
+    aPolygon.append( aEnd );
+
+    drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
+
+    const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+
+    std::vector< double > aStrokePattern;
+    basegfx::BColor aColor = m_aColor;
+    if ( rSettings.GetHighContrastMode( ) )
+    {
+        // Only a solid line in high contrast mode
+        aColor = rSettings.GetDialogTextColor().getBColor();
+    }
+    else
+    {
+        // Get a color for the contrast
+        basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor );
+        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 );
+        const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
+
+        // Compute the plain line
+        drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
+            new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+                    aPolygon, aOtherColor );
+
+        aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
+        // Dashed line in twips
+        aStrokePattern.push_back( 3 );
+        aStrokePattern.push_back( 3 );
+
+        aSeq.realloc( 2 );
+    }
+
+    // Compute the dashed line primitive
+    drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
+            new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
+                basegfx::B2DPolyPolygon( aPolygon ),
+                drawinglayer::attribute::LineAttribute( m_aColor ),
+                drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
+
+    aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+
+    pProcessor->process( aSeq );
+    delete pProcessor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index a706639..f1eb77a 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -33,6 +33,7 @@
 #include <svtools/svtools.hrc>
 
 #include <cmdid.h>
+#include <DashedLine.hxx>
 #include <docsh.hxx>
 #include <edtwin.hxx>
 #include <fmthdft.hxx>
@@ -143,7 +144,8 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
     m_pPageFrm( pPageFrm ),
     m_bIsHeader( bHeader ),
     m_bReadonly( false ),
-    m_pPopupMenu( NULL )
+    m_pPopupMenu( NULL ),
+    m_pLine( NULL )
 {
     // Define the readonly member
     const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
@@ -163,6 +165,10 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
     sal_Int32 nPos = m_sLabel.lastIndexOf( rtl::OUString::createFromAscii( "%1" ) );
     m_sLabel = m_sLabel.replaceAt( nPos, 2, m_pPageFrm->GetPageDesc()->GetName() );
 
+    // Create the line control
+    basegfx::BColor aColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
+    m_pLine = new SwDashedLine( m_pEditWin, aColor );
+
     // Create and set the PopupMenu
     m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
 
@@ -184,9 +190,10 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
 SwHeaderFooterWin::~SwHeaderFooterWin( )
 {
     delete m_pPopupMenu;
+    delete m_pLine;
 }
 
-void SwHeaderFooterWin::SetOffset( Point aOffset )
+void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd )
 {
     // Compute the text size and get the box position & size from it
     Rectangle aTextRect;
@@ -205,6 +212,19 @@ void SwHeaderFooterWin::SetOffset( Point aOffset )
 
     // Set the position & Size of the window
     SetPosSizePixel( aBoxPos, aBoxSize );
+
+    double nYLinePos = aBoxPos.Y();
+    if ( !m_bIsHeader )
+        nYLinePos += aBoxSize.Height();
+    Point aLinePos( nXLineStart, nYLinePos );
+    Size aLineSize( nXLineEnd - nXLineStart, 1 );
+    m_pLine->SetPosSizePixel( aLinePos, aLineSize );
+}
+
+void SwHeaderFooterWin::ShowAll( bool bShow )
+{
+    Show( bShow );
+    m_pLine->Show( bShow );
 }
 
 void SwHeaderFooterWin::Paint( const Rectangle& )
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index f2e2e89..3c29c27 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5777,10 +5777,13 @@ void SwEditWin::SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader,
         pControl.swap( pNewControl );
         aHeadFootControls.push_back( pControl );
     }
-    pControl->SetOffset( aOffset );
+
+    Rectangle aPageRect = LogicToPixel( pPageFrm->Frm().SVRect() );
+
+    pControl->SetOffset( aOffset, aPageRect.Left(), aPageRect.Right() );
 
     if ( !pControl->IsVisible() )
-        pControl->Show( );
+        pControl->ShowAll( true );
 }
 
 void SwEditWin::RemoveHeaderFooterControls( const SwPageFrm* pPageFrm )
@@ -5795,7 +5798,7 @@ void SwEditWin::HideHeaderFooterControls( )
     std::vector< boost::shared_ptr< SwHeaderFooterWin > >::iterator pIt = aHeadFootControls.begin();
     while ( pIt != aHeadFootControls.end() )
     {
-        ( *pIt )->Hide();
+        ( *pIt )->ShowAll( false );
         ++pIt;
     }
 }
diff --git a/sw/source/ui/inc/DashedLine.hxx b/sw/source/ui/inc/DashedLine.hxx
new file mode 100644
index 0000000..671024a
--- /dev/null
+++ b/sw/source/ui/inc/DashedLine.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 SUSE <cbosdonnat at suse.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _DASHEDLINE_HXX
+#define _DASHEDLINE_HXX
+
+#include <basegfx/color/bcolor.hxx>
+#include <vcl/fixed.hxx>
+
+/** Class for displaying a dashed line in the Writer GUI.
+  */
+class SwDashedLine : public FixedLine
+{
+    basegfx::BColor m_aColor;
+
+public:
+    SwDashedLine( Window* pParent, const basegfx::BColor& rColor );
+    ~SwDashedLine( );
+
+    virtual void Paint( const Rectangle& rRect );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index 50af8fd..c59211d 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -45,17 +45,20 @@ class SwHeaderFooterWin : public MenuButton
     bool                  m_bIsHeader;
     bool                  m_bReadonly;
     PopupMenu*            m_pPopupMenu;
+    Window*               m_pLine;
 
 public:
     SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader );
     ~SwHeaderFooterWin( );
 
-    void SetOffset( Point aOffset );
+    void SetOffset( Point aOffset, long nXLineStart, long nXLineEnd );
 
     virtual void Paint( const Rectangle& rRect );
     virtual void MouseButtonDown( const MouseEvent& rMEvt );
     virtual void Select( );
 
+    void ShowAll( bool bShow );
+
     bool IsHeader() { return m_bIsHeader; };
     bool IsEmptyHeaderFooter( );
     const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };


More information about the Libreoffice-commits mailing list