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>
75
76using namespace com::sun::star::uno;
77using namespace com::sun::star::container;
78using namespace com::sun::star::lang;
79using namespace com::sun::star::beans;
80using namespace com::sun::star::text;
81using namespace com::sun::star::style;
82using namespace com::sun::star::sdbc;
83using namespace ::com::sun::star;
84using namespace nsSwDocInfoSubType;
85
86// groups of fields
87enum
88{
91
94
97
100
103
107
108enum
109{
112
114 GRP_WEB_FKT_END = GRP_WEB_FKT_BEGIN + 0, // the group is empty!
115
116 GRP_WEB_REF_BEGIN = GRP_WEB_FKT_END + 6, // the group is empty!
118
121
122 GRP_WEB_DB_BEGIN = GRP_WEB_REG_END, // the group is empty!
124
128
129const sal_uInt16 VF_COUNT = 1; // { 0 }
130const sal_uInt16 VF_USR_COUNT = 2; // { 0, nsSwExtendedSubType::SUB_CMD }
131const sal_uInt16 VF_DB_COUNT = 1; // { nsSwExtendedSubType::SUB_OWN_FMT }
132
134{
135 FLD_EU_COMPANY,
136 FLD_EU_GIVENNAME,
137 FLD_EU_SURNAME,
138 FLD_EU_INITIALS,
139 FLD_EU_STREET,
140 FLD_EU_COUNTRY,
141 FLD_EU_POSTCODE,
142 FLD_EU_TOWN,
143 FLD_EU_TITLE,
144 FLD_EU_POS,
145 FLD_EU_TELPERSONAL,
146 FLD_EU_TELWORK,
147 FLD_EU_FAX,
148 FLD_EU_EMAIL,
149 FLD_EU_REGION
150};
151
153{
154 FMT_AUTHOR_NAME,
155 FMT_AUTHOR_SCUT
156};
157
159{
160 FLD_DATE_STD,
161 FLD_DATE_FIX,
162};
163
165{
166 FLD_TIME_STD,
167 FLD_TIME_FIX,
168};
169
171{
172 FMT_NUM_ABC,
173 FMT_NUM_SABC,
174 FMT_NUM_ABC_N,
175 FMT_NUM_SABC_N,
176 FMT_NUM_ROMAN,
177 FMT_NUM_SROMAN,
178 FMT_NUM_ARABIC,
179 FMT_NUM_PAGEDESC,
180 FMT_NUM_PAGESPECIAL
181};
182
184{
185 FMT_FF_NAME,
186 FMT_FF_PATHNAME,
187 FMT_FF_PATH,
188 FMT_FF_NAME_NOEXT,
189 FMT_FF_UI_NAME,
190 FMT_FF_UI_RANGE
191};
192
194{
195 FLD_STAT_PAGE,
196 FLD_STAT_PARA,
197 FLD_STAT_WORD,
198 FLD_STAT_CHAR,
199 FLD_STAT_TABLE,
200 FLD_STAT_GRF,
201 FLD_STAT_OBJ
202};
203
205{
206 FMT_CHAPTER_NO,
207 FMT_CHAPTER_NAME,
208 FMT_CHAPTER_NAMENO,
209 FMT_CHAPTER_NO_NOSEPARATOR
210};
211
213{
214 FLD_INPUT_TEXT
215};
216
218{
219 FMT_MARK_TEXT,
220 FMT_MARK_TABLE,
221 FMT_MARK_FRAME,
222 FMT_MARK_GRAFIC,
223 FMT_MARK_OLE
224};
225
227{
228 FMT_REF_PAGE,
229 FMT_REF_CHAPTER,
230 FMT_REF_TEXT,
231 FMT_REF_UPDOWN,
232 FMT_REF_PAGE_PGDSC,
233 FMT_REF_ONLYNUMBER,
234 FMT_REF_ONLYCAPTION,
235 FMT_REF_ONLYSEQNO,
236 FMT_REF_NUMBER,
237 FMT_REF_NUMBER_NO_CONTEXT,
238 FMT_REF_NUMBER_FULL_CONTEXT
239};
240
242{
243 FMT_REG_AUTHOR,
244 FMT_REG_TIME,
245 FMT_REG_DATE
246};
247
249{
250 FMT_DBFLD_DB,
251 FMT_DBFLD_SYS
252};
253
255{
256 FMT_SETVAR_SYS,
257 FMT_SETVAR_TEXT
258};
259
261{
262 FMT_GETVAR_TEXT,
263 FMT_GETVAR_NAME
264};
265
267{
268 FMT_DDE_NORMAL,
269 FMT_DDE_HOT
270};
271
273{
274 FLD_PAGEREF_OFF,
275 FLD_PAGEREF_ON
276};
277
279{
280 FMT_USERVAR_TEXT,
281 FMT_USERVAR_CMD
282};
283
284namespace {
285
286// field types and subtypes
287struct SwFieldPack
288{
289 SwFieldTypesEnum nTypeId;
290
291 const TranslateId* pSubTypeResIds;
292 size_t nSubTypeLength;
293
294 const TranslateId* pFormatResIds;
295 size_t nFormatLength;
296};
297
298}
299
300// strings and formats
301const SwFieldPack aSwFields[] =
302{
303 // Document
313
316 { SwFieldTypesEnum::ParagraphSignature, nullptr, 0, nullptr, 0 },
317
318 // Functions
319 { SwFieldTypesEnum::ConditionalText, nullptr, 0, nullptr, 0 },
320 { SwFieldTypesEnum::Dropdown, nullptr, 0, nullptr, 0 },
322 { SwFieldTypesEnum::Macro, nullptr, 0, nullptr, 0 },
324 { SwFieldTypesEnum::CombinedChars, nullptr, 0, nullptr, 0 },
325 { SwFieldTypesEnum::HiddenText, nullptr, 0, nullptr, 0 },
326 { SwFieldTypesEnum::HiddenParagraph, nullptr, 0, nullptr, 0 },
327
328 // Cross-References
329 { SwFieldTypesEnum::SetRef, nullptr, 0, nullptr, 0 },
331
332 // DocInformation
334
335 // Database
337 { SwFieldTypesEnum::DatabaseNextSet, nullptr, 0, nullptr, 0 },
338 { SwFieldTypesEnum::DatabaseNumberSet, nullptr, 0, nullptr, 0 },
340 { SwFieldTypesEnum::DatabaseName, nullptr, 0, nullptr, 0 },
341
342 // Variables
344
353};
354
355// access to the shell
357{
358 SwView* pView = ::GetActiveView();
359 if ( nullptr != pView )
360 return pView->GetWrtShellPtr();
361 OSL_FAIL("no current shell found!");
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 pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
1075 return true;
1076 }
1077 return false;
1078 }
1079
1081 {
1082 SwGetRefFieldType* pTyp =
1083 static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) );
1084 sal_uInt16 nSeqNo = o3tl::narrowing<sal_uInt16>(rData.m_sPar2.toInt32());
1085 OUString sReferenceLanguage;
1086 // handle language-variant formats
1087 if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY))
1088 {
1091 {
1092 if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2)
1093 sReferenceLanguage = "Hu";
1094 else
1095 sReferenceLanguage = "hu";
1096 }
1097 nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY);
1098 }
1099 pField.reset(new SwGetRefField(pTyp, rData.m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1100 bExp = true;
1101 break;
1102 }
1103
1105 {
1106 //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
1107 // That's not yet considered here.
1108 sal_Int32 nIndex = 0;
1109 OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1110 if (nIndex>=0 && ++nIndex<sCmd.getLength())
1111 {
1112 sCmd = sCmd.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1113 }
1114
1115 SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
1116 SwDDEFieldType* pTyp = static_cast<SwDDEFieldType*>( pCurShell->InsertFieldType( aType ) );
1117 pField.reset(new SwDDEField( pTyp ));
1118 break;
1119 }
1120
1122 {
1123 SwMacroFieldType* pTyp =
1124 static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro));
1125
1126 pField.reset(new SwMacroField(pTyp, rData.m_sPar1, rData.m_sPar2));
1127
1128 break;
1129 }
1130
1132 {
1133 SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame );
1134 return pCurShell->InsertURL( aFormat, rData.m_sPar2 );
1135 }
1136
1138 {
1139 SwJumpEditFieldType* pTyp =
1140 static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit));
1141
1142 pField.reset(new SwJumpEditField(pTyp, nFormatId, rData.m_sPar1, rData.m_sPar2));
1143 break;
1144 }
1145
1147 {
1148 SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType(
1149 0, SwFieldIds::DocInfo ) );
1150 pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId));
1151 break;
1152 }
1153
1155 {
1156 SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType(
1157 0, SwFieldIds::ExtUser) );
1158 pField.reset(new SwExtUserField(pTyp, nSubType, nFormatId));
1159 break;
1160 }
1161
1163 {
1164#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1165 SwDBData aDBData;
1166 OUString sPar1;
1167
1168 if (rData.m_sPar1.indexOf(DB_DELIM)<0)
1169 {
1170 aDBData = pCurShell->GetDBData();
1171 sPar1 = rData.m_sPar1;
1172 }
1173 else
1174 {
1175 sal_Int32 nIdx{ 0 };
1176 aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1177 aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1178 aDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rData.m_sPar1, 0, DB_DELIM, nIdx));
1179 sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1180 }
1181
1182 if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1183 pCurShell->ChgDBData(aDBData);
1184
1185 SwDBFieldType* pTyp = static_cast<SwDBFieldType*>(pCurShell->InsertFieldType(
1186 SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) ) );
1187 pField.reset(new SwDBField(pTyp));
1188 pField->SetSubType(nSubType);
1189
1190 if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determine database format
1191 {
1193 rData.m_aDBDataSource >>= xSource;
1194 Reference<XConnection> xConnection;
1195 rData.m_aDBConnection >>= xConnection;
1197 rData.m_aDBColumn >>= xColumn;
1198 if(xColumn.is())
1199 {
1200 nFormatId = SwDBManager::GetColumnFormat(xSource, xConnection, xColumn,
1201 pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1202 }
1203 else
1204 nFormatId = pCurShell->GetDBManager()->GetColumnFormat(
1205 aDBData.sDataSource, aDBData.sCommand, sPar1,
1206 pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1207 }
1208 pField->ChangeFormat( nFormatId );
1209
1210 bExp = true;
1211#endif
1212 break;
1213 }
1214
1219 {
1220#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1221 SwDBData aDBData;
1222
1223 // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg
1224 sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM);
1225 sal_Int32 nExpPos = -1;
1226
1227 if (nTablePos>=0)
1228 {
1229 aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++);
1230 sal_Int32 nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos);
1231 if (nCmdTypePos>=0)
1232 {
1233 aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos);
1234 nExpPos = rData.m_sPar1.indexOf(DB_DELIM, nCmdTypePos);
1235 if (nExpPos>=0)
1236 {
1237 aDBData.nCommandType = o3tl::toInt32(rData.m_sPar1.subView(nCmdTypePos, nExpPos++ - nCmdTypePos));
1238 }
1239 }
1240 }
1241
1242 sal_Int32 nPos = 0;
1243 if (nExpPos>=0)
1244 nPos = nExpPos;
1245 else if (nTablePos>=0)
1246 nPos = nTablePos;
1247
1248 OUString sPar1 = rData.m_sPar1.copy(nPos);
1249
1250 if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1251 pCurShell->ChgDBData(aDBData);
1252
1253 switch(rData.m_nTypeId)
1254 {
1256 {
1257 SwDBNameFieldType* pTyp =
1258 static_cast<SwDBNameFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::DatabaseName));
1259 pField.reset(new SwDBNameField(pTyp, aDBData));
1260
1261 break;
1262 }
1264 {
1265 SwDBNextSetFieldType* pTyp = static_cast<SwDBNextSetFieldType*>(pCurShell->GetFieldType(
1267 pField.reset(new SwDBNextSetField(pTyp, sPar1, aDBData));
1268 bExp = true;
1269 break;
1270 }
1272 {
1273 SwDBNumSetFieldType* pTyp = static_cast<SwDBNumSetFieldType*>( pCurShell->GetFieldType(
1275 pField.reset(new SwDBNumSetField( pTyp, sPar1, rData.m_sPar2, aDBData));
1276 bExp = true;
1277 break;
1278 }
1280 {
1281 SwDBSetNumberFieldType* pTyp = static_cast<SwDBSetNumberFieldType*>(
1282 pCurShell->GetFieldType(0, SwFieldIds::DbSetNumber) );
1283 pField.reset(new SwDBSetNumberField( pTyp, aDBData, nFormatId));
1284 bExp = true;
1285 break;
1286 }
1287 default: break;
1288 }
1289#endif
1290 break;
1291 }
1292
1294 {
1295 SwUserFieldType* pTyp =
1296 static_cast<SwUserFieldType*>( pCurShell->GetFieldType(SwFieldIds::User, rData.m_sPar1) );
1297
1298 // only if existing
1299 if(!pTyp)
1300 {
1301 pTyp = static_cast<SwUserFieldType*>( pCurShell->InsertFieldType(
1302 SwUserFieldType(pCurShell->GetDoc(), rData.m_sPar1)) );
1303 }
1304 if (pTyp->GetContent(nFormatId) != rData.m_sPar2)
1305 pTyp->SetContent(rData.m_sPar2, nFormatId);
1306 pField.reset(new SwUserField(pTyp, 0, nFormatId));
1307 if (pField->GetSubType() != nSubType)
1308 pField->SetSubType(nSubType);
1309 bTable = true;
1310 break;
1311 }
1312
1314 {
1315 if ((nSubType & 0x00ff) == INP_VAR)
1316 {
1317 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>(
1318 pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1) );
1319
1320 // no Expression Type with this name existing -> create
1321 if(pTyp)
1322 {
1323 std::unique_ptr<SwSetExpField> pExpField(
1324 new SwSetExpField(pTyp, OUString(), nFormatId));
1325
1326 // Don't change type of SwSetExpFieldType:
1327 sal_uInt16 nOldSubType = pExpField->GetSubType();
1328 pExpField->SetSubType(nOldSubType | (nSubType & 0xff00));
1329
1330 pExpField->SetPromptText(rData.m_sPar2);
1331 pExpField->SetInputFlag(true) ;
1332 bExp = true;
1333 pField = std::move(pExpField);
1334 }
1335 else
1336 return false;
1337 }
1338 else
1339 {
1340 SwInputFieldType* pTyp =
1341 static_cast<SwInputFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Input) );
1342
1343 pField.reset(
1344 new SwInputField( pTyp, rData.m_sPar1, rData.m_sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId));
1345 }
1346 break;
1347 }
1348
1350 {
1351 if (rData.m_sPar2.isEmpty()) // empty variables are not allowed
1352 return false;
1353
1354 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1355 SwSetExpFieldType(pCurShell->GetDoc(), rData.m_sPar1) ) );
1356
1357 std::unique_ptr<SwSetExpField> pExpField(new SwSetExpField( pTyp, rData.m_sPar2, nFormatId));
1358 pExpField->SetSubType(nSubType);
1359 pExpField->SetPar2(rData.m_sPar2);
1360 bExp = true;
1361 pField = std::move(pExpField);
1362 break;
1363 }
1364
1366 {
1367 SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1369
1370 sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1371
1372 pTyp->SetOutlineLvl(nLevel);
1373 if (nLevel != 0x7f && cSeparator == 0)
1374 cSeparator = '.';
1375
1376 pTyp->SetDelimiter(OUString(cSeparator));
1377 pField.reset(new SwSetExpField(pTyp, rData.m_sPar2, nFormatId));
1378 bExp = true;
1379 break;
1380 }
1381
1383 {
1384 // is there a corresponding SetField
1385 SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
1386 pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1));
1387
1388 if(pSetTyp)
1389 {
1390 SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>( pCurShell->GetFieldType(
1391 0, SwFieldIds::GetExp) );
1392 pField.reset( new SwGetExpField(pTyp, rData.m_sPar1, pSetTyp->GetType(), nFormatId) );
1393 pField->SetSubType(nSubType | pSetTyp->GetType());
1394 bExp = true;
1395 }
1396 else
1397 return false;
1398 break;
1399 }
1400
1402 {
1403 if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE)
1404 {
1405 pCurShell->StartAllAction();
1406
1407 SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1408 const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1409
1410 if (pEntry)
1411 {
1413 pCurShell->GetView().GetViewFrame()->GetDispatcher()->
1414 ExecuteList(FN_NUMBER_FORMAT, SfxCallMode::SYNCHRON,
1415 { &aFormat });
1416 }
1417
1419
1420 OUString sFormula(comphelper::string::stripStart(rData.m_sPar2, ' '));
1421 if ( sFormula.startsWith("=") )
1422 {
1423 sFormula = sFormula.copy(1);
1424 }
1425
1426 aBoxSet.Put( SwTableBoxFormula( sFormula ));
1427 pCurShell->SetTableBoxFormulaAttrs( aBoxSet );
1428 pCurShell->UpdateTable();
1429
1430 pCurShell->EndAllAction();
1431 return true;
1432
1433 }
1434 else
1435 {
1436 SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>(
1437 pCurShell->GetFieldType(0, SwFieldIds::GetExp) );
1438 pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId) );
1439 pField->SetSubType(nSubType);
1440 bExp = true;
1441 }
1442 break;
1443 }
1445 pField.reset( new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(
1446 pCurShell->GetFieldType( 0, SwFieldIds::RefPageSet ) ),
1447 static_cast<short>(rData.m_sPar2.toInt32()), 0 != nSubType ) );
1448 bPageVar = true;
1449 break;
1450
1452 pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>(
1453 pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) );
1454 bPageVar = true;
1455 break;
1457 {
1458 pField.reset( new SwDropDownField(pCurShell->GetFieldType( 0, SwFieldIds::Dropdown )) );
1459 const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.m_sPar2, DB_DELIM);
1460 Sequence<OUString> aEntries(nTokenCount);
1461 OUString* pArray = aEntries.getArray();
1462 for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1463 pArray[nToken] = rData.m_sPar2.getToken(0, DB_DELIM, nIdx);
1464 static_cast<SwDropDownField*>(pField.get())->SetItems(aEntries);
1465 static_cast<SwDropDownField*>(pField.get())->SetName(rData.m_sPar1);
1466 }
1467 break;
1468
1469 // Insert Paragraph Signature field by signing the paragraph.
1470 // The resulting field is really a metadata field, created and added via signing.
1472 pCurShell->SignParagraph();
1473 return true;
1474
1475 default:
1476 { OSL_ENSURE(false, "wrong field type");
1477 return false;
1478 }
1479 }
1480 OSL_ENSURE(pField, "field not available");
1481
1482 //the auto language flag has to be set prior to the language!
1483 pField->SetAutomaticLanguage(rData.m_bIsAutomaticLanguage);
1485 pField->SetLanguage(nLang);
1486
1487 // insert
1488 pCurShell->StartAllAction();
1489
1490 bool const isSuccess = pCurShell->InsertField2(*pField, rData.m_oAnnotationRange ? &*rData.m_oAnnotationRange : nullptr);
1491
1492 if (isSuccess)
1493 {
1495 {
1496 pCurShell->Push();
1497
1498 // start dialog, not before the field is inserted tdf#99529
1499 pCurShell->Left(SwCursorSkipMode::Chars, false,
1500 (INP_VAR == (nSubType & 0xff) || pCurShell->GetViewOptions()->IsFieldName()) ? 1 : 2,
1501 false);
1502 pCurShell->StartInputFieldDlg(pField.get(), false, true, rData.m_pParent);
1503
1505 }
1506
1507 if (bExp && m_bEvalExp)
1508 {
1509 pCurShell->UpdateExpFields(true);
1510 }
1511
1512 if (bTable)
1513 {
1514 pCurShell->Left(SwCursorSkipMode::Chars, false, 1, false );
1515 pCurShell->UpdateOneField(*pField);
1516 pCurShell->Right(SwCursorSkipMode::Chars, false, 1, false );
1517 }
1518 else if (bPageVar)
1519 {
1520 static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::RefPageGet))->UpdateFields();
1521 }
1522 else if (SwFieldTypesEnum::GetRef == rData.m_nTypeId)
1523 {
1524 pField->GetTyp()->UpdateFields();
1525 }
1526 }
1527
1528 // delete temporary field
1529 pField.reset();
1530
1531 pCurShell->EndAllAction();
1532 return isSuccess;
1533}
1534
1535// fields update
1536void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
1537 const OUString& rPar1,
1538 const OUString& rPar2,
1539 std::unique_ptr<SwField> pTmpField)
1540{
1541 // change format
1542 OSL_ENSURE(m_pCurField, "no field at CursorPos");
1543
1544 if (!pTmpField)
1545 pTmpField = m_pCurField->CopyField();
1546
1547 SwFieldType* pType = pTmpField->GetTyp();
1548 const SwFieldTypesEnum nTypeId = pTmpField->GetTypeId();
1549
1551 OSL_ENSURE(pSh, "no SwWrtShell found");
1552 if(!pSh)
1553 return;
1554 pSh->StartAllAction();
1555
1556 bool bSetPar2 = true;
1557 bool bSetPar1 = true;
1558 OUString sPar2( rPar2 );
1559
1560 // Order to Format
1561 switch( nTypeId )
1562 {
1564 {
1565 // DDE-Topics/-Items can have blanks in their names!
1566 // That's not yet considered here!
1567 sal_Int32 nIndex = 0;
1568 sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex );
1569 if (nIndex>=0 && ++nIndex<sPar2.getLength())
1570 {
1571 sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1572 }
1573 break;
1574 }
1575
1577 {
1578 sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rPar2.toInt32());
1579 nByte = std::max(sal_uInt16(1), nByte);
1580 nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1581 nByte -= 1;
1582 static_cast<SwChapterField*>(pTmpField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1583 bSetPar2 = false;
1584 break;
1585 }
1586
1588 static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat));
1589 break;
1590
1592 if( SVX_NUM_CHAR_SPECIAL == nFormat )
1593 {
1594 static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1595 sPar2 = "1";
1596 }
1597 else
1598 {
1599 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1600 nFormat = SVX_NUM_PAGEDESC;
1601 short nOff = static_cast<short>(sPar2.toInt32());
1602 nOff += 1;
1603 sPar2 = OUString::number(nOff);
1604 }
1605 break;
1606
1608 if( SVX_NUM_CHAR_SPECIAL == nFormat )
1609 {
1610 static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1611 sPar2 = "-1";
1612 }
1613 else
1614 {
1615 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1616 nFormat = SVX_NUM_PAGEDESC;
1617 short nOff = static_cast<short>(sPar2.toInt32());
1618 nOff -= 1;
1619 sPar2 = OUString::number(nOff);
1620 }
1621 break;
1622
1625 if( nFormat + 2 == SVX_NUM_PAGEDESC )
1626 nFormat = SVX_NUM_PAGEDESC;
1627 break;
1628
1630 {
1631 bSetPar2 = false;
1632 static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( o3tl::narrowing<sal_uInt16>(rPar2.toInt32()) );
1633 const sal_Int32 nPos = rPar2.indexOf( '|' );
1634 if( nPos>=0 )
1635 static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( o3tl::narrowing<sal_uInt16>(o3tl::toInt32(rPar2.subView( nPos + 1 ))));
1636 }
1637 break;
1639 {
1640 sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
1641 Sequence<OUString> aEntries(nTokenCount);
1642 OUString* pArray = aEntries.getArray();
1643 for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1644 pArray[nToken] = sPar2.getToken(0, DB_DELIM, nIdx);
1645 static_cast<SwDropDownField*>(pTmpField.get())->SetItems(aEntries);
1646 static_cast<SwDropDownField*>(pTmpField.get())->SetName(rPar1);
1647 bSetPar1 = bSetPar2 = false;
1648 }
1649 break;
1651 {
1652 //#i99069# changes to a bibliography field should change the field type
1653 SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get());
1654 SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1656 for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i )
1657 xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
1658 rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx ));
1659
1660 // If just the page number of the URL changed, then update the current field and not
1661 // others.
1662 bool bEquivalent = true;
1663 for (int i = 0; i < AUTH_FIELD_END; ++i)
1664 {
1665 auto eField = static_cast<ToxAuthorityField>(i);
1666 if (eField == AUTH_FIELD_URL)
1667 {
1668 if (SwTOXAuthority::GetSourceURL(xTempEntry->GetAuthorField(AUTH_FIELD_URL))
1670 pAuthorityField->GetFieldText(AUTH_FIELD_URL)))
1671 {
1672 bEquivalent = false;
1673 break;
1674 }
1675 }
1676 else
1677 {
1678 if (xTempEntry->GetAuthorField(eField) != pAuthorityField->GetFieldText(eField))
1679 {
1680 bEquivalent = false;
1681 break;
1682 }
1683 }
1684 }
1685
1686 if (bEquivalent)
1687 {
1688 break;
1689 }
1690
1691 if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) )
1692 {
1693 pType->UpdateFields();
1694 pSh->SetModified();
1695 }
1696
1697 if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1698 pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1699 bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
1700 bSetPar2 = false;
1701 }
1702 break;
1703 default: break;
1704 }
1705
1706 // set format
1707 // setup format before SetPar2 because of NumberFormatter!
1708 pTmpField->ChangeFormat(nFormat);
1709
1710 if( bSetPar1 )
1711 pTmpField->SetPar1( rPar1 );
1712 if( bSetPar2 )
1713 pTmpField->SetPar2( sPar2 );
1714
1715 // kick off update
1716 if(nTypeId == SwFieldTypesEnum::DDE ||
1717 nTypeId == SwFieldTypesEnum::User ||
1718 nTypeId == SwFieldTypesEnum::UserInput)
1719 {
1720 pType->UpdateFields();
1721 pSh->SetModified();
1722 }
1723 else {
1724 // mb: #32157
1725 pSh->SwEditShell::UpdateOneField(*pTmpField);
1726 GetCurField();
1727 }
1728
1729 pTmpField.reset();
1730
1731 pSh->EndAllAction();
1732}
1733
1734// explicitly evaluate ExpressionFields
1736{
1737 if (pSh == nullptr)
1739
1740 if(pSh)
1741 {
1742 pSh->StartAllAction();
1743 pSh->UpdateExpFields(true);
1744 pSh->EndAllAction();
1745 }
1746}
1748{
1750 if( pSh )
1751 return pSh->GetCurLang();
1753}
1754
1756{
1757 static const TranslateId coFieldNms[] =
1758 {
1759 FLD_DATE_STD,
1760 FLD_TIME_STD,
1761 STR_FILENAMEFLD,
1762 STR_DBNAMEFLD,
1763 STR_CHAPTERFLD,
1764 STR_PAGENUMBERFLD,
1765 STR_DOCSTATFLD,
1766 STR_AUTHORFLD,
1767 STR_SETFLD,
1768 STR_GETFLD,
1769 STR_FORMELFLD,
1770 STR_HIDDENTXTFLD,
1771 STR_SETREFFLD,
1772 STR_GETREFFLD,
1773 STR_DDEFLD,
1774 STR_MACROFLD,
1775 STR_INPUTFLD,
1776 STR_HIDDENPARAFLD,
1777 STR_DOCINFOFLD,
1778 STR_DBFLD,
1779 STR_USERFLD,
1780 STR_POSTITFLD,
1781 STR_TEMPLNAMEFLD,
1782 STR_SEQFLD,
1783 STR_DBNEXTSETFLD,
1784 STR_DBNUMSETFLD,
1785 STR_DBSETNUMBERFLD,
1786 STR_CONDTXTFLD,
1787 STR_NEXTPAGEFLD,
1788 STR_PREVPAGEFLD,
1789 STR_EXTUSERFLD,
1790 FLD_DATE_FIX,
1791 FLD_TIME_FIX,
1792 STR_SETINPUTFLD,
1793 STR_USRINPUTFLD,
1794 STR_SETREFPAGEFLD,
1795 STR_GETREFPAGEFLD,
1796 STR_INTERNETFLD,
1797 STR_JUMPEDITFLD,
1798 STR_SCRIPTFLD,
1799 STR_AUTHORITY,
1800 STR_COMBINED_CHARS,
1801 STR_DROPDOWN,
1802 STR_CUSTOM_FIELD,
1803 STR_PARAGRAPH_SIGNATURE
1804 };
1805
1806 // insert infos for fields
1807 SwFieldType::s_pFieldNames = new std::vector<OUString>;
1808 SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms));
1809 for (const TranslateId & id : coFieldNms)
1810 {
1811 const OUString aTmp(SwResId(id));
1813 }
1814}
1815
1817{
1818 bool bRet = false;
1819
1820 // choose script dialog
1821 OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
1822
1823 // the script selector dialog returns a valid script URL
1824 if ( !aScriptURL.isEmpty() )
1825 {
1826 SetMacroPath( aScriptURL );
1827 bRet = true;
1828 }
1829
1830 return bRet;
1831}
1832
1833void SwFieldMgr::SetMacroPath(const OUString& rPath)
1834{
1835 m_sMacroPath = rPath;
1836 m_sMacroName = rPath;
1837
1838 // try to set sMacroName member variable by parsing the macro path
1839 // using the new URI parsing services
1840
1842 ::comphelper::getProcessComponentContext();
1843
1845 xFactory = uri::UriReferenceFactory::create( xContext );
1846
1848 xUrl( xFactory->parse( m_sMacroPath ), UNO_QUERY );
1849
1850 if ( xUrl.is() )
1851 {
1852 m_sMacroName = xUrl->getName();
1853 }
1854}
1855
1856sal_uInt32 SwFieldMgr::GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
1857{
1858 SvNumFormatType nDefFormat;
1859
1860 switch (nTypeId)
1861 {
1864 {
1865 nDefFormat = (nTypeId == SwFieldTypesEnum::Date) ? SvNumFormatType::DATE : SvNumFormatType::TIME;
1866 }
1867 break;
1868
1869 default:
1870 if (bIsText)
1871 {
1872 nDefFormat = SvNumFormatType::TEXT;
1873 }
1874 else
1875 {
1876 nDefFormat = SvNumFormatType::ALL;
1877 }
1878 break;
1879 }
1880
1881 return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1882}
1883
1885{
1886 if(!m_xNumberingInfo.is())
1887 {
1888 Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
1889 Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
1890 const_cast<SwFieldMgr*>(this)->m_xNumberingInfo.set(xDefNum, UNO_QUERY);
1891 }
1892 return m_xNumberingInfo;
1893}
1894
1895/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static sal_uInt8 nTablePos
Definition: basesh.cxx:117
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:153
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:155
const OUString & GetFieldText(ToxAuthorityField eField) const
Definition: authfld.cxx:545
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2251
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2752
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:939
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:669
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)
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1418
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:1751
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:328
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:342
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:291
void SetModified()
Definition: edws.cxx:70
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
Definition: edfld.cxx:338
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
Definition: edfld.cxx:314
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:1856
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:1536
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:1816
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:1735
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:1833
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:1884
SAL_DLLPRIVATE LanguageType GetCurrLanguage() const
Definition: fldmgr.cxx:1747
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:242
virtual void UpdateFields()
Definition: fldbas.cxx:213
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:137
SwFieldIds Which() const
Definition: fldbas.hxx:273
static void GetFieldName_()
Sets up FieldNames; fldmgr.cxx!
Definition: fldmgr.cxx:1755
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:122
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:248
Base class of all fields.
Definition: fldbas.hxx:292
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:257
virtual OUString GetPar1() const
Definition: fldbas.cxx:321
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:504
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
virtual OUString GetPar2() const
Definition: fldbas.cxx:326
Get reference.
Definition: reffld.hxx:66
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
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:294
OUString GetContent(sal_uInt32 nFormat=0)
Definition: usrfld.cxx:278
The non-shared part of a user field.
Definition: usrfld.hxx:103
bool IsFieldName() const
Definition: viewopt.hxx:361
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2650
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:624
Definition: view.hxx:146
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:417
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:263
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:2069
bool InsertField2(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:63
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
Definition: wrtsh1.cxx:2030
const SwView & GetView() const
Definition: wrtsh.hxx:443
#define FN_NUMBER_FORMAT
Definition: cmdid.h:461
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:94
@ FF_FIXED
Definition: fldbas.hxx:162
@ FIXEDFLD
Definition: fldbas.hxx:229
@ DATEFLD
Definition: fldbas.hxx:230
@ TIMEFLD
Definition: fldbas.hxx:231
@ INP_VAR
Definition: fldbas.hxx:220
@ INP_USR
Definition: fldbas.hxx:219
SwFieldIds
Definition: fldbas.hxx:45
@ 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:241
const TranslateId FMT_DBFLD_ARY[]
Definition: fldmgr.cxx:248
const TranslateId FMT_SETVAR_ARY[]
Definition: fldmgr.cxx:254
const TranslateId FMT_MARK_ARY[]
Definition: fldmgr.cxx:217
@ GRP_WEB_DB_BEGIN
Definition: fldmgr.cxx:122
@ GRP_WEB_REG_END
Definition: fldmgr.cxx:120
@ GRP_WEB_FKT_BEGIN
Definition: fldmgr.cxx:113
@ GRP_WEB_REF_END
Definition: fldmgr.cxx:117
@ GRP_WEB_DOC_END
Definition: fldmgr.cxx:111
@ GRP_WEB_DOC_BEGIN
Definition: fldmgr.cxx:110
@ GRP_WEB_DB_END
Definition: fldmgr.cxx:123
@ GRP_WEB_VAR_END
Definition: fldmgr.cxx:126
@ GRP_WEB_FKT_END
Definition: fldmgr.cxx:114
@ GRP_WEB_REF_BEGIN
Definition: fldmgr.cxx:116
@ GRP_WEB_VAR_BEGIN
Definition: fldmgr.cxx:125
@ GRP_WEB_REG_BEGIN
Definition: fldmgr.cxx:119
const TranslateId FMT_DDE_ARY[]
Definition: fldmgr.cxx:266
const sal_uInt16 VF_USR_COUNT
Definition: fldmgr.cxx:130
const TranslateId FMT_USERVAR_ARY[]
Definition: fldmgr.cxx:278
const TranslateId FMT_AUTHOR_ARY[]
Definition: fldmgr.cxx:152
static sal_uInt16 GetPackCount()
Definition: fldmgr.cxx:365
const sal_uInt16 VF_COUNT
Definition: fldmgr.cxx:129
const TranslateId FMT_FF_ARY[]
Definition: fldmgr.cxx:183
const TranslateId FLD_EU_ARY[]
Definition: fldmgr.cxx:133
const sal_uInt16 VF_DB_COUNT
Definition: fldmgr.cxx:131
const TranslateId FLD_STAT_ARY[]
Definition: fldmgr.cxx:193
const TranslateId FMT_CHAPTER_ARY[]
Definition: fldmgr.cxx:204
const TranslateId FMT_NUM_ARY[]
Definition: fldmgr.cxx:170
const SwFieldPack aSwFields[]
Definition: fldmgr.cxx:301
@ GRP_VAR_END
Definition: fldmgr.cxx:105
@ GRP_DOC_END
Definition: fldmgr.cxx:90
@ GRP_DOC_BEGIN
Definition: fldmgr.cxx:89
@ GRP_REF_END
Definition: fldmgr.cxx:96
@ GRP_VAR_BEGIN
Definition: fldmgr.cxx:104
@ GRP_DB_BEGIN
Definition: fldmgr.cxx:101
@ GRP_REF_BEGIN
Definition: fldmgr.cxx:95
@ GRP_REG_END
Definition: fldmgr.cxx:99
@ GRP_FKT_END
Definition: fldmgr.cxx:93
@ GRP_REG_BEGIN
Definition: fldmgr.cxx:98
@ GRP_FKT_BEGIN
Definition: fldmgr.cxx:92
@ GRP_DB_END
Definition: fldmgr.cxx:102
const TranslateId FLD_PAGEREF_ARY[]
Definition: fldmgr.cxx:272
const TranslateId FMT_REF_ARY[]
Definition: fldmgr.cxx:226
const TranslateId FMT_GETVAR_ARY[]
Definition: fldmgr.cxx:260
const TranslateId FLD_TIME_ARY[]
Definition: fldmgr.cxx:164
static SwWrtShell * lcl_GetShell()
Definition: fldmgr.cxx:356
const TranslateId FLD_INPUT_ARY[]
Definition: fldmgr.cxx:212
const TranslateId FLD_DATE_ARY[]
Definition: fldmgr.cxx:158
@ 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)
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:213
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:214
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:205
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:206
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
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:116
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
#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:118
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
ResultType type
OUString sId
const SvXMLTokenMapEntry aTypes[]
SvNumFormatType