sw/source/core/crsr/crsrsh.cxx | 11 +++++ sw/source/ui/docvw/HeaderFooterWin.cxx | 11 ----- sw/source/ui/docvw/edtwin.cxx | 72 ++++++++++++++++++++++++--------- sw/source/ui/inc/HeaderFooterWin.hxx | 1 sw/source/ui/inc/edtwin.hxx | 1 sw/source/ui/wrtsh/wrtsh1.cxx | 6 +- 6 files changed, 68 insertions(+), 34 deletions(-)
New commits: commit 3632b3a01fa8ad5f111658ff5cea555db58637fd Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Mon Aug 27 18:12:00 2012 +0200 Headers/Footers: don't create temporary parts of document (perf problems) Clicking on an empty header/footer only displays the separator as creating empty header/footer could cause important layout recomputing on long documents. Change-Id: I800c5dd27744772833dee0da4269e7591bd0a10b Signed-off-by: Petr Mladek <pmla...@suse.cz> Signed-off-by: Michael Stahl <mst...@redhat.com> Signed-off-by: Rainer Bielefeld <libreoff...@bielefeldundbuss.de> Signed-off-by: Roman Eisele <b...@eikota.de> diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index dfd80d9..ca62c55 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -690,6 +690,17 @@ int SwCrsrShell::SetCrsr( const Point &rLPt, sal_Bool bOnlyText, bool bBlock ) bool bInHeaderFooter = pFrm && ( pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() ); if ( bInHeaderFooter != IsHeaderFooterEdit() ) ToggleHeaderFooterEdit(); + else + { + // Make sure we have the proper Header/Footer separators shown + // as these may be changed if clicking on an empty Header/Footer + SetShowHeaderFooterSeparator( Header, pFrm != NULL && pFrm->IsHeaderFrm( ) ); + SetShowHeaderFooterSeparator( Footer, pFrm != NULL && pFrm->IsFooterFrm( ) ); + + // Repaint everything + GetWin()->Invalidate(); + } + if( pBlockCrsr && bBlock ) { diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index a6b09dd..dd58e44 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -1316,13 +1316,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) rSh.IsHeaderFooterEdit( ) ) { bool bHeader = FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False); - - // Remove the temporary header/footer - if ( !m_sTmpHFPageStyle.isEmpty() ) - { - rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); - } - if ( bHeader ) rSh.SttPg(); else @@ -1330,10 +1323,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) rSh.ToggleHeaderFooterEdit(); } - // If we are inputing a key in a temporary header/footer, then make it definitive - if ( !m_sTmpHFPageStyle.isEmpty( ) ) - m_sTmpHFPageStyle = rtl::OUString( ); - SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell(); if ( bLockInput || (pObjSh && pObjSh->GetProgress()) ) // When the progress bar is active or a progress is @@ -2679,26 +2668,10 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) ); - FrameControlType eControl; - bool bIsInHF = IsInHeaderFooter( aDocPos, eControl ); - if ( !m_sTmpHFPageStyle.isEmpty( ) ) - { - // Are we clicking outside the temporary header/footer? if so remove it - rtl::OUString sStyleName = rSh.GetCurPageStyle( false ); - bool bMatchesTmpHF = sStyleName == m_sTmpHFPageStyle && - ( ( m_bTmpHFIsHeader && eControl == Header ) || - ( !m_bTmpHFIsHeader && eControl == Footer ) ); - - if ( ( !bIsInHF && rSh.IsHeaderFooterEdit( ) ) || !bMatchesTmpHF ) - rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); - - m_sTmpHFPageStyle = rtl::OUString( ); - } - // Are we clicking on a blank header/footer area? - if ( bIsInHF && !rSh.IsHeaderFooterEdit( ) ) + FrameControlType eControl; + if ( IsInHeaderFooter( aDocPos, eControl ) ) { - // Create empty header/footer under the cursor and switch to it const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPos ); // Is it active? @@ -2719,10 +2692,25 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) if ( !bActive ) { - const String& rStyleName = pPageFrm->GetPageDesc()->GetName(); - rSh.ChangeHeaderOrFooter( rStyleName, eControl == Header, true, false ); - m_sTmpHFPageStyle = rStyleName; - m_bTmpHFIsHeader = eControl == Header; + SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() ); + bool bWasInHeader = aPam.GetPoint( )->nNode.GetNode( ).FindHeaderStartNode( ) != NULL; + bool bWasInFooter = aPam.GetPoint( )->nNode.GetNode( ).FindFooterStartNode( ) != NULL; + + // Is the cursor in a part like similar to the one we clicked on? For example, + // if the cursor is in a header and we click on an empty header... don't change anything to + // keep consistent behaviour due to header edit mode (and the same for the footer as well). + // + // Otherwise, we hide the header/footer control if a separator is shown, and vice versa. + if ( !( bWasInHeader && eControl == Header ) && + !( bWasInFooter && eControl == Footer ) ) + { + rSh.SetShowHeaderFooterSeparator( eControl, !rSh.IsShowHeaderFooterSeparator( eControl ) ); + } + + // Repaint everything + Invalidate(); + + return; } } @@ -4619,9 +4607,7 @@ SwEditWin::SwEditWin(Window *pParent, SwView &rMyView): bObjectSelect( sal_False ), nKS_NUMDOWN_Count(0), nKS_NUMINDENTINC_Count(0), - m_aFrameControlsManager( this ), - m_sTmpHFPageStyle( ), - m_bTmpHFIsHeader( false ) + m_aFrameControlsManager( this ) { SetHelpId(HID_EDIT_WIN); EnableChildTransparentMode(); @@ -4803,23 +4789,6 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) if ( !rCEvt.IsMouseEvent() ) aDocPos = rSh.GetCharRect().Center(); - // Triggering a command remove temporary header/footer status - FrameControlType eControl; - bool bIsInHF = IsInHeaderFooter( aDocPos, eControl ); - if ( !m_sTmpHFPageStyle.isEmpty( ) ) - { - const rtl::OUString sStyleName = rSh.GetCurPageStyle( false ); - bool bMatchesTmpHF = sStyleName == m_sTmpHFPageStyle && - ( ( m_bTmpHFIsHeader && eControl == Header ) || - ( !m_bTmpHFIsHeader && eControl == Footer ) ); - - // Are we clicking outside the temporary header/footer? if so remove it - if ( ( !bIsInHF && rSh.IsHeaderFooterEdit( ) ) || !bMatchesTmpHF ) - rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); - - m_sTmpHFPageStyle = rtl::OUString( ); - } - if (rCEvt.IsMouseEvent() && lcl_CheckHeaderFooterClick( rSh, aDocPos, 1 ) ) return; diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx index 11a6446..67af3ae 100644 --- a/sw/source/ui/inc/edtwin.hxx +++ b/sw/source/ui/inc/edtwin.hxx @@ -154,8 +154,6 @@ friend void PageNumNotify( ViewShell* pVwSh, sal_uInt16 nKS_NUMINDENTINC_Count; SwFrameControlsManager m_aFrameControlsManager; - rtl::OUString m_sTmpHFPageStyle; - bool m_bTmpHFIsHeader; void LeaveArea(const Point &); void JustifyAreaTimer(); commit 1dcb0eeb018f9ed54bce6dbbe262bf80fbd2ae93 Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Thu Aug 23 09:45:10 2012 +0200 fdo#46141: Don't use a timer to show header/footer separators Clicking on the header/footer area will show the separator. Clicking on an empty header/footer area will add a temporary one that we try hard to remove when clicking outside Change-Id: I8f29f8fd80b2d808257636bf94ec4e2e46f6028e Signed-off-by: Petr Mladek <pmla...@suse.cz> Signed-off-by: Michael Stahl <mst...@redhat.com> Signed-off-by: Rainer Bielefeld <libreoff...@bielefeldundbuss.de> Signed-off-by: Roman Eisele <b...@eikota.de> diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index f35f603..cd09e65 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -152,7 +152,6 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag m_pLine( NULL ), m_bIsAppearing( false ), m_nFadeRate( 100 ), - m_nDelayAppearing( 0 ), m_aFadeTimer( ) { // Get the font and configure it @@ -243,8 +242,6 @@ void SwHeaderFooterWin::ShowAll( bool bShow ) if ( !PopupMenu::IsInExecute() ) { m_bIsAppearing = bShow; - if ( bShow ) - m_nDelayAppearing = 0; if ( m_aFadeTimer.IsActive( ) ) m_aFadeTimer.Stop(); @@ -516,14 +513,6 @@ void SwHeaderFooterWin::Select( ) IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler) { - const int TICKS_BEFORE_WE_APPEAR = 10; - if ( m_bIsAppearing && m_nDelayAppearing < TICKS_BEFORE_WE_APPEAR ) - { - ++m_nDelayAppearing; - m_aFadeTimer.Start(); - return 0; - } - if ( m_bIsAppearing && m_nFadeRate > 0 ) m_nFadeRate -= 25; else if ( !m_bIsAppearing && m_nFadeRate < 100 ) diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index fffe6c3..a6b09dd 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -93,6 +93,7 @@ #include <fmtornt.hxx> #include <fmtfsize.hxx> #include <fmtclds.hxx> +#include <fmthdft.hxx> #include <frmfmt.hxx> #include <modcfg.hxx> #include <fmtcol.hxx> @@ -1315,6 +1316,13 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) rSh.IsHeaderFooterEdit( ) ) { bool bHeader = FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False); + + // Remove the temporary header/footer + if ( !m_sTmpHFPageStyle.isEmpty() ) + { + rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); + } + if ( bHeader ) rSh.SttPg(); else @@ -1322,6 +1330,10 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) rSh.ToggleHeaderFooterEdit(); } + // If we are inputing a key in a temporary header/footer, then make it definitive + if ( !m_sTmpHFPageStyle.isEmpty( ) ) + m_sTmpHFPageStyle = rtl::OUString( ); + SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell(); if ( bLockInput || (pObjSh && pObjSh->GetProgress()) ) // When the progress bar is active or a progress is @@ -2667,9 +2679,57 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) ); + FrameControlType eControl; + bool bIsInHF = IsInHeaderFooter( aDocPos, eControl ); + if ( !m_sTmpHFPageStyle.isEmpty( ) ) + { + // Are we clicking outside the temporary header/footer? if so remove it + rtl::OUString sStyleName = rSh.GetCurPageStyle( false ); + bool bMatchesTmpHF = sStyleName == m_sTmpHFPageStyle && + ( ( m_bTmpHFIsHeader && eControl == Header ) || + ( !m_bTmpHFIsHeader && eControl == Footer ) ); + + if ( ( !bIsInHF && rSh.IsHeaderFooterEdit( ) ) || !bMatchesTmpHF ) + rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); + + m_sTmpHFPageStyle = rtl::OUString( ); + } + + // Are we clicking on a blank header/footer area? + if ( bIsInHF && !rSh.IsHeaderFooterEdit( ) ) + { + // Create empty header/footer under the cursor and switch to it + const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPos ); + + // Is it active? + bool bActive = true; + const SwPageDesc* pDesc = pPageFrm->GetPageDesc(); + + const SwFrmFmt* pFmt = pDesc->GetLeftFmt(); + if ( pPageFrm->OnRightPage() ) + pFmt = pDesc->GetRightFmt(); + + if ( pFmt ) + { + if ( eControl == Header ) + bActive = pFmt->GetHeader().IsActive(); + else + bActive = pFmt->GetFooter().IsActive(); + } + + if ( !bActive ) + { + const String& rStyleName = pPageFrm->GetPageDesc()->GetName(); + rSh.ChangeHeaderOrFooter( rStyleName, eControl == Header, true, false ); + m_sTmpHFPageStyle = rStyleName; + m_bTmpHFIsHeader = eControl == Header; + } + } + if ( lcl_CheckHeaderFooterClick( rSh, aDocPos, rMEvt.GetClicks() ) ) return; + if ( IsChainMode() ) { SetChainMode( sal_False ); @@ -3819,17 +3879,6 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) } else rView.GetPostItMgr()->SetShadowState(0,false); - - // Are we moving from or to header / footer area? - if ( !rSh.IsHeaderFooterEdit() ) - { - FrameControlType eControl; - bool bIsInHF = IsInHeaderFooter( aDocPt, eControl ); - if ( !bIsInHF ) - ShowHeaderFooterSeparator( false, false ); - else - ShowHeaderFooterSeparator( eControl == Header, eControl == Footer ); - } } // no break; case KEY_SHIFT: @@ -4570,7 +4619,9 @@ SwEditWin::SwEditWin(Window *pParent, SwView &rMyView): bObjectSelect( sal_False ), nKS_NUMDOWN_Count(0), nKS_NUMINDENTINC_Count(0), - m_aFrameControlsManager( this ) + m_aFrameControlsManager( this ), + m_sTmpHFPageStyle( ), + m_bTmpHFIsHeader( false ) { SetHelpId(HID_EDIT_WIN); EnableChildTransparentMode(); @@ -4748,8 +4799,28 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel())) return; - if (rCEvt.IsMouseEvent() && lcl_CheckHeaderFooterClick( rSh, - PixelToLogic( rCEvt.GetMousePosPixel() ), 1 ) ) + Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) ); + if ( !rCEvt.IsMouseEvent() ) + aDocPos = rSh.GetCharRect().Center(); + + // Triggering a command remove temporary header/footer status + FrameControlType eControl; + bool bIsInHF = IsInHeaderFooter( aDocPos, eControl ); + if ( !m_sTmpHFPageStyle.isEmpty( ) ) + { + const rtl::OUString sStyleName = rSh.GetCurPageStyle( false ); + bool bMatchesTmpHF = sStyleName == m_sTmpHFPageStyle && + ( ( m_bTmpHFIsHeader && eControl == Header ) || + ( !m_bTmpHFIsHeader && eControl == Footer ) ); + + // Are we clicking outside the temporary header/footer? if so remove it + if ( ( !bIsInHF && rSh.IsHeaderFooterEdit( ) ) || !bMatchesTmpHF ) + rSh.ChangeHeaderOrFooter( m_sTmpHFPageStyle, m_bTmpHFIsHeader, false, false ); + + m_sTmpHFPageStyle = rtl::OUString( ); + } + + if (rCEvt.IsMouseEvent() && lcl_CheckHeaderFooterClick( rSh, aDocPos, 1 ) ) return; @@ -4765,14 +4836,10 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) bNoInterrupt = sal_False; bMBPressed = sal_False; } - Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) ); - if ( !rCEvt.IsMouseEvent() ) - aDocPos = rSh.GetCharRect().Center(); - else + if ( rCEvt.IsMouseEvent() ) { SelectMenuPosition(rSh, rCEvt.GetMousePosPixel()); rView.StopShellTimer(); - } const Point aPixPos = LogicToPixel( aDocPos ); diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx index d6c250d..04a0a81 100644 --- a/sw/source/ui/inc/HeaderFooterWin.hxx +++ b/sw/source/ui/inc/HeaderFooterWin.hxx @@ -45,7 +45,6 @@ class SwHeaderFooterWin : public MenuButton, public SwFrameControl Window* m_pLine; bool m_bIsAppearing; int m_nFadeRate; - int m_nDelayAppearing; //< Before we show the control, let it transparent for a few timer ticks to avoid appearing with every mouse over. Timer m_aFadeTimer; public: diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx index ac78de9..11a6446 100644 --- a/sw/source/ui/inc/edtwin.hxx +++ b/sw/source/ui/inc/edtwin.hxx @@ -150,11 +150,12 @@ friend void PageNumNotify( ViewShell* pVwSh, bUseInputLanguage: 1, bObjectSelect : 1; - sal_uInt16 nKS_NUMDOWN_Count; // #i23725# sal_uInt16 nKS_NUMINDENTINC_Count; SwFrameControlsManager m_aFrameControlsManager; + rtl::OUString m_sTmpHFPageStyle; + bool m_bTmpHFIsHeader; void LeaveArea(const Point &); void JustifyAreaTimer(); diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index efd9930..0350940 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -1839,9 +1839,9 @@ void SwWrtShell::ChangeHeaderOrFooter( String sTmp(aDesc.GetName()); if( !rStyleName.Len() || rStyleName == sTmp ) { - if( (bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() && - (bHeader && aDesc.GetMaster().GetHeader().IsActive())) || - (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) ) + if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() && + ( (bHeader && aDesc.GetMaster().GetHeader().IsActive()) || + (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) ) ) { bShowWarning = sal_False; //Actions have to be closed while the dialog is showing
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits