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