LibreOffice Module sw (master)  1
swfont.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 
22 #include <com/sun/star/i18n/ScriptType.hpp>
23 #include <vcl/outdev.hxx>
24 #include <editeng/brushitem.hxx>
25 #include <editeng/wrlmitem.hxx>
26 #include <editeng/blinkitem.hxx>
27 #include <editeng/kernitem.hxx>
28 #include <editeng/cmapitem.hxx>
29 #include <editeng/langitem.hxx>
31 #include <editeng/autokernitem.hxx>
32 #include <editeng/shdditem.hxx>
34 #include <editeng/contouritem.hxx>
35 #include <editeng/colritem.hxx>
37 #include <editeng/udlnitem.hxx>
38 #include <editeng/wghtitem.hxx>
39 #include <editeng/postitem.hxx>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/fontitem.hxx>
45 #include <editeng/twolinesitem.hxx>
47 #include <editeng/boxitem.hxx>
48 #include <editeng/shaditem.hxx>
50 #include <charatr.hxx>
51 #include <viewsh.hxx>
52 #include <swfont.hxx>
53 #include <fntcache.hxx>
54 #include <txtfrm.hxx>
55 #include <scriptinfo.hxx>
56 
57 #ifdef DBG_UTIL
58 // global Variable
60 #endif
61 
62 using namespace ::com::sun::star;
63 
64 // set background brush, depending on character formatting
65 void SwFont::SetBackColor( Color* pNewColor )
66 {
67  m_pBackColor.reset( pNewColor );
68  m_bFontChg = true;
69  m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
70 }
71 
73 {
74  if( pTopBorder )
75  m_aTopBorder = *pTopBorder;
76  else
77  {
78  m_aTopBorder.reset();
79  m_nTopBorderDist = 0;
80  }
81  m_bFontChg = true;
82  m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
83 }
84 
85 void SwFont::SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder )
86 {
87  if( pBottomBorder )
88  m_aBottomBorder = *pBottomBorder;
89  else
90  {
91  m_aBottomBorder.reset();
93  }
94  m_bFontChg = true;
95  m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
96 }
97 
99 {
100  if( pRightBorder )
101  m_aRightBorder = *pRightBorder;
102  else
103  {
104  m_aRightBorder.reset();
105  m_nRightBorderDist = 0;
106  }
107  m_bFontChg = true;
108  m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
109 }
110 
112 {
113  if( pLeftBorder )
114  m_aLeftBorder = *pLeftBorder;
115  else
116  {
117  m_aLeftBorder.reset();
118  m_nLeftBorderDist = 0;
119  }
120  m_bFontChg = true;
121  m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
122 }
123 
124 const std::optional<editeng::SvxBorderLine>&
125 SwFont::GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
126 {
127  switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
128  {
129  case 0 :
130  return m_aTopBorder;
131  break;
132  case 900 :
133  return m_aRightBorder;
134  break;
135  case 1800 :
136  return m_aBottomBorder;
137  break;
138  case 2700 :
139  return m_aLeftBorder;
140  break;
141  default :
142  assert(false);
143  return m_aTopBorder;
144  break;
145  }
146 }
147 
148 const std::optional<editeng::SvxBorderLine>&
149 SwFont::GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
150 {
151  switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
152  {
153  case 0 :
154  return m_aBottomBorder;
155  break;
156  case 900 :
157  return m_aLeftBorder;
158  break;
159  case 1800 :
160  return m_aTopBorder;
161  break;
162  case 2700 :
163  return m_aRightBorder;
164  break;
165  default :
166  assert(false);
167  return m_aBottomBorder;
168  break;
169  }
170 }
171 
172 const std::optional<editeng::SvxBorderLine>&
173 SwFont::GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
174 {
175  switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
176  {
177  case 0 :
178  return m_aLeftBorder;
179  break;
180  case 900 :
181  return m_aTopBorder;
182  break;
183  case 1800 :
184  return m_aRightBorder;
185  break;
186  case 2700 :
187  return m_aBottomBorder;
188  break;
189  default :
190  assert(false);
191  return m_aLeftBorder;
192  break;
193  }
194 }
195 
196 const std::optional<editeng::SvxBorderLine>&
197 SwFont::GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
198 {
199  switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
200  {
201  case 0 :
202  return m_aRightBorder;
203  break;
204  case 900 :
205  return m_aBottomBorder;
206  break;
207  case 1800 :
208  return m_aLeftBorder;
209  break;
210  case 2700 :
211  return m_aTopBorder;
212  break;
213  default :
214  assert(false);
215  return m_aRightBorder;
216  break;
217  }
218 }
219 
221  const bool bVertLayoutLRBT) const
222 {
223  SvxShadowLocation aLocation = SvxShadowLocation::NONE;
224  switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
225  {
226  case 0:
227  aLocation = m_aShadowLocation;
228  break;
229 
230  case 900:
231  switch ( m_aShadowLocation )
232  {
233  case SvxShadowLocation::TopLeft:
234  aLocation = SvxShadowLocation::BottomLeft;
235  break;
236  case SvxShadowLocation::TopRight:
237  aLocation = SvxShadowLocation::TopLeft;
238  break;
239  case SvxShadowLocation::BottomLeft:
240  aLocation = SvxShadowLocation::BottomRight;
241  break;
242  case SvxShadowLocation::BottomRight:
243  aLocation = SvxShadowLocation::TopRight;
244  break;
245  case SvxShadowLocation::NONE:
246  case SvxShadowLocation::End:
247  aLocation = m_aShadowLocation;
248  break;
249  }
250  break;
251 
252  case 1800:
253  switch ( m_aShadowLocation )
254  {
255  case SvxShadowLocation::TopLeft:
256  aLocation = SvxShadowLocation::BottomRight;
257  break;
258  case SvxShadowLocation::TopRight:
259  aLocation = SvxShadowLocation::BottomLeft;
260  break;
261  case SvxShadowLocation::BottomLeft:
262  aLocation = SvxShadowLocation::TopRight;
263  break;
264  case SvxShadowLocation::BottomRight:
265  aLocation = SvxShadowLocation::TopLeft;
266  break;
267  case SvxShadowLocation::NONE:
268  case SvxShadowLocation::End:
269  aLocation = m_aShadowLocation;
270  break;
271  }
272  break;
273 
274  case 2700:
275  switch ( m_aShadowLocation )
276  {
277  case SvxShadowLocation::TopLeft:
278  aLocation = SvxShadowLocation::TopRight;
279  break;
280  case SvxShadowLocation::TopRight:
281  aLocation = SvxShadowLocation::BottomRight;
282  break;
283  case SvxShadowLocation::BottomLeft:
284  aLocation = SvxShadowLocation::TopLeft;
285  break;
286  case SvxShadowLocation::BottomRight:
287  aLocation = SvxShadowLocation::BottomLeft;
288  break;
289  case SvxShadowLocation::NONE:
290  case SvxShadowLocation::End:
291  aLocation = m_aShadowLocation;
292  break;
293  }
294  break;
295 
296  default:
297  assert(false);
298  break;
299  }
300  return aLocation;
301 }
302 
303 sal_uInt16 SwFont::CalcShadowSpace(const SvxShadowItemSide nShadow, const bool bVertLayout,
304  const bool bVertLayoutLRBT, const bool bSkipLeft,
305  const bool bSkipRight) const
306 {
307  sal_uInt16 nSpace = 0;
308  const sal_uInt16 nOrient = GetOrientation(bVertLayout, bVertLayoutLRBT);
309  const SvxShadowLocation aLoc = GetAbsShadowLocation(bVertLayout, bVertLayoutLRBT);
310  switch( nShadow )
311  {
312  case SvxShadowItemSide::TOP:
313  if(( aLoc == SvxShadowLocation::TopLeft ||
314  aLoc == SvxShadowLocation::TopRight ) &&
315  ( nOrient == 0 || nOrient == 1800 ||
316  ( nOrient == 900 && !bSkipRight ) ||
317  ( nOrient == 2700 && !bSkipLeft )))
318  {
319  nSpace = m_nShadowWidth;
320  }
321  break;
322 
323  case SvxShadowItemSide::BOTTOM:
324  if(( aLoc == SvxShadowLocation::BottomLeft ||
325  aLoc == SvxShadowLocation::BottomRight ) &&
326  ( nOrient == 0 || nOrient == 1800 ||
327  ( nOrient == 900 && !bSkipLeft ) ||
328  ( nOrient == 2700 && !bSkipRight )))
329  {
330  nSpace = m_nShadowWidth;
331  }
332  break;
333 
334  case SvxShadowItemSide::LEFT:
335  if(( aLoc == SvxShadowLocation::TopLeft ||
336  aLoc == SvxShadowLocation::BottomLeft ) &&
337  ( nOrient == 900 || nOrient == 2700 ||
338  ( nOrient == 0 && !bSkipLeft ) ||
339  ( nOrient == 1800 && !bSkipRight )))
340  {
341  nSpace = m_nShadowWidth;
342  }
343  break;
344 
345  case SvxShadowItemSide::RIGHT:
346  if(( aLoc == SvxShadowLocation::TopRight ||
347  aLoc == SvxShadowLocation::BottomRight ) &&
348  ( nOrient == 900 || nOrient == 2700 ||
349  ( nOrient == 0 && !bSkipRight ) ||
350  ( nOrient == 1800 && !bSkipLeft )))
351  {
352  nSpace = m_nShadowWidth;
353  }
354  break;
355  default:
356  assert(false);
357  break;
358  }
359 
360  return nSpace;
361 }
362 
363 // maps directions for vertical layout
364 static sal_uInt16 MapDirection(sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT)
365 {
366  if ( bVertFormat )
367  {
368  switch ( nDir )
369  {
370  case 0 :
371  if (bVertFormatLRBT)
372  nDir = 900;
373  else
374  nDir = 2700;
375  break;
376  case 900 :
377  nDir = 0;
378  break;
379  case 2700 :
380  nDir = 1800;
381  break;
382 #if OSL_DEBUG_LEVEL > 0
383  default :
384  OSL_FAIL( "Unsupported direction" );
385  break;
386 #endif
387  }
388  }
389  return nDir;
390 }
391 
392 // maps the absolute direction set at the font to its logical counterpart
393 // in the rotated environment
394 sal_uInt16 UnMapDirection(sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT)
395 {
396  if (bVertFormatLRBT)
397  {
398  switch (nDir)
399  {
400  case 900:
401  nDir = 0;
402  break;
403  default:
404  SAL_WARN("sw.core", "unsupported direction for VertLRBT");
405  break;
406  }
407  return nDir;
408  }
409 
410  if ( bVertFormat )
411  {
412  switch ( nDir )
413  {
414  case 0 :
415  nDir = 900;
416  break;
417  case 1800 :
418  nDir = 2700;
419  break;
420  case 2700 :
421  nDir = 0;
422  break;
423 #if OSL_DEBUG_LEVEL > 0
424  default :
425  OSL_FAIL( "Unsupported direction" );
426  break;
427 #endif
428  }
429  }
430  return nDir;
431 }
432 
433 sal_uInt16 SwFont::GetOrientation(const bool bVertFormat, const bool bVertFormatLRBT) const
434 {
435  return UnMapDirection(m_aSub[m_nActual].GetOrientation(), bVertFormat, bVertFormatLRBT);
436 }
437 
438 void SwFont::SetVertical(sal_uInt16 nDir, const bool bVertFormat, const bool bVertLayoutLRBT)
439 {
440  // map direction if frame has vertical layout
441  nDir = MapDirection(nDir, bVertFormat, bVertLayoutLRBT);
442 
443  if( nDir != m_aSub[SwFontScript::Latin].GetOrientation() )
444  {
445  m_bFontChg = true;
446  m_aSub[SwFontScript::Latin].SetVertical( nDir, bVertFormat );
447  m_aSub[SwFontScript::CJK].SetVertical( nDir, bVertFormat );
448  m_aSub[SwFontScript::CTL].SetVertical( nDir, bVertFormat );
449  }
450 }
451 
452 /*
453  Escapement:
454  frEsc: Fraction, ratio of Escapements
455  Esc = resulting Escapement
456  A1 = original Ascent (nOrgAscent)
457  A2 = shrunk Ascent (nEscAscent)
458  Ax = resulting Ascent (GetAscent())
459  H1 = original Height (nOrgHeight)
460  H2 = shrunk Height (nEscHeight)
461  Hx = resulting Height (GetHeight())
462  Bx = resulting Baseline for Text (CalcPos())
463  (Attention: Y - A1!)
464 
465  Escapement:
466  Esc = H1 * frEsc;
467 
468  Superscript:
469  Ax = A2 + Esc;
470  Hx = H2 + Esc;
471  Bx = A1 - Esc;
472 
473  Subscript:
474  Ax = A1;
475  Hx = A1 + Esc + (H2 - A2);
476  Bx = A1 + Esc;
477 */
478 
479 // nEsc is the percentage
480 sal_uInt16 SwSubFont::CalcEscAscent( const sal_uInt16 nOldAscent ) const
481 {
484  {
485  const long nAscent = nOldAscent +
486  ( static_cast<long>(m_nOrgHeight) * GetEscapement() ) / 100;
487  if ( nAscent>0 )
488  return std::max<sal_uInt16>( nAscent, m_nOrgAscent );
489  }
490  return m_nOrgAscent;
491 }
492 
493 void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
494  const IDocumentSettingAccess *pIDocumentSettingAccess )
495 {
496  m_pBackColor.reset();
497 
498  if( pAttrSet )
499  {
500  const SfxPoolItem* pItem;
501  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_FONT,
502  true, &pItem ))
503  {
504  const SvxFontItem *pFont = static_cast<const SvxFontItem *>(pItem);
505  m_aSub[SwFontScript::Latin].SetFamily( pFont->GetFamily() );
506  m_aSub[SwFontScript::Latin].Font::SetFamilyName( pFont->GetFamilyName() );
507  m_aSub[SwFontScript::Latin].Font::SetStyleName( pFont->GetStyleName() );
508  m_aSub[SwFontScript::Latin].Font::SetPitch( pFont->GetPitch() );
509  m_aSub[SwFontScript::Latin].Font::SetCharSet( pFont->GetCharSet() );
510  }
511  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_FONTSIZE,
512  true, &pItem ))
513  {
514  const SvxFontHeightItem *pHeight = static_cast<const SvxFontHeightItem *>(pItem);
515  m_aSub[SwFontScript::Latin].SvxFont::SetPropr( 100 );
516  m_aSub[SwFontScript::Latin].m_aSize = m_aSub[SwFontScript::Latin].Font::GetFontSize();
517  Size aTmpSize = m_aSub[SwFontScript::Latin].m_aSize;
518  aTmpSize.setHeight( pHeight->GetHeight() );
519  m_aSub[SwFontScript::Latin].SetSize( aTmpSize );
520  }
521  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_POSTURE,
522  true, &pItem ))
523  m_aSub[SwFontScript::Latin].Font::SetItalic( static_cast<const SvxPostureItem*>(pItem)->GetPosture() );
524  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_WEIGHT,
525  true, &pItem ))
526  m_aSub[SwFontScript::Latin].Font::SetWeight( static_cast<const SvxWeightItem*>(pItem)->GetWeight() );
527  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_LANGUAGE,
528  true, &pItem ))
529  m_aSub[SwFontScript::Latin].SetLanguage( static_cast<const SvxLanguageItem*>(pItem)->GetLanguage() );
530 
531  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONT,
532  true, &pItem ))
533  {
534  const SvxFontItem *pFont = static_cast<const SvxFontItem *>(pItem);
535  m_aSub[SwFontScript::CJK].SetFamily( pFont->GetFamily() );
536  m_aSub[SwFontScript::CJK].Font::SetFamilyName( pFont->GetFamilyName() );
537  m_aSub[SwFontScript::CJK].Font::SetStyleName( pFont->GetStyleName() );
538  m_aSub[SwFontScript::CJK].Font::SetPitch( pFont->GetPitch() );
539  m_aSub[SwFontScript::CJK].Font::SetCharSet( pFont->GetCharSet() );
540  }
541  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONTSIZE,
542  true, &pItem ))
543  {
544  const SvxFontHeightItem *pHeight = static_cast<const SvxFontHeightItem *>(pItem);
545  m_aSub[SwFontScript::CJK].SvxFont::SetPropr( 100 );
546  m_aSub[SwFontScript::CJK].m_aSize = m_aSub[SwFontScript::CJK].Font::GetFontSize();
547  Size aTmpSize = m_aSub[SwFontScript::CJK].m_aSize;
548  aTmpSize.setHeight( pHeight->GetHeight() );
549  m_aSub[SwFontScript::CJK].SetSize( aTmpSize );
550  }
551  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CJK_POSTURE,
552  true, &pItem ))
553  m_aSub[SwFontScript::CJK].Font::SetItalic( static_cast<const SvxPostureItem*>(pItem)->GetPosture() );
554  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CJK_WEIGHT,
555  true, &pItem ))
556  m_aSub[SwFontScript::CJK].Font::SetWeight( static_cast<const SvxWeightItem*>(pItem)->GetWeight() );
557  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CJK_LANGUAGE,
558  true, &pItem ))
559  {
560  LanguageType eNewLang = static_cast<const SvxLanguageItem*>(pItem)->GetLanguage();
561  m_aSub[SwFontScript::CJK].SetLanguage( eNewLang );
562  m_aSub[SwFontScript::Latin].SetCJKContextLanguage( eNewLang );
563  m_aSub[SwFontScript::CJK].SetCJKContextLanguage( eNewLang );
564  m_aSub[SwFontScript::CTL].SetCJKContextLanguage( eNewLang );
565  }
566 
567  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONT,
568  true, &pItem ))
569  {
570  const SvxFontItem *pFont = static_cast<const SvxFontItem *>(pItem);
571  m_aSub[SwFontScript::CTL].SetFamily( pFont->GetFamily() );
572  m_aSub[SwFontScript::CTL].Font::SetFamilyName( pFont->GetFamilyName() );
573  m_aSub[SwFontScript::CTL].Font::SetStyleName( pFont->GetStyleName() );
574  m_aSub[SwFontScript::CTL].Font::SetPitch( pFont->GetPitch() );
575  m_aSub[SwFontScript::CTL].Font::SetCharSet( pFont->GetCharSet() );
576  }
577  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONTSIZE,
578  true, &pItem ))
579  {
580  const SvxFontHeightItem *pHeight = static_cast<const SvxFontHeightItem *>(pItem);
581  m_aSub[SwFontScript::CTL].SvxFont::SetPropr( 100 );
582  m_aSub[SwFontScript::CTL].m_aSize = m_aSub[SwFontScript::CTL].Font::GetFontSize();
583  Size aTmpSize = m_aSub[SwFontScript::CTL].m_aSize;
584  aTmpSize.setHeight( pHeight->GetHeight() );
585  m_aSub[SwFontScript::CTL].SetSize( aTmpSize );
586  }
587  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CTL_POSTURE,
588  true, &pItem ))
589  m_aSub[SwFontScript::CTL].Font::SetItalic( static_cast<const SvxPostureItem*>(pItem)->GetPosture() );
590  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CTL_WEIGHT,
591  true, &pItem ))
592  m_aSub[SwFontScript::CTL].Font::SetWeight( static_cast<const SvxWeightItem*>(pItem)->GetWeight() );
593  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CTL_LANGUAGE,
594  true, &pItem ))
595  m_aSub[SwFontScript::CTL].SetLanguage( static_cast<const SvxLanguageItem*>(pItem)->GetLanguage() );
596 
597  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_UNDERLINE,
598  true, &pItem ))
599  {
600  SetUnderline( static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle() );
601  SetUnderColor( static_cast<const SvxUnderlineItem*>(pItem)->GetColor() );
602  }
603  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_OVERLINE,
604  true, &pItem ))
605  {
606  SetOverline( static_cast<const SvxOverlineItem*>(pItem)->GetLineStyle() );
607  SetOverColor( static_cast<const SvxOverlineItem*>(pItem)->GetColor() );
608  }
609  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CROSSEDOUT,
610  true, &pItem ))
611  SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() );
612  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_COLOR,
613  true, &pItem ))
614  SetColor( static_cast<const SvxColorItem*>(pItem)->GetValue() );
615  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_EMPHASIS_MARK,
616  true, &pItem ))
617  SetEmphasisMark( static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark() );
618 
619  SetTransparent( true );
621  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CONTOUR,
622  true, &pItem ))
623  SetOutline( static_cast<const SvxContourItem*>(pItem)->GetValue() );
624  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
625  true, &pItem ))
626  SetShadow( static_cast<const SvxShadowedItem*>(pItem)->GetValue() );
627  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_RELIEF,
628  true, &pItem ))
629  SetRelief( static_cast<const SvxCharReliefItem*>(pItem)->GetValue() );
630  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
631  true, &pItem ))
632  SetPropWidth(static_cast<const SvxShadowedItem*>(pItem)->GetValue() ? 50 : 100 );
633  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_AUTOKERN,
634  true, &pItem ))
635  {
636  if( static_cast<const SvxAutoKernItem*>(pItem)->GetValue() )
637  {
638  SetAutoKern( ( !pIDocumentSettingAccess ||
639  !pIDocumentSettingAccess->get(DocumentSettingId::KERN_ASIAN_PUNCTUATION) ) ?
640  FontKerning::FontSpecific :
641  FontKerning::Asian );
642  }
643  else
644  SetAutoKern( FontKerning::NONE );
645  }
646  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_WORDLINEMODE,
647  true, &pItem ))
648  SetWordLineMode( static_cast<const SvxWordLineModeItem*>(pItem)->GetValue() );
649 
650  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_ESCAPEMENT,
651  true, &pItem ))
652  {
653  const SvxEscapementItem *pEsc = static_cast<const SvxEscapementItem *>(pItem);
654  SetEscapement( pEsc->GetEsc() );
655  if( m_aSub[SwFontScript::Latin].IsEsc() )
657  }
658  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_CASEMAP,
659  true, &pItem ))
660  SetCaseMap( static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap() );
661  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_KERNING,
662  true, &pItem ))
663  SetFixKerning( static_cast<const SvxKerningItem*>(pItem)->GetValue() );
664  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BLINK,
665  true, &pItem ))
666  SetBlink( static_cast<const SvxBlinkItem*>(pItem)->GetValue() );
667  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_ROTATE,
668  true, &pItem ))
669  SetVertical( static_cast<const SvxCharRotateItem*>(pItem)->GetValue() );
670  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
671  true, &pItem ))
672  m_pBackColor.reset( new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() ) );
673  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
674  true, &pItem ))
675  SetHighlightColor(static_cast<const SvxBrushItem*>(pItem)->GetColor());
676  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
677  true, &pItem ))
678  {
679  const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
680  SetTopBorder(pBoxItem->GetTop());
681  SetBottomBorder(pBoxItem->GetBottom());
682  SetRightBorder(pBoxItem->GetRight());
683  SetLeftBorder(pBoxItem->GetLeft());
684  SetTopBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP));
685  SetBottomBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM));
686  SetRightBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::RIGHT));
687  SetLeftBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
688  }
689  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_SHADOW,
690  true, &pItem ))
691  {
692  const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
693  SetShadowColor(pShadowItem->GetColor());
694  SetShadowWidth(pShadowItem->GetWidth());
695  SetShadowLocation(pShadowItem->GetLocation());
696  }
697  const SfxPoolItem* pTwoLinesItem = nullptr;
698  if( SfxItemState::SET ==
699  pAttrSet->GetItemState( RES_CHRATR_TWO_LINES, true, &pTwoLinesItem ))
700  if ( static_cast<const SvxTwoLinesItem*>(pTwoLinesItem)->GetValue() )
701  SetVertical( 0 );
702  }
703  else
704  {
705  Invalidate();
706  m_bBlink = false;
707  }
708  m_bPaintBlank = false;
709  OSL_ENSURE( m_aSub[SwFontScript::Latin].IsTransparent(), "SwFont: Transparent revolution" );
710 }
711 
712 SwFont::SwFont( const SwFont &rFont )
713  : m_aSub(rFont.m_aSub)
714 {
715  m_nActual = rFont.m_nActual;
716  m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
718  m_aTopBorder = rFont.m_aTopBorder;
729  m_aUnderColor = rFont.GetUnderColor();
730  m_aOverColor = rFont.GetOverColor();
731  m_nToxCount = 0;
732  m_nRefCount = 0;
733  m_nMetaCount = 0;
734  m_nInputFieldCount = 0;
735  m_bFontChg = rFont.m_bFontChg;
736  m_bOrgChg = rFont.m_bOrgChg;
738  m_bGreyWave = rFont.m_bGreyWave;
739  m_bBlink = rFont.m_bBlink;
740 }
741 
742 SwFont::SwFont( const SwAttrSet* pAttrSet,
743  const IDocumentSettingAccess* pIDocumentSettingAccess )
744  : m_aSub()
745 {
747  m_nToxCount = 0;
748  m_nRefCount = 0;
749  m_nMetaCount = 0;
750  m_nInputFieldCount = 0;
751  m_bPaintBlank = false;
752  m_bGreyWave = false;
753  m_bBlink = pAttrSet->GetBlink().GetValue();
754  m_bOrgChg = true;
755  {
756  const SvxFontItem& rFont = pAttrSet->GetFont();
757  m_aSub[SwFontScript::Latin].SetFamily( rFont.GetFamily() );
758  m_aSub[SwFontScript::Latin].SetFamilyName( rFont.GetFamilyName() );
759  m_aSub[SwFontScript::Latin].SetStyleName( rFont.GetStyleName() );
760  m_aSub[SwFontScript::Latin].SetPitch( rFont.GetPitch() );
761  m_aSub[SwFontScript::Latin].SetCharSet( rFont.GetCharSet() );
762  m_aSub[SwFontScript::Latin].SvxFont::SetPropr( 100 ); // 100% of FontSize
763  Size aTmpSize = m_aSub[SwFontScript::Latin].m_aSize;
764  aTmpSize.setHeight( pAttrSet->GetSize().GetHeight() );
765  m_aSub[SwFontScript::Latin].SetSize( aTmpSize );
766  m_aSub[SwFontScript::Latin].SetItalic( pAttrSet->GetPosture().GetPosture() );
767  m_aSub[SwFontScript::Latin].SetWeight( pAttrSet->GetWeight().GetWeight() );
768  m_aSub[SwFontScript::Latin].SetLanguage( pAttrSet->GetLanguage().GetLanguage() );
769  }
770 
771  {
772  const SvxFontItem& rFont = pAttrSet->GetCJKFont();
773  m_aSub[SwFontScript::CJK].SetFamily( rFont.GetFamily() );
774  m_aSub[SwFontScript::CJK].SetFamilyName( rFont.GetFamilyName() );
775  m_aSub[SwFontScript::CJK].SetStyleName( rFont.GetStyleName() );
776  m_aSub[SwFontScript::CJK].SetPitch( rFont.GetPitch() );
777  m_aSub[SwFontScript::CJK].SetCharSet( rFont.GetCharSet() );
778  m_aSub[SwFontScript::CJK].SvxFont::SetPropr( 100 ); // 100% of FontSize
779  Size aTmpSize = m_aSub[SwFontScript::CJK].m_aSize;
780  aTmpSize.setHeight( pAttrSet->GetCJKSize().GetHeight() );
781  m_aSub[SwFontScript::CJK].SetSize( aTmpSize );
782  m_aSub[SwFontScript::CJK].SetItalic( pAttrSet->GetCJKPosture().GetPosture() );
783  m_aSub[SwFontScript::CJK].SetWeight( pAttrSet->GetCJKWeight().GetWeight() );
784  LanguageType eNewLang = pAttrSet->GetCJKLanguage().GetLanguage();
785  m_aSub[SwFontScript::CJK].SetLanguage( eNewLang );
786  m_aSub[SwFontScript::Latin].SetCJKContextLanguage( eNewLang );
787  m_aSub[SwFontScript::CJK].SetCJKContextLanguage( eNewLang );
788  m_aSub[SwFontScript::CTL].SetCJKContextLanguage( eNewLang );
789  }
790 
791  {
792  const SvxFontItem& rFont = pAttrSet->GetCTLFont();
793  m_aSub[SwFontScript::CTL].SetFamily( rFont.GetFamily() );
794  m_aSub[SwFontScript::CTL].SetFamilyName( rFont.GetFamilyName() );
795  m_aSub[SwFontScript::CTL].SetStyleName( rFont.GetStyleName() );
796  m_aSub[SwFontScript::CTL].SetPitch( rFont.GetPitch() );
797  m_aSub[SwFontScript::CTL].SetCharSet( rFont.GetCharSet() );
798  m_aSub[SwFontScript::CTL].SvxFont::SetPropr( 100 ); // 100% of FontSize
799  Size aTmpSize = m_aSub[SwFontScript::CTL].m_aSize;
800  aTmpSize.setHeight( pAttrSet->GetCTLSize().GetHeight() );
801  m_aSub[SwFontScript::CTL].SetSize( aTmpSize );
802  m_aSub[SwFontScript::CTL].SetItalic( pAttrSet->GetCTLPosture().GetPosture() );
803  m_aSub[SwFontScript::CTL].SetWeight( pAttrSet->GetCTLWeight().GetWeight() );
804  m_aSub[SwFontScript::CTL].SetLanguage( pAttrSet->GetCTLLanguage().GetLanguage() );
805  }
806  if ( pAttrSet->GetCharHidden().GetValue() )
808  else
809  SetUnderline( pAttrSet->GetUnderline().GetLineStyle() );
810  SetUnderColor( pAttrSet->GetUnderline().GetColor() );
811  SetOverline( pAttrSet->GetOverline().GetLineStyle() );
812  SetOverColor( pAttrSet->GetOverline().GetColor() );
814  SetStrikeout( pAttrSet->GetCrossedOut().GetStrikeout() );
815  SetColor( pAttrSet->GetColor().GetValue() );
816  SetTransparent( true );
818  SetOutline( pAttrSet->GetContour().GetValue() );
819  SetShadow( pAttrSet->GetShadowed().GetValue() );
820  SetPropWidth( pAttrSet->GetCharScaleW().GetValue() );
821  SetRelief( pAttrSet->GetCharRelief().GetValue() );
822  if( pAttrSet->GetAutoKern().GetValue() )
823  {
824  SetAutoKern( ( !pIDocumentSettingAccess ||
825  !pIDocumentSettingAccess->get(DocumentSettingId::KERN_ASIAN_PUNCTUATION) ) ?
826  FontKerning::FontSpecific :
827  FontKerning::Asian );
828  }
829  else
830  SetAutoKern( FontKerning::NONE );
831  SetWordLineMode( pAttrSet->GetWordLineMode().GetValue() );
832  const SvxEscapementItem &rEsc = pAttrSet->GetEscapement();
833  SetEscapement( rEsc.GetEsc() );
834  if( m_aSub[SwFontScript::Latin].IsEsc() )
835  SetProportion( rEsc.GetProportionalHeight() );
836  SetCaseMap( pAttrSet->GetCaseMap().GetCaseMap() );
837  SetFixKerning( pAttrSet->GetKerning().GetValue() );
838  const SfxPoolItem* pItem;
839  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
840  true, &pItem ))
841  m_pBackColor.reset( new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() ) );
842  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
843  true, &pItem ))
844  SetHighlightColor(static_cast<const SvxBrushItem*>(pItem)->GetColor());
845  else
847  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
848  true, &pItem ))
849  {
850  const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
851  SetTopBorder(pBoxItem->GetTop());
852  SetBottomBorder(pBoxItem->GetBottom());
853  SetRightBorder(pBoxItem->GetRight());
854  SetLeftBorder(pBoxItem->GetLeft());
855  SetTopBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP));
856  SetBottomBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM));
857  SetRightBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::RIGHT));
858  SetLeftBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
859  }
860  else
861  {
862  SetTopBorder(nullptr);
863  SetBottomBorder(nullptr);
864  SetRightBorder(nullptr);
865  SetLeftBorder(nullptr);
866  SetTopBorderDist(0);
870  }
871 
872  if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_SHADOW,
873  true, &pItem ))
874  {
875  const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
876  SetShadowColor(pShadowItem->GetColor());
877  SetShadowWidth(pShadowItem->GetWidth());
878  SetShadowLocation(pShadowItem->GetLocation());
879  }
880  else
881  {
883  SetShadowWidth(0);
884  SetShadowLocation(SvxShadowLocation::NONE);
885  }
886 
887  const SvxTwoLinesItem& rTwoLinesItem = pAttrSet->Get2Lines();
888  if ( ! rTwoLinesItem.GetValue() )
889  SetVertical( pAttrSet->GetCharRotate().GetValue() );
890  else
891  SetVertical( 0 );
892  if( pIDocumentSettingAccess && pIDocumentSettingAccess->get( DocumentSettingId::SMALL_CAPS_PERCENTAGE_66 ))
893  {
894  m_aSub[ SwFontScript::Latin ].m_bSmallCapsPercentage66 = true;
895  m_aSub[ SwFontScript::CJK ].m_bSmallCapsPercentage66 = true;
896  m_aSub[ SwFontScript::CTL ].m_bSmallCapsPercentage66 = true;
897  }
898 }
899 
901 {
902 }
903 
905 {
906  if (this != &rFont)
907  {
911  m_nActual = rFont.m_nActual;
912  m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
914  m_aTopBorder = rFont.m_aTopBorder;
925  m_aUnderColor = rFont.GetUnderColor();
926  m_aOverColor = rFont.GetOverColor();
927  m_nToxCount = 0;
928  m_nRefCount = 0;
929  m_nMetaCount = 0;
930  m_nInputFieldCount = 0;
931  m_bFontChg = rFont.m_bFontChg;
932  m_bOrgChg = rFont.m_bOrgChg;
934  m_bGreyWave = rFont.m_bGreyWave;
935  m_bBlink = rFont.m_bBlink;
936  }
937  return *this;
938 }
939 
941 {
942  SwFntAccess aFntAccess( m_aSub[nWhich].m_nFontCacheId, m_aSub[nWhich].m_nFontIndex,
943  &m_aSub[nWhich], pSh, true );
944 }
945 
947 {
948  SwFntAccess aFntAccess( m_nFontCacheId, m_nFontIndex, this, pSh, false );
949  return aFntAccess.Get()->IsSymbol();
950 }
951 
952 bool SwSubFont::ChgFnt( SwViewShell const *pSh, OutputDevice& rOut )
953 {
954  if ( pLastFont )
955  pLastFont->Unlock();
956  SwFntAccess aFntAccess( m_nFontCacheId, m_nFontIndex, this, pSh, true );
957  SV_STAT( nChangeFont );
958 
959  pLastFont = aFntAccess.Get();
960 
961  pLastFont->SetDevFont( pSh, rOut );
962 
963  pLastFont->Lock();
964  return LINESTYLE_NONE != GetUnderline() ||
965  LINESTYLE_NONE != GetOverline() ||
966  STRIKEOUT_NONE != GetStrikeout();
967 }
968 
969 void SwFont::ChgPhysFnt( SwViewShell const *pSh, OutputDevice& rOut )
970 {
971  if( m_bOrgChg && m_aSub[m_nActual].IsEsc() )
972  {
973  const sal_uInt8 nOldProp = m_aSub[m_nActual].GetPropr();
974  SetProportion( 100 );
975  ChgFnt( pSh, rOut );
976  SwFntAccess aFntAccess( m_aSub[m_nActual].m_nFontCacheId, m_aSub[m_nActual].m_nFontIndex,
977  &m_aSub[m_nActual], pSh );
978  m_aSub[m_nActual].m_nOrgHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
979  m_aSub[m_nActual].m_nOrgAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
980  SetProportion( nOldProp );
981  m_bOrgChg = false;
982  }
983 
984  if( m_bFontChg )
985  {
986  ChgFnt( pSh, rOut );
988  }
989  if( rOut.GetTextLineColor() != m_aUnderColor )
991  if( rOut.GetOverlineColor() != m_aOverColor )
993 }
994 
995 // Height = MaxAscent + MaxDescent
996 // MaxAscent = Max (T1_ascent, T2_ascent + (Esc * T1_height) );
997 // MaxDescent = Max (T1_height-T1_ascent,
998 // T2_height-T2_ascent - (Esc * T1_height)
999 sal_uInt16 SwSubFont::CalcEscHeight( const sal_uInt16 nOldHeight,
1000  const sal_uInt16 nOldAscent ) const
1001 {
1004  {
1005  long nDescent = nOldHeight - nOldAscent -
1006  ( static_cast<long>(m_nOrgHeight) * GetEscapement() ) / 100;
1007  const sal_uInt16 nDesc = nDescent>0
1008  ? std::max<sal_uInt16>( nDescent, m_nOrgHeight - m_nOrgAscent)
1010  return ( nDesc + CalcEscAscent( nOldAscent ) );
1011  }
1012  return m_nOrgHeight;
1013 }
1014 
1016 {
1017  short nKernx = - short( Font::GetFontSize().Height() / 6 );
1018 
1019  if ( nKernx < GetFixKerning() )
1020  return GetFixKerning();
1021  return nKernx;
1022 }
1023 
1024 sal_uInt16 SwSubFont::GetAscent( SwViewShell const *pSh, const OutputDevice& rOut )
1025 {
1026  SwFntAccess aFntAccess( m_nFontCacheId, m_nFontIndex, this, pSh );
1027  const sal_uInt16 nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
1028  return GetEscapement() ? CalcEscAscent( nAscent ) : nAscent;
1029 }
1030 
1031 sal_uInt16 SwSubFont::GetHeight( SwViewShell const *pSh, const OutputDevice& rOut )
1032 {
1033  SV_STAT( nGetTextSize );
1034  SwFntAccess aFntAccess( m_nFontCacheId, m_nFontIndex, this, pSh );
1035  const sal_uInt16 nHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
1036  if ( GetEscapement() )
1037  {
1038  const sal_uInt16 nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
1039  return CalcEscHeight( nHeight, nAscent ); // + nLeading;
1040  }
1041  return nHeight; // + nLeading;
1042 }
1043 
1045 {
1046  // Robust: the font is supposed to be set already, but better safe than
1047  // sorry...
1048  if ( !pLastFont || pLastFont->GetOwner() != reinterpret_cast<const void*>(m_nFontCacheId) ||
1049  !IsSameInstance( rInf.GetpOut()->GetFont() ) )
1050  ChgFnt( rInf.GetShell(), rInf.GetOut() );
1051 
1052  SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1053 
1054  Size aTextSize;
1055  TextFrameIndex const nLn = rInf.GetLen() == TextFrameIndex(COMPLETE_STRING)
1056  ? TextFrameIndex(rInf.GetText().getLength())
1057  : rInf.GetLen();
1058  rInf.SetLen( nLn );
1059  if( IsCapital() && nLn )
1060  aTextSize = GetCapitalSize( rInf );
1061  else
1062  {
1063  SV_STAT( nGetTextSize );
1064  long nOldKern = rInf.GetKern();
1065  const OUString oldText = rInf.GetText();
1066  rInf.SetKern( CheckKerning() );
1067  if ( !IsCaseMap() )
1068  aTextSize = pLastFont->GetTextSize( rInf );
1069  else
1070  {
1071  const OUString aTmp = CalcCaseMap( rInf.GetText() );
1072  const OUString oldStr = rInf.GetText();
1073  bool bCaseMapLengthDiffers(aTmp.getLength() != oldStr.getLength());
1074 
1075  if(bCaseMapLengthDiffers && rInf.GetLen())
1076  {
1077  // If the length of the original string and the CaseMapped one
1078  // are different, it is necessary to handle the given text part as
1079  // a single snippet since its size may differ, too.
1080  TextFrameIndex const nOldIdx(rInf.GetIdx());
1081  TextFrameIndex const nOldLen(rInf.GetLen());
1082  const OUString aSnippet(oldStr.copy(sal_Int32(nOldIdx), sal_Int32(nOldLen)));
1083  const OUString aNewText(CalcCaseMap(aSnippet));
1084 
1085  rInf.SetText( aNewText );
1086  rInf.SetIdx( TextFrameIndex(0) );
1087  rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
1088 
1089  aTextSize = pLastFont->GetTextSize( rInf );
1090 
1091  rInf.SetIdx( nOldIdx );
1092  rInf.SetLen( nOldLen );
1093  }
1094  else
1095  {
1096  rInf.SetText( aTmp );
1097  aTextSize = pLastFont->GetTextSize( rInf );
1098  }
1099 
1100  rInf.SetText(oldStr);
1101  }
1102  rInf.SetKern( nOldKern );
1103  rInf.SetText(oldText);
1104  // A word that's longer than one line, with escapement at the line
1105  // break, must report its effective height.
1106  if( GetEscapement() )
1107  {
1108  const sal_uInt16 nAscent = pLastFont->GetFontAscent( rInf.GetShell(),
1109  rInf.GetOut() );
1110  aTextSize.setHeight(
1111  static_cast<long>(CalcEscHeight( static_cast<sal_uInt16>(aTextSize.Height()), nAscent)) );
1112  }
1113  }
1114 
1115  if (TextFrameIndex(1) == rInf.GetLen()
1116  && CH_TXT_ATR_FIELDSTART == rInf.GetText()[sal_Int32(rInf.GetIdx())])
1117  {
1118  assert(!"this is presumably dead code");
1119  TextFrameIndex const nOldIdx(rInf.GetIdx());
1120  TextFrameIndex const nOldLen(rInf.GetLen());
1121  const OUString aNewText(CH_TXT_ATR_SUBST_FIELDSTART);
1122  rInf.SetText( aNewText );
1123  rInf.SetIdx( TextFrameIndex(0) );
1124  rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
1125  aTextSize = pLastFont->GetTextSize( rInf );
1126  rInf.SetIdx( nOldIdx );
1127  rInf.SetLen( nOldLen );
1128  }
1129  else if (TextFrameIndex(1) == rInf.GetLen()
1130  && CH_TXT_ATR_FIELDEND == rInf.GetText()[sal_Int32(rInf.GetIdx())])
1131  {
1132  assert(!"this is presumably dead code");
1133  TextFrameIndex const nOldIdx(rInf.GetIdx());
1134  TextFrameIndex const nOldLen(rInf.GetLen());
1135  const OUString aNewText(CH_TXT_ATR_SUBST_FIELDEND);
1136  rInf.SetText( aNewText );
1137  rInf.SetIdx( TextFrameIndex(0) );
1138  rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
1139  aTextSize = pLastFont->GetTextSize( rInf );
1140  rInf.SetIdx( nOldIdx );
1141  rInf.SetLen( nOldLen );
1142  }
1143 
1144  return aTextSize;
1145 }
1146 
1147 void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const bool bGrey )
1148 {
1149  rInf.SetGreyWave( bGrey );
1150  TextFrameIndex const nLn(rInf.GetText().getLength());
1151  if( !rInf.GetLen() || !nLn )
1152  return;
1153  if (TextFrameIndex(COMPLETE_STRING) == rInf.GetLen())
1154  rInf.SetLen( nLn );
1155 
1156  FontLineStyle nOldUnder = LINESTYLE_NONE;
1157  SwUnderlineFont* pUnderFnt = nullptr;
1158 
1159  if( rInf.GetUnderFnt() )
1160  {
1161  nOldUnder = GetUnderline();
1163  pUnderFnt = rInf.GetUnderFnt();
1164  }
1165 
1166  if( !pLastFont || pLastFont->GetOwner() != reinterpret_cast<const void*>(m_nFontCacheId) )
1167  ChgFnt( rInf.GetShell(), rInf.GetOut() );
1168 
1169  SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1170 
1171  const Point aOldPos(rInf.GetPos());
1172  Point aPos( rInf.GetPos() );
1173 
1174  if( GetEscapement() )
1175  CalcEsc( rInf, aPos );
1176 
1177  rInf.SetPos( aPos );
1179 
1180  if( IsCapital() )
1181  DrawCapital( rInf );
1182  else
1183  {
1184  SV_STAT( nDrawText );
1185  if ( !IsCaseMap() )
1186  pLastFont->DrawText( rInf );
1187  else
1188  {
1189  const OUString oldStr = rInf.GetText();
1190  const OUString aString( CalcCaseMap(oldStr) );
1191  bool bCaseMapLengthDiffers(aString.getLength() != oldStr.getLength());
1192 
1193  if(bCaseMapLengthDiffers && rInf.GetLen())
1194  {
1195  // If the length of the original string and the CaseMapped one
1196  // are different, it is necessary to handle the given text part as
1197  // a single snippet since its size may differ, too.
1198  TextFrameIndex const nOldIdx(rInf.GetIdx());
1199  TextFrameIndex const nOldLen(rInf.GetLen());
1200  const OUString aSnippet(oldStr.copy(sal_Int32(nOldIdx), sal_Int32(nOldLen)));
1201  const OUString aNewText = CalcCaseMap(aSnippet);
1202 
1203  rInf.SetText( aNewText );
1204  rInf.SetIdx( TextFrameIndex(0) );
1205  rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
1206 
1207  pLastFont->DrawText( rInf );
1208 
1209  rInf.SetIdx( nOldIdx );
1210  rInf.SetLen( nOldLen );
1211  }
1212  else
1213  {
1214  rInf.SetText( aString );
1215  pLastFont->DrawText( rInf );
1216  }
1217 
1218  rInf.SetText(oldStr);
1219  }
1220  }
1221 
1222  if( pUnderFnt && nOldUnder != LINESTYLE_NONE )
1223  {
1224  Size aFontSize = GetTextSize_( rInf );
1225  const OUString oldStr = rInf.GetText();
1226 
1227  TextFrameIndex const nOldIdx = rInf.GetIdx();
1228  TextFrameIndex const nOldLen = rInf.GetLen();
1229  long nSpace = 0;
1230  if( rInf.GetSpace() )
1231  {
1232  TextFrameIndex nTmpEnd = nOldIdx + nOldLen;
1233  if (nTmpEnd > TextFrameIndex(oldStr.getLength()))
1234  nTmpEnd = TextFrameIndex(oldStr.getLength());
1235 
1236  const SwScriptInfo* pSI = rInf.GetScriptInfo();
1237 
1238  const bool bAsianFont =
1239  ( rInf.GetFont() && SwFontScript::CJK == rInf.GetFont()->GetActual() );
1240  for (TextFrameIndex nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp)
1241  {
1242  if (CH_BLANK == oldStr[sal_Int32(nTmp)] || bAsianFont ||
1243  (nTmp + TextFrameIndex(1) < TextFrameIndex(oldStr.getLength())
1244  && pSI
1245  && i18n::ScriptType::ASIAN == pSI->ScriptType(nTmp + TextFrameIndex(1))))
1246  {
1247  ++nSpace;
1248  }
1249  }
1250 
1251  // if next portion if a hole portion we do not consider any
1252  // extra space added because the last character was ASIAN
1253  if ( nSpace && rInf.IsSpaceStop() && bAsianFont )
1254  --nSpace;
1255 
1256  nSpace *= rInf.GetSpace() / SPACING_PRECISION_FACTOR;
1257  }
1258 
1259  rInf.SetWidth( sal_uInt16(aFontSize.Width() + nSpace) );
1260  rInf.SetText( " " );
1261  rInf.SetIdx( TextFrameIndex(0) );
1262  rInf.SetLen( TextFrameIndex(2) );
1263  SetUnderline( nOldUnder );
1264  rInf.SetUnderFnt( nullptr );
1265 
1266  // set position for underline font
1267  rInf.SetPos( pUnderFnt->GetPos() );
1268 
1269  pUnderFnt->GetFont().DrawStretchText_( rInf );
1270 
1271  rInf.SetUnderFnt( pUnderFnt );
1272  rInf.SetText(oldStr);
1273  rInf.SetIdx( nOldIdx );
1274  rInf.SetLen( nOldLen );
1275  }
1276 
1277  rInf.SetPos(aOldPos);
1278 }
1279 
1281 {
1282  if( !rInf.GetLen() || !rInf.GetText().getLength() )
1283  return;
1284 
1285  FontLineStyle nOldUnder = LINESTYLE_NONE;
1286  SwUnderlineFont* pUnderFnt = nullptr;
1287 
1288  if( rInf.GetUnderFnt() )
1289  {
1290  nOldUnder = GetUnderline();
1292  pUnderFnt = rInf.GetUnderFnt();
1293  }
1294 
1295  if ( !pLastFont || pLastFont->GetOwner() != reinterpret_cast<const void*>(m_nFontCacheId) )
1296  ChgFnt( rInf.GetShell(), rInf.GetOut() );
1297 
1298  SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1299 
1300  rInf.ApplyAutoColor();
1301 
1302  const Point aOldPos(rInf.GetPos());
1303  Point aPos( rInf.GetPos() );
1304 
1305  if( GetEscapement() )
1306  CalcEsc( rInf, aPos );
1307 
1309  rInf.SetPos( aPos );
1310 
1311  if( IsCapital() )
1312  DrawStretchCapital( rInf );
1313  else
1314  {
1315  SV_STAT( nDrawStretchText );
1316 
1317  if ( rInf.GetFrame() )
1318  {
1319  if ( rInf.GetFrame()->IsRightToLeft() )
1320  rInf.GetFrame()->SwitchLTRtoRTL( aPos );
1321 
1322  if ( rInf.GetFrame()->IsVertical() )
1323  rInf.GetFrame()->SwitchHorizontalToVertical( aPos );
1324 
1325  rInf.SetPos( aPos );
1326  }
1327 
1328  if ( !IsCaseMap() )
1329  rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(),
1330  rInf.GetText(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
1331  else
1332  rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(),
1333  CalcCaseMap(rInf.GetText()),
1334  sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
1335  }
1336 
1337  if( pUnderFnt && nOldUnder != LINESTYLE_NONE )
1338  {
1339  const OUString oldStr = rInf.GetText();
1340  TextFrameIndex const nOldIdx = rInf.GetIdx();
1341  TextFrameIndex const nOldLen = rInf.GetLen();
1342  rInf.SetText( " " );
1343  rInf.SetIdx( TextFrameIndex(0) );
1344  rInf.SetLen( TextFrameIndex(2) );
1345  SetUnderline( nOldUnder );
1346  rInf.SetUnderFnt( nullptr );
1347 
1348  // set position for underline font
1349  rInf.SetPos( pUnderFnt->GetPos() );
1350 
1351  pUnderFnt->GetFont().DrawStretchText_( rInf );
1352 
1353  rInf.SetUnderFnt( pUnderFnt );
1354  rInf.SetText(oldStr);
1355  rInf.SetIdx( nOldIdx );
1356  rInf.SetLen( nOldLen );
1357  }
1358 
1359  rInf.SetPos(aOldPos);
1360 }
1361 
1363 {
1364  if ( !pLastFont || pLastFont->GetOwner() != reinterpret_cast<const void*>(m_nFontCacheId) )
1365  ChgFnt( rInf.GetShell(), rInf.GetOut() );
1366 
1367  SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1368 
1369  TextFrameIndex const nLn = rInf.GetLen() == TextFrameIndex(COMPLETE_STRING)
1370  ? TextFrameIndex(rInf.GetText().getLength())
1371  : rInf.GetLen();
1372  rInf.SetLen( nLn );
1373  TextFrameIndex nCursor(0);
1374  if( IsCapital() && nLn )
1375  nCursor = GetCapitalCursorOfst( rInf );
1376  else
1377  {
1378  const OUString oldText = rInf.GetText();
1379  long nOldKern = rInf.GetKern();
1380  rInf.SetKern( CheckKerning() );
1381  SV_STAT( nGetTextSize );
1382  if ( !IsCaseMap() )
1383  nCursor = pLastFont->GetModelPositionForViewPoint( rInf );
1384  else
1385  {
1386  rInf.SetText( CalcCaseMap( rInf.GetText() ) );
1387  nCursor = pLastFont->GetModelPositionForViewPoint( rInf );
1388  }
1389  rInf.SetKern( nOldKern );
1390  rInf.SetText(oldText);
1391  }
1392  return nCursor;
1393 }
1394 
1395 void SwSubFont::CalcEsc( SwDrawTextInfo const & rInf, Point& rPos )
1396 {
1397  long nOfst;
1398 
1399  bool bVert = false;
1400  bool bVertLRBT = false;
1401  if (rInf.GetFrame())
1402  {
1403  bVert = rInf.GetFrame()->IsVertical();
1404  bVertLRBT = rInf.GetFrame()->IsVertLRBT();
1405  }
1406  const sal_uInt16 nDir = UnMapDirection(GetOrientation(), bVert, bVertLRBT);
1407 
1408  switch ( GetEscapement() )
1409  {
1410  case DFLT_ESC_AUTO_SUB :
1411  nOfst = m_nOrgHeight - m_nOrgAscent -
1412  pLastFont->GetFontHeight( rInf.GetShell(), rInf.GetOut() ) +
1413  pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() );
1414 
1415  switch ( nDir )
1416  {
1417  case 0 :
1418  rPos.AdjustY(nOfst );
1419  break;
1420  case 900 :
1421  rPos.AdjustX(nOfst );
1422  break;
1423  case 2700 :
1424  rPos.AdjustX( -nOfst );
1425  break;
1426  }
1427 
1428  break;
1429  case DFLT_ESC_AUTO_SUPER :
1430  nOfst = pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() ) -
1431  m_nOrgAscent;
1432 
1433  switch ( nDir )
1434  {
1435  case 0 :
1436  rPos.AdjustY(nOfst );
1437  break;
1438  case 900 :
1439  rPos.AdjustX(nOfst );
1440  break;
1441  case 2700 :
1442  rPos.AdjustX( -nOfst );
1443  break;
1444  }
1445 
1446  break;
1447  default :
1448  nOfst = (static_cast<long>(m_nOrgHeight) * GetEscapement()) / 100;
1449 
1450  switch ( nDir )
1451  {
1452  case 0 :
1453  rPos.AdjustY( -nOfst );
1454  break;
1455  case 900 :
1456  rPos.AdjustX( -nOfst );
1457  break;
1458  case 2700 :
1459  rPos.AdjustX(nOfst );
1460  break;
1461  }
1462  }
1463 }
1464 
1465 // used during painting of small capitals
1466 void SwDrawTextInfo::Shift( sal_uInt16 nDir )
1467 {
1468 #ifdef DBG_UTIL
1469  OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
1470  OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Width" );
1471 #endif
1472 
1473  const bool bBidiPor = ( GetFrame() && GetFrame()->IsRightToLeft() ) !=
1474  ( ComplexTextLayoutFlags::Default != ( ComplexTextLayoutFlags::BiDiRtl & GetpOut()->GetLayoutMode() ) );
1475 
1476  bool bVert = false;
1477  bool bVertLRBT = false;
1478  if (GetFrame())
1479  {
1480  bVert = GetFrame()->IsVertical();
1481  bVertLRBT = GetFrame()->IsVertLRBT();
1482  }
1483  nDir = bBidiPor ? 1800 : UnMapDirection(nDir, bVert, bVertLRBT);
1484 
1485  switch ( nDir )
1486  {
1487  case 0 :
1488  m_aPos.AdjustX(GetSize().Width() );
1489  break;
1490  case 900 :
1491  OSL_ENSURE( m_aPos.Y() >= GetSize().Width(), "Going underground" );
1492  m_aPos.AdjustY( -(GetSize().Width()) );
1493  break;
1494  case 1800 :
1495  m_aPos.AdjustX( -(GetSize().Width()) );
1496  break;
1497  case 2700 :
1498  m_aPos.AdjustY(GetSize().Width() );
1499  break;
1500  }
1501 }
1502 
1506 SwUnderlineFont::SwUnderlineFont(SwFont& rFnt, TextFrameIndex const nEnd, const Point& rPoint)
1507  : m_aPos( rPoint ), m_nEnd( nEnd ), m_pFont( &rFnt )
1508 {
1509 };
1510 
1512 {
1513 }
1514 
1516 long AttrSetToLineHeight( const IDocumentSettingAccess& rIDocumentSettingAccess,
1517  const SwAttrSet &rSet,
1518  const vcl::RenderContext &rOut, sal_Int16 nScript)
1519 {
1520  SwFont aFont(&rSet, &rIDocumentSettingAccess);
1521  SwFontScript nActual;
1522  switch (nScript)
1523  {
1524  default:
1525  case i18n::ScriptType::LATIN:
1526  nActual = SwFontScript::Latin;
1527  break;
1528  case i18n::ScriptType::ASIAN:
1529  nActual = SwFontScript::CJK;
1530  break;
1531  case i18n::ScriptType::COMPLEX:
1532  nActual = SwFontScript::CTL;
1533  break;
1534  }
1535  aFont.SetActual(nActual);
1536 
1537  vcl::RenderContext &rMutableOut = const_cast<vcl::RenderContext &>(rOut);
1538  const vcl::Font aOldFont(rMutableOut.GetFont());
1539 
1540  rMutableOut.SetFont(aFont.GetActualFont());
1541  long nHeight = rMutableOut.GetTextHeight();
1542 
1543  rMutableOut.SetFont(aOldFont);
1544  return nHeight;
1545 }
1546 
1547 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetLeftBorderDist(const sal_uInt16 nLeftDist)
Definition: swfont.hxx:856
const SvxFontItem & GetCTLFont(bool=true) const
Definition: charatr.hxx:88
long Width() const
SwFntObj * pLastFont
Definition: fntcache.cxx:66
SwViewShell const * GetShell() const
Definition: drawfont.hxx:175
const SvxBlinkItem & GetBlink(bool=true) const
Definition: charatr.hxx:104
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:177
sal_uInt16 UnMapDirection(sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT)
Definition: swfont.cxx:394
long GetSpace() const
Definition: drawfont.hxx:325
const SvxColorItem & GetColor(bool=true) const
Definition: charatr.hxx:90
const SvxFontHeightItem & GetSize(bool=true) const
Definition: charatr.hxx:78
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:186
~SwFont()
Definition: swfont.cxx:900
void SetWordLineMode(const bool bWordLineMode)
Definition: swfont.hxx:671
const SvxContourItem & GetContour(bool=true) const
Definition: charatr.hxx:68
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
Definition: swfont.cxx:1024
vcl::RenderContext * GetpOut() const
Definition: drawfont.hxx:185
const SvxCharRotateItem & GetCharRotate(bool=true) const
Definition: charatr.hxx:112
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:170
#define CH_TXT_ATR_SUBST_FIELDSTART
Definition: hintids.hxx:148
SwFont * GetFont() const
Definition: drawfont.hxx:250
TextFrameIndex GetCapitalCursorOfst(SwDrawTextInfo &rInf)
Definition: fntcap.cxx:394
void Lock()
Definition: swcache.cxx:477
bool GetValue() const
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:172
static sal_uInt16 MapDirection(sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT)
Definition: swfont.cxx:364
#define RES_CHRATR_RELIEF
Definition: hintids.hxx:198
const SvxUnderlineItem & GetUnderline(bool=true) const
Definition: charatr.hxx:72
sal_uInt16 m_nOrgAscent
Definition: swfont.hxx:60
const SvxOverlineItem & GetOverline(bool=true) const
Definition: charatr.hxx:74
const SvxPostureItem & GetCTLPosture(bool=true) const
Definition: charatr.hxx:54
const Color & GetTextLineColor() const
sal_uInt16 GetFontHeight(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:379
const Color & GetUnderColor() const
Definition: swfont.hxx:272
std::optional< editeng::SvxBorderLine > m_aTopBorder
Definition: swfont.hxx:143
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:187
const SvxShadowedItem & GetShadowed(bool=true) const
Definition: charatr.hxx:62
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
Definition: txtfrm.cxx:471
#define RES_CHRATR_WORDLINEMODE
Definition: hintids.hxx:178
#define CH_TXT_ATR_SUBST_FIELDEND
Definition: hintids.hxx:149
void SetKern(long nNew)
Definition: drawfont.hxx:495
sal_uInt8 & GetProportionalHeight()
bool ChgFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.cxx:952
TextFrameIndex GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
Definition: fntcache.cxx:2084
void SetIdx(TextFrameIndex const nNew)
Definition: drawfont.hxx:456
const SvxLanguageItem & GetLanguage(bool=true) const
Definition: charatr.hxx:92
const SvxCrossedOutItem & GetCrossedOut(bool=true) const
Definition: charatr.hxx:76
void SetUnderline(const FontLineStyle eUnderline)
Definition: swfont.hxx:539
void SetBackColor(Color *pNewColor)
Definition: swfont.cxx:65
const SvxCharHiddenItem & GetCharHidden(bool=true) const
Definition: charatr.hxx:116
const std::optional< editeng::SvxBorderLine > & GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
Definition: swfont.cxx:197
const SvxFont & GetActualFont() const
Definition: swfont.hxx:185
void SetGreyWave(bool bNew)
Definition: drawfont.hxx:562
void SetEmphasisMark(const FontEmphasisMark eValue)
Definition: swfont.hxx:685
const SvxLanguageItem & GetCJKLanguage(bool=true) const
Definition: charatr.hxx:94
sal_uInt16 GetFontAscent(const SwViewShell *pSh, const OutputDevice &rOut)
Definition: fntcache.cxx:342
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:188
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
void SetPos(const Point &rNew)
Definition: drawfont.hxx:397
#define RES_CHRATR_FONT
Definition: hintids.hxx:169
void CalcEsc(SwDrawTextInfo const &rInf, Point &rPos)
Definition: swfont.cxx:1395
sal_uInt16 GetWidth() const
Definition: drawfont.hxx:294
void SetWidth(sal_uInt16 nNew)
Definition: drawfont.hxx:482
#define RES_CHRATR_BLINK
Definition: hintids.hxx:180
#define DFLT_ESC_AUTO_SUB
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:184
bool m_bPaintBlank
Definition: swfont.hxx:167
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:185
void SetOutline(const bool bOutline)
Definition: swfont.hxx:603
const editeng::SvxBorderLine * GetRight() const
void SetPropWidth(const sal_uInt16 nNew)
Definition: swfont.hxx:693
Color m_aShadowColor
Definition: swfont.hxx:154
sal_uInt16 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
Definition: swfont.cxx:433
FontPitch GetPitch() const
bool m_bFontChg
Definition: swfont.hxx:168
void SetBottomBorderDist(const sal_uInt16 nBottomDist)
Definition: swfont.hxx:842
sal_uInt16 m_nLeftBorderDist
Definition: swfont.hxx:152
bool IsCaseMap() const
FontFamily GetFamily() const
FontItalic GetPosture() const
#define RES_CHRATR_TWO_LINES
Definition: hintids.hxx:196
void DrawCapital(SwDrawTextInfo &rInf)
Definition: fntcap.cxx:318
bool IsVertLRBT() const
Definition: frame.hxx:961
void SetColor(const Color &rColor)
Definition: swfont.hxx:414
const SwScriptInfo * GetScriptInfo() const
Definition: drawfont.hxx:190
const Color & GetOverlineColor() const
void SetShadow(const bool bShadow)
Definition: swfont.hxx:618
sal_uInt16 m_nShadowWidth
Definition: swfont.hxx:155
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
sal_uInt16 m_nRightBorderDist
Definition: swfont.hxx:151
const Color & GetColor() const
void DrawStretchText(const Point &rStartPt, sal_uLong nWidth, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1)
const SwTextFrame * GetFrame() const
Definition: drawfont.hxx:165
SvxShadowLocation GetLocation() const
const SvxFontHeightItem & GetCJKSize(bool=true) const
Definition: charatr.hxx:80
LINESTYLE_NONE
Color m_aOverColor
Definition: swfont.hxx:140
#define RES_CHRATR_CTL_FONTSIZE
Definition: hintids.hxx:190
const Color & GetOverColor() const
Definition: swfont.hxx:274
SwUnderlineFont(SwFont &rFnt, TextFrameIndex nEnd, const Point &rPoint)
Definition: swfont.cxx:1506
const vcl::Font & GetFont() const
void SetUnderFnt(SwUnderlineFont *pULFnt)
Definition: drawfont.hxx:541
rtl_TextEncoding GetCharSet() const
const SvxCaseMapItem & GetCaseMap(bool=true) const
Definition: charatr.hxx:100
const SvxFontHeightItem & GetCTLSize(bool=true) const
Definition: charatr.hxx:82
void DrawStretchText_(SwDrawTextInfo &rInf)
Definition: swfont.cxx:1280
o3tl::enumarray< SwFontScript, SwSubFont > m_aSub
Definition: swfont.hxx:134
#define DFLT_ESC_AUTO_SUPER
SwFont(const SwAttrSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
Definition: swfont.cxx:742
FontEmphasisMark GetEmphasisMark() const
bool IsSymbol() const
Definition: fntcache.hxx:127
sal_uInt16 m_nFontIndex
Definition: swfont.hxx:58
void SetShadowColor(const Color &rColor)
Definition: swfont.hxx:928
const SvxAutoKernItem & GetAutoKern(bool=true) const
Definition: charatr.hxx:64
long GetKern() const
Definition: drawfont.hxx:320
void SetUnderline(const FontLineStyle eUnderline)
Definition: swfont.hxx:545
void SetShadowLocation(const SvxShadowLocation aLocation)
Definition: swfont.hxx:942
const std::optional< editeng::SvxBorderLine > & GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
Definition: swfont.cxx:149
#define RES_CHRATR_CASEMAP
Definition: hintids.hxx:163
SwUnderlineFont * GetUnderFnt() const
Definition: drawfont.hxx:258
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.cxx:969
sal_uInt16 GetHeight(SwViewShell const *pSh, const OutputDevice &rOut)
Definition: swfont.cxx:1031
void SetStrikeout(const FontStrikeout eStrikeout)
Definition: swfont.hxx:575
void SetAlign(const FontAlign eAlign)
Definition: swfont.hxx:517
SwFontScript GetActual() const
Definition: swfont.hxx:183
void SetLen(TextFrameIndex const nNew)
Definition: drawfont.hxx:461
void SetTextLineColor()
void Shift(sal_uInt16 nDir)
Definition: swfont.cxx:1466
void SetLeftBorder(const editeng::SvxBorderLine *pLeftBorder)
Definition: swfont.cxx:111
const OUString & GetText() const
Definition: drawfont.hxx:216
const OUString & GetStyleName() const
std::optional< editeng::SvxBorderLine > m_aLeftBorder
Definition: swfont.hxx:146
Color m_aHighlightColor
Definition: swfont.hxx:138
const SvxWeightItem & GetCTLWeight(bool=true) const
Definition: charatr.hxx:60
#define RES_CHRATR_COLOR
Definition: hintids.hxx:165
const Color & GetColor() const
const SvxCharScaleWidthItem & GetCharScaleW(bool=true) const
Definition: charatr.hxx:110
const editeng::SvxBorderLine * GetTop() const
bool ApplyAutoColor(vcl::Font *pFnt=nullptr)
Definition: fntcache.cxx:2575
ALIGN_BASELINE
void SetTransparent(const bool bTrans)
Definition: swfont.hxx:643
#define RES_CHRATR_OVERLINE
Definition: hintids.hxx:200
SvxShadowItemSide
void SetLanguage(LanguageType eNewLang, const SwFontScript nWhich)
Definition: swfont.hxx:807
#define RES_CHRATR_BACKGROUND
Definition: hintids.hxx:183
SwFontScript m_nActual
Definition: swfont.hxx:163
void SetRightBorder(const editeng::SvxBorderLine *pRightBorder)
Definition: swfont.cxx:98
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::optional< editeng::SvxBorderLine > m_aBottomBorder
Definition: swfont.hxx:144
sal_uInt8 m_nInputFieldCount
Definition: swfont.hxx:161
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:189
FontWeight GetWeight() const
void SetUnderColor(const Color &rColor)
Definition: swfont.hxx:215
void SetRightBorderDist(const sal_uInt16 nRightDist)
Definition: swfont.hxx:849
#define RES_CHRATR_BOX
Definition: hintids.hxx:202
void SetShadowWidth(const sal_uInt16 nWidth)
Definition: swfont.hxx:935
const Point & GetPos() const
Definition: swfont.hxx:975
void DrawStretchCapital(SwDrawTextInfo &rInf)
Definition: fntcap.cxx:467
const SvxTwoLinesItem & Get2Lines(bool=true) const
Definition: charatr.hxx:108
void SetCaseMap(const SvxCaseMap eNew)
Definition: swfont.hxx:657
const std::optional< editeng::SvxBorderLine > & GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
Definition: swfont.cxx:125
void DrawText_(SwDrawTextInfo &rInf, const bool bGrey)
Definition: swfont.cxx:1147
Size GetCapitalSize(SwDrawTextInfo &rInf)
Definition: fntcap.cxx:138
const sal_Unicode CH_BLANK
Definition: swfont.hxx:42
bool m_bOrgChg
Definition: swfont.hxx:169
SwFont & GetFont()
Definition: swfont.hxx:970
void SetRelief(const FontRelief eNew)
Definition: swfont.hxx:711
#define CH_TXT_ATR_FIELDSTART
Definition: hintids.hxx:145
sal_uInt8 m_nToxCount
Definition: swfont.hxx:158
const SvxFontItem & GetCJKFont(bool=true) const
Definition: charatr.hxx:86
void SetEscapement(const short nNewEsc)
Definition: swfont.hxx:784
Provides access to settings of a document.
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:176
void DrawStretchText_(SwDrawTextInfo &rInf)
Definition: swfont.hxx:320
long AttrSetToLineHeight(const IDocumentSettingAccess &rIDocumentSettingAccess, const SwAttrSet &rSet, const vcl::RenderContext &rOut, sal_Int16 nScript)
Helper for filters to find true lineheight of a font.
Definition: swfont.cxx:1516
const SvxLanguageItem & GetCTLLanguage(bool=true) const
Definition: charatr.hxx:96
SvxCaseMap GetCaseMap() const
#define RES_CHRATR_ESCAPEMENT
Definition: hintids.hxx:168
void SetOverlineColor()
const SvxEscapementItem & GetEscapement(bool=true) const
Definition: charatr.hxx:98
const Color & GetColor() const
Definition: swfont.hxx:276
TextFrameIndex GetModelPositionForViewPoint_(SwDrawTextInfo &rInf)
Definition: swfont.cxx:1362
long GetTextHeight() const
void SetOverColor(const Color &rColor)
Definition: swfont.hxx:217
#define RES_CHRATR_CONTOUR
Definition: hintids.hxx:166
#define SV_STAT(nWhich)
Definition: swfont.hxx:999
sal_uInt16 m_nBottomBorderDist
Definition: swfont.hxx:150
const SvxEmphasisMarkItem & GetEmphasisMark(bool=true) const
Definition: charatr.hxx:106
void SetFixKerning(const short nNewKern)
Definition: swfont.hxx:650
#define RES_CHRATR_KERNING
Definition: hintids.hxx:171
sal_uInt16 CalcShadowSpace(const SvxShadowItemSide nShadow, const bool bVertLayout, const bool bVertLayoutLRBT, const bool bSkipLeft, const bool bSkipRight) const
Calculate the shadow space on the specified side dependent from the orientation and connection with n...
Definition: swfont.cxx:303
void SetBottomBorder(const editeng::SvxBorderLine *pBottomBorder)
Definition: swfont.cxx:85
FontLineStyle GetLineStyle() const
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:681
Size GetTextSize_(SwDrawTextInfo &rInf)
Definition: swfont.cxx:1044
SwFont & operator=(const SwFont &rFont)
Definition: swfont.cxx:904
const OUString & GetFamilyName() const
#define RES_CHRATR_EMPHASIS_MARK
Definition: hintids.hxx:195
#define RES_CHRATR_SHADOW
Definition: hintids.hxx:203
#define RES_CHRATR_ROTATE
Definition: hintids.hxx:194
LanguageType GetLanguage() const
long GetSperren() const
Definition: drawfont.hxx:312
bool IsSymbol(SwViewShell const *pSh)
Definition: swfont.cxx:946
void SetDevFont(const SwViewShell *pSh, OutputDevice &rOut)
Definition: fntcache.cxx:642
LanguageType GetLanguage() const
Definition: swfont.hxx:282
SwFntObj * Get()
Definition: fntcache.hxx:159
std::unique_ptr< Color > m_pBackColor
Definition: swfont.hxx:137
sal_uInt32 GetHeight() const
const SvxWeightItem & GetCJKWeight(bool=true) const
Definition: charatr.hxx:58
const void * m_nFontCacheId
Definition: swfont.hxx:56
bool m_bBlink
Definition: swfont.hxx:166
bool IsCapital() const
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:191
unsigned char sal_uInt8
sal_uInt16 CalcEscAscent(const sal_uInt16 nOldAscent) const
Definition: swfont.cxx:480
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:173
#define RES_CHRATR_CTL_WEIGHT
Definition: hintids.hxx:193
#define RES_CHRATR_CTL_POSTURE
Definition: hintids.hxx:192
LINESTYLE_DOTTED
const SvxKerningItem & GetKerning(bool=true) const
Definition: charatr.hxx:70
void SetFont(const vcl::Font &rNewFont)
const Point & GetPos() const
Definition: drawfont.hxx:195
void SetTopBorder(const editeng::SvxBorderLine *pTopBorder)
Definition: swfont.cxx:72
TextFrameIndex GetLen() const
Definition: drawfont.hxx:268
sal_uInt8 m_nRefCount
Definition: swfont.hxx:159
const Size & GetSize() const
Definition: drawfont.hxx:242
void SetActual(SwFontScript nNew)
Definition: swfont.hxx:747
void SetBlink(const bool bBlink)
Definition: swfont.hxx:818
short CheckKerning_()
Definition: swfont.cxx:1015
std::optional< editeng::SvxBorderLine > m_aRightBorder
Definition: swfont.hxx:145
OUString CalcCaseMap(const OUString &rTxt) const
bool IsRightToLeft() const
Definition: frame.hxx:965
short GetEscapement() const
#define RES_CHRATR_HIGHLIGHT
Definition: hintids.hxx:204
const SvxPostureItem & GetPosture(bool=true) const
Definition: charatr.hxx:50
SwFontScript
Definition: swfont.hxx:122
void Invalidate()
Definition: swfont.hxx:331
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
FontStrikeout GetStrikeout() const
vcl::RenderContext & GetOut() const
Definition: drawfont.hxx:180
const SvxWordLineModeItem & GetWordLineMode(bool=true) const
Definition: charatr.hxx:66
#define CH_TXT_ATR_FIELDEND
Definition: hintids.hxx:147
#define RES_CHRATR_SHADOWED
Definition: hintids.hxx:175
void Unlock()
Definition: swcache.cxx:483
SvStatistics g_SvStat
Definition: swfont.cxx:59
#define RES_CHRATR_AUTOKERN
Definition: hintids.hxx:179
void DrawText(SwDrawTextInfo &rInf)
Definition: fntcache.cxx:838
bool IsVertical() const
Definition: frame.hxx:951
#define SPACING_PRECISION_FACTOR
Definition: scriptinfo.hxx:39
#define SAL_WARN(area, stream)
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:167
void SetText(const OUString &rNew)
Definition: drawfont.hxx:413
short GetFixKerning() const
void SetAutoKern(FontKerning nAutoKern)
Definition: swfont.hxx:633
TextFrameIndex GetIdx() const
Definition: drawfont.hxx:263
void SetDiffFnt(const SfxItemSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
Definition: swfont.cxx:493
SvxShadowLocation m_aShadowLocation
Definition: swfont.hxx:156
bool IsSpaceStop() const
Definition: drawfont.hxx:372
sal_uInt16 CalcEscHeight(const sal_uInt16 nOldHeight, const sal_uInt16 nOldAscent) const
Definition: swfont.cxx:999
sal_uInt16 m_nTopBorderDist
Definition: swfont.hxx:149
const std::optional< editeng::SvxBorderLine > & GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
Definition: swfont.cxx:173
STRIKEOUT_NONE
void SetProportion(const sal_uInt8 nNewPropr)
Definition: swfont.hxx:765
SvxShadowLocation GetAbsShadowLocation(const bool bVertLayout, const bool bVertLayoutLRBT) const
Get the absolute shadow location dependent from orientation.
Definition: swfont.cxx:220
void SetVertical(sal_uInt16 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
Definition: swfont.cxx:438
void SetHighlightColor(const Color &aNewColor)
Definition: swfont.hxx:949
FontLineStyle
void ChgFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.hxx:176
Color m_aUnderColor
Definition: swfont.hxx:139
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...
sal_uInt16 m_nOrgHeight
Definition: swfont.hxx:59
const SvxWeightItem & GetWeight(bool=true) const
Definition: charatr.hxx:56
sal_uInt8 m_nMetaCount
Definition: swfont.hxx:160
void SetOverline(const FontLineStyle eOverline)
Definition: swfont.hxx:560
const editeng::SvxBorderLine * GetBottom() const
const SvxFontItem & GetFont(bool=true) const
Definition: charatr.hxx:84
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61
void SetTopBorderDist(const sal_uInt16 nTopDist)
Definition: swfont.hxx:835
const SvxPostureItem & GetCJKPosture(bool=true) const
Definition: charatr.hxx:52
const SvxCharReliefItem & GetCharRelief(bool=true) const
Definition: charatr.hxx:114
const Color & GetValue() const
void AllocFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
Definition: swfont.cxx:940
const void * GetOwner() const
Definition: swcache.hxx:167
Size GetTextSize(SwDrawTextInfo &rInf)
determine the TextSize (of the printer)
Definition: fntcache.cxx:1882
sal_uInt16 GetWidth() const
SvxShadowLocation
short CheckKerning()
Definition: swfont.hxx:112
void setHeight(long nHeight)
bool m_bGreyWave
Definition: swfont.hxx:170