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 != 0 && rField.m_nPageNumber != 0 && m_nPageNumber != rField.m_nPageNumber)
232 {
233 return m_nPageNumber < rField.m_nPageNumber;
234 }
235 if( m_nNode < rField.m_nNode || ( m_nNode == rField.m_nNode && m_nContent < rField.m_nContent ))
236 return true;
237 else if( m_nNode != rField.m_nNode || m_nContent != rField.m_nContent )
238 return false;
239
240 const SwNode *pFirst = GetNodeFromContent(),
241 *pNext = rField.GetNodeFromContent();
242
243 // Position is the same: continue only if both field pointers are set!
244 if( !pFirst || !pNext )
245 return false;
246
247 // same Section?
248 if( pFirst->StartOfSectionNode() != pNext->StartOfSectionNode() )
249 {
250 // is one in the table?
251 const SwNode *pFirstStt, *pNextStt;
252 const SwTableNode* pTableNd = pFirst->FindTableNode();
253 if( pTableNd )
254 pFirstStt = pTableNd->StartOfSectionNode();
255 else
256 pFirstStt = pFirst->StartOfSectionNode();
257
258 pTableNd = pNext->FindTableNode();
259 if( pTableNd )
260 pNextStt = pTableNd->StartOfSectionNode();
261 else
262 pNextStt = pNext->StartOfSectionNode();
263
264 if( pFirstStt != pNextStt )
265 {
266 if( pFirst->IsTextNode() && pNext->IsTextNode() &&
267 ( pFirst->FindFlyStartNode() || pNext->FindFlyStartNode() ))
268 {
269 // FIXME: in NewFieldPortion(), SwGetExpField are expanded via
270 // DocumentFieldsManager::FieldsToExpand() calling
271 // std::upper_bound binary search function - the sort order
272 // depends on the fly positions in the layout, but the fly
273 // positions depend on the expansion of the SwGetExpField!
274 // This circular dep will cause trouble, it would be better to
275 // use only model positions (anchor), but then how to compare
276 // at-page anchored flys which don't have a model anchor?
277 return ::IsFrameBehind( *pNext->GetTextNode(), m_nContent, *pFirst->GetTextNode(), m_nContent );
278 }
279 return pFirstStt->GetIndex() < pNextStt->GetIndex();
280 }
281 }
282
283 // same Section: is the field in the same Node?
284 if( pFirst != pNext )
285 return pFirst->GetIndex() < pNext->GetIndex();
286
287 // same Node in the Section, check Position in the Node
288 return GetCntPosFromContent() < rField.GetCntPosFromContent();
289}
290
292{
293 const SwNode* pRet = nullptr;
294 if( m_CNTNT.pTextField )
295 switch( m_eSetGetExpFieldType )
296 {
297 case TEXTFIELD:
298 pRet = &m_CNTNT.pTextField->GetTextNode();
299 break;
300
301 case TEXTINET:
302 pRet = &m_CNTNT.pTextINet->GetTextNode();
303 break;
304
305 case SECTIONNODE:
306 pRet = m_CNTNT.pSection->GetFormat()->GetSectionNode();
307 break;
308
309 case BOOKMARK:
310 pRet = &m_CNTNT.pBookmark->GetMarkStart().GetNode();
311 break;
312
313 case CRSRPOS:
314 pRet = &m_CNTNT.pPos->GetNode();
315 break;
316
317 case TEXTTOXMARK:
318 pRet = &m_CNTNT.pTextTOX->GetTextNode();
319 break;
320
321 case TABLEBOX:
322 if( m_CNTNT.pTBox->GetSttNd() )
323 {
324 SwNodeIndex aIdx( *m_CNTNT.pTBox->GetSttNd() );
325 pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx );
326 }
327 break;
328
329 case FLYFRAME:
330 {
331 SwNodeIndex aIdx( *m_CNTNT.pFlyFormat->GetContent().GetContentIdx() );
332 pRet = aIdx.GetNode().GetNodes().GoNext( &aIdx );
333 }
334 break;
335 }
336 return pRet;
337}
338
340{
341 sal_Int32 nRet = 0;
342 if( m_CNTNT.pTextField )
343 switch( m_eSetGetExpFieldType )
344 {
345 case TEXTFIELD:
346 nRet = m_CNTNT.pTextField->GetStart();
347 break;
348 case TEXTINET:
349 nRet = m_CNTNT.pTextINet->GetStart();
350 break;
351 case TEXTTOXMARK:
352 nRet = m_CNTNT.pTextTOX->GetStart();
353 break;
354 case BOOKMARK:
355 nRet = m_CNTNT.pBookmark->GetMarkStart().GetContentIndex();
356 break;
357 case CRSRPOS:
358 nRet = m_CNTNT.pPos->GetContentIndex();
359 break;
360 default:
361 break;
362 }
363 return nRet;
364}
365
366HashStr::HashStr( const OUString& rName, OUString aText,
367 HashStr* pNxt )
368 : SwHash( rName ), aSetStr(std::move( aText ))
369{
370 pNext.reset( pNxt );
371}
372
374OUString LookString( SwHashTable<HashStr> const & rTable, const OUString& rName )
375{
376 HashStr* pFnd = rTable.Find( comphelper::string::strip(rName, ' ') );
377 if( pFnd )
378 return pFnd->aSetStr;
379
380 return OUString();
381}
382
384{
385#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
386 if(maDBData.sDataSource.isEmpty())
387 {
388 // Similar to: SwEditShell::IsAnyDatabaseFieldInDoc
389 for (const auto& pFieldType : *getIDocumentFieldsAccess().GetFieldTypes())
390 {
391 if (IsUsed(*pFieldType))
392 {
393 SwFieldIds nWhich = pFieldType->Which();
394 switch(nWhich)
395 {
400 {
401 std::vector<SwFormatField*> vFields;
402 pFieldType->GatherFields(vFields);
403 if(vFields.size())
404 {
405 if(SwFieldIds::Database == nWhich)
406 maDBData = static_cast<SwDBFieldType*>(vFields.front()->GetField()->GetTyp())->GetDBData();
407 else
408 maDBData = static_cast<SwDBNameInfField*> (vFields.front()->GetField())->GetRealDBData();
409 }
410 }
411 break;
412 default: break;
413 }
414 }
415 }
416 }
417 if(maDBData.sDataSource.isEmpty())
419#endif
420 return maDBData;
421}
422
424{
425#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
426 (void) b;
427#else
429#endif
430}
431
432#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
433
435static OUString lcl_DBDataToString(const SwDBData& rData)
436{
437 return rData.sDataSource + OUStringChar(DB_DELIM)
438 + rData.sCommand + OUStringChar(DB_DELIM)
439 + OUString::number(rData.nCommandType);
440}
441
442#endif
443
444void SwDoc::GetAllUsedDB( std::vector<OUString>& rDBNameList,
445 const std::vector<OUString>* pAllDBNames )
446{
447#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
448 (void) rDBNameList;
449 (void) pAllDBNames;
450#else
451 std::vector<OUString> aUsedDBNames;
452 std::vector<OUString> aAllDBNames;
453
454 if( !pAllDBNames )
455 {
456 GetAllDBNames( aAllDBNames );
457 pAllDBNames = &aAllDBNames;
458 }
459
461 for (auto n = rArr.size(); n; )
462 {
463 SwSection* pSect = rArr[ --n ]->GetSection();
464
465 if( pSect )
466 {
467 AddUsedDBToList( rDBNameList, FindUsedDBs( *pAllDBNames,
468 pSect->GetCondition(), aUsedDBNames ) );
469 aUsedDBNames.clear();
470 }
471 }
472
473 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
474 {
475 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(nWhichHint))
476 {
477 const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
478 const SwTextField* pTextField = pFormatField->GetTextField();
479 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
480 continue;
481
482 const SwField* pField = pFormatField->GetField();
483 switch (pField->GetTyp()->Which())
484 {
486 AddUsedDBToList( rDBNameList,
487 lcl_DBDataToString(static_cast<const SwDBField*>(pField)->GetDBData() ));
488 break;
489
492 AddUsedDBToList( rDBNameList,
493 lcl_DBDataToString(static_cast<const SwDBNameInfField*>(pField)->GetRealDBData() ));
494 break;
495
498 AddUsedDBToList( rDBNameList,
499 lcl_DBDataToString(static_cast<const SwDBNameInfField*>(pField)->GetRealDBData() ));
500 [[fallthrough]]; // JP: is that right like that?
501
504 AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames,
505 pField->GetPar1(), aUsedDBNames ));
506 aUsedDBNames.clear();
507 break;
508
512 AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames,
513 pField->GetFormula(), aUsedDBNames ));
514 aUsedDBNames.clear();
515 break;
516 default: break;
517 }
518 }
519 }
520#endif
521}
522
523void SwDoc::GetAllDBNames( std::vector<OUString>& rAllDBNames )
524{
525#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
526 (void) rAllDBNames;
527#else
528 SwDBManager* pMgr = GetDBManager();
529
530 const SwDSParams_t& rArr = pMgr->GetDSParamArray();
531 for (const auto& pParam : rArr)
532 {
533 rAllDBNames.emplace_back(pParam->sDataSource + OUStringChar(DB_DELIM) + pParam->sCommand);
534 }
535#endif
536}
537
538std::vector<OUString>& SwDoc::FindUsedDBs( const std::vector<OUString>& rAllDBNames,
539 const OUString& rFormula,
540 std::vector<OUString>& rUsedDBNames )
541{
542 const CharClass& rCC = GetAppCharClass();
543#ifndef UNX
544 const OUString sFormula(rCC.uppercase( rFormula ));
545#else
546 const OUString sFormula(rFormula);
547#endif
548
549 for (const auto &sItem : rAllDBNames)
550 {
551 sal_Int32 nPos = sFormula.indexOf( sItem );
552 if( nPos>=0 &&
553 sFormula[ nPos + sItem.getLength() ] == '.' &&
554 (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 )))
555 {
556 // Look up table name
557 nPos += sItem.getLength() + 1;
558 const sal_Int32 nEndPos = sFormula.indexOf('.', nPos);
559 if( nEndPos>=0 )
560 {
561 rUsedDBNames.emplace_back(sItem + OUStringChar(DB_DELIM) + sFormula.subView( nPos, nEndPos - nPos ));
562 }
563 }
564 }
565 return rUsedDBNames;
566}
567
568void SwDoc::AddUsedDBToList( std::vector<OUString>& rDBNameList,
569 const std::vector<OUString>& rUsedDBNames )
570{
571 for ( const auto &sName : rUsedDBNames )
572 AddUsedDBToList( rDBNameList, sName );
573}
574
575void SwDoc::AddUsedDBToList( std::vector<OUString>& rDBNameList, const OUString& rDBName)
576{
577#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
578 (void) rDBNameList;
579 (void) rDBName;
580#else
581 if( rDBName.isEmpty() )
582 return;
583
584#ifdef UNX
585 for( const auto &sName : rDBNameList )
586 if( rDBName == o3tl::getToken(sName, 0, ';') )
587 return;
588#else
589 const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
590 for( const auto &sName : rDBNameList )
591 if( rSCmp.isEqual( rDBName, sName.getToken(0, ';') ) )
592 return;
593#endif
594
596 sal_Int32 nIdx{ 0 };
597 aData.sDataSource = rDBName.getToken(0, DB_DELIM, nIdx);
598 aData.sCommand = rDBName.getToken(0, DB_DELIM, nIdx);
599 aData.nCommandType = -1;
601 rDBNameList.push_back(rDBName);
602#endif
603}
604
605void SwDoc::ChangeDBFields( const std::vector<OUString>& rOldNames,
606 const OUString& rNewName )
607{
608#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
609 (void) rOldNames;
610 (void) rNewName;
611#else
612 SwDBData aNewDBData;
613 sal_Int32 nIdx{ 0 };
614 aNewDBData.sDataSource = rNewName.getToken(0, DB_DELIM, nIdx);
615 aNewDBData.sCommand = rNewName.getToken(0, DB_DELIM, nIdx);
616 aNewDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rNewName, 0, DB_DELIM, nIdx));
617
619 for (auto n = rArr.size(); n; )
620 {
621 SwSection* pSect = rArr[ --n ]->GetSection();
622
623 if( pSect )
624 {
625 pSect->SetCondition(ReplaceUsedDBs(rOldNames, rNewName, pSect->GetCondition()));
626 }
627 }
628
629 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
630 {
631 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(nWhichHint))
632 {
633 SwFormatField* pFormatField = const_cast<SwFormatField*>(static_cast<const SwFormatField*>(pItem));
634 SwTextField* pTextField = pFormatField->GetTextField();
635 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
636 continue;
637
638 SwField* pField = pFormatField->GetField();
639 bool bExpand = false;
640
641 switch( pField->GetTyp()->Which() )
642 {
644#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
645 if (IsNameInArray(rOldNames, lcl_DBDataToString(static_cast<SwDBField*>(pField)->GetDBData())))
646 {
647 SwDBFieldType* pOldTyp = static_cast<SwDBFieldType*>(pField->GetTyp());
648
650 SwDBFieldType(this, pOldTyp->GetColumnName(), aNewDBData)));
651
652 pFormatField->RegisterToFieldType( *pTyp );
653 pField->ChgTyp(pTyp);
654
655 static_cast<SwDBField*>(pField)->ClearInitialized();
656 static_cast<SwDBField*>(pField)->InitContent();
657
658 bExpand = true;
659 }
660#endif
661 break;
662
665 if (IsNameInArray(rOldNames,
666 lcl_DBDataToString(static_cast<SwDBNameInfField*>(pField)->GetRealDBData())))
667 {
668 static_cast<SwDBNameInfField*>(pField)->SetDBData(aNewDBData);
669 bExpand = true;
670 }
671 break;
672
675 if (IsNameInArray(rOldNames,
676 lcl_DBDataToString(static_cast<SwDBNameInfField*>(pField)->GetRealDBData())))
677 {
678 static_cast<SwDBNameInfField*>(pField)->SetDBData(aNewDBData);
679 }
680 [[fallthrough]];
683 pField->SetPar1( ReplaceUsedDBs(rOldNames, rNewName, pField->GetPar1()) );
684 bExpand = true;
685 break;
686
690 pField->SetPar2( ReplaceUsedDBs(rOldNames, rNewName, pField->GetFormula()) );
691 bExpand = true;
692 break;
693 default: break;
694 }
695
696 if (bExpand)
697 pTextField->ExpandTextField( true );
698 }
699 }
701#endif
702}
703
704namespace
705{
706
707OUString lcl_CutOffDBCommandType(const OUString& rName)
708{
709 return rName.replaceFirst(OUStringChar(DB_DELIM), ".").getToken(0, DB_DELIM);
710}
711
712}
713
714OUString SwDoc::ReplaceUsedDBs( const std::vector<OUString>& rUsedDBNames,
715 const OUString& rNewName, const OUString& rFormula )
716{
717 const CharClass& rCC = GetAppCharClass();
718 const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
719 OUString sFormula(rFormula);
720
721 for(const auto & rUsedDBName : rUsedDBNames)
722 {
723 const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBName) );
724
725 if (sDBName!=sNewName)
726 {
727 sal_Int32 nPos = 0;
728 for (;;)
729 {
730 nPos = sFormula.indexOf(sDBName, nPos);
731 if (nPos<0)
732 {
733 break;
734 }
735
736 if( sFormula[nPos + sDBName.getLength()] == '.' &&
737 (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 )))
738 {
739 sFormula = sFormula.replaceAt(nPos, sDBName.getLength(), sNewName);
740 //prevent re-searching - this is useless and provokes
741 //endless loops when names containing each other and numbers are exchanged
742 //e.g.: old ?12345.12345 new: i12345.12345
743 nPos += sNewName.getLength();
744 }
745 }
746 }
747 }
748 return sFormula;
749}
750
751bool SwDoc::IsNameInArray( const std::vector<OUString>& rArr, const OUString& rName )
752{
753#ifdef UNX
754 for( const auto &sName : rArr )
755 if( rName == sName )
756 return true;
757#else
758 const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
759 for( const auto &sName : rArr )
760 if( rSCmp.isEqual( rName, sName ))
761 return true;
762#endif
763 return false;
764}
765
767{
768 const SwFieldTypes::size_type nSize = getIDocumentFieldsAccess().GetFieldTypes()->size();
769
770 for( SwFieldTypes::size_type i = INIT_FLDTYPES; i < nSize; ++i )
771 {
773 if( SwFieldIds::TableOfAuthorities == pFieldType->Which() )
774 {
775 SwAuthorityFieldType* pAuthType = static_cast<SwAuthorityFieldType*>(pFieldType);
776 pAuthType->ChangeEntryContent(pNewData);
777 break;
778 }
779 }
780
781}
782
784{
785 const SwFieldIds nWhich = rField.GetFormatField().GetField()->GetTyp()->Which();
786 switch( nWhich )
787 {
796 break; // these have to be added/removed!
797
798 default:
799 return;
800 }
801
802 SetFieldsDirty( true );
803 if (!m_pFieldSortList)
804 {
805 if( !bIns ) // if list is present and deleted
806 return; // don't do a thing
808 }
809
810 if( bIns ) // insert anew:
811 GetBodyNode( rField, nWhich );
812 else
813 {
814 // look up via the pTextField pointer. It is a sorted list, but it's sorted by node
815 // position. Until this is found, the search for the pointer is already done.
816 for (SetGetExpFields::size_type n = 0; n < m_pFieldSortList->size(); ++n)
817 {
818 if (&rField == (*m_pFieldSortList)[n]->GetPointer())
819 {
820 m_pFieldSortList->erase_at(n);
821 n--; // one field can occur multiple times
822 }
823 }
824 }
825}
826
827void SwDocUpdateField::MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode )
828{
829 if (!m_pFieldSortList || bAll
830 || ((eGetMode & m_nFieldListGetMode) != eGetMode)
831 || rDoc.GetNodes().Count() != m_nNodes)
832 {
833 MakeFieldList_( rDoc, eGetMode );
834 }
835}
836
837void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
838{
839 // new version: walk all fields of the attribute pool
841
842 // remember sections that were unhidden and need to be hidden again
843 std::vector<std::reference_wrapper<SwSection>> aUnhiddenSections;
844
845 // consider and unhide sections
846 // with hide condition, only in mode GETFLD_ALL (<eGetMode == GETFLD_ALL>)
847 // notes by OD:
848 // eGetMode == GETFLD_CALC in call from methods SwDoc::FieldsToCalc
849 // eGetMode == GETFLD_EXPAND in call from method SwDoc::FieldsToExpand
850 // eGetMode == GETFLD_ALL in call from method SwDoc::UpdateExpFields
851 // I figured out that hidden section only have to be shown,
852 // if fields have updated (call by SwDoc::UpdateExpFields) and thus
853 // the hide conditions of section have to be updated.
854 // For correct updating the hide condition of a section, its position
855 // have to be known in order to insert the hide condition as a new
856 // expression field into the sorted field list (<m_pFieldSortList>).
857 if ( eGetMode == GETFLD_ALL )
858 // Collect the sections first. Supply sections that are hidden by condition
859 // with frames so that the contained fields are sorted properly.
860 {
861 // In order for the frames to be created the right way, they have to be expanded
862 // from top to bottom
863 std::vector<SwNodeOffset> aTmpArr;
864 std::vector<SwNodeOffset>::size_type nArrStt = 0;
865 SwSectionFormats& rArr = rDoc.GetSections();
866 SwSectionNode* pSectNd = nullptr;
867 SwNodeOffset nSttContent = rDoc.GetNodes().GetEndOfExtras().GetIndex();
868
869 for (SwSectionFormats::size_type n = rArr.size(); n; )
870 {
871 SwSection* pSect = rArr[ --n ]->GetSection();
872 if( !pSect || !pSect->IsHidden() || pSect->GetCondition().isEmpty() )
873 continue;
874 pSectNd = pSect->GetFormat()->GetSectionNode();
875 if( pSectNd )
876 {
877 SwNodeOffset nIdx = pSectNd->GetIndex();
878 aTmpArr.push_back( nIdx );
879 if( nIdx < nSttContent )
880 ++nArrStt;
881 }
882 }
883 std::sort(aTmpArr.begin(), aTmpArr.end());
884
885 // Display all first so that we have frames. The BodyAnchor is defined by that.
886 // First the ContentArea, then the special areas!
887 for (std::vector<sal_uLong>::size_type n = nArrStt; n < aTmpArr.size(); ++n)
888 {
889 pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode();
890 OSL_ENSURE( pSectNd, "Where is my SectionNode" );
891
892 auto& rSection = pSectNd->GetSection();
893 // unhide and remember the conditionally hidden sections
894 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
895 {
896 aUnhiddenSections.push_back(std::ref(rSection)); // remember to later hide again
897 rSection.SetCondHidden(false);
898 }
899 }
900 for (std::vector<sal_uLong>::size_type n = 0; n < nArrStt; ++n)
901 {
902 pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode();
903 OSL_ENSURE( pSectNd, "Where is my SectionNode" );
904
905 auto& rSection = pSectNd->GetSection();
906 // unhide and remember the conditionally hidden sections
907 if (rSection.IsHidden() && !rSection.GetCondition().isEmpty() && rSection.IsCondHidden())
908 {
909 aUnhiddenSections.push_back(std::ref(rSection)); // remember to later hide again
910 rSection.SetCondHidden(false);
911 }
912 }
913
914 // add all to the list so that they are sorted
915 for (const auto &nId : aTmpArr)
916 {
917 SwSectionNode const& rSectionNode(*rDoc.GetNodes()[ nId ]->GetSectionNode());
918 GetBodyNodeGeneric(rSectionNode, rSectionNode);
919 }
920
921 // bookmarks with hide conditions, handle similar to sections
922 auto const& rIDMA(*rDoc.getIDocumentMarkAccess());
923 for (auto it = rIDMA.getBookmarksBegin(); it != rIDMA.getBookmarksEnd(); ++it)
924 {
925 auto const pBookmark(dynamic_cast<::sw::mark::IBookmark const*>(*it));
926 assert(pBookmark);
927 if (!pBookmark->GetHideCondition().isEmpty())
928 {
929 GetBodyNodeGeneric((*it)->GetMarkStart().GetNode(), *pBookmark);
930 }
931 }
932 }
933
934 static const OUStringLiteral sTrue(u"TRUE");
935 static const OUStringLiteral sFalse(u"FALSE");
936
937#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
938 bool bIsDBManager = nullptr != rDoc.GetDBManager();
939#endif
940
941 for (sal_uInt16 const nWhichHint : { RES_TXTATR_FIELD, RES_TXTATR_INPUTFIELD })
942 {
943 for (const SfxPoolItem* pItem : rDoc.GetAttrPool().GetItemSurrogates(nWhichHint))
944 {
945 const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
946 const SwTextField* pTextField = pFormatField->GetTextField();
947 if (!pTextField || !pTextField->GetTextNode().GetNodes().IsDocNodes())
948 continue;
949
950 OUString sFormula;
951 const SwField* pField = pFormatField->GetField();
952 const SwFieldIds nWhich = pField->GetTyp()->Which();
953 switch (nWhich)
954 {
957 if (GETFLD_ALL == eGetMode)
958 sFormula = sTrue;
959 break;
960
962 if (GETFLD_EXPAND & eGetMode)
963 sFormula = sTrue;
964 break;
965
967 if ((eGetMode != GETFLD_EXPAND) ||
969 {
970 sFormula = sTrue;
971 }
972 break;
973
975 if (GETFLD_ALL == eGetMode)
976 {
977 sFormula = pField->GetPar1();
978 if (sFormula.isEmpty() || sFormula==sFalse)
979 const_cast<SwHiddenParaField*>(static_cast<const SwHiddenParaField*>(pField))->SetHidden( false );
980 else if (sFormula==sTrue)
981 const_cast<SwHiddenParaField*>(static_cast<const SwHiddenParaField*>(pField))->SetHidden( true );
982 else
983 break;
984
985 sFormula.clear();
986 // trigger formatting
987 const_cast<SwFormatField*>(pFormatField)->ForceUpdateTextNode();
988 }
989 break;
990
992 if (GETFLD_ALL == eGetMode)
993 {
994 sFormula = pField->GetPar1();
995 if (sFormula.isEmpty() || sFormula==sFalse)
996 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->SetValue( true );
997 else if (sFormula==sTrue)
998 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->SetValue( false );
999 else
1000 break;
1001
1002 sFormula.clear();
1003
1004 // evaluate field
1005 const_cast<SwHiddenTextField*>(static_cast<const SwHiddenTextField*>(pField))->Evaluate(rDoc);
1006 // trigger formatting
1007 const_cast<SwFormatField*>(pFormatField)->ForceUpdateTextNode();
1008 }
1009 break;
1010
1011#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1013 {
1014 SwDBData aDBData(const_cast<SwDBNumSetField*>(static_cast<const SwDBNumSetField*>(pField))->GetDBData(&rDoc));
1015
1016 if ( (bIsDBManager && rDoc.GetDBManager()->OpenDataSource(aDBData.sDataSource, aDBData.sCommand))
1017 && (GETFLD_ALL == eGetMode
1018 || (GETFLD_CALC & eGetMode
1019 && static_cast<const SwDBNumSetField*>(pField)->IsCondValid()))
1020 )
1021 {
1022 sFormula = pField->GetPar1();
1023 }
1024 }
1025 break;
1027 {
1028 SwDBData aDBData(const_cast<SwDBNextSetField*>(static_cast<const SwDBNextSetField*>(pField))->GetDBData(&rDoc));
1029
1030 if ( (bIsDBManager && rDoc.GetDBManager()->OpenDataSource(aDBData.sDataSource, aDBData.sCommand))
1031 && (GETFLD_ALL == eGetMode
1032 || (GETFLD_CALC & eGetMode
1033 && static_cast<const SwDBNextSetField*>(pField)->IsCondValid()))
1034 )
1035 {
1036 sFormula = pField->GetPar1();
1037 }
1038 }
1039 break;
1040#endif
1041 default: break;
1042 }
1043
1044 if (!sFormula.isEmpty())
1045 {
1046 GetBodyNode( *pTextField, nWhich );
1047 }
1048 }
1049 }
1050 m_nFieldListGetMode = eGetMode;
1051 m_nNodes = rDoc.GetNodes().Count();
1052
1053 // return the conditional hidden value back to the previous value
1054 for (auto& rSectionWrapper : aUnhiddenSections)
1055 {
1056 auto& rSection = rSectionWrapper.get();
1057 rSection.SetCondHidden(true);
1058 }
1059}
1060
1061void SwDocUpdateField::GetBodyNode( const SwTextField& rTField, SwFieldIds nFieldWhich )
1062{
1063 const SwTextNode& rTextNd = rTField.GetTextNode();
1064 const SwDoc& rDoc = rTextNd.GetDoc();
1065
1066 // always the first! (in tab headline, header-/footer)
1067 Point aPt;
1068 std::pair<Point, bool> const tmp(aPt, false);
1069 // need pos to get the frame on the correct page
1070 SwPosition const pos(rTextNd, rTField.GetStart());
1071 const SwFrame* pFrame = rTextNd.getLayoutFrame(
1073
1074 std::unique_ptr<SetGetExpField> pNew;
1075 bool bIsInBody = false;
1076
1077 if( !pFrame || pFrame->IsInDocBody() )
1078 {
1079 bIsInBody = rDoc.GetNodes().GetEndOfExtras().GetIndex() < rTextNd.GetIndex();
1080
1081 // We don't want to update fields in redlines, or those
1082 // in frames whose anchor is in redline. However, we do want to update
1083 // fields in hidden sections. So: In order to be updated, a field 1)
1084 // must have a frame, or 2) it must be in the document body.
1085 if (pFrame == nullptr && bIsInBody)
1086 { // try harder to get a frame for the page number
1087 pFrame = ::sw::FindNeighbourFrameForNode(rTextNd);
1088 // possibly there is no layout at all, happens in mail merge
1089 }
1090 if( (pFrame != nullptr) || bIsInBody )
1091 {
1092 pNew.reset(new SetGetExpField(rTextNd, &rTField, std::nullopt,
1093 pFrame ? pFrame->GetPhyPageNum() : 0));
1094 }
1095 }
1096 else
1097 {
1098 // create index to determine the TextNode
1099 SwPosition aPos( rDoc.GetNodes().GetEndOfPostIts() );
1100 bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame );
1101 OSL_ENSURE(bResult, "where is the Field");
1102 pNew.reset(new SetGetExpField(aPos.GetNode(), &rTField, aPos.GetContentIndex(),
1103 pFrame->GetPhyPageNum()));
1104 }
1105
1106 // always set the BodyTextFlag in GetExp or DB fields
1107 if( SwFieldIds::GetExp == nFieldWhich )
1108 {
1109 SwGetExpField* pGetField = const_cast<SwGetExpField*>(static_cast<const SwGetExpField*>(rTField.GetFormatField().GetField()));
1110 pGetField->ChgBodyTextFlag( bIsInBody );
1111 }
1112#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1113 else if( SwFieldIds::Database == nFieldWhich )
1114 {
1115 SwDBField* pDBField = const_cast<SwDBField*>(static_cast<const SwDBField*>(rTField.GetFormatField().GetField()));
1116 pDBField->ChgBodyTextFlag( bIsInBody );
1117 }
1118#endif
1119 if( pNew != nullptr )
1120 m_pFieldSortList->insert( std::move(pNew) );
1121}
1122
1123template<typename T>
1124void SwDocUpdateField::GetBodyNodeGeneric(SwNode const& rNode, T const& rCond)
1125{
1126 const SwDoc& rDoc = rNode.GetDoc();
1127 std::unique_ptr<SetGetExpField> pNew;
1128
1129 if (rNode.GetIndex() < rDoc.GetNodes().GetEndOfExtras().GetIndex())
1130 {
1131 do { // middle check loop
1132
1133 // we need to get the anchor first
1134 // create index to determine the TextNode
1135 SwPosition aPos(rNode);
1136 SwContentNode const*const pCNd = rNode.IsSectionNode()
1137 ? rDoc.GetNodes().GoNext(&aPos.nNode) // to the next ContentNode
1138 : rNode.GetContentNode();
1139
1140 if( !pCNd || !pCNd->IsTextNode() )
1141 break;
1142
1143 // always the first! (in tab headline, header-/footer)
1144 Point aPt;
1145 std::pair<Point, bool> const tmp(aPt, false);
1146 const SwContentFrame* pFrame = pCNd->getLayoutFrame(
1148 nullptr, &tmp);
1149 if( !pFrame )
1150 break;
1151
1152 bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame );
1153 OSL_ENSURE(bResult, "where is the Field");
1154 pNew.reset(new SetGetExpField(rCond, &aPos, pFrame->GetPhyPageNum()));
1155
1156 } while( false );
1157 }
1158
1159 if( !pNew )
1160 {
1161 // try harder to get a frame for the page number
1162 SwFrame const*const pFrame = ::sw::FindNeighbourFrameForNode(rNode);
1163 pNew.reset(new SetGetExpField(rCond, nullptr, pFrame ? pFrame->GetPhyPageNum() : 0));
1164 }
1165
1166 m_pFieldSortList->insert( std::move(pNew) );
1167}
1168
1170{
1171 OUString sFieldName;
1172 switch( rType.Which() )
1173 {
1174 case SwFieldIds::User :
1175 sFieldName = static_cast<const SwUserFieldType&>(rType).GetName();
1176 break;
1177 case SwFieldIds::SetExp:
1178 sFieldName = static_cast<const SwSetExpFieldType&>(rType).GetName();
1179 break;
1180 default:
1181 OSL_ENSURE( false, "No valid field type" );
1182 }
1183
1184 if( sFieldName.isEmpty() )
1185 return;
1186
1187 SetFieldsDirty( true );
1188 // look up and remove from the hash table
1189 sFieldName = GetAppCharClass().lowercase( sFieldName );
1190 sal_uInt32 n;
1191
1192 SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
1193
1194 if( !pFnd )
1195 {
1196 SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
1197 pNew->pNext.reset( m_FieldTypeTable[n].release() );
1198 m_FieldTypeTable[n].reset(pNew);
1199 }
1200}
1201
1203{
1204 OUString sFieldName;
1205 switch( rType.Which() )
1206 {
1207 case SwFieldIds::User :
1208 sFieldName = static_cast<const SwUserFieldType&>(rType).GetName();
1209 break;
1210 case SwFieldIds::SetExp:
1211 sFieldName = static_cast<const SwSetExpFieldType&>(rType).GetName();
1212 break;
1213 default: break;
1214 }
1215
1216 if( sFieldName.isEmpty() )
1217 return;
1218
1219 SetFieldsDirty( true );
1220 // look up and remove from the hash table
1221 sFieldName = GetAppCharClass().lowercase( sFieldName );
1222 sal_uInt32 n;
1223
1224 SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
1225 if( !pFnd )
1226 return;
1227
1228 if (m_FieldTypeTable[n].get() == pFnd)
1229 {
1230 m_FieldTypeTable[n].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
1231 }
1232 else
1233 {
1234 SwHash* pPrev = m_FieldTypeTable[n].get();
1235 while( pPrev->pNext.get() != pFnd )
1236 pPrev = pPrev->pNext.get();
1237 pPrev->pNext = std::move(pFnd->pNext);
1238 // no need to explicitly delete here, the embedded linked list uses unique_ptr
1239 }
1240}
1241
1243 : m_FieldTypeTable(TBLSZ)
1244 , m_nNodes(0)
1245 , m_nFieldListGetMode(0)
1246 , m_rDoc(rDoc)
1247 , m_bInUpdateFields(false)
1248 , m_bFieldsDirty(false)
1249{
1250}
1251
1253{
1254}
1255
1256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define TBLSZ
Definition: calc.hxx:39
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:339
bool operator<(const SetGetExpField &rField) const
Definition: docfld.cxx:229
const SwNode * GetNodeFromContent() const
Definition: docfld.cxx:291
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:1225
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:2534
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:2314
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:827
SwHashTable< SwCalcFieldType > m_FieldTypeTable
Definition: docfld.hxx:147
SwDocUpdateField(SwDoc &rDocument)
Definition: docfld.cxx:1242
void MakeFieldList_(SwDoc &pDoc, int eGetMode)
Definition: docfld.cxx:837
void InsDelFieldInFieldLst(bool bIns, const SwTextField &rField)
Definition: docfld.cxx:783
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:1061
void InsertFieldType(const SwFieldType &rType)
Definition: docfld.cxx:1169
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:1202
void GetBodyNodeGeneric(SwNode const &rNode, T const &)
Definition: docfld.cxx:1124
Definition: doc.hxx:195
SwDBData const & GetDBData()
Definition: docfld.cxx:383
SwSectionFormats & GetSections()
Definition: doc.hxx:1350
void ChangeAuthorityData(const SwAuthEntry *pNewData)
Definition: docfld.cxx:766
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:402
bool IsUsed(const sw::BroadcastingModify &) const
Definition: poolfmt.cxx:86
SwDBManager * GetDBManager() const
Definition: doc.hxx:681
SwDBData maDBData
Definition: doc.hxx:210
void AddUsedDBToList(std::vector< OUString > &rDBNameList, const std::vector< OUString > &rUsedDBNames)
Definition: docfld.cxx:568
SwNodes & GetNodes()
Definition: doc.hxx:420
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:365
static OUString ReplaceUsedDBs(const std::vector< OUString > &rUsedDBNames, const OUString &rNewName, const OUString &rFormula)
Definition: docfld.cxx:714
static bool IsNameInArray(const std::vector< OUString > &rOldNames, const OUString &rName)
Definition: docfld.cxx:751
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1877
void SetInitDBFields(bool b)
Definition: docfld.cxx:423
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1331
void GetAllDBNames(std::vector< OUString > &rAllDBNames)
Definition: docfld.cxx:523
void GetAllUsedDB(std::vector< OUString > &rDBNameList, const std::vector< OUString > *pAllDBNames=nullptr)
Definition: docfld.cxx:444
static std::vector< OUString > & FindUsedDBs(const std::vector< OUString > &rAllDBNames, const OUString &rFormula, std::vector< OUString > &rUsedDBNames)
Definition: docfld.cxx:538
void ChangeDBFields(const std::vector< OUString > &rOldNames, const OUString &rNewName)
Definition: docfld.cxx:605
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:244
SwFieldIds Which() const
Definition: fldbas.hxx:275
Base class of all fields.
Definition: fldbas.hxx:295
virtual OUString GetFormula() const
Definition: fldbas.cxx:335
virtual OUString GetPar1() const
Definition: fldbas.cxx:325
virtual void SetPar1(const OUString &rStr)
Definition: fldbas.cxx:340
virtual void SetPar2(const OUString &rStr)
Definition: fldbas.cxx:343
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:346
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
Definition: fldbas.cxx:406
SwFieldType * GetTyp() const
Definition: fldbas.hxx:401
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:154
T * Find(std::u16string_view aStr, sal_uInt32 *pPos=nullptr) const
Definition: calc.hxx:165
void SetHidden(bool bHidden)
Definition: docufld.hxx:375
void Evaluate(SwDoc &rDoc)
get current field value and cache it
Definition: docufld.cxx:1341
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:903
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:744
SwDoc & GetDoc()
Definition: node.hxx:233
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
bool IsSectionNode() const
Definition: node.hxx:695
bool IsTextNode() const
Definition: node.hxx:687
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:2538
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:311
SwNodeOffset Count() const
Definition: ndarr.hxx:142
SwSectionNode * GetSectionNode()
Definition: section.cxx:931
Array of Undo-history.
Definition: docary.hxx:192
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:339
void SetCondition(OUString const &rNew)
Definition: section.hxx:202
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:436
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:488
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:524
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:166
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:467
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:66
size_t size() const
Definition: docary.hxx:87
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:1215
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:374
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:46
@ Database
For old documents the Field-Which IDs must be preserved !!!
@ TableOfAuthorities
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:800
CharClass & GetAppCharClass()
Definition: init.cxx:719
sal_Int64 n
sal_uInt16 nPos
const char * sName
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
OString strip(const OString &rIn, char c)
int i
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:204
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:366
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
OUString sDataSource
Definition: swdbdata.hxx:30
OUString sCommand
Definition: swdbdata.hxx:31
Definition: calc.hxx:135
std::unique_ptr< SwHash > pNext
Definition: calc.hxx:139
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
SwNodeIndex nNode
Definition: pam.hxx:38
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
UNDERLYING_TYPE get() const
#define INIT_FLDTYPES
Definition: swtypes.hxx:105
#define DB_DELIM
Definition: swtypes.hxx:130
size_t pos