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