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