sw/inc/crsrsh.hxx | 1 sw/inc/viewsh.hxx | 21 +++- sw/source/core/crsr/crsrsh.cxx | 23 +++- sw/source/core/inc/pagefrm.hxx | 5 - sw/source/core/layout/pagechg.cxx | 22 +++- sw/source/core/layout/paintfrm.cxx | 47 +++++---- sw/source/core/view/viewsh.cxx | 21 +++- sw/source/core/view/vnew.cxx | 9 + sw/source/ui/docvw/FrameControlsManager.cxx | 9 + sw/source/ui/docvw/HeaderFooterWin.cxx | 19 +++- sw/source/ui/docvw/PageBreakWin.cxx | 132 +++++++++++----------------- sw/source/ui/docvw/edtwin.cxx | 121 +++++++++++++------------ sw/source/ui/inc/FrameControl.hxx | 4 sw/source/ui/inc/FrameControlsManager.hxx | 11 -- sw/source/ui/inc/HeaderFooterWin.hxx | 3 sw/source/ui/inc/PageBreakWin.hxx | 7 + sw/source/ui/inc/edtwin.hxx | 14 +- sw/source/ui/inc/wrtsh.hxx | 2 sw/source/ui/wrtsh/wrtsh1.cxx | 6 - 19 files changed, 267 insertions(+), 210 deletions(-)
New commits: commit 6e3d9d601cf7a9f20a93eb8fc9abf5d8464eec28 Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Thu Jan 5 11:34:49 2012 +0100 Page Break: center the tab on the mouse and remove click on the line diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index b16e51f..f954b6e 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -125,7 +125,6 @@ namespace m_pWin( pWin ) {}; virtual void MouseMove( const MouseEvent& rMEvt ); - virtual void MouseButtonDown( const MouseEvent& rMEvt ); }; void SwBreakDashedLine::MouseMove( const MouseEvent& rMEvt ) @@ -148,16 +147,6 @@ namespace m_pWin->UpdatePosition( pPtr ); } } - - void SwBreakDashedLine::MouseButtonDown( const MouseEvent& rMEvt ) - { - sal_uInt16 nItemId = m_pWin->GetPopupMenu()->Execute( this, rMEvt.GetPosPixel() ); - if ( nItemId ) - { - m_pWin->SetCurItemId( nItemId ); - m_pWin->Select(); - } - } } SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) : @@ -452,14 +441,10 @@ void SwPageBreakWin::UpdatePosition( const Point* pEvtPt ) if ( m_pMousePt ) { - nBtnLeft = nLineLeft + m_pMousePt->X(); + nBtnLeft = nLineLeft + m_pMousePt->X() - aBtnSize.getWidth() / 2; - if ( Application::GetSettings().GetLayoutRTL() ) - { - nBtnLeft -= aBtnSize.getWidth(); - if ( nBtnLeft < nLineLeft ) - nBtnLeft = nLineLeft; - } + if ( nBtnLeft < nLineLeft ) + nBtnLeft = nLineLeft; else if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight ) nBtnLeft = nLineRight - aBtnSize.getWidth(); } commit c17724737cc54fbecb32c510c437c4fda045d94b Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Wed Jan 4 21:54:05 2012 +0100 Page Break: fixed position of tab in RTL and added dirty hack for freezes diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index aa1085c..b16e51f 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -142,8 +142,11 @@ namespace m_pWin->Fade( true ); } - Point* pPtr = new Point( rMEvt.GetPosPixel() ); - m_pWin->UpdatePosition( pPtr ); + if ( !rMEvt.IsSynthetic() ) + { + Point* pPtr = new Point( rMEvt.GetPosPixel() ); + m_pWin->UpdatePosition( pPtr ); + } } void SwBreakDashedLine::MouseButtonDown( const MouseEvent& rMEvt ) @@ -450,7 +453,14 @@ void SwPageBreakWin::UpdatePosition( const Point* pEvtPt ) if ( m_pMousePt ) { nBtnLeft = nLineLeft + m_pMousePt->X(); - if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight ) + + if ( Application::GetSettings().GetLayoutRTL() ) + { + nBtnLeft -= aBtnSize.getWidth(); + if ( nBtnLeft < nLineLeft ) + nBtnLeft = nLineLeft; + } + else if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight ) nBtnLeft = nLineRight - aBtnSize.getWidth(); } commit a0347a9b94e2dc4ee1906341aa187d6a9f7749af Author: Cédric Bosdonnat <cedric.bosdonnat....@free.fr> Date: Wed Jan 4 09:33:44 2012 +0100 Page Break: show the page break right under the mouse diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index 94b314c..aa1085c 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -68,59 +68,22 @@ using namespace drawinglayer::primitive2d; namespace { - static B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bMirror ) + static B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds ) { B2DPolygon aRetval; const double nRadius = 1; const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); - // Create the top left corner - { - B2DPoint aTLCorner = aBounds.getMinimum(); - B2DPoint aStart( 0.0, nRadius ); - B2DPoint aEnd( nRadius, 0.0 ); - aRetval.append( aStart ); - aRetval.appendBezierSegment( - interpolate( aStart, aTLCorner, nKappa ), - interpolate( aEnd, aTLCorner, nKappa ), - aEnd ); - } - - // Create the top right angle - { - B2DPoint aTMCorner( aBounds.getWidth() - ARROW_WIDTH, 0.0 ); - B2DPoint aStart = aTMCorner + B2DVector( - nRadius, 0.0 ); - B2DVector aEndVect( double( ARROW_WIDTH ), aBounds.getHeight() / 2.0 ); - aEndVect.setLength( nRadius ); - B2DPoint aEnd = aTMCorner + aEndVect; - aRetval.append( aStart ); - aRetval.appendBezierSegment( - interpolate( aStart, aTMCorner, nKappa ), - interpolate( aEnd, aTMCorner, nKappa ), - aEnd ); - } - - // Create the right corner + // Create the top right corner { - B2DPoint aMRCorner( aBounds.getWidth(), aBounds.getHeight() / 2.0 ); - B2DVector aStartVect( double( - ARROW_WIDTH ), - aBounds.getHeight() / 2.0 ); - aStartVect.setLength( nRadius ); - B2DPoint aStart = aMRCorner + aStartVect; - B2DVector aEndVect( double( - ARROW_WIDTH ), aBounds.getHeight() / 2.0 ); - aEndVect.setLength( nRadius ); - B2DPoint aEnd = aMRCorner + aEndVect; - aRetval.append( aStart ); - aRetval.appendBezierSegment( - interpolate( aStart, aMRCorner, nKappa ), - interpolate( aEnd, aMRCorner, nKappa ), - aEnd ); + B2DPoint aTMCorner( aBounds.getWidth(), 0.0 ); + aRetval.append( aTMCorner ); } - // Create the bottom right angle + // Create the bottom right corner { - B2DPoint aBMCorner( aBounds.getWidth() - ARROW_WIDTH, aBounds.getHeight() ); - B2DVector aStartVect( double( ARROW_WIDTH ), - aBounds.getHeight() / 2.0 ); - aStartVect.setLength( nRadius ); + B2DPoint aBMCorner( aBounds.getWidth(), aBounds.getHeight() ); + B2DVector aStartVect( 0.0, - nRadius ); B2DPoint aStart = aBMCorner + aStartVect; B2DPoint aEnd = aBMCorner + B2DVector( - nRadius, 0.0 ); aRetval.append( aStart ); @@ -142,13 +105,10 @@ namespace aEnd ); } - aRetval.setClosed( true ); - - if ( bMirror ) + // Create the top left corner { - B2DHomMatrix bRotMatrix = createRotateAroundPoint( - aBounds.getCenterX(), aBounds.getCenterY(), M_PI ); - aRetval.transform( bRotMatrix ); + B2DPoint aTLCorner = aBounds.getMinimum(); + aRetval.append( aTLCorner ); } return aRetval; @@ -178,7 +138,12 @@ namespace m_pWin->Fade( false ); } else if ( !m_pWin->IsVisible() ) + { m_pWin->Fade( true ); + } + + Point* pPtr = new Point( rMEvt.GetPosPixel() ); + m_pWin->UpdatePosition( pPtr ); } void SwBreakDashedLine::MouseButtonDown( const MouseEvent& rMEvt ) @@ -199,7 +164,8 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) m_pLine( NULL ), m_bIsAppearing( false ), m_nFadeRate( 100 ), - m_bDestroyed( false ) + m_bDestroyed( false ), + m_pMousePt( NULL ) { // Use pixels for the rest of the drawing SetMapMode( MapMode ( MAP_PIXEL ) ); @@ -223,6 +189,7 @@ SwPageBreakWin::~SwPageBreakWin( ) delete m_pPopupMenu; delete m_pLine; + delete m_pMousePt; } void SwPageBreakWin::Paint( const Rectangle& ) @@ -254,7 +221,7 @@ void SwPageBreakWin::Paint( const Rectangle& ) B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ), double( aRect.Right() ), double( aRect.Bottom( ) ) ); bool bMirror = ( bShowOnRight && !bRtl ) || ( !bShowOnRight && bRtl ); - B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bMirror ); + B2DPolygon aPolygon = lcl_CreatePolygon( aBRect ); // Create the polygon primitives aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( @@ -400,7 +367,7 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt ) if ( rMEvt.IsLeaveWindow() ) { // don't fade if we just move to the 'line', or the popup menu is open - Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() ); + Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() ); if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() ) Fade( false ); } @@ -432,8 +399,16 @@ bool SwPageBreakWin::ShowOnRight( ) return bOnRight; } -void SwPageBreakWin::UpdatePosition( ) +void SwPageBreakWin::UpdatePosition( const Point* pEvtPt ) { + if ( pEvtPt != NULL ) + { + if ( pEvtPt == m_pMousePt ) + return; + delete m_pMousePt; + m_pMousePt = pEvtPt; + } + const SwPageFrm* pPageFrm = GetPageFrame(); const SwFrm* pPrevPage = pPageFrm->GetPrev(); while ( pPrevPage && ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) ) ) @@ -470,18 +445,17 @@ void SwPageBreakWin::UpdatePosition( ) long nLineLeft = std::max( nPgLeft, aVisArea.Left() ); long nLineRight = std::min( nPgRight, aVisArea.Right() ); - long nBtnLeft = nPgLeft; + long nBtnLeft = nLineLeft; - if ( ShowOnRight( ) ) + if ( m_pMousePt ) { - long nRight = std::min( nPgRight + aBtnSize.getWidth() - ARROW_WIDTH / 2, aVisArea.Right() ); - nBtnLeft = nRight - aBtnSize.getWidth(); + nBtnLeft = nLineLeft + m_pMousePt->X(); + if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight ) + nBtnLeft = nLineRight - aBtnSize.getWidth(); } - else - nBtnLeft = std::max( nPgLeft - aBtnSize.Width() + ARROW_WIDTH / 2, aVisArea.Left() ); // Set the button position - Point aBtnPos( nBtnLeft, nYLineOffset - aBtnSize.Height() / 2 ); + Point aBtnPos( nBtnLeft, nYLineOffset + 1 ); SetPosSizePixel( aBtnPos, aBtnSize ); // Set the line position diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx index e1967f3..bd4eb64 100644 --- a/sw/source/ui/inc/PageBreakWin.hxx +++ b/sw/source/ui/inc/PageBreakWin.hxx @@ -48,6 +48,8 @@ class SwPageBreakWin : public MenuButton, public SwFrameControl Timer m_aFadeTimer; bool m_bDestroyed; + const Point* m_pMousePt; + public: SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ); ~SwPageBreakWin( ); @@ -57,7 +59,7 @@ public: virtual void MouseMove( const MouseEvent& rMEvt ); virtual void Activate( ); - void UpdatePosition( ); + void UpdatePosition( const Point* pEvtPt = NULL ); virtual void ShowAll( bool bShow ); virtual bool Contains( const Point &rDocPt ) const; commit 5fb10a076a9192f8f37f6936231b742bae9ca44a Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Mon Jan 2 10:58:12 2012 +0100 Page Breaks: avoid flickering of the tab by drawing it over the line diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index 3848208..94b314c 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -476,15 +476,9 @@ void SwPageBreakWin::UpdatePosition( ) { long nRight = std::min( nPgRight + aBtnSize.getWidth() - ARROW_WIDTH / 2, aVisArea.Right() ); nBtnLeft = nRight - aBtnSize.getWidth(); - if ( IsVisible() ) - nLineRight = nBtnLeft; } else - { nBtnLeft = std::max( nPgLeft - aBtnSize.Width() + ARROW_WIDTH / 2, aVisArea.Left() ); - if ( IsVisible() ) - nLineLeft = nBtnLeft + aBtnSize.Width(); - } // Set the button position Point aBtnPos( nBtnLeft, nYLineOffset - aBtnSize.Height() / 2 ); commit 0aff79354dc368e0c0a16070943b63c1ca91259d Author: Cédric Bosdonnat <cedric.bosdonnat....@free.fr> Date: Thu Jan 5 16:59:22 2012 +0100 Header/Footer: fix some bad indicators updates due to wrong call order diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 049a867..36fe86d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1315,22 +1315,22 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd ) return; // wenn nicht, dann kein Update !! } - if ( IsInHeaderFooter() != IsHeaderFooterEdit() ) - ToggleHeaderFooterEdit(); sal_Bool bInHeader= sal_True; if ( IsInHeaderFooter( &bInHeader ) ) { - if ( IsShowHeaderFooterSeparator( Header ) && !bInHeader ) + if ( !bInHeader ) { SetShowHeaderFooterSeparator( Footer, true ); SetShowHeaderFooterSeparator( Header, false ); } - else if ( IsShowHeaderFooterSeparator( Footer ) && bInHeader ) + else { SetShowHeaderFooterSeparator( Header, true ); SetShowHeaderFooterSeparator( Footer, false ); } } + if ( IsInHeaderFooter() != IsHeaderFooterEdit() ) + ToggleHeaderFooterEdit(); // #i27301# commit d3ea6fe7473049f421c1f72cde4bbd5c4c6348a9 Author: Cédric Bosdonnat <cedric.bosdonnat....@free.fr> Date: Wed Jan 4 20:42:17 2012 +0100 Header/Footer: switch cursor between header and footer using the cursor This fixes commit cce76e658af88813e17dea4f04388a29d7e582df. diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 0d1efa3..049a867 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1317,6 +1317,21 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd ) if ( IsInHeaderFooter() != IsHeaderFooterEdit() ) ToggleHeaderFooterEdit(); + sal_Bool bInHeader= sal_True; + if ( IsInHeaderFooter( &bInHeader ) ) + { + if ( IsShowHeaderFooterSeparator( Header ) && !bInHeader ) + { + SetShowHeaderFooterSeparator( Footer, true ); + SetShowHeaderFooterSeparator( Header, false ); + } + else if ( IsShowHeaderFooterSeparator( Footer ) && bInHeader ) + { + SetShowHeaderFooterSeparator( Header, true ); + SetShowHeaderFooterSeparator( Footer, false ); + } + } + // #i27301# SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this ); commit cdd2364f23f92a3f63a551aa883b99cadf0bcf28 Author: Jan Holesovsky <ke...@suse.cz> Date: Thu Dec 29 13:42:43 2011 +0100 Header/Footer: When editing, show only the appropriate conrol. Instead of showing both the header and footer controls, show only the footer-related if in footer, or header-related if in header. Signed-off-by: Stefan Knorr (Astron) <heinzless...@googlemail.com> Signed-off-by: Cor Nouws <oo...@nouenoff.nl> Signed-off-by: Michael Meeks <michael.me...@suse.com> diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index fd4a3d6..85b17a4 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -92,6 +92,12 @@ namespace vcl class OldStylePrintAdaptor; } +enum FrameControlType +{ + PageBreak, + Header, + Footer +}; // Define for flags needed in ctor or layers below. // Currently the PreView flag is needed for DrawPage. @@ -156,9 +162,10 @@ class SW_DLLPUBLIC ViewShell : public Ring sal_Bool bEnableSmooth :1; // Disable SmoothScroll, e.g. for drag // of scrollbars. sal_Bool bEndActionByVirDev:1; // Paints from EndAction always via virtual device - bool bShowHeaderFooterSeparator:1; - bool bHeaderFooterEdit:1; // (e.g. when browsing). + bool bShowHeaderSeparator:1; //< Flag to say that we are showing the header control + bool bShowFooterSeparator:1; //< Flag to say that we are showing the footer control + bool bHeaderFooterEdit:1; //< Flag to say that we are editing header or footer (according to the bShow(Header|Footer)Separator above) // boolean, indicating that class in in constructor. bool mbInConstructor:1; @@ -565,10 +572,12 @@ public: const SwPostItMgr* GetPostItMgr() const { return (const_cast<ViewShell*>(this))->GetPostItMgr(); } SwPostItMgr* GetPostItMgr(); - void ToggleHeaderFooterEdit( ); + /// Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags + void ToggleHeaderFooterEdit(); + /// Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags bool IsHeaderFooterEdit() const { return bHeaderFooterEdit; } - bool IsShowHeaderFooterSeparator() { return bShowHeaderFooterSeparator; } - virtual void SetShowHeaderFooterSeparator( bool bShow ) { bShowHeaderFooterSeparator = bShow; } + bool IsShowHeaderFooterSeparator( FrameControlType eControl ) { return (eControl == Header)? bShowHeaderSeparator: bShowFooterSeparator; } + virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) { if ( eControl == Header ) bShowHeaderSeparator = bShow; else bShowFooterSeparator = bShow; } }; //---- class CurrShell manages global ShellPointer ------------------- diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index bb55f6b..0d1efa3 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1316,7 +1316,7 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd ) } if ( IsInHeaderFooter() != IsHeaderFooterEdit() ) - ToggleHeaderFooterEdit( ); + ToggleHeaderFooterEdit(); // #i27301# SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this ); diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index 1e16a98..779c4cd 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -28,7 +28,7 @@ #ifndef _PAGEFRM_HXX #define _PAGEFRM_HXX - +#include <viewsh.hxx> #include <svl/svarray.hxx> #include "ftnboss.hxx" @@ -359,7 +359,8 @@ public: // in case this is am empty page, this function returns the 'reference' page const SwPageFrm& GetFormatPage() const; - bool IsOverHeaderFooterArea( const Point& rPt ) const; + /// If in header or footer area, it also indicates the exact area in rControl. + bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const; // return font used to paint the "empty page" string static const Font& GetEmptyPageFont(); diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 7e1c34f..79d7d1b 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -2449,7 +2449,7 @@ const SwPageFrm& SwPageFrm::GetFormatPage() const return *pRet; } -bool SwPageFrm::IsOverHeaderFooterArea( const Point& rPt ) const +bool SwPageFrm::IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const { long nUpperLimit = 0; long nLowerLimit = 0; @@ -2470,10 +2470,24 @@ bool SwPageFrm::IsOverHeaderFooterArea( const Point& rPt ) const SwRect aHeaderArea( Frm().TopLeft(), Size( Frm().Width(), nUpperLimit - Frm().Top() ) ); - SwRect aFooterArea( Point( Frm().Left(), nLowerLimit ), - Size( Frm().Width(), Frm().Bottom() - nLowerLimit ) ); + if ( aHeaderArea.IsInside( rPt ) ) + { + rControl = Header; + return true; + } + else + { + SwRect aFooterArea( Point( Frm().Left(), nLowerLimit ), + Size( Frm().Width(), Frm().Bottom() - nLowerLimit ) ); + + if ( aFooterArea.IsInside( rPt ) ) + { + rControl = Footer; + return true; + } + } - return aHeaderArea.IsInside( rPt ) || aFooterArea.IsInside( rPt ); + return false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 55a2b71..074a54a 100755 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3377,7 +3377,8 @@ void SwColumnFrm::PaintBreak( ) const // header/footer marker // * Non-printing characters are shown, as this is more consistent // with other formatting marks - if ( !pGlobalShell->IsShowHeaderFooterSeparator() && + if ( !pGlobalShell->IsShowHeaderFooterSeparator( Header ) && + !pGlobalShell->IsShowHeaderFooterSeparator( Footer ) && pGlobalShell->GetViewOptions( )->IsLineBreak( ) ) { SwRect aRect( pCnt->Prt() ); @@ -3469,36 +3470,42 @@ void SwPageFrm::PaintDecorators( ) const if ( pGlobalShell->GetOut()->GetOutDevType() != OUTDEV_PRINTER && !pGlobalShell->GetViewOptions()->IsPDFExport() && !pGlobalShell->IsPreView() && - pGlobalShell->IsShowHeaderFooterSeparator( ) ) + ( pGlobalShell->IsShowHeaderFooterSeparator( Header ) || + pGlobalShell->IsShowHeaderFooterSeparator( Footer ) ) ) { bool bRtl = Application::GetSettings().GetLayoutRTL(); - - // Header - const SwFrm* pHeaderFrm = Lower(); - if ( !pHeaderFrm->IsHeaderFrm() ) - pHeaderFrm = NULL; - const SwRect& rVisArea = pGlobalShell->VisArea(); long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() ); if ( bRtl ) nXOff = std::max( aBodyRect.Left(), rVisArea.Left() ); - long nHeaderYOff = aBodyRect.Top(); - Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff ) ); - rEditWin.GetFrameControlsManager().SetHeaderFooterControl( this, true, nOutputOff ); + // Header + if ( pGlobalShell->IsShowHeaderFooterSeparator( Header ) ) + { + const SwFrm* pHeaderFrm = Lower(); + if ( !pHeaderFrm->IsHeaderFrm() ) + pHeaderFrm = NULL; + + long nHeaderYOff = aBodyRect.Top(); + Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff ) ); + rEditWin.GetFrameControlsManager().SetHeaderFooterControl( this, Header, nOutputOff ); + } // Footer - const SwFrm* pFtnContFrm = Lower(); - while ( pFtnContFrm ) + if ( pGlobalShell->IsShowHeaderFooterSeparator( Footer ) ) { - if ( pFtnContFrm->IsFtnContFrm() ) - aBodyRect.AddBottom( pFtnContFrm->Frm().Bottom() - aBodyRect.Bottom() ); - pFtnContFrm = pFtnContFrm->GetNext(); - } + const SwFrm* pFtnContFrm = Lower(); + while ( pFtnContFrm ) + { + if ( pFtnContFrm->IsFtnContFrm() ) + aBodyRect.AddBottom( pFtnContFrm->Frm().Bottom() - aBodyRect.Bottom() ); + pFtnContFrm = pFtnContFrm->GetNext(); + } - long nFooterYOff = aBodyRect.Bottom(); - nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff ) ); - rEditWin.GetFrameControlsManager().SetHeaderFooterControl( this, false, nOutputOff ); + long nFooterYOff = aBodyRect.Bottom(); + Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff ) ); + rEditWin.GetFrameControlsManager().SetHeaderFooterControl( this, Footer, nOutputOff ); + } } } } diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 9e3bb9b..0413382 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -97,10 +97,20 @@ using namespace ::com::sun::star; void ViewShell::ToggleHeaderFooterEdit() { bHeaderFooterEdit = !bHeaderFooterEdit; - if ( bHeaderFooterEdit != IsShowHeaderFooterSeparator() ) - SetShowHeaderFooterSeparator( bHeaderFooterEdit ); + if ( !bHeaderFooterEdit ) + { + SetShowHeaderFooterSeparator( Header, false ); + SetShowHeaderFooterSeparator( Footer, false ); + } + + // Avoid corner case + if ( !IsShowHeaderFooterSeparator( Header ) && + !IsShowHeaderFooterSeparator( Footer ) ) + { + bHeaderFooterEdit = false; + } - // Repaint everything to update the colors of the selected area + // Repaint everything GetWin()->Invalidate(); } diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index 647e649..1234c4d 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -151,8 +151,9 @@ ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow, mpTmpRef( 0 ), pOpt( 0 ), pAccOptions( new SwAccessibilityOptions ), - bShowHeaderFooterSeparator( sal_False ), - bHeaderFooterEdit( sal_False ), + bShowHeaderSeparator( false ), + bShowFooterSeparator( false ), + bHeaderFooterEdit( false ), mpTargetPaintWindow(0), mpBufferedOut(0), pDoc( &rDocument ), @@ -219,7 +220,9 @@ ViewShell::ViewShell( ViewShell& rShell, Window *pWindow, mpTmpRef( 0 ), pOpt( 0 ), pAccOptions( new SwAccessibilityOptions ), - bHeaderFooterEdit( sal_False ), + bShowHeaderSeparator( false ), + bShowFooterSeparator( false ), + bHeaderFooterEdit( false ), mpTargetPaintWindow(0), mpBufferedOut(0), pDoc( rShell.GetDoc() ), diff --git a/sw/source/ui/docvw/FrameControlsManager.cxx b/sw/source/ui/docvw/FrameControlsManager.cxx index b59610a..5c00b58 100644 --- a/sw/source/ui/docvw/FrameControlsManager.cxx +++ b/sw/source/ui/docvw/FrameControlsManager.cxx @@ -157,11 +157,13 @@ void SwFrameControlsManager::SetReadonlyControls( bool bReadonly ) } } -void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset ) +void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, FrameControlType eType, Point aOffset ) { + OSL_ASSERT( eType == Header || eType == Footer ); + // Check if we already have the control SwFrameControlPtr pControl; - FrameControlType eType = bHeader? Header: Footer; + const bool bHeader = ( eType == Header ); vector< SwFrameControlPtr >& aControls = m_aControls[eType]; diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index ad50654..66b8fad 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -3810,9 +3810,12 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) // Are we moving from or to header / footer area? if ( !rSh.IsHeaderFooterEdit() ) { - bool bIsInHF = IsInHeaderFooter( aDocPt ); - if ( rSh.IsShowHeaderFooterSeparator() != bIsInHF ) - ShowHeaderFooterSeparator( bIsInHF ); + FrameControlType eControl; + bool bIsInHF = IsInHeaderFooter( aDocPt, eControl ); + if ( !bIsInHF ) + ShowHeaderFooterSeparator( false, false ); + else + ShowHeaderFooterSeparator( eControl == Header, eControl == Footer ); } } // no break; @@ -5649,37 +5652,51 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp( pQuickHlpData->Start( rSh, rWord.Len() ); } -void SwEditWin::ShowHeaderFooterSeparator( bool bShow ) +void SwEditWin::ShowHeaderFooterSeparator( bool bShowHeader, bool bShowFooter ) { SwWrtShell& rSh = rView.GetWrtShell(); - if ( rSh.IsShowHeaderFooterSeparator() != bShow ) + if ( ( rSh.IsShowHeaderFooterSeparator( Header ) != bShowHeader ) || + ( rSh.IsShowHeaderFooterSeparator( Footer ) != bShowFooter ) ) { - rSh.SetShowHeaderFooterSeparator( bShow ); + rSh.SetShowHeaderFooterSeparator( Header, bShowHeader ); + rSh.SetShowHeaderFooterSeparator( Footer, bShowFooter ); Invalidate(); } } -bool SwEditWin::IsInHeaderFooter( const Point &rDocPt ) const +bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const { SwWrtShell &rSh = rView.GetWrtShell(); const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt ); - if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt ) ) + if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt, rControl ) ) return true; - if ( rSh.IsShowHeaderFooterSeparator() ) + if ( rSh.IsShowHeaderFooterSeparator( Header ) || rSh.IsShowHeaderFooterSeparator( Footer ) ) { SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager(); Point aPoint( LogicToPixel( rDocPt ) ); - SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm ); - if ( pControl.get() && pControl->Contains( aPoint ) ) - return true; + if ( rSh.IsShowHeaderFooterSeparator( Header ) ) + { + SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm ); + if ( pControl.get() && pControl->Contains( aPoint ) ) + { + rControl = Header; + return true; + } + } - pControl = rMgr.GetControl( Footer, pPageFrm ); - if ( pControl.get() && pControl->Contains( aPoint ) ) - return true; + if ( rSh.IsShowHeaderFooterSeparator( Footer ) ) + { + SwFrameControlPtr pControl = rMgr.GetControl( Footer, pPageFrm ); + if ( pControl.get() && pControl->Contains( aPoint ) ) + { + rControl = Footer; + return true; + } + } } return false; diff --git a/sw/source/ui/inc/FrameControlsManager.hxx b/sw/source/ui/inc/FrameControlsManager.hxx index 8d5c426..06e618c 100644 --- a/sw/source/ui/inc/FrameControlsManager.hxx +++ b/sw/source/ui/inc/FrameControlsManager.hxx @@ -28,6 +28,7 @@ #ifndef _FRAMECONTROLSMANAGER_HXX #define _FRAMECONTROLSMANAGER_HXX +#include <viewsh.hxx> #include <FrameControl.hxx> #include <boost/shared_ptr.hpp> @@ -39,13 +40,6 @@ class SwPageFrm; class SwEditWin; -enum FrameControlType -{ - PageBreak, - Header, - Footer -}; - typedef boost::shared_ptr< SwFrameControl > SwFrameControlPtr; /** A container for the Header/Footer, or PageBreak controls. @@ -72,7 +66,7 @@ class SwFrameControlsManager void SetReadonlyControls( bool bReadonly ); // Helper methods - void SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset ); + void SetHeaderFooterControl( const SwPageFrm* pPageFrm, FrameControlType eType, Point aOffset ); void SetPageBreakControl( const SwPageFrm* pPageFrm ); }; diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx index ca87b89..1f03374 100644 --- a/sw/source/ui/inc/edtwin.hxx +++ b/sw/source/ui/inc/edtwin.hxx @@ -229,10 +229,10 @@ protected: SvxAutoCorrect* pACorr, sal_Bool bFromIME = sal_False ); /// Shows or hides the header & footer separators; only if there is a change. - void ShowHeaderFooterSeparator( bool bShow ); + void ShowHeaderFooterSeparator( bool bShowHeader, bool bShowFooter ); /// Returns true if in header/footer area, or in the header/footer control. - bool IsInHeaderFooter( const Point &rDocPt ) const; + bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const; public: void UpdatePointer(const Point &, sal_uInt16 nButtons = 0); diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 408da88..90e6296 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -491,7 +491,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)(); const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False); void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning); - virtual void SetShowHeaderFooterSeparator( bool bShow ); + virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ); private: diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index b67e433..d042c4d 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -1889,14 +1889,11 @@ void SwWrtShell::ChangeHeaderOrFooter( EndAllAction(); } -void SwWrtShell::SetShowHeaderFooterSeparator( bool bShow ) +void SwWrtShell::SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) { - ViewShell::SetShowHeaderFooterSeparator( bShow ); + ViewShell::SetShowHeaderFooterSeparator( eControl, bShow ); if ( !bShow ) - { - GetView().GetEditWin().GetFrameControlsManager().HideControls( Header ); - GetView().GetEditWin().GetFrameControlsManager().HideControls( Footer ); - } + GetView().GetEditWin().GetFrameControlsManager().HideControls( eControl ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 77ec56689230606281c60b945f3d5edc1e97d7f7 Author: Jan Holesovsky <ke...@suse.cz> Date: Wed Dec 28 20:01:57 2011 +0100 Header/Footer: Show / hide the control immediately. - When the mouse pointer enters or leaves the headers / footers, show or hide the header / footer control immediately. Waiting for that to appear is annoying; and similarly for disappearing - one usually ended up clicking the header / footer area to speed that up, and had a feeling of misbehaving. - Few related re-paint improvements Signed-off-by: Stefan Knorr (Astron) <heinzless...@googlemail.com> Signed-off-by: Cor Nouws <oo...@nouenoff.nl> Signed-off-by: Michael Meeks <michael.me...@suse.com> diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 18f1fde..b21e07d 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -495,6 +495,7 @@ public: void SetReadOnlyAvailable( sal_Bool bFlag ); sal_Bool IsOverReadOnlyPos( const Point& rPt ) const; + /// Is the rPt point in the header or footer area? sal_Bool IsOverHeaderFooterPos( const Point& rPt ) const; // Methods for aFlyMacroLnk. diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 241fb17..fd4a3d6 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -156,8 +156,8 @@ class SW_DLLPUBLIC ViewShell : public Ring sal_Bool bEnableSmooth :1; // Disable SmoothScroll, e.g. for drag // of scrollbars. sal_Bool bEndActionByVirDev:1; // Paints from EndAction always via virtual device - sal_Bool bShowHeaderFooterSeparator; - sal_Bool bHeaderFooterEdit; + bool bShowHeaderFooterSeparator:1; + bool bHeaderFooterEdit:1; // (e.g. when browsing). // boolean, indicating that class in in constructor. @@ -566,9 +566,9 @@ public: SwPostItMgr* GetPostItMgr(); void ToggleHeaderFooterEdit( ); - sal_Bool IsHeaderFooterEdit( ) const { return bHeaderFooterEdit; } - sal_Bool IsShowHeaderFooterSeparator( ) { return bShowHeaderFooterSeparator; } - virtual void SetShowHeaderFooterSeparator( sal_Bool bShow ) { bShowHeaderFooterSeparator = bShow; } + bool IsHeaderFooterEdit() const { return bHeaderFooterEdit; } + bool IsShowHeaderFooterSeparator() { return bShowHeaderFooterSeparator; } + virtual void SetShowHeaderFooterSeparator( bool bShow ) { bShowHeaderFooterSeparator = bShow; } }; //---- class CurrShell manages global ShellPointer ------------------- diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 5617665..bb55f6b 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -674,7 +674,7 @@ int SwCrsrShell::SetCrsr( const Point &rLPt, sal_Bool bOnlyText, bool bBlock ) // Toggle the Header/Footer mode if needed bool bInHeaderFooter = pFrm && ( pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() ); - if ( bInHeaderFooter ^ (bool) IsHeaderFooterEdit() ) + if ( bInHeaderFooter != IsHeaderFooterEdit() ) ToggleHeaderFooterEdit(); if( pBlockCrsr && bBlock ) @@ -1315,9 +1315,7 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd ) return; // wenn nicht, dann kein Update !! } - bool bInHeaderFooter = IsInHeaderFooter( ); - if ( ( bInHeaderFooter && !IsHeaderFooterEdit( ) ) || - ( !bInHeaderFooter && IsHeaderFooterEdit( ) ) ) + if ( IsInHeaderFooter() != IsHeaderFooterEdit() ) ToggleHeaderFooterEdit( ); // #i27301# diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 41f1443..9e3bb9b 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -94,11 +94,14 @@ TYPEINIT0(ViewShell); using namespace ::com::sun::star; -void ViewShell::ToggleHeaderFooterEdit( ) { +void ViewShell::ToggleHeaderFooterEdit() +{ bHeaderFooterEdit = !bHeaderFooterEdit; - SetShowHeaderFooterSeparator( bHeaderFooterEdit ); + if ( bHeaderFooterEdit != IsShowHeaderFooterSeparator() ) + SetShowHeaderFooterSeparator( bHeaderFooterEdit ); + // Repaint everything to update the colors of the selected area - Paint( VisArea().SVRect() ); + GetWin()->Invalidate(); } ////////////////////////////////////////////////////////////////////////////// diff --git a/sw/source/ui/docvw/FrameControlsManager.cxx b/sw/source/ui/docvw/FrameControlsManager.cxx index 40e461d..b59610a 100644 --- a/sw/source/ui/docvw/FrameControlsManager.cxx +++ b/sw/source/ui/docvw/FrameControlsManager.cxx @@ -161,8 +161,9 @@ void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, { // Check if we already have the control SwFrameControlPtr pControl; + FrameControlType eType = bHeader? Header: Footer; - vector< SwFrameControlPtr >& aControls = m_aControls[HeaderFooter]; + vector< SwFrameControlPtr >& aControls = m_aControls[eType]; vector< SwFrameControlPtr >::iterator pIt = aControls.begin(); while ( pIt != aControls.end() && !pControl.get() ) @@ -179,7 +180,7 @@ void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, SwFrameControlPtr pNewControl( new SwHeaderFooterWin( m_pEditWin, pPageFrm, bHeader ) ); const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions(); pNewControl->SetReadonly( pViewOpt->IsReadonly() ); - AddControl( HeaderFooter, pNewControl ); + AddControl( eType, pNewControl ); pControl.swap( pNewControl ); } diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index 180b975..ff7d50e 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -78,7 +78,7 @@ using namespace drawinglayer::primitive2d; namespace { - basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor ) + static basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor ) { basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor ); double nLuminance = aHslLine.getZ() * 2.5; @@ -90,7 +90,7 @@ namespace return basegfx::tools::hsl2rgb( aHslLine ); } - basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor ) + static basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor ) { basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor ); double nLuminance = aHslDark.getZ() * 255 + 20; @@ -98,7 +98,7 @@ namespace return basegfx::tools::hsl2rgb( aHslDark ); } - B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader ) + static B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader ) { const double nRadius = 3; const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); @@ -249,6 +249,19 @@ void SwHeaderFooterWin::ShowAll( bool bShow ) } } +bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const +{ + Rectangle aRect( GetPosPixel(), GetSizePixel() ); + if ( aRect.IsInside( rDocPt ) ) + return true; + + Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() ); + if ( aLineRect.IsInside( rDocPt ) ) + return true; + + return false; +} + void SwHeaderFooterWin::Paint( const Rectangle& ) { const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index 4799320..3848208 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -173,9 +173,8 @@ namespace if ( rMEvt.IsLeaveWindow() ) { // don't fade if we just move to the 'button' - Rectangle aRect( m_pWin->GetPosPixel(), m_pWin->GetSizePixel() ); Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() ); - if ( !aRect.IsInside( aEventPos ) ) + if ( !m_pWin->Contains( aEventPos ) ) m_pWin->Fade( false ); } else if ( !m_pWin->IsVisible() ) @@ -401,9 +400,8 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt ) if ( rMEvt.IsLeaveWindow() ) { // don't fade if we just move to the 'line', or the popup menu is open - Rectangle aRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() ); Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() ); - if ( !aRect.IsInside( aEventPos ) && !PopupMenu::IsInExecute() ) + if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() ) Fade( false ); } else if ( !IsVisible() ) @@ -503,6 +501,19 @@ void SwPageBreakWin::ShowAll( bool bShow ) m_pLine->Show( bShow ); } +bool SwPageBreakWin::Contains( const Point &rDocPt ) const +{ + Rectangle aRect( GetPosPixel(), GetSizePixel() ); + if ( aRect.IsInside( rDocPt ) ) + return true; + + Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() ); + if ( aLineRect.IsInside( rDocPt ) ) + return true; + + return false; +} + const SwPageFrm* SwPageBreakWin::GetPageFrame( ) { return static_cast< const SwPageFrm * >( GetFrame( ) ); diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 51fa548..ad50654 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -188,17 +188,17 @@ DBG_NAME(edithdl) namespace { - bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point aDocPos, sal_uInt16 nClicks ) + static bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point &rDocPos, sal_uInt16 nClicks ) { bool bRet = false; - sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( aDocPos ); + sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( rDocPos ); if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHdrFtr ) || ( !rSh.IsHeaderFooterEdit() && bOverHdrFtr ) ) { bRet = true; // Check if there we are in a FlyFrm - Point aPt( aDocPos ); + Point aPt( rDocPos ); SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() ); rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt ); @@ -209,7 +209,7 @@ namespace if ( nClicks == nNbClicks ) { - rSh.SwCrsrShell::SetCrsr( aDocPos ); + rSh.SwCrsrShell::SetCrsr( rDocPos ); bRet = false; } } @@ -1289,13 +1289,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) { SwWrtShell &rSh = rView.GetWrtShell(); - // Hide the header/footer separator if not editing a header of footer - if ( rSh.IsShowHeaderFooterSeparator( ) && !rSh.IsHeaderFooterEdit() ) - { - rSh.SetShowHeaderFooterSeparator( sal_False ); - aOverHeaderFooterTimer.Stop(); - } - if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE && pApplyTempl && pApplyTempl->pFormatClipboard ) { @@ -2626,23 +2619,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) { SwWrtShell &rSh = rView.GetWrtShell(); - // Hide the header/footer separator if not editing a header of footer - if ( rSh.IsShowHeaderFooterSeparator( ) && !rSh.IsHeaderFooterEdit() ) - { - const Point aDocPt( PixelToLogic( _rMEvt.GetPosPixel() ) ); - const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPt ); - if ( pPageFrm ) - { - bool bOverHeadFoot = pPageFrm->IsOverHeaderFooterArea( aDocPt ); - - if ( !bOverHeadFoot ) - { - rSh.SetShowHeaderFooterSeparator( sal_False ); - aOverHeaderFooterTimer.Stop(); - } - } - } - // We have to check if a context menu is shown and we have an UI // active inplace client. In that case we have to ignore the mouse // button down event. Otherwise we would crash (context menu has been @@ -3438,10 +3414,6 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) { MouseEvent rMEvt(_rMEvt); - // Mouse went out of the edit window: don't show the header/footer marker - if ( rMEvt.IsLeaveWindow() ) - aOverHeaderFooterTimer.Stop(); - //ignore key modifiers for format paintbrush { sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard @@ -3834,23 +3806,16 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) } else rView.GetPostItMgr()->SetShadowState(0,false); - // no break; - // Are we over a header or footer area? - const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPt ); - if ( pPageFrm ) + // Are we moving from or to header / footer area? + if ( !rSh.IsHeaderFooterEdit() ) { - bool bOverHeadFoot = pPageFrm->IsOverHeaderFooterArea( aDocPt ); - if ( bOverHeadFoot ) - aOverHeaderFooterTimer.Start(); - else - { - aOverHeaderFooterTimer.Stop(); - if ( !rSh.IsHeaderFooterEdit() && rSh.IsShowHeaderFooterSeparator() ) - aOverHeaderFooterTimer.Start(); - } + bool bIsInHF = IsInHeaderFooter( aDocPt ); + if ( rSh.IsShowHeaderFooterSeparator() != bIsInHF ) + ShowHeaderFooterSeparator( bIsInHF ); } } + // no break; case KEY_SHIFT: case KEY_MOD2: case KEY_MOD1: @@ -4610,9 +4575,6 @@ SwEditWin::SwEditWin(Window *pParent, SwView &rMyView): aKeyInputFlushTimer.SetTimeout( 200 ); aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler)); - aOverHeaderFooterTimer.SetTimeout( 1000 ); - aOverHeaderFooterTimer.SetTimeoutHdl(LINK(this, SwEditWin, OverHeaderFooterHandler)); - // TemplatePointer for colors should be resetted without // selection after single click aTemplateTimer.SetTimeout(400); @@ -5433,18 +5395,6 @@ IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG ) return 0; } -IMPL_LINK( SwEditWin, OverHeaderFooterHandler, Timer *, EMPTYARG ) -{ - if ( !GetView().GetWrtShell().IsHeaderFooterEdit() && IsMouseOver() ) - { - // Toggle the Header/Footer separator - sal_Bool bShown = GetView().GetWrtShell().IsShowHeaderFooterSeparator( ); - GetView().GetWrtShell().SetShowHeaderFooterSeparator( !bShown ); - Invalidate(); - } - return 0; -} - void SwEditWin::_InitStaticData() { pQuickHlpData = new QuickHelpData(); @@ -5699,6 +5649,42 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp( pQuickHlpData->Start( rSh, rWord.Len() ); } +void SwEditWin::ShowHeaderFooterSeparator( bool bShow ) +{ + SwWrtShell& rSh = rView.GetWrtShell(); + + if ( rSh.IsShowHeaderFooterSeparator() != bShow ) + { + rSh.SetShowHeaderFooterSeparator( bShow ); + Invalidate(); + } +} + +bool SwEditWin::IsInHeaderFooter( const Point &rDocPt ) const +{ + SwWrtShell &rSh = rView.GetWrtShell(); + const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt ); + + if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt ) ) + return true; + + if ( rSh.IsShowHeaderFooterSeparator() ) + { + SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager(); + Point aPoint( LogicToPixel( rDocPt ) ); + + SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm ); + if ( pControl.get() && pControl->Contains( aPoint ) ) + return true; + + pControl = rMgr.GetControl( Footer, pPageFrm ); + if ( pControl.get() && pControl->Contains( aPoint ) ) + return true; + } + + return false; +} + void SwEditWin::SetUseInputLanguage( sal_Bool bNew ) { if ( bNew || bUseInputLanguage ) diff --git a/sw/source/ui/inc/FrameControl.hxx b/sw/source/ui/inc/FrameControl.hxx index 4e52918..cf887a9 100644 --- a/sw/source/ui/inc/FrameControl.hxx +++ b/sw/source/ui/inc/FrameControl.hxx @@ -30,6 +30,7 @@ class SwEditWin; class SwFrm; +struct Point; /** Class representing a control linked to a SwFrm. */ @@ -61,6 +62,9 @@ public: virtual void SetReadonly( bool bReadonly ) = 0; virtual void ShowAll( bool bShow ) = 0; + + /// Returns true if the point is inside the control. + virtual bool Contains( const Point &rDocPt ) const = 0; }; #endif diff --git a/sw/source/ui/inc/FrameControlsManager.hxx b/sw/source/ui/inc/FrameControlsManager.hxx index c9e0aed..8d5c426 100644 --- a/sw/source/ui/inc/FrameControlsManager.hxx +++ b/sw/source/ui/inc/FrameControlsManager.hxx @@ -42,11 +42,14 @@ class SwEditWin; enum FrameControlType { PageBreak, - HeaderFooter + Header, + Footer }; typedef boost::shared_ptr< SwFrameControl > SwFrameControlPtr; +/** A container for the Header/Footer, or PageBreak controls. +*/ class SwFrameControlsManager { private: diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx index 247678e..c895b53 100644 --- a/sw/source/ui/inc/HeaderFooterWin.hxx +++ b/sw/source/ui/inc/HeaderFooterWin.hxx @@ -58,7 +58,8 @@ public: virtual void MouseButtonDown( const MouseEvent& rMEvt ); virtual void Select( ); - void ShowAll( bool bShow ); + virtual void ShowAll( bool bShow ); + virtual bool Contains( const Point &rDocPt ) const; bool IsHeader() { return m_bIsHeader; }; bool IsEmptyHeaderFooter( ); diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx index fa2631c..e1967f3 100644 --- a/sw/source/ui/inc/PageBreakWin.hxx +++ b/sw/source/ui/inc/PageBreakWin.hxx @@ -59,7 +59,8 @@ public: void UpdatePosition( ); - void ShowAll( bool bShow ); + virtual void ShowAll( bool bShow ); + virtual bool Contains( const Point &rDocPt ) const; const SwPageFrm* GetPageFrame( ); diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx index 8cdcb1b..ca87b89 100644 --- a/sw/source/ui/inc/edtwin.hxx +++ b/sw/source/ui/inc/edtwin.hxx @@ -100,11 +100,6 @@ friend void PageNumNotify( ViewShell* pVwSh, Timer aKeyInputTimer; // timer for ANY-KeyInut question without a following KeyInputEvent Timer aKeyInputFlushTimer; - /* - * timer for showing the Header/Footer separators when the mouse - * stays over a header or footer area for several seconds. - */ - Timer aOverHeaderFooterTimer; String aInBuffer; LanguageType eBufferLanguage; @@ -199,9 +194,6 @@ friend void PageNumNotify( ViewShell* pVwSh, // timer for overlapping KeyInputs (e.g. for tables) DECL_LINK( KeyInputTimerHandler, Timer * ); - // timer for hovering header/footer areas - DECL_LINK( OverHeaderFooterHandler, Timer * ); - // timer for ApplyTemplates via mouse (in disguise Drag&Drop) DECL_LINK( TemplateTimerHdl, Timer* ); @@ -235,6 +227,12 @@ protected: void ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr, sal_Bool bFromIME = sal_False ); + + /// Shows or hides the header & footer separators; only if there is a change. + void ShowHeaderFooterSeparator( bool bShow ); + + /// Returns true if in header/footer area, or in the header/footer control. + bool IsInHeaderFooter( const Point &rDocPt ) const; public: void UpdatePointer(const Point &, sal_uInt16 nButtons = 0); diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 879ccbe..408da88 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -491,7 +491,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)(); const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False); void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning); - virtual void SetShowHeaderFooterSeparator( sal_Bool bShow ); + virtual void SetShowHeaderFooterSeparator( bool bShow ); private: diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 9dcda67..b67e433 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -1889,11 +1889,14 @@ void SwWrtShell::ChangeHeaderOrFooter( EndAllAction(); } -void SwWrtShell::SetShowHeaderFooterSeparator( sal_Bool bShow ) +void SwWrtShell::SetShowHeaderFooterSeparator( bool bShow ) { ViewShell::SetShowHeaderFooterSeparator( bShow ); if ( !bShow ) - GetView().GetEditWin().GetFrameControlsManager().HideControls( HeaderFooter ); + { + GetView().GetEditWin().GetFrameControlsManager().HideControls( Header ); + GetView().GetEditWin().GetFrameControlsManager().HideControls( Footer ); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits