LibreOffice Module sw (master) 1
docfld.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 <hintids.hxx>
24
25#include <comphelper/string.hxx>
26#include <osl/diagnose.h>
28#ifndef UNX
30#endif
31#include <o3tl/string_view.hxx>
32#include <doc.hxx>
35#include <IDocumentState.hxx>
37#include <node2lay.hxx>
38#include <cntfrm.hxx>
39#include <pagefrm.hxx>
40#include <txtfrm.hxx>
41#include <notxtfrm.hxx>
42#include <pam.hxx>
43#include <ndtxt.hxx>
44#include <swtable.hxx>
45#include <calc.hxx>
46#include <txtfld.hxx>
47#include <fmtfld.hxx>
48#include <txttxmrk.hxx>
49#include <docfld.hxx>
50#include <docufld.hxx>
51#include <usrfld.hxx>
52#include <expfld.hxx>
53#include <dbfld.hxx>
54#include <reffld.hxx>
55#include <dbmgr.hxx>
56#include <section.hxx>
57#include <docary.hxx>
58#include <authfld.hxx>
59#include <txtinet.hxx>
60#include <fmtcntnt.hxx>
61#include <utility>
62
63using namespace ::com::sun::star::uno;
64
65// the StartIndex can be supplied optionally (e.g. if it was queried before - is a virtual
66// method otherwise!)
68 const SwNode& rNdIdx,
69 const SwTextField* pField,
70 std::optional<sal_Int32> oContentIdx,
71 sal_uInt16 const nPageNumber)
72 : m_nPageNumber(nPageNumber)
73{
75 m_CNTNT.pTextField = pField;
76 m_nNode = rNdIdx.GetIndex();
77 if( oContentIdx )
78 m_nContent = *oContentIdx;
79 else if( pField )
80 m_nContent = pField->GetStart();
81 else
82 m_nContent = 0;
83}
84
86 const SwTextINetFormat& rINet )
87{
89 m_CNTNT.pTextINet = &rINet;
90 m_nNode = rNdIdx.GetIndex();
91 m_nContent = rINet.GetStart();
92}
93
94// Extension for Sections:
95// these always have content position 0xffffffff!
96// There is never a field on this, only up to COMPLETE_STRING possible
98 const SwPosition* pPos,
99 sal_uInt16 const nPageNumber)
100 : m_nPageNumber(nPageNumber)
101{
103 m_CNTNT.pSection = &rSectNd.GetSection();
104
105 if( pPos )
106 {
109 }
110 else
111 {
112 m_nNode = rSectNd.GetIndex();
113 m_nContent = 0;
114 }
115}
116
118 SwPosition const*const pPos,
119 sal_uInt16 const nPageNumber)
120 : m_nPageNumber(nPageNumber)
121{
123 m_CNTNT.pBookmark = &rBookmark;
124
125 if (pPos)
126 {
129 }
130 else
131 {
132 m_nNode = rBookmark.GetMarkStart().GetNodeIndex();
133 m_nContent = rBookmark.GetMarkStart().GetContentIndex();;
134 }
135}
136
138{
140 m_CNTNT.pTBox = &rTBox;
141
143 m_nContent = 0;
144 if( rTBox.GetSttNd() )
145 {
146 SwNodeIndex aIdx( *rTBox.GetSttNd() );
147 const SwContentNode* pNd = aIdx.GetNode().GetNodes().GoNext( &aIdx );
148 if( pNd )
149 m_nNode = pNd->GetIndex();
150 }
151}
152
154 const SwTextTOXMark& rTOX )
155{
157 m_CNTNT.pTextTOX = &rTOX;
158 m_nNode = rNdIdx.GetIndex();
159 m_nContent = rTOX.GetStart();
160}
161
163{
165 m_CNTNT.pPos = &rPos;
166 m_nNode = rPos.GetNodeIndex();
168}
169
171 const SwPosition* pPos )
172{
174 m_CNTNT.pFlyFormat = &rFlyFormat;
175 if( pPos )
176 {
179 }
180 else
181 {
182 const SwFormatContent& rContent = rFlyFormat.GetContent();
183 m_nNode = rContent.GetContentIdx()->GetIndex() + 1;
184 m_nContent = 0;
185 }
186}
187
189{
190 const SwNode* pNd = GetNodeFromContent();
191 if( pNd )
192 pNd = pNd->GetContentNode();
193
194 if( pNd )
195 {
196 rPos.Assign( *static_cast<const SwContentNode*>(pNd), GetCntPosFromContent() );
197 }
198 else
199 {
200 rPos.Assign( m_nNode, m_nContent );
201 }
202}
203
205{
206 if( !rFrame.IsInDocBody() )
207 {
208 SwNodeIndex aIdx( rFrame.IsTextFrame()
209 ? *static_cast<SwTextFrame const&>(rFrame).GetTextNodeFirst()
210 : *static_cast<SwNoTextFrame const&>(rFrame).GetNode() );
211 SwDoc& rDoc = aIdx.GetNodes().GetDoc();
212 SwPosition aPos( aIdx );
213 bool const bResult = ::GetBodyTextNode( rDoc, aPos, rFrame );
214 OSL_ENSURE(bResult, "Where is the field?");
215 m_nNode = aPos.GetNodeIndex();
217 }
218}
219
221{
222 return m_nNode == rField.m_nNode
223 && m_nContent == rField.m_nContent
224 && ( !m_CNTNT.pTextField
225 || !rField.m_CNTNT.pTextField
226 || m_CNTNT.pTextField == rField.m_CNTNT.pTextField );
227}
228
229bool SetGetExpField::operator<( const SetGetExpField& rField ) const
230{
231 if (m_nPageNumber != rField.m_nPageNumber)
232 {
233 // sort "invalid" page nums of 0 after valid page nums of non 0
234 if (m_nPageNumber == 0 || rField.m_nPageNumber == 0)
235 return m_nPageNumber != 0;
236 return m_nPageNumber < rField.m_nPageNumber;
237 }
238 if( m_nNode < rField.m_nNode || ( m_nNode == rField.m_nNode && m_nContent < rField.m_nContent ))
239 return true;
240 else if( m_nNode != rField.m_nNode || m_nContent != rField.m_nContent )
241 return false;
242
243 const SwNode *pFirst = GetNodeFromContent(),
244 *pNext = rField.GetNodeFromContent();
245
246 // Position is the same: continue only if both field pointers are set!
247 if( !pFirst || !pNext )
248 return false;
249
250 // same Section?
251 if( pFirst->StartOfSectionNode() != pNext->StartOfSectionNode() )
252 {
253 // is one in the table?
254 const SwNode *pFirstStt, *pNextStt;
255 const SwTableNode* pTableNd = pFirst->FindTableNode();
256 if( pTableNd )
257 pFirstStt = pTableNd->StartOfSectionNode();
258 else
259 pFirstStt = pFirst->StartOfSectionNode();
260
261 pTableNd = pNext->FindTableNode();
262 if( pTableNd )
263 pNextStt = pTableNd->StartOfSectionNode();
264 else
265 pNextStt = pNext->StartOfSectionNode();
266
267 if( pFirstStt != pNextStt )
268 {
269 if( pFirst->IsTextNode() && pNext->IsTextNode() &&
270 ( pFirst->FindFlyStartNode() || pNext->FindFlyStartNode() ))
271 {
272 // FIXME: in NewFieldPortion(), SwGetExpField are expanded via
273 // DocumentFieldsManager::FieldsToExpand() calling
274 // std::upper_bound binary search function - the sort order
275 // depends on the fly positions in the layout, but the fly
276 // positions depend on the expansion of the SwGetExpField!
277 // This circular dep will cause trouble, it would be better to
278 // use only model positions (anchor), but then how to compare
279 // at-page anchored flys which don't have a model anchor?
280 return ::IsFrameBehind( *pNext->GetTextNode(), m_nContent, *pFirst->GetTextNode(), m_nContent );
281 }
282 return pFirstStt->GetIndex() < pNextStt->GetIndex();
283 }
284 }
285
286 // same Section: is the field in the same Node?
287 if( pFirst != pNext )
288 return pFirst->GetIndex() < pNext->GetIndex();
289
290 // same Node in the Section, check Position in the Node
291 return GetCntPosFromContent() < rField.GetCntPosFromContent();
292}
293
295{
296 const SwNode* pRet = nullptr;
297 if( m_CNTNT.pTextField )
298 switch( m_eSetGetExpFieldType )
299 {
300 case TEXTFIELD:
301 pRet = &m_CNTNT.pTextField->GetTextNode();
302 break;
303
304 case TEXTINET:
305 pRet = &m_CNTNT.pTextINet->GetTextNode();
306 break;
307
308 case SECTIONNODE:
309 pRet = m_CNTNT.pSection->GetFormat()->GetSectionNode();
310 break;
311
312 case BOOKMARK:
313 pRet = &m_CNTNT.pBookmark->GetMarkStart().GetNode();
314 break;
315
316 case CRSRPOS:
317 pRet = &m_CNTNT.pPos->GetNode();
318 break;
319
320 case TEXTTOXMARK:
321 pRet = &m_CNTNT.pTextTOX->GetTextNode();
322 break;
323
324 case TABLEBOX:
325 if( m_CNTNT.pTBox->GetSttNd() )
326 {
327 SwNodeIndex aIdx( *m_CNTNT.pTBox->GetSttNd() );
328 pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx );
329 }
330 break;
331
332 case FLYFRAME:
333 {
334 SwNodeIndex aIdx( *m_CNTNT.pFlyFormat->GetContent().GetContentIdx() );
335 pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx );
336 }
337 break;
338 }
339 return pRet;
340}
341
343{
344 sal_Int32 nRet = 0;
345 if( m_CNTNT.pTextField )
346 switch( m_eSetGetExpFieldType )
347 {
348 case TEXTFIELD:
349 nRet = m_CNTNT.pTextField->GetStart();
350 break;
351 case TEXTINET:
352 nRet = m_CNTNT.pTextINet->GetStart();
353 break;
354 case TEXTTOXMARK:
355 nRet = m_CNTNT.pTextTOX->GetStart();
356 break;
357 case BOOKMARK:
358 nRet = m_CNTNT.pBookmark->GetMarkStart().GetContentIndex();
359 break;
360 case CRSRPOS:
361 nRet = m_CNTNT.pPos->GetContentIndex();
362 break;
363 default:
364 break;
365 }
366 return nRet;
367}
368
369HashStr::HashStr( const OUString& rName, OUString aText,
370 HashStr* pNxt )
371 : SwHash( rName ), aSetStr(std::move( aText ))
372{
373 pNext.reset( pNxt );
374}
375
377OUString LookString( SwHashTable<HashStr> const & rTable, const OUString& rName )
378{
379 HashStr* pFnd = rTable.Find( comphelper::string::strip(rName, ' ') );
380 if( pFnd )
381 return pFnd->aSetStr;
382
383 return OUString();
384}
385
387{
388#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
389 if(maDBData.sDataSource.isEmpty())
390 {
391 // Similar to: SwEditShell::IsAnyDatabaseFieldInDoc
392 for (const auto& pFieldType : *getIDocumentFieldsAccess().GetFieldTypes())
393 {
394 if (IsUsed(*pFieldType))
395 {
396 SwFieldIds nWhich = pFieldType->Which();
397 switch(nWhich)
398 {
403 {
404 std::vector<SwFormatField*> vFields;
405 pFieldType->GatherFields(vFields);
406 if(vFields.size())
407 {
408 if(SwFieldIds::Database == nWhich)
409 maDBData = static_cast<SwDBFieldType*>(vFields.front()->GetField()->GetTyp())->GetDBData();
410 else
411 maDBData = static_cast<SwDBNameInfField*> (vFields.front()->GetField())->GetRealDBData();
412 }
413 }
414 break;
415 default: break;
416 }
417 }
418 }
419 }
420 if(maDBData.sDataSource.isEmpty())
422#endif
423 return maDBData;
424}
425
427{
428#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
429 (void) b;
430#else
432#endif
433}
434
435#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
436
438static OUString lcl_DBDataToString(const SwDBData& rData)
439{
440 return rData.sDataSource + OUStringChar(DB_DELIM)
441 + rData.sCommand + OUStringChar(DB_DELIM)
442 + OUString::number(rData.nCommandType);
443}
444
445#endif
446
447void SwDoc::GetAllUsedDB( std::vector<OUString>& rDBNameList,
448 const std::vector<OUString>* pAllDBNames )
449{
450#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
451 (void) rDBNameList;
452 (void) pAllDBNames;
453#else
454 std::vector<OUString> aUsedDBNames;
455 std::vector<OUString> aAllDBNames;
456
457 if( !pAllDBNames )
458 {
459 GetAllDBNames( aAllDBNames );
460 pAllDBNames = &aAllDBNames;
461 }
462
464 for (auto n = rArr.size(); n; )
465 {
466 SwSection* pSect = rArr[ --n ]->GetSection();
467
468 if( pSect )
469 {
470 AddUsedDBToList( rDBNameList, FindUsedDBs( *pAllDBNames,
471 pSect->GetCondition(), aUsedDBNames ) );
472 aUsedDBNames.clear();
473 }
474 }
475
476 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
477 {
478 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(nWhichHint))
479 {
480 const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
481 const SwTextField* pTextField = pFormatField->GetTextField();
482 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
483 continue;
484
485 const SwField* pField = pFormatField->GetField();
486 switch (pField->GetTyp()->Which())
487 {
489 AddUsedDBToList( rDBNameList,
490 lcl_DBDataToString(static_cast<const SwDBField*>(pField)->GetDBData() ));
491 break;
492
495 AddUsedDBToList( rDBNameList,
496 lcl_DBDataToString(static_cast<const SwDBNameInfField*>(pField)->GetRealDBData() ));
497 break;
498
501 AddUsedDBToList( rDBNameList,
502 lcl_DBDataToString(static_cast<const SwDBNameInfField*>(pField)->GetRealDBData() ));
503 [[fallthrough]]; // JP: is that right like that?
504
507 AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames,
508 pField->GetPar1(), aUsedDBNames ));
509 aUsedDBNames.clear();
510 break;
511
515 AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames,
516 pField->GetFormula(), aUsedDBNames ));
517 aUsedDBNames.clear();
518 break;
519 default: break;
520 }
521 }
522 }
523#endif
524}
525
526void SwDoc::GetAllDBNames( std::vector<OUString>& rAllDBNames )
527{
528#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
529 (void) rAllDBNames;
530#else
531 SwDBManager* pMgr = GetDBManager();
532
533 const SwDSParams_t& rArr = pMgr->GetDSParamArray();
534 for (const auto& pParam : rArr)
535 {
536 rAllDBNames.emplace_back(pParam->sDataSource + OUStringChar(DB_DELIM) + pParam->sCommand);
537 }
538#endif
539}
540
541std::vector<OUString>& SwDoc::FindUsedDBs( const std::vector<OUString>& rAllDBNames,
542 const OUString& rFormula,
543 std::vector<OUString>& rUsedDBNames )
544{
545 const CharClass& rCC = GetAppCharClass();
546#ifndef UNX
547 const OUString sFormula(rCC.uppercase( rFormula ));
548#else
549 const OUString sFormula(rFormula);
550#endif
551
552 for (const auto &sItem : rAllDBNames)
553 {
554 sal_Int32 nPos = sFormula.indexOf( sItem );
555 if( nPos>=0 &&
556 sFormula[ nPos + sItem.getLength() ] == '.' &&
557 (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 )))
558 {
559 // Look up table name
560 nPos += sItem.getLength() + 1;
561 const sal_Int32 nEndPos = sFormula.indexOf('.', nPos);
562 if( nEndPos>=0 )
563 {
564 rUsedDBNames.emplace_back(sItem + OUStringChar(DB_DELIM) + sFormula.subView( nPos, nEndPos - nPos ));
565 }
566 }
567 }
568 return rUsedDBNames;
569}
570
571void SwDoc::AddUsedDBToList( std::vector<OUString>& rDBNameList,
572 const std::vector<OUString>& rUsedDBNames )
573{
574 for ( const auto &sName : rUsedDBNames )
575 AddUsedDBToList( rDBNameList, sName );
576}
577
578void SwDoc::AddUsedDBToList( std::vector<OUString>& rDBNameList, const OUString& rDBName)
579{
580#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
581 (void) rDBNameList;
582 (void) rDBName;
583#else
584 if( rDBName.isEmpty() )
585 return;
586
587#ifdef UNX
588 for( const auto &sName : rDBNameList )
589 if( rDBName == o3tl::getToken(sName, 0, ';') )
590 return;
591#else
592 const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
593 for( const auto &sName : rDBNameList )
594 if( rSCmp.isEqual( rDBName, sName.getToken(0, ';') ) )
595 return;
596#endif
597
599 sal_Int32 nIdx{ 0 };
600 aData.sDataSource = rDBName.getToken(0, DB_DELIM, nIdx);
601 aData.sCommand = rDBName.getToken(0, DB_DELIM, nIdx);
602 aData.nCommandType = -1;
604 rDBNameList.push_back(rDBName);
605#endif
606}
607
608void SwDoc::ChangeDBFields( const std::vector<OUString>& rOldNames,
609 const OUString& rNewName )
610{
611#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
612 (void) rOldNames;
613 (void) rNewName;
614#else
615 SwDBData aNewDBData;
616 sal_Int32 nIdx{ 0 };
617 aNewDBData.sDataSource = rNewName.getToken(0, DB_DELIM, nIdx);
618 aNewDBData.sCommand = rNewName.getToken(0, DB_DELIM, nIdx);
619 aNewDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rNewName, 0, DB_DELIM, nIdx));
620
622 for (auto n = rArr.size(); n; )
623 {
624 SwSection* pSect = rArr[ --n ]->GetSection();
625
626 if( pSect )
627 {
628 pSect->SetCondition(ReplaceUsedDBs(rOldNames, rNewName, pSect->GetCondition()));
629 }
630 }
631
632 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
633 {
634 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(nWhichHint))
635 {
636 SwFormatField* pFormatField = const_cast<SwFormatField*>(static_cast<const SwFormatField*>(pItem));
637 SwTextField* pTextField = pFormatField->GetTextField();
638 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
639 continue;
640
641 SwField* pField = pFormatField->GetField();
642 bool bExpand = false;
643
644 switch( pField->GetTyp()->Which() )
645 {
647#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
648 if (IsNameInArray(rOldNames, lcl_DBDataToString(static_cast<SwDBField*>(pField)->GetDBData())))
649 {
650 SwDBFieldType* pOldTyp = static_cast<SwDBFieldType*>(pField->GetTyp());
651
653 SwDBFieldType(this, pOldTyp->GetColumnName(), aNewDBData)));
654
655 pFormatField->RegisterToFieldType( *pTyp );
656 pField->ChgTyp(pTyp);
657
658 static_cast<SwDBField*>(pField)->ClearInitialized();
659 static_cast<SwDBField*>(pField)->InitContent();
660
661 bExpand = true;
662 }
663#endif
664 break;
665
668 if (IsNameInArray(rOldNames,
669 lcl_DBDataToString(static_cast<SwDBNameInfField*>(pField)->GetRealDBData())))
670 {
671 static_cast<SwDBNameInfField*>(pField)->SetDBData(aNewDBData);
672 bExpand = true;
673 }
674 break;
675
678 if (IsNameInArray(rOldNames,
679 lcl_DBDataToString(static_cast<SwDBNameInfField*>(pField)->GetRealDBData())))
680 {
681 static_cast<SwDBNameInfField*>(pField)->SetDBData(aNewDBData);
682 }
683 [[fallthrough]];
686 pField->SetPar1( ReplaceUsedDBs(rOldNames, rNewName, pField->GetPar1()) );
687 bExpand = true;
688 break;
689
693 pField->SetPar2( ReplaceUsedDBs(rOldNames, rNewName, pField->GetFormula()) );
694 bExpand = true;
695 break;
696 default: break;
697 }
698
699 if (bExpand)
700 pTextField->ExpandTextField( true );
701 }
702 }
704#endif
705}
706
707namespace
708{
709
710OUString lcl_CutOffDBCommandType(const OUString& rName)
711{
712 return rName.replaceFirst(OUStringChar(DB_DELIM), ".").getToken(0, DB_DELIM);
713}
714
715}
716
717OUString SwDoc::ReplaceUsedDBs( const std::vector<OUString>& rUsedDBNames,
718 const OUString& rNewName, const OUString& rFormula )
719{
720 const CharClass& rCC = GetAppCharClass();
721 const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
722 OUString sFormula(rFormula);
723
724 for(const auto & rUsedDBName : rUsedDBNames)
725 {
726 const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBName) );
727
728 if (sDBName!=sNewName)
729 {
730 sal_Int32 nPos = 0;
731 for (;;)
732 {
733 nPos = sFormula.indexOf(sDBName, nPos);
734 if (nPos<0)
735 {
736 break;
737 }
738
739 if( sFormula[nPos + sDBName.getLength()] == '.' &&
740 (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 )))
741 {
742 sFormula = sFormula.replaceAt(nPos, sDBName.getLength(), sNewName);
743 //prevent re-searching - this is useless and provokes
744 //endless loops when names containing each other and numbers are exchanged
745 //e.g.: old ?12345.12345 new: i12345.12345
746 nPos += sNewName.getLength();
747 }
748 }
749 }
750 }
751 return sFormula;
752}
753
754bool SwDoc::IsNameInArray( const std::vector<OUString>& rArr, const OUString& rName )
755{
756#ifdef UNX
757 for( const auto &sName : rArr )
758 if( rName == sName )
759 return true;
760#else
761 const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
762 for( const auto &sName : rArr )
763 if( rSCmp.isEqual( rName, sName ))
764 return true;
765#endif
766 return false;
767}
768
770{
771 const SwFieldTypes::size_type nSize = getIDocumentFieldsAccess().GetFieldTypes()->size();
772
773 for( SwFieldTypes::size_type i = INIT_FLDTYPES; i < nSize; ++i )
774 {
776 if( SwFieldIds::TableOfAuthorities == pFieldType->Which() )
777 {
778 SwAuthorityFieldType* pAuthType = static_cast<SwAuthorityFieldType*>(pFieldType);
779 pAuthType->ChangeEntryContent(pNewData);
780 break;
781 }
782 }
783
784}
785
787{
788 const SwFieldIds nWhich = rField.GetFormatField().GetField()->GetTyp()->Which();
789 switch( nWhich )
790 {
799 break; // these have to be added/removed!
800
801 default:
802 return;
803 }
804
805 SetFieldsDirty( true );
806 if (!m_pFieldSortList)
807 {
808 if( !bIns ) // if list is present and deleted
809 return; // don't do a thing
811 }
812
813 if( bIns ) // insert anew:
814 GetBodyNode( rField, nWhich );
815 else
816 {
817 // look up via the pTextField pointer. It is a sorted list, but it's sorted by node
818 // position. Until this is found, the search for the pointer is already done.
819 for (SetGetExpFields::size_type n = 0; n < m_pFieldSortList->size(); ++n)
820 {
821 if (&rField == (*m_pFieldSortList)[n]->GetPointer())
822 {
823 m_pFieldSortList->erase_at(n);
824 n--; // one field can occur multiple times
825 }
826 }
827 }
828}
829
830void SwDocUpdateField::MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode )
831{
832 if (!m_pFieldSortList || bAll
833 || ((eGetMode & m_nFieldListGetMode) != eGetMode)
834 || rDoc.GetNodes().Count() != m_nNodes)
835 {
836 MakeFieldList_( rDoc, eGetMode );
837 }
838}
839
840void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
841{
842 // new version: walk all fields of the attribute pool
844
845 // remember sections that were unhidden and need to be hidden again
846 std::vector<std::reference_wrapper<SwSection>> aUnhiddenSections;
847
848 // consider and unhide sections
849 // with hide condition, only in mode GETFLD_ALL (<eGetMode == GETFLD_ALL>)
850 // notes by OD:
851 // eGetMode == GETFLD_CALC in call from methods SwDoc::FieldsToCalc
852 // eGetMode == GETFLD_EXPAND in call from method SwDoc::FieldsToExpand
853 // eGetMode == GETFLD_ALL in call from method SwDoc::UpdateExpFields
854 // I figured out that hidden section only have to be shown,
855 // if fields have updated (call by SwDoc::UpdateExpFields) and thus
856 // the hide conditions of section have to be updated.
857 // For correct updating the hide condition of a section, its position
858 // have to be known in order to insert the hide condition as a new
859 // expression field into the sorted field list (<m_pFieldSortList>).
860 if ( eGetMode == GETFLD_ALL )
861 // Collect the sections first. Supply sections that are hidden by condition
862 // with frames so that the contained fields are sorted properly.
863 {
864 // In order for the frames to be created the right way, they have to be expanded
865 // from top to bottom
866 std::vector<SwNodeOffset> aTmpArr;
867 std::vector<SwNodeOffset>::size_type nArrStt = 0;
868 SwSectionFormats& rArr = rDoc.GetSections();
869 SwSectionNode* pSectNd = nullptr;
870 SwNodeOffset nSttContent = rDoc.GetNodes().GetEndOfExtras().GetIndex();
871
872 for (SwSectionFormats::size_type n = rArr.size(); n; )
873 {
874 SwSection* pSect = rArr[ --n ]->GetSection();
875 if( !pSect || !pSect->IsHidden() || pSect->GetCondition().isEmpty() )
876 continue;
877 pSectNd = pSect->GetFormat()->GetSectionNode();
878 if( pSectNd )
879 {
880 SwNodeOffset nIdx = pSectNd->GetIndex();
881 aTmpArr.push_back( nIdx );
882 if( nIdx < nSttContent )
883 ++nArrStt;
884 }
885 }
886 std::sort(aTmpArr.begin(), aTmpArr.end());
887
888 // Display all first so that we have frames. The BodyAnchor is defined by that.
889 // First the ContentArea, then the special areas!
890 for (std::vector<sal_uLong>::size_type n = nArrStt; n < aTmpArr.size(); ++n)
891 {
892 pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode();
893 OSL_ENSURE( pSectNd, "Where is my SectionNode" );
894
895 auto& rSection = pSectNd->GetSection();
896 // unhide and remember the conditionally hidden sections
897 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
898 {
899 aUnhiddenSections.push_back(std::ref(rSection)); // remember to later hide again
900 rSection.SetCondHidden(false);
901 }
902 }
903 for (std::vector<sal_uLong>::size_type n = 0; n < nArrStt; ++n)
904 {
905 pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode();
906 OSL_ENSURE( pSectNd, "Where is my SectionNode" );
907
908 auto& rSection = pSectNd->GetSection();
909 // unhide and remember the conditionally hidden sections
910 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
911 {
912 aUnhiddenSections.push_back(std::ref(rSection)); // remember to later hide again
913 rSection.SetCondHidden(false);
914 }
915 }
916
917 // add all to the list so that they are sorted
918 for (const auto &nId : aTmpArr)
919 {
920 SwSectionNode const& rSectionNode(*rDoc.GetNodes()[ nId ]->GetSectionNode());
921 GetBodyNodeGeneric(rSectionNode, rSectionNode);
922 }
923
924 // bookmarks with hide conditions, handle similar to sections
925 auto const& rIDMA(*rDoc.getIDocumentMarkAccess());
926 for (auto it = rIDMA.getBookmarksBegin(); it != rIDMA.getBookmarksEnd(); ++it)
927 {
928 auto const pBookmark(dynamic_cast<::sw::mark::IBookmark const*>(*it));
929 assert(pBookmark);
930 if (!pBookmark->GetHideCondition().isEmpty())
931 {
932 GetBodyNodeGeneric((*it)->GetMarkStart().GetNode(), *pBookmark);
933 }
934 }
935 }
936
937 static constexpr OUStringLiteral sTrue(u"TRUE");
938 static constexpr OUStringLiteral sFalse(u"FALSE");
939
940#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
941 bool bIsDBManager = nullptr != rDoc.GetDBManager();
942#endif
943
944 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
945 {
946 for (const SfxPoolItem* pItem : rDoc.GetAttrPool().GetItemSurrogates(nWhichHint))
947 {
948 const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
949 const SwTextField* pTextField = pFormatField->GetTextField();
950 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
951 continue;
952
953 OUString sFormula;
954 const SwField* pField = pFormatField->GetField();
955 const SwFieldIds nWhich = pField->GetTyp()->Which();
956 switch (nWhich)
957 {
960 if (GETFLD_ALL == eGetMode)
961 sFormula = sTrue;
962 break;
963
965 if (GETFLD_EXPAND & eGetMode)
966 sFormula = sTrue;
967 break;
968
970 if ((eGetMode != GETFLD_EXPAND) ||
972 {
973 sFormula = sTrue;
974 }
975 break;
976
978 if (GETFLD_ALL == eGetMode)
979 {
980 sFormula = pField->GetPar1();
981 if (sFormula.isEmpty() || sFormula==sFalse)
982 const_cast<SwHiddenParaField*>(static_cast<const SwHiddenParaField*>(pField))->SetHidden( false );
983 else if (sFormula==sTrue)
984 const_cast<SwHiddenParaField*>(static_cast<const SwHiddenParaField*>(pField))->SetHidden( true );
985 else
986 break;
987
988 sFormula.clear();
989 // trigger formatting
990 const_cast<SwFormatField*>(pFormatField)->ForceUpdateTextNode();
991 }
992 break;
993
995 if (GETFLD_ALL == eGetMode)
996 {
997 sFormula = pField->GetPar1();
998 if (sFormula.isEmpty() || sFormula==sFalse)
999 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->SetValue( true );
1000 else if (sFormula==sTrue)
1001 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->SetValue( false );
1002 else
1003 break;
1004
1005 sFormula.clear();
1006
1007 // evaluate field
1008 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->Evaluate(rDoc);
1009 // trigger formatting
1010 const_cast<SwFormatField*>(pFormatField)->ForceUpdateTextNode();
1011 }
1012 break;
1013
1014#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1016 {
1017 SwDBData aDBData(const_cast<SwDBNumSetField*>(static_cast<const SwDBNumSetField*>(pField))->GetDBData(&rDoc));
1018
1019 if ( (bIsDBManager && rDoc.GetDBManager()->OpenDataSource(aDBData.sDataSource, aDBData.sCommand))
1020 && (GETFLD_ALL == eGetMode
1021 || (GETFLD_CALC & eGetMode
1022 && static_cast<const SwDBNumSetField*>(pField)->IsCondValid()))
1023 )
1024 {
1025 sFormula = pField->GetPar1();
1026 }
1027 }
1028 break;
1030 {
1031 SwDBData aDBData(const_cast<SwDBNextSetField*>(static_cast<const SwDBNextSetField*>(pField))->GetDBData(&rDoc));
1032
1033 if ( (bIsDBManager && rDoc.GetDBManager()->OpenDataSource(aDBData.sDataSource, aDBData.sCommand))
1034 && (GETFLD_ALL == eGetMode
1035 || (GETFLD_CALC & eGetMode
1036 && static_cast<const SwDBNextSetField*>(pField)->IsCondValid()))
1037 )
1038 {
1039 sFormula = pField->GetPar1();
1040 }
1041 }
1042 break;
1043#endif
1044 default: break;
1045 }
1046
1047 if (!sFormula.isEmpty())
1048 {
1049 GetBodyNode( *pTextField, nWhich );
1050 }
1051 }
1052 }
1053 m_nFieldListGetMode = eGetMode;
1054 m_nNodes = rDoc.GetNodes().Count();
1055
1056 // return the conditional hidden value back to the previous value
1057 for (auto& rSectionWrapper : aUnhiddenSections)
1058 {
1059 auto& rSection = rSectionWrapper.get();
1060 rSection.SetCondHidden(true);
1061 }
1062}
1063
1064void SwDocUpdateField::GetBodyNode( const SwTextField& rTField, SwFieldIds nFieldWhich )
1065{
1066 const SwTextNode& rTextNd = rTField.GetTextNode();
1067 const SwDoc& rDoc = rTextNd.GetDoc();
1068
1069 // always the first! (in tab headline, header-/footer)
1070 Point aPt;
1071 std::pair<Point, bool> const tmp(aPt, false);
1072 // need pos to get the frame on the correct page
1073 SwPosition const pos(rTextNd, rTField.GetStart());
1074 const SwFrame* pFrame = rTextNd.getLayoutFrame(
1076
1077 std::unique_ptr<SetGetExpField> pNew;
1078 bool bIsInBody = false;
1079
1080 if( !pFrame || pFrame->IsInDocBody() )
1081 {
1082 bIsInBody = rDoc.GetNodes().GetEndOfExtras().GetIndex() < rTextNd.GetIndex();
1083
1084 // We don't want to update fields in redlines, or those
1085 // in frames whose anchor is in redline. However, we do want to update
1086 // fields in hidden sections. So: In order to be updated, a field 1)
1087 // must have a frame, or 2) it must be in the document body.
1088 if (pFrame == nullptr && bIsInBody)
1089 { // try harder to get a frame for the page number
1090 pFrame = ::sw::FindNeighbourFrameForNode(rTextNd);
1091 // possibly there is no layout at all, happens in mail merge
1092 }
1093 if( (pFrame != nullptr) || bIsInBody )
1094 {
1095 pNew.reset(new SetGetExpField(rTextNd, &rTField, std::nullopt,
1096 pFrame ? pFrame->GetPhyPageNum() : 0));
1097 }
1098 }
1099 else
1100 {
1101 // create index to determine the TextNode
1102 SwPosition aPos( rDoc.GetNodes().GetEndOfPostIts() );
1103 bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame );
1104 OSL_ENSURE(bResult, "where is the Field");
1105 pNew.reset(new SetGetExpField(aPos.GetNode(), &rTField, aPos.GetContentIndex(),
1106 pFrame->GetPhyPageNum()));
1107 }
1108
1109 // always set the BodyTextFlag in GetExp or DB fields
1110 if( SwFieldIds::GetExp == nFieldWhich )
1111 {
1112 SwGetExpField* pGetField = const_cast<SwGetExpField*>(static_cast<const SwGetExpField*>(rTField.GetFormatField().GetField()));
1113 pGetField->ChgBodyTextFlag( bIsInBody );
1114 }
1115#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1116 else if( SwFieldIds::Database == nFieldWhich )
1117 {
1118 SwDBField* pDBField = const_cast<SwDBField*>(static_cast<const SwDBField*>(rTField.GetFormatField().GetField()));
1119 pDBField->ChgBodyTextFlag( bIsInBody );
1120 }
1121#endif
1122 if( pNew != nullptr )
1123 m_pFieldSortList->insert( std::move(pNew) );
1124}
1125
1126template<typename T>
1127void SwDocUpdateField::GetBodyNodeGeneric(SwNode const& rNode, T const& rCond)
1128{
1129 const SwDoc& rDoc = rNode.GetDoc();
1130 std::unique_ptr<SetGetExpField> pNew;
1131
1132 if (rNode.GetIndex() < rDoc.GetNodes().GetEndOfExtras().GetIndex())
1133 {
1134 do { // middle check loop
1135
1136 // we need to get the anchor first
1137 // create index to determine the TextNode
1138 SwPosition aPos(rNode);
1139 SwContentNode const*const pCNd = rNode.IsSectionNode()
1140 ? rDoc.GetNodes().GoNext(&aPos.nNode) // to the next ContentNode
1141 : rNode.GetContentNode();
1142
1143 if( !pCNd || !pCNd->IsTextNode() )
1144 break;
1145
1146 // always the first! (in tab headline, header-/footer)
1147 Point aPt;
1148 std::pair<Point, bool> const tmp(aPt, false);
1149 const SwContentFrame* pFrame = pCNd->getLayoutFrame(
1151 nullptr, &tmp);
1152 if( !pFrame )
1153 break;
1154
1155 bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame );
1156 OSL_ENSURE(bResult, "where is the Field");
1157 pNew.reset(new SetGetExpField(rCond, &aPos, pFrame->GetPhyPageNum()));
1158
1159 } while( false );
1160 }
1161
1162 if( !pNew )
1163 {
1164 // try harder to get a frame for the page number
1165 SwFrame const*const pFrame = ::sw::FindNeighbourFrameForNode(rNode);
1166 pNew.reset(new SetGetExpField(rCond, nullptr, pFrame ? pFrame->GetPhyPageNum() : 0));
1167 }
1168
1169 m_pFieldSortList->insert( std::move(pNew) );
1170}
1171
1173{
1174 OUString sFieldName;
1175 switch( rType.Which() )
1176 {
1177 case SwFieldIds::User :
1178 sFieldName = static_cast<const SwUserFieldType&>(rType).GetName();
1179 break;
1180 case SwFieldIds::SetExp:
1181 sFieldName = static_cast<const SwSetExpFieldType&>(rType).GetName();
1182 break;
1183 default:
1184 OSL_ENSURE( false, "No valid field type" );
1185 }
1186
1187 if( sFieldName.isEmpty() )
1188 return;
1189
1190 SetFieldsDirty( true );
1191 // look up and remove from the hash table
1192 sFieldName = GetAppCharClass().lowercase( sFieldName );
1193 sal_uInt32 n;
1194
1195 SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
1196
1197 if( !pFnd )
1198 {
1199 SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
1200 pNew->pNext.reset( m_FieldTypeTable[n].release() );
1201 m_FieldTypeTable[n].reset(pNew);
1202 }
1203}
1204
1206{
1207 OUString sFieldName;
1208 switch( rType.Which() )
1209 {
1210 case SwFieldIds::User :
1211 sFieldName = static_cast<const SwUserFieldType&>(rType).GetName();
1212 break;
1213 case SwFieldIds::SetExp:
1214 sFieldName = static_cast<const SwSetExpFieldType&>(rType).GetName();
1215 break;
1216 default: break;
1217 }
1218
1219 if( sFieldName.isEmpty() )
1220 return;
1221
1222 SetFieldsDirty( true );
1223 // look up and remove from the hash table
1224 sFieldName = GetAppCharClass().lowercase( sFieldName );
1225 sal_uInt32 n;
1226
1227 SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
1228 if( !pFnd )
1229 return;
1230
1231 if (m_FieldTypeTable[n].get() == pFnd)
1232 {
1233 m_FieldTypeTable[n].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
1234 }
1235 else
1236 {
1237 SwHash* pPrev = m_FieldTypeTable[n].get();
1238 while( pPrev->pNext.get() != pFnd )
1239 pPrev = pPrev->pNext.get();
1240 pPrev->pNext = std::move(pFnd->pNext);
1241 // no need to explicitly delete here, the embedded linked list uses unique_ptr
1242 }
1243}
1244
1246 : m_FieldTypeTable(TBLSZ)
1247 , m_nNodes(0)
1248 , m_nFieldListGetMode(0)
1249 , m_rDoc(rDoc)
1250 , m_bInUpdateFields(false)
1251 , m_bFieldsDirty(false)
1252{
1253}
1254
1256{
1257}
1258
1259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define TBLSZ
Definition: calc.hxx:40
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)
Definition: docfld.cxx:67
sal_Int32 GetCntPosFromContent() const
Definition: docfld.cxx:342
bool operator<(const SetGetExpField &rField) const
Definition: docfld.cxx:229
const SwNode * GetNodeFromContent() const
Definition: docfld.cxx:294
const SwPosition * pPos
Definition: docfld.hxx:54
void SetBodyPos(const SwContentFrame &rFrame)
Definition: docfld.cxx:204
void GetPosOfContent(SwPosition &rPos) const
Definition: docfld.cxx:188
union SetGetExpField::@4 m_CNTNT
enum SetGetExpField::SetGetExpFieldType m_eSetGetExpFieldType
SwNodeOffset m_nNode
Definition: docfld.hxx:50
const SwTextField * pTextField
Definition: docfld.hxx:52
bool operator==(const SetGetExpField &rField) const
Definition: docfld.cxx:220
sal_uInt16 m_nPageNumber
Definition: docfld.hxx:49
sal_Int32 m_nContent
Definition: docfld.hxx:61
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
Definition: authfld.cxx:158
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
const OUString & GetColumnName() const
Definition: dbfld.hxx:47
void ChgBodyTextFlag(bool bIsInBody)
set from UpdateExpFields (the Node-Position is known there)
Definition: dbfld.hxx:118
void CreateDSData(const SwDBData &rData)
Definition: dbmgr.hxx:366
static const SwDBData & GetAddressDBName()
Definition: dbmgr.cxx:2530
const SwDSParams_t & GetDSParamArray() const
Definition: dbmgr.hxx:368
bool OpenDataSource(const OUString &rDataSource, const OUString &rTableOrQuery)
open the source while fields are updated - for the calculator only!
Definition: dbmgr.cxx:2310
void SetInitDBFields(bool b)
Definition: dbmgr.hxx:316
const SwDBData & GetRealDBData() const
DBName.
Definition: dbfld.hxx:135
bool IsCondValid() const
Definition: dbfld.hxx:182
bool IsCondValid() const
Definition: dbfld.hxx:228
void MakeFieldList(SwDoc &rDoc, bool bAll, int eGetMode)
Definition: docfld.cxx:830
SwHashTable< SwCalcFieldType > m_FieldTypeTable
Definition: docfld.hxx:147
SwDocUpdateField(SwDoc &rDocument)
Definition: docfld.cxx:1245
void MakeFieldList_(SwDoc &pDoc, int eGetMode)
Definition: docfld.cxx:840
void InsDelFieldInFieldLst(bool bIns, const SwTextField &rField)
Definition: docfld.cxx:786
void SetFieldsDirty(bool b)
Definition: docfld.hxx:178
int m_nFieldListGetMode
Definition: docfld.hxx:150
SwHashTable< SwCalcFieldType > const & GetFieldTypeTable() const
Definition: docfld.hxx:188
void GetBodyNode(const SwTextField &, SwFieldIds nFieldWhich)
Definition: docfld.cxx:1064
void InsertFieldType(const SwFieldType &rType)
Definition: docfld.cxx:1172
std::unique_ptr< SetGetExpFields > m_pFieldSortList
current field list for calculation
Definition: docfld.hxx:146
SwNodeOffset m_nNodes
to check if the node count changed
Definition: docfld.hxx:149
void RemoveFieldType(const SwFieldType &rType)
Definition: docfld.cxx:1205
void GetBodyNodeGeneric(SwNode const &rNode, T const &)
Definition: docfld.cxx:1127
Definition: doc.hxx:197
SwDBData const & GetDBData()
Definition: docfld.cxx:386
SwSectionFormats & GetSections()
Definition: doc.hxx:1356
void ChangeAuthorityData(const SwAuthEntry *pNewData)
Definition: docfld.cxx:769
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:408
bool IsUsed(const sw::BroadcastingModify &) const
Definition: poolfmt.cxx:86
SwDBManager * GetDBManager() const
Definition: doc.hxx:685
SwDBData maDBData
Definition: doc.hxx:212
void AddUsedDBToList(std::vector< OUString > &rDBNameList, const std::vector< OUString > &rUsedDBNames)
Definition: docfld.cxx:571
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
static OUString ReplaceUsedDBs(const std::vector< OUString > &rUsedDBNames, const OUString &rNewName, const OUString &rFormula)
Definition: docfld.cxx:717
static bool IsNameInArray(const std::vector< OUString > &rOldNames, const OUString &rName)
Definition: docfld.cxx:754
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1890
void SetInitDBFields(bool b)
Definition: docfld.cxx:426
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
void GetAllDBNames(std::vector< OUString > &rAllDBNames)
Definition: docfld.cxx:526
void GetAllUsedDB(std::vector< OUString > &rDBNameList, const std::vector< OUString > *pAllDBNames=nullptr)
Definition: docfld.cxx:447
static std::vector< OUString > & FindUsedDBs(const std::vector< OUString > &rAllDBNames, const OUString &rFormula, std::vector< OUString > &rUsedDBNames)
Definition: docfld.cxx:541
void ChangeDBFields(const std::vector< OUString > &rOldNames, const OUString &rNewName)
Definition: docfld.cxx:608
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
SwFieldIds Which() const
Definition: fldbas.hxx:276
Base class of all fields.
Definition: fldbas.hxx:296
virtual OUString GetFormula() const
Definition: fldbas.cxx:344
virtual OUString GetPar1() const
Definition: fldbas.cxx:334
virtual void SetPar1(const OUString &rStr)
Definition: fldbas.cxx:349
virtual void SetPar2(const OUString &rStr)
Definition: fldbas.cxx:352
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:355
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
Definition: fldbas.cxx:415
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:32
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
const SwField * GetField() const
Definition: fmtfld.hxx:131
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:149
void RegisterToFieldType(SwFieldType &)
Definition: atrfld.cxx:170
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
bool IsInDocBody() const
Definition: frame.hxx:949
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1706
void ChgBodyTextFlag(bool bIsInBody)
Set by UpdateExpFields where node position is known.
Definition: expfld.hxx:143
T should be a subclass of SwHash.
Definition: calc.hxx:155
T * Find(std::u16string_view aStr, sal_uInt32 *pPos=nullptr) const
Definition: calc.hxx:166
void SetHidden(bool bHidden)
Definition: docufld.hxx:375
void Evaluate(SwDoc &rDoc)
get current field value and cache it
Definition: docufld.cxx:1344
void SetValue(bool bHidden)
Definition: docufld.hxx:331
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:77
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwNodes & GetNodes() const
Definition: ndindex.hxx:119
SwNode & GetNode() const
Definition: ndindex.hxx:123
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:111
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
SwDoc & GetDoc()
Definition: node.hxx:233
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
bool IsSectionNode() const
Definition: node.hxx:192
bool IsTextNode() const
Definition: node.hxx:190
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwContentNode * GetContentNode()
Definition: node.hxx:666
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2555
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1299
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:154
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:307
SwNodeOffset Count() const
Definition: ndarr.hxx:142
SwSectionNode * GetSectionNode()
Definition: section.cxx:923
Array of Undo-history.
Definition: docary.hxx:193
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
const SwSection & GetSection() const
Definition: node.hxx:590
OUString const & GetCondition() const
Definition: section.hxx:201
bool IsHidden() const
Definition: section.hxx:181
void SetCondHidden(bool const bFlag)
Definition: section.cxx:509
SwSectionFormat * GetFormat()
Definition: section.hxx:341
void SetCondition(OUString const &rNew)
Definition: section.hxx:202
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:495
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:199
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
void ExpandTextField(const bool bForceNotify=false) const
Definition: atrfld.cxx:520
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:472
SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
Definition: txtinet.hxx:30
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
The shared part of a user field.
Definition: usrfld.hxx:35
std::vector< SwSectionFormat * >::size_type size_type
Definition: docary.hxx:67
size_t size() const
Definition: docary.hxx:88
virtual const SwPosition & GetMarkStart() const =0
std::vector< std::unique_ptr< SwDSParam > > SwDSParams_t
Definition: dbmgr.hxx:137
virtual OUString GetName() const override
virtual void SetValue(tools::Long nNew) override
SwDoc & m_rDoc
Definition: docbm.cxx:1228
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.
Definition: docfld.cxx:377
const int GETFLD_CALC
Definition: docfld.hxx:141
const int GETFLD_ALL
Definition: docfld.hxx:140
const int GETFLD_EXPAND
Definition: docfld.hxx:142
OString sFormula
float u
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
Definition: expfld.cxx:163
SwFieldIds
Definition: fldbas.hxx:49
@ Database
For old documents the Field-Which IDs must be preserved !!!
@ TableOfAuthorities
OUString sName
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:802
CharClass & GetAppCharClass()
Definition: init.cxx:721
sal_Int64 n
sal_uInt16 nPos
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
OString strip(const OString &rIn, char c)
int i
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:207
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)
Definition: node2lay.cxx:145
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
sal_Int16 nId
bool IsFrameBehind(const SwTextNode &rMyNd, sal_Int32 nMySttPos, const SwTextNode &rBehindNd, sal_Int32 nSttPos)
Definition: reffld.cxx:100
OUString aSetStr
Definition: docfld.hxx:124
HashStr(const OUString &rName, OUString aText, HashStr *)
Definition: docfld.cxx:369
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
OUString sDataSource
Definition: swdbdata.hxx:30
OUString sCommand
Definition: swdbdata.hxx:31
Definition: calc.hxx:136
std::unique_ptr< SwHash > pNext
Definition: calc.hxx:140
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:231
SwNodeIndex nNode
Definition: pam.hxx:39
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:78
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
UNDERLYING_TYPE get() const
#define INIT_FLDTYPES
Definition: swtypes.hxx:105
#define DB_DELIM
Definition: swtypes.hxx:130
size_t pos