LibreOffice Module sw (master) 1
fldmgr.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 <config_features.h>
21#include <config_fuzzers.h>
22
23#include <cmdid.h>
24#include <hintids.hxx>
25#include <svl/numformat.hxx>
26#include <svl/stritem.hxx>
27#include <com/sun/star/text/DefaultNumberingProvider.hpp>
28#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
29#include <com/sun/star/text/XNumberingTypeInfo.hpp>
30#include <com/sun/star/style/NumberingType.hpp>
31#include <com/sun/star/beans/XPropertySet.hpp>
32#include <com/sun/star/sdbc/XConnection.hpp>
33#include <com/sun/star/sdbc/XDataSource.hpp>
34#include <com/sun/star/uri/UriReferenceFactory.hpp>
35#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
37#include <comphelper/string.hxx>
38#include <o3tl/string_view.hxx>
39#include <tools/resary.hxx>
40#include <osl/diagnose.h>
41#include <sfx2/dispatch.hxx>
42#include <sfx2/linkmgr.hxx>
43#include <sfx2/app.hxx>
44#include <sfx2/viewfrm.hxx>
45#include <svx/strarray.hxx>
46#include <fmtrfmrk.hxx>
47#include <svl/zforlist.hxx>
48#include <svl/zformat.hxx>
49#include <vcl/mnemonic.hxx>
50#include <view.hxx>
51#include <wrtsh.hxx>
52#include <doc.hxx>
53#include <swmodule.hxx>
54#include <fmtinfmt.hxx>
55#include <cellatr.hxx>
56#include <dbmgr.hxx>
57#include <shellres.hxx>
58#include <fldbas.hxx>
59#include <docufld.hxx>
60#include <chpfld.hxx>
61#include <ddefld.hxx>
62#include <expfld.hxx>
63#include <reffld.hxx>
64#include <usrfld.hxx>
65#include <dbfld.hxx>
66#include <authfld.hxx>
67#include <flddat.hxx>
68#include <fldmgr.hxx>
69#include <flddropdown.hxx>
70#include <strings.hrc>
71#include <tox.hxx>
72#include <viewopt.hxx>
73#include <txmsrt.hxx>
76#include <translatehelper.hxx>
77
78using namespace com::sun::star::uno;
79using namespace com::sun::star::container;
80using namespace com::sun::star::lang;
81using namespace com::sun::star::beans;
82using namespace com::sun::star::text;
83using namespace com::sun::star::style;
84using namespace com::sun::star::sdbc;
85using namespace ::com::sun::star;
86using namespace nsSwDocInfoSubType;
87
88// groups of fields
89enum
90{
93
96
99
102
105
109
110enum
111{
114
116 GRP_WEB_FKT_END = GRP_WEB_FKT_BEGIN + 0, // the group is empty!
117
118 GRP_WEB_REF_BEGIN = GRP_WEB_FKT_END + 6, // the group is empty!
120
123
124 GRP_WEB_DB_BEGIN = GRP_WEB_REG_END, // the group is empty!
126
130
131const sal_uInt16 VF_COUNT = 1; // { 0 }
132const sal_uInt16 VF_USR_COUNT = 2; // { 0, nsSwExtendedSubType::SUB_CMD }
133const sal_uInt16 VF_DB_COUNT = 1; // { nsSwExtendedSubType::SUB_OWN_FMT }
134
136{
137 FLD_EU_COMPANY,
138 FLD_EU_GIVENNAME,
139 FLD_EU_SURNAME,
140 FLD_EU_INITIALS,
141 FLD_EU_STREET,
142 FLD_EU_COUNTRY,
143 FLD_EU_POSTCODE,
144 FLD_EU_TOWN,
145 FLD_EU_TITLE,
146 FLD_EU_POS,
147 FLD_EU_TELPERSONAL,
148 FLD_EU_TELWORK,
149 FLD_EU_FAX,
150 FLD_EU_EMAIL,
151 FLD_EU_REGION
152};
153
155{
156 FMT_AUTHOR_NAME,
157 FMT_AUTHOR_SCUT
158};
159
161{
162 FLD_DATE_STD,
163 FLD_DATE_FIX
164};
165
167{
168 FLD_TIME_STD,
169 FLD_TIME_FIX
170};
171
173{
174 FMT_NUM_ABC,
175 FMT_NUM_SABC,
176 FMT_NUM_ABC_N,
177 FMT_NUM_SABC_N,
178 FMT_NUM_ROMAN,
179 FMT_NUM_SROMAN,
180 FMT_NUM_ARABIC,
181 FMT_NUM_PAGEDESC,
182 FMT_NUM_PAGESPECIAL
183};
184
186{
187 FMT_FF_NAME,
188 FMT_FF_PATHNAME,
189 FMT_FF_PATH,
190 FMT_FF_NAME_NOEXT,
191 FMT_FF_UI_NAME,
192 FMT_FF_UI_RANGE
193};
194
196{
197 FLD_STAT_PAGE,
198 FLD_STAT_PARA,
199 FLD_STAT_WORD,
200 FLD_STAT_CHAR,
201 FLD_STAT_TABLE,
202 FLD_STAT_GRF,
203 FLD_STAT_OBJ
204};
205
207{
208 FMT_CHAPTER_NO,
209 FMT_CHAPTER_NAME,
210 FMT_CHAPTER_NAMENO,
211 FMT_CHAPTER_NO_NOSEPARATOR
212};
213
215{
216 FLD_INPUT_TEXT
217};
218
220{
221 FMT_MARK_TEXT,
222 FMT_MARK_TABLE,
223 FMT_MARK_FRAME,
224 FMT_MARK_GRAFIC,
225 FMT_MARK_OLE
226};
227
229{
230 FMT_REF_PAGE,
231 FMT_REF_CHAPTER,
232 FMT_REF_TEXT,
233 FMT_REF_UPDOWN,
234 FMT_REF_PAGE_PGDSC,
235 FMT_REF_ONLYNUMBER,
236 FMT_REF_ONLYCAPTION,
237 FMT_REF_ONLYSEQNO,
238 FMT_REF_NUMBER,
239 FMT_REF_NUMBER_NO_CONTEXT,
240 FMT_REF_NUMBER_FULL_CONTEXT
241};
242
244{
245 FMT_REG_AUTHOR,
246 FMT_REG_TIME,
247 FMT_REG_DATE
248};
249
251{
252 FMT_DBFLD_DB,
253 FMT_DBFLD_SYS
254};
255
257{
258 FMT_SETVAR_SYS,
259 FMT_SETVAR_TEXT
260};
261
263{
264 FMT_GETVAR_TEXT,
265 FMT_GETVAR_NAME
266};
267
269{
270 FMT_DDE_NORMAL,
271 FMT_DDE_HOT
272};
273
275{
276 FLD_PAGEREF_OFF,
277 FLD_PAGEREF_ON
278};
279
281{
282 FMT_USERVAR_TEXT,
283 FMT_USERVAR_CMD
284};
285
286namespace {
287
288// field types and subtypes
289struct SwFieldPack
290{
291 SwFieldTypesEnum nTypeId;
292
293 const TranslateId* pSubTypeResIds;
294 size_t nSubTypeLength;
295
296 const TranslateId* pFormatResIds;
297 size_t nFormatLength;
298};
299
300}
301
302// strings and formats
303const SwFieldPack aSwFields[] =
304{
305 // Document
306 { SwFieldTypesEnum::ExtendedUser, FLD_EU_ARY, std::size(FLD_EU_ARY), nullptr, 0 },
307 { SwFieldTypesEnum::Author, nullptr, 0, FMT_AUTHOR_ARY, std::size(FMT_AUTHOR_ARY) },
308 { SwFieldTypesEnum::Date, FLD_DATE_ARY, std::size(FLD_DATE_ARY), nullptr, 0 },
309 { SwFieldTypesEnum::Time, FLD_TIME_ARY, std::size(FLD_TIME_ARY), nullptr, 0 },
310 { SwFieldTypesEnum::PageNumber, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) -1 },
311 { SwFieldTypesEnum::NextPage, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) },
312 { SwFieldTypesEnum::PreviousPage, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) },
313 { SwFieldTypesEnum::Filename, nullptr, 0, FMT_FF_ARY, std::size(FMT_FF_ARY) },
315
316 { SwFieldTypesEnum::Chapter, nullptr, 0, FMT_CHAPTER_ARY, std::size(FMT_CHAPTER_ARY) },
317 { SwFieldTypesEnum::TemplateName, nullptr, 0, FMT_FF_ARY, std::size(FMT_FF_ARY) },
318 { SwFieldTypesEnum::ParagraphSignature, nullptr, 0, nullptr, 0 },
319
320 // Functions
321 { SwFieldTypesEnum::ConditionalText, nullptr, 0, nullptr, 0 },
322 { SwFieldTypesEnum::Dropdown, nullptr, 0, nullptr, 0 },
323 { SwFieldTypesEnum::Input, FLD_INPUT_ARY, std::size(FLD_INPUT_ARY), nullptr, 0 },
324 { SwFieldTypesEnum::Macro, nullptr, 0, nullptr, 0 },
325 { SwFieldTypesEnum::JumpEdit, nullptr, 0, FMT_MARK_ARY, std::size(FMT_MARK_ARY) },
326 { SwFieldTypesEnum::CombinedChars, nullptr, 0, nullptr, 0 },
327 { SwFieldTypesEnum::HiddenText, nullptr, 0, nullptr, 0 },
328 { SwFieldTypesEnum::HiddenParagraph, nullptr, 0, nullptr, 0 },
329
330 // Cross-References
331 { SwFieldTypesEnum::SetRef, nullptr, 0, nullptr, 0 },
332 { SwFieldTypesEnum::GetRef, nullptr, 0, FMT_REF_ARY, std::size(FMT_REF_ARY) },
333
334 // DocInformation
335 { SwFieldTypesEnum::DocumentInfo, nullptr, 0, FMT_REG_ARY, std::size(FMT_REG_ARY) },
336
337 // Database
338 { SwFieldTypesEnum::Database, nullptr, 0, FMT_DBFLD_ARY, std::size(FMT_DBFLD_ARY) },
339 { SwFieldTypesEnum::DatabaseNextSet, nullptr, 0, nullptr, 0 },
340 { SwFieldTypesEnum::DatabaseNumberSet, nullptr, 0, nullptr, 0 },
341 { SwFieldTypesEnum::DatabaseSetNumber, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) - 2 },
342 { SwFieldTypesEnum::DatabaseName, nullptr, 0, nullptr, 0 },
343
344 // Variables
345 { SwFieldTypesEnum::Set, nullptr, 0, FMT_SETVAR_ARY, std::size(FMT_SETVAR_ARY) },
346
347 { SwFieldTypesEnum::Get, nullptr, 0, FMT_GETVAR_ARY, std::size(FMT_GETVAR_ARY) },
348 { SwFieldTypesEnum::DDE, nullptr, 0, FMT_DDE_ARY, std::size(FMT_DDE_ARY) },
349 { SwFieldTypesEnum::Formel, nullptr, 0, FMT_GETVAR_ARY, std::size(FMT_GETVAR_ARY) },
350 { SwFieldTypesEnum::Input, FLD_INPUT_ARY, std::size(FLD_INPUT_ARY), nullptr, 0 },
351 { SwFieldTypesEnum::Sequence, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) - 2 },
353 { SwFieldTypesEnum::GetRefPage, nullptr, 0, FMT_NUM_ARY, std::size(FMT_NUM_ARY) - 1 },
354 { SwFieldTypesEnum::User, nullptr, 0, FMT_USERVAR_ARY, std::size(FMT_USERVAR_ARY) }
355};
356
357// access to the shell
359{
360 if (SwView* pView = GetActiveView())
361 return pView->GetWrtShellPtr();
362 return nullptr;
363}
364
365static sal_uInt16 GetPackCount() { return SAL_N_ELEMENTS(aSwFields); }
366
367// FieldManager controls inserting and updating of fields
369 m_pWrtShell(pSh),
370 m_bEvalExp(true)
371{
372 // determine current field if existing
373 GetCurField();
374}
375
377{
378}
379
380// organise RefMark by names
381bool SwFieldMgr::CanInsertRefMark( std::u16string_view rStr )
382{
383 bool bRet = false;
385 OSL_ENSURE(pSh, "no SwWrtShell found");
386 if(pSh)
387 {
388 sal_uInt16 nCnt = pSh->GetCursorCnt();
389
390 // the last Cursor doesn't have to be a spanned selection
391 if( 1 < nCnt && !pSh->SwCursorShell::HasSelection() )
392 --nCnt;
393
394 bRet = 2 > nCnt && nullptr == pSh->GetRefMark( rStr );
395 }
396 return bRet;
397}
398
399// access over ResIds
400void SwFieldMgr::RemoveFieldType(SwFieldIds nResId, const OUString& rName )
401{
403 OSL_ENSURE(pSh, "no SwWrtShell found");
404 if( pSh )
405 pSh->RemoveFieldType(nResId, rName);
406}
407
409{
411 OSL_ENSURE(pSh, "no SwWrtShell found");
412 return pSh ? pSh->GetFieldTypeCount() : 0;
413}
414
416{
418 OSL_ENSURE(pSh, "no SwWrtShell found");
419 return pSh ? pSh->GetFieldType(nField, nResId) : nullptr;
420}
421
422SwFieldType* SwFieldMgr::GetFieldType(SwFieldIds nResId, const OUString& rName) const
423{
425 OSL_ENSURE(pSh, "no SwWrtShell found");
426 return pSh ? pSh->GetFieldType(nResId, rName) : nullptr;
427}
428
429// determine current field
431{
433 if ( pSh )
434 m_pCurField = pSh->GetCurField( true );
435 else
436 m_pCurField = nullptr;
437
438 // initialise strings and format
439 m_aCurPar1.clear();
440 m_aCurPar2.clear();
441 m_sCurFrame.clear();
442 m_nCurFormat = 0;
443
444 if(!m_pCurField)
445 return nullptr;
446
447 // preprocess current values; determine parameter 1 and parameter 2
448 // as well as the format
449 const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId();
450
454
455 switch( nTypeId )
456 {
462 m_nCurFormat -= 2;
463 break;
464 default: break;
465 }
466 return m_pCurField;
467}
468
469// provide group range
470const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
471{
472 static SwFieldGroupRgn const aRanges[] =
473 {
474 { /* Document */ GRP_DOC_BEGIN, GRP_DOC_END },
475 { /* Functions */ GRP_FKT_BEGIN, GRP_FKT_END },
476 { /* Cross-Refs */ GRP_REF_BEGIN, GRP_REF_END },
477 { /* DocInfos */ GRP_REG_BEGIN, GRP_REG_END },
478 { /* Database */ GRP_DB_BEGIN, GRP_DB_END },
479 { /* User */ GRP_VAR_BEGIN, GRP_VAR_END }
480 };
481 static SwFieldGroupRgn const aWebRanges[] =
482 {
483 { /* Document */ GRP_WEB_DOC_BEGIN, GRP_WEB_DOC_END },
484 { /* Functions */ GRP_WEB_FKT_BEGIN, GRP_WEB_FKT_END },
485 { /* Cross-Refs */ GRP_WEB_REF_BEGIN, GRP_WEB_REF_END },
486 { /* DocInfos */ GRP_WEB_REG_BEGIN, GRP_WEB_REG_END },
487 { /* Database */ GRP_WEB_DB_BEGIN, GRP_WEB_DB_END },
488 { /* User */ GRP_WEB_VAR_BEGIN, GRP_WEB_VAR_END }
489 };
490
491 if (bHtmlMode)
492 return aWebRanges[nGrpId];
493 else
494 return aRanges[nGrpId];
495}
496
497// determine GroupId
498sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType)
499{
500 if (nTypeId == SwFieldTypesEnum::SetInput)
501 nTypeId = SwFieldTypesEnum::Set;
502
503 if (nTypeId == SwFieldTypesEnum::Input && (nSubType & INP_USR))
504 nTypeId = SwFieldTypesEnum::User;
505
506 if (nTypeId == SwFieldTypesEnum::FixedDate)
507 nTypeId = SwFieldTypesEnum::Date;
508
509 if (nTypeId == SwFieldTypesEnum::FixedTime)
510 nTypeId = SwFieldTypesEnum::Time;
511
512 for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++)
513 {
514 const SwFieldGroupRgn& rRange = GetGroupRange(false/*bHtmlMode*/, i);
515 for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++)
516 {
517 if (aSwFields[nPos].nTypeId == nTypeId)
518 return i;
519 }
520 }
521 return USHRT_MAX;
522}
523
524// determine names to TypeId
525// ACCESS over TYP_...
527{
528 OSL_ENSURE(nPos < ::GetPackCount(), "forbidden Pos");
529 return aSwFields[ nPos ].nTypeId;
530}
531
532const OUString & SwFieldMgr::GetTypeStr(sal_uInt16 nPos)
533{
534 OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId");
535
536 SwFieldTypesEnum nFieldWh = aSwFields[ nPos ].nTypeId;
537
538 // special treatment for date/time fields (without var/fix)
539 if( SwFieldTypesEnum::Date == nFieldWh )
540 {
541 static OUString g_aDate( SwResId( STR_DATEFLD ) );
542 return g_aDate;
543 }
544 if( SwFieldTypesEnum::Time == nFieldWh )
545 {
546 static OUString g_aTime( SwResId( STR_TIMEFLD ) );
547 return g_aTime;
548 }
549
550 return SwFieldType::GetTypeStr( nFieldWh );
551}
552
553// determine Pos in the list
555{
556 switch( nTypeId )
557 {
562 default: break;
563 }
564
565 for(sal_uInt16 i = 0; i < GetPackCount(); i++)
566 if(aSwFields[i].nTypeId == nTypeId)
567 return i;
568
569 return USHRT_MAX;
570}
571
572// localise subtypes of a field
573void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rToFill)
574{
576 OSL_ENSURE(pSh, "no SwWrtShell found");
577 if(!pSh)
578 return;
579
580 const sal_uInt16 nPos = GetPos(nTypeId);
581
582 switch(nTypeId)
583 {
586 {
587 // references are no fields
588 pSh->GetRefMarks( &rToFill );
589 break;
590 }
592 {
593 break;
594 }
596 {
597 rToFill.push_back(SwResId(aSwFields[nPos].pSubTypeResIds[0]));
598 [[fallthrough]]; // move on at generic types
599 }
606 {
607
608 const size_t nCount = pSh->GetFieldTypeCount();
609 for(size_t i = 0; i < nCount; ++i)
610 {
611 SwFieldType* pFieldType = pSh->GetFieldType( i );
612 const SwFieldIds nWhich = pFieldType->Which();
613
614 if((nTypeId == SwFieldTypesEnum::DDE && pFieldType->Which() == SwFieldIds::Dde) ||
615
616 (nTypeId == SwFieldTypesEnum::User && nWhich == SwFieldIds::User) ||
617
618 (nTypeId == SwFieldTypesEnum::Get && nWhich == SwFieldIds::SetExp &&
619 !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
620
621 (nTypeId == SwFieldTypesEnum::Set && nWhich == SwFieldIds::SetExp &&
622 !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
623
624 (nTypeId == SwFieldTypesEnum::Sequence && nWhich == SwFieldIds::SetExp &&
625 (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
626
627 ((nTypeId == SwFieldTypesEnum::Input || nTypeId == SwFieldTypesEnum::Formel) &&
628 (nWhich == SwFieldIds::User ||
629 (nWhich == SwFieldIds::SetExp &&
630 !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) )
631 {
632 rToFill.push_back(pFieldType->GetName());
633 }
634 }
635 break;
636 }
641 break;
642
643 default:
644 {
645 // static SubTypes
646 if(nPos != USHRT_MAX)
647 {
648 sal_uInt16 nCount;
649 if (nTypeId == SwFieldTypesEnum::DocumentInfo)
651 else
652 nCount = aSwFields[nPos].nSubTypeLength;
653
654 for(sal_uInt16 i = 0; i < nCount; ++i)
655 {
656 OUString sNew;
657 if (nTypeId == SwFieldTypesEnum::DocumentInfo)
658 {
659 if ( i == DI_CUSTOM )
660 sNew = SwResId(STR_CUSTOM_FIELD);
661 else
663 }
664 else
665 sNew = SwResId(aSwFields[nPos].pSubTypeResIds[i]);
666
667 rToFill.push_back(sNew);
668 }
669 }
670 }
671 }
672}
673
674// determine format
675// ACCESS over TYP_...
676sal_uInt16 SwFieldMgr::GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
677{
678 assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId");
679 {
680 const sal_uInt16 nPos = GetPos(nTypeId);
681
682 if (nPos == USHRT_MAX || (bHtmlMode && nTypeId == SwFieldTypesEnum::Set))
683 return 0;
684
685 sal_uInt16 nCount = aSwFields[nPos].nFormatLength;
686
687 if (nTypeId == SwFieldTypesEnum::Filename)
688 nCount -= 2; // no range or template
689
690 const TranslateId* pStart = aSwFields[nPos].pFormatResIds;
691 if (!pStart)
692 return nCount;
693
694 if (*pStart == FMT_GETVAR_ARY[0] || *pStart == FMT_SETVAR_ARY[0])
695 return VF_COUNT;
696 else if (*pStart == FMT_USERVAR_ARY[0])
697 return VF_USR_COUNT;
698 else if (*pStart == FMT_DBFLD_ARY[0])
699 return VF_DB_COUNT;
700 else if (*pStart == FMT_NUM_ARY[0])
701 {
703 if(m_xNumberingInfo.is())
704 {
705 const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
706 // #i28073# it's not necessarily a sorted sequence
707 //skip all values below or equal to CHARS_LOWER_LETTER_N
708 nCount += std::count_if(aTypes.begin(), aTypes.end(),
709 [](sal_Int16 nCurrent) { return nCurrent > NumberingType::CHARS_LOWER_LETTER_N; });
710 }
711 return nCount;
712 }
713
714 return nCount;
715 }
716}
717
718// determine FormatString to a type
719OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
720{
721 assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId");
722 const sal_uInt16 nPos = GetPos(nTypeId);
723
724 if (nPos == USHRT_MAX)
725 return OUString();
726
727 const TranslateId* pStart = aSwFields[nPos].pFormatResIds;
728 if (!pStart)
729 return OUString();
730
731 if (SwFieldTypesEnum::Author == nTypeId || SwFieldTypesEnum::Filename == nTypeId)
732 nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag
733
734 if (nFormatId < aSwFields[nPos].nFormatLength)
735 return SwResId(pStart[nFormatId]);
736
737 OUString aRet;
738 if (*pStart == FMT_NUM_ARY[0])
739 {
740 if (m_xNumberingInfo.is())
741 {
742 const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
743 sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
744 sal_uInt32 nValidEntry = 0;
745 for (const sal_Int16 nCurrent : aTypes)
746 {
747 if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
748 (nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
749 {
750 if (nValidEntry == nFormatId - nOffset)
751 {
752 sal_uInt32 n = SvxNumberingTypeTable::FindIndex(nCurrent);
754 {
756 }
757 else
758 {
759 aRet = m_xNumberingInfo->getNumberingIdentifier( nCurrent );
760 }
761 break;
762 }
763 ++nValidEntry;
764 }
765 }
766 }
767 }
768
769 return aRet;
770}
771
772// determine FormatId from Pseudo-ID
773sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
774{
775 sal_uInt16 nId = o3tl::narrowing<sal_uInt16>(nFormatId);
776 switch( nTypeId )
777 {
779 {
780 TranslateId sId = aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId];
781 if (sId == FMT_REG_AUTHOR)
783 else if (sId == FMT_REG_TIME)
785 else if (sId == FMT_REG_DATE)
787 break;
788 }
796 {
797 sal_uInt16 nPos = GetPos(nTypeId);
798 if (nFormatId < aSwFields[nPos].nFormatLength)
799 {
800 const TranslateId sId = aSwFields[nPos].pFormatResIds[nFormatId];
801 if (sId == FMT_NUM_ABC)
803 else if (sId == FMT_NUM_SABC)
805 else if (sId == FMT_NUM_ROMAN)
807 else if (sId == FMT_NUM_SROMAN)
809 else if (sId == FMT_NUM_ARABIC)
811 else if (sId == FMT_NUM_PAGEDESC)
813 else if (sId == FMT_NUM_PAGESPECIAL)
815 else if (sId == FMT_NUM_ABC_N)
817 else if (sId == FMT_NUM_SABC_N)
819 }
820 else if (m_xNumberingInfo.is())
821 {
822 const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
823 sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
824 sal_Int32 nValidEntry = 0;
825 for (const sal_Int16 nCurrent : aTypes)
826 {
827 if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
828 {
829 if (nValidEntry == static_cast<sal_Int32>(nFormatId) - nOffset)
830 {
831 nId = nCurrent;
832 break;
833 }
834 ++nValidEntry;
835 }
836 }
837 }
838 break;
839 }
841 {
842 const TranslateId sId = aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId];
843 if (sId == FMT_DDE_NORMAL)
844 nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ONCALL);
845 else if (sId == FMT_DDE_HOT)
846 nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ALWAYS);
847 break;
848 }
849 default: break;
850 }
851 return nId;
852}
853
854// Traveling
855bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp )
856{
858 if(!pSh)
859 return false;
860
861 if( !pTyp && m_pCurField )
862 {
863 const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId();
864 if( SwFieldTypesEnum::SetInput == nTypeId || SwFieldTypesEnum::UserInput == nTypeId )
865 pTyp = pSh->GetFieldType( 0, SwFieldIds::Input );
866 else
867 pTyp = m_pCurField->GetTyp();
868 }
869
870 if (pTyp && pTyp->Which() == SwFieldIds::Database)
871 {
872 // for fieldcommand-edit (hop to all DB fields)
873 return pSh->MoveFieldType( nullptr, bNext, SwFieldIds::Database );
874 }
875
876 return pTyp && pSh->MoveFieldType(pTyp, bNext);
877}
878
879// insert field types
881{
883 OSL_ENSURE(pSh, "no SwWrtShell found");
884 if(pSh)
885 pSh->InsertFieldType(rType);
886}
887
888// determine current TypeId
890{
892}
893
894// Over string insert field or update
896 SwInsertField_Data& rData)
897{
898 std::unique_ptr<SwField> pField;
899 bool bExp = false;
900 bool bTable = false;
901 bool bPageVar = false;
902 sal_uInt32 nFormatId = rData.m_nFormatId;
903 sal_uInt16 nSubType = rData.m_nSubType;
904 sal_Unicode cSeparator = rData.m_cSeparator;
905 SwWrtShell* pCurShell = rData.m_pSh;
906 if(!pCurShell)
907 pCurShell = m_pWrtShell ? m_pWrtShell : ::lcl_GetShell();
908 OSL_ENSURE(pCurShell, "no SwWrtShell found");
909 if(!pCurShell)
910 return false;
911
912 switch (rData.m_nTypeId)
913 { // ATTENTION this field is inserted by a separate dialog
915 {
916 SvtUserOptions aUserOpt;
917 SwPostItFieldType* pType = static_cast<SwPostItFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Postit));
918 pField.reset(
919 new SwPostItField(
920 pType,
921 rData.m_sPar1, // author
922 rData.m_sPar2, // content
923 aUserOpt.GetID(), // author's initials
924 OUString(), // name
926 }
927 break;
929 {
930 SwScriptFieldType* pType =
931 static_cast<SwScriptFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Script));
932 pField.reset(new SwScriptField(pType, rData.m_sPar1, rData.m_sPar2, static_cast<bool>(nFormatId)));
933 break;
934 }
935
937 {
939 pCurShell->GetFieldType( 0, SwFieldIds::CombinedChars ));
940 pField.reset(new SwCombinedCharField( pType, rData.m_sPar1 ));
941 }
942 break;
943
945 {
946 SwAuthorityFieldType* pType =
948 if (!pType)
949 {
950 SwAuthorityFieldType const type(pCurShell->GetDoc());
951 pType = static_cast<SwAuthorityFieldType*>(
952 pCurShell->InsertFieldType(type));
953 }
954 pField.reset(new SwAuthorityField(pType, rData.m_sPar1));
955 }
956 break;
957
960 {
961 sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == SwFieldTypesEnum::Date ? DATEFLD : TIMEFLD);
962 nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
963
964 SwDateTimeFieldType* pTyp =
965 static_cast<SwDateTimeFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DateTime) );
966 pField.reset(new SwDateTimeField(pTyp, nSub, nFormatId));
967 pField->SetPar2(rData.m_sPar2);
968 break;
969 }
970
972 {
973 SwFileNameFieldType* pTyp =
974 static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) );
975 pField.reset(new SwFileNameField(pTyp, nFormatId));
976 break;
977 }
978
980 {
982 static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) );
983 pField.reset(new SwTemplNameField(pTyp, nFormatId));
984 break;
985 }
986
988 {
989 sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rData.m_sPar2.toInt32());
990 SwChapterFieldType* pTyp =
991 static_cast<SwChapterFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Chapter) );
992 pField.reset(new SwChapterField(pTyp, nFormatId));
993 nByte = std::max(sal_uInt16(1), nByte);
994 nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
995 nByte -= 1;
996 static_cast<SwChapterField*>(pField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
997 break;
998 }
999
1003 {
1004 short nOff = static_cast<short>(rData.m_sPar2.toInt32());
1005
1007 {
1008 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1009 nOff = 1;
1010 else
1011 nOff += 1;
1012 nSubType = PG_NEXT;
1013 }
1015 {
1016 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1017 nOff = -1;
1018 else
1019 nOff -= 1;
1020 nSubType = PG_PREV;
1021 }
1022 else
1023 nSubType = PG_RANDOM;
1024
1025 SwPageNumberFieldType* pTyp =
1026 static_cast<SwPageNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::PageNumber) );
1027 pField.reset(new SwPageNumberField(pTyp, nSubType, nFormatId, nOff));
1028
1029 if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
1030 ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
1031 static_cast<SwPageNumberField*>(pField.get())->SetUserString( rData.m_sPar2 );
1032 break;
1033 }
1034
1036 {
1037 SwDocStatFieldType* pTyp =
1038 static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) );
1039 pField.reset(new SwDocStatField(pTyp, nSubType, nFormatId));
1040 break;
1041 }
1042
1044 {
1045 SwAuthorFieldType* pTyp =
1046 static_cast<SwAuthorFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Author) );
1047 pField.reset(new SwAuthorField(pTyp, nFormatId));
1048 break;
1049 }
1050
1053 {
1054 SwHiddenTextFieldType* pTyp =
1055 static_cast<SwHiddenTextFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenText) );
1056 pField.reset(new SwHiddenTextField(pTyp, true, rData.m_sPar1, rData.m_sPar2, false, rData.m_nTypeId));
1057 bExp = true;
1058 break;
1059 }
1060
1062 {
1063 SwHiddenParaFieldType* pTyp =
1064 static_cast<SwHiddenParaFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenPara) );
1065 pField.reset(new SwHiddenParaField(pTyp, rData.m_sPar1));
1066 bExp = true;
1067 break;
1068 }
1069
1071 {
1072 if( !rData.m_sPar1.isEmpty() && CanInsertRefMark( rData.m_sPar1 ) )
1073 {
1074 const OUString& rRefmarkText = rData.m_sPar2;
1075 SwPaM* pCursorPos = pCurShell->GetCursor();
1076 pCurShell->StartAction();
1077 if (!rRefmarkText.isEmpty())
1078 {
1079 // Split node to remember where the start position is.
1080 bool bSuccess = pCurShell->GetDoc()->getIDocumentContentOperations().SplitNode(
1081 *pCursorPos->GetPoint(), /*bChkTableStart=*/false);
1082 if (bSuccess)
1083 {
1084 SwPaM aRefmarkPam(*pCursorPos->GetPoint());
1085 aRefmarkPam.Move(fnMoveBackward, GoInContent);
1086
1087 // Paste HTML content.
1089 *pCurShell, pCursorPos, rRefmarkText.toUtf8());
1090
1091 // Undo the above SplitNode().
1092 aRefmarkPam.SetMark();
1093 aRefmarkPam.Move(fnMoveForward, GoInContent);
1095 aRefmarkPam);
1096 *aRefmarkPam.GetMark() = *pCursorPos->GetPoint();
1097 *pCursorPos = aRefmarkPam;
1098 }
1099 }
1100
1101 pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
1102
1103 if (!rRefmarkText.isEmpty())
1104 {
1105 pCursorPos->DeleteMark();
1106 }
1107 pCurShell->EndAction();
1108 return true;
1109 }
1110 return false;
1111 }
1112
1114 {
1115 SwGetRefFieldType* pTyp =
1116 static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) );
1117 sal_uInt16 nSeqNo = o3tl::narrowing<sal_uInt16>(rData.m_sPar2.toInt32());
1118 OUString sReferenceLanguage;
1119 // handle language-variant formats
1120 if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY))
1121 {
1124 {
1125 if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2)
1126 sReferenceLanguage = "Hu";
1127 else
1128 sReferenceLanguage = "hu";
1129 }
1130 nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY);
1131 }
1132 pField.reset(new SwGetRefField(pTyp, rData.m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1133 bExp = true;
1134 break;
1135 }
1136
1138 {
1139 //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
1140 // That's not yet considered here.
1141 sal_Int32 nIndex = 0;
1142 OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1143 if (nIndex>=0 && ++nIndex<sCmd.getLength())
1144 {
1145 sCmd = sCmd.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1146 }
1147
1148 SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
1149 SwDDEFieldType* pTyp = static_cast<SwDDEFieldType*>( pCurShell->InsertFieldType( aType ) );
1150 pField.reset(new SwDDEField( pTyp ));
1151 break;
1152 }
1153
1155 {
1156 SwMacroFieldType* pTyp =
1157 static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro));
1158
1159 pField.reset(new SwMacroField(pTyp, rData.m_sPar1, rData.m_sPar2));
1160
1161 break;
1162 }
1163
1165 {
1166 SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame );
1167 return pCurShell->InsertURL( aFormat, rData.m_sPar2 );
1168 }
1169
1171 {
1172 SwJumpEditFieldType* pTyp =
1173 static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit));
1174
1175 pField.reset(new SwJumpEditField(pTyp, nFormatId, rData.m_sPar1, rData.m_sPar2));
1176 break;
1177 }
1178
1180 {
1181 SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType(
1182 0, SwFieldIds::DocInfo ) );
1183 pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId));
1184 break;
1185 }
1186
1188 {
1189 SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType(
1190 0, SwFieldIds::ExtUser) );
1191 pField.reset(new SwExtUserField(pTyp, nSubType, nFormatId));
1192 break;
1193 }
1194
1196 {
1197#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1198 SwDBData aDBData;
1199 OUString sPar1;
1200
1201 if (rData.m_sPar1.indexOf(DB_DELIM)<0)
1202 {
1203 aDBData = pCurShell->GetDBData();
1204 sPar1 = rData.m_sPar1;
1205 }
1206 else
1207 {
1208 sal_Int32 nIdx{ 0 };
1209 aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1210 aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1211 aDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rData.m_sPar1, 0, DB_DELIM, nIdx));
1212 sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1213 }
1214
1215 if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1216 pCurShell->ChgDBData(aDBData);
1217
1218 SwDBFieldType* pTyp = static_cast<SwDBFieldType*>(pCurShell->InsertFieldType(
1219 SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) ) );
1220 pField.reset(new SwDBField(pTyp));
1221 pField->SetSubType(nSubType);
1222
1223 if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determine database format
1224 {
1226 rData.m_aDBDataSource >>= xSource;
1227 Reference<XConnection> xConnection;
1228 rData.m_aDBConnection >>= xConnection;
1230 rData.m_aDBColumn >>= xColumn;
1231 if(xColumn.is())
1232 {
1233 nFormatId = SwDBManager::GetColumnFormat(xSource, xConnection, xColumn,
1234 pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1235 }
1236 else
1237 nFormatId = pCurShell->GetDBManager()->GetColumnFormat(
1238 aDBData.sDataSource, aDBData.sCommand, sPar1,
1239 pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1240 }
1241 pField->ChangeFormat( nFormatId );
1242
1243 bExp = true;
1244#endif
1245 break;
1246 }
1247
1252 {
1253#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1254 SwDBData aDBData;
1255
1256 // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg
1257 sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM);
1258 sal_Int32 nExpPos = -1;
1259
1260 if (nTablePos>=0)
1261 {
1262 aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++);
1263 sal_Int32 nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos);
1264 if (nCmdTypePos>=0)
1265 {
1266 aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos);
1267 nExpPos = rData.m_sPar1.indexOf(DB_DELIM, nCmdTypePos);
1268 if (nExpPos>=0)
1269 {
1270 aDBData.nCommandType = o3tl::toInt32(rData.m_sPar1.subView(nCmdTypePos, nExpPos++ - nCmdTypePos));
1271 }
1272 }
1273 }
1274
1275 sal_Int32 nPos = 0;
1276 if (nExpPos>=0)
1277 nPos = nExpPos;
1278 else if (nTablePos>=0)
1279 nPos = nTablePos;
1280
1281 OUString sPar1 = rData.m_sPar1.copy(nPos);
1282
1283 if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1284 pCurShell->ChgDBData(aDBData);
1285
1286 switch(rData.m_nTypeId)
1287 {
1289 {
1290 SwDBNameFieldType* pTyp =
1291 static_cast<SwDBNameFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::DatabaseName));
1292 pField.reset(new SwDBNameField(pTyp, aDBData));
1293
1294 break;
1295 }
1297 {
1298 SwDBNextSetFieldType* pTyp = static_cast<SwDBNextSetFieldType*>(pCurShell->GetFieldType(
1300 pField.reset(new SwDBNextSetField(pTyp, sPar1, aDBData));
1301 bExp = true;
1302 break;
1303 }
1305 {
1306 SwDBNumSetFieldType* pTyp = static_cast<SwDBNumSetFieldType*>( pCurShell->GetFieldType(
1308 pField.reset(new SwDBNumSetField( pTyp, sPar1, rData.m_sPar2, aDBData));
1309 bExp = true;
1310 break;
1311 }
1313 {
1314 SwDBSetNumberFieldType* pTyp = static_cast<SwDBSetNumberFieldType*>(
1315 pCurShell->GetFieldType(0, SwFieldIds::DbSetNumber) );
1316 pField.reset(new SwDBSetNumberField( pTyp, aDBData, nFormatId));
1317 bExp = true;
1318 break;
1319 }
1320 default: break;
1321 }
1322#endif
1323 break;
1324 }
1325
1327 {
1328 SwUserFieldType* pTyp =
1329 static_cast<SwUserFieldType*>( pCurShell->GetFieldType(SwFieldIds::User, rData.m_sPar1) );
1330
1331 // only if existing
1332 if(!pTyp)
1333 {
1334 pTyp = static_cast<SwUserFieldType*>( pCurShell->InsertFieldType(
1335 SwUserFieldType(pCurShell->GetDoc(), rData.m_sPar1)) );
1336 }
1337 if (pTyp->GetContent(nFormatId) != rData.m_sPar2)
1338 pTyp->SetContent(rData.m_sPar2, nFormatId);
1339 pField.reset(new SwUserField(pTyp, 0, nFormatId));
1340 if (pField->GetSubType() != nSubType)
1341 pField->SetSubType(nSubType);
1342 bTable = true;
1343 break;
1344 }
1345
1347 {
1348 if ((nSubType & 0x00ff) == INP_VAR)
1349 {
1350 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>(
1351 pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1) );
1352
1353 // no Expression Type with this name existing -> create
1354 if(pTyp)
1355 {
1356 std::unique_ptr<SwSetExpField> pExpField(
1357 new SwSetExpField(pTyp, OUString(), nFormatId));
1358
1359 // Don't change type of SwSetExpFieldType:
1360 sal_uInt16 nOldSubType = pExpField->GetSubType();
1361 pExpField->SetSubType(nOldSubType | (nSubType & 0xff00));
1362
1363 pExpField->SetPromptText(rData.m_sPar2);
1364 pExpField->SetInputFlag(true) ;
1365 bExp = true;
1366 pField = std::move(pExpField);
1367 }
1368 else
1369 return false;
1370 }
1371 else
1372 {
1373 SwInputFieldType* pTyp =
1374 static_cast<SwInputFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Input) );
1375
1376 pField.reset(
1377 new SwInputField( pTyp, rData.m_sPar1, rData.m_sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId));
1378 }
1379 break;
1380 }
1381
1383 {
1384 if (rData.m_sPar2.isEmpty()) // empty variables are not allowed
1385 return false;
1386
1387 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1388 SwSetExpFieldType(pCurShell->GetDoc(), rData.m_sPar1) ) );
1389
1390 std::unique_ptr<SwSetExpField> pExpField(new SwSetExpField( pTyp, rData.m_sPar2, nFormatId));
1391 pExpField->SetSubType(nSubType);
1392 pExpField->SetPar2(rData.m_sPar2);
1393 bExp = true;
1394 pField = std::move(pExpField);
1395 break;
1396 }
1397
1399 {
1400 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1402
1403 sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1404
1405 pTyp->SetOutlineLvl(nLevel);
1406 if (nLevel != 0x7f && cSeparator == 0)
1407 cSeparator = '.';
1408
1409 pTyp->SetDelimiter(OUString(cSeparator));
1410 pField.reset(new SwSetExpField(pTyp, rData.m_sPar2, nFormatId));
1411 bExp = true;
1412 break;
1413 }
1414
1416 {
1417 // is there a corresponding SetField
1418 SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
1419 pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1));
1420
1421 if(pSetTyp)
1422 {
1423 SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>( pCurShell->GetFieldType(
1424 0, SwFieldIds::GetExp) );
1425 pField.reset( new SwGetExpField(pTyp, rData.m_sPar1, pSetTyp->GetType(), nFormatId) );
1426 pField->SetSubType(nSubType | pSetTyp->GetType());
1427 bExp = true;
1428 }
1429 else
1430 return false;
1431 break;
1432 }
1433
1435 {
1436 if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE)
1437 {
1438 pCurShell->StartAllAction();
1439
1440 SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1441 const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1442
1443 if (pEntry)
1444 {
1446 pCurShell->GetView().GetViewFrame().GetDispatcher()->
1447 ExecuteList(FN_NUMBER_FORMAT, SfxCallMode::SYNCHRON,
1448 { &aFormat });
1449 }
1450
1452
1453 OUString sFormula(comphelper::string::stripStart(rData.m_sPar2, ' '));
1454 if ( sFormula.startsWith("=") )
1455 {
1456 sFormula = sFormula.copy(1);
1457 }
1458
1459 aBoxSet.Put( SwTableBoxFormula( sFormula ));
1460 pCurShell->SetTableBoxFormulaAttrs( aBoxSet );
1461 pCurShell->UpdateTable();
1462
1463 pCurShell->EndAllAction();
1464 return true;
1465
1466 }
1467 else
1468 {
1469 SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>(
1470 pCurShell->GetFieldType(0, SwFieldIds::GetExp) );
1471 pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId) );
1472 pField->SetSubType(nSubType);
1473 bExp = true;
1474 }
1475 break;
1476 }
1478 pField.reset( new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(
1479 pCurShell->GetFieldType( 0, SwFieldIds::RefPageSet ) ),
1480 static_cast<short>(rData.m_sPar2.toInt32()), 0 != nSubType ) );
1481 bPageVar = true;
1482 break;
1483
1485 pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>(
1486 pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) );
1487 bPageVar = true;
1488 break;
1490 {
1491 pField.reset( new SwDropDownField(pCurShell->GetFieldType( 0, SwFieldIds::Dropdown )) );
1492 const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.m_sPar2, DB_DELIM);
1493 Sequence<OUString> aEntries(nTokenCount);
1494 OUString* pArray = aEntries.getArray();
1495 for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1496 pArray[nToken] = rData.m_sPar2.getToken(0, DB_DELIM, nIdx);
1497 static_cast<SwDropDownField*>(pField.get())->SetItems(aEntries);
1498 static_cast<SwDropDownField*>(pField.get())->SetName(rData.m_sPar1);
1499 }
1500 break;
1501
1502 // Insert Paragraph Signature field by signing the paragraph.
1503 // The resulting field is really a metadata field, created and added via signing.
1505 pCurShell->SignParagraph();
1506 return true;
1507
1508 default:
1509 { OSL_ENSURE(false, "wrong field type");
1510 return false;
1511 }
1512 }
1513 OSL_ENSURE(pField, "field not available");
1514
1515 //the auto language flag has to be set prior to the language!
1516 pField->SetAutomaticLanguage(rData.m_bIsAutomaticLanguage);
1518 pField->SetLanguage(nLang);
1519
1520 // insert
1521 pCurShell->StartAllAction();
1522
1523 bool const isSuccess = pCurShell->InsertField2(*pField, rData.m_oAnnotationRange ? &*rData.m_oAnnotationRange : nullptr);
1524
1525 if (isSuccess)
1526 {
1528 {
1529 pCurShell->Push();
1530
1531 // start dialog, not before the field is inserted tdf#99529
1532 pCurShell->Left(SwCursorSkipMode::Chars, false,
1533 (INP_VAR == (nSubType & 0xff) || pCurShell->GetViewOptions()->IsFieldName()) ? 1 : 2,
1534 false);
1535 pCurShell->StartInputFieldDlg(pField.get(), false, true, rData.m_pParent);
1536
1538 }
1539
1540 if (bExp && m_bEvalExp)
1541 {
1542 pCurShell->UpdateExpFields(true);
1543 }
1544
1545 if (bTable)
1546 {
1547 pCurShell->Left(SwCursorSkipMode::Chars, false, 1, false );
1548 pCurShell->UpdateOneField(*pField);
1549 pCurShell->Right(SwCursorSkipMode::Chars, false, 1, false );
1550 }
1551 else if (bPageVar)
1552 {
1553 static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::RefPageGet))->UpdateFields();
1554 }
1555 else if (SwFieldTypesEnum::GetRef == rData.m_nTypeId)
1556 {
1557 pField->GetTyp()->UpdateFields();
1558 }
1559 }
1560
1561 // delete temporary field
1562 pField.reset();
1563
1564 pCurShell->EndAllAction();
1565 return isSuccess;
1566}
1567
1568// fields update
1569void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
1570 const OUString& rPar1,
1571 const OUString& rPar2,
1572 std::unique_ptr<SwField> pTmpField)
1573{
1574 // change format
1575 OSL_ENSURE(m_pCurField, "no field at CursorPos");
1576
1577 if (!pTmpField)
1578 pTmpField = m_pCurField->CopyField();
1579
1580 SwFieldType* pType = pTmpField->GetTyp();
1581 const SwFieldTypesEnum nTypeId = pTmpField->GetTypeId();
1582
1584 OSL_ENSURE(pSh, "no SwWrtShell found");
1585 if(!pSh)
1586 return;
1587 pSh->StartAllAction();
1588
1589 bool bSetPar2 = true;
1590 bool bSetPar1 = true;
1591 OUString sPar2( rPar2 );
1592
1593 // Order to Format
1594 switch( nTypeId )
1595 {
1597 {
1598 // DDE-Topics/-Items can have blanks in their names!
1599 // That's not yet considered here!
1600 sal_Int32 nIndex = 0;
1601 sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex );
1602 if (nIndex>=0 && ++nIndex<sPar2.getLength())
1603 {
1604 sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1605 }
1606 break;
1607 }
1608
1610 {
1611 sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rPar2.toInt32());
1612 nByte = std::max(sal_uInt16(1), nByte);
1613 nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1614 nByte -= 1;
1615 static_cast<SwChapterField*>(pTmpField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1616 bSetPar2 = false;
1617 break;
1618 }
1619
1621 static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat));
1622 break;
1623
1625 if( SVX_NUM_CHAR_SPECIAL == nFormat )
1626 {
1627 static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1628 sPar2 = "1";
1629 }
1630 else
1631 {
1632 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1633 nFormat = SVX_NUM_PAGEDESC;
1634 short nOff = static_cast<short>(sPar2.toInt32());
1635 nOff += 1;
1636 sPar2 = OUString::number(nOff);
1637 }
1638 break;
1639
1641 if( SVX_NUM_CHAR_SPECIAL == nFormat )
1642 {
1643 static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1644 sPar2 = "-1";
1645 }
1646 else
1647 {
1648 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1649 nFormat = SVX_NUM_PAGEDESC;
1650 short nOff = static_cast<short>(sPar2.toInt32());
1651 nOff -= 1;
1652 sPar2 = OUString::number(nOff);
1653 }
1654 break;
1655
1658 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1659 nFormat = SVX_NUM_PAGEDESC;
1660 break;
1661
1663 {
1664 bSetPar2 = false;
1665 static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( o3tl::narrowing<sal_uInt16>(rPar2.toInt32()) );
1666 const sal_Int32 nPos = rPar2.indexOf( '|' );
1667 if( nPos>=0 )
1668 static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( o3tl::narrowing<sal_uInt16>(o3tl::toInt32(rPar2.subView( nPos + 1 ))));
1669 }
1670 break;
1672 {
1673 sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
1674 Sequence<OUString> aEntries(nTokenCount);
1675 OUString* pArray = aEntries.getArray();
1676 for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1677 pArray[nToken] = sPar2.getToken(0, DB_DELIM, nIdx);
1678 static_cast<SwDropDownField*>(pTmpField.get())->SetItems(aEntries);
1679 static_cast<SwDropDownField*>(pTmpField.get())->SetName(rPar1);
1680 bSetPar1 = bSetPar2 = false;
1681 }
1682 break;
1684 {
1685 //#i99069# changes to a bibliography field should change the field type
1686 SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get());
1687 SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1689 for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i )
1690 xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
1691 rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx ));
1692
1693 // If just the page number of the URL changed, then update the current field and not
1694 // others.
1695 bool bEquivalent = true;
1696 for (int i = 0; i < AUTH_FIELD_END; ++i)
1697 {
1698 auto eField = static_cast<ToxAuthorityField>(i);
1699 if (eField == AUTH_FIELD_URL)
1700 {
1701 if (SwTOXAuthority::GetSourceURL(xTempEntry->GetAuthorField(AUTH_FIELD_URL))
1703 pAuthorityField->GetFieldText(AUTH_FIELD_URL)))
1704 {
1705 bEquivalent = false;
1706 break;
1707 }
1708 }
1709 else
1710 {
1711 if (xTempEntry->GetAuthorField(eField) != pAuthorityField->GetFieldText(eField))
1712 {
1713 bEquivalent = false;
1714 break;
1715 }
1716 }
1717 }
1718
1719 if (bEquivalent)
1720 {
1721 break;
1722 }
1723
1724 if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) )
1725 {
1726 pType->UpdateFields();
1727 pSh->SetModified();
1728 }
1729
1730 if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1731 pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1732 bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
1733 bSetPar2 = false;
1734 }
1735 break;
1736 default: break;
1737 }
1738
1739 // set format
1740 // setup format before SetPar2 because of NumberFormatter!
1741 pTmpField->ChangeFormat(nFormat);
1742
1743 if( bSetPar1 )
1744 pTmpField->SetPar1( rPar1 );
1745 if( bSetPar2 )
1746 pTmpField->SetPar2( sPar2 );
1747
1748 // kick off update
1749 if(nTypeId == SwFieldTypesEnum::DDE ||
1750 nTypeId == SwFieldTypesEnum::User ||
1751 nTypeId == SwFieldTypesEnum::UserInput)
1752 {
1753 pType->UpdateFields();
1754 pSh->SetModified();
1755 }
1756 else {
1757 // mb: #32157
1758 pSh->SwEditShell::UpdateOneField(*pTmpField);
1759 GetCurField();
1760 }
1761
1762 pTmpField.reset();
1763
1764 pSh->EndAllAction();
1765}
1766
1767// explicitly evaluate ExpressionFields
1769{
1770 if (pSh == nullptr)
1772
1773 if(pSh)
1774 {
1775 pSh->StartAllAction();
1776 pSh->UpdateExpFields(true);
1777 pSh->EndAllAction();
1778 }
1779}
1781{
1783 if( pSh )
1784 return pSh->GetCurLang();
1786}
1787
1789{
1790 static const TranslateId coFieldNms[] =
1791 {
1792 FLD_DATE_STD,
1793 FLD_TIME_STD,
1794 STR_FILENAMEFLD,
1795 STR_DBNAMEFLD,
1796 STR_CHAPTERFLD,
1797 STR_PAGENUMBERFLD,
1798 STR_DOCSTATFLD,
1799 STR_AUTHORFLD,
1800 STR_SETFLD,
1801 STR_GETFLD,
1802 STR_FORMELFLD,
1803 STR_HIDDENTXTFLD,
1804 STR_SETREFFLD,
1805 STR_GETREFFLD,
1806 STR_DDEFLD,
1807 STR_MACROFLD,
1808 STR_INPUTFLD,
1809 STR_HIDDENPARAFLD,
1810 STR_DOCINFOFLD,
1811 STR_DBFLD,
1812 STR_USERFLD,
1813 STR_POSTITFLD,
1814 STR_TEMPLNAMEFLD,
1815 STR_SEQFLD,
1816 STR_DBNEXTSETFLD,
1817 STR_DBNUMSETFLD,
1818 STR_DBSETNUMBERFLD,
1819 STR_CONDTXTFLD,
1820 STR_NEXTPAGEFLD,
1821 STR_PREVPAGEFLD,
1822 STR_EXTUSERFLD,
1823 FLD_DATE_FIX,
1824 FLD_TIME_FIX,
1825 STR_SETINPUTFLD,
1826 STR_USRINPUTFLD,
1827 STR_SETREFPAGEFLD,
1828 STR_GETREFPAGEFLD,
1829 STR_INTERNETFLD,
1830 STR_JUMPEDITFLD,
1831 STR_SCRIPTFLD,
1832 STR_AUTHORITY,
1833 STR_COMBINED_CHARS,
1834 STR_DROPDOWN,
1835 STR_CUSTOM_FIELD,
1836 STR_PARAGRAPH_SIGNATURE
1837 };
1838
1839 // insert infos for fields
1840 SwFieldType::s_pFieldNames = new std::vector<OUString>;
1841 SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms));
1842 for (const TranslateId & id : coFieldNms)
1843 {
1844 const OUString aTmp(SwResId(id));
1846 }
1847}
1848
1850{
1851 bool bRet = false;
1852
1853 // choose script dialog
1854 OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
1855
1856 // the script selector dialog returns a valid script URL
1857 if ( !aScriptURL.isEmpty() )
1858 {
1859 SetMacroPath( aScriptURL );
1860 bRet = true;
1861 }
1862
1863 return bRet;
1864}
1865
1866void SwFieldMgr::SetMacroPath(const OUString& rPath)
1867{
1868 m_sMacroPath = rPath;
1869 m_sMacroName = rPath;
1870
1871 // try to set sMacroName member variable by parsing the macro path
1872 // using the new URI parsing services
1873
1875 ::comphelper::getProcessComponentContext();
1876
1878 xFactory = uri::UriReferenceFactory::create( xContext );
1879
1881 xUrl( xFactory->parse( m_sMacroPath ), UNO_QUERY );
1882
1883 if ( xUrl.is() )
1884 {
1885 m_sMacroName = xUrl->getName();
1886 }
1887}
1888
1889sal_uInt32 SwFieldMgr::GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
1890{
1891 SvNumFormatType nDefFormat;
1892
1893 switch (nTypeId)
1894 {
1897 {
1898 nDefFormat = (nTypeId == SwFieldTypesEnum::Date) ? SvNumFormatType::DATE : SvNumFormatType::TIME;
1899 }
1900 break;
1901
1902 default:
1903 if (bIsText)
1904 {
1905 nDefFormat = SvNumFormatType::TEXT;
1906 }
1907 else
1908 {
1909 nDefFormat = SvNumFormatType::ALL;
1910 }
1911 break;
1912 }
1913
1914 return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1915}
1916
1918{
1919 if(!m_xNumberingInfo.is())
1920 {
1921 Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
1922 Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
1923 const_cast<SwFieldMgr*>(this)->m_xNumberingInfo.set(xDefNum, UNO_QUERY);
1924 }
1925 return m_xNumberingInfo;
1926}
1927
1928/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static sal_uInt8 nTablePos
Definition: basesh.cxx:130
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).
LanguageType getLanguageType(bool bResolveSystem=true) const
static OUString EraseAllMnemonicChars(const OUString &rStr)
static OUString ChooseScript(weld::Window *pParent)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
const OUString & GetFormatstring() const
const LanguageTag & GetLanguageTag() const
OUString GetID() const
static sal_uInt32 FindIndex(int nValue)
static OUString GetString(sal_uInt32 i)
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
Definition: authfld.cxx:158
Represents an inserted bibliography entry, created using Insert -> Table of Contents and Index -> Bib...
Definition: authfld.hxx:161
const OUString & GetFieldText(ToxAuthorityField eField) const
Definition: authfld.cxx:550
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2550
void StartAction()
Definition: crsrsh.cxx:226
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:3055
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1073
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:674
static sal_uLong GetColumnFormat(css::uno::Reference< css::sdbc::XDataSource > const &xSource, css::uno::Reference< css::sdbc::XConnection > const &xConnection, css::uno::Reference< css::beans::XPropertySet > const &xColumn, SvNumberFormatter *pNFormatr, LanguageType nLanguage)
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:329
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1429
Dropdown field.
Definition: flddropdown.hxx:59
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:255
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
Definition: edfld.cxx:43
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1764
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:329
void RemoveFieldType(size_t nField)
delete field type
Definition: edfld.cxx:94
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
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:336
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
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
get the names of all references in a Doc
Definition: editsh.cxx:447
SwDBData const & GetDBData() const
Database information.
Definition: edfld.cxx:292
void SetModified()
Definition: edws.cxx:70
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
Definition: edfld.cxx:339
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
Definition: edfld.cxx:315
void EndAllAction()
Definition: edws.cxx:97
LanguageType GetCurLang() const
Definition: edattr.cxx:801
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
get the reference of a given name in the Doc
Definition: editsh.cxx:441
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:470
sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter *pFormatter)
Definition: fldmgr.cxx:1889
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:676
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
Definition: fldmgr.cxx:1569
void InsertFieldType(SwFieldType const &rType)
Definition: fldmgr.cxx:880
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
Definition: fldmgr.hxx:117
bool ChooseMacro(weld::Window *pDialogParent)
Definition: fldmgr.cxx:1849
OUString m_sMacroName
Definition: fldmgr.hxx:110
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:773
static const OUString & GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:532
OUString m_aCurPar2
Definition: fldmgr.hxx:106
SwFieldTypesEnum GetCurTypeId() const
Definition: fldmgr.cxx:889
bool CanInsertRefMark(std::u16string_view rStr)
Definition: fldmgr.cxx:381
~SwFieldMgr()
Definition: fldmgr.cxx:376
SwWrtShell * m_pWrtShell
Definition: fldmgr.hxx:104
void EvalExpFields(SwWrtShell *pSh)
Definition: fldmgr.cxx:1768
bool m_bEvalExp
Definition: fldmgr.hxx:113
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
Definition: fldmgr.cxx:415
bool GoNextPrev(bool bNext=true, SwFieldType *pTyp=nullptr)
Definition: fldmgr.cxx:855
size_t GetFieldTypeCount() const
Definition: fldmgr.cxx:408
void SetMacroPath(const OUString &rPath)
Definition: fldmgr.cxx:1866
SwField * m_pCurField
Definition: fldmgr.hxx:103
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:573
OUString m_sMacroPath
Definition: fldmgr.hxx:109
void RemoveFieldType(SwFieldIds nResId, const OUString &rName)
Definition: fldmgr.cxx:400
bool InsertField(SwInsertField_Data &rData)
Definition: fldmgr.cxx:895
sal_uInt32 m_nCurFormat
Definition: fldmgr.hxx:112
OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:719
SAL_DLLPRIVATE css::uno::Reference< css::text::XNumberingTypeInfo > const & GetNumberingInfo() const
Definition: fldmgr.cxx:1917
SAL_DLLPRIVATE LanguageType GetCurrLanguage() const
Definition: fldmgr.cxx:1780
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
Definition: fldmgr.cxx:554
SwFieldMgr(SwWrtShell *pSh=nullptr)
Definition: fldmgr.cxx:368
OUString m_sCurFrame
Definition: fldmgr.hxx:107
SwField * GetCurField()
Definition: fldmgr.cxx:430
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:526
OUString m_aCurPar1
Definition: fldmgr.hxx:105
static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType)
Definition: fldmgr.cxx:498
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual void UpdateFields()
Definition: fldbas.cxx:219
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:139
SwFieldIds Which() const
Definition: fldbas.hxx:276
static void GetFieldName_()
Sets up FieldNames; fldmgr.cxx!
Definition: fldmgr.cxx:1788
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:124
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:253
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:270
virtual OUString GetPar1() const
Definition: fldbas.cxx:334
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:511
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:407
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
virtual OUString GetPar2() const
Definition: fldbas.cxx:339
Get reference.
Definition: reffld.hxx:66
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
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:657
void DeleteMark()
Definition: pam.hxx:232
const SwPosition * GetPoint() const
Definition: pam.hxx:253
sal_uInt16 GetType() const
Definition: expfld.hxx:198
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:184
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:182
The shared part of a user field.
Definition: usrfld.hxx:35
OUString GetContent(sal_uInt32 nFormat=0) const
Definition: usrfld.cxx:283
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:299
The non-shared part of a user field.
Definition: usrfld.hxx:106
bool IsFieldName() const
Definition: viewopt.hxx:417
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:452
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2664
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:648
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
bool Right(SwCursorSkipMode nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:127
bool StartInputFieldDlg(SwField *, bool bPrevButton, bool bNextButton, weld::Widget *pParentWin, FieldDialogPressedButton *pPressedButton=nullptr)
Definition: wrtsh2.cxx:264
bool Left(SwCursorSkipMode nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:110
void ChgDBData(const SwDBData &SwDBData)
Definition: wrtsh1.cxx:2083
bool InsertField2(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:64
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
Definition: wrtsh1.cxx:2047
const SwView & GetView() const
Definition: wrtsh.hxx:443
#define FN_NUMBER_FORMAT
Definition: cmdid.h:477
int nCount
@ PG_NEXT
Definition: docufld.hxx:93
@ PG_RANDOM
Definition: docufld.hxx:92
@ PG_PREV
Definition: docufld.hxx:94
OString sFormula
ScXMLEditAttributeMap::Entry const aEntries[]
Reference< XSingleServiceFactory > xFactory
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:98
@ FF_FIXED
Definition: fldbas.hxx:166
@ FIXEDFLD
Definition: fldbas.hxx:233
@ DATEFLD
Definition: fldbas.hxx:234
@ TIMEFLD
Definition: fldbas.hxx:235
@ INP_VAR
Definition: fldbas.hxx:224
@ INP_USR
Definition: fldbas.hxx:223
SwFieldIds
Definition: fldbas.hxx:49
@ Database
For old documents the Field-Which IDs must be preserved !!!
@ TableOfAuthorities
@ DATE_VAR
Definition: flddat.hxx:33
const TranslateId FMT_REG_ARY[]
Definition: fldmgr.cxx:243
const TranslateId FMT_DBFLD_ARY[]
Definition: fldmgr.cxx:250
const TranslateId FMT_SETVAR_ARY[]
Definition: fldmgr.cxx:256
const TranslateId FMT_MARK_ARY[]
Definition: fldmgr.cxx:219
const TranslateId FMT_DDE_ARY[]
Definition: fldmgr.cxx:268
const sal_uInt16 VF_USR_COUNT
Definition: fldmgr.cxx:132
const TranslateId FMT_USERVAR_ARY[]
Definition: fldmgr.cxx:280
const TranslateId FMT_AUTHOR_ARY[]
Definition: fldmgr.cxx:154
static sal_uInt16 GetPackCount()
Definition: fldmgr.cxx:365
const sal_uInt16 VF_COUNT
Definition: fldmgr.cxx:131
@ GRP_VAR_END
Definition: fldmgr.cxx:107
@ GRP_DOC_END
Definition: fldmgr.cxx:92
@ GRP_DOC_BEGIN
Definition: fldmgr.cxx:91
@ GRP_REF_END
Definition: fldmgr.cxx:98
@ GRP_VAR_BEGIN
Definition: fldmgr.cxx:106
@ GRP_DB_BEGIN
Definition: fldmgr.cxx:103
@ GRP_REF_BEGIN
Definition: fldmgr.cxx:97
@ GRP_REG_END
Definition: fldmgr.cxx:101
@ GRP_FKT_END
Definition: fldmgr.cxx:95
@ GRP_REG_BEGIN
Definition: fldmgr.cxx:100
@ GRP_FKT_BEGIN
Definition: fldmgr.cxx:94
@ GRP_DB_END
Definition: fldmgr.cxx:104
const TranslateId FMT_FF_ARY[]
Definition: fldmgr.cxx:185
const TranslateId FLD_EU_ARY[]
Definition: fldmgr.cxx:135
const sal_uInt16 VF_DB_COUNT
Definition: fldmgr.cxx:133
const TranslateId FLD_STAT_ARY[]
Definition: fldmgr.cxx:195
const TranslateId FMT_CHAPTER_ARY[]
Definition: fldmgr.cxx:206
const TranslateId FMT_NUM_ARY[]
Definition: fldmgr.cxx:172
const SwFieldPack aSwFields[]
Definition: fldmgr.cxx:303
const TranslateId FLD_PAGEREF_ARY[]
Definition: fldmgr.cxx:274
const TranslateId FMT_REF_ARY[]
Definition: fldmgr.cxx:228
const TranslateId FMT_GETVAR_ARY[]
Definition: fldmgr.cxx:262
const TranslateId FLD_TIME_ARY[]
Definition: fldmgr.cxx:166
static SwWrtShell * lcl_GetShell()
Definition: fldmgr.cxx:358
@ GRP_WEB_DB_BEGIN
Definition: fldmgr.cxx:124
@ GRP_WEB_REG_END
Definition: fldmgr.cxx:122
@ GRP_WEB_FKT_BEGIN
Definition: fldmgr.cxx:115
@ GRP_WEB_REF_END
Definition: fldmgr.cxx:119
@ GRP_WEB_DOC_END
Definition: fldmgr.cxx:113
@ GRP_WEB_DOC_BEGIN
Definition: fldmgr.cxx:112
@ GRP_WEB_DB_END
Definition: fldmgr.cxx:125
@ GRP_WEB_VAR_END
Definition: fldmgr.cxx:128
@ GRP_WEB_FKT_END
Definition: fldmgr.cxx:116
@ GRP_WEB_REF_BEGIN
Definition: fldmgr.cxx:118
@ GRP_WEB_VAR_BEGIN
Definition: fldmgr.cxx:127
@ GRP_WEB_REG_BEGIN
Definition: fldmgr.cxx:121
const TranslateId FLD_INPUT_ARY[]
Definition: fldmgr.cxx:214
const TranslateId FLD_DATE_ARY[]
Definition: fldmgr.cxx:160
@ GRP_DOC
Definition: fldmgr.hxx:54
@ GRP_VAR
Definition: fldmgr.hxx:59
Reference< XColumn > xColumn
sal_Int32 nIndex
sal_Int64 n
#define LANGUAGE_HUNGARIAN
sal_uInt16 nPos
SfxLinkUpdateMode
#define SAL_N_ELEMENTS(arr)
SW_DLLPUBLIC void PasteHTMLToPaM(SwWrtShell &rWrtSh, SwPaM *pCursor, const OString &rData)
OString stripStart(const OString &rIn, char c)
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
int i
const SwDocInfoSubType DI_SUB_AUTHOR
Definition: docufld.hxx:83
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:80
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
Definition: docufld.hxx:70
const SwDocInfoSubType DI_SUBTYPE_END
Definition: docufld.hxx:81
const SwDocInfoSubType DI_SUB_DATE
Definition: docufld.hxx:85
const SwDocInfoSubType DI_SUB_TIME
Definition: docufld.hxx:84
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:217
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:218
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:209
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:210
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
const sal_Unicode cTokenSeparator
eField
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
#define LINK_TOKEN
sal_Int16 nId
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
DefTokenId nToken
#define RESARRAY_INDEX_NOTFOUND
static LanguageType nLang
Definition: srtdlg.cxx:51
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:62
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
OUString sDataSource
Definition: swdbdata.hxx:30
OUString sCommand
Definition: swdbdata.hxx:31
sal_uInt16 nStart
Definition: fldmgr.hxx:64
sal_uInt16 nEnd
Definition: fldmgr.hxx:65
const OUString m_sPar2
Definition: fldmgr.hxx:75
bool m_bIsAutomaticLanguage
Definition: fldmgr.hxx:79
SwWrtShell * m_pSh
Definition: fldmgr.hxx:77
sal_uInt16 m_nSubType
Definition: fldmgr.hxx:73
css::uno::Any m_aDBColumn
Definition: fldmgr.hxx:82
sal_uInt32 m_nFormatId
Definition: fldmgr.hxx:76
std::optional< SwPaM > m_oAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
Definition: fldmgr.hxx:85
css::uno::Any m_aDBDataSource
Definition: fldmgr.hxx:80
SwFieldTypesEnum m_nTypeId
Definition: fldmgr.hxx:72
const OUString m_sPar1
Definition: fldmgr.hxx:74
sal_Unicode m_cSeparator
Definition: fldmgr.hxx:78
css::uno::Any m_aDBConnection
Definition: fldmgr.hxx:81
weld::Widget * m_pParent
Definition: fldmgr.hxx:83
static OUString GetSourceURL(const OUString &rText)
Gets the URL of the underlying SwAuthEntry, ignoring its page number.
Definition: txmsrt.cxx:851
SVX_NUM_CHARS_LOWER_LETTER_N
SVX_NUM_CHARS_LOWER_LETTER
SVX_NUM_CHARS_UPPER_LETTER
SVX_NUM_ROMAN_UPPER
SVX_NUM_ROMAN_LOWER
SVX_NUM_ARABIC
SVX_NUM_CHARS_UPPER_LETTER_N
SVX_NUM_CHAR_SPECIAL
SVX_NUM_PAGEDESC
SwView * GetActiveView()
Definition: swmodul1.cxx:115
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
#define DB_DELIM
Definition: swtypes.hxx:130
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:422
ToxAuthorityField
Definition: toxe.hxx:83
@ AUTH_FIELD_IDENTIFIER
Definition: toxe.hxx:84
@ AUTH_FIELD_URL
Definition: toxe.hxx:110
@ AUTH_FIELD_END
Definition: toxe.hxx:121
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
ResultType type
OUString sId
const SvXMLTokenMapEntry aTypes[]
SvNumFormatType