1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX
23 #include <i18nlangtag/lang.h>
24 #include <tools/color.hxx>
25 #include <tools/gen.hxx>
26 #include <svl/poolitem.hxx>
27 #include <editeng/svxfont.hxx>
28 #include <swtypes.hxx>
29 #include "drawfont.hxx"
30 #include <editeng/borderline.hxx>
32 #include <o3tl/enumarray.hxx>
36 class SwDoCapitals
; // DoCapitals
37 class SwScriptInfo
; // GetTextSize_
39 class IDocumentSettingAccess
;
40 enum class SvxShadowItemSide
;
42 const sal_Unicode CH_BLANK
= ' '; // ' ' blank spaces
43 const sal_Unicode CH_BREAK
= 0x0A;
44 const sal_Unicode CH_TAB
= '\t'; // \t
45 constexpr OUStringChar CH_PAR
= u
'\u00B6'; // paragraph
46 const sal_Unicode CH_BULLET
= 0xB7; // centered dot
47 const sal_Unicode CH_FULL_BLANK
= 0x3000;
48 const sal_Unicode CH_NB_SPACE
= 0xA0;
49 const sal_Unicode CH_SIX_PER_EM
= 0x2006; // six-per-em space
51 Degree10
UnMapDirection( Degree10 nDir
, const bool bVertFormat
, const bool bVertFormatLRBT
);
53 class SwSubFont
: public SvxFont
56 const void* m_nFontCacheId
; // "MagicNumber" within the font cache
57 Size m_aSize
; // foreigners only see this size
58 sal_uInt16 m_nFontIndex
; // index in the font cache
59 sal_uInt16 m_nOrgHeight
; // height including escapement/proportion
60 sal_uInt16 m_nOrgAscent
; // ascent including escapement/proportion
61 sal_uInt16 m_nProportionalWidth
; // proportional width
62 bool m_bSmallCapsPercentage66
;
64 sal_uInt16
CalcEscAscent( const sal_uInt16 nOldAscent
) const;
65 sal_uInt16
CalcEscHeight( const sal_uInt16 nOldHeight
,
66 const sal_uInt16 nOldAscent
) const;
67 void CalcEsc( SwDrawTextInfo
const & rInf
, Point
& rPos
);
69 short CheckKerning_( );
71 bool ChgFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
);
72 bool IsSymbol( SwViewShell
const *pSh
);
73 sal_uInt16
GetAscent( SwViewShell
const *pSh
, const OutputDevice
& rOut
);
74 sal_uInt16
GetHeight( SwViewShell
const *pSh
, const OutputDevice
& rOut
);
75 Size
GetTextSize_( SwDrawTextInfo
& rInf
);
76 Size
GetCapitalSize( SwDrawTextInfo
& rInf
);
77 void DrawText_( SwDrawTextInfo
&rInf
, const bool bGrey
);
78 void DrawCapital( SwDrawTextInfo
&rInf
);
79 void DrawStretchCapital( SwDrawTextInfo
&rInf
);
80 void DoOnCapitals( SwDoCapitals
&rDo
);
81 void DrawStretchText_( SwDrawTextInfo
&rInf
);
82 TextFrameIndex
GetModelPositionForViewPoint_( SwDrawTextInfo
& rInf
);
83 TextFrameIndex
GetCapitalCursorOfst( SwDrawTextInfo
& rInf
);
85 inline void SetColor( const Color
& rColor
);
86 inline void SetFillColor( const Color
& rColor
);
87 inline void SetCharSet( const rtl_TextEncoding eCharSet
);
88 inline void SetPitch( const FontPitch ePitch
);
89 inline void SetAlign( const FontAlign eAlign
);
90 inline void SetUnderline( const FontLineStyle eUnderline
);
91 inline void SetOverline( const FontLineStyle eOverline
);
92 inline void SetStrikeout( const FontStrikeout eStrikeout
);
93 inline void SetItalic( const FontItalic eItalic
);
94 inline void SetOutline( const bool bOutline
);
95 inline void SetVertical( const Degree10 nDir
, const bool bVertFormat
);
96 inline void SetShadow( const bool bShadow
);
97 inline void SetAutoKern( FontKerning nAutoKern
);
98 inline void SetWordLineMode( const bool bWordLineMode
);
99 inline void SetEmphasisMark( const FontEmphasisMark eValue
);
100 inline void SetRelief( const FontRelief eNew
);
102 // methods for sub-/superscript
103 inline void SetEscapement( const short nNewEsc
);
104 inline void SetProportion( const sal_uInt8 nNewPropr
);
106 inline void SetFamily( const FontFamily eFamily
);
107 inline void SetName( const OUString
& rName
);
108 inline void SetStyleName( const OUString
& rStyleName
);
109 inline void SetSize( const Size
& rSize
);
110 inline void SetWeight( const FontWeight eWeight
);
111 inline void SetLanguage( LanguageType eNewLang
);
113 { return GetFixKerning() >= 0 ? GetFixKerning() : CheckKerning_( ); }
114 void SetPropWidth( const sal_uInt16 nNew
)
115 { m_nFontCacheId
= nullptr; m_nProportionalWidth
= nNew
; }
117 SwSubFont() : m_aSize(0,0)
118 { m_nFontCacheId
= nullptr; m_nFontIndex
= m_nOrgHeight
= m_nOrgAscent
= 0; m_nProportionalWidth
=100; m_bSmallCapsPercentage66
= false; }
119 sal_uInt16
GetPropWidth() const { return m_nProportionalWidth
; }
122 enum class SwFontScript
124 Latin
, CJK
, CTL
, LAST
= CTL
127 // mostly used as a "unknown script" marker
128 #define SW_SCRIPTS (SwFontScript(int(SwFontScript::LAST)+1))
132 // CJK == Chinese, Japanese, Korean
133 // CTL == Complex text layout ( Hebrew, Arabic )
134 o3tl::enumarray
<SwFontScript
, SwSubFont
> m_aSub
; // Latin-, CJK- and CTL-font
137 mxBackColor
; // background color (i.e. at character styles)
138 Color m_aHighlightColor
; // highlight color
139 Color m_aUnderColor
; // color of the underlining
140 Color m_aOverColor
; // color of the overlining
143 std::optional
<editeng::SvxBorderLine
> m_aTopBorder
;
144 std::optional
<editeng::SvxBorderLine
> m_aBottomBorder
;
145 std::optional
<editeng::SvxBorderLine
> m_aRightBorder
;
146 std::optional
<editeng::SvxBorderLine
> m_aLeftBorder
;
149 sal_uInt16 m_nTopBorderDist
;
150 sal_uInt16 m_nBottomBorderDist
;
151 sal_uInt16 m_nRightBorderDist
;
152 sal_uInt16 m_nLeftBorderDist
;
154 Color m_aShadowColor
;
155 sal_uInt16 m_nShadowWidth
;
156 SvxShadowLocation m_aShadowLocation
;
158 sal_uInt8 m_nToxCount
; // counts the nesting depth of the Tox
159 sal_uInt8 m_nRefCount
; // counts the nesting depth of the Refs
160 sal_uInt8 m_nMetaCount
; // count META/METAFIELD
161 sal_uInt8 m_nInputFieldCount
; // count INPUTFIELD
163 SwFontScript m_nActual
; // actual font (Latin, CJK or CTL)
165 // switch for the font-extensions
166 bool m_bPaintBlank
:1; // blanks not with DrawRect
168 bool m_bOrgChg
:1; // nOrgHeight/Ascent are invalid
169 bool m_bGreyWave
:1; // for the extended TextInput: gray waveline
172 SwFont( const SwAttrSet
* pSet
, const IDocumentSettingAccess
* pIDocumentSettingAccess
);
173 SwFont( const SwFont
& rFont
);
175 void ChgFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
)
176 { m_bPaintBlank
= m_aSub
[m_nActual
].ChgFnt( pSh
, rOut
); }
180 SwFont
& operator=( const SwFont
&rFont
);
182 SwFontScript
GetActual() const { return m_nActual
; }
183 inline void SetActual( SwFontScript nNew
);
184 const SvxFont
& GetActualFont() const { return m_aSub
[m_nActual
]; }
186 // gets a font cache id via SwFntAccess
187 void AllocFontCacheId( SwViewShell
const *pSh
, SwFontScript nWhich
);
188 // set background color
189 void SetBackColor( std::optional
<Color
> xNewColor
);
190 const std::optional
<Color
>& GetBackColor() const{ return mxBackColor
; }
191 void SetHighlightColor( const Color
& aNewColor
);
192 const Color
& GetHighlightColor() const { return m_aHighlightColor
; }
194 void CheckFontCacheId( SwViewShell
const *pSh
, SwFontScript nWhich
)
195 { if( !m_aSub
[ nWhich
].m_nFontCacheId
) AllocFontCacheId( pSh
, nWhich
); }
196 void GetFontCacheId( const void* &rnFontCacheId
, sal_uInt16
&rIdx
, SwFontScript nWhich
)
197 { rnFontCacheId
= m_aSub
[nWhich
].m_nFontCacheId
; rIdx
= m_aSub
[nWhich
].m_nFontIndex
; }
198 void SetFontCacheId( const void* nNewFontCacheId
, const sal_uInt16 nIdx
, SwFontScript nWhich
)
199 { m_aSub
[nWhich
].m_nFontCacheId
= nNewFontCacheId
; m_aSub
[nWhich
].m_nFontIndex
= nIdx
; }
200 bool DifferentFontCacheId( const SwFont
* pFnt
, SwFontScript nWhich
)
201 { return m_aSub
[nWhich
].m_nFontCacheId
!= pFnt
->m_aSub
[nWhich
].m_nFontCacheId
||
202 !m_aSub
[nWhich
].m_nFontCacheId
|| !pFnt
->m_aSub
[nWhich
].m_nFontCacheId
; }
204 const Size
&GetSize( SwFontScript nWhich
) const
205 { return m_aSub
[nWhich
].m_aSize
; }
206 bool IsFntChg() const { return m_bFontChg
; }
207 void SetFntChg( const bool bNew
) { m_bFontChg
= bNew
; }
209 // the encapsulated SV-Font-methods (set bFntChg to true)
210 inline void SetColor( const Color
& rColor
);
211 inline void SetFillColor( const Color
& rColor
);
212 inline void SetAlign( const FontAlign eAlign
);
213 inline void SetUnderline( const FontLineStyle eUnderline
);
214 void SetUnderColor( const Color
&rColor
) { m_aUnderColor
= rColor
; }
215 inline void SetOverline( const FontLineStyle eOverline
);
216 void SetOverColor( const Color
&rColor
) { m_aOverColor
= rColor
; }
217 inline void SetStrikeout( const FontStrikeout eStrikeout
);
218 inline void SetOutline( const bool bOutline
);
219 void SetVertical(Degree10 nDir
, const bool bVertLayout
= false,
220 const bool bVertLayoutLRBT
= false);
221 inline void SetShadow( const bool bShadow
);
222 inline void SetAutoKern( FontKerning nAutoKern
);
223 inline void SetTransparent( const bool bTrans
);
224 inline void SetWordLineMode( const bool bWordLineMode
);
225 inline void SetFixKerning( const short nNewKern
);
226 inline void SetCaseMap( const SvxCaseMap eNew
);
227 inline void SetEmphasisMark( const FontEmphasisMark eValue
);
229 // methods for sub-/superscript
230 inline void SetEscapement( const short nNewEsc
);
231 inline void SetProportion( const sal_uInt8 nNewPropr
);
233 inline void SetPropWidth( const sal_uInt16 nNew
);
235 inline void SetFamily( const FontFamily eFamily
, const SwFontScript nWhich
);
236 inline void SetName( const OUString
& rName
, const SwFontScript nWhich
);
237 inline void SetStyleName( const OUString
& rStyleName
, const SwFontScript nWhich
);
238 inline void SetSize( const Size
& rSize
, const SwFontScript nWhich
);
239 inline void SetWeight( const FontWeight eWeight
, const SwFontScript nWhich
);
240 inline void SetItalic( const FontItalic eItalic
, const SwFontScript nWhich
);
241 inline void SetLanguage( LanguageType eNewLang
, const SwFontScript nWhich
);
242 inline void SetCharSet( const rtl_TextEncoding eCharSet
, const SwFontScript nWhich
);
243 inline void SetPitch( const FontPitch ePitch
, const SwFontScript nWhich
);
244 inline void SetRelief( const FontRelief eNew
);
246 // Get/Set-methods for the current setting
247 sal_uInt8
&GetTox() { return m_nToxCount
; }
248 bool IsTox() const { return ( 0 != m_nToxCount
); }
249 sal_uInt8
&GetRef() { return m_nRefCount
; }
250 bool IsRef() const { return ( 0 != m_nRefCount
); }
251 sal_uInt8
&GetMeta() { return m_nMetaCount
; }
252 bool IsMeta() const { return (0 != m_nMetaCount
); }
253 sal_uInt8
&GetInputField() { return m_nInputFieldCount
; }
254 bool IsInputField() const { return (0 != m_nInputFieldCount
); }
255 inline void SetGreyWave( const bool bNew
);
256 bool IsGreyWave() const { return m_bGreyWave
; }
257 bool IsPaintBlank() const { return m_bPaintBlank
; }
259 // setting of the base class font for SwTextCharFormat
260 void SetDiffFnt( const SfxItemSet
* pSet
,
261 const IDocumentSettingAccess
* pIDocumentSettingAccess
);
263 const SvxFont
&GetFnt( const SwFontScript nWhich
) const
264 { return m_aSub
[nWhich
]; };
266 bool IsSymbol( SwViewShell
const *pSh
)
267 { return m_aSub
[m_nActual
].IsSymbol( pSh
); }
268 FontLineStyle
GetUnderline() const { return m_aSub
[m_nActual
].GetUnderline(); }
269 const Color
& GetUnderColor() const { return m_aUnderColor
; }
270 FontLineStyle
GetOverline() const { return m_aSub
[m_nActual
].GetOverline(); }
271 const Color
& GetOverColor() const { return m_aOverColor
; }
272 FontStrikeout
GetStrikeout() const { return m_aSub
[m_nActual
].GetStrikeout(); }
273 const Color
& GetColor() const { return m_aSub
[m_nActual
].GetColor(); }
274 bool IsWordLineMode() const { return m_aSub
[m_nActual
].IsWordLineMode(); }
275 short GetEscapement() const { return m_aSub
[m_nActual
].GetEscapement(); }
276 SvxCaseMap
GetCaseMap() const { return m_aSub
[m_nActual
].GetCaseMap(); }
277 sal_uInt8
GetPropr() const { return m_aSub
[m_nActual
].GetPropr(); }
278 FontItalic
GetItalic() const { return m_aSub
[m_nActual
].GetItalic(); }
279 LanguageType
GetLanguage() const { return m_aSub
[m_nActual
].GetLanguage(); }
280 tools::Long
GetHeight() const { return m_aSub
[m_nActual
].GetFontSize().Height(); }
281 FontWeight
GetWeight() const { return m_aSub
[m_nActual
].GetWeight(); }
282 FontEmphasisMark
GetEmphasisMark() const
283 { return m_aSub
[m_nActual
].GetEmphasisMark(); }
284 Degree10
GetOrientation(const bool bVertLayout
= false,
285 const bool bVertFormatLRBT
= false) const;
287 const OUString
& GetName( const SwFontScript nWhich
) const
288 { return m_aSub
[nWhich
].GetFamilyName(); }
289 LanguageType
GetLanguage( const SwFontScript nWhich
) const
290 { return m_aSub
[nWhich
].GetLanguage(); }
291 rtl_TextEncoding
GetCharSet( const SwFontScript nWhich
) const
292 { return m_aSub
[nWhich
].GetCharSet(); }
293 tools::Long
GetHeight( const SwFontScript nWhich
) const
294 { return m_aSub
[nWhich
].GetFontSize().Height(); }
296 // makes the logical font be effective in the OutputDevice
297 void ChgPhysFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
);
299 TextFrameIndex
GetCapitalBreak( SwViewShell
const* pSh
, const OutputDevice
* pOut
,
300 const SwScriptInfo
* pScript
, const OUString
& rText
,
301 tools::Long nTextWidth
, TextFrameIndex nIdx
, TextFrameIndex nLen
);
303 void DoOnCapitals( SwDoCapitals
&rDo
)
304 { m_aSub
[m_nActual
].DoOnCapitals( rDo
); }
306 Size
GetTextSize_( SwDrawTextInfo
& rInf
)
307 { rInf
.SetFont( this ); return m_aSub
[m_nActual
].GetTextSize_( rInf
); }
309 TextFrameIndex
GetTextBreak( SwDrawTextInfo
const & rInf
, tools::Long nTextWidth
);
311 TextFrameIndex
GetModelPositionForViewPoint_( SwDrawTextInfo
& rInf
)
312 { return m_aSub
[m_nActual
].GetModelPositionForViewPoint_( rInf
); }
314 void DrawText_( SwDrawTextInfo
&rInf
)
315 { m_aSub
[m_nActual
].DrawText_( rInf
, IsGreyWave() ); }
317 void DrawStretchText_( SwDrawTextInfo
&rInf
)
318 { m_aSub
[m_nActual
].DrawStretchText_( rInf
); }
321 { return m_aSub
[m_nActual
].CheckKerning(); }
323 sal_uInt16
GetAscent( SwViewShell
const *pSh
, const OutputDevice
& rOut
)
324 { return m_aSub
[m_nActual
].GetAscent( pSh
, rOut
); }
325 sal_uInt16
GetHeight( SwViewShell
const *pSh
, const OutputDevice
& rOut
)
326 { return m_aSub
[m_nActual
].GetHeight( pSh
, rOut
); }
329 { m_bFontChg
= m_bOrgChg
= true; }
331 void SetTopBorder( const editeng::SvxBorderLine
* pTopBorder
);
332 void SetBottomBorder( const editeng::SvxBorderLine
* pBottomBorder
);
333 void SetRightBorder( const editeng::SvxBorderLine
* pRightBorder
);
334 void SetLeftBorder( const editeng::SvxBorderLine
* pLeftBorder
);
336 const std::optional
<editeng::SvxBorderLine
>& GetTopBorder() const { return m_aTopBorder
; }
337 const std::optional
<editeng::SvxBorderLine
>& GetBottomBorder() const { return m_aBottomBorder
; }
338 const std::optional
<editeng::SvxBorderLine
>& GetRightBorder() const { return m_aRightBorder
; }
339 const std::optional
<editeng::SvxBorderLine
>& GetLeftBorder() const { return m_aLeftBorder
; }
341 // Get absolute border correspond to the layout verticality and orientation.
342 const std::optional
<editeng::SvxBorderLine
>&
343 GetAbsTopBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
344 const std::optional
<editeng::SvxBorderLine
>&
345 GetAbsBottomBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
346 const std::optional
<editeng::SvxBorderLine
>&
347 GetAbsRightBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
348 const std::optional
<editeng::SvxBorderLine
>&
349 GetAbsLeftBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
351 void SetTopBorderDist( const sal_uInt16 nTopDist
);
352 void SetBottomBorderDist( const sal_uInt16 nBottomDist
);
353 void SetRightBorderDist( const sal_uInt16 nRightDist
);
354 void SetLeftBorderDist( const sal_uInt16 nLeftDist
);
356 sal_uInt16
GetTopBorderDist() const { return m_nTopBorderDist
; }
357 sal_uInt16
GetBottomBorderDist() const { return m_nBottomBorderDist
; }
358 sal_uInt16
GetRightBorderDist() const { return m_nRightBorderDist
; }
359 sal_uInt16
GetLeftBorderDist() const { return m_nLeftBorderDist
; }
361 // Return with the whole space which border holed (border width, spacing and shadow width)
362 sal_uInt16
GetTopBorderSpace() const;
363 sal_uInt16
GetBottomBorderSpace() const;
364 sal_uInt16
GetRightBorderSpace() const;
365 sal_uInt16
GetLeftBorderSpace() const;
367 /// Check whether font has any border on any side
368 bool HasBorder() const;
370 void SetShadowColor( const Color
& rColor
);
371 void SetShadowWidth( const sal_uInt16 nWidth
);
372 void SetShadowLocation( const SvxShadowLocation aLocation
);
374 const Color
& GetShadowColor() const { return m_aShadowColor
; }
375 sal_uInt16
GetShadowWidth() const { return m_nShadowWidth
; }
376 SvxShadowLocation
GetShadowLocation() const { return m_aShadowLocation
; }
379 * Get the absolute shadow location dependent from orientation.
381 * @param[in] bVertLayout true, if the container layout is vertical
383 * @param[in] bVertLayoutLRBT true if the container layout is vertical
384 * (bottom to top, left to right), false otherwise
385 * @return absolute location
387 SvxShadowLocation
GetAbsShadowLocation(const bool bVertLayout
,
388 const bool bVertLayoutLRBT
) const;
391 * Calculate the shadow space on the specified side dependent from
392 * the orientation and connection with neighbours.
393 * @see shaditem.hxx for integer constants of sides
395 * @param[in] nShadow specify the side
396 * @param[in] bVertLayout true, if the container layout is vertical
398 * @param[in] bVertLayoutLRBT true if the container layout is vertical
399 * (bottom to top, left to right), false otherwise
400 * @param[in] bSkipLeft relative left shadow space is skipped
401 * @param[in] bSkipRight relative right shadow space is skipped
402 * @return the shadow space
404 sal_uInt16
CalcShadowSpace(
405 const SvxShadowItemSide nShadow
, const bool bVertLayout
, const bool bVertLayoutLRBT
,
406 const bool bSkipLeft
, const bool bSkipRight
) const;
408 void dumpAsXml( xmlTextWriterPtr writer
) const;
411 inline void SwFont::SetColor( const Color
& rColor
)
414 m_aSub
[SwFontScript::Latin
].SetColor( rColor
);
415 m_aSub
[SwFontScript::CJK
].SetColor( rColor
);
416 m_aSub
[SwFontScript::CTL
].SetColor( rColor
);
419 // encapsulated SV-Font-method
420 inline void SwSubFont::SetColor( const Color
& rColor
)
422 m_nFontCacheId
= nullptr;
423 Font::SetColor( rColor
);
426 // encapsulated SV-Font-method
427 inline void SwSubFont::SetFillColor( const Color
& rColor
)
429 m_nFontCacheId
= nullptr;
430 Font::SetFillColor( rColor
);
433 inline void SwFont::SetFillColor( const Color
& rColor
)
436 m_aSub
[SwFontScript::Latin
].SetFillColor( rColor
);
437 m_aSub
[SwFontScript::CJK
].SetFillColor( rColor
);
438 m_aSub
[SwFontScript::CTL
].SetFillColor( rColor
);
441 // encapsulated SV-Font-method
442 inline void SwSubFont::SetFamily( const FontFamily eFamily
)
444 m_nFontCacheId
= nullptr;
445 Font::SetFamily( eFamily
);
448 inline void SwFont::SetFamily( const FontFamily eFamily
, const SwFontScript nWhich
)
451 m_aSub
[nWhich
].SetFamily( eFamily
);
454 // encapsulated SV-Font-method
455 inline void SwSubFont::SetName( const OUString
& rName
)
457 m_nFontCacheId
= nullptr;
458 Font::SetFamilyName( rName
);
461 inline void SwFont::SetName( const OUString
& rName
, const SwFontScript nWhich
)
464 m_aSub
[nWhich
].SetName( rName
);
467 // encapsulated SV-Font-method
468 inline void SwSubFont::SetStyleName( const OUString
& rStyleName
)
470 m_nFontCacheId
= nullptr;
471 Font::SetStyleName( rStyleName
);
474 inline void SwFont::SetStyleName( const OUString
& rStyle
, const SwFontScript nWhich
)
477 m_aSub
[nWhich
].SetStyleName( rStyle
);
480 // encapsulated SV-Font-method
481 inline void SwSubFont::SetCharSet( const rtl_TextEncoding eCharSet
)
483 m_nFontCacheId
= nullptr;
484 Font::SetCharSet( eCharSet
);
487 inline void SwFont::SetCharSet( const rtl_TextEncoding eCharSet
, const SwFontScript nWhich
)
490 m_aSub
[nWhich
].SetCharSet( eCharSet
);
493 // encapsulated SV-Font-method
494 inline void SwSubFont::SetPitch( const FontPitch ePitch
)
496 m_nFontCacheId
= nullptr;
497 Font::SetPitch( ePitch
);
500 // encapsulated SV-Font-method
501 inline void SwFont::SetPitch( const FontPitch ePitch
, const SwFontScript nWhich
)
504 m_aSub
[nWhich
].SetPitch( ePitch
);
507 // encapsulated SV-Font-method
508 inline void SwSubFont::SetAlign( const FontAlign eAlign
)
510 m_nFontCacheId
= nullptr;
511 Font::SetAlignment( eAlign
);
514 inline void SwFont::SetAlign( const FontAlign eAlign
)
517 m_aSub
[SwFontScript::Latin
].SetAlign( eAlign
);
518 m_aSub
[SwFontScript::CJK
].SetAlign( eAlign
);
519 m_aSub
[SwFontScript::CTL
].SetAlign( eAlign
);
522 // encapsulated SV-Font-method
523 inline void SwSubFont::SetWeight( const FontWeight eWeight
)
525 m_nFontCacheId
= nullptr;
526 Font::SetWeight( eWeight
);
529 inline void SwFont::SetWeight( const FontWeight eWeight
, const SwFontScript nWhich
)
532 m_aSub
[nWhich
].SetWeight( eWeight
);
535 // encapsulated SV-Font-method
536 inline void SwSubFont::SetUnderline( const FontLineStyle eUnderline
)
538 m_nFontCacheId
= nullptr;
539 Font::SetUnderline( eUnderline
);
542 inline void SwFont::SetUnderline( const FontLineStyle eUnderline
)
545 m_aSub
[SwFontScript::Latin
].SetUnderline( eUnderline
);
546 m_aSub
[SwFontScript::CJK
].SetUnderline( eUnderline
);
547 m_aSub
[SwFontScript::CTL
].SetUnderline( eUnderline
);
550 // encapsulated SV-Font-method
551 inline void SwSubFont::SetOverline( const FontLineStyle eOverline
)
553 m_nFontCacheId
= nullptr;
554 Font::SetOverline( eOverline
);
557 inline void SwFont::SetOverline( const FontLineStyle eOverline
)
560 m_aSub
[SwFontScript::Latin
].SetOverline( eOverline
);
561 m_aSub
[SwFontScript::CJK
].SetOverline( eOverline
);
562 m_aSub
[SwFontScript::CTL
].SetOverline( eOverline
);
565 // encapsulated SV-Font-method
566 inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout
)
568 m_nFontCacheId
= nullptr;
569 Font::SetStrikeout( eStrikeout
);
572 inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout
)
575 m_aSub
[SwFontScript::Latin
].SetStrikeout( eStrikeout
);
576 m_aSub
[SwFontScript::CJK
].SetStrikeout( eStrikeout
);
577 m_aSub
[SwFontScript::CTL
].SetStrikeout( eStrikeout
);
580 // encapsulated SV-Font-method
581 inline void SwSubFont::SetItalic( const FontItalic eItalic
)
583 m_nFontCacheId
= nullptr;
584 Font::SetItalic( eItalic
);
587 inline void SwFont::SetItalic( const FontItalic eItalic
, const SwFontScript nWhich
)
590 m_aSub
[nWhich
].SetItalic( eItalic
);
593 // encapsulated SV-Font-method
594 inline void SwSubFont::SetOutline( const bool bOutline
)
596 m_nFontCacheId
= nullptr;
597 Font::SetOutline( bOutline
);
600 inline void SwFont::SetOutline( const bool bOutline
)
603 m_aSub
[SwFontScript::Latin
].SetOutline( bOutline
);
604 m_aSub
[SwFontScript::CJK
].SetOutline( bOutline
);
605 m_aSub
[SwFontScript::CTL
].SetOutline( bOutline
);
608 // encapsulated SV-Font-method
609 inline void SwSubFont::SetShadow( const bool bShadow
)
611 m_nFontCacheId
= nullptr;
612 Font::SetShadow( bShadow
);
615 inline void SwFont::SetShadow( const bool bShadow
)
618 m_aSub
[SwFontScript::Latin
].SetShadow( bShadow
);
619 m_aSub
[SwFontScript::CJK
].SetShadow( bShadow
);
620 m_aSub
[SwFontScript::CTL
].SetShadow( bShadow
);
623 // encapsulated SV-Font-method
624 inline void SwSubFont::SetAutoKern( FontKerning nAutoKern
)
626 m_nFontCacheId
= nullptr;
627 Font::SetKerning( nAutoKern
);
630 inline void SwFont::SetAutoKern( FontKerning nAutoKern
)
633 m_aSub
[SwFontScript::CJK
].SetAutoKern( nAutoKern
);
634 if( nAutoKern
!= FontKerning::NONE
)
635 nAutoKern
= FontKerning::FontSpecific
;
636 m_aSub
[SwFontScript::Latin
].SetAutoKern( nAutoKern
);
637 m_aSub
[SwFontScript::CTL
].SetAutoKern( nAutoKern
);
640 inline void SwFont::SetTransparent( const bool bTrans
)
642 m_aSub
[SwFontScript::Latin
].SetTransparent( bTrans
);
643 m_aSub
[SwFontScript::CJK
].SetTransparent( bTrans
);
644 m_aSub
[SwFontScript::CTL
].SetTransparent( bTrans
);
647 inline void SwFont::SetFixKerning( const short nNewKern
)
649 m_aSub
[SwFontScript::Latin
].SetFixKerning( nNewKern
);
650 m_aSub
[SwFontScript::CJK
].SetFixKerning( nNewKern
);
651 m_aSub
[SwFontScript::CTL
].SetFixKerning( nNewKern
);
654 inline void SwFont::SetCaseMap( const SvxCaseMap eNew
)
656 m_aSub
[SwFontScript::Latin
].SetCaseMap( eNew
);
657 m_aSub
[SwFontScript::CJK
].SetCaseMap( eNew
);
658 m_aSub
[SwFontScript::CTL
].SetCaseMap( eNew
);
661 // encapsulated SV-Font-method
662 inline void SwSubFont::SetWordLineMode( const bool bWordLineMode
)
664 m_nFontCacheId
= nullptr;
665 Font::SetWordLineMode( bWordLineMode
);
668 inline void SwFont::SetWordLineMode( const bool bWordLineMode
)
671 m_aSub
[SwFontScript::Latin
].SetWordLineMode( bWordLineMode
);
672 m_aSub
[SwFontScript::CJK
].SetWordLineMode( bWordLineMode
);
673 m_aSub
[SwFontScript::CTL
].SetWordLineMode( bWordLineMode
);
675 // encapsulated SV-Font-method
676 inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue
)
678 m_nFontCacheId
= nullptr;
679 Font::SetEmphasisMark( eValue
);
682 inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue
)
685 m_aSub
[SwFontScript::Latin
].SetEmphasisMark( eValue
);
686 m_aSub
[SwFontScript::CJK
].SetEmphasisMark( eValue
);
687 m_aSub
[SwFontScript::CTL
].SetEmphasisMark( eValue
);
690 inline void SwFont::SetPropWidth( const sal_uInt16 nNew
)
692 if( nNew
!= m_aSub
[SwFontScript::Latin
].GetPropWidth() )
695 m_aSub
[SwFontScript::Latin
].SetPropWidth( nNew
);
696 m_aSub
[SwFontScript::CJK
].SetPropWidth( nNew
);
697 m_aSub
[SwFontScript::CTL
].SetPropWidth( nNew
);
701 // encapsulated SV-Font-method
702 inline void SwSubFont::SetRelief( const FontRelief eNew
)
704 m_nFontCacheId
= nullptr;
705 Font::SetRelief( eNew
);
708 inline void SwFont::SetRelief( const FontRelief eNew
)
710 if( eNew
!= m_aSub
[SwFontScript::Latin
].GetRelief() )
713 m_aSub
[SwFontScript::Latin
].SetRelief( eNew
);
714 m_aSub
[SwFontScript::CJK
].SetRelief( eNew
);
715 m_aSub
[SwFontScript::CTL
].SetRelief( eNew
);
719 // overloaded font-method
720 inline void SwSubFont::SetSize( const Size
& rSize
)
723 if ( GetPropr() == 100 )
724 Font::SetFontSize( m_aSize
);
727 Font::SetFontSize( Size(
728 m_aSize
.Width() * GetPropr() / 100,
729 m_aSize
.Height() * GetPropr() / 100 ) );
731 m_nFontCacheId
= nullptr;
734 inline void SwFont::SetSize( const Size
& rSize
, const SwFontScript nWhich
)
736 if( m_aSub
[nWhich
].m_aSize
!= rSize
)
738 m_aSub
[nWhich
].SetSize( rSize
);
744 inline void SwFont::SetActual( SwFontScript nNew
)
746 if ( m_nActual
!= nNew
)
754 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr
)
756 m_nFontCacheId
= nullptr;
757 Font::SetFontSize( Size( m_aSize
.Width() * nNewPropr
/ 100,
758 m_aSize
.Height() * nNewPropr
/ 100 ) );
759 SvxFont::SetPropr( nNewPropr
);
762 inline void SwFont::SetProportion( const sal_uInt8 nNewPropr
)
764 if( nNewPropr
!= m_aSub
[SwFontScript::Latin
].GetPropr() )
769 m_aSub
[SwFontScript::Latin
].SetProportion( nNewPropr
);
770 m_aSub
[SwFontScript::CJK
].SetProportion( nNewPropr
);
771 m_aSub
[SwFontScript::CTL
].SetProportion( nNewPropr
);
775 inline void SwSubFont::SetEscapement( const short nNewEsc
)
777 m_nFontCacheId
= nullptr;
778 SvxFont::SetEscapement( nNewEsc
);
781 inline void SwFont::SetEscapement( const short nNewEsc
)
783 if( nNewEsc
!= m_aSub
[SwFontScript::Latin
].GetEscapement() )
785 // these have to be set, otherwise nOrgHeight and nOrgAscent will not
790 m_aSub
[SwFontScript::Latin
].SetEscapement( nNewEsc
);
791 m_aSub
[SwFontScript::CJK
].SetEscapement( nNewEsc
);
792 m_aSub
[SwFontScript::CTL
].SetEscapement( nNewEsc
);
796 inline void SwSubFont::SetLanguage( LanguageType eNewLang
)
798 m_nFontCacheId
= nullptr;
799 if( eNewLang
== LANGUAGE_SYSTEM
)
800 eNewLang
= GetAppLanguage();
801 SvxFont::SetLanguage( eNewLang
);
804 inline void SwFont::SetLanguage( const LanguageType eNewLang
, const SwFontScript nWhich
)
806 m_aSub
[nWhich
].SetLanguage( eNewLang
);
807 if( SwFontScript::CJK
== nWhich
)
809 m_aSub
[SwFontScript::Latin
].SetCJKContextLanguage( eNewLang
);
810 m_aSub
[SwFontScript::CJK
].SetCJKContextLanguage( eNewLang
);
811 m_aSub
[SwFontScript::CTL
].SetCJKContextLanguage( eNewLang
);
815 inline void SwFont::SetGreyWave( const bool bNew
)
820 inline void SwSubFont::SetVertical( const Degree10 nDir
, const bool bVertFormat
)
822 m_nFontCacheId
= nullptr;
823 Font::SetVertical( bVertFormat
);
824 Font::SetOrientation( nDir
);
827 inline void SwFont::SetTopBorderDist( const sal_uInt16 nTopDist
)
829 m_nTopBorderDist
= nTopDist
;
831 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
834 inline void SwFont::SetBottomBorderDist( const sal_uInt16 nBottomDist
)
836 m_nBottomBorderDist
= nBottomDist
;
838 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
841 inline void SwFont::SetRightBorderDist( const sal_uInt16 nRightDist
)
843 m_nRightBorderDist
= nRightDist
;
845 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
848 inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist
)
850 m_nLeftBorderDist
= nLeftDist
;
852 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
855 inline sal_uInt16
SwFont::GetTopBorderSpace() const
860 nRet
+= m_aTopBorder
->GetScaledWidth() + m_nTopBorderDist
;
862 if( m_aShadowLocation
== SvxShadowLocation::TopLeft
||
863 m_aShadowLocation
== SvxShadowLocation::TopRight
)
865 nRet
+= m_nShadowWidth
;
870 inline sal_uInt16
SwFont::GetBottomBorderSpace() const
873 if( m_aBottomBorder
)
875 nRet
+= m_aBottomBorder
->GetScaledWidth() + m_nBottomBorderDist
;
877 if( m_aShadowLocation
== SvxShadowLocation::BottomLeft
||
878 m_aShadowLocation
== SvxShadowLocation::BottomRight
)
880 nRet
+= m_nShadowWidth
;
885 inline sal_uInt16
SwFont::GetRightBorderSpace() const
890 nRet
+= m_aRightBorder
->GetScaledWidth() + m_nRightBorderDist
;
892 if( m_aShadowLocation
== SvxShadowLocation::TopRight
||
893 m_aShadowLocation
== SvxShadowLocation::BottomRight
)
895 nRet
+= m_nShadowWidth
;
900 inline sal_uInt16
SwFont::GetLeftBorderSpace() const
905 nRet
+= m_aLeftBorder
->GetScaledWidth() + m_nLeftBorderDist
;
907 if( m_aShadowLocation
== SvxShadowLocation::TopLeft
||
908 m_aShadowLocation
== SvxShadowLocation::BottomLeft
)
910 nRet
+= m_nShadowWidth
;
915 inline bool SwFont::HasBorder() const
917 return m_aTopBorder
|| m_aBottomBorder
|| m_aLeftBorder
|| m_aRightBorder
;
920 inline void SwFont::SetShadowColor( const Color
& rColor
)
922 m_aShadowColor
= rColor
;
924 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
927 inline void SwFont::SetShadowWidth( const sal_uInt16 nWidth
)
929 m_nShadowWidth
= nWidth
;
931 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
934 inline void SwFont::SetShadowLocation( const SvxShadowLocation aLocation
)
936 m_aShadowLocation
= aLocation
;
938 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
941 inline void SwFont::SetHighlightColor( const Color
& aNewColor
)
943 m_aHighlightColor
= aNewColor
;
945 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
948 // Used for the "continuous underline" feature.
949 class SwUnderlineFont
952 TextFrameIndex m_nEnd
;
953 std::unique_ptr
<SwFont
> m_pFont
;
956 // sets the font which should paint the common baseline,
957 // index where continuous underline ends,
958 // and the starting point of the common baseline
959 SwUnderlineFont(SwFont
& rFnt
, TextFrameIndex nEnd
, const Point
& rPoint
);
964 OSL_ENSURE( m_pFont
, "No underline font" );
967 const Point
& GetPos() const { return m_aPos
; }
968 TextFrameIndex
GetEnd() const { return m_nEnd
; }
969 // the x coordinate of the starting point has to be set for each portion
970 void SetPos( const Point
& rPoint
) { m_aPos
= rPoint
; }
978 sal_uInt16 nGetTextSize
;
979 sal_uInt16 nDrawText
;
980 sal_uInt16 nGetStretchTextSize
;
981 sal_uInt16 nDrawStretchText
;
982 sal_uInt16 nChangeFont
;
985 { nGetTextSize
= nDrawText
= nGetStretchTextSize
= nDrawStretchText
= nChangeFont
= 0; }
988 // global variable, implemented in swfont.cxx
989 extern SvStatistics g_SvStat
;
991 #define SV_STAT(nWhich) ++(g_SvStat.nWhich);
995 #define SV_STAT(nWhich)
996 #endif /* DBG_UTIL */
1000 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */