20#include <config_features.h>
21#include <config_fuzzers.h>
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>
40#include <osl/diagnose.h>
211 FMT_CHAPTER_NO_NOSEPARATOR
239 FMT_REF_NUMBER_NO_CONTEXT,
240 FMT_REF_NUMBER_FULL_CONTEXT
294 size_t nSubTypeLength;
297 size_t nFormatLength;
361 return pView->GetWrtShellPtr();
385 OSL_ENSURE(pSh,
"no SwWrtShell found");
391 if( 1 < nCnt && !pSh->SwCursorShell::HasSelection() )
394 bRet = 2 > nCnt &&
nullptr == pSh->
GetRefMark( rStr );
403 OSL_ENSURE(pSh,
"no SwWrtShell found");
411 OSL_ENSURE(pSh,
"no SwWrtShell found");
418 OSL_ENSURE(pSh,
"no SwWrtShell found");
419 return pSh ? pSh->
GetFieldType(nField, nResId) :
nullptr;
425 OSL_ENSURE(pSh,
"no SwWrtShell found");
426 return pSh ? pSh->
GetFieldType(nResId, rName) :
nullptr;
492 return aWebRanges[nGrpId];
494 return aRanges[nGrpId];
541 static OUString g_aDate(
SwResId( STR_DATEFLD ) );
546 static OUString g_aTime(
SwResId( STR_TIMEFLD ) );
576 OSL_ENSURE(pSh,
"no SwWrtShell found");
632 rToFill.push_back(pFieldType->
GetName());
646 if(
nPos != USHRT_MAX)
660 sNew =
SwResId(STR_CUSTOM_FIELD);
667 rToFill.push_back(sNew);
709 [](sal_Int16 nCurrent) { return nCurrent > NumberingType::CHARS_LOWER_LETTER_N; });
724 if (
nPos == USHRT_MAX)
732 nFormatId &= ~static_cast<sal_uInt32>(
FF_FIXED);
735 return SwResId(pStart[nFormatId]);
744 sal_uInt32 nValidEntry = 0;
745 for (
const sal_Int16 nCurrent :
aTypes)
747 if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
748 (nCurrent != (NumberingType::BITMAP |
LINK_TOKEN)))
750 if (nValidEntry == nFormatId - nOffset)
775 sal_uInt16
nId = o3tl::narrowing<sal_uInt16>(nFormatId);
781 if (
sId == FMT_REG_AUTHOR)
783 else if (
sId == FMT_REG_TIME)
785 else if (
sId == FMT_REG_DATE)
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)
824 sal_Int32 nValidEntry = 0;
825 for (
const sal_Int16 nCurrent :
aTypes)
827 if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
829 if (nValidEntry ==
static_cast<sal_Int32
>(nFormatId) - nOffset)
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);
883 OSL_ENSURE(pSh,
"no SwWrtShell found");
898 std::unique_ptr<SwField> pField;
901 bool bPageVar =
false;
908 OSL_ENSURE(pCurShell,
"no SwWrtShell found");
967 pField->SetPar2(rData.
m_sPar2);
989 sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rData.
m_sPar2.toInt32());
993 nByte = std::max(sal_uInt16(1), nByte);
1004 short nOff =
static_cast<short>(rData.
m_sPar2.toInt32());
1074 const OUString& rRefmarkText = rData.
m_sPar2;
1077 if (!rRefmarkText.isEmpty())
1089 *pCurShell, pCursorPos, rRefmarkText.toUtf8());
1097 *pCursorPos = aRefmarkPam;
1103 if (!rRefmarkText.isEmpty())
1117 sal_uInt16 nSeqNo = o3tl::narrowing<sal_uInt16>(rData.
m_sPar2.toInt32());
1118 OUString sReferenceLanguage;
1126 sReferenceLanguage =
"Hu";
1128 sReferenceLanguage =
"hu";
1132 pField.reset(
new SwGetRefField(pTyp, rData.
m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1197#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1208 sal_Int32 nIdx{ 0 };
1221 pField->SetSubType(nSubType);
1241 pField->ChangeFormat( nFormatId );
1253#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1258 sal_Int32 nExpPos = -1;
1339 pField.reset(
new SwUserField(pTyp, 0, nFormatId));
1340 if (pField->GetSubType() != nSubType)
1341 pField->SetSubType(nSubType);
1348 if ((nSubType & 0x00ff) ==
INP_VAR)
1356 std::unique_ptr<SwSetExpField> pExpField(
1360 sal_uInt16 nOldSubType = pExpField->GetSubType();
1361 pExpField->SetSubType(nOldSubType | (nSubType & 0xff00));
1363 pExpField->SetPromptText(rData.
m_sPar2);
1364 pExpField->SetInputFlag(
true) ;
1366 pField = std::move(pExpField);
1391 pExpField->SetSubType(nSubType);
1392 pExpField->SetPar2(rData.
m_sPar2);
1394 pField = std::move(pExpField);
1406 if (nLevel != 0x7f && cSeparator == 0)
1426 pField->SetSubType(nSubType | pSetTyp->
GetType());
1472 pField->SetSubType(nSubType);
1480 static_cast<short>(rData.
m_sPar2.toInt32()), 0 != nSubType ) );
1494 OUString* pArray =
aEntries.getArray();
1509 { OSL_ENSURE(
false,
"wrong field type");
1513 OSL_ENSURE(pField,
"field not available");
1518 pField->SetLanguage(
nLang);
1570 const OUString& rPar1,
1571 const OUString& rPar2,
1572 std::unique_ptr<SwField> pTmpField)
1584 OSL_ENSURE(pSh,
"no SwWrtShell found");
1589 bool bSetPar2 =
true;
1590 bool bSetPar1 =
true;
1591 OUString sPar2( rPar2 );
1611 sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rPar2.toInt32());
1612 nByte = std::max(sal_uInt16(1), nByte);
1621 static_cast<SwScriptField*
>(pTmpField.get())->SetCodeURL(
static_cast<bool>(nFormat));
1634 short nOff =
static_cast<short>(sPar2.toInt32());
1636 sPar2 = OUString::number(nOff);
1650 short nOff =
static_cast<short>(sPar2.toInt32());
1652 sPar2 = OUString::number(nOff);
1665 static_cast<SwGetRefField*
>(pTmpField.get())->SetSubType( o3tl::narrowing<sal_uInt16>(rPar2.toInt32()) );
1666 const sal_Int32
nPos = rPar2.indexOf(
'|' );
1675 OUString* pArray =
aEntries.getArray();
1680 bSetPar1 = bSetPar2 =
false;
1695 bool bEquivalent =
true;
1705 bEquivalent =
false;
1713 bEquivalent =
false;
1741 pTmpField->ChangeFormat(nFormat);
1744 pTmpField->SetPar1( rPar1 );
1746 pTmpField->SetPar2( sPar2 );
1758 pSh->SwEditShell::UpdateOneField(*pTmpField);
1836 STR_PARAGRAPH_SIGNATURE
1844 const OUString aTmp(
SwResId(
id));
1857 if ( !aScriptURL.isEmpty() )
1875 ::comphelper::getProcessComponentContext();
1878 xFactory = uri::UriReferenceFactory::create( xContext );
1905 nDefFormat = SvNumFormatType::TEXT;
1909 nDefFormat = SvNumFormatType::ALL;
static sal_uInt8 nTablePos
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
const LanguageTag & GetLanguageTag() const
static sal_uInt32 FindIndex(int nValue)
static OUString GetString(sal_uInt32 i)
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
Represents an inserted bibliography entry, created using Insert -> Table of Contents and Index -> Bib...
const OUString & GetFieldText(ToxAuthorityField eField) const
void Push()
store a copy of the current cursor on the cursor stack
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
void EndAction(const bool bIdleEnd=false)
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
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
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
void UpdateTable()
update fields of a listing
void StartAllAction()
For all views of this document.
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
void SignParagraph()
Sign the paragraph at the cursor.
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
void RemoveFieldType(size_t nField)
delete field type
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
bool InsertURL(const SwFormatINetFormat &rFormat, const OUString &rStr, bool bKeepSelection=false)
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
void UpdateOneField(SwField &)
One single field.
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
get the names of all references in a Doc
SwDBData const & GetDBData() const
Database information.
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
LanguageType GetCurLang() const
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
get the reference of a given name in the Doc
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter *pFormatter)
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
void InsertFieldType(SwFieldType const &rType)
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
bool ChooseMacro(weld::Window *pDialogParent)
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
static const OUString & GetTypeStr(sal_uInt16 nPos)
SwFieldTypesEnum GetCurTypeId() const
bool CanInsertRefMark(std::u16string_view rStr)
void EvalExpFields(SwWrtShell *pSh)
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
bool GoNextPrev(bool bNext=true, SwFieldType *pTyp=nullptr)
size_t GetFieldTypeCount() const
void SetMacroPath(const OUString &rPath)
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
void RemoveFieldType(SwFieldIds nResId, const OUString &rName)
bool InsertField(SwInsertField_Data &rData)
OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
SAL_DLLPRIVATE css::uno::Reference< css::text::XNumberingTypeInfo > const & GetNumberingInfo() const
SAL_DLLPRIVATE LanguageType GetCurrLanguage() const
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
SwFieldMgr(SwWrtShell *pSh=nullptr)
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType)
Instances of SwFields and those derived from it occur 0 to n times.
virtual void UpdateFields()
virtual OUString GetName() const
Only in derived classes.
static void GetFieldName_()
Sets up FieldNames; fldmgr.cxx!
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
static std::vector< OUString > * s_pFieldNames
field names
Base class of all fields.
SwFieldTypesEnum GetTypeId() const
virtual OUString GetPar1() const
std::unique_ptr< SwField > CopyField() const
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
SwFieldType * GetTyp() const
virtual OUString GetPar2() const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * GetPoint() const
sal_uInt16 GetType() const
void SetOutlineLvl(sal_uInt8 n)
void SetDelimiter(const OUString &s)
The shared part of a user field.
OUString GetContent(sal_uInt32 nFormat=0) const
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
The non-shared part of a user field.
const SwViewOption * GetViewOptions() const
static ShellResource * GetShellRes()
const SfxItemPool & GetAttrPool() const
Used by the UI to modify the document model.
bool Right(SwCursorSkipMode nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
bool StartInputFieldDlg(SwField *, bool bPrevButton, bool bNextButton, weld::Widget *pParentWin, FieldDialogPressedButton *pPressedButton=nullptr)
bool Left(SwCursorSkipMode nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
void ChgDBData(const SwDBData &SwDBData)
bool InsertField2(SwField const &, SwPaM *pAnnotationRange=nullptr)
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
const SwView & GetView() const
ScXMLEditAttributeMap::Entry const aEntries[]
Reference< XSingleServiceFactory > xFactory
SwFieldTypesEnum
List of FieldTypes at UI.
@ Database
For old documents the Field-Which IDs must be preserved !!!
const TranslateId FMT_REG_ARY[]
const TranslateId FMT_DBFLD_ARY[]
const TranslateId FMT_SETVAR_ARY[]
const TranslateId FMT_MARK_ARY[]
const TranslateId FMT_DDE_ARY[]
const sal_uInt16 VF_USR_COUNT
const TranslateId FMT_USERVAR_ARY[]
const TranslateId FMT_AUTHOR_ARY[]
static sal_uInt16 GetPackCount()
const sal_uInt16 VF_COUNT
const TranslateId FMT_FF_ARY[]
const TranslateId FLD_EU_ARY[]
const sal_uInt16 VF_DB_COUNT
const TranslateId FLD_STAT_ARY[]
const TranslateId FMT_CHAPTER_ARY[]
const TranslateId FMT_NUM_ARY[]
const SwFieldPack aSwFields[]
const TranslateId FLD_PAGEREF_ARY[]
const TranslateId FMT_REF_ARY[]
const TranslateId FMT_GETVAR_ARY[]
const TranslateId FLD_TIME_ARY[]
static SwWrtShell * lcl_GetShell()
const TranslateId FLD_INPUT_ARY[]
const TranslateId FLD_DATE_ARY[]
#define LANGUAGE_HUNGARIAN
#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)
const SwDocInfoSubType DI_SUB_AUTHOR
const SwDocInfoSubType DI_CUSTOM
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
const SwDocInfoSubType DI_SUBTYPE_END
const SwDocInfoSubType DI_SUB_DATE
const SwDocInfoSubType DI_SUB_TIME
const SwExtendedSubType SUB_INVISIBLE
Invisible.
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
const SwGetSetExpType GSE_SEQ
Sequence.
const SwGetSetExpType GSE_FORMULA
Formula.
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
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
#define RESARRAY_INDEX_NOTFOUND
static LanguageType nLang
std::vector< OUString > aDocInfoLst
bool m_bIsAutomaticLanguage
css::uno::Any m_aDBColumn
std::optional< SwPaM > m_oAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
css::uno::Any m_aDBDataSource
SwFieldTypesEnum m_nTypeId
css::uno::Any m_aDBConnection
static OUString GetSourceURL(const OUString &rText)
Gets the URL of the underlying SwAuthEntry, ignoring its page number.
SVX_NUM_CHARS_LOWER_LETTER_N
SVX_NUM_CHARS_LOWER_LETTER
SVX_NUM_CHARS_UPPER_LETTER
SVX_NUM_CHARS_UPPER_LETTER_N
OUString SwResId(TranslateId aId)
constexpr sal_uInt8 MAXLEVEL
#define TOX_STYLE_DELIMITER