LibreOffice Module sw (master)  1
txtfld.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 <hintids.hxx>
21 #include <fmtfld.hxx>
22 #include <txtfld.hxx>
23 #include <charfmt.hxx>
24 #include <fmtautofmt.hxx>
25 
26 #include <viewsh.hxx>
27 #include <doc.hxx>
28 #include <rootfrm.hxx>
29 #include <pagefrm.hxx>
30 #include <ndtxt.hxx>
31 #include <fldbas.hxx>
32 #include <viewopt.hxx>
33 #include <flyfrm.hxx>
34 #include <viewimp.hxx>
35 #include <swfont.hxx>
36 #include <swmodule.hxx>
37 #include "porfld.hxx"
38 #include "porftn.hxx"
39 #include "porref.hxx"
40 #include "portox.hxx"
41 #include "porfly.hxx"
42 #include "itrform2.hxx"
43 #include <chpfld.hxx>
44 #include <dbfld.hxx>
45 #include <expfld.hxx>
46 #include <docufld.hxx>
47 #include <pagedesc.hxx>
48 #include <fmtmeta.hxx>
49 #include <reffld.hxx>
50 #include <flddat.hxx>
53 #include <redline.hxx>
54 #include <sfx2/docfile.hxx>
55 #include <svl/itemiter.hxx>
56 #include <editeng/colritem.hxx>
57 #include <editeng/udlnitem.hxx>
59 
60 static bool lcl_IsInBody( SwFrame const *pFrame )
61 {
62  if ( pFrame->IsInDocBody() )
63  return true;
64  else
65  {
66  const SwFrame *pTmp = pFrame;
67  const SwFlyFrame *pFly;
68  while ( nullptr != (pFly = pTmp->FindFlyFrame()) )
69  pTmp = pFly->GetAnchorFrame();
70  return pTmp->IsInDocBody();
71  }
72 }
73 
75  const SwTextAttr *pHint ) const
76 {
77  SwExpandPortion *pRet = nullptr;
78  SwFrame *pFrame = m_pFrame;
79  SwField *pField = const_cast<SwField*>(pHint->GetFormatField().GetField());
80  const bool bName = rInf.GetOpt().IsFieldName();
81 
82  SwCharFormat* pChFormat = nullptr;
83  bool bNewFlyPor = false;
84  sal_uInt16 subType = 0;
85 
86  // set language
87  const_cast<SwTextFormatter*>(this)->SeekAndChg( rInf );
88  if (pField->GetLanguage() != GetFnt()->GetLanguage())
89  {
90  pField->SetLanguage( GetFnt()->GetLanguage() );
91  // let the visual note know about its new language
92  if (pField->GetTyp()->Which()==SwFieldIds::Postit)
93  const_cast<SwFormatField*> (&pHint->GetFormatField())->Broadcast( SwFormatFieldHint( &pHint->GetFormatField(), SwFormatFieldHintWhich::LANGUAGE ) );
94  }
95 
96  SwViewShell *pSh = rInf.GetVsh();
97  SwDoc *const pDoc( pSh ? pSh->GetDoc() : nullptr );
98  bool const bInClipboard( pDoc == nullptr || pDoc->IsClipBoard() );
99  bool bPlaceHolder = false;
100 
101  switch( pField->GetTyp()->Which() )
102  {
103  case SwFieldIds::Script:
104  case SwFieldIds::Postit:
105  pRet = new SwPostItsPortion( SwFieldIds::Script == pField->GetTyp()->Which() );
106  break;
107 
109  {
110  if( bName )
111  pRet = new SwFieldPortion( pField->GetFieldName() );
112  else
113  pRet = new SwCombinedPortion( pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
114  }
115  break;
116 
118  {
119  OUString const aStr( bName
120  ? pField->GetFieldName()
121  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
122  pRet = new SwHiddenPortion(aStr);
123  }
124  break;
125 
126  case SwFieldIds::Chapter:
127  if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
128  {
129  static_cast<SwChapterField*>(pField)->ChangeExpansion(*pFrame,
130  &static_txtattr_cast<SwTextField const*>(pHint)->GetTextNode());
131  }
132  {
133  OUString const aStr( bName
134  ? pField->GetFieldName()
135  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
136  pRet = new SwFieldPortion( aStr );
137  }
138  break;
139 
140  case SwFieldIds::DocStat:
141  if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
142  {
143  static_cast<SwDocStatField*>(pField)->ChangeExpansion( pFrame );
144  }
145  {
146  OUString const aStr( bName
147  ? pField->GetFieldName()
148  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
149  pRet = new SwFieldPortion( aStr );
150  }
151  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGECOOUNTFLD;
152  break;
153 
155  {
156  if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFields() )
157  {
158  SwPageNumberFieldType *pPageNr = static_cast<SwPageNumberFieldType *>(pField->GetTyp());
159 
160  const SwRootFrame* pTmpRootFrame = pSh->GetLayout();
161  const bool bVirt = pTmpRootFrame->IsVirtPageNum();
162 
163  sal_uInt16 nVirtNum = pFrame->GetVirtPageNum();
164  sal_uInt16 nNumPages = pTmpRootFrame->GetPageNum();
165  SvxNumType nNumFormat = SvxNumType(-1);
166  if(SVX_NUM_PAGEDESC == pField->GetFormat())
167  nNumFormat = pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType();
168  static_cast<SwPageNumberField*>(pField)
169  ->ChangeExpansion(nVirtNum, nNumPages);
170  pPageNr->ChangeExpansion(pDoc,
171  bVirt, nNumFormat != SvxNumType(-1) ? &nNumFormat : nullptr);
172  }
173  {
174  OUString const aStr( bName
175  ? pField->GetFieldName()
176  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
177  pRet = new SwFieldPortion( aStr );
178  }
179  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_PAGENUMBERFLD;
180  break;
181  }
182  case SwFieldIds::GetExp:
183  {
184  if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
185  {
186  SwGetExpField* pExpField = static_cast<SwGetExpField*>(pField);
187  if( !::lcl_IsInBody( pFrame ) )
188  {
189  pExpField->ChgBodyTextFlag( false );
190  pExpField->ChangeExpansion(*pFrame,
191  *static_txtattr_cast<SwTextField const*>(pHint));
192  }
193  else if( !pExpField->IsInBodyText() )
194  {
195  // Was something else previously, thus: expand first, then convert it!
196  pExpField->ChangeExpansion(*pFrame,
197  *static_txtattr_cast<SwTextField const*>(pHint));
198  pExpField->ChgBodyTextFlag( true );
199  }
200  }
201  {
202  OUString const aStr( bName
203  ? pField->GetFieldName()
204  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
205  pRet = new SwFieldPortion( aStr );
206  }
207  break;
208  }
210  {
211  if( !bName )
212  {
213  SwDBField* pDBField = static_cast<SwDBField*>(pField);
214  pDBField->ChgBodyTextFlag( ::lcl_IsInBody( pFrame ) );
215  }
216  {
217  OUString const aStr( bName
218  ? pField->GetFieldName()
219  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
220  pRet = new SwFieldPortion(aStr);
221  }
222  break;
223  }
225  if( !bName && pSh && !pSh->Imp()->IsUpdateExpFields() )
226  {
227  static_cast<SwRefPageGetField*>(pField)->ChangeExpansion(*pFrame,
228  static_txtattr_cast<SwTextField const*>(pHint));
229  }
230  {
231  OUString const aStr( bName
232  ? pField->GetFieldName()
233  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
234  pRet = new SwFieldPortion(aStr);
235  }
236  break;
237 
239  if( !bName )
240  pChFormat = static_cast<SwJumpEditField*>(pField)->GetCharFormat();
241  bNewFlyPor = true;
242  bPlaceHolder = true;
243  break;
244  case SwFieldIds::GetRef:
245  subType = static_cast<SwGetRefField*>(pField)->GetSubType();
246  {
247  OUString const str( bName
248  ? pField->GetFieldName()
249  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
250  pRet = new SwFieldPortion(str);
251  }
252  if( subType == REF_BOOKMARK )
253  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_BOOKMARKFLD;
254  else if( subType == REF_SETREFATTR )
255  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_SETREFATTRFLD;
256  break;
258  subType = static_cast<SwDateTimeField*>(pField)->GetSubType();
259  {
260  OUString const str( bName
261  ? pField->GetFieldName()
262  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
263  pRet = new SwFieldPortion(str);
264  }
265  if( subType & DATEFLD )
266  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType= ATTR_DATEFLD;
267  else if( subType & TIMEFLD )
268  static_cast<SwFieldPortion*>(pRet)->m_nAttrFieldType = ATTR_TIMEFLD;
269  break;
270  default:
271  {
272  OUString const aStr( bName
273  ? pField->GetFieldName()
274  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
275  pRet = new SwFieldPortion(aStr);
276  }
277  }
278 
279  if( bNewFlyPor )
280  {
281  std::unique_ptr<SwFont> pTmpFnt;
282  if( !bName )
283  {
284  pTmpFnt.reset(new SwFont( *m_pFont ));
285  pTmpFnt->SetDiffFnt(&pChFormat->GetAttrSet(), &m_pFrame->GetDoc().getIDocumentSettingAccess());
286  }
287  OUString const aStr( bName
288  ? pField->GetFieldName()
289  : pField->ExpandField(bInClipboard, pFrame->getRootFrame()) );
290  pRet = new SwFieldPortion(aStr, std::move(pTmpFnt), bPlaceHolder);
291  }
292 
293  return pRet;
294 }
295 
296 static SwFieldPortion * lcl_NewMetaPortion(SwTextAttr & rHint, const bool bPrefix)
297 {
298  ::sw::Meta *const pMeta(
299  static_cast<SwFormatMeta &>(rHint.GetAttr()).GetMeta() );
300  OUString fix;
301  ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) );
302  OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?");
303  if (pField)
304  {
305  pField->GetPrefixAndSuffix(bPrefix ? &fix : nullptr, bPrefix ? nullptr : &fix);
306  }
307  return new SwFieldPortion( fix );
308 }
309 
319 {
320  const TextFrameIndex nIdx(rInfo.GetIdx());
321 
322  // sw_redlinehide: because there is a dummy character at the start of these
323  // hints, it's impossible to have ends of hints from different nodes at the
324  // same view position, so it's sufficient to check the hints of the current
325  // node. However, m_pByEndIter exists for the whole text frame, so
326  // it's necessary to iterate all hints for that purpose...
327  if (!m_pByEndIter)
328  {
330  }
331  SwTextNode const* pNode(nullptr);
332  for (SwTextAttr const* pHint = m_pByEndIter->NextAttr(pNode); pHint;
333  pHint = m_pByEndIter->NextAttr(pNode))
334  {
335  SwTextAttr & rHint(const_cast<SwTextAttr&>(*pHint));
336  TextFrameIndex const nEnd(
337  rInfo.GetTextFrame()->MapModelToView(pNode, rHint.GetAnyEnd()));
338  if (nEnd > nIdx)
339  {
340  m_pByEndIter->PrevAttr();
341  break;
342  }
343  if (nEnd == nIdx)
344  {
345  if (RES_TXTATR_METAFIELD == rHint.Which())
346  {
347  SwFieldPortion *const pPortion(
348  lcl_NewMetaPortion(rHint, false));
349  pPortion->SetNoLength(); // no CH_TXTATR at hint end!
350  return pPortion;
351  }
352  }
353  }
354  return nullptr;
355 }
356 
358 {
359  SwTextAttr *pHint = GetAttr( rInf.GetIdx() );
360  SwLinePortion *pRet = nullptr;
361  if( !pHint )
362  {
363  pRet = new SwTextPortion;
364  pRet->SetLen(TextFrameIndex(1));
365  rInf.SetLen(TextFrameIndex(1));
366  return pRet;
367  }
368 
369  switch( pHint->Which() )
370  {
371  case RES_TXTATR_FLYCNT :
372  {
373  pRet = NewFlyCntPortion( rInf, pHint );
374  break;
375  }
376  case RES_TXTATR_FTN :
377  {
378  pRet = NewFootnotePortion( rInf, pHint );
379  break;
380  }
381  case RES_TXTATR_FIELD :
382  case RES_TXTATR_ANNOTATION :
383  {
384  pRet = NewFieldPortion( rInf, pHint );
385  break;
386  }
387  case RES_TXTATR_REFMARK :
388  {
389  pRet = new SwIsoRefPortion;
390  break;
391  }
392  case RES_TXTATR_TOXMARK :
393  {
394  pRet = new SwIsoToxPortion;
395  break;
396  }
398  {
399  pRet = lcl_NewMetaPortion( *pHint, true );
400  break;
401  }
402  default: ;
403  }
404  if( !pRet )
405  {
406  const OUString aNothing;
407  pRet = new SwFieldPortion( aNothing );
408  rInf.SetLen(TextFrameIndex(1));
409  }
410  return pRet;
411 }
412 
419  const IDocumentSettingAccess* pIDSA,
420  const SwAttrSet* pFormat)
421 {
423  return;
424 
425  SwFormatAutoFormat const& rListAutoFormat(static_cast<SwFormatAutoFormat const&>(rInf.GetTextFrame()->GetTextNodeForParaProps()->GetAttr(RES_PARATR_LIST_AUTOFMT)));
426  std::shared_ptr<SfxItemSet> pSet(rListAutoFormat.GetStyleHandle());
427 
428  // TODO remove this fallback (for WW8/RTF)
429  if (!pSet)
430  {
431  TextFrameIndex const nTextLen(rInf.GetTextFrame()->GetText().getLength());
432  SwTextNode const* pNode(nullptr);
434  for (SwTextAttr const* pHint = iter.PrevAttr(&pNode); pHint;
435  pHint = iter.PrevAttr(&pNode))
436  {
437  TextFrameIndex const nHintEnd(
438  rInf.GetTextFrame()->MapModelToView(pNode, pHint->GetAnyEnd()));
439  if (nHintEnd < nTextLen)
440  {
441  break; // only those at para end are interesting
442  }
443  // Formatting for the paragraph mark is usually set to apply only to the
444  // (non-existent) extra character at end of the text node, but there can be
445  // other hints too (ending at nTextLen), so look for all matching hints.
446  // Still the (non-existent) extra character at the end is preferred if it exists.
447  if (pHint->Which() == RES_TXTATR_AUTOFMT
448  && pHint->GetStart() == *pHint->End())
449  {
450  pSet = pHint->GetAutoFormat().GetStyleHandle();
451  // When we find an empty hint (start == end) we got what we are looking for.
452  break;
453  }
454  }
455  }
456 
457  // TODO: apparently Word can apply Character Style too, see testParagraphMark
458 
459  // Check each item and in case it should be ignored, then clear it.
460  if (pSet.get())
461  {
462  std::unique_ptr<SfxItemSet> const pCleanedSet = pSet->Clone();
463 
464  SfxItemIter aIter(*pSet);
465  const SfxPoolItem* pItem = aIter.GetCurItem();
466  do
467  {
469  pCleanedSet->ClearItem(pItem->Which());
470  else if (pFormat && pFormat->HasItem(pItem->Which()))
471  pCleanedSet->ClearItem(pItem->Which());
472 
473  pItem = aIter.NextItem();
474  } while (pItem);
475  // Highlightcolor also needed to be untouched, but we can't have that just by clearing the item
476  Color nSaveHighlight = pNumFnt->GetHighlightColor();
477  pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA);
478  pNumFnt->SetHighlightColor(nSaveHighlight);
479  }
480 }
481 
483 {
484  const SwDoc* pDoc = rTextNode.GetDoc();
485  SwRedlineTable::size_type nRedlPos = pDoc->getIDocumentRedlineAccess().GetRedlinePos( rTextNode, RedlineType::Any );
486 
487  if( SwRedlineTable::npos != nRedlPos )
488  {
489  const sal_uLong nNdIdx = rTextNode.GetIndex();
490  for( ; nRedlPos < pDoc->getIDocumentRedlineAccess().GetRedlineTable().size() ; ++nRedlPos )
491  {
492  const SwRangeRedline* pTmp = pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nRedlPos ];
493  if( RedlineType::Delete == pTmp->GetType() ||
494  RedlineType::Insert == pTmp->GetType() )
495  {
496  const SwPosition *pRStt = pTmp->Start(), *pREnd = pTmp->End();
497  if( pRStt->nNode < nNdIdx && pREnd->nNode >= nNdIdx )
498  return pTmp;
499  }
500  }
501  }
502  return nullptr;
503 }
504 
505 static void lcl_setRedlineAttr( SwTextFormatInfo &rInf, const SwTextNode& rTextNode, std::unique_ptr<SwFont>& pNumFnt )
506 {
507  if ( !rInf.GetVsh()->GetLayout()->IsHideRedlines() )
508  {
509  const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode );
510  if (pRedlineNum)
511  {
512  std::unique_ptr<SfxItemSet> pSet;
513 
514  SwAttrPool& rPool = rInf.GetVsh()->GetDoc()->GetAttrPool();
515  pSet = std::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{});
516 
517  std::size_t aAuthor = (1 < pRedlineNum->GetStackCount())
518  ? pRedlineNum->GetAuthor( 1 )
519  : pRedlineNum->GetAuthor();
520 
521  if ( RedlineType::Delete == pRedlineNum->GetType() )
522  SW_MOD()->GetDeletedAuthorAttr(aAuthor, *pSet);
523  else
524  SW_MOD()->GetInsertAuthorAttr(aAuthor, *pSet);
525 
526  const SfxPoolItem* pItem = nullptr;
527  if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_COLOR, true, &pItem))
528  pNumFnt->SetColor(static_cast<const SvxColorItem*>(pItem)->GetValue());
529  if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_UNDERLINE, true, &pItem))
530  pNumFnt->SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle());
531  if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_CROSSEDOUT, true, &pItem))
532  pNumFnt->SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() );
533  }
534  }
535 }
536 
538 {
539  if( rInf.IsNumDone() || rInf.GetTextStart() != m_nStart
540  || rInf.GetTextStart() != rInf.GetIdx() )
541  return nullptr;
542 
543  SwNumberPortion *pRet = nullptr;
544  // sw_redlinehide: at this point it's certain that pTextNd is the node with
545  // the numbering of the frame; only the actual number-vector (GetNumString)
546  // depends on the hide-mode in the layout so other calls don't need to care
547  const SwTextNode *const pTextNd = GetTextFrame()->GetTextNodeForParaProps();
548  const SwNumRule* pNumRule = pTextNd->GetNumRule();
549 
550  // Has a "valid" number?
551  // sw_redlinehide: check that pParaPropsNode is the correct one
552  assert(pTextNd->IsNumbered(m_pFrame->getRootFrame()) == pTextNd->IsNumbered(nullptr));
553  if (pTextNd->IsNumbered(m_pFrame->getRootFrame()) && pTextNd->IsCountedInList())
554  {
555  int nLevel = pTextNd->GetActualListLevel();
556 
557  if (nLevel < 0)
558  nLevel = 0;
559 
560  if (nLevel >= MAXLEVEL)
561  nLevel = MAXLEVEL - 1;
562 
563  const SwNumFormat &rNumFormat = pNumRule->Get( nLevel );
564  const bool bLeft = SvxAdjust::Left == rNumFormat.GetNumAdjust();
565  const bool bCenter = SvxAdjust::Center == rNumFormat.GetNumAdjust();
566  const bool bLabelAlignmentPosAndSpaceModeActive(
568  const sal_uInt16 nMinDist = bLabelAlignmentPosAndSpaceModeActive
569  ? 0 : rNumFormat.GetCharTextDistance();
570 
571  if( SVX_NUM_BITMAP == rNumFormat.GetNumberingType() )
572  {
573  OUString referer;
574  if (auto const sh1 = rInf.GetVsh()) {
575  if (auto const doc = sh1->GetDoc()) {
576  auto const sh2 = doc->GetPersist();
577  if (sh2 != nullptr && sh2->HasName()) {
578  referer = sh2->GetMedium()->GetName();
579  }
580  }
581  }
582  pRet = new SwGrfNumPortion( pTextNd->GetLabelFollowedBy(),
583  rNumFormat.GetBrush(), referer,
584  rNumFormat.GetGraphicOrientation(),
585  rNumFormat.GetGraphicSize(),
586  bLeft, bCenter, nMinDist,
587  bLabelAlignmentPosAndSpaceModeActive );
588  long nTmpA = rInf.GetLast()->GetAscent();
589  long nTmpD = rInf.GetLast()->Height() - nTmpA;
590  if( !rInf.IsTest() )
591  static_cast<SwGrfNumPortion*>(pRet)->SetBase( nTmpA, nTmpD, nTmpA, nTmpD );
592  }
593  else
594  {
595  // The SwFont is created dynamically and passed in the ctor,
596  // as the CharFormat only returns an SV-Font.
597  // In the dtor of SwNumberPortion, the SwFont is deleted.
598  const SwAttrSet* pFormat = rNumFormat.GetCharFormat() ?
599  &rNumFormat.GetCharFormat()->GetAttrSet() :
600  nullptr;
601  const IDocumentSettingAccess* pIDSA = pTextNd->getIDocumentSettingAccess();
602 
603  if( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() )
604  {
605  const vcl::Font *pFormatFnt = rNumFormat.GetBulletFont();
606 
607  // Build a new bullet font basing on the current paragraph font:
608  std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA ));
609 
610  // #i53199#
612  {
613  // i18463:
614  // Underline style of paragraph font should not be considered
615  // Overline style of paragraph font should not be considered
616  // Weight style of paragraph font should not be considered
617  // Posture style of paragraph font should not be considered
618  pNumFnt->SetUnderline( LINESTYLE_NONE );
619  pNumFnt->SetOverline( LINESTYLE_NONE );
620  pNumFnt->SetItalic( ITALIC_NONE, SwFontScript::Latin );
621  pNumFnt->SetItalic( ITALIC_NONE, SwFontScript::CJK );
622  pNumFnt->SetItalic( ITALIC_NONE, SwFontScript::CTL );
623  pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::Latin );
624  pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CJK );
625  pNumFnt->SetWeight( WEIGHT_NORMAL, SwFontScript::CTL );
626  }
627 
628  // Apply the explicit attributes from the character style
629  // associated with the numbering to the new bullet font.
630  if( pFormat )
631  pNumFnt->SetDiffFnt( pFormat, pIDSA );
632 
633  checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat);
634 
635  if ( pFormatFnt )
636  {
637  const SwFontScript nAct = pNumFnt->GetActual();
638  pNumFnt->SetFamily( pFormatFnt->GetFamilyType(), nAct );
639  pNumFnt->SetName( pFormatFnt->GetFamilyName(), nAct );
640  pNumFnt->SetStyleName( pFormatFnt->GetStyleName(), nAct );
641  pNumFnt->SetCharSet( pFormatFnt->GetCharSet(), nAct );
642  pNumFnt->SetPitch( pFormatFnt->GetPitch(), nAct );
643  }
644 
645  // we do not allow a vertical font
646  pNumFnt->SetVertical( pNumFnt->GetOrientation(),
647  m_pFrame->IsVertical() );
648 
649  lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt );
650 
651  // --> OD 2008-01-23 #newlistelevelattrs#
652  pRet = new SwBulletPortion( rNumFormat.GetBulletChar(),
653  pTextNd->GetLabelFollowedBy(),
654  std::move(pNumFnt),
655  bLeft, bCenter, nMinDist,
656  bLabelAlignmentPosAndSpaceModeActive );
657  }
658  else
659  {
660  OUString aText( pTextNd->GetNumString(true, MAXLEVEL, m_pFrame->getRootFrame()) );
661  if ( !aText.isEmpty() )
662  {
663  aText += pTextNd->GetLabelFollowedBy();
664  }
665 
666  // Not just an optimization ...
667  // A number portion without text will be assigned a width of 0.
668  // The succeeding text portion will flow into the BreakCut in the BreakLine,
669  // although we have rInf.GetLast()->GetFlyPortion()!
670  if( !aText.isEmpty() )
671  {
672 
673  // Build a new numbering font basing on the current paragraph font:
674  std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA ));
675 
676  // #i53199#
678  {
679  // i18463:
680  // Underline style of paragraph font should not be considered
681  pNumFnt->SetUnderline( LINESTYLE_NONE );
682  // Overline style of paragraph font should not be considered
683  pNumFnt->SetOverline( LINESTYLE_NONE );
684  }
685 
686  // Apply the explicit attributes from the character style
687  // associated with the numbering to the new bullet font.
688  if( pFormat )
689  pNumFnt->SetDiffFnt( pFormat, pIDSA );
690 
691  checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat);
692 
693  lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt );
694 
695  // we do not allow a vertical font
696  pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
697 
698  pRet = new SwNumberPortion( aText, std::move(pNumFnt),
699  bLeft, bCenter, nMinDist,
700  bLabelAlignmentPosAndSpaceModeActive );
701  }
702  }
703  }
704  }
705  return pRet;
706 }
707 
708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxNumType GetNumberingType() const
Base class of the Writer layout elements.
Definition: frame.hxx:295
sal_uLong GetIndex() const
Definition: node.hxx:282
SwViewShell * GetVsh()
Definition: inftxt.hxx:228
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:727
Marks a position in the document model.
Definition: pam.hxx:35
const OUString & GetFamilyName() const
const SwField * GetField() const
Definition: fmtfld.hxx:70
bool IsInDocBody() const
Definition: frame.hxx:919
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:393
OUString GetLabelFollowedBy() const
Retrieves the character following the list label, if the paragraph's list level defines one...
Definition: ndtxt.cxx:4500
SwFlyCntPortion * NewFlyCntPortion(SwTextFormatInfo &rInf, SwTextAttr *pHt) const
Sets a new portion for an object anchored as character.
Definition: itrform2.cxx:2478
SwExpandPortion * NewFieldPortion(SwTextFormatInfo &rInf, const SwTextAttr *pHt) const
Definition: txtfld.cxx:74
sal_uInt16 Height() const
Definition: possiz.hxx:44
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
SwTextAttr * GetAttr(TextFrameIndex nPos) const
Returns the attribute for a position.
Definition: itratr.cxx:142
#define RES_TXTATR_METAFIELD
Definition: hintids.hxx:233
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:388
const OUString & GetStyleName() const
SwNodeIndex nNode
Definition: pam.hxx:37
const SvxBrushItem * GetBrush() const
sal_uIntPtr sal_uLong
Base class of all fields.
Definition: fldbas.hxx:280
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:399
Definition: doc.hxx:185
bool IsNumDone() const
Definition: inftxt.hxx:634
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
Distinguish only for painting/hide.
Definition: porfld.hxx:107
SwFont * m_pFont
Definition: itratr.hxx:39
bool SeekAndChg(SwTextSizeInfo &rInf)
Definition: itrtxt.hxx:310
const std::shared_ptr< SfxItemSet > & GetStyleHandle() const
Definition: fmtautofmt.hxx:49
sal_uInt16 Which() const
Definition: txatbase.hxx:110
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1280
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:153
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
For old documents the Field-Which IDs must be preserved !!!
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4088
FontFamily GetFamilyType()
SvxNumType
size_type size() const
Definition: docary.hxx:368
bool IsFieldName() const
Definition: viewopt.hxx:252
#define RES_CHRATR_END
Definition: hintids.hxx:208
const SfxPoolItem * NextItem()
SwExpandPortion * TryNewNoLengthPortion(SwTextFormatInfo const &rInfo)
Try to create a new portion with zero length, for an end of a hint (where there is no CH_TXTATR)...
Definition: txtfld.cxx:318
LINESTYLE_NONE
void ChangeExpansion(SwDoc *pDoc, bool bVirtPageNum, const SvxNumType *pNumFormat)
Definition: docufld.cxx:127
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
short GetCharTextDistance() const
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:191
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
static void lcl_setRedlineAttr(SwTextFormatInfo &rInf, const SwTextNode &rTextNode, std::unique_ptr< SwFont > &pNumFnt)
Definition: txtfld.cxx:505
sal_uInt16 GetStackCount() const
Definition: docredln.cxx:1705
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
SVX_NUM_BITMAP
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1809
SVX_NUM_CHAR_SPECIAL
SwCharFormat * GetCharFormat() const
Definition: numrule.hxx:73
#define RES_CHRATR_COLOR
Definition: hintids.hxx:165
static SwFieldPortion * lcl_NewMetaPortion(SwTextAttr &rHint, const bool bPrefix)
Definition: txtfld.cxx:296
const SwFormatVertOrient * GetGraphicOrientation() const
Definition: number.cxx:340
const SwViewOption & GetOpt() const
Definition: inftxt.hxx:245
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns...
Definition: porfld.hxx:199
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1290
#define SW_MOD()
Definition: swmodule.hxx:256
SwFootnotePortion * NewFootnotePortion(SwTextFormatInfo &rInf, SwTextAttr *pHt)
The portion for the Footnote Reference in the Text.
Definition: txtftn.cxx:779
FontPitch GetPitch()
void ChgBodyTextFlag(bool bIsInBody)
Set by UpdateExpFields where node position is known.
Definition: expfld.hxx:139
#define RES_TXTATR_FTN
Definition: hintids.hxx:246
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:537
vector_type::size_type size_type
Definition: docary.hxx:330
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:357
SwDoc * GetDoc()
Definition: node.hxx:702
const vcl::Font * GetBulletFont() const
std::unique_ptr< sw::MergedAttrIterByEnd > m_pByEndIter
Definition: itrform2.hxx:45
WEIGHT_NORMAL
bool IsInBodyText() const
Called by formatting.
Definition: expfld.hxx:135
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:162
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2804
Provides access to settings of a document.
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:176
SwFont * GetFnt()
Definition: itratr.hxx:103
#define RES_TXTATR_TOXMARK
Definition: hintids.hxx:231
TextFrameIndex GetIdx() const
Definition: inftxt.hxx:278
const IDocumentSettingAccess * getIDocumentSettingAccess() const
Provides access to the document setting interface.
Definition: node.cxx:2052
SvxAdjust GetNumAdjust() const
bool IsUpdateExpFields()
Definition: viewimp.cxx:150
ITALIC_NONE
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
SwTextFrame * GetTextFrame()
Definition: inftxt.hxx:291
const SwPosition * Start() const
Definition: pam.hxx:212
const SwAttrSet & GetCharAttr() const
Definition: inftxt.hxx:774
void SetNoLength()
Definition: porfld.hxx:52
SwFieldType * GetTyp() const
Definition: fldbas.hxx:383
static void checkApplyParagraphMarkFormatToNumbering(SwFont *pNumFnt, SwTextFormatInfo &rInf, const IDocumentSettingAccess *pIDSA, const SwAttrSet *pFormat)
OOXML spec says that w:rPr inside w:pPr specifies formatting for the paragraph mark symbol (i...
Definition: txtfld.cxx:418
SwTextFrame * m_pFrame
Definition: itrtxt.hxx:34
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:77
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SVX_NUM_PAGEDESC
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:404
LanguageType GetLanguage() const
Definition: swfont.hxx:282
TextFrameIndex m_nStart
Definition: itrtxt.hxx:41
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
#define RES_TXTATR_FIELD
Definition: hintids.hxx:244
const Size & GetGraphicSize() const
#define RES_TXTATR_AUTOFMT
Definition: hintids.hxx:234
void SetLen(const TextFrameIndex nNew)
Definition: inftxt.hxx:281
virtual void SetLanguage(LanguageType nLng)
Definition: fldbas.cxx:362
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1713
bool IsNumbered(SwRootFrame const *pLayout=nullptr) const
Returns is this text node is numbered.
Definition: ndtxt.cxx:2879
#define RES_TXTATR_ANNOTATION
Definition: hintids.hxx:247
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1241
#define RES_PARATR_LIST_AUTOFMT
Definition: hintids.hxx:284
bool IsCountedInList() const
Definition: ndtxt.cxx:4231
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:175
const SwPosition * End() const
Definition: pam.hxx:217
static bool IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich)
In MS Word, the font underline setting of the paragraph end position won't affect the formatting of n...
Definition: thints.cxx:1797
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1728
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
static const SwRangeRedline * lcl_GetRedlineAtNodeInsertionOrDeletion(const SwTextNode &rTextNode)
Definition: txtfld.cxx:482
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:247
SwFontScript
Definition: swfont.hxx:122
SwLinePortion * GetLast()
Definition: inftxt.hxx:566
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:416
const Color & GetHighlightColor() const
Definition: swfont.hxx:193
#define RES_TXTATR_FLYCNT
Definition: hintids.hxx:245
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
#define RES_TXTATR_REFMARK
Definition: hintids.hxx:230
sal_Unicode GetBulletChar() const
OUString GetNumString(const bool _bInclPrefixAndSuffixStrings=true, const unsigned int _nRestrictToThisLevel=MAXLEVEL, SwRootFrame const *pLayout=nullptr) const
Returns outline of numbering string.
Definition: ndtxt.cxx:3121
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
bool IsVertical() const
Definition: frame.hxx:949
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:167
SwDoc & GetDoc()
Definition: txtfrm.hxx:450
void SetDiffFnt(const SfxItemSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
Definition: swfont.cxx:493
bool IsTest() const
Definition: inftxt.hxx:593
SwTextFrame * GetTextFrame()
Definition: itrtxt.hxx:134
const SwFrame * GetAnchorFrame() const
void ChangeExpansion(const SwFrame &, const SwTextField &)
For fields in header/footer/footnotes/flys: Only called by formatting!!
Definition: expfld.cxx:340
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
virtual const SwRedlineTable & GetRedlineTable() const =0
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
SS for PoolItems: hard attributation.
Definition: node.hxx:730
void ChgBodyTextFlag(bool bIsInBody)
set from UpdateExpFields (the Node-Position is known there)
Definition: dbfld.hxx:117
void SetHighlightColor(const Color &aNewColor)
Definition: swfont.hxx:949
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
static constexpr size_type npos
Definition: docary.hxx:331
SwFieldIds Which() const
Definition: fldbas.hxx:266
aStr
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:307
sal_uInt16 & GetAscent()
Definition: porlin.hxx:77
TextFrameIndex GetTextStart() const
Definition: inftxt.hxx:130
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
rtl_TextEncoding GetCharSet() const
const SfxPoolItem * GetCurItem() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1313
bool IsVirtPageNum() const
Definition: rootfrm.hxx:310
static bool lcl_IsInBody(SwFrame const *pFrame)
Definition: txtfld.cxx:60
const SvxNumberType & GetNumType() const
Definition: pagedesc.hxx:193