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