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