summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-04-26 12:05:15 -0400
committerMiklos Vajna <vmiklos@collabora.com>2023-04-28 08:06:44 +0200
commita3a758350e92a3084d2cbef05ca6caef899746a4 (patch)
treee21a8e331bbe58c55dcc4fa085ef23e0a97422fe /sw
parent1770d3ba3313f2166153d39be6ae1212c00da6d8 (diff)
tdf#86630 sw page number wizard: only turn on current page footer
Without specifying the name of the page style, all in-use page styles were having the header or footer enabled. That was not the intent. Change-Id: I5eadd73cb2d7e11b6a003826b5698e22df3f13c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151133 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/shells/textfld.cxx38
1 files changed, 21 insertions, 17 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 6e6cf9455724..bee499cd57f8 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -37,6 +37,7 @@
#include <svx/hlnkitem.hxx>
#include <svx/svxdlg.hxx>
#include <osl/diagnose.h>
+#include <fmthdft.hxx>
#include <fmtinfmt.hxx>
#include <fldwrap.hxx>
#include <redline.hxx>
@@ -1047,24 +1048,27 @@ FIELD_INSERT:
rSh.SwCursorShell::Push();
rDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_PAGE_NUMBER, nullptr);
- // Insert header/footer
- bool bFooter = (pDlg->GetPageNumberPosition() == 1);
- sal_uInt16 nPageNumberPosition = bFooter ?
- FN_INSERT_PAGEFOOTER : FN_INSERT_PAGEHEADER;
- SfxBoolItem aItem(FN_PARAM_1, true);
+ const size_t nPageDescIndex = rSh.GetCurPageDesc();
+ const SwPageDesc& rDesc = rSh.GetPageDesc(nPageDescIndex);
+ const bool bHeaderAlreadyOn = rDesc.GetMaster().GetHeader().IsActive();
+ const bool bFooterAlreadyOn = rDesc.GetMaster().GetFooter().IsActive();
SvxPageItem aPageItem(SID_ATTR_PAGE);
aPageItem.SetNumType(pDlg->GetPageNumberType());
GetView().GetViewFrame().GetBindings().GetDispatcher()->ExecuteList(
SID_ATTR_PAGE, SfxCallMode::RECORD, { &aPageItem });
+ // Insert header/footer
+ const bool bHeader = !pDlg->GetPageNumberPosition();
+ if (bHeader && !bHeaderAlreadyOn)
+ rSh.ChangeHeaderOrFooter(rDesc.GetName(), bHeader, /*On=*/true, /*Warn=*/false);
+ else if (!bHeader && !bFooterAlreadyOn)
+ rSh.ChangeHeaderOrFooter(rDesc.GetName(), false, /*On=*/true, /*Warn=*/false);
-
- rSh.GetView().GetDispatcher().ExecuteList(
- nPageNumberPosition,
- SfxCallMode::API | SfxCallMode::SYNCHRON,
- {&aItem}
- );
+ if (bHeader)
+ rSh.GotoHeaderText();
+ else
+ rSh.GotoFooterText();
SwTextNode* pTextNode = rSh.GetCursor()->GetPoint()->GetNode().GetTextNode();
@@ -1072,13 +1076,13 @@ FIELD_INSERT:
if (pTextNode && !pTextNode->GetText().isEmpty())
{
rDoc->getIDocumentContentOperations().SplitNode(*rSh.GetCursor()->GetPoint(), false);
- }
- // Go back to start of header/footer
- if (bFooter)
- rSh.GotoFooterText();
- else
- rSh.GotoHeaderText();
+ // Go back to start of header/footer
+ if (bHeader)
+ rSh.GotoHeaderText();
+ else
+ rSh.GotoFooterText();
+ }
// Set alignment for the new line
switch (pDlg->GetPageNumberAlignment())