LibreOffice Module sw (master) 1
textfld.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/beans/PropertyValues.hpp>
21#include <AnnotationWin.hxx>
22#include <comphelper/lok.hxx>
23#include <hintids.hxx>
25#include <sfx2/bindings.hxx>
26#include <sfx2/lnkbase.hxx>
27#include <txtfld.hxx>
28#include <svl/itempool.hxx>
29#include <svl/numformat.hxx>
30#include <tools/lineend.hxx>
31#include <svl/whiter.hxx>
32#include <svl/eitem.hxx>
33#include <svl/macitem.hxx>
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/request.hxx>
36#include <svx/postattr.hxx>
37#include <svx/hlnkitem.hxx>
38#include <svx/svxdlg.hxx>
39#include <osl/diagnose.h>
40#include <fmthdft.hxx>
41#include <fmtinfmt.hxx>
42#include <fldwrap.hxx>
43#include <redline.hxx>
44#include <view.hxx>
45#include <viewopt.hxx>
46#include <wrtsh.hxx>
47#include <textsh.hxx>
48#include <docufld.hxx>
49#include <ddefld.hxx>
50#include <fldmgr.hxx>
51#include <uitool.hxx>
52#include <cmdid.h>
53#include <strings.hrc>
54#include <sfx2/event.hxx>
55#include <swabstdlg.hxx>
56#include <doc.hxx>
57#include <PostItMgr.hxx>
58#include <swmodule.hxx>
59
60#include <editeng/ulspitem.hxx>
61#include <xmloff/odffields.hxx>
64#include <IDocumentUndoRedo.hxx>
65#include <svl/zforlist.hxx>
66#include <svl/zformat.hxx>
67#include <svx/xfillit0.hxx>
68#include <svx/pageitem.hxx>
70#include <IMark.hxx>
71#include <officecfg/Office/Compatibility.hxx>
72#include <ndtxt.hxx>
73#include <translatehelper.hxx>
74#include <sfx2/dispatch.hxx>
75
76
77using namespace nsSwDocInfoSubType;
78
79static OUString lcl_BuildTitleWithRedline( const SwRangeRedline *pRedline )
80{
81 const OUString sTitle(SwResId(STR_REDLINE_COMMENT));
82
83 TranslateId pResId;
84 switch( pRedline->GetType() )
85 {
86 case RedlineType::Insert:
87 pResId = STR_REDLINE_INSERTED;
88 break;
89 case RedlineType::Delete:
90 pResId = STR_REDLINE_DELETED;
91 break;
92 case RedlineType::Format:
93 case RedlineType::ParagraphFormat:
94 pResId = STR_REDLINE_FORMATTED;
95 break;
96 case RedlineType::Table:
97 pResId = STR_REDLINE_TABLECHG;
98 break;
99 case RedlineType::FmtColl:
100 pResId = STR_REDLINE_FMTCOLLSET;
101 break;
102 default:
103 return sTitle;
104 }
105
106 return sTitle + SwResId(pResId);
107}
108
110{
111 SwWrtShell& rSh = GetShell();
112 const SfxPoolItem* pItem = nullptr;
113
114 sal_uInt16 nSlot = rReq.GetSlot();
115 const SfxItemSet* pArgs = rReq.GetArgs();
116 if(pArgs)
117 pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
118
119 bool bMore = false;
120 bool bIsText = true;
122 sal_uInt16 nInsertSubType = 0;
123 sal_uInt32 nInsertFormat = 0;
124
125 switch(nSlot)
126 {
127 case FN_EDIT_FIELD:
128 {
129 SwField* pField = rSh.GetCurField(true);
130 if( pField )
131 {
132 switch ( pField->GetTypeId() )
133 {
135 {
136 ::sfx2::SvBaseLink& rLink = static_cast<SwDDEFieldType*>(pField->GetTyp())->
137 GetBaseLink();
138 if(rLink.IsVisible())
139 {
141 ScopedVclPtr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog(GetView().GetFrameWeld(), &rSh.GetLinkManager(), false, &rLink));
142 pDlg->Execute();
143 }
144 break;
145 }
146 default:
147 {
150 pDlg->Execute();
151 }
152 }
153 }
154 break;
155 }
157 {
158 SwField *pField = rSh.GetCurField();
159
160 if (pField)
161 {
162 rSh.UpdateOneField(*pField);
163 }
164 break;
165 }
167 {
168 SwField* pField = rSh.GetCurField();
169 if(pField && pField->GetTyp()->Which() == SwFieldIds::Macro)
170 {
171
172 const OUString& rMacro = static_cast<SwMacroField*>(pField)->GetMacro();
173 sal_Int32 nPos = rMacro.indexOf('.');
174 if(nPos != -1)
175 {
176 SvxMacro aMacro( rMacro.copy(nPos + 1), rMacro.copy(0,nPos), STARBASIC );
177 rSh.ExecMacro(aMacro);
178 }
179 }
180 }
181 break;
182
185 {
186 bool bRet = false;
187 SwFieldType* pField = rSh.GetFieldType( 0, SwFieldIds::Input );
188 const bool bAddSetExpressionFields = !( rSh.GetViewOptions()->IsReadonly() );
189 if ( pField != nullptr
190 && rSh.MoveFieldType(
191 pField,
192 FN_GOTO_NEXT_INPUTFLD == nSlot,
194 bAddSetExpressionFields ) )
195 {
196 rSh.ClearMark();
197 if (!rSh.IsMultiSelection()
198 && (nullptr != dynamic_cast<const SwTextInputField*>(
200 {
201 rSh.SttSelect();
202 rSh.SelectTextModel(
205 }
206 else if (SwField* pCurrentField = rSh.GetCurField(true))
207 {
208 rSh.StartInputFieldDlg(pCurrentField, false, false, GetView().GetFrameWeld());
209 }
210 bRet = true;
211 }
212
213 rReq.SetReturnValue( SfxBoolItem( nSlot, bRet ));
214 }
215 break;
216
217 case FN_GOTO_MARK:
218 {
220 if (pName)
221 {
222 rSh.GotoMark(pName->GetValue());
223 }
224 }
225 break;
226 default:
227 bMore = true;
228 }
229 if(!bMore)
230 return;
231
232 // Here come the slots with FieldMgr.
233 SwFieldMgr aFieldMgr(GetShellPtr());
234 switch(nSlot)
235 {
237 {
238 bool bRes = false;
239 if( pItem )
240 {
241 sal_uInt32 nFormat = 0;
243 OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue();
244 OUString aPar2;
245 sal_Int32 nCommand = 0;
246
247 if( const SfxUInt16Item* pFieldItem = pArgs->GetItemIfSet( FN_PARAM_FIELD_TYPE,
248 false ))
249 nType = static_cast<SwFieldTypesEnum>(pFieldItem->GetValue());
250 aPar1 += OUStringChar(DB_DELIM);
251 if( SfxItemState::SET == pArgs->GetItemState(
252 FN_PARAM_1, false, &pItem ))
253 {
254 aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue();
255 }
256 if( SfxItemState::SET == pArgs->GetItemState(
257 FN_PARAM_3, false, &pItem ))
258 nCommand = static_cast<const SfxInt32Item*>(pItem)->GetValue();
259 aPar1 += OUStringChar(DB_DELIM)
260 + OUString::number(nCommand)
261 + OUStringChar(DB_DELIM);
262 if( SfxItemState::SET == pArgs->GetItemState(
263 FN_PARAM_2, false, &pItem ))
264 {
265 aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue();
266 }
267 if( const SfxStringItem* pContentItem = pArgs->GetItemIfSet(
268 FN_PARAM_FIELD_CONTENT, false ))
269 aPar2 = pContentItem->GetValue();
270 if( const SfxUInt32Item* pFormatItem = pArgs->GetItemIfSet(
271 FN_PARAM_FIELD_FORMAT, false ))
272 nFormat = pFormatItem->GetValue();
273 OSL_FAIL("Command is not yet used");
274 SwInsertField_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), ' '/*separator*/ );
275 bRes = aFieldMgr.InsertField(aData);
276 }
277 rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
278 }
279 break;
281 case FN_INSERT_FIELD:
282 {
283 bool bRes = false;
284 if( pItem && nSlot != FN_INSERT_FIELD_CTRL)
285 {
286 sal_uInt32 nFormat = 0;
288 sal_uInt16 nSubType = 0;
289 OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue();
290 OUString aPar2;
291 sal_Unicode cSeparator = ' ';
292
293 if( const SfxUInt16Item* pTypeItem = pArgs->GetItemIfSet( FN_PARAM_FIELD_TYPE,
294 false ))
295 nType = static_cast<SwFieldTypesEnum>(pTypeItem->GetValue());
296 else if (pArgs->GetItemState(FN_PARAM_4, false, &pItem) == SfxItemState::SET)
297 {
298 const OUString& rTypeName = static_cast<const SfxStringItem *>(pItem)->GetValue();
299 nType = SwFieldTypeFromString(rTypeName);
300 }
301 if( const SfxUInt16Item* pSubtypeItem = pArgs->GetItemIfSet( FN_PARAM_FIELD_SUBTYPE,
302 false ))
303 nSubType = pSubtypeItem->GetValue();
304 if( const SfxStringItem* pContentItem = pArgs->GetItemIfSet(
305 FN_PARAM_FIELD_CONTENT, false ))
306 aPar2 = pContentItem->GetValue();
307 if( const SfxUInt32Item* pFormatItem = pArgs->GetItemIfSet(
308 FN_PARAM_FIELD_FORMAT, false ))
309 nFormat = pFormatItem->GetValue();
310 if( SfxItemState::SET == pArgs->GetItemState(
311 FN_PARAM_3, false, &pItem ))
312 {
313 OUString sTmp = static_cast<const SfxStringItem *>(pItem)->GetValue();
314 if(!sTmp.isEmpty())
315 cSeparator = sTmp[0];
316 }
317 if (pArgs->GetItemState(FN_PARAM_5, false, &pItem) == SfxItemState::SET)
318 {
319 // Wrap the field in the requested container instead of inserting it
320 // directly at the cursor position.
321 const OUString& rWrapper = static_cast<const SfxStringItem *>(pItem)->GetValue();
322 if (rWrapper == "Footnote")
323 {
324 GetShellPtr()->InsertFootnote(OUString());
325 }
326 else if (rWrapper == "Endnote")
327 {
328 GetShellPtr()->InsertFootnote(OUString(), /*bEndNote=*/true);
329 }
330 }
331 SwInsertField_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator );
332 bRes = aFieldMgr.InsertField( aData );
333 }
334 else
335 {
336 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
337 if(!GetView().GetViewFrame().IsInModalMode())
338 {
339 SfxViewFrame& rVFrame = GetView().GetViewFrame();
341 bRes = rVFrame.GetChildWindow( nSlot ) != nullptr;
342 Invalidate(rReq.GetSlot());
344 rReq.Ignore();
345 }
346 }
347 rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
348 }
349 break;
350
352 {
353 SfxViewFrame& rVFrame = GetView().GetViewFrame();
354 if (!rVFrame.HasChildWindow(FN_INSERT_FIELD))
355 rVFrame.ToggleChildWindow(FN_INSERT_FIELD); // Show dialog
356
357 // Switch Fielddlg at a new TabPage
358 sal_uInt16 nId = SwFieldDlgWrapper::GetChildWindowId();
359 SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(rVFrame.GetChildWindow(nId));
360 if (pWrp)
361 pWrp->ShowReferencePage();
362 rReq.Ignore();
363 }
364 break;
366 {
367 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
368 if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr())
369 {
370 GetView().GetPostItMgr()->Delete(pIdItem->GetValue().toUInt32());
371 }
372 else if ( GetView().GetPostItMgr() &&
373 GetView().GetPostItMgr()->HasActiveSidebarWin() )
374 {
376 }
377 break;
378 }
380 {
381 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
382 if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr())
383 {
384 GetView().GetPostItMgr()->DeleteCommentThread(pIdItem->GetValue().toUInt32());
385 }
386 else if ( GetView().GetPostItMgr() &&
387 GetView().GetPostItMgr()->HasActiveSidebarWin() )
388 {
390 }
391 break;
392 }
393 case FN_RESOLVE_NOTE:
394 {
395 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
396 if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr())
397 {
398 GetView().GetPostItMgr()->ToggleResolved(pIdItem->GetValue().toUInt32());
399 }
400 break;
401 }
403 {
404 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
405 if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr())
406 {
407 GetView().GetPostItMgr()->ToggleResolvedForThread(pIdItem->GetValue().toUInt32());
408 }
409 break;
410 }
412 if ( GetView().GetPostItMgr() )
414 break;
416 {
417 SwPostItMgr* pPostItMgr = GetView().GetPostItMgr();
418 if (pPostItMgr)
419 pPostItMgr->ExecuteFormatAllDialog(GetView());
420 }
421 break;
423 {
424 const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot);
425 if ( pNoteItem && GetView().GetPostItMgr() )
426 GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() );
427 }
428 break;
429 case FN_HIDE_NOTE:
430 if ( GetView().GetPostItMgr() &&
432 {
434 }
435 break;
437 if ( GetView().GetPostItMgr() )
439 break;
441 {
442 const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot);
443 if ( pNoteItem && GetView().GetPostItMgr() )
444 GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() );
445 }
446 break;
447 case FN_REPLY:
448 {
449 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
450 if (pIdItem && !pIdItem->GetValue().isEmpty())
451 {
452 SwFieldType* pType = rSh.GetDoc()->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Postit, OUString(), false);
453 if(pType->FindFormatForPostItId(pIdItem->GetValue().toUInt32()))
454 {
455 auto pMgr = GetView().GetPostItMgr();
456 auto pWin = pMgr->GetAnnotationWin(pIdItem->GetValue().toUInt32());
457 if(pWin)
458 {
459 OUString sText;
460 if(const auto pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT))
461 sText = pTextItem->GetValue();
462 pMgr->RegisterAnswerText(sText);
463 pWin->ExecuteCommand(nSlot);
464 }
465 }
466 }
467 }
468 break;
469 case FN_POSTIT:
470 {
471 rSh.InsertPostIt(aFieldMgr, rReq);
472 }
473 break;
474 case SID_EDIT_POSTIT:
475 {
476 const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
477 if (pIdItem && !pIdItem->GetValue().isEmpty())
478 {
479 const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
480 OUString sText;
481 if ( pTextItem )
482 sText = pTextItem->GetValue();
483
484 sw::annotation::SwAnnotationWin* pAnnotationWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue().toUInt32());
485 if (pAnnotationWin)
486 {
487 pAnnotationWin->UpdateText(sText);
488
489 // explicit state update to get the Undo state right
490 GetView().AttrChangedNotify(nullptr);
491 }
492 }
493 }
494 break;
496 {
497 /* this code can be used once we want redline comments in the margin, all other stuff can
498 then be deleted
499 String sComment;
500 const SwRangeRedline *pRedline = rSh.GetCurrRedline();
501
502 if (pRedline)
503 {
504 sComment = pRedline->GetComment();
505 if ( !sComment.Len() )
506 GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED));
507 const_cast<SwRangeRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView()));
508 }
509 */
510
511 const SwRangeRedline *pRedline = rSh.GetCurrRedline();
512 SwDoc *pDoc = rSh.GetDoc();
513 // If index is specified, goto and select the appropriate redline
514 if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
515 {
516 const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
517 const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
518 for (SwRedlineTable::size_type nRedline = 0; nRedline < rRedlineTable.size(); ++nRedline)
519 {
520 if (nChangeId == rRedlineTable[nRedline]->GetId())
521 pRedline = rSh.GotoRedline(nRedline, true);
522 }
523 }
524
525 OUString sCommentText;
526 const SfxStringItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
527 if (pTextItem)
528 sCommentText = pTextItem->GetValue();
529
530 if (pRedline)
531 {
532 // In case of LOK and comment text is already provided, skip
533 // dialog creation and just change the redline comment directly
534 if (comphelper::LibreOfficeKit::isActive() && !sCommentText.isEmpty())
535 {
536 rSh.SetRedlineComment(sCommentText);
537 GetView().AttrChangedNotify(nullptr);
538 MaybeNotifyRedlineModification(const_cast<SwRangeRedline&>(*pRedline), pRedline->GetDoc());
539 break;
540 }
541
542 OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
543
544 bool bTravel = false;
545
547 ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc();
548 SfxItemSet aSet(GetPool(), fnGetRange());
549 aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT));
550 aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
551
553 pRedline->GetRedlineData().GetTimeStamp() ),
554 SID_ATTR_POSTIT_DATE ));
555
556 // Traveling only if more than one field.
557 rSh.StartAction();
558
559 rSh.Push();
560 const SwRangeRedline *pActRed = rSh.SelPrevRedline();
561
562 if (pActRed == pRedline)
563 { // New cursor is at the beginning of the current redlines.
564 rSh.Pop(); // Throw old cursor away
565 rSh.Push();
566 pActRed = rSh.SelPrevRedline();
567 }
568
569 bool bPrev = pActRed != nullptr;
571 rSh.EndAction();
572
573 rSh.ClearMark();
574 // Select current redline.
575 pActRed = rSh.SelNextRedline();
576 if (pActRed != pRedline)
577 rSh.SelPrevRedline();
578
579 rSh.StartAction();
580 rSh.Push();
581 pActRed = rSh.SelNextRedline();
582 bool bNext = pActRed != nullptr;
583 rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position
584
585 if( rSh.IsCursorPtAtEnd() )
586 rSh.SwapPam();
587
588 rSh.EndAction();
589
590 bTravel |= bNext || bPrev;
591
594 pDlg->HideAuthor();
595
596 pDlg->SetText(lcl_BuildTitleWithRedline(pRedline));
597
598 if (bTravel)
599 {
600 pDlg->EnableTravel(bNext, bPrev);
601 pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl));
602 pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl));
603 }
604
605 SwViewShell::SetCareDialog(pDlg->GetDialog());
606 g_bNoInterrupt = true;
607
608 if ( pDlg->Execute() == RET_OK )
609 {
610 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
611 OUString sMsg(pOutSet->Get(SID_ATTR_POSTIT_TEXT).GetValue());
612
613 // Insert or change a comment
614 rSh.SetRedlineComment(sMsg);
615 }
616
618 pDlg.disposeAndClear();
619 g_bNoInterrupt = false;
620 rSh.ClearMark();
621 GetView().AttrChangedNotify(nullptr);
622 }
623 }
624 break;
625
626 case FN_JAVAEDIT:
627 {
628 OUString aType, aText;
629 bool bIsUrl=false;
630 bool bNew=false;
631 bool bUpdate = false;
632 SwFieldMgr aMgr;
633 if ( pItem )
634 {
635 aText = static_cast<const SfxStringItem*>(pItem)->GetValue();
636 const SfxStringItem* pType = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
637 const SfxBoolItem* pIsUrl = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
638 if ( pType )
639 aType = pType->GetValue();
640 if ( pIsUrl )
641 bIsUrl = pIsUrl->GetValue();
642
643 SwScriptField* pField = static_cast<SwScriptField*>(aMgr.GetCurField());
644 bNew = !pField || (pField->GetTyp()->Which() != SwFieldIds::Script);
645 bUpdate = pField && ( bIsUrl != static_cast<bool>(pField->GetFormat()) || pField->GetPar2() != aType || pField->GetPar1() != aText );
646 }
647 else
648 {
651 if ( pDlg->Execute() )
652 {
653 aType = pDlg->GetScriptType();
654 aText = pDlg->GetScriptText();
655 bIsUrl = pDlg->IsUrl();
656 bNew = pDlg->IsNew();
657 bUpdate = pDlg->IsUpdate();
658 rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) );
659 rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) );
660 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) );
661 }
662 }
663
664 if( bNew )
665 {
666 SwInsertField_Data aData(SwFieldTypesEnum::Script, 0, aType, aText, bIsUrl ? 1 : 0);
667 aMgr.InsertField(aData);
668 rReq.Done();
669 }
670 else if( bUpdate )
671 {
672 aMgr.UpdateCurField( bIsUrl ? 1 : 0, aType, aText );
674 rReq.Done();
675 }
676 else
677 rReq.Ignore();
678 }
679 break;
680
681 case FN_INSERT_FLD_DATE :
682 {
683 nInsertType = SwFieldTypesEnum::Date;
684 bIsText = false;
685 // use long date format for Hungarian
686 SwPaM* pCursorPos = rSh.GetCursor();
687 if( pCursorPos )
688 {
689 LanguageType nLang = pCursorPos->GetPoint()->GetNode().GetTextNode()->GetLang(pCursorPos->GetPoint()->GetContentIndex());
692 }
693 goto FIELD_INSERT;
694 }
695 case FN_INSERT_FLD_TIME :
696 nInsertType = SwFieldTypesEnum::Time;
697 bIsText = false;
698 goto FIELD_INSERT;
700 nInsertType = SwFieldTypesEnum::PageNumber;
701 nInsertFormat = SVX_NUM_PAGEDESC; // Like page template
702 bIsText = false;
703 goto FIELD_INSERT;
706 nInsertSubType = 0;
707 bIsText = false;
708 nInsertFormat = SVX_NUM_PAGEDESC;
709 goto FIELD_INSERT;
711 nInsertType = SwFieldTypesEnum::DocumentInfo;
712 nInsertSubType = DI_SUBJECT;
713 goto FIELD_INSERT;
715 nInsertType = SwFieldTypesEnum::DocumentInfo;
716 nInsertSubType = DI_TITLE;
717 goto FIELD_INSERT;
719 nInsertType = SwFieldTypesEnum::DocumentInfo;
720 nInsertSubType = DI_CREATE|DI_SUB_AUTHOR;
721
722FIELD_INSERT:
723 {
724 //format conversion should only be done for number formatter formats
725 if(!nInsertFormat)
726 nInsertFormat = aFieldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter());
727 SwInsertField_Data aData(nInsertType, nInsertSubType,
728 OUString(), OUString(), nInsertFormat);
729 aFieldMgr.InsertField(aData);
730 rReq.Done();
731 }
732 break;
733
735 {
736 OUString aFieldType(ODF_FORMTEXT);
737 const SfxStringItem* pFieldType = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
738 if (pFieldType)
739 {
740 // Allow overwriting the default type.
741 aFieldType = pFieldType->GetValue();
742 }
743
744 OUString aFieldCode;
745 const SfxStringItem* pFieldCode = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
746 if (pFieldCode)
747 {
748 // Allow specifying a field code/command.
749 aFieldCode = pFieldCode->GetValue();
750 }
751
752 if (rSh.HasReadonlySel())
753 {
754 // Inform the user that the request has been ignored.
755 auto xInfo = std::make_shared<weld::GenericDialogController>(
756 GetView().GetFrameWeld(), "modules/swriter/ui/inforeadonlydialog.ui",
757 "InfoReadonlyDialog");
758 weld::DialogController::runAsync(xInfo, [](sal_Int32 /*nResult*/) {});
759 break;
760 }
761
762 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr);
763
764 SwPaM* pCursorPos = rSh.GetCursor();
765 if(pCursorPos)
766 {
767 // Insert five En Space into the text field so the field has extent
768 static constexpr OUStringLiteral vEnSpaces = u"\u2002\u2002\u2002\u2002\u2002";
769 OUString aFieldResult(vEnSpaces);
770 const SfxStringItem* pFieldResult = rReq.GetArg<SfxStringItem>(FN_PARAM_3);
771 if (pFieldResult)
772 {
773 // Allow specifying a field result / expanded value.
774 aFieldResult = pFieldResult->GetValue();
775 }
776
777 const SfxStringItem* pWrapper = rReq.GetArg<SfxStringItem>(FN_PARAM_4);
778 if (pWrapper)
779 {
780 // Wrap the fieldmark in the requested container instead of inserting it
781 // directly at the cursor position.
782 OUString aWrapper = pWrapper->GetValue();
783 if (aWrapper == "Footnote")
784 {
785 rSh.InsertFootnote(OUString());
786 }
787 else if (aWrapper == "Endnote")
788 {
789 // It's important that there is no Start/EndAction() around this, so the
790 // inner EndAction() triggers a layout update and the cursor can jump to the
791 // created SwFootnoteFrame.
792 rSh.InsertFootnote(OUString(), /*bEndNote=*/true);
793 }
794 }
795
796 // Don't update the layout after inserting content and before deleting temporary
797 // text nodes.
798 rSh.StartAction();
799
800 // Split node to remember where the start position is.
801 bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().SplitNode(
802 *pCursorPos->GetPoint(), false);
803 if(bSuccess)
804 {
805 SwPaM aFieldPam(*pCursorPos->GetPoint());
806 aFieldPam.Move(fnMoveBackward, GoInContent);
807 if (pFieldResult)
808 {
809 // Paste HTML content.
810 SwTranslateHelper::PasteHTMLToPaM(rSh, pCursorPos, aFieldResult.toUtf8());
811 if (pCursorPos->GetPoint()->GetContentIndex() == 0)
812 {
813 // The paste created a last empty text node, remove it.
814 SwPaM aPam(*pCursorPos->GetPoint());
815 aPam.SetMark();
818 }
819 }
820 else
821 {
822 // Insert default placeholder.
824 aFieldResult);
825 }
826 // Undo the above SplitNode().
827 aFieldPam.SetMark();
828 aFieldPam.Move(fnMoveForward, GoInContent);
830 *aFieldPam.GetMark() = *pCursorPos->GetPoint();
831
832 IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
833 sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(
834 aFieldPam, OUString(), aFieldType, aFieldPam.Start());
835 if (pFieldmark && !aFieldCode.isEmpty())
836 {
837 pFieldmark->GetParameters()->insert(
838 std::pair<OUString, uno::Any>(ODF_CODE_PARAM, uno::Any(aFieldCode)));
839 }
840 }
841 rSh.EndAction();
842 }
843
845 rSh.GetView().GetViewFrame().GetBindings().Invalidate( SID_UNDO );
846 }
847 break;
849 {
850 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr);
851
852 SwPaM* pCursorPos = rSh.GetCursor();
853 if(pCursorPos)
854 {
855 IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
856 pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX);
857 }
858
860 rSh.GetView().GetViewFrame().GetBindings().Invalidate( SID_UNDO );
861 }
862 break;
864 {
865 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr);
866
867 SwPaM* pCursorPos = rSh.GetCursor();
868 if(pCursorPos)
869 {
870 IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
871 pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN);
872 }
873
875 rSh.GetView().GetViewFrame().GetBindings().Invalidate( SID_UNDO );
876 }
877 break;
879 {
880 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr);
881
882 SwPaM* pCursorPos = rSh.GetCursor();
883 if(pCursorPos)
884 {
885 // Insert five enspaces into the text field so the field has extent
886 sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
887 bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH));
888 if(bSuccess)
889 {
890 IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
891 SwPaM aFieldPam(pCursorPos->GetPoint()->GetNode(), pCursorPos->GetPoint()->GetContentIndex() - ODF_FORMFIELD_DEFAULT_LENGTH,
892 pCursorPos->GetPoint()->GetNode(), pCursorPos->GetPoint()->GetContentIndex());
893 sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE,
894 aFieldPam.Start());
895
896 // Use a default date format and language
897 sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters();
898 SvNumberFormatter* pFormatter = rSh.GetDoc()->GetNumberFormatter();
899 sal_uInt32 nStandardFormat = pFormatter->GetStandardFormat(SvNumFormatType::DATE);
900 const SvNumberformat* pFormat = pFormatter->GetEntry(nStandardFormat);
901
902 (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= pFormat->GetFormatstring();
903 (*pParameters)[ODF_FORMDATE_DATEFORMAT_LANGUAGE] <<= LanguageTag(pFormat->GetLanguage()).getBcp47();
904 }
905 }
906
908 rSh.GetView().GetViewFrame().GetBindings().Invalidate( SID_UNDO );
909 }
910 break;
912 {
913 // This updates multiple fieldmarks in a document, based on their field name & field command
914 // prefix.
915 OUString aFieldType;
916 const SfxStringItem* pFieldType = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
917 if (pFieldType)
918 {
919 aFieldType = pFieldType->GetValue();
920 }
921 OUString aFieldCommandPrefix;
922 const SfxStringItem* pFieldCommandPrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
923 if (pFieldCommandPrefix)
924 {
925 aFieldCommandPrefix = pFieldCommandPrefix->GetValue();
926 }
927 uno::Sequence<beans::PropertyValues> aFields;
928 const SfxUnoAnyItem* pFields = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3);
929 if (pFields)
930 {
931 pFields->GetValue() >>= aFields;
932 }
933
934 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FORM_FIELDS, nullptr);
935 rSh.StartAction();
936
937 IDocumentMarkAccess* pMarkAccess = rSh.GetDoc()->getIDocumentMarkAccess();
938 sal_Int32 nFieldIndex = 0;
939 for (auto it = pMarkAccess->getFieldmarksBegin(); it != pMarkAccess->getFieldmarksEnd(); ++it)
940 {
941 auto pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(*it);
942 assert(pFieldmark);
943 if (pFieldmark->GetFieldname() != aFieldType)
944 {
945 continue;
946 }
947
948 auto itParam = pFieldmark->GetParameters()->find(ODF_CODE_PARAM);
949 if (itParam == pFieldmark->GetParameters()->end())
950 {
951 continue;
952 }
953
954 OUString aCommand;
955 itParam->second >>= aCommand;
956 if (!aCommand.startsWith(aFieldCommandPrefix))
957 {
958 continue;
959 }
960
961 if (aFields.getLength() <= nFieldIndex)
962 {
963 continue;
964 }
965
966 comphelper::SequenceAsHashMap aMap(aFields[nFieldIndex++]);
967 itParam->second = aMap["FieldCommand"];
968 SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos());
969 aPaM.Normalize();
970 // Skip field start & separator.
971 aPaM.GetPoint()->AdjustContent(2);
972 // Skip field end.
973 aPaM.GetMark()->AdjustContent(-1);
975 OUString aFieldResult;
976 aMap["FieldResult"] >>= aFieldResult;
977 SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8());
978 }
979
980 rSh.EndAction();
982 }
983 break;
985 {
986 // This deletes all fieldmarks that match the provided field type & field command prefix.
987 OUString aFieldType;
988 const SfxStringItem* pFieldType = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
989 if (pFieldType)
990 {
991 aFieldType = pFieldType->GetValue();
992 }
993 OUString aFieldCommandPrefix;
994 const SfxStringItem* pFieldCommandPrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
995 if (pFieldCommandPrefix)
996 {
997 aFieldCommandPrefix = pFieldCommandPrefix->GetValue();
998 }
999 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE_FORM_FIELDS, nullptr);
1000 rSh.StartAction();
1001
1002 IDocumentMarkAccess* pMarkAccess = rSh.GetDoc()->getIDocumentMarkAccess();
1003 std::vector<sw::mark::IMark*> aRemovals;
1004 for (auto it = pMarkAccess->getFieldmarksBegin(); it != pMarkAccess->getFieldmarksEnd(); ++it)
1005 {
1006 auto pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(*it);
1007 assert(pFieldmark);
1008 if (pFieldmark->GetFieldname() != aFieldType)
1009 {
1010 continue;
1011 }
1012
1013 if (!aFieldCommandPrefix.isEmpty())
1014 {
1015 auto itParam = pFieldmark->GetParameters()->find(ODF_CODE_PARAM);
1016 if (itParam == pFieldmark->GetParameters()->end())
1017 {
1018 continue;
1019 }
1020
1021 OUString aCommand;
1022 itParam->second >>= aCommand;
1023 if (!aCommand.startsWith(aFieldCommandPrefix))
1024 {
1025 continue;
1026 }
1027 }
1028
1029 aRemovals.push_back(pFieldmark);
1030 }
1031
1032 for (const auto& pMark : aRemovals)
1033 {
1034 pMarkAccess->deleteMark(pMark);
1035 }
1036
1037 rSh.EndAction();
1038 rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE_FORM_FIELDS, nullptr);
1039 }
1040 break;
1041 case FN_PGNUMBER_WIZARD:
1042 {
1046 auto pShell = GetShellPtr();
1047
1048 const SwPageDesc& rCurrDesc = rSh.GetPageDesc(rSh.GetCurPageDesc());
1049 pDlg->SetPageNumberType(rCurrDesc.GetNumType().GetNumberingType());
1050
1051 pDlg->StartExecuteAsync([pShell, &rSh, pDlg](int nResult) {
1052 if ( nResult == RET_OK )
1053 {
1054 auto rDoc = rSh.GetDoc();
1055
1056 rSh.LockView(true);
1057 rSh.StartAllAction();
1058 rSh.SwCursorShell::Push();
1059 rDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_PAGE_NUMBER, nullptr);
1060
1061 const size_t nPageDescIndex = rSh.GetCurPageDesc();
1062 const SwPageDesc& rDesc = rSh.GetPageDesc(nPageDescIndex);
1063 const bool bHeader = !pDlg->GetPageNumberPosition();
1064 const bool bHeaderAlreadyOn = rDesc.GetMaster().GetHeader().IsActive();
1065 const bool bFooterAlreadyOn = rDesc.GetMaster().GetFooter().IsActive();
1066 const bool bIsSinglePage = rDesc.GetFollow() != &rDesc;
1067 const size_t nMirrorPagesNeeded = rDesc.IsFirstShared() ? 2 : 3;
1068 const OUString sBookmarkName = OUString::Concat("PageNumWizard_")
1069 + (bHeader ? "HEADER" : "FOOTER") + "_" + rDesc.GetName();
1071
1072 // Allow wizard to be re-run: delete previously wizard-inserted page number.
1073 // Try before creating non-shared header: avoid copying ODD bookmark onto EVEN page.
1075 sBookmarkName + OUString::number(rSh.GetVirtPageNum()));
1076 if (ppMark != rIDMA.getAllMarksEnd() && *ppMark)
1077 {
1078 SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd());
1079 rDoc->getIDocumentContentOperations().DeleteAndJoin(aDeleteOldPageNum);
1080 }
1081
1082 SwPageDesc aNewDesc(rDesc);
1083 bool bChangePageDesc = false;
1084 if (pDlg->GetPageNumberType() != aNewDesc.GetNumType().GetNumberingType())
1085 {
1086 bChangePageDesc = true;
1087 SvxNumberType aNewType(rDesc.GetNumType());
1088 aNewType.SetNumberingType(pDlg->GetPageNumberType());
1089 aNewDesc.SetNumType(aNewType);
1090 }
1091
1092 // Insert header/footer
1093 if ((bHeader && !bHeaderAlreadyOn) || (!bHeader && !bFooterAlreadyOn))
1094 {
1095 bChangePageDesc = true;
1096 SwFrameFormat &rMaster = aNewDesc.GetMaster();
1097 if (bHeader)
1098 rMaster.SetFormatAttr(SwFormatHeader(/*On=*/true));
1099 else
1100 rMaster.SetFormatAttr(SwFormatFooter(/*On=*/true));
1101
1102 // Init copied from ChangeHeaderOrFooter: keep in sync
1104 const SvxULSpaceItem aUL(bHeader ? 0 : constTwips_5mm,
1105 bHeader ? constTwips_5mm : 0,
1106 RES_UL_SPACE);
1107 const XFillStyleItem aFill(drawing::FillStyle_NONE);
1108 SwFrameFormat& rFormat
1109 = bHeader
1110 ? const_cast<SwFrameFormat&>(*rMaster.GetHeader().GetHeaderFormat())
1111 : const_cast<SwFrameFormat&>(*rMaster.GetFooter().GetFooterFormat());
1112 rFormat.SetFormatAttr(aUL);
1113 rFormat.SetFormatAttr(aFill);
1114
1115 // Might as well turn on margin mirroring too - if appropriate
1116 if (pDlg->GetMirrorOnEvenPages() && !bHeaderAlreadyOn && !bFooterAlreadyOn
1117 && !bIsSinglePage
1118 && (aNewDesc.ReadUseOn() & UseOnPage::Mirror) == UseOnPage::All)
1119 {
1120 aNewDesc.WriteUseOn(rDesc.ReadUseOn() | UseOnPage::Mirror);
1121 }
1122 }
1123
1124 const bool bCreateMirror = !bIsSinglePage && pDlg->GetMirrorOnEvenPages()
1125 && nMirrorPagesNeeded <= rSh.GetPageCnt();
1126 if (bCreateMirror)
1127 {
1128 // Use different left/right header/footer
1129 if ((bHeader && rDesc.IsHeaderShared()) || (!bHeader && rDesc.IsFooterShared()))
1130 {
1131 bChangePageDesc = true;
1132 if (bHeader)
1133 aNewDesc.ChgHeaderShare(/*Share=*/false);
1134 else
1135 aNewDesc.ChgFooterShare(/*Share=*/false);
1136 }
1137 }
1138
1139 if (bChangePageDesc)
1140 rSh.ChgPageDesc(nPageDescIndex, aNewDesc);
1141
1142 // Go to the header or footer insert position
1143 bool bInHF = false;
1144 bool bSkipMirror = true;
1145 size_t nEvenPage = 0;
1146 if (bCreateMirror || !rSh.GetCurrFrame())
1147 {
1148 // Come here if Currframe can't be found, otherwise Goto*Text will crash.
1149 // Get*PageNum will also be invalid (0), so we have no idea where we are.
1150 // (Since not asking for mirror, the likelihood is that the bHeader is shared,
1151 // in which case it doesn't matter anyway, and we just hope for the best.)
1152 // Read the code in this block assuming that bCreateMirror is true.
1153
1154 // There are enough pages that there probably is a valid odd page.
1155 // However, that is not guaranteed: perhaps the page style switched,
1156 // or a blank page was forced, or some other complexity.
1157 bInHF = rSh.SetCursorInHdFt(nPageDescIndex, bHeader, /*Even=*/true);
1158 if (bInHF)
1159 {
1160 // Remember valid EVEN page. Mirror it if also a valid ODD or FIRST page
1161 nEvenPage = rSh.GetVirtPageNum();
1162 assert (nEvenPage && "couldn't find page number. Use a bool instead");
1163 }
1164
1165 bInHF = rSh.SetCursorInHdFt(nPageDescIndex, bHeader, /*Even=*/false);
1166 if (bInHF && nEvenPage)
1167 {
1168 // Even though the cursor may be on a FIRST page,
1169 // the user requested mirrored pages, and we have both ODD and EVEN,
1170 // so set page numbers on these two pages, and leave FIRST alone.
1171 bSkipMirror = false;
1172 }
1173 if (!bInHF)
1174 {
1175 // no ODD page, look for FIRST page
1176 bInHF = rSh.SetCursorInHdFt(nPageDescIndex, bHeader, false, /*First=*/true);
1177 if (bInHF && nEvenPage)
1178 {
1179 // Unlikely but valid situation: EVEN and FIRST pages, but no ODD page.
1180 // In this case, the first header gets the specified page number
1181 // and the even header is mirrored, with an empty odd header,
1182 // as the user (somewhat) requested.
1183 bSkipMirror = false;
1184 }
1185 }
1186 assert((bInHF || nEvenPage) && "Impossible - why couldn't the move happen?");
1187 assert((bInHF || nEvenPage == rSh.GetVirtPageNum()) && "Unexpected move");
1188 }
1189 else
1190 {
1191 if (bHeader)
1192 bInHF = rSh.GotoHeaderText();
1193 else
1194 bInHF = rSh.GotoFooterText();
1195 assert(bInHF && "shouldn't have a problem going to text when no mirroring");
1196 }
1197
1198 // Allow wizard to be re-run: delete previously wizard-inserted page number.
1199 // Now that the cursor may have moved to a different page, try delete again.
1200 ppMark = rIDMA.findMark(sBookmarkName + OUString::number(rSh.GetVirtPageNum()));
1201 if (ppMark != rIDMA.getAllMarksEnd() && *ppMark)
1202 {
1203 SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd());
1204 rDoc->getIDocumentContentOperations().DeleteAndJoin(aDeleteOldPageNum);
1205 }
1206
1207 SwTextNode* pTextNode = rSh.GetCursor()->GetPoint()->GetNode().GetTextNode();
1208
1209 // Insert new line if there is already text in header/footer
1210 if (pTextNode && !pTextNode->GetText().isEmpty())
1211 {
1213
1214 // Go back to start of header/footer
1215 if (bHeader)
1216 rSh.GotoHeaderText();
1217 else
1218 rSh.GotoFooterText();
1219 }
1220
1221 // Set alignment for the new line
1222 switch (pDlg->GetPageNumberAlignment())
1223 {
1224 case 0:
1225 {
1226 SvxAdjustItem aAdjustItem(SvxAdjust::Left, RES_PARATR_ADJUST);
1227 rSh.SetAttrItem(aAdjustItem);
1228 break;
1229 }
1230 case 1:
1231 {
1232 SvxAdjustItem aAdjustItem(SvxAdjust::Center, RES_PARATR_ADJUST);
1233 rSh.SetAttrItem(aAdjustItem);
1234 break;
1235 }
1236 case 2:
1237 {
1238 SvxAdjustItem aAdjustItem(SvxAdjust::Right, RES_PARATR_ADJUST);
1239 rSh.SetAttrItem(aAdjustItem);
1240 break;
1241 }
1242 }
1243
1244 sal_Int32 nStartContentIndex = rSh.GetCursor()->Start()->GetContentIndex();
1245 assert(!nStartContentIndex && "earlier split node if not empty, but not zero?");
1246
1247 // Insert page number
1248 SwFieldMgr aMgr(pShell);
1250 OUString(), OUString(), SVX_NUM_PAGEDESC);
1251 aMgr.InsertField(aData);
1252 if (pDlg->GetIncludePageTotal())
1253 {
1254 rDoc->getIDocumentContentOperations().InsertString(*rSh.GetCursor(), " / ");
1256 OUString(), OUString(), SVX_NUM_PAGEDESC);
1257 aMgr.InsertField(aPageTotalData);
1258 }
1259
1260 // Mark inserted fields with a bookmark - so it can be found/removed if re-run
1261 SwPaM aNewBookmarkPaM(*rSh.GetCursor()->Start());
1262 aNewBookmarkPaM.SetMark();
1263 assert(aNewBookmarkPaM.GetPointContentNode() && "only SetContent on content node");
1264 aNewBookmarkPaM.Start()->SetContent(nStartContentIndex);
1265 rIDMA.makeMark(aNewBookmarkPaM,
1266 sBookmarkName + OUString::number(rSh.GetVirtPageNum()),
1269
1270 // Mirror on the even pages
1271 if (!bSkipMirror && bCreateMirror
1272 && rSh.SetCursorInHdFt(nPageDescIndex, bHeader, /*Even=*/true))
1273 {
1274 assert(nEvenPage && "what? no even page and yet we got here?");
1275 ppMark = rIDMA.findMark(sBookmarkName + OUString::number(rSh.GetVirtPageNum()));
1276 if (ppMark != rIDMA.getAllMarksEnd() && *ppMark)
1277 {
1278 SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd());
1279 rDoc->getIDocumentContentOperations().DeleteAndJoin(aDeleteOldPageNum);
1280 }
1281
1282 pTextNode = rSh.GetCursor()->GetPoint()->GetNode().GetTextNode();
1283
1284 // Insert new line if there is already text in header/footer
1285 if (pTextNode && !pTextNode->GetText().isEmpty())
1286 {
1288 *rSh.GetCursor()->GetPoint(), false);
1289 // Go back to start of header/footer
1290 rSh.SetCursorInHdFt(nPageDescIndex, bHeader, /*Even=*/true);
1291 }
1292
1293 // mirror the adjustment
1294 assert(pDlg->GetPageNumberAlignment() != 1 && "cannot have Center and bMirror");
1295 SvxAdjust eAdjust = SvxAdjust::Left;
1296 if (!pDlg->GetPageNumberAlignment())
1297 eAdjust = SvxAdjust::Right;
1298 SvxAdjustItem aMirrorAdjustItem(eAdjust, RES_PARATR_ADJUST);
1299 rSh.SetAttrItem(aMirrorAdjustItem);
1300
1301 nStartContentIndex = rSh.GetCursor()->Start()->GetContentIndex();
1302
1303 // Insert page number
1304 SwFieldMgr aEvenMgr(pShell);
1305 aEvenMgr.InsertField(aData);
1306 if (pDlg->GetIncludePageTotal())
1307 {
1308 rDoc->getIDocumentContentOperations().InsertString(*rSh.GetCursor(), " / ");
1310 DS_PAGE, OUString(), OUString(),
1312 aMgr.InsertField(aPageTotalData);
1313 }
1314
1315 // Mark inserted fields with a bookmark - so it can be found/removed if re-run
1316 SwPaM aNewEvenBookmarkPaM(*rSh.GetCursor()->Start());
1317 aNewEvenBookmarkPaM.SetMark();
1318 aNewEvenBookmarkPaM.Start()->SetContent(nStartContentIndex);
1319 rIDMA.makeMark(aNewEvenBookmarkPaM,
1320 sBookmarkName + OUString::number(rSh.GetVirtPageNum()),
1323 }
1324
1325 rSh.SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent);
1326 rSh.EndAllAction();
1327 rSh.LockView(false);
1328 rDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_PAGE_NUMBER, nullptr);
1329 }
1330 pDlg->disposeOnce();
1331 });
1332 rReq.Done();
1333 }
1334 break;
1336 {
1337 // This updates a single fieldmark under the current cursor.
1338 OUString aFieldType;
1339 const SfxStringItem* pFieldType = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
1340 if (pFieldType)
1341 {
1342 aFieldType = pFieldType->GetValue();
1343 }
1344 OUString aFieldCommandPrefix;
1345 const SfxStringItem* pFieldCommandPrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
1346 if (pFieldCommandPrefix)
1347 {
1348 aFieldCommandPrefix = pFieldCommandPrefix->GetValue();
1349 }
1350 uno::Sequence<beans::PropertyValue> aField;
1351 const SfxUnoAnyItem* pFields = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3);
1352 if (pFields)
1353 {
1354 pFields->GetValue() >>= aField;
1355 }
1356
1358 SwPosition& rCursor = *rSh.GetCursor()->GetPoint();
1359 sw::mark::IFieldmark* pFieldmark = rIDMA.getInnerFieldmarkFor(rCursor);
1360 if (!pFieldmark)
1361 {
1362 break;
1363 }
1364
1365 if (pFieldmark->GetFieldname() != aFieldType)
1366 {
1367 break;
1368 }
1369
1370 auto itParam = pFieldmark->GetParameters()->find(ODF_CODE_PARAM);
1371 if (itParam == pFieldmark->GetParameters()->end())
1372 {
1373 break;
1374 }
1375
1376 OUString aCommand;
1377 itParam->second >>= aCommand;
1378 if (!aCommand.startsWith(aFieldCommandPrefix))
1379 {
1380 break;
1381 }
1382
1383 rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FORM_FIELD, nullptr);
1384 rSh.StartAction();
1386 itParam->second = aMap["FieldCommand"];
1387 SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos());
1388 aPaM.Normalize();
1389 // Skip field start & separator.
1390 aPaM.GetPoint()->AdjustContent(2);
1391 // Skip field end.
1392 aPaM.GetMark()->AdjustContent(-1);
1394 OUString aFieldResult;
1395 aMap["FieldResult"] >>= aFieldResult;
1396 SwTranslateHelper::PasteHTMLToPaM(rSh, &aPaM, aFieldResult.toUtf8());
1397
1398 rSh.EndAction();
1399 rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FORM_FIELD, nullptr);
1400 }
1401 break;
1402 default:
1403 OSL_FAIL("wrong dispatcher");
1404 return;
1405 }
1406}
1407
1409{
1410 SwWrtShell& rSh = GetShell();
1411 SfxWhichIter aIter( rSet );
1412 const SwField* pField = nullptr;
1413 bool bGetField = false;
1414 sal_uInt16 nWhich = aIter.FirstWhich();
1415
1416 while (nWhich)
1417 {
1418 switch (nWhich)
1419 {
1420 case FN_DELETE_COMMENT:
1424 case FN_HIDE_NOTE:
1426 case FN_HIDE_ALL_NOTES:
1427 {
1428 SwPostItMgr* pPostItMgr = GetView().GetPostItMgr();
1429 if ( !pPostItMgr )
1430 rSet.InvalidateItem( nWhich );
1431 else if ( !pPostItMgr->HasActiveSidebarWin() )
1432 {
1435 }
1436 // tdf#137568 do not offer comment formatting, if no comments are present
1437 if (!pPostItMgr || !pPostItMgr->HasNotes())
1439 }
1440 break;
1441
1442 case FN_EDIT_FIELD:
1443 {
1444 if( !bGetField )
1445 {
1446 pField = rSh.GetCurField(true);
1447 bGetField = true;
1448 }
1449
1450 SwFieldIds nTempWhich = pField ? pField->GetTyp()->Which() : SwFieldIds::Unknown;
1451 if( SwFieldIds::Unknown == nTempWhich ||
1452 SwFieldIds::Postit == nTempWhich ||
1453 SwFieldIds::Script == nTempWhich ||
1454 SwFieldIds::TableOfAuthorities == nTempWhich )
1455 rSet.DisableItem( nWhich );
1456 else if( SwFieldIds::Dde == nTempWhich &&
1457 !static_cast<SwDDEFieldType*>(pField->GetTyp())->GetBaseLink().IsVisible())
1458 {
1459 // nested links cannot be edited
1460 rSet.DisableItem( nWhich );
1461 }
1462 }
1463 break;
1464
1466 {
1467 pField = rSh.GetCurField();
1468
1469 if (!pField)
1470 rSet.DisableItem( nWhich );
1471 }
1472
1473 break;
1474
1476 {
1477 if(!bGetField)
1478 {
1479 pField = rSh.GetCurField();
1480 bGetField = true;
1481 }
1482 if(!pField || pField->GetTyp()->Which() != SwFieldIds::Macro)
1483 rSet.DisableItem(nWhich);
1484 }
1485 break;
1486
1487 case FN_INSERT_FIELD:
1488 {
1489 if ( rSh.CursorInsideInputField() )
1490 {
1491 rSet.DisableItem(nWhich);
1492 }
1493 else
1494 {
1495 SfxViewFrame& rVFrame = GetView().GetViewFrame();
1496 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
1497 if(!rVFrame.IsInModalMode() &&
1500 else
1502 }
1503 }
1504 break;
1505
1507 {
1508 SfxViewFrame& rVFrame = GetView().GetViewFrame();
1509 if ( !rVFrame.KnowsChildWindow(FN_INSERT_FIELD)
1510 || rSh.CursorInsideInputField() )
1511 {
1513 }
1514 }
1515 break;
1516
1518 if ( rSh.CursorInsideInputField() )
1519 {
1520 rSet.DisableItem(nWhich);
1521 }
1522 else
1523 {
1524 rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame().HasChildWindow(FN_INSERT_FIELD)));
1525 }
1526 break;
1527
1528 case FN_REDLINE_COMMENT:
1530 rSet.DisableItem(nWhich);
1531 break;
1532
1533 case FN_REPLY:
1535 rSet.DisableItem(nWhich);
1536 break;
1537
1538 case FN_POSTIT :
1539 case FN_JAVAEDIT :
1540 {
1541 bool bCurField = false;
1542 pField = rSh.GetCurField();
1543 if(nWhich == FN_POSTIT)
1544 bCurField = pField && pField->GetTyp()->Which() == SwFieldIds::Postit;
1545 else
1546 bCurField = pField && pField->GetTyp()->Which() == SwFieldIds::Script;
1547
1548 if( !bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() )
1549 {
1550 rSet.DisableItem(nWhich);
1551 }
1552 else if ( rSh.CursorInsideInputField() )
1553 {
1554 rSet.DisableItem(nWhich);
1555 }
1556 // tdf#86188, tdf#135794: Allow disabling comment insertion
1557 // on footnote/endnote/header/frames for better OOXML interoperability
1559 (rSh.IsCursorInFootnote() || rSh.IsInHeaderFooter() ||
1560 rSh.GetCurrFlyFrame(/*bCalcFrame=*/false)))
1561 {
1562 rSet.DisableItem(nWhich);
1563 }
1564 }
1565
1566 break;
1567
1569 case FN_INSERT_FLD_DATE:
1572 case FN_INSERT_FLD_TIME:
1575 case FN_INSERT_DBFIELD:
1576 if ( rSh.CursorInsideInputField() )
1577 {
1578 rSet.DisableItem(nWhich);
1579 }
1580 break;
1581
1586 if ( rSh.CursorInsideInputField() )
1587 {
1588 rSet.DisableItem(nWhich);
1589 }
1590 else
1591 {
1592 // Check whether we are in a text form field
1593 SwPosition aCursorPos(*rSh.GetCursor()->GetPoint());
1594 sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getInnerFieldmarkFor(aCursorPos);
1595 if ((!pFieldBM || pFieldBM->GetFieldname() != ODF_FORMTEXT)
1596 && aCursorPos.GetContentIndex() > 0)
1597 {
1598 SwPosition aPos(*aCursorPos.GetContentNode(), aCursorPos.GetContentIndex() - 1);
1600 }
1601 if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMTEXT &&
1602 (aCursorPos > pFieldBM->GetMarkStart() && aCursorPos < pFieldBM->GetMarkEnd() ))
1603 {
1604 rSet.DisableItem(nWhich);
1605 }
1606 }
1607 break;
1608
1609 }
1610 nWhich = aIter.NextWhich();
1611 }
1612}
1613
1615{
1616 const OUString& rName = rHlnkItem.GetName();
1617 const OUString& rURL = rHlnkItem.GetURL();
1618 const OUString& rTarget = rHlnkItem.GetTargetFrame();
1619 const OUString& rReplacementText = rHlnkItem.GetReplacementText();
1620 sal_uInt16 nType = o3tl::narrowing<sal_uInt16>(rHlnkItem.GetInsertMode());
1621 nType &= ~HLINK_HTMLMODE;
1622 const SvxMacroTableDtor* pMacroTable = rHlnkItem.GetMacroTable();
1623
1624 SwWrtShell& rSh = GetShell();
1625
1626 if( !(rSh.GetSelectionType() & SelectionType::Text) )
1627 return;
1628
1629 rSh.StartAction();
1631 rSh.GetCurAttr( aSet );
1632
1633 if(SfxItemState::SET == aSet.GetItemState(RES_TXTATR_INETFMT, false))
1634 {
1635 // Select links
1636 rSh.SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT, false);
1637 }
1638 switch (nType)
1639 {
1640 case HLINK_DEFAULT:
1641 case HLINK_FIELD:
1642 {
1643 SwFormatINetFormat aINetFormat( rURL, rTarget );
1644 aINetFormat.SetName(rHlnkItem.GetIntName());
1645 if(pMacroTable)
1646 {
1647 const SvxMacro *pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOver );
1648 if( pMacro )
1649 aINetFormat.SetMacro(SvMacroItemId::OnMouseOver, *pMacro);
1650 pMacro = pMacroTable->Get( SvMacroItemId::OnClick );
1651 if( pMacro )
1652 aINetFormat.SetMacro(SvMacroItemId::OnClick, *pMacro);
1653 pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOut );
1654 if( pMacro )
1655 aINetFormat.SetMacro(SvMacroItemId::OnMouseOut, *pMacro);
1656 }
1657 rSh.SttSelect();
1658 // inserting mention
1659 if (comphelper::LibreOfficeKit::isActive() && !rReplacementText.isEmpty())
1660 {
1661 SwPaM* pCursorPos = rSh.GetCursor();
1662 // move cursor backwards to select @mention
1663 for(int i=0; i < rReplacementText.getLength(); i++)
1664 pCursorPos->Move(fnMoveBackward);
1665 rSh.InsertURL( aINetFormat, rName, false );
1666 }
1667 else
1668 {
1669 rSh.InsertURL( aINetFormat, rName, true );
1670 }
1671 rSh.EndSelect();
1672 }
1673 break;
1674
1675 case HLINK_BUTTON:
1676 bool bSel = rSh.HasSelection();
1677 if(bSel)
1678 rSh.DelRight();
1679 InsertURLButton( rURL, rTarget, rName );
1680 rSh.EnterStdMode();
1681 break;
1682 }
1683 rSh.EndAction();
1684}
1685
1686IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog&, rDlg, void )
1687{
1688 SwWrtShell* pSh = GetShellPtr();
1689
1690 // Insert or change a comment.
1691 pSh->SetRedlineComment(rDlg.GetNote());
1692
1693 const SwRangeRedline *pRedline = pSh->GetCurrRedline();
1694
1695 if (!pRedline)
1696 return;
1697
1698 // Traveling only if more than one field.
1699 if( !pSh->IsCursorPtAtEnd() )
1700 pSh->SwapPam(); // Move the cursor behind the Redline.
1701
1702 pSh->Push();
1703 const SwRangeRedline *pActRed = pSh->SelNextRedline();
1705
1706 bool bEnable = false;
1707
1708 if (pActRed)
1709 {
1710 pSh->StartAction();
1711 pSh->Push();
1712 bEnable = pSh->SelNextRedline() != nullptr;
1714 pSh->EndAction();
1715 }
1716
1717 rDlg.EnableTravel(bEnable, true);
1718
1719 if( pSh->IsCursorPtAtEnd() )
1720 pSh->SwapPam();
1721
1722 pRedline = pSh->GetCurrRedline();
1723 OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
1724
1725 rDlg.SetNote(sComment);
1726 rDlg.ShowLastAuthor( pRedline->GetAuthorString(),
1728 pRedline->GetRedlineData().GetTimeStamp() ));
1729
1730 rDlg.SetText(lcl_BuildTitleWithRedline(pRedline));
1731
1732}
1733
1734IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog&, rDlg, void )
1735{
1736 SwWrtShell* pSh = GetShellPtr();
1737
1738 // Insert or change a comment.
1739 pSh->SetRedlineComment(rDlg.GetNote());
1740
1741 const SwRangeRedline *pRedline = pSh->GetCurrRedline();
1742
1743 if (!pRedline)
1744 return;
1745
1746 // Traveling only if more than one field.
1747 pSh->Push();
1748 const SwRangeRedline *pActRed = pSh->SelPrevRedline();
1750
1751 bool bEnable = false;
1752
1753 if (pActRed)
1754 {
1755 pSh->StartAction();
1756 pSh->Push();
1757 bEnable = pSh->SelPrevRedline() != nullptr;
1759 pSh->EndAction();
1760 }
1761
1762 rDlg.EnableTravel(true, bEnable);
1763
1764 pRedline = pSh->GetCurrRedline();
1765 OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd());
1766
1767 rDlg.SetNote(sComment);
1768 rDlg.ShowLastAuthor(pRedline->GetAuthorString(),
1770 pRedline->GetRedlineData().GetTimeStamp() ));
1771
1772 rDlg.SetText(lcl_BuildTitleWithRedline(pRedline));
1773
1774}
1775
1776/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
#define GetWhich(nSlot)
sal_Int32 GetValue() const
const OUString & GetValue() const
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides access to the marks of a document.
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr)=0
virtual const_iterator_t getFieldmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of fieldmarks.
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
virtual sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark, ::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
Generates a new mark in the document for a certain selection.
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark, bool isMoveNodes)=0
Deletes a mark.
virtual const SwRedlineTable & GetRedlineTable() const =0
const OUString & getBcp47(bool bResolveSystem=true) const
void Invalidate(sal_uInt16 nId)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
void Done(bool bRemove=false)
SfxItemPool & GetPool() const
virtual void Invalidate(sal_uInt16 nId=0)
bool IsActive() const
const css::uno::Any & GetValue() const
void ToggleChildWindow(sal_uInt16)
bool IsInModalMode() const
SfxBindings & GetBindings()
bool HasChildWindow(sal_uInt16)
SfxChildWindow * GetChildWindow(sal_uInt16)
bool KnowsChildWindow(sal_uInt16)
weld::Window * GetFrameWeld() const
SfxViewFrame & GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
LanguageType GetLanguage() const
const OUString & GetFormatstring() const
virtual VclPtr< AbstractSvxPostItDialog > CreateSvxPostItDialog(weld::Widget *pParent, const SfxItemSet &rCoreSet, bool bPrevNext=false)=0
static SvxAbstractDialogFactory * Create()
virtual DialogGetRanges GetDialogGetRangesFunc()=0
const OUString & GetReplacementText() const
SvxLinkInsertMode GetInsertMode() const
const OUString & GetName() const
const OUString & GetURL() const
const OUString & GetIntName() const
const SvxMacroTableDtor * GetMacroTable() const
const OUString & GetTargetFrame() const
const SvxMacro * Get(SvMacroItemId nEvent) const
void SetNumberingType(SvxNumType nSet)
SvxNumType GetNumberingType() const
virtual VclPtr< SfxAbstractDialog > CreateSwFieldEditDlg(SwView &rVw)=0
virtual VclPtr< AbstractJavaEditDialog > CreateJavaEditDialog(weld::Window *pParent, SwWrtShell *pWrtSh)=0
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
virtual VclPtr< AbstractSwPageNumberDlg > CreateSwPageNumberDlg(weld::Window *pParent)=0
SwWrtShell & GetShell()
Definition: basesh.cxx:3001
SwView & GetView()
Definition: basesh.hxx:59
void InsertURLButton(const OUString &rURL, const OUString &rTarget, const OUString &rText)
Definition: textdrw.cxx:43
SwWrtShell * GetShellPtr()
Definition: basesh.cxx:3006
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2550
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:494
void StartAction()
Definition: crsrsh.cxx:226
bool GotoHeaderText()
jump from the content to the header
Definition: crstrvl.cxx:132
void SwapPam()
Definition: crsrsh.cxx:1262
bool IsMultiSelection() const
Definition: crsrsh.hxx:915
bool SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven=false, bool bFirst=false)
Definition: crstrvl.cxx:192
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
bool SelectTextModel(sal_Int32 nStart, sal_Int32 nEnd)
Definition: crstrvl.cxx:2197
bool CursorInsideInputField() const
Definition: crstrvl.cxx:1094
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1073
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
static sal_Int32 StartOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1141
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2771
static SwTextField * GetTextFieldAtCursor(const SwPaM *pCursor, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1040
const SwRangeRedline * SelNextRedline()
Definition: crstrvl.cxx:2477
void ClearMark()
Definition: crsrsh.cxx:1225
const SwRangeRedline * SelPrevRedline()
Definition: crstrvl.cxx:2504
static sal_Int32 EndOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1149
bool HasReadonlySel(bool isReplace=false) const
Definition: crsrsh.cxx:3662
bool IsInHeaderFooter(bool *pbInHeader=nullptr) const
Definition: crsrsh.cxx:1038
bool IsCursorPtAtEnd() const
Definition: crsrsh.hxx:920
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:674
bool IsCursorInFootnote() const
Definition: crsrsh.cxx:1437
bool GotoFooterText()
jump from the content to the footer
Definition: crstrvl.cxx:160
sal_uInt16 GetPageCnt()
Definition: crsrsh.cxx:1591
const ::sfx2::SvBaseLink & GetBaseLink() const
Definition: ddefld.hxx:90
Definition: doc.hxx:197
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:329
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:349
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1890
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1429
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:171
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void SetUndoNoResetModified()
Definition: edws.cxx:80
bool SetRedlineComment(const OUString &rS)
Set comment to Redline at position.
Definition: edredln.cxx:150
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:98
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:756
bool InsertURL(const SwFormatINetFormat &rFormat, const OUString &rStr, bool bKeepSelection=false)
Definition: editsh.cxx:633
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
void UpdateOneField(SwField &)
One single field.
Definition: edfld.cxx:200
const SwRangeRedline * GetCurrRedline() const
Definition: edredln.cxx:161
sfx2::LinkManager & GetLinkManager()
Definition: editsh.cxx:592
void EndAllAction()
Definition: edws.cxx:97
void ChgPageDesc(size_t i, const SwPageDesc &)
Definition: fedesc.cxx:111
size_t GetCurPageDesc(const bool bCalcFrame=true) const
Definition: fedesc.cxx:167
SwFlyFrame * GetCurrFlyFrame(const bool bCalcFrame=true) const
Definition: fefly1.cxx:296
sal_uInt16 GetVirtPageNum() const
Definition: fews.cxx:343
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:126
void ShowReferencePage()
Definition: fldwrap.cxx:90
sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter *pFormatter)
Definition: fldmgr.cxx:1889
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
Definition: fldmgr.cxx:1569
bool InsertField(SwInsertField_Data &rData)
Definition: fldmgr.cxx:895
SwField * GetCurField()
Definition: fldmgr.cxx:430
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
SwFieldIds Which() const
Definition: fldbas.hxx:276
SwFormatField * FindFormatForPostItId(sal_uInt32 nPostItId) const
Definition: fldbas.cxx:177
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:270
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:407
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:65
const SwFrameFormat * GetFooterFormat() const
Definition: fmthdft.hxx:85
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:34
const SwFrameFormat * GetHeaderFormat() const
Definition: fmthdft.hxx:54
void SetMacro(SvMacroItemId nEvent, const SvxMacro &rMacro)
Macro getter and setter.
Definition: fmtatr2.cxx:261
void SetName(const OUString &rNm)
Definition: fmtinfmt.hxx:84
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
Style of a layout element.
Definition: frmfmt.hxx:72
IDocumentContentOperations & getIDocumentContentOperations()
Provides access to the document content operations interface.
Definition: node.cxx:2149
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
const SwPosition * GetMark() const
Definition: pam.hxx:255
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:643
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:689
SwContentNode * GetPointContentNode() const
Definition: pam.hxx:279
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:657
SwDoc & GetDoc() const
Definition: pam.hxx:291
const SwPosition * GetPoint() const
Definition: pam.hxx:253
const SwPosition * Start() const
Definition: pam.hxx:258
void ChgFooterShare(bool bNew)
Definition: pagedesc.hxx:334
const OUString & GetName() const
Definition: pagedesc.hxx:196
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
bool IsHeaderShared() const
Definition: pagedesc.hxx:319
const SvxNumberType & GetNumType() const
Definition: pagedesc.hxx:202
void ChgHeaderShare(bool bNew)
Definition: pagedesc.hxx:327
bool IsFirstShared() const
Definition: pagedesc.cxx:396
bool IsFooterShared() const
Definition: pagedesc.hxx:323
void SetNumType(const SvxNumberType &rNew)
Definition: pagedesc.hxx:203
const SwPageDesc * GetFollow() const
Definition: pagedesc.hxx:267
void WriteUseOn(UseOnPage const eNew)
Definition: pagedesc.hxx:235
UseOnPage ReadUseOn() const
Definition: pagedesc.hxx:236
void Delete(const OUString &aAuthor)
Definition: PostItMgr.cxx:1510
sw::annotation::SwAnnotationWin * GetAnnotationWin(const SwPostItField *pField) const
Definition: PostItMgr.cxx:1783
void HideActiveSidebarWin()
Definition: PostItMgr.cxx:2407
bool HasNotes() const
Definition: PostItMgr.cxx:2116
void ToggleResolved(sal_uInt32 nPostItId)
Definition: PostItMgr.cxx:1589
void Hide(std::u16string_view rAuthor)
Definition: PostItMgr.cxx:1740
void ExecuteFormatAllDialog(SwView &rView)
Definition: PostItMgr.cxx:1667
void DeleteCommentThread(sal_uInt32 nPostItId)
Definition: PostItMgr.cxx:1565
void ToggleResolvedForThread(sal_uInt32 nPostItId)
Definition: PostItMgr.cxx:1614
void DeleteActiveSidebarWin()
Definition: PostItMgr.cxx:2399
SW_DLLPUBLIC bool HasActiveSidebarWin() const
Definition: PostItMgr.cxx:2372
const OUString & GetComment(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1985
OUString const & GetAuthorString(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1965
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1975
const SwRedlineData & GetRedlineData(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1998
const DateTime & GetTimeStamp() const
Definition: redline.hxx:130
size_type size() const
Definition: docary.hxx:268
vector_type::size_type size_type
Definition: docary.hxx:223
virtual OUString GetPar1() const override
Type.
Definition: scrptfld.cxx:66
virtual OUString GetPar2() const override
Text.
Definition: scrptfld.cxx:77
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
const OUString & GetText() const
Definition: ndtxt.hxx:244
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
Definition: thints.cxx:3474
void StateField(SfxItemSet &)
Definition: textfld.cxx:1408
void InsertHyperlink(const SvxHyperlinkItem &rHlnkItem)
Definition: textfld.cxx:1614
void ExecField(SfxRequest &rReq)
Definition: textfld.cxx:109
bool IsReadonly() const
Definition: viewopt.hxx:627
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:452
static void SetCareDialog(const std::shared_ptr< weld::Window > &rNew)
Definition: viewsh.cxx:2669
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2821
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2835
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
void LockView(bool b)
Definition: viewsh.hxx:491
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:650
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
const SwRangeRedline * GotoRedline(SwRedlineTable::size_type nArrPos, bool bSelect)
Definition: move.cxx:755
void EndSelect()
Definition: select.cxx:434
void InsertPostIt(SwFieldMgr &rFieldMgr, const SfxRequest &rReq)
Inserts a new annotation/comment at the current cursor position / selection.
Definition: wrtsh1.cxx:2228
bool StartInputFieldDlg(SwField *, bool bPrevButton, bool bNextButton, weld::Widget *pParentWin, FieldDialogPressedButton *pPressedButton=nullptr)
Definition: wrtsh2.cxx:264
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:272
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1723
void EnterStdMode()
Definition: select.cxx:560
void ExecMacro(const SvxMacro &rMacro, OUString *pRet=nullptr, SbxArray *pArgs=nullptr)
Definition: wrtsh3.cxx:319
void InsertFootnote(const OUString &, bool bEndNote=false, bool bEdit=true)
Definition: wrtsh1.cxx:1175
bool DelRight(bool isReplaceHeuristic=false)
Definition: delete.cxx:285
bool HasSelection() const
Definition: wrtsh.hxx:147
void SttSelect()
Definition: select.cxx:394
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
Definition: wrtsh1.cxx:2047
const SwView & GetView() const
Definition: wrtsh.hxx:443
void disposeAndClear()
void UpdateText(const OUString &aText)
void ExecuteCommand(sal_uInt16 nSlot)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
#define FN_RESOLVE_NOTE
Definition: cmdid.h:795
#define FN_REPLY
Definition: cmdid.h:793
#define FN_INSERT_REF_FIELD
Definition: cmdid.h:218
#define FN_GOTO_MARK
Definition: cmdid.h:110
#define FN_DELETE_NOTE_AUTHOR
Definition: cmdid.h:786
#define FN_UPDATE_TEXT_FORMFIELDS
Definition: cmdid.h:317
#define FN_JAVAEDIT
Definition: cmdid.h:294
#define FN_HIDE_NOTE_AUTHOR
Definition: cmdid.h:789
#define FN_INSERT_FLD_TIME
Definition: cmdid.h:278
#define FN_INSERT_FLD_AUTHOR
Definition: cmdid.h:283
#define FN_INSERT_FLD_TOPIC
Definition: cmdid.h:281
#define FN_INSERT_DBFIELD
Definition: cmdid.h:215
#define FN_POSTIT
Definition: cmdid.h:233
#define FN_INSERT_FLD_PGNUMBER
Definition: cmdid.h:279
#define FN_GOTO_PREV_INPUTFLD
Definition: cmdid.h:109
#define FN_INSERT_FIELD_CTRL
Definition: cmdid.h:275
#define FN_PGNUMBER_WIZARD
Definition: cmdid.h:246
#define FN_INSERT_FLD_DATE
Definition: cmdid.h:277
#define FN_REDLINE_COMMENT
Definition: cmdid.h:132
#define FN_HIDE_ALL_NOTES
Definition: cmdid.h:790
#define FN_DELETE_ALL_NOTES
Definition: cmdid.h:787
#define FN_HIDE_NOTE
Definition: cmdid.h:788
#define FN_UPDATE_SEL_FIELD
Definition: cmdid.h:81
#define FN_UPDATE_TEXT_FORMFIELD
Definition: cmdid.h:318
#define FN_INSERT_FIELD
Definition: cmdid.h:211
#define FN_DELETE_COMMENT
Definition: cmdid.h:792
#define FN_INSERT_FIELD_DATA_ONLY
Definition: cmdid.h:223
#define FN_DELETE_COMMENT_THREAD
Definition: cmdid.h:797
#define FN_INSERT_FLD_PGCOUNT
Definition: cmdid.h:280
#define FN_EDIT_FIELD
Definition: cmdid.h:77
#define FN_RESOLVE_NOTE_THREAD
Definition: cmdid.h:796
#define FN_INSERT_DATE_FORMFIELD
Definition: cmdid.h:312
#define FN_GOTO_NEXT_INPUTFLD
Definition: cmdid.h:108
#define FN_PARAM_FIELD_SUBTYPE
Definition: cmdid.h:823
#define FN_PARAM_FIELD_FORMAT
Definition: cmdid.h:824
#define FN_FORMAT_ALL_NOTES
Definition: cmdid.h:794
#define FN_DELETE_TEXT_FORMFIELDS
Definition: cmdid.h:328
#define FN_INSERT_FLD_TITLE
Definition: cmdid.h:282
#define FN_EXECUTE_MACROFIELD
Definition: cmdid.h:84
#define FN_INSERT_CHECKBOX_FORMFIELD
Definition: cmdid.h:308
#define FN_INSERT_DROPDOWN_FORMFIELD
Definition: cmdid.h:309
#define FN_INSERT_TEXT_FORMFIELD
Definition: cmdid.h:307
#define FN_PARAM_FIELD_TYPE
Definition: cmdid.h:822
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
virtual sal_uInt32 GetId() const override
void MaybeNotifyRedlineModification(SwRangeRedline &rRedline, SwDoc &rDoc)
Definition: docredln.cxx:1220
@ DS_PAGE
Definition: docufld.hxx:54
float u
FilterGroup & rTarget
SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view rString)
Definition: fldbas.cxx:539
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:98
SwFieldIds
Definition: fldbas.hxx:49
@ TableOfAuthorities
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
HLINK_FIELD
HLINK_DEFAULT
HLINK_BUTTON
#define LANGUAGE_HUNGARIAN
LineEnd GetSystemLineEnd()
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
sal_uInt16 nPos
STARBASIC
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
SW_DLLPUBLIC void PasteHTMLToPaM(SwWrtShell &rWrtSh, SwPaM *pCursor, const OString &rData)
int i
const SwDocInfoSubType DI_SUB_AUTHOR
Definition: docufld.hxx:83
const SwDocInfoSubType DI_SUBJECT
Definition: docufld.hxx:72
const SwDocInfoSubType DI_TITLE
Definition: docufld.hxx:71
const SwDocInfoSubType DI_CREATE
Definition: docufld.hxx:75
constexpr auto toTwips(N number, Length from)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
HashMap_OWString_Interface aMap
constexpr OUStringLiteral ODF_FORMTEXT
constexpr OUStringLiteral ODF_FORMDATE_DATEFORMAT
constexpr OUStringLiteral ODF_CODE_PARAM
constexpr OUStringLiteral ODF_FORMCHECKBOX
#define ODF_FORMFIELD_DEFAULT_LENGTH
constexpr OUStringLiteral ODF_FORMDATE
constexpr OUStringLiteral ODF_FORMDATE_DATEFORMAT_LANGUAGE
constexpr OUStringLiteral ODF_FORMDROPDOWN
sal_Int16 nId
const char GetValue[]
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1203
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
constexpr tools::Long constTwips_5mm
Definition: pggrid.cxx:38
QPRO_FUNC_TYPE nType
static SfxItemSet & rSet
static LanguageType nLang
Definition: srtdlg.cxx:51
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:267
const SwContentNode * GetContentNode() const
Definition: pam.hxx:84
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
void AdjustContent(sal_Int32 nDelta)
Adjust content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:262
SVX_NUM_PAGEDESC
SvxAdjust
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
bool g_bNoInterrupt
Definition: swmodule.cxx:115
#define DB_DELIM
Definition: swtypes.hxx:130
@ UPDATE_FORM_FIELD
@ INSERT_PAGE_NUMBER
@ INSERT_FORM_FIELD
@ UPDATE_FORM_FIELDS
@ DELETE_FORM_FIELDS
IMPL_LINK(SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog &, rDlg, void)
Definition: textfld.cxx:1686
static OUString lcl_BuildTitleWithRedline(const SwRangeRedline *pRedline)
Definition: textfld.cxx:79
OUString aCommand
sal_uInt16 sal_Unicode
OUString GetAppLangDateTimeString(const DateTime &)
Definition: uitool.cxx:863
RET_OK
NF_DATE_SYSTEM_LONG