[Libreoffice-commits] .: 2 commits - sw/inc sw/source
Jan Holesovsky
kendy at kemper.freedesktop.org
Thu Dec 29 04:47:43 PST 2011
sw/inc/crsrsh.hxx | 1
sw/inc/viewsh.hxx | 21 +++-
sw/source/core/crsr/crsrsh.cxx | 8 -
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 | 19 +++-
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 | 3
sw/source/ui/inc/edtwin.hxx | 14 +--
sw/source/ui/inc/wrtsh.hxx | 2
sw/source/ui/wrtsh/wrtsh1.cxx | 6 -
19 files changed, 211 insertions(+), 134 deletions(-)
New commits:
commit cce76e658af88813e17dea4f04388a29d7e582df
Author: Jan Holesovsky <kendy at 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.
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 387d8a3..dd0c0a7 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3376,7 +3376,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() );
@@ -3468,36 +3469,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 7267104..40527a6 100644
--- a/sw/source/ui/docvw/FrameControlsManager.cxx
+++ b/sw/source/ui/docvw/FrameControlsManager.cxx
@@ -149,11 +149,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 729c4c8..4246c2c 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -3808,9 +3808,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;
@@ -5647,37 +5650,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 ddfaaa0..ec78b1d 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.
@@ -71,7 +65,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 64e08fd3c5980b74bb958dc566c229d92db18726
Author: Jan Holesovsky <kendy at 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
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index fac84b4..fba2e68 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 2ee4886..7267104 100644
--- a/sw/source/ui/docvw/FrameControlsManager.cxx
+++ b/sw/source/ui/docvw/FrameControlsManager.cxx
@@ -153,8 +153,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() )
@@ -171,7 +172,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 64e75e4..b5a3c70 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);
@@ -250,6 +250,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 7c1f00e..7e6232d 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() )
@@ -402,9 +401,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() )
@@ -504,6 +502,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 78d18fa..729c4c8 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 )
{
@@ -2624,23 +2617,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
@@ -3436,10 +3412,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
@@ -3832,23 +3804,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:
@@ -4608,9 +4573,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);
@@ -5431,18 +5393,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();
@@ -5697,6 +5647,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 453466e..ddfaaa0 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: */
More information about the Libreoffice-commits
mailing list