summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/viewsh.hxx19
-rw-r--r--sw/source/core/crsr/crsrsh.cxx2
-rw-r--r--sw/source/core/inc/pagefrm.hxx5
-rw-r--r--sw/source/core/layout/pagechg.cxx22
-rwxr-xr-xsw/source/core/layout/paintfrm.cxx47
-rw-r--r--sw/source/core/view/viewsh.cxx16
-rw-r--r--sw/source/core/view/vnew.cxx9
-rw-r--r--sw/source/ui/docvw/FrameControlsManager.cxx6
-rw-r--r--sw/source/ui/docvw/edtwin.cxx47
-rw-r--r--sw/source/ui/inc/FrameControlsManager.hxx10
-rw-r--r--sw/source/ui/inc/edtwin.hxx4
-rw-r--r--sw/source/ui/inc/wrtsh.hxx2
-rw-r--r--sw/source/ui/wrtsh/wrtsh1.cxx9
13 files changed, 126 insertions, 72 deletions
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index fd4a3d67edbe..85b17a400ca5 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 bb55f6b57a06..0d1efa3b87f9 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 1e16a980e627..779c4cd24bb3 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 7e1c34f010ed..79d7d1beb433 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 387d8a38b099..dd0c0a72c36e 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 9e3bb9bd9295..0413382d5fe5 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 647e64965307..1234c4d3235b 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 72671049bbc5..40527a64b237 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 729c4c8bd6ee..4246c2cba24e 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 ddfaaa00a2db..ec78b1d06aca 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 ca87b8988912..1f03374e5f8f 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 408da88351cb..90e6296a0053 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 b67e43350d93..d042c4dc5a42 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: */