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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon Sep 12 13:54:29 PDT 2011


 sw/source/core/layout/paintfrm.cxx     |   19 ---
 sw/source/ui/docvw/HeaderFooterWin.cxx |  187 ++++++++++++---------------------
 sw/source/ui/inc/HeaderFooterWin.hxx   |   12 --
 3 files changed, 81 insertions(+), 137 deletions(-)

New commits:
commit 6b6e6b8dbc71b56a1833e5dd6e1b2a2f9943ff87
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 12 22:49:43 2011 +0200

    Header/Footer: the whole separator tab is now a menu button

diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index c8e18f8..65b4176 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -102,32 +102,20 @@ namespace
     }
 }
 
-class SwHeaderFooterButton : public MenuButton
-{
-    SwHeaderFooterWin* m_pWindow;
-    PopupMenu*         m_pPopupMenu;
-
-    public:
-        SwHeaderFooterButton( SwHeaderFooterWin* pWindow );
-        ~SwHeaderFooterButton( );
-
-        // overloaded <MenuButton> methods
-        virtual void Select();
-
-        // overloaded <Window> methods
-        virtual void Paint( const Rectangle& rRect );
-        virtual void MouseButtonDown( const MouseEvent& rMEvt );
-};
-
 
 SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
-    Window( pEditWin, WB_DIALOGCONTROL  ),
+    MenuButton( pEditWin, WB_DIALOGCONTROL  ),
     m_pEditWin( pEditWin ),
     m_sLabel( ),
     m_pPageFrm( pPageFrm ),
     m_bIsHeader( bHeader ),
-    m_pButton( NULL )
+    m_bReadonly( false ),
+    m_pPopupMenu( NULL )
 {
+    // Define the readonly member
+    const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
+    m_bReadonly = pViewOpt->IsReadonly();
+
     // Get the font and configure it
     Font aFont = GetSettings().GetStyleSettings().GetToolFont();
     SetZoomedPointFont( aFont );
@@ -141,25 +129,28 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
         m_sLabel = ResId::toString( SW_RES( STR_FOOTER_TITLE ) );
     sal_Int32 nPos = m_sLabel.lastIndexOf( rtl::OUString::createFromAscii( "%1" ) );
     m_sLabel = m_sLabel.replaceAt( nPos, 2, m_pPageFrm->GetPageDesc()->GetName() );
-}
 
-SwHeaderFooterWin::~SwHeaderFooterWin( )
-{
-    delete m_pButton;
-}
+    // Create and set the PopupMenu
+    m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
 
-MenuButton* SwHeaderFooterWin::GetMenuButton()
-{
-    if ( !m_pButton )
-    {
-        m_pButton = new SwHeaderFooterButton( this );
+    // Rewrite the menu entries' text
+    String sType = SW_RESSTR( STR_FOOTER );
+    if ( m_bIsHeader )
+        sType = SW_RESSTR( STR_HEADER );
+    SwRewriter aRewriter;
+    aRewriter.AddRule( String::CreateFromAscii( "$1" ), sType );
 
-        // Don't blindly show it: check for readonly document
-        const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
-        m_pButton->Show( !pViewOpt->IsReadonly() );
-    }
+    String aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_EDIT );
+    m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, aRewriter.Apply( aText ) );
 
-    return m_pButton;
+    aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_DELETE );
+    m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, aRewriter.Apply( aText ) );
+    SetPopupMenu( m_pPopupMenu );
+}
+
+SwHeaderFooterWin::~SwHeaderFooterWin( )
+{
+    delete m_pPopupMenu;
 }
 
 void SwHeaderFooterWin::SetOffset( Point aOffset )
@@ -181,11 +172,6 @@ void SwHeaderFooterWin::SetOffset( Point aOffset )
 
     // Set the position & Size of the window
     SetPosSizePixel( aBoxPos, aBoxSize );
-
-    // Set the button position and size
-    Point aBtnPos( aBoxSize.getWidth() - BUTTON_WIDTH, 0 );
-    Size aBtnSize( BUTTON_WIDTH, aBoxSize.getHeight() );
-    GetMenuButton()->SetPosSizePixel( aBtnPos, aBtnSize );
 }
 
 void SwHeaderFooterWin::Paint( const Rectangle& )
@@ -201,6 +187,45 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
     SetTextColor( Color( aLineColor ) );
     DrawText( aTextPos, String( m_sLabel ) );
+
+    // Paint the symbol if not readonly button
+    if ( !m_bReadonly )
+    {
+        Point aPicPos( aRect.getWidth() - BUTTON_WIDTH, 0 );
+        Size aPicSize( BUTTON_WIDTH, aRect.getHeight() );
+        Rectangle aSymbolRect( aPicPos, aPicSize );
+
+        if ( IsEmptyHeaderFooter( ) )
+        {
+            SvtResId id( BMP_LIST_ADD );
+            Image aPlusImg( id );
+            Size aSize = aPlusImg.GetSizePixel();
+            Point aPt = aSymbolRect.TopLeft();
+            long nXOffset = ( aSymbolRect.GetWidth() - aSize.Width() ) / 2;
+            long nYOffset = ( aSymbolRect.GetHeight() - aSize.Height() ) / 2;
+            aPt += Point( nXOffset, nYOffset );
+            DrawImage(aPt, aPlusImg);
+        }
+        else
+        {
+            // 25% distance to the left and right button border
+            const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
+            aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
+            aSymbolRect.Right()-=nBorderDistanceLeftAndRight;
+            // 30% distance to the top button border
+            const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*300)+500)/1000;
+            aSymbolRect.Top()+=nBorderDistanceTop;
+            // 25% distance to the bottom button border
+            const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*250)+500)/1000;
+            aSymbolRect.Bottom()-=nBorderDistanceBottom;
+
+            DecorationView aDecoView( this );
+            aDecoView.DrawSymbol( aSymbolRect, SYMBOL_SPIN_DOWN,
+                                  ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()
+                                    ? Color( COL_WHITE )
+                                    : Color( COL_BLACK ) ) );
+        }
+    }
 }
 
 bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
@@ -281,94 +306,24 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
 
 void SwHeaderFooterWin::SetReadonly( bool bReadonly )
 {
-    if ( bReadonly )
-        m_pButton->Hide();
-    else
-        m_pButton->Show();
+    m_bReadonly = bReadonly;
     Update();
 }
 
-SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
-    MenuButton( pWindow ),
-    m_pWindow( pWindow )
-{
-    // Create and set the PopupMenu
-    m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
-
-    // Rewrite the menu entries' text
-    String sType = SW_RESSTR( STR_FOOTER );
-    if ( m_pWindow->IsHeader() )
-        sType = SW_RESSTR( STR_HEADER );
-    SwRewriter aRewriter;
-    aRewriter.AddRule( String::CreateFromAscii( "$1" ), sType );
-
-    String aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_EDIT );
-    m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, aRewriter.Apply( aText ) );
-
-    aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_DELETE );
-    m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, aRewriter.Apply( aText ) );
-
-    SetPopupMenu( m_pPopupMenu );
-}
-
-SwHeaderFooterButton::~SwHeaderFooterButton( )
-{
-    delete m_pPopupMenu;
-}
-
-void SwHeaderFooterButton::Paint( const Rectangle& )
-{
-    const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
-
-    lcl_DrawBackground( this, aRect, m_pWindow->IsHeader() );
-
-    Rectangle aSymbolRect( aRect );
-    // 25% distance to the left and right button border
-    const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
-    aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
-    aSymbolRect.Right()-=nBorderDistanceLeftAndRight;
-    // 30% distance to the top button border
-    const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*300)+500)/1000;
-    aSymbolRect.Top()+=nBorderDistanceTop;
-    // 25% distance to the bottom button border
-    const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*250)+500)/1000;
-    aSymbolRect.Bottom()-=nBorderDistanceBottom;
-
-    if ( m_pWindow->IsEmptyHeaderFooter( ) )
-    {
-        SvtResId id( BMP_LIST_ADD );
-        Image aPlusImg( id );
-        Size aSize = aPlusImg.GetSizePixel();
-        Point aPt = aRect.TopLeft();
-        long nXOffset = ( aRect.GetWidth() - aSize.Width() ) / 2;
-        long nYOffset = ( aRect.GetHeight() - aSize.Height() ) / 2;
-        aPt += Point( nXOffset, nYOffset );
-        DrawImage(aPt, aPlusImg);
-    }
-    else
-    {
-        DecorationView aDecoView( this );
-        aDecoView.DrawSymbol( aSymbolRect, SYMBOL_SPIN_DOWN,
-                              ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()
-                                ? Color( COL_WHITE )
-                                : Color( COL_BLACK ) ) );
-    }
-}
-
-void SwHeaderFooterButton::MouseButtonDown( const MouseEvent& rMEvt )
+void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
 {
-    if ( m_pWindow->IsEmptyHeaderFooter( ) )
+    if ( IsEmptyHeaderFooter( ) )
     {
         // Add the header / footer
-        m_pWindow->ChangeHeaderOrFooter( true );
+        ChangeHeaderOrFooter( true );
     }
     else
         MenuButton::MouseButtonDown( rMEvt );
 }
 
-void SwHeaderFooterButton::Select( )
+void SwHeaderFooterWin::Select( )
 {
-    m_pWindow->ExecuteCommand( GetCurItemId() );
+    ExecuteCommand( GetCurItemId() );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index e7d4d65..f805be2 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -33,20 +33,19 @@
 #include <vcl/menubtn.hxx>
 #include <vcl/window.hxx>
 
-class SwHeaderFooterButton;
-
 /** Class for the header and footer separator control window.
 
     This control is showing the header / footer style name and provides
     a few useful actions to the user.
   */
-class SwHeaderFooterWin : public Window
+class SwHeaderFooterWin : public MenuButton
 {
     SwEditWin*            m_pEditWin;
     rtl::OUString         m_sLabel;
     const SwPageFrm*      m_pPageFrm;
     bool                  m_bIsHeader;
-    SwHeaderFooterButton* m_pButton;
+    bool                  m_bReadonly;
+    PopupMenu*            m_pPopupMenu;
 
 public:
     SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader );
@@ -55,6 +54,8 @@ public:
     void SetOffset( Point aOffset );
 
     virtual void Paint( const Rectangle& rRect );
+    virtual void MouseButtonDown( const MouseEvent& rMEvt );
+    virtual void Select( );
 
     bool IsHeader() { return m_bIsHeader; };
     bool IsEmptyHeaderFooter( );
@@ -64,9 +65,6 @@ public:
     void ExecuteCommand(sal_uInt16 nSlot);
 
     void SetReadonly( bool bReadonly );
-
-private:
-    MenuButton* GetMenuButton( );
 };
 
 #endif
commit f189e7275dece893a942a9533ce5380d71127df0
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 12 21:54:32 2011 +0200

    Header/Footer: forgot to remove a sequence realloc

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e0f1c81..38247ed 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3286,9 +3286,6 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
 
     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
 
-    // Only draw the dashed line for unexisting header / footers
-    aSeq.realloc( 4 );
-
     // Dashed line in twips
     std::vector< double > aStrokePattern;
     aStrokePattern.push_back( 40 );
commit 053d4c9c7a268dcee5667b6905a8fd946c9bdae9
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Mon Sep 12 21:08:50 2011 +0200

    Header/Footer: small painting improvements
    
    The dashed line is now 1px wide and has smaller dashes. The separator
    button has also smaller padding.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index f384bcc..e0f1c81 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3275,8 +3275,6 @@ void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
     }
 }
 
-#define LINE_HALF_THICKNESS 10
-
 drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPrimitives(
         const SwPageFrm* pPageFrm, double nLineY )
 {
@@ -3293,8 +3291,8 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
 
     // Dashed line in twips
     std::vector< double > aStrokePattern;
-    aStrokePattern.push_back( 110 );
-    aStrokePattern.push_back( 110 );
+    aStrokePattern.push_back( 40 );
+    aStrokePattern.push_back( 40 );
 
 
     // Compute the dashed line primitive
@@ -3302,11 +3300,10 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
     aLinePolygon.append( aLeft );
     aLinePolygon.append( aRight );
 
-    double nThickness = double( LINE_HALF_THICKNESS ) * 2;
     drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
             new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
                 basegfx::B2DPolyPolygon( aLinePolygon ),
-                drawinglayer::attribute::LineAttribute( aLineColor, nThickness ),
+                drawinglayer::attribute::LineAttribute( aLineColor ),
                 drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
 
     aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
@@ -3408,9 +3405,6 @@ void SwPageFrm::PaintDecorators( ) const
             {
                 drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
 
-                // Line thickness in px
-                long nHalfThickness = pGlobalShell->GetOut()->LogicToPixel( Point( 0, LINE_HALF_THICKNESS ) ).Y();
-
                 // Header
                 const SwFrm* pHeaderFrm = Lower();
                 if ( !pHeaderFrm->IsHeaderFrm() )
@@ -3420,7 +3414,7 @@ void SwPageFrm::PaintDecorators( ) const
                 long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
 
                 long nHeaderYOff = aBodyRect.Top();
-                Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) );
+                Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff ) );
                 rEditWin.SetHeaderFooterControl( this, true, nOutputOff );
 
                 pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
@@ -3436,7 +3430,7 @@ void SwPageFrm::PaintDecorators( ) const
                 }
 
                 long nFooterYOff = aBodyRect.Bottom();
-                nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) );
+                nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff ) );
                 rEditWin.SetHeaderFooterControl( this, false, nOutputOff );
 
                 pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 2f9a99c..c8e18f8 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -51,7 +51,7 @@
 #include <vcl/menubtn.hxx>
 #include <vcl/svapp.hxx>
 
-#define TEXT_PADDING 7
+#define TEXT_PADDING 5
 #define BOX_DISTANCE 10
 #define BUTTON_WIDTH 18
 


More information about the Libreoffice-commits mailing list