sw/source/core/crsr/crsrsh.cxx | 11 ++++++ sw/source/ui/docvw/edtwin.cxx | 75 ++++++++++++----------------------------- sw/source/ui/inc/edtwin.hxx | 2 - 3 files changed, 33 insertions(+), 55 deletions(-)
New commits: commit 3a8f97a07ff02e160e35c54986c30c014c6415d0 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 diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 1c38bcc..96d96b7 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -679,6 +679,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 2805bc2..3fbc8c0 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -1323,13 +1323,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 @@ -1337,10 +1330,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 @@ -2686,26 +2675,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? @@ -2726,10 +2699,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; } } @@ -4627,9 +4615,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(); @@ -4811,23 +4797,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 04f9c2e..a606644 100644 --- a/sw/source/ui/inc/edtwin.hxx +++ b/sw/source/ui/inc/edtwin.hxx @@ -153,8 +153,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();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits