LibreOffice Module sw (master)  1
reffld.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 <com/sun/star/text/ReferenceFieldPart.hpp>
21 #include <com/sun/star/text/ReferenceFieldSource.hpp>
22 #include <o3tl/unreachable.hxx>
24 #include <unotools/charclass.hxx>
25 #include <doc.hxx>
28 #include <IDocumentMarkAccess.hxx>
29 #include <pam.hxx>
30 #include <cntfrm.hxx>
31 #include <pagefrm.hxx>
32 #include <rootfrm.hxx>
33 #include <modeltoviewhelper.hxx>
34 #include <fmtfld.hxx>
35 #include <txtfld.hxx>
36 #include <txtftn.hxx>
37 #include <fmtrfmrk.hxx>
38 #include <txtrfmrk.hxx>
39 #include <fmtftn.hxx>
40 #include <ndtxt.hxx>
41 #include <chpfld.hxx>
42 #include <reffld.hxx>
43 #include <expfld.hxx>
44 #include <txtfrm.hxx>
45 #include <flyfrm.hxx>
46 #include <pagedesc.hxx>
47 #include <IMark.hxx>
48 #include <crossrefbookmark.hxx>
49 #include <ftnidx.hxx>
50 #include <viewsh.hxx>
51 #include <unofldmid.h>
52 #include <SwStyleNameMapper.hxx>
53 #include <shellres.hxx>
54 #include <poolfmt.hxx>
55 #include <strings.hrc>
56 #include <numrule.hxx>
57 #include <SwNodeNum.hxx>
58 #include <calbck.hxx>
59 
60 #include <cstddef>
61 #include <memory>
62 #include <vector>
63 #include <set>
64 #include <string_view>
65 #include <map>
66 #include <algorithm>
67 
68 using namespace ::com::sun::star;
69 using namespace ::com::sun::star::text;
70 using namespace ::com::sun::star::lang;
71 
72 static std::pair<OUString, bool> MakeRefNumStr(SwRootFrame const* pLayout,
73  const SwTextNode& rTextNodeOfField,
74  const SwTextNode& rTextNodeOfReferencedItem,
75  sal_uInt32 nRefNumFormat);
76 
77 static void lcl_GetLayTree( const SwFrame* pFrame, std::vector<const SwFrame*>& rArr )
78 {
79  while( pFrame )
80  {
81  if( pFrame->IsBodyFrame() ) // unspectacular
82  pFrame = pFrame->GetUpper();
83  else
84  {
85  rArr.push_back( pFrame );
86 
87  // this is the last page
88  if( pFrame->IsPageFrame() )
89  break;
90 
91  if( pFrame->IsFlyFrame() )
92  pFrame = static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame();
93  else
94  pFrame = pFrame->GetUpper();
95  }
96  }
97 }
98 
99 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos,
100  const SwTextNode& rBehindNd, sal_Int32 nSttPos )
101 {
102  const SwTextFrame * pMyFrame = static_cast<SwTextFrame*>(rMyNd.getLayoutFrame(
103  rMyNd.GetDoc().getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr));
104  const SwTextFrame * pFrame = static_cast<SwTextFrame*>(rBehindNd.getLayoutFrame(
105  rBehindNd.GetDoc().getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, nullptr));
106 
107  if( !pFrame || !pMyFrame)
108  return false;
109 
110  TextFrameIndex const nMySttPosIndex(pMyFrame->MapModelToView(&rMyNd, nMySttPos));
111  TextFrameIndex const nSttPosIndex(pFrame->MapModelToView(&rBehindNd, nSttPos));
112  while (pFrame && !pFrame->IsInside(nSttPosIndex))
113  pFrame = pFrame->GetFollow();
114  while (pMyFrame && !pMyFrame->IsInside(nMySttPosIndex))
115  pMyFrame = pMyFrame->GetFollow();
116 
117  if( !pFrame || !pMyFrame || pFrame == pMyFrame )
118  return false;
119 
120  std::vector<const SwFrame*> aRefArr, aArr;
121  ::lcl_GetLayTree( pFrame, aRefArr );
122  ::lcl_GetLayTree( pMyFrame, aArr );
123 
124  size_t nRefCnt = aRefArr.size() - 1, nCnt = aArr.size() - 1;
125  bool bVert = false;
126  bool bR2L = false;
127 
128  // Loop as long as a frame does not equal?
129  while( nRefCnt && nCnt && aRefArr[ nRefCnt ] == aArr[ nCnt ] )
130  {
131  const SwFrame* pTmpFrame = aArr[ nCnt ];
132  bVert = pTmpFrame->IsVertical();
133  bR2L = pTmpFrame->IsRightToLeft();
134  --nCnt;
135  --nRefCnt;
136  }
137 
138  // If a counter overflows?
139  if( aRefArr[ nRefCnt ] == aArr[ nCnt ] )
140  {
141  if( nCnt )
142  --nCnt;
143  else
144  --nRefCnt;
145  }
146 
147  const SwFrame* pRefFrame = aRefArr[ nRefCnt ];
148  const SwFrame* pFieldFrame = aArr[ nCnt ];
149 
150  // different frames, check their Y-/X-position
151  bool bRefIsLower = false;
152  if( ( SwFrameType::Column | SwFrameType::Cell ) & pFieldFrame->GetType() ||
153  ( SwFrameType::Column | SwFrameType::Cell ) & pRefFrame->GetType() )
154  {
155  if( pFieldFrame->GetType() == pRefFrame->GetType() )
156  {
157  // here, the X-pos is more important
158  if( bVert )
159  {
160  if( bR2L )
161  bRefIsLower = pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() ||
162  ( pRefFrame->getFrameArea().Top() == pFieldFrame->getFrameArea().Top() &&
163  pRefFrame->getFrameArea().Left() < pFieldFrame->getFrameArea().Left() );
164  else
165  bRefIsLower = pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() ||
166  ( pRefFrame->getFrameArea().Top() == pFieldFrame->getFrameArea().Top() &&
167  pRefFrame->getFrameArea().Left() > pFieldFrame->getFrameArea().Left() );
168  }
169  else if( bR2L )
170  bRefIsLower = pRefFrame->getFrameArea().Left() > pFieldFrame->getFrameArea().Left() ||
171  ( pRefFrame->getFrameArea().Left() == pFieldFrame->getFrameArea().Left() &&
172  pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() );
173  else
174  bRefIsLower = pRefFrame->getFrameArea().Left() < pFieldFrame->getFrameArea().Left() ||
175  ( pRefFrame->getFrameArea().Left() == pFieldFrame->getFrameArea().Left() &&
176  pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() );
177  pRefFrame = nullptr;
178  }
179  else if( ( SwFrameType::Column | SwFrameType::Cell ) & pFieldFrame->GetType() )
180  pFieldFrame = aArr[ nCnt - 1 ];
181  else
182  pRefFrame = aRefArr[ nRefCnt - 1 ];
183  }
184 
185  if( pRefFrame ) // misuse as flag
186  {
187  if( bVert )
188  {
189  if( bR2L )
190  bRefIsLower = pRefFrame->getFrameArea().Left() < pFieldFrame->getFrameArea().Left() ||
191  ( pRefFrame->getFrameArea().Left() == pFieldFrame->getFrameArea().Left() &&
192  pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() );
193  else
194  bRefIsLower = pRefFrame->getFrameArea().Left() > pFieldFrame->getFrameArea().Left() ||
195  ( pRefFrame->getFrameArea().Left() == pFieldFrame->getFrameArea().Left() &&
196  pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() );
197  }
198  else if( bR2L )
199  bRefIsLower = pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() ||
200  ( pRefFrame->getFrameArea().Top() == pFieldFrame->getFrameArea().Top() &&
201  pRefFrame->getFrameArea().Left() > pFieldFrame->getFrameArea().Left() );
202  else
203  bRefIsLower = pRefFrame->getFrameArea().Top() < pFieldFrame->getFrameArea().Top() ||
204  ( pRefFrame->getFrameArea().Top() == pFieldFrame->getFrameArea().Top() &&
205  pRefFrame->getFrameArea().Left() < pFieldFrame->getFrameArea().Left() );
206  }
207  return bRefIsLower;
208 }
209 
210 // tdf#115319 create alternative reference formats, if the user asked for it
211 // (ReferenceFieldLanguage attribute of the reference field is not empty), and
212 // language of the text and ReferenceFieldLanguage are the same.
213 // Right now only HUNGARIAN seems to need this (as in the related issue,
214 // the reversed caption order in autocaption, solved by #i61007#)
215 static void lcl_formatReferenceLanguage( OUString& rRefText,
216  bool bClosingParenthesis, LanguageType eLang,
217  std::u16string_view rReferenceLanguage)
218 {
219  if (eLang != LANGUAGE_HUNGARIAN || (rReferenceLanguage != u"hu" && rReferenceLanguage != u"Hu"))
220  return;
221 
222  // Add Hungarian definitive article (a/az) before references,
223  // similar to \aref, \apageref etc. of LaTeX Babel package.
224  //
225  // for example:
226  //
227  // "az 1. oldalon" ("on page 1"), but
228  // "a 2. oldalon" ("on page 2")
229  // "a fentebbi", "az alábbi" (above/below)
230  // "a Lorem", "az Ipsum"
231  //
232  // Support following numberings of EU publications:
233  //
234  // 1., 1a., a), (1), (1a), iii., III., IA.
235  //
236  // (http://publications.europa.eu/code/hu/hu-120700.htm,
237  // http://publications.europa.eu/code/hu/hu-4100600.htm)
238 
239  LanguageTag aLanguageTag(eLang);
240  CharClass aCharClass( aLanguageTag );
241  sal_Int32 nLen = rRefText.getLength();
242  sal_Int32 i;
243  // substring of rRefText starting with letter or number
244  OUString sNumbering;
245  // is article "az"?
246  bool bArticleAz = false;
247  // is numbering a number?
248  bool bNum = false;
249 
250  // search first member of the numbering (numbers or letters)
251  for (i=0; i<nLen && (sNumbering.isEmpty() ||
252  ((bNum && aCharClass.isDigit(rRefText, i)) ||
253  (!bNum && aCharClass.isLetter(rRefText, i)))); ++i)
254  {
255  // start of numbering within the field text
256  if (sNumbering.isEmpty() && aCharClass.isLetterNumeric(rRefText, i)) {
257  sNumbering = rRefText.copy(i);
258  bNum = aCharClass.isDigit(rRefText, i);
259  }
260  }
261 
262  // length of numbering
263  nLen = i - (rRefText.getLength() - sNumbering.getLength());
264 
265  if (bNum)
266  {
267  // az 1, 1000, 1000000, 1000000000...
268  // az 5, 50, 500...
269  if ((sNumbering.startsWith("1") && (nLen == 1 || nLen == 4 || nLen == 7 || nLen == 10)) ||
270  sNumbering.startsWith("5"))
271  bArticleAz = true;
272  }
273  else if (nLen == 1 && sNumbering[0] < 128)
274  {
275  // ASCII 1-letter numbering
276  // az a), e), f) ... x)
277  // az i., v. (but, a x.)
278  static const std::u16string_view sLettersStartingWithVowels = u"aefilmnorsuxyAEFILMNORSUXY";
279  if (sLettersStartingWithVowels.find(sNumbering[0]) != std::u16string_view::npos)
280  {
281  // x), X) are letters, but x. and X. etc. are Roman numbers
282  if (bClosingParenthesis ||
283  (sNumbering[0] != 'x' && sNumbering[0] != 'X'))
284  bArticleAz = true;
285  } else if ((sNumbering[0] == 'v' || sNumbering[0] == 'V') && !bClosingParenthesis)
286  // v), V) are letters, but v. and V. are Roman numbers
287  bArticleAz = true;
288  }
289  else
290  {
291  static const sal_Unicode sVowelsWithDiacritic[] = {
292  0x00E1, 0x00C1, 0x00E9, 0x00C9, 0x00ED, 0x00CD,
293  0x00F3, 0x00D3, 0x00F6, 0x00D6, 0x0151, 0x0150,
294  0x00FA, 0x00DA, 0x00FC, 0x00DC, 0x0171, 0x0170, 0 };
295  static const OUString sVowels = OUString::Concat(u"aAeEiIoOuU") + sVowelsWithDiacritic;
296 
297  // handle more than 1-letter long Roman numbers and
298  // their possible combinations with letters:
299  // az IA, a IIB, a IIIC., az Ia, a IIb., a iiic), az LVIII. szonett
300  bool bRomanNumber = false;
301  if (nLen > 1 && (nLen + 1 >= sNumbering.getLength() || sNumbering[nLen] == '.'))
302  {
303  sal_Unicode last = sNumbering[nLen - 1];
304  OUString sNumberingTrim;
305  if ((last >= 'A' && last < 'I') || (last >= 'a' && last < 'i'))
306  sNumberingTrim = sNumbering.copy(0, nLen - 1);
307  else
308  sNumberingTrim = sNumbering.copy(0, nLen);
309  bRomanNumber =
310  sNumberingTrim.replaceAll("i", "").replaceAll("v", "").replaceAll("x", "").replaceAll("l", "").replaceAll("c", "").isEmpty() ||
311  sNumberingTrim.replaceAll("I", "").replaceAll("V", "").replaceAll("X", "").replaceAll("L", "").replaceAll("C", "").isEmpty();
312  }
313 
314  if (
315  // Roman number and a letter optionally
316  ( bRomanNumber && (
317  (sNumbering[0] == 'i' && sNumbering[1] != 'i' && sNumbering[1] != 'v' && sNumbering[1] != 'x') ||
318  (sNumbering[0] == 'I' && sNumbering[1] != 'I' && sNumbering[1] != 'V' && sNumbering[1] != 'X') ||
319  (sNumbering[0] == 'v' && sNumbering[1] != 'i') ||
320  (sNumbering[0] == 'V' && sNumbering[1] != 'I') ||
321  (sNumbering[0] == 'l' && sNumbering[1] != 'x') ||
322  (sNumbering[0] == 'L' && sNumbering[1] != 'X')) ) ||
323  // a word starting with vowel (not Roman number)
324  ( !bRomanNumber && sVowels.indexOf(sNumbering[0]) != -1))
325  {
326  bArticleAz = true;
327  }
328  }
329  // not a title text starting already with a definitive article
330  if ( sNumbering.startsWith("A ") || sNumbering.startsWith("Az ") ||
331  sNumbering.startsWith("a ") || sNumbering.startsWith("az ") )
332  return;
333 
334  // lowercase, if rReferenceLanguage == "hu", not "Hu"
335  OUString sArticle;
336 
337  if ( rReferenceLanguage == u"hu" )
338  sArticle = "a";
339  else
340  sArticle = "A";
341 
342  if (bArticleAz)
343  sArticle += "z";
344 
345  rRefText = sArticle + " " + rRefText;
346 }
347 
350  const OUString& rSetRef, const OUString& rSetReferenceLanguage, sal_uInt16 nSubTyp,
351  sal_uInt16 nSequenceNo, sal_uLong nFormat )
352  : SwField( pFieldType, nFormat ),
353  m_sSetRefName( rSetRef ),
354  m_sSetReferenceLanguage( rSetReferenceLanguage ),
355  m_nSubType( nSubTyp ),
356  m_nSeqNo( nSequenceNo )
357 {
358 }
359 
361 {
362 }
363 
365 {
366  return SwResId(STR_REFERENCE);
367 }
368 
369 sal_uInt16 SwGetRefField::GetSubType() const
370 {
371  return m_nSubType;
372 }
373 
374 void SwGetRefField::SetSubType( sal_uInt16 n )
375 {
376  m_nSubType = n;
377 }
378 
379 // #i81002#
381 {
382  return GetSubType() == REF_BOOKMARK &&
384 }
385 
387 {
388  return GetSubType() == REF_BOOKMARK &&
390 }
391 
393 {
394  SwGetRefFieldType *pTyp = dynamic_cast<SwGetRefFieldType*>(GetTyp());
395  if (!pTyp)
396  return nullptr;
397  sal_Int32 nDummy = -1;
399 }
400 
401 // strikethrough for tooltips using Unicode combining character
402 static OUString lcl_formatStringByCombiningCharacter(const OUString& sText, const sal_Unicode cChar)
403 {
404  OUStringBuffer sRet;
405  for (sal_Int32 i = 0; i < sText.getLength(); ++i)
406  {
407  sRet.append(sText[i]);
408  sRet.append(cChar);
409  }
410  return sRet.makeStringAndClear();
411 }
412 
413 // #i85090#
415  SwRootFrame const& rLayout) const
416 {
417  const SwTextNode* pReferencedTextNode( GetReferencedTextNode() );
418  if ( !pReferencedTextNode )
419  return OUString();
420 
421  // show the referenced text without the deletions, but if the whole text was
422  // deleted, show the original text for the sake of the comfortable reviewing,
423  // but with Unicode strikethrough in the tooltip
424  OUString sRet = sw::GetExpandTextMerged(&rLayout, *pReferencedTextNode, true, false, ExpandMode::HideDeletions);
425  if ( sRet.isEmpty() )
426  {
427  static const sal_Unicode cStrikethrough = u'\x0336';
428  sRet = sw::GetExpandTextMerged(&rLayout, *pReferencedTextNode, true, false, ExpandMode(0));
429  sRet = lcl_formatStringByCombiningCharacter( sRet, cStrikethrough );
430  }
431  return sRet;
432 }
433 
434 void SwGetRefField::SetExpand( const OUString& rStr )
435 {
436  m_sText = rStr;
437  m_sTextRLHidden = rStr;
438 }
439 
440 OUString SwGetRefField::ExpandImpl(SwRootFrame const*const pLayout) const
441 {
442  return pLayout && pLayout->IsHideRedlines() ? m_sTextRLHidden : m_sText;
443 }
444 
446 {
447  const OUString aName = GetTyp()->GetName();
448  if ( !aName.isEmpty() || !m_sSetRefName.isEmpty() )
449  {
450  return aName + " " + m_sSetRefName;
451  }
452  return ExpandImpl(nullptr);
453 }
454 
455 
456 static void FilterText(OUString & rText, LanguageType const eLang,
457  std::u16string_view rSetReferenceLanguage)
458 {
459  // remove all special characters (replace them with blanks)
460  if (rText.isEmpty())
461  return;
462 
463  rText = rText.replaceAll(u"\u00ad", "");
464  OUStringBuffer aBuf(rText);
465  const sal_Int32 l = aBuf.getLength();
466  for (sal_Int32 i = 0; i < l; ++i)
467  {
468  if (aBuf[i] < ' ')
469  {
470  aBuf[i] = ' ';
471  }
472  else if (aBuf[i] == 0x2011)
473  {
474  aBuf[i] = '-';
475  }
476  }
477  rText = aBuf.makeStringAndClear();
478  if (!rSetReferenceLanguage.empty())
479  {
480  lcl_formatReferenceLanguage(rText, false, eLang, rSetReferenceLanguage);
481  }
482 }
483 
484 // #i81002# - parameter <pFieldTextAttr> added
485 void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
486 {
487  m_sText.clear();
488  m_sTextRLHidden.clear();
489 
490  SwDoc& rDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
491  // finding the reference target (the number)
492  sal_Int32 nNumStart = -1;
493  sal_Int32 nNumEnd = -1;
495  &rDoc, m_sSetRefName, m_nSubType, m_nSeqNo, &nNumStart, &nNumEnd
496  );
497  // not found?
498  if ( !pTextNd )
499  {
502  return ;
503  }
504 
505  SwRootFrame const* pLayout(nullptr);
506  SwRootFrame const* pLayoutRLHidden(nullptr);
507  for (SwRootFrame const*const pLay : rDoc.GetAllLayouts())
508  {
509  if (pLay->IsHideRedlines())
510  {
511  pLayoutRLHidden = pLay;
512  }
513  else
514  {
515  pLayout = pLay;
516  }
517  }
518 
519  // where is the category name (e.g. "Illustration")?
520  const OUString aText = pTextNd->GetText();
521  const sal_Int32 nCatStart = aText.indexOf(m_sSetRefName);
522  const bool bHasCat = nCatStart>=0;
523  const sal_Int32 nCatEnd = bHasCat ? nCatStart + m_sSetRefName.getLength() : -1;
524 
525  // length of the referenced text
526  const sal_Int32 nLen = aText.getLength();
527 
528  // which format?
529  switch( GetFormat() )
530  {
531  case REF_CONTENT:
532  case REF_ONLYNUMBER:
533  case REF_ONLYCAPTION:
534  case REF_ONLYSEQNO:
535  {
536  // needed part of Text
537  sal_Int32 nStart;
538  sal_Int32 nEnd;
539 
540  switch( m_nSubType )
541  {
542  case REF_SEQUENCEFLD:
543 
544  switch( GetFormat() )
545  {
546  // "Category and Number"
547  case REF_ONLYNUMBER:
548  if (bHasCat) {
549  nStart = std::min(nNumStart, nCatStart);
550  nEnd = std::max(nNumEnd, nCatEnd);
551  } else {
552  nStart = nNumStart;
553  nEnd = nNumEnd;
554  }
555  break;
556 
557  // "Caption Text"
558  case REF_ONLYCAPTION: {
559  // next alphanumeric character after category+number
560  if (const SwTextAttr* const pTextAttr =
561  pTextNd->GetTextAttrForCharAt(nNumStart, RES_TXTATR_FIELD)
562  ) {
563  // start searching from nFrom
564  const sal_Int32 nFrom = bHasCat
565  ? std::max(nNumStart + 1, nCatEnd)
566  : nNumStart + 1;
567  nStart = SwGetExpField::GetReferenceTextPos( pTextAttr->GetFormatField(), rDoc, nFrom );
568  } else {
569  nStart = bHasCat ? std::max(nNumEnd, nCatEnd) : nNumEnd;
570  }
571  nEnd = nLen;
572  break;
573  }
574 
575  // "Numbering"
576  case REF_ONLYSEQNO:
577  nStart = nNumStart;
578  nEnd = std::min(nStart + 1, nLen);
579  break;
580 
581  // "Reference" (whole Text)
582  case REF_CONTENT:
583  nStart = 0;
584  nEnd = nLen;
585  break;
586 
587  default:
589  }
590  break;
591 
592  case REF_BOOKMARK:
593  nStart = nNumStart;
594  // text is spread across multiple nodes - get whole text or only until end of node?
595  nEnd = nNumEnd<0 ? nLen : nNumEnd;
596  break;
597 
598  case REF_OUTLINE:
599  nStart = nNumStart;
600  nEnd = nNumEnd;
601  break;
602 
603  case REF_FOOTNOTE:
604  case REF_ENDNOTE:
605  // get number or numString
606  for( size_t i = 0; i < rDoc.GetFootnoteIdxs().size(); ++i )
607  {
608  SwTextFootnote* const pFootnoteIdx = rDoc.GetFootnoteIdxs()[i];
609  if( m_nSeqNo == pFootnoteIdx->GetSeqRefNo() )
610  {
611  m_sText = pFootnoteIdx->GetFootnote().GetViewNumStr(rDoc, nullptr);
612  m_sTextRLHidden = pFootnoteIdx->GetFootnote().GetViewNumStr(rDoc, pLayoutRLHidden);
613  if (!m_sSetReferenceLanguage.isEmpty())
614  {
617  }
618  break;
619  }
620  }
621  return;
622 
623  case REF_SETREFATTR:
624  nStart = nNumStart;
625  nEnd = nNumEnd;
626  break;
627 
628  default:
630  }
631 
632  if( nStart != nEnd ) // a section?
633  {
634  m_sText = pTextNd->GetExpandText(pLayout, nStart, nEnd - nStart, false, false, false, ExpandMode::HideDeletions);
635  // show the referenced text without the deletions, but if the whole text was
636  // deleted, show the original text for the sake of the comfortable reviewing
637  // (with strikethrough in tooltip, see GetExpandedTextOfReferencedTextNode())
638  if ( m_sText.isEmpty() )
639  m_sText = pTextNd->GetExpandText(pLayout, nStart, nEnd - nStart, false, false, false, ExpandMode(0));
640 
641  if (m_nSubType == REF_OUTLINE
643  {
645  pLayoutRLHidden, *pTextNd, false, false, ExpandMode(0));
646  }
647  else
648  {
649  m_sTextRLHidden = pTextNd->GetExpandText(pLayoutRLHidden,
650  nStart, nEnd - nStart, false, false, false, ExpandMode::HideDeletions);
651  }
654  }
655  }
656  break;
657 
658  case REF_PAGE:
659  case REF_PAGE_PGDESC:
660  {
661  auto const func =
662  [this, pTextNd, nNumStart](OUString & rText, SwRootFrame const*const pLay)
663  {
664  SwTextFrame const* pFrame = static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLay, nullptr, nullptr));
665  SwTextFrame const*const pSave = pFrame;
666  if (pFrame)
667  {
668  TextFrameIndex const nNumStartIndex(pFrame->MapModelToView(pTextNd, nNumStart));
669  while (pFrame && !pFrame->IsInside(nNumStartIndex))
670  pFrame = pFrame->GetFollow();
671  }
672 
673  if( pFrame || nullptr != ( pFrame = pSave ))
674  {
675  sal_uInt16 nPageNo = pFrame->GetVirtPageNum();
676  const SwPageFrame *pPage;
677  if( REF_PAGE_PGDESC == GetFormat() &&
678  nullptr != ( pPage = pFrame->FindPageFrame() ) &&
679  pPage->GetPageDesc() )
680  {
681  rText = pPage->GetPageDesc()->GetNumType().GetNumStr(nPageNo);
682  }
683  else
684  {
685  rText = OUString::number(nPageNo);
686  }
687 
688  if (!m_sSetReferenceLanguage.isEmpty())
690  }
691  };
692  // sw_redlinehide: currently only one of these layouts will exist,
693  // so the getLayoutFrame will use the same frame in both cases
694  func(m_sText, pLayout);
695  func(m_sTextRLHidden, pLayoutRLHidden);
696  }
697  break;
698 
699  case REF_CHAPTER:
700  {
701  auto const func =
702  [this, pTextNd](OUString & rText, SwRootFrame const*const pLay)
703  {
704  // a bit tricky: search any frame
705  SwFrame const*const pFrame = pTextNd->getLayoutFrame(pLay);
706  if( pFrame )
707  {
708  SwChapterFieldType aFieldTyp;
709  SwChapterField aField( &aFieldTyp, 0 );
710  aField.SetLevel( MAXLEVEL - 1 );
711  aField.ChangeExpansion( *pFrame, pTextNd, true );
712  rText = aField.GetNumber(pLay);
713 
714  if (!m_sSetReferenceLanguage.isEmpty())
716  }
717  };
718  func(m_sText, pLayout);
719  func(m_sTextRLHidden, pLayoutRLHidden);
720  }
721  break;
722 
723  case REF_UPDOWN:
724  {
725  // #i81002#
726  // simplified: use parameter <pFieldTextAttr>
727  if( !pFieldTextAttr || !pFieldTextAttr->GetpTextNode() )
728  break;
729 
730  LanguageTag aLanguageTag( GetLanguage());
731  LocaleDataWrapper aLocaleData( aLanguageTag );
732 
733  // first a "short" test - in case both are in the same node
734  if( pFieldTextAttr->GetpTextNode() == pTextNd )
735  {
736  m_sText = nNumStart < pFieldTextAttr->GetStart()
737  ? aLocaleData.getAboveWord()
738  : aLocaleData.getBelowWord();
740  break;
741  }
742 
743  m_sText = ::IsFrameBehind( *pFieldTextAttr->GetpTextNode(), pFieldTextAttr->GetStart(),
744  *pTextNd, nNumStart )
745  ? aLocaleData.getAboveWord()
746  : aLocaleData.getBelowWord();
747 
748  if (!m_sSetReferenceLanguage.isEmpty())
750 
752  }
753  break;
754  // #i81002#
755  case REF_NUMBER:
758  {
759  if ( pFieldTextAttr && pFieldTextAttr->GetpTextNode() )
760  {
761  auto result =
762  MakeRefNumStr(pLayout, pFieldTextAttr->GetTextNode(), *pTextNd, GetFormat());
763  m_sText = result.first;
764  // for differentiation of Roman numbers and letters in Hungarian article handling
765  bool bClosingParenthesis = result.second;
766  if (!m_sSetReferenceLanguage.isEmpty())
767  {
768  lcl_formatReferenceLanguage(m_sText, bClosingParenthesis, GetLanguage(), m_sSetReferenceLanguage);
769  }
770  result =
771  MakeRefNumStr(pLayoutRLHidden, pFieldTextAttr->GetTextNode(), *pTextNd, GetFormat());
772  m_sTextRLHidden = result.first;
773  bClosingParenthesis = result.second;
774  if (!m_sSetReferenceLanguage.isEmpty())
775  {
776  lcl_formatReferenceLanguage(m_sTextRLHidden, bClosingParenthesis, GetLanguage(), m_sSetReferenceLanguage);
777  }
778  }
779  }
780  break;
781 
782  default:
783  OSL_FAIL("<SwGetRefField::UpdateField(..)> - unknown format type");
784  }
785 }
786 
787 // #i81002#
788 static std::pair<OUString, bool> MakeRefNumStr(
789  SwRootFrame const*const pLayout,
790  const SwTextNode& i_rTextNodeOfField,
791  const SwTextNode& i_rTextNodeOfReferencedItem,
792  const sal_uInt32 nRefNumFormat)
793 {
794  SwTextNode const& rTextNodeOfField(pLayout
795  ? *sw::GetParaPropsNode(*pLayout, i_rTextNodeOfField)
796  : i_rTextNodeOfField);
797  SwTextNode const& rTextNodeOfReferencedItem(pLayout
798  ? *sw::GetParaPropsNode(*pLayout, i_rTextNodeOfReferencedItem)
799  : i_rTextNodeOfReferencedItem);
800  if ( rTextNodeOfReferencedItem.HasNumber(pLayout) &&
801  rTextNodeOfReferencedItem.IsCountedInList() )
802  {
803  OSL_ENSURE( rTextNodeOfReferencedItem.GetNum(pLayout),
804  "<SwGetRefField::MakeRefNumStr(..)> - referenced paragraph has number, but no <SwNodeNum> instance!" );
805 
806  // Determine, up to which level the superior list labels have to be
807  // included - default is to include all superior list labels.
808  int nRestrictInclToThisLevel( 0 );
809  // Determine for format REF_NUMBER the level, up to which the superior
810  // list labels have to be restricted, if the text node of the reference
811  // field and the text node of the referenced item are in the same
812  // document context.
813  if ( nRefNumFormat == REF_NUMBER &&
814  rTextNodeOfField.FindFlyStartNode()
815  == rTextNodeOfReferencedItem.FindFlyStartNode() &&
816  rTextNodeOfField.FindFootnoteStartNode()
817  == rTextNodeOfReferencedItem.FindFootnoteStartNode() &&
818  rTextNodeOfField.FindHeaderStartNode()
819  == rTextNodeOfReferencedItem.FindHeaderStartNode() &&
820  rTextNodeOfField.FindFooterStartNode()
821  == rTextNodeOfReferencedItem.FindFooterStartNode() )
822  {
823  const SwNodeNum* pNodeNumForTextNodeOfField( nullptr );
824  if ( rTextNodeOfField.HasNumber(pLayout) &&
825  rTextNodeOfField.GetNumRule() == rTextNodeOfReferencedItem.GetNumRule() )
826  {
827  pNodeNumForTextNodeOfField = rTextNodeOfField.GetNum(pLayout);
828  }
829  else
830  {
831  pNodeNumForTextNodeOfField =
832  rTextNodeOfReferencedItem.GetNum(pLayout)->GetPrecedingNodeNumOf(rTextNodeOfField);
833  }
834  if ( pNodeNumForTextNodeOfField )
835  {
836  const SwNumberTree::tNumberVector rFieldNumVec =
837  pNodeNumForTextNodeOfField->GetNumberVector();
838  const SwNumberTree::tNumberVector rRefItemNumVec =
839  rTextNodeOfReferencedItem.GetNum()->GetNumberVector();
840  std::size_t nLevel( 0 );
841  while ( nLevel < rFieldNumVec.size() && nLevel < rRefItemNumVec.size() )
842  {
843  if ( rRefItemNumVec[nLevel] == rFieldNumVec[nLevel] )
844  {
845  nRestrictInclToThisLevel = nLevel + 1;
846  }
847  else
848  {
849  break;
850  }
851  ++nLevel;
852  }
853  }
854  }
855 
856  // Determine, if superior list labels have to be included
857  const bool bInclSuperiorNumLabels(
858  ( nRestrictInclToThisLevel < rTextNodeOfReferencedItem.GetActualListLevel() &&
859  ( nRefNumFormat == REF_NUMBER || nRefNumFormat == REF_NUMBER_FULL_CONTEXT ) ) );
860 
861  OSL_ENSURE( rTextNodeOfReferencedItem.GetNumRule(),
862  "<SwGetRefField::MakeRefNumStr(..)> - referenced numbered paragraph has no numbering rule set!" );
863  return std::make_pair(
864  rTextNodeOfReferencedItem.GetNumRule()->MakeRefNumString(
865  *(rTextNodeOfReferencedItem.GetNum(pLayout)),
866  bInclSuperiorNumLabels,
867  nRestrictInclToThisLevel ),
868  rTextNodeOfReferencedItem.GetNumRule()->MakeNumString(
869  *(rTextNodeOfReferencedItem.GetNum(pLayout)),
870  true).endsWith(")") );
871  }
872 
873  return std::make_pair(OUString(), false);
874 }
875 
876 std::unique_ptr<SwField> SwGetRefField::Copy() const
877 {
878  std::unique_ptr<SwGetRefField> pField( new SwGetRefField( static_cast<SwGetRefFieldType*>(GetTyp()),
880  m_nSeqNo, GetFormat() ) );
881  pField->m_sText = m_sText;
882  pField->m_sTextRLHidden = m_sTextRLHidden;
883  return std::unique_ptr<SwField>(pField.release());
884 }
885 
887 OUString SwGetRefField::GetPar1() const
888 {
889  return m_sSetRefName;
890 }
891 
893 void SwGetRefField::SetPar1( const OUString& rName )
894 {
895  m_sSetRefName = rName;
896 }
897 
898 OUString SwGetRefField::GetPar2() const
899 {
900  return ExpandImpl(nullptr);
901 }
902 
903 bool SwGetRefField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
904 {
905  switch( nWhichId )
906  {
907  case FIELD_PROP_USHORT1:
908  {
909  sal_Int16 nPart = 0;
910  switch(GetFormat())
911  {
912  case REF_PAGE : nPart = ReferenceFieldPart::PAGE ; break;
913  case REF_CHAPTER : nPart = ReferenceFieldPart::CHAPTER ; break;
914  case REF_CONTENT : nPart = ReferenceFieldPart::TEXT ; break;
915  case REF_UPDOWN : nPart = ReferenceFieldPart::UP_DOWN ; break;
916  case REF_PAGE_PGDESC: nPart = ReferenceFieldPart::PAGE_DESC ; break;
917  case REF_ONLYNUMBER : nPart = ReferenceFieldPart::CATEGORY_AND_NUMBER ; break;
918  case REF_ONLYCAPTION: nPart = ReferenceFieldPart::ONLY_CAPTION ; break;
919  case REF_ONLYSEQNO : nPart = ReferenceFieldPart::ONLY_SEQUENCE_NUMBER; break;
920  // #i81002#
921  case REF_NUMBER: nPart = ReferenceFieldPart::NUMBER; break;
922  case REF_NUMBER_NO_CONTEXT: nPart = ReferenceFieldPart::NUMBER_NO_CONTEXT; break;
923  case REF_NUMBER_FULL_CONTEXT: nPart = ReferenceFieldPart::NUMBER_FULL_CONTEXT; break;
924  }
925  rAny <<= nPart;
926  }
927  break;
928  case FIELD_PROP_USHORT2:
929  {
930  sal_Int16 nSource = 0;
931  switch(m_nSubType)
932  {
933  case REF_SETREFATTR : nSource = ReferenceFieldSource::REFERENCE_MARK; break;
934  case REF_SEQUENCEFLD: nSource = ReferenceFieldSource::SEQUENCE_FIELD; break;
935  case REF_BOOKMARK : nSource = ReferenceFieldSource::BOOKMARK; break;
936  case REF_OUTLINE : OSL_FAIL("not implemented"); break;
937  case REF_FOOTNOTE : nSource = ReferenceFieldSource::FOOTNOTE; break;
938  case REF_ENDNOTE : nSource = ReferenceFieldSource::ENDNOTE; break;
939  }
940  rAny <<= nSource;
941  }
942  break;
943  case FIELD_PROP_PAR1:
944  {
945  OUString sTmp(GetPar1());
947  {
949  switch( nPoolId )
950  {
956  SwStyleNameMapper::FillProgName(nPoolId, sTmp) ;
957  break;
958  }
959  }
960  rAny <<= sTmp;
961  }
962  break;
963  case FIELD_PROP_PAR3:
964  rAny <<= ExpandImpl(nullptr);
965  break;
966  case FIELD_PROP_PAR4:
967  rAny <<= m_sSetReferenceLanguage;
968  break;
969  case FIELD_PROP_SHORT1:
970  rAny <<= static_cast<sal_Int16>(m_nSeqNo);
971  break;
972  default:
973  assert(false);
974  }
975  return true;
976 }
977 
978 bool SwGetRefField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
979 {
980  switch( nWhichId )
981  {
982  case FIELD_PROP_USHORT1:
983  {
984  sal_Int16 nPart = 0;
985  rAny >>= nPart;
986  switch(nPart)
987  {
988  case ReferenceFieldPart::PAGE: nPart = REF_PAGE; break;
989  case ReferenceFieldPart::CHAPTER: nPart = REF_CHAPTER; break;
990  case ReferenceFieldPart::TEXT: nPart = REF_CONTENT; break;
991  case ReferenceFieldPart::UP_DOWN: nPart = REF_UPDOWN; break;
992  case ReferenceFieldPart::PAGE_DESC: nPart = REF_PAGE_PGDESC; break;
993  case ReferenceFieldPart::CATEGORY_AND_NUMBER: nPart = REF_ONLYNUMBER; break;
994  case ReferenceFieldPart::ONLY_CAPTION: nPart = REF_ONLYCAPTION; break;
995  case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER : nPart = REF_ONLYSEQNO; break;
996  // #i81002#
997  case ReferenceFieldPart::NUMBER: nPart = REF_NUMBER; break;
998  case ReferenceFieldPart::NUMBER_NO_CONTEXT: nPart = REF_NUMBER_NO_CONTEXT; break;
999  case ReferenceFieldPart::NUMBER_FULL_CONTEXT: nPart = REF_NUMBER_FULL_CONTEXT; break;
1000  default: return false;
1001  }
1002  SetFormat(nPart);
1003  }
1004  break;
1005  case FIELD_PROP_USHORT2:
1006  {
1007  sal_Int16 nSource = 0;
1008  rAny >>= nSource;
1009  switch(nSource)
1010  {
1011  case ReferenceFieldSource::REFERENCE_MARK : m_nSubType = REF_SETREFATTR ; break;
1012  case ReferenceFieldSource::SEQUENCE_FIELD :
1013  {
1015  break;
1018  }
1019  break;
1020  case ReferenceFieldSource::BOOKMARK : m_nSubType = REF_BOOKMARK ; break;
1021  case ReferenceFieldSource::FOOTNOTE : m_nSubType = REF_FOOTNOTE ; break;
1023  }
1024  }
1025  break;
1026  case FIELD_PROP_PAR1:
1027  {
1028  OUString sTmpStr;
1029  rAny >>= sTmpStr;
1030  SetPar1(sTmpStr);
1032  }
1033  break;
1034  case FIELD_PROP_PAR3:
1035  {
1036  OUString sTmpStr;
1037  rAny >>= sTmpStr;
1038  SetExpand( sTmpStr );
1039  }
1040  break;
1041  case FIELD_PROP_PAR4:
1042  rAny >>= m_sSetReferenceLanguage;
1043  break;
1044  case FIELD_PROP_SHORT1:
1045  {
1046  sal_Int16 nSetSeq = 0;
1047  rAny >>= nSetSeq;
1048  if(nSetSeq >= 0)
1049  m_nSeqNo = nSetSeq;
1050  }
1051  break;
1052  default:
1053  assert(false);
1054  }
1055  return true;
1056 }
1057 
1059 {
1060  if(!(GetTyp() && REF_SEQUENCEFLD == m_nSubType))
1061  return;
1062 
1063  SwDoc& rDoc = static_cast<SwGetRefFieldType*>(GetTyp())->GetDoc();
1064  const OUString rPar1 = GetPar1();
1065  // don't convert when the name points to an existing field type
1066  if (rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rPar1, false))
1067  return;
1068 
1070  TranslateId pResId;
1071  switch( nPoolId )
1072  {
1074  pResId = STR_POOLCOLL_LABEL_ABB;
1075  break;
1077  pResId = STR_POOLCOLL_LABEL_TABLE;
1078  break;
1080  pResId = STR_POOLCOLL_LABEL_FRAME;
1081  break;
1083  pResId = STR_POOLCOLL_LABEL_DRAWING;
1084  break;
1086  pResId = STR_POOLCOLL_LABEL_FIGURE;
1087  break;
1088  }
1089  if (pResId)
1090  SetPar1(SwResId(pResId));
1091 }
1092 
1094  : SwFieldType( SwFieldIds::GetRef ), m_rDoc( rDc )
1095 {}
1096 
1097 std::unique_ptr<SwFieldType> SwGetRefFieldType::Copy() const
1098 {
1099  return std::make_unique<SwGetRefFieldType>( m_rDoc );
1100 }
1101 
1103 {
1104  std::vector<SwFormatField*> vFields;
1105  GatherFields(vFields, false);
1106  for(auto pFormatField: vFields)
1107  {
1108  // update only the GetRef fields
1109  //JP 3.4.2001: Task 71231 - we need the correct language
1110  SwGetRefField* pGRef = static_cast<SwGetRefField*>(pFormatField->GetField());
1111  const SwTextField* pTField;
1112  if(!pGRef->GetLanguage() &&
1113  nullptr != (pTField = pFormatField->GetTextField()) &&
1114  pTField->GetpTextNode())
1115  {
1116  pGRef->SetLanguage(pTField->GetpTextNode()->GetLang(pTField->GetStart()));
1117  }
1118 
1119  // #i81002#
1120  pGRef->UpdateField(pFormatField->GetTextField());
1121  }
1122  CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
1123 }
1124 
1126 {
1127  if (rHint.GetId() != SfxHintId::SwLegacyModify)
1128  return;
1129  auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
1130  if(!pLegacy->m_pNew && !pLegacy->m_pOld)
1131  // update to all GetReference fields
1132  // hopefully, this codepath is soon dead code, and
1133  // UpdateGetReferences gets only called directly
1135  else
1136  // forward to text fields, they "expand" the text
1137  CallSwClientNotify(rHint);
1138 }
1139 
1140 namespace sw {
1141 
1142 bool IsMarkHintHidden(SwRootFrame const& rLayout,
1143  SwTextNode const& rNode, SwTextAttrEnd const& rHint)
1144 {
1145  if (!rLayout.HasMergedParas())
1146  {
1147  return false;
1148  }
1149  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
1150  rNode.getLayoutFrame(&rLayout)));
1151  if (!pFrame)
1152  {
1153  return true;
1154  }
1155  sal_Int32 const*const pEnd(rHint.GetEnd());
1156  if (pEnd)
1157  {
1158  return pFrame->MapModelToView(&rNode, rHint.GetStart())
1159  == pFrame->MapModelToView(&rNode, *pEnd);
1160  }
1161  else
1162  {
1163  assert(rHint.HasDummyChar());
1164  return pFrame->MapModelToView(&rNode, rHint.GetStart())
1165  == pFrame->MapModelToView(&rNode, rHint.GetStart() + 1);
1166  }
1167 }
1168 
1169 } // namespace sw
1170 
1171 SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
1172  sal_uInt16 nSubType, sal_uInt16 nSeqNo,
1173  sal_Int32* pStt, sal_Int32* pEnd,
1174  SwRootFrame const*const pLayout)
1175 {
1176  OSL_ENSURE( pStt, "Why did no one check the StartPos?" );
1177 
1179  SwTextNode* pTextNd = nullptr;
1180  switch( nSubType )
1181  {
1182  case REF_SETREFATTR:
1183  {
1184  const SwFormatRefMark *pRef = pDoc->GetRefMark( rRefMark );
1185  SwTextRefMark const*const pRefMark(pRef ? pRef->GetTextRefMark() : nullptr);
1186  if (pRefMark && (!pLayout || !sw::IsMarkHintHidden(*pLayout,
1187  pRefMark->GetTextNode(), *pRefMark)))
1188  {
1189  pTextNd = const_cast<SwTextNode*>(&pRef->GetTextRefMark()->GetTextNode());
1190  *pStt = pRef->GetTextRefMark()->GetStart();
1191  if( pEnd )
1192  *pEnd = pRef->GetTextRefMark()->GetAnyEnd();
1193  }
1194  }
1195  break;
1196 
1197  case REF_SEQUENCEFLD:
1198  {
1199  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::SetExp, rRefMark, false );
1200  if( pFieldType && pFieldType->HasWriterListeners() &&
1201  nsSwGetSetExpType::GSE_SEQ & static_cast<SwSetExpFieldType*>(pFieldType)->GetType() )
1202  {
1203  std::vector<SwFormatField*> vFields;
1204  pFieldType->GatherFields(vFields, false);
1205  for(auto pFormatField: vFields)
1206  {
1207  SwTextField *const pTextField(pFormatField->GetTextField());
1208  if (pTextField && nSeqNo ==
1209  static_cast<SwSetExpField*>(pFormatField->GetField())->GetSeqNumber()
1210  && (!pLayout || !pLayout->IsHideRedlines()
1211  || !sw::IsFieldDeletedInModel(rIDRA, *pTextField)))
1212  {
1213  pTextNd = pTextField->GetpTextNode();
1214  *pStt = pTextField->GetStart();
1215  if( pEnd )
1216  *pEnd = (*pStt) + 1;
1217  break;
1218  }
1219  }
1220  }
1221  }
1222  break;
1223 
1224  case REF_BOOKMARK:
1225  {
1227  if (ppMark != pDoc->getIDocumentMarkAccess()->getAllMarksEnd()
1228  && (!pLayout || !pLayout->IsHideRedlines()
1229  || !sw::IsMarkHidden(*pLayout, **ppMark)))
1230  {
1231  const ::sw::mark::IMark* pBkmk = *ppMark;
1232  const SwPosition* pPos = &pBkmk->GetMarkStart();
1233 
1234  pTextNd = pPos->nNode.GetNode().GetTextNode();
1235  *pStt = pPos->nContent.GetIndex();
1236  if(pEnd)
1237  {
1238  if(!pBkmk->IsExpanded())
1239  {
1240  *pEnd = *pStt;
1241  // #i81002#
1242  if(dynamic_cast< ::sw::mark::CrossRefBookmark const *>(pBkmk))
1243  {
1244  OSL_ENSURE( pTextNd,
1245  "<SwGetRefFieldType::FindAnchor(..)> - node marked by cross-reference bookmark isn't a text node --> crash" );
1246  *pEnd = pTextNd->Len();
1247  }
1248  }
1249  else if(pBkmk->GetOtherMarkPos().nNode == pBkmk->GetMarkPos().nNode)
1250  *pEnd = pBkmk->GetMarkEnd().nContent.GetIndex();
1251  else
1252  *pEnd = -1;
1253  }
1254  }
1255  }
1256  break;
1257 
1258  case REF_OUTLINE:
1259  break;
1260 
1261  case REF_FOOTNOTE:
1262  case REF_ENDNOTE:
1263  {
1264  for( auto pFootnoteIdx : pDoc->GetFootnoteIdxs() )
1265  if( nSeqNo == pFootnoteIdx->GetSeqRefNo() )
1266  {
1267  if (pLayout && pLayout->IsHideRedlines()
1268  && sw::IsFootnoteDeleted(rIDRA, *pFootnoteIdx))
1269  {
1270  return nullptr;
1271  }
1272  // otherwise: the position at the start of the footnote
1273  // will be mapped to something visible at least...
1274  SwNodeIndex* pIdx = pFootnoteIdx->GetStartNode();
1275  if( pIdx )
1276  {
1277  SwNodeIndex aIdx( *pIdx, 1 );
1278  pTextNd = aIdx.GetNode().GetTextNode();
1279  if( nullptr == pTextNd )
1280  pTextNd = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext( &aIdx ));
1281  }
1282  *pStt = 0;
1283  if( pEnd )
1284  *pEnd = 0;
1285  break;
1286  }
1287  }
1288  break;
1289  }
1290 
1291  return pTextNd;
1292 }
1293 
1294 namespace {
1295 
1296 struct RefIdsMap
1297 {
1298 private:
1299  OUString aName;
1300  std::set<sal_uInt16> aIds;
1301  std::set<sal_uInt16> aDstIds;
1302  std::map<sal_uInt16, sal_uInt16> sequencedIds;
1303  bool bInit;
1304 
1305  void Init(SwDoc& rDoc, SwDoc& rDestDoc, bool bField );
1306  static void GetNoteIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds );
1307  void GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds );
1308  void AddId( sal_uInt16 id, sal_uInt16 seqNum );
1309  static sal_uInt16 GetFirstUnusedId( std::set<sal_uInt16> &rIds );
1310 
1311 public:
1312  explicit RefIdsMap( const OUString& rName ) : aName( rName ), bInit( false ) {}
1313 
1314  void Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rField, bool bField );
1315 
1316  const OUString& GetName() const { return aName; }
1317 };
1318 
1319 }
1320 
1324 void RefIdsMap::GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
1325 {
1326  SwFieldType *const pType = rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, aName, false);
1327  if (!pType)
1328  return;
1329  std::vector<SwFormatField*> vFields;
1330  pType->GatherFields(vFields);
1331  for(const auto pF: vFields)
1332  rIds.insert(static_cast<SwSetExpField const*>(pF->GetField())->GetSeqNumber());
1333 }
1334 
1338 void RefIdsMap::GetNoteIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
1339 {
1340  for( auto n = rDoc.GetFootnoteIdxs().size(); n; )
1341  rIds.insert( rDoc.GetFootnoteIdxs()[ --n ]->GetSeqRefNo() );
1342 }
1343 
1348 void RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, bool bField )
1349 {
1350  if( bInit )
1351  return;
1352 
1353  if( bField )
1354  {
1355  GetFieldIdsFromDoc( rDestDoc, aIds );
1356  GetFieldIdsFromDoc( rDoc, aDstIds );
1357 
1358  // Map all the new src fields to the next available unused id
1359  for (const auto& rId : aDstIds)
1360  AddId( GetFirstUnusedId(aIds), rId );
1361 
1362  // Change the Sequence number of all SetExp fields in the source document
1363  SwFieldType* pType = rDoc.getIDocumentFieldsAccess().GetFieldType( SwFieldIds::SetExp, aName, false );
1364  if(pType)
1365  {
1366  std::vector<SwFormatField*> vFields;
1367  pType->GatherFields(vFields, false);
1368  for(auto pF: vFields)
1369  {
1370  if(!pF->GetTextField())
1371  continue;
1372  SwSetExpField *const pSetExp(static_cast<SwSetExpField *>(pF->GetField()));
1373  sal_uInt16 const n = pSetExp->GetSeqNumber();
1374  pSetExp->SetSeqNumber(sequencedIds[n]);
1375  }
1376  }
1377  }
1378  else
1379  {
1380  GetNoteIdsFromDoc( rDestDoc, aIds );
1381  GetNoteIdsFromDoc( rDoc, aDstIds );
1382 
1383  for (const auto& rId : aDstIds)
1384  AddId( GetFirstUnusedId(aIds), rId );
1385 
1386  // Change the footnotes/endnotes in the source doc to the new ID
1387  for ( const auto pFootnoteIdx : rDoc.GetFootnoteIdxs() )
1388  {
1389  sal_uInt16 const n = pFootnoteIdx->GetSeqRefNo();
1390  pFootnoteIdx->SetSeqNo(sequencedIds[n]);
1391  }
1392  }
1393  bInit = true;
1394 }
1395 
1399 sal_uInt16 RefIdsMap::GetFirstUnusedId( std::set<sal_uInt16> &rIds )
1400 {
1401  sal_uInt16 num(0);
1402 
1403  for( const auto& rId : rIds )
1404  {
1405  if( num != rId )
1406  {
1407  return num;
1408  }
1409  ++num;
1410  }
1411  return num;
1412 }
1413 
1417 void RefIdsMap::AddId( sal_uInt16 id, sal_uInt16 seqNum )
1418 {
1419  aIds.insert( id );
1420  sequencedIds[ seqNum ] = id;
1421 }
1422 
1423 void RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rField,
1424  bool bField )
1425 {
1426  Init( rDoc, rDestDoc, bField);
1427 
1428  sal_uInt16 const nSeqNo = rField.GetSeqNo();
1429 
1430  // check if it needs to be remapped
1431  // if sequencedIds doesn't contain the number, it means there is no
1432  // SetExp field / footnote in the source document: do not modify
1433  // the number, which works well for copy from/paste to same document
1434  // (and if it is not the same document, there's no "correct" result anyway)
1435  if (sequencedIds.count(nSeqNo))
1436  {
1437  rField.SetSeqNo( sequencedIds[nSeqNo] );
1438  }
1439 }
1440 
1449 {
1450  if (&rDestDoc == &m_rDoc)
1451  return;
1452 
1453  if (rDestDoc.IsClipBoard())
1454  {
1455  // when copying _to_ clipboard, expectation is that no fields exist
1456  // so no re-mapping is required to avoid collisions
1458  return; // don't modify the fields in the source doc
1459  }
1460 
1461  // then there are RefFields in the DescDox - so all RefFields in the SourceDoc
1462  // need to be converted to have unique IDs for both documents
1463  RefIdsMap aFntMap { OUString() };
1464  std::vector<std::unique_ptr<RefIdsMap>> aFieldMap;
1465 
1466  std::vector<SwFormatField*> vFields;
1467  GatherFields(vFields);
1468  for(auto pField: vFields)
1469  {
1470  SwGetRefField& rRefField = *static_cast<SwGetRefField*>(pField->GetField());
1471  switch( rRefField.GetSubType() )
1472  {
1473  case REF_SEQUENCEFLD:
1474  {
1475  RefIdsMap* pMap = nullptr;
1476  for( auto n = aFieldMap.size(); n; )
1477  {
1478  if (aFieldMap[ --n ]->GetName() == rRefField.GetSetRefName())
1479  {
1480  pMap = aFieldMap[ n ].get();
1481  break;
1482  }
1483  }
1484  if( !pMap )
1485  {
1486  pMap = new RefIdsMap( rRefField.GetSetRefName() );
1487  aFieldMap.push_back(std::unique_ptr<RefIdsMap>(pMap));
1488  }
1489 
1490  pMap->Check(m_rDoc, rDestDoc, rRefField, true);
1491  }
1492  break;
1493 
1494  case REF_FOOTNOTE:
1495  case REF_ENDNOTE:
1496  aFntMap.Check(m_rDoc, rDestDoc, rRefField, false);
1497  break;
1498  }
1499  }
1500 }
1501 
1502 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetNumStr(sal_Int32 nNo) const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:241
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
bool IsMarkHintHidden(SwRootFrame const &rLayout, SwTextNode const &rNode, SwTextAttrEnd const &rHint)
Definition: reffld.cxx:1142
static std::pair< OUString, bool > MakeRefNumStr(SwRootFrame const *pLayout, const SwTextNode &rTextNodeOfField, const SwTextNode &rTextNodeOfReferencedItem, sal_uInt32 nRefNumFormat)
Definition: reffld.cxx:788
static bool IsLegalName(std::u16string_view rName)
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Overlay in order to update all ref-fields.
Definition: reffld.cxx:1125
OUString GetExpandedTextOfReferencedTextNode(SwRootFrame const &rLayout) const
Definition: reffld.cxx:414
OUString m_sTextRLHidden
result for layout with redlines hidden
Definition: reffld.hxx:93
void MergeWithOtherDoc(SwDoc &rDestDoc)
Definition: reffld.cxx:1448
const SwStartNode * FindHeaderStartNode() const
Definition: node.hxx:204
Marks a position in the document model.
Definition: pam.hxx:36
void Init()
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr) const
Definition: ndtxt.cxx:3994
bool isDigit(const OUString &rStr, sal_Int32 nPos) const
virtual OUString GetPar2() const override
Definition: reffld.cxx:898
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
Definition: doc.cxx:1045
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:408
virtual ~SwGetRefField() override
Definition: reffld.cxx:360
OUString MakeRefNumString(const SwNodeNum &rNodeNum, const bool bInclSuperiorNumLabels, const int nRestrictInclToThisLevel) const
Definition: number.cxx:787
"Page"
Definition: reffld.hxx:48
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:642
const OUString & GetText() const
Definition: ndtxt.hxx:218
const SwStartNode * FindFooterStartNode() const
Definition: node.hxx:206
virtual const SwRootFrame * GetCurrentLayout() const =0
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2662
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
"Caption Text"
Definition: reffld.hxx:54
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
SwNodeIndex nNode
Definition: pam.hxx:38
sal_uInt16 m_nSeqNo
reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo
Definition: reffld.hxx:96
SwFrameType GetType() const
Definition: frame.hxx:519
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
sal_uIntPtr sal_uLong
constexpr OUStringLiteral last
Base class of all fields.
Definition: fldbas.hxx:291
virtual OUString GetDescription() const override
Definition: reffld.cxx:364
#define FIELD_PROP_USHORT1
Definition: unofldmid.h:31
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1210
sal_Int64 n
#define ENDNOTE
Definition: ftnfrm.cxx:43
Definition: doc.hxx:187
static void FilterText(OUString &rText, LanguageType const eLang, std::u16string_view rSetReferenceLanguage)
Definition: reffld.cxx:456
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId) override
Definition: reffld.cxx:978
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
aBuf
bool IsMarkHidden(SwRootFrame const &rLayout,::sw::mark::IMark const &rMark)
Definition: crbm.cxx:125
bool IsFootnoteDeleted(IDocumentRedlineAccess const &rIDRA, SwTextFootnote const &rTextFootnote)
Definition: ftnidx.cxx:37
bool HasDummyChar() const
Definition: txatbase.hxx:107
SwNode & GetNode() const
Definition: ndindex.hxx:119
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: reffld.cxx:440
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
virtual OUString GetPar1() const override
get reference name
Definition: reffld.cxx:887
SwNumberTree::tNumberVector GetNumberVector() const
Returns level numbers of this node.
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1792
Dialog to specify the properties of date form field.
void SetLevel(sal_uInt8)
Definition: chpfld.cxx:86
virtual const sal_Int32 * GetEnd() const override
end position
Definition: txatbase.cxx:77
bool IsInside(TextFrameIndex nPos) const
Respect the Follows.
Definition: txtfrm.hxx:830
void UpdateGetReferences()
Definition: reffld.cxx:1102
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:161
bool HasNumber(SwRootFrame const *pLayout=nullptr) const
Returns if this text node has a number.
Definition: ndtxt.cxx:3126
bool HasWriterListeners() const
Definition: calbck.hxx:202
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4139
SfxHintId GetId() const
OUString GetViewNumStr(const SwDoc &rDoc, SwRootFrame const *pLayout, bool bInclStrings=false) const
Returns string to be displayed of footnote / endnote.
Definition: atrftn.cxx:217
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const override
Definition: reffld.cxx:903
virtual void SetSubType(sal_uInt16 n) override
Definition: reffld.cxx:374
#define LANGUAGE_HUNGARIAN
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:203
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3068
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
SwDoc & m_rDoc
Definition: docbm.cxx:1201
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
sal_uInt16 sal_Unicode
bool IsFlyFrame() const
Definition: frame.hxx:1210
const SwTextNode & GetTextNode() const
Definition: txtrfmrk.hxx:44
"As Page Style"
Definition: reffld.hxx:52
static SwTextNode * FindAnchor(SwDoc *pDoc, const OUString &rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_Int32 *pStt, sal_Int32 *pEnd=nullptr, SwRootFrame const *pLayout=nullptr)
Definition: reffld.cxx:1171
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
void ConvertProgrammaticToUIName()
Definition: reffld.cxx:1058
SwIndex nContent
Definition: pam.hxx:39
const SwRect & getFrameArea() const
Definition: frame.hxx:179
"Chapter"
Definition: reffld.hxx:49
"Number (full context)"
Definition: reffld.hxx:60
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:43
static void lcl_GetLayTree(const SwFrame *pFrame, std::vector< const SwFrame * > &rArr)
Definition: reffld.cxx:77
OUString m_sSetRefName
Definition: reffld.hxx:90
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const OUString & getAboveWord() const
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
"Category and Number"
Definition: reffld.hxx:53
o3tl::sorted_vector< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1668
virtual OUString GetName() const override
OUString m_sSetReferenceLanguage
Definition: reffld.hxx:91
size_type size() const
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: reffld.cxx:1097
sal_uInt16 GetSeqRefNo() const
Definition: txtftn.hxx:64
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:856
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
static sal_Int32 GetReferenceTextPos(const SwFormatField &rFormat, SwDoc &rDoc, sal_Int32 nHint=0)
Find the index of the reference text following the current field.
Definition: expfld.cxx:973
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
bool IsRefToNumItemCrossRefBookmark() const
Definition: reffld.cxx:386
OUString GetExpandTextMerged(SwRootFrame const *const pLayout, SwTextNode const &rNode, bool const bWithNumber, bool const bWithSpacesForLevel, ExpandMode const i_mode)
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
int i
SwDoc & GetDoc()
Definition: node.hxx:213
#define O3TL_UNREACHABLE
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
const OUString & getBelowWord() const
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
#define FIELD_PROP_USHORT2
Definition: unofldmid.h:32
const SvxPageUsage aArr[]
SwFieldIds
Definition: fldbas.hxx:45
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
float u
new reference format types for referencing bookmarks and set references
Definition: reffld.hxx:58
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2833
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:307
SwDoc & m_rDoc
Definition: reffld.hxx:67
Label drawing objects.
Definition: poolfmt.hxx:358
const SwTextRefMark * GetTextRefMark() const
Definition: fmtrfmrk.hxx:59
Marks a node in the document model.
Definition: ndindex.hxx:30
A page of the document layout.
Definition: pagefrm.hxx:57
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
#define FIELD_PROP_PAR3
Definition: unofldmid.h:25
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
Definition: txtfrm.cxx:330
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
std::vector< tSwNumTreeNumber > tNumberVector
SwGetRefFieldType(SwDoc &rDoc)
Definition: reffld.cxx:1093
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
ExpandMode
Some helpers for converting model strings to view strings.
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
"Reference"
Definition: reffld.hxx:50
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:205
sal_uInt16 GetSeqNo() const
Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
Definition: reffld.hxx:134
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote) const
add 4th optional parameter indicating, when that a spa...
Definition: ndtxt.cxx:3412
virtual void SetLanguage(LanguageType nLng)
Definition: fldbas.cxx:442
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
OUString aGetRefField_RefItemNotFound
Definition: shellres.hxx:44
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:137
void ChangeExpansion(const SwFrame &, const SwContentNode *, bool bSrchNum=false)
Definition: chpfld.cxx:133
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
virtual OUString GetFieldName() const override
get name or content
Definition: reffld.cxx:445
bool IsRefToHeadingCrossRefBookmark() const
Definition: reffld.cxx:380
OUString m_sText
result
Definition: reffld.hxx:92
"Above/Below"
Definition: reffld.hxx:51
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1255
SwDoc & GetDoc() const
Definition: reffld.hxx:76
OUString aName
static OUString lcl_formatStringByCombiningCharacter(const OUString &sText, const sal_Unicode cChar)
Definition: reffld.cxx:402
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool IsCountedInList() const
Definition: ndtxt.cxx:4276
static bool IsLegalName(std::u16string_view rName)
bool IsClipBoard() const
Definition: doc.hxx:962
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
SwNodes & GetNodes()
Definition: doc.hxx:408
bool IsRightToLeft() const
Definition: frame.hxx:987
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
Definition: thints.cxx:3433
"Number (no context)"
Definition: reffld.hxx:59
bool IsPageFrame() const
Definition: frame.hxx:1178
sal_uInt16 m_nSubType
Definition: reffld.hxx:94
const OUString & GetSetRefName() const
Definition: reffld.hxx:109
Label illustration.
Definition: poolfmt.hxx:346
void SetSeqNo(sal_uInt16 n)
Definition: reffld.hxx:135
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:421
Get reference.
Definition: reffld.hxx:65
const OUString & GetNumber(SwRootFrame const *pLayout=nullptr) const
Definition: chpfld.cxx:92
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
const SwNodeNum * GetPrecedingNodeNumOf(const SwTextNode &rTextNode) const
determines the instance, which is preceding the given text node
Definition: SwNodeNum.cxx:354
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:200
"Numbering"
Definition: reffld.hxx:55
SwGetRefField(SwGetRefFieldType *, const OUString &rSetRef, const OUString &rReferenceLanguage, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFormat)
get references
Definition: reffld.cxx:349
bool IsVertical() const
Definition: frame.hxx:973
Any result
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:633
#define FIELD_PROP_PAR4
Definition: unofldmid.h:36
bool IsFrameBehind(const SwTextNode &rMyNd, sal_Int32 nMySttPos, const SwTextNode &rBehindNd, sal_Int32 nSttPos)
Definition: reffld.cxx:99
bool HasMergedParas() const
Definition: rootfrm.hxx:425
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
void UpdateField(const SwTextField *pFieldTextAttr)
The instance, which represents the text attribute for the instance...
Definition: reffld.cxx:485
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
virtual std::unique_ptr< SwField > Copy() const override
Definition: reffld.cxx:876
bool IsBodyFrame() const
Definition: frame.hxx:1206
void SetExpand(const OUString &rStr)
Definition: reffld.cxx:434
static void lcl_formatReferenceLanguage(OUString &rRefText, bool bClosingParenthesis, LanguageType eLang, std::u16string_view rReferenceLanguage)
Definition: reffld.cxx:215
virtual sal_uInt16 GetSubType() const override
Get/set sub type.
Definition: reffld.cxx:369
bool isLetter(const OUString &rStr, sal_Int32 nPos) const
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
const SwStartNode * FindFootnoteStartNode() const
Definition: node.hxx:202
virtual void SetPar1(const OUString &rStr) override
set reference name
Definition: reffld.cxx:893
const SwTextNode * GetReferencedTextNode() const
Definition: reffld.cxx:392
static sal_uInt16 GetPoolIdFromProgName(const OUString &rName, SwGetPoolIdFromName)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:864
bool m_bDetectedRangeSegmentation false
#define FIELD_PROP_SHORT1
Definition: unofldmid.h:37
const SvxNumberType & GetNumType() const
Definition: pagedesc.hxx:202