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