summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-13 11:32:11 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-13 14:11:04 +0200
commitc0251bf65d1e972be395514724a413995ef53af8 (patch)
treebe915401e23164c2754389ade67fda4255784d94
parentc900069dee03c5ebf631a5862b94cd2962cbaea0 (diff)
Header/Footer: shared code for the insertion/removal
Moved the ChangedHeaderOrFooter method from SwTextShell to SwWrtShell for it to be accessible from the SwHeaderFooterWin objects... and that method didn't really need to be in the root shell. That fixed a few quirks from the copied code in SwHeaderFooterWin.
-rw-r--r--sw/source/ui/app/mn.src2
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx53
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx2
-rw-r--r--sw/source/ui/inc/textsh.hxx1
-rw-r--r--sw/source/ui/inc/wrtsh.hxx2
-rw-r--r--sw/source/ui/shells/textsh1.cxx78
-rw-r--r--sw/source/ui/wrtsh/wrtsh1.cxx76
7 files changed, 95 insertions, 119 deletions
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index c63d6d087ee8..4156ba2232c4 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1448,7 +1448,7 @@ Menu MN_HEADERFOOTER_BUTTON
{
Identifier = FN_HEADERFOOTER_DELETE ;
HelpID = CMD_FN_HEADERFOOTER_DELETE ;
- Text [ en-US ] = "Delete $1" ;
+ Text [ en-US ] = "Delete $1..." ;
};
};
};
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index d7c9c848199a..6f59189afa77 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -45,7 +45,6 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/color/bcolortools.hxx>
-#include <editeng/ulspitem.hxx>
#include <svtools/svtdata.hxx>
#include <vcl/decoview.hxx>
#include <vcl/gradient.hxx>
@@ -184,7 +183,7 @@ void SwHeaderFooterWin::SetOffset( Point aOffset )
aTextPxRect.GetHeight() + TEXT_PADDING * 2 );
long nYFooterOff = 0;
- if ( !IsHeader() )
+ if ( !m_bIsHeader )
nYFooterOff = aBoxSize.Height();
Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
@@ -270,54 +269,29 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
return bResult;
}
-void SwHeaderFooterWin::ChangeHeaderOrFooter( bool bAdd )
-{
- SwWrtShell& rSh = m_pEditWin->GetView().GetWrtShell();
- rSh.addCurrentPosition();
- rSh.StartAllAction();
- rSh.StartUndo( UNDO_HEADER_FOOTER );
-
- const SwPageDesc* pPageDesc = GetPageFrame()->GetPageDesc();
- SwFrmFmt& rMaster = const_cast< SwFrmFmt& > (pPageDesc->GetMaster() );
-
- if ( m_bIsHeader )
- rMaster.SetFmtAttr( SwFmtHeader( bAdd ) );
- else
- rMaster.SetFmtAttr( SwFmtFooter( bAdd ) );
-
- if ( bAdd )
- {
- SvxULSpaceItem aUL( m_bIsHeader ? 0 : MM50, m_bIsHeader ? MM50 : 0, RES_UL_SPACE );
- SwFrmFmt* pFmt = m_bIsHeader ?
- ( SwFrmFmt* )rMaster.GetHeader().GetHeaderFmt():
- ( SwFrmFmt* )rMaster.GetFooter().GetFooterFmt();
- pFmt->SetFmtAttr( aUL );
- }
-
-
- rSh.EndUndo( UNDO_HEADER_FOOTER );
- rSh.EndAllAction();
-}
-
void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
{
+ SwView& rView = m_pEditWin->GetView();
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
switch ( nSlot )
{
case FN_HEADERFOOTER_EDIT:
{
- SwView& rView = m_pEditWin->GetView();
- SwWrtShell& rSh = rView.GetWrtShell();
sal_uInt16 nPageId = TP_FOOTER_PAGE;
- if ( IsHeader() )
+ if ( m_bIsHeader )
nPageId = TP_HEADER_PAGE;
rView.GetDocShell()->FormatPage(
- GetPageFrame()->GetPageDesc()->GetName(),
+ rStyleName,
nPageId, &rSh );
}
break;
case FN_HEADERFOOTER_DELETE:
- ChangeHeaderOrFooter( false );
+ {
+ rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
+ }
break;
default:
break;
@@ -334,8 +308,11 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( IsEmptyHeaderFooter( ) )
{
- // Add the header / footer
- ChangeHeaderOrFooter( true );
+ SwView& rView = m_pEditWin->GetView();
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
+ rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
}
else
MenuButton::MouseButtonDown( rMEvt );
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index f805be2c53f5..50af8fd4acf4 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -31,7 +31,6 @@
#include <pagedesc.hxx>
#include <vcl/menubtn.hxx>
-#include <vcl/window.hxx>
/** Class for the header and footer separator control window.
@@ -61,7 +60,6 @@ public:
bool IsEmptyHeaderFooter( );
const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
- void ChangeHeaderOrFooter( bool bAdd );
void ExecuteCommand(sal_uInt16 nSlot);
void SetReadonly( bool bReadonly );
diff --git a/sw/source/ui/inc/textsh.hxx b/sw/source/ui/inc/textsh.hxx
index 31a545ae65d6..aa08e8ad99d7 100644
--- a/sw/source/ui/inc/textsh.hxx
+++ b/sw/source/ui/inc/textsh.hxx
@@ -44,7 +44,6 @@ class SwTextShell: public SwBaseShell
void InsertSymbol( SfxRequest& );
void InsertHyperlink(const SvxHyperlinkItem& rHlnkItem);
bool InsertMediaDlg( SfxRequest& );
- void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning);
public:
SFX_DECL_INTERFACE(SW_TEXTSHELL)
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index e98afbd33333..735848f73626 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -485,6 +485,8 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
sal_Bool GotoFld( const SwFmtFld& rFld );
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);
+
private:
SW_DLLPRIVATE void OpenMark();
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index 739eaa6d2073..7ccc72d59c13 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -33,7 +33,6 @@
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <comphelper/processfactory.hxx>
-#include <svx/dialogs.hrc>
#include <hintids.hxx>
#include <cmdid.h>
#include <helpid.h>
@@ -50,13 +49,11 @@
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/objitem.hxx>
-#include <vcl/msgbox.hxx>
#include <vcl/unohelp2.hxx>
#include <sfx2/request.hxx>
#include <svl/eitem.hxx>
#include <svl/macitem.hxx>
#include <editeng/lrspitem.hxx>
-#include <editeng/ulspitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/brshitem.hxx>
@@ -67,7 +64,6 @@
#include <charfmt.hxx>
#include <editeng/fontitem.hxx>
#include <svx/SmartTagItem.hxx>
-#include <svx/dialmgr.hxx>
#include <fmtinfmt.hxx>
#include <swwait.hxx>
#include <wrtsh.hxx>
@@ -76,7 +72,6 @@
#include <viewopt.hxx>
#include <uitool.hxx>
#include <swevent.hxx>
-#include <fmthdft.hxx>
#include <pagedesc.hxx>
#include <textsh.hxx>
#include <IMark.hxx>
@@ -1188,7 +1183,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
sal_Bool bOn = sal_True;
if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem))
bOn = ((const SfxBoolItem*)pItem)->GetValue();
- ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
+ rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
rReq.Done();
}
break;
@@ -1675,75 +1670,4 @@ void SwTextShell::GetState( SfxItemSet &rSet )
}
}
-/*
- * Switch on/off header of footer of a page style - if an empty name is
- * given all styles are changed
- */
-void SwTextShell::ChangeHeaderOrFooter(
- const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
-{
- SwWrtShell& rSh = GetShell();
- rSh.addCurrentPosition();
- rSh.StartAllAction();
- rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
- sal_Bool bExecute = sal_True;
- sal_Bool bCrsrSet = sal_False;
- for( sal_uInt16 nFrom = 0, nTo = rSh.GetPageDescCnt();
- nFrom < nTo; ++nFrom )
- {
- int bChgd = sal_False;
- SwPageDesc aDesc( rSh.GetPageDesc( nFrom ));
- 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()) )
- {
- bShowWarning = sal_False;
- //Actions have to be closed while the dialog is showing
- rSh.EndAllAction();
-
- Window* pParent = &GetView().GetViewFrame()->GetWindow();
- sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
- DIALOG_MGR() ) ).Execute();
- bExecute = bRet;
- rSh.StartAllAction();
- }
- if( bExecute )
- {
- bChgd = sal_True;
- SwFrmFmt &rMaster = aDesc.GetMaster();
- if(bHeader)
- rMaster.SetFmtAttr( SwFmtHeader( bOn ));
- else
- rMaster.SetFmtAttr( SwFmtFooter( bOn ));
- if( bOn )
- {
- SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
- SwFrmFmt* pFmt = bHeader ?
- (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
- (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
- pFmt->SetFmtAttr( aUL );
- }
- }
- if( bChgd )
- {
- rSh.ChgPageDesc( nFrom, aDesc );
-
- if( !bCrsrSet && bOn )
- {
- if ( !rSh.IsHeaderFooterEdit() )
- rSh.ToggleHeaderFooterEdit();
- bCrsrSet = rSh.SetCrsrInHdFt(
- !rStyleName.Len() ? USHRT_MAX : nFrom,
- bHeader );
- }
- }
- }
- }
- rSh.EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
- rSh.EndAllAction();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx
index 94460f91425b..ec03fe41cd29 100644
--- a/sw/source/ui/wrtsh/wrtsh1.cxx
+++ b/sw/source/ui/wrtsh/wrtsh1.cxx
@@ -38,6 +38,8 @@
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/util/XModifiable.hpp>
+#include <svx/dialogs.hrc>
+
#include <math.h>
#include <hintids.hxx>
#include <svx/svdview.hxx>
@@ -56,7 +58,9 @@
#include <editeng/sizeitem.hxx>
#include <editeng/brkitem.hxx>
#include <editeng/svxacorr.hxx>
+#include <editeng/ulspitem.hxx>
#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
#include <sfx2/printer.hxx>
#include <unotools/charclass.hxx>
#include <comphelper/storagehelper.hxx>
@@ -65,6 +69,7 @@
#include <svx/fontworkbar.hxx>
#include <frmfmt.hxx>
#include <fmtftn.hxx>
+#include <fmthdft.hxx>
#include <fmtpdsc.hxx>
#include <wdocsh.hxx>
#include <basesh.hxx>
@@ -98,6 +103,7 @@
#include <editeng/acorrcfg.hxx>
#include <IMark.hxx>
#include <sfx2/bindings.hxx>
+#include <svx/dialmgr.hxx>
// -> #111827#
#include <SwRewriter.hxx>
@@ -1814,4 +1820,74 @@ void SwWrtShell::SetReadonlyOption(sal_Bool bSet)
ViewShell::SetReadonlyOption( bSet );
}
+/*
+ * Switch on/off header of footer of a page style - if an empty name is
+ * given all styles are changed
+ */
+void SwWrtShell::ChangeHeaderOrFooter(
+ const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
+{
+ addCurrentPosition();
+ StartAllAction();
+ StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
+ sal_Bool bExecute = sal_True;
+ sal_Bool bCrsrSet = sal_False;
+ for( sal_uInt16 nFrom = 0, nTo = GetPageDescCnt();
+ nFrom < nTo; ++nFrom )
+ {
+ int bChgd = sal_False;
+ SwPageDesc aDesc( GetPageDesc( nFrom ));
+ 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()) )
+ {
+ bShowWarning = sal_False;
+ //Actions have to be closed while the dialog is showing
+ EndAllAction();
+
+ Window* pParent = &GetView().GetViewFrame()->GetWindow();
+ sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
+ DIALOG_MGR() ) ).Execute();
+ bExecute = bRet;
+ StartAllAction();
+ }
+ if( bExecute )
+ {
+ bChgd = sal_True;
+ SwFrmFmt &rMaster = aDesc.GetMaster();
+ if(bHeader)
+ rMaster.SetFmtAttr( SwFmtHeader( bOn ));
+ else
+ rMaster.SetFmtAttr( SwFmtFooter( bOn ));
+ if( bOn )
+ {
+ SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
+ SwFrmFmt* pFmt = bHeader ?
+ (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
+ (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
+ pFmt->SetFmtAttr( aUL );
+ }
+ }
+ if( bChgd )
+ {
+ ChgPageDesc( nFrom, aDesc );
+
+ if( !bCrsrSet && bOn )
+ {
+ if ( !IsHeaderFooterEdit() )
+ ToggleHeaderFooterEdit();
+ bCrsrSet = SetCrsrInHdFt(
+ !rStyleName.Len() ? USHRT_MAX : nFrom,
+ bHeader );
+ }
+ }
+ }
+ }
+ EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
+ EndAllAction();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */