20#include <config_features.h>
21#include <config_fuzzers.h>
26#include <osl/diagnose.h>
70 std::optional<sal_Int32> oContentIdx,
71 sal_uInt16
const nPageNumber)
72 : m_nPageNumber(nPageNumber)
99 sal_uInt16
const nPageNumber)
100 : m_nPageNumber(nPageNumber)
119 sal_uInt16
const nPageNumber)
120 : m_nPageNumber(nPageNumber)
123 m_CNTNT.pBookmark = &rBookmark;
174 m_CNTNT.pFlyFormat = &rFlyFormat;
214 OSL_ENSURE(bResult,
"Where is the field?");
247 if( !pFirst || !pNext )
254 const SwNode *pFirstStt, *pNextStt;
267 if( pFirstStt != pNextStt )
269 if( pFirst->
IsTextNode() && pNext->IsTextNode() &&
287 if( pFirst != pNext )
288 return pFirst->
GetIndex() < pNext->GetIndex();
296 const SwNode* pRet =
nullptr;
301 pRet = &
m_CNTNT.pTextField->GetTextNode();
305 pRet = &
m_CNTNT.pTextINet->GetTextNode();
309 pRet =
m_CNTNT.pSection->GetFormat()->GetSectionNode();
313 pRet = &
m_CNTNT.pBookmark->GetMarkStart().GetNode();
317 pRet = &
m_CNTNT.pPos->GetNode();
321 pRet = &
m_CNTNT.pTextTOX->GetTextNode();
325 if(
m_CNTNT.pTBox->GetSttNd() )
349 nRet =
m_CNTNT.pTextField->GetStart();
352 nRet =
m_CNTNT.pTextINet->GetStart();
355 nRet =
m_CNTNT.pTextTOX->GetStart();
358 nRet =
m_CNTNT.pBookmark->GetMarkStart().GetContentIndex();
361 nRet =
m_CNTNT.pPos->GetContentIndex();
371 :
SwHash( rName ), aSetStr(
std::move( aText ))
388#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
404 std::vector<SwFormatField*> vFields;
405 pFieldType->GatherFields(vFields);
428#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
435#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
438static OUString lcl_DBDataToString(
const SwDBData& rData)
448 const std::vector<OUString>* pAllDBNames )
450#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
454 std::vector<OUString> aUsedDBNames;
455 std::vector<OUString> aAllDBNames;
460 pAllDBNames = &aAllDBNames;
464 for (
auto n = rArr.
size();
n; )
472 aUsedDBNames.clear();
496 lcl_DBDataToString(
static_cast<const SwDBNameInfField*
>(pField)->GetRealDBData() ));
502 lcl_DBDataToString(
static_cast<const SwDBNameInfField*
>(pField)->GetRealDBData() ));
508 pField->
GetPar1(), aUsedDBNames ));
509 aUsedDBNames.clear();
517 aUsedDBNames.clear();
528#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
534 for (
const auto& pParam : rArr)
536 rAllDBNames.emplace_back(pParam->sDataSource + OUStringChar(
DB_DELIM) + pParam->sCommand);
542 const OUString& rFormula,
543 std::vector<OUString>& rUsedDBNames )
552 for (
const auto &sItem : rAllDBNames)
560 nPos += sItem.getLength() + 1;
572 const std::vector<OUString>& rUsedDBNames )
574 for (
const auto &
sName : rUsedDBNames )
580#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
584 if( rDBName.isEmpty() )
588 for(
const auto &
sName : rDBNameList )
593 for(
const auto &
sName : rDBNameList )
594 if( rSCmp.isEqual( rDBName,
sName.getToken(0,
';') ) )
602 aData.nCommandType = -1;
604 rDBNameList.push_back(rDBName);
609 const OUString& rNewName )
611#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
622 for (
auto n = rArr.
size();
n; )
642 bool bExpand =
false;
647#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
658 static_cast<SwDBField*
>(pField)->ClearInitialized();
659 static_cast<SwDBField*
>(pField)->InitContent();
710OUString lcl_CutOffDBCommandType(
const OUString& rName)
712 return rName.replaceFirst(OUStringChar(
DB_DELIM),
".").getToken(0,
DB_DELIM);
718 const OUString& rNewName,
const OUString& rFormula )
721 const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
724 for(
const auto & rUsedDBName : rUsedDBNames)
726 const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBName) );
728 if (sDBName!=sNewName)
746 nPos += sNewName.getLength();
757 for(
const auto &
sName : rArr )
762 for(
const auto &
sName : rArr )
763 if( rSCmp.isEqual( rName,
sName ))
846 std::vector<std::reference_wrapper<SwSection>> aUnhiddenSections;
866 std::vector<SwNodeOffset> aTmpArr;
867 std::vector<SwNodeOffset>::size_type nArrStt = 0;
881 aTmpArr.push_back( nIdx );
882 if( nIdx < nSttContent )
886 std::sort(aTmpArr.begin(), aTmpArr.end());
890 for (std::vector<sal_uLong>::size_type
n = nArrStt;
n < aTmpArr.size(); ++
n)
892 pSectNd = rDoc.
GetNodes()[ aTmpArr[
n ] ]->GetSectionNode();
893 OSL_ENSURE( pSectNd,
"Where is my SectionNode" );
897 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
899 aUnhiddenSections.push_back(std::ref(rSection));
903 for (std::vector<sal_uLong>::size_type
n = 0;
n < nArrStt; ++
n)
905 pSectNd = rDoc.
GetNodes()[ aTmpArr[
n ] ]->GetSectionNode();
906 OSL_ENSURE( pSectNd,
"Where is my SectionNode" );
910 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
912 aUnhiddenSections.push_back(std::ref(rSection));
918 for (
const auto &
nId : aTmpArr)
926 for (
auto it = rIDMA.getBookmarksBegin(); it != rIDMA.getBookmarksEnd(); ++it)
930 if (!pBookmark->GetHideCondition().isEmpty())
937 static constexpr OUStringLiteral sTrue(
u"TRUE");
938 static constexpr OUStringLiteral sFalse(
u"FALSE");
940#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
990 const_cast<SwFormatField*
>(pFormatField)->ForceUpdateTextNode();
1010 const_cast<SwFormatField*
>(pFormatField)->ForceUpdateTextNode();
1014#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1057 for (
auto& rSectionWrapper : aUnhiddenSections)
1059 auto& rSection = rSectionWrapper.
get();
1060 rSection.SetCondHidden(
true);
1071 std::pair<Point, bool>
const tmp(aPt,
false);
1077 std::unique_ptr<SetGetExpField> pNew;
1078 bool bIsInBody =
false;
1088 if (pFrame ==
nullptr && bIsInBody)
1093 if( (pFrame !=
nullptr) || bIsInBody )
1104 OSL_ENSURE(bResult,
"where is the Field");
1115#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1122 if( pNew !=
nullptr )
1130 std::unique_ptr<SetGetExpField> pNew;
1148 std::pair<Point, bool>
const tmp(aPt,
false);
1156 OSL_ENSURE(bResult,
"where is the Field");
1174 OUString sFieldName;
1175 switch( rType.
Which() )
1184 OSL_ENSURE(
false,
"No valid field type" );
1187 if( sFieldName.isEmpty() )
1207 OUString sFieldName;
1208 switch( rType.
Which() )
1219 if( sFieldName.isEmpty() )
1238 while( pPrev->
pNext.get() != pFnd )
1239 pPrev = pPrev->
pNext.get();
1246 : m_FieldTypeTable(
TBLSZ)
1248 , m_nFieldListGetMode(0)
1250 , m_bInUpdateFields(false)
1251 , m_bFieldsDirty(false)
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
virtual const SwFieldTypes * GetFieldTypes() const =0
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual void SetModified()=0
Must be called manually at changes of format.
SetGetExpField(const SwNode &rNd, const SwTextField *pField=nullptr, std::optional< sal_Int32 > oContentIdx=std::nullopt, sal_uInt16 nPageNumber=0)
sal_Int32 GetCntPosFromContent() const
bool operator<(const SetGetExpField &rField) const
const SwNode * GetNodeFromContent() const
void SetBodyPos(const SwContentFrame &rFrame)
void GetPosOfContent(SwPosition &rPos) const
union SetGetExpField::@4 m_CNTNT
enum SetGetExpField::SetGetExpFieldType m_eSetGetExpFieldType
const SwTextField * pTextField
bool operator==(const SetGetExpField &rField) const
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
const OUString & GetColumnName() const
void ChgBodyTextFlag(bool bIsInBody)
set from UpdateExpFields (the Node-Position is known there)
void CreateDSData(const SwDBData &rData)
static const SwDBData & GetAddressDBName()
const SwDSParams_t & GetDSParamArray() const
bool OpenDataSource(const OUString &rDataSource, const OUString &rTableOrQuery)
open the source while fields are updated - for the calculator only!
void SetInitDBFields(bool b)
const SwDBData & GetRealDBData() const
DBName.
void MakeFieldList(SwDoc &rDoc, bool bAll, int eGetMode)
SwHashTable< SwCalcFieldType > m_FieldTypeTable
SwDocUpdateField(SwDoc &rDocument)
void MakeFieldList_(SwDoc &pDoc, int eGetMode)
void InsDelFieldInFieldLst(bool bIns, const SwTextField &rField)
void SetFieldsDirty(bool b)
SwHashTable< SwCalcFieldType > const & GetFieldTypeTable() const
void GetBodyNode(const SwTextField &, SwFieldIds nFieldWhich)
void InsertFieldType(const SwFieldType &rType)
std::unique_ptr< SetGetExpFields > m_pFieldSortList
current field list for calculation
SwNodeOffset m_nNodes
to check if the node count changed
void RemoveFieldType(const SwFieldType &rType)
void GetBodyNodeGeneric(SwNode const &rNode, T const &)
SwDBData const & GetDBData()
SwSectionFormats & GetSections()
void ChangeAuthorityData(const SwAuthEntry *pNewData)
IDocumentState const & getIDocumentState() const
bool IsUsed(const sw::BroadcastingModify &) const
SwDBManager * GetDBManager() const
void AddUsedDBToList(std::vector< OUString > &rDBNameList, const std::vector< OUString > &rUsedDBNames)
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
static OUString ReplaceUsedDBs(const std::vector< OUString > &rUsedDBNames, const OUString &rNewName, const OUString &rFormula)
static bool IsNameInArray(const std::vector< OUString > &rOldNames, const OUString &rName)
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentMarkAccess * getIDocumentMarkAccess()
void SetInitDBFields(bool b)
const SwAttrPool & GetAttrPool() const
void GetAllDBNames(std::vector< OUString > &rAllDBNames)
void GetAllUsedDB(std::vector< OUString > &rDBNameList, const std::vector< OUString > *pAllDBNames=nullptr)
static std::vector< OUString > & FindUsedDBs(const std::vector< OUString > &rAllDBNames, const OUString &rFormula, std::vector< OUString > &rUsedDBNames)
void ChangeDBFields(const std::vector< OUString > &rOldNames, const OUString &rNewName)
Instances of SwFields and those derived from it occur 0 to n times.
Base class of all fields.
virtual OUString GetFormula() const
virtual OUString GetPar1() const
virtual void SetPar1(const OUString &rStr)
virtual void SetPar2(const OUString &rStr)
virtual sal_uInt16 GetSubType() const
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
SwFieldType * GetTyp() const
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
Base class of the Writer layout elements.
sal_uInt16 GetPhyPageNum() const
void ChgBodyTextFlag(bool bIsInBody)
Set by UpdateExpFields where node position is known.
T should be a subclass of SwHash.
T * Find(std::u16string_view aStr, sal_uInt32 *pPos=nullptr) const
void SetHidden(bool bHidden)
void Evaluate(SwDoc &rDoc)
get current field value and cache it
void SetValue(bool bHidden)
const SwContentNode * GetNode() const
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
const SwStartNode * FindFlyStartNode() const
bool IsSectionNode() const
SwTableNode * FindTableNode()
Search table node, in which it is.
const SwStartNode * StartOfSectionNode() const
SwContentNode * GetContentNode()
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
SwContentNode * GoNext(SwNodeIndex *) const
SwNode & GetEndOfPostIts() const
A still empty section.
SwDoc & GetDoc()
Which Doc contains the nodes-array?
SwNodeOffset Count() const
A section node represents the start of a section on the UI, i.e.
const SwSection & GetSection() const
OUString const & GetCondition() const
void SetCondHidden(bool const bFlag)
SwSectionFormat * GetFormat()
void SetCondition(OUString const &rNew)
SwTableBox is one table cell in the document model.
const SwStartNode * GetSttNd() const
sal_Int32 GetStart() const
const SwFormatField & GetFormatField() const
SwTextNode & GetTextNode() const
void ExpandTextField(const bool bForceNotify=false) const
Represents the visualization of a paragraph.
SwTextNode * GetTextNodeFirst()
SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
SwTextNode is a paragraph in the document model.
The shared part of a user field.
std::vector< SwSectionFormat * >::size_type size_type
std::vector< Value >::size_type size_type
virtual const SwPosition & GetMarkStart() const =0
std::vector< std::unique_ptr< SwDSParam > > SwDSParams_t
virtual OUString GetName() const override
virtual void SetValue(tools::Long nNew) override
OUString LookString(SwHashTable< HashStr > const &rTable, const OUString &rName)
Look up the Name, if it is present, return its String, otherwise return an empty String.
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
@ Database
For old documents the Field-Which IDs must be preserved !!!
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
CharClass & GetAppCharClass()
constexpr OUStringLiteral aData
OString strip(const OString &rIn, char c)
const SwGetSetExpType GSE_STRING
String.
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)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SwFrame const * FindNeighbourFrameForNode(SwNode const &rNode)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
bool IsFrameBehind(const SwTextNode &rMyNd, sal_Int32 nMySttPos, const SwTextNode &rBehindNd, sal_Int32 nSttPos)
HashStr(const OUString &rName, OUString aText, HashStr *)
std::unique_ptr< SwHash > pNext
Marks a position in the document model.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
UNDERLYING_TYPE get() const