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>
31 #include <editeng/lrspitem.hxx>
33 #include <o3tl/enumarray.hxx>
37 class SwDoCapitals
; // DoCapitals
38 class SwScriptInfo
; // GetTextSize_
40 class IDocumentSettingAccess
;
41 enum class SvxShadowItemSide
;
43 const sal_Unicode CH_BLANK
= ' '; // ' ' blank spaces
44 const sal_Unicode CH_BREAK
= 0x0A;
45 const sal_Unicode CH_TAB
= '\t'; // \t
46 constexpr OUStringChar CH_PAR
= u
'\u00B6'; // paragraph
47 const sal_Unicode CH_BULLET
= 0xB7; // centered dot
48 const sal_Unicode CH_FULL_BLANK
= 0x3000;
49 const sal_Unicode CH_NB_SPACE
= 0xA0;
50 const sal_Unicode CH_SIX_PER_EM
= 0x2006; // six-per-em space
51 const sal_Unicode CH_EN_SPACE
= 0x2002;
52 const sal_Unicode CH_DEGREE
= 0xb0;
54 Degree10
UnMapDirection( Degree10 nDir
, const bool bVertFormat
, const bool bVertFormatLRBT
);
56 class SwSubFont final
: public SvxFont
59 const void* m_nFontCacheId
; // "MagicNumber" within the font cache
60 Size m_aSize
; // foreigners only see this size
61 sal_uInt16 m_nFontIndex
; // index in the font cache
62 sal_uInt16 m_nOrgHeight
; // height including escapement/proportion
63 sal_uInt16 m_nOrgAscent
; // ascent including escapement/proportion
64 sal_uInt16 m_nProportionalWidth
; // proportional width
65 bool m_bSmallCapsPercentage66
;
67 sal_uInt16
CalcEscAscent( const sal_uInt16 nOldAscent
) const;
68 sal_uInt16
CalcEscHeight( const sal_uInt16 nOldHeight
,
69 const sal_uInt16 nOldAscent
) const;
70 void CalcEsc( SwDrawTextInfo
const & rInf
, Point
& rPos
);
72 short CheckKerning_( );
74 bool ChgFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
);
75 bool IsSymbol( SwViewShell
const *pSh
);
76 sal_uInt16
GetAscent( SwViewShell
const *pSh
, const OutputDevice
& rOut
);
77 sal_uInt16
GetHeight(SwViewShell
const* pSh
, const OutputDevice
& rOut
,
78 bool bIsCJKGridContext
= false);
79 sal_uInt16
GetHangingBaseline( SwViewShell
const *pSh
, const OutputDevice
& rOut
);
80 Size
GetTextSize_( SwDrawTextInfo
& rInf
);
81 Size
GetCapitalSize( SwDrawTextInfo
& rInf
);
82 void DrawText_( SwDrawTextInfo
&rInf
, const bool bGrey
);
83 void DrawCapital( SwDrawTextInfo
&rInf
);
84 void DrawStretchCapital( SwDrawTextInfo
&rInf
);
85 void DoOnCapitals( SwDoCapitals
&rDo
);
86 void DrawStretchText_( SwDrawTextInfo
&rInf
);
87 TextFrameIndex
GetModelPositionForViewPoint_( SwDrawTextInfo
& rInf
);
88 TextFrameIndex
GetCapitalCursorOfst( SwDrawTextInfo
& rInf
);
90 inline void SetColor( const Color
& rColor
);
91 inline void SetFillColor( const Color
& rColor
);
92 inline void SetCharSet( const rtl_TextEncoding eCharSet
);
93 inline void SetPitch( const FontPitch ePitch
);
94 inline void SetAlign( const TextAlign eAlign
);
95 inline void SetUnderline( const FontLineStyle eUnderline
);
96 inline void SetOverline( const FontLineStyle eOverline
);
97 inline void SetStrikeout( const FontStrikeout eStrikeout
);
98 inline void SetItalic( const FontItalic eItalic
);
99 inline void SetOutline( const bool bOutline
);
100 inline void SetVertical( const Degree10 nDir
, const bool bVertFormat
);
101 inline void SetShadow( const bool bShadow
);
102 inline void SetAutoKern( FontKerning nAutoKern
);
103 inline void SetWordLineMode( const bool bWordLineMode
);
104 inline void SetEmphasisMark( const FontEmphasisMark eValue
);
105 inline void SetRelief( const FontRelief eNew
);
107 // methods for sub-/superscript
108 inline void SetEscapement( const short nNewEsc
);
109 inline void SetProportion( const sal_uInt8 nNewPropr
);
111 inline void SetFamily( const FontFamily eFamily
);
112 inline void SetName( const OUString
& rName
);
113 inline void SetStyleName( const OUString
& rStyleName
);
114 inline void SetSize( const Size
& rSize
);
115 inline void SetWeight( const FontWeight eWeight
);
116 inline void SetLanguage( LanguageType eNewLang
);
118 { return GetFixKerning() >= 0 ? GetFixKerning() : CheckKerning_( ); }
119 void SetPropWidth( const sal_uInt16 nNew
)
120 { m_nFontCacheId
= nullptr; m_nProportionalWidth
= nNew
; }
122 SwSubFont() : m_aSize(0,0)
123 { m_nFontCacheId
= nullptr; m_nFontIndex
= m_nOrgHeight
= m_nOrgAscent
= 0; m_nProportionalWidth
=100; m_bSmallCapsPercentage66
= false; }
124 sal_uInt16
GetPropWidth() const { return m_nProportionalWidth
; }
127 enum class SwFontScript
129 Latin
, CJK
, CTL
, LAST
= CTL
132 // mostly used as a "unknown script" marker
133 #define SW_SCRIPTS (SwFontScript(int(SwFontScript::LAST)+1))
135 /// To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts
136 /// (Latin, CJK, and CTL). The m_nActual member indicates the current script, i.e. the currently
140 // CJK == Chinese, Japanese, Korean
141 // CTL == Complex text layout ( Hebrew, Arabic )
142 o3tl::enumarray
<SwFontScript
, SwSubFont
> m_aSub
; // Latin-, CJK- and CTL-font
145 mxBackColor
; // background color (i.e. at character styles)
146 Color m_aHighlightColor
; // highlight color
147 Color m_aUnderColor
; // color of the underlining
148 Color m_aOverColor
; // color of the overlining
151 std::optional
<editeng::SvxBorderLine
> m_aTopBorder
;
152 std::optional
<editeng::SvxBorderLine
> m_aBottomBorder
;
153 std::optional
<editeng::SvxBorderLine
> m_aRightBorder
;
154 std::optional
<editeng::SvxBorderLine
> m_aLeftBorder
;
157 sal_uInt16 m_nTopBorderDist
;
158 sal_uInt16 m_nBottomBorderDist
;
159 sal_uInt16 m_nRightBorderDist
;
160 sal_uInt16 m_nLeftBorderDist
;
162 Color m_aShadowColor
;
163 sal_uInt16 m_nShadowWidth
;
164 SvxShadowLocation m_aShadowLocation
;
166 sal_uInt8 m_nToxCount
; // counts the nesting depth of the Tox
167 sal_uInt8 m_nRefCount
; // counts the nesting depth of the Refs
168 sal_uInt8 m_nMetaCount
; // count META/METAFIELD
169 sal_uInt8 m_nContentControlCount
; // count CONTENTCONTROL
170 sal_uInt8 m_nInputFieldCount
; // count INPUTFIELD
172 SwFontScript m_nActual
; // actual font (Latin, CJK or CTL)
174 // switch for the font-extensions
175 bool m_bPaintBlank
:1; // blanks not with DrawRect
177 bool m_bOrgChg
:1; // nOrgHeight/Ascent are invalid
178 bool m_bGreyWave
:1; // for the extended TextInput: gray waveline
179 bool m_bURL
: 1 = false;
182 SwFont( const SwAttrSet
* pSet
, const IDocumentSettingAccess
* pIDocumentSettingAccess
);
183 SwFont( const SwFont
& rFont
);
185 void ChgFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
)
186 { m_bPaintBlank
= m_aSub
[m_nActual
].ChgFnt( pSh
, rOut
); }
190 SwFont
& operator=( const SwFont
&rFont
);
192 SwFontScript
GetActual() const { return m_nActual
; }
193 inline void SetActual( SwFontScript nNew
);
194 const SvxFont
& GetActualFont() const { return m_aSub
[m_nActual
]; }
196 // gets a font cache id via SwFntAccess
197 void AllocFontCacheId( SwViewShell
const *pSh
, SwFontScript nWhich
);
198 // set background color
199 void SetBackColor( std::optional
<Color
> xNewColor
);
200 const std::optional
<Color
>& GetBackColor() const{ return mxBackColor
; }
201 void SetHighlightColor( const Color
& aNewColor
);
202 const Color
& GetHighlightColor() const { return m_aHighlightColor
; }
204 void CheckFontCacheId( SwViewShell
const *pSh
, SwFontScript nWhich
)
205 { if( !m_aSub
[ nWhich
].m_nFontCacheId
) AllocFontCacheId( pSh
, nWhich
); }
206 void GetFontCacheId( const void* &rnFontCacheId
, sal_uInt16
&rIdx
, SwFontScript nWhich
)
207 { rnFontCacheId
= m_aSub
[nWhich
].m_nFontCacheId
; rIdx
= m_aSub
[nWhich
].m_nFontIndex
; }
208 void SetFontCacheId( const void* nNewFontCacheId
, const sal_uInt16 nIdx
, SwFontScript nWhich
)
209 { m_aSub
[nWhich
].m_nFontCacheId
= nNewFontCacheId
; m_aSub
[nWhich
].m_nFontIndex
= nIdx
; }
210 bool DifferentFontCacheId( const SwFont
* pFnt
, SwFontScript nWhich
)
211 { return m_aSub
[nWhich
].m_nFontCacheId
!= pFnt
->m_aSub
[nWhich
].m_nFontCacheId
||
212 !m_aSub
[nWhich
].m_nFontCacheId
|| !pFnt
->m_aSub
[nWhich
].m_nFontCacheId
; }
214 const Size
&GetSize( SwFontScript nWhich
) const
215 { return m_aSub
[nWhich
].m_aSize
; }
216 bool IsFntChg() const { return m_bFontChg
; }
217 void SetFntChg( const bool bNew
) { m_bFontChg
= bNew
; }
219 // the encapsulated SV-Font-methods (set bFntChg to true)
220 inline void SetColor( const Color
& rColor
);
221 inline void SetFillColor( const Color
& rColor
);
222 inline void SetAlign( const TextAlign eAlign
);
223 inline void SetUnderline( const FontLineStyle eUnderline
);
224 void SetUnderColor( const Color
&rColor
) { m_aUnderColor
= rColor
; }
225 inline void SetOverline( const FontLineStyle eOverline
);
226 void SetOverColor( const Color
&rColor
) { m_aOverColor
= rColor
; }
227 inline void SetStrikeout( const FontStrikeout eStrikeout
);
228 inline void SetOutline( const bool bOutline
);
229 void SetVertical(Degree10 nDir
, const bool bVertLayout
= false,
230 const bool bVertLayoutLRBT
= false);
231 inline void SetShadow( const bool bShadow
);
232 inline void SetAutoKern( FontKerning nAutoKern
);
233 inline void SetTransparent( const bool bTrans
);
234 inline void SetWordLineMode( const bool bWordLineMode
);
235 inline void SetFixKerning( const short nNewKern
);
236 inline void SetCaseMap( const SvxCaseMap eNew
);
237 inline void SetEmphasisMark( const FontEmphasisMark eValue
);
239 // methods for sub-/superscript
240 inline void SetEscapement( const short nNewEsc
);
241 inline void SetProportion( const sal_uInt8 nNewPropr
);
243 inline void SetPropWidth( const sal_uInt16 nNew
);
245 inline void SetFamily( const FontFamily eFamily
, const SwFontScript nWhich
);
246 inline void SetName( const OUString
& rName
, const SwFontScript nWhich
);
247 inline void SetStyleName( const OUString
& rStyleName
, const SwFontScript nWhich
);
248 inline void SetSize( const Size
& rSize
, const SwFontScript nWhich
);
249 inline void SetWeight( const FontWeight eWeight
, const SwFontScript nWhich
);
250 inline void SetItalic( const FontItalic eItalic
, const SwFontScript nWhich
);
251 inline void SetLanguage( LanguageType eNewLang
, const SwFontScript nWhich
);
252 inline void SetCharSet( const rtl_TextEncoding eCharSet
, const SwFontScript nWhich
);
253 inline void SetPitch( const FontPitch ePitch
, const SwFontScript nWhich
);
254 inline void SetRelief( const FontRelief eNew
);
256 // Get/Set-methods for the current setting
257 sal_uInt8
&GetTox() { return m_nToxCount
; }
258 bool IsTox() const { return ( 0 != m_nToxCount
); }
259 sal_uInt8
&GetRef() { return m_nRefCount
; }
260 bool IsRef() const { return ( 0 != m_nRefCount
); }
261 sal_uInt8
&GetMeta() { return m_nMetaCount
; }
262 bool IsMeta() const { return (0 != m_nMetaCount
); }
263 sal_uInt8
& GetContentControl() { return m_nContentControlCount
; }
264 bool IsContentControl() const { return m_nContentControlCount
!= 0; }
265 sal_uInt8
&GetInputField() { return m_nInputFieldCount
; }
266 bool IsInputField() const { return (0 != m_nInputFieldCount
); }
267 inline void SetGreyWave( const bool bNew
);
268 bool IsGreyWave() const { return m_bGreyWave
; }
269 bool IsPaintBlank() const { return m_bPaintBlank
; }
270 void SetURL(const bool bURL
) { m_bURL
= bURL
; }
271 bool IsURL() const { return m_bURL
; }
273 // setting of the base class font for SwTextCharFormat
274 void SetDiffFnt( const SfxItemSet
* pSet
,
275 const IDocumentSettingAccess
* pIDocumentSettingAccess
);
277 const SvxFont
&GetFnt( const SwFontScript nWhich
) const
278 { return m_aSub
[nWhich
]; };
280 bool IsSymbol( SwViewShell
const *pSh
)
281 { return m_aSub
[m_nActual
].IsSymbol( pSh
); }
282 FontLineStyle
GetUnderline() const { return m_aSub
[m_nActual
].GetUnderline(); }
283 const Color
& GetUnderColor() const { return m_aUnderColor
; }
284 FontLineStyle
GetOverline() const { return m_aSub
[m_nActual
].GetOverline(); }
285 const Color
& GetOverColor() const { return m_aOverColor
; }
286 FontStrikeout
GetStrikeout() const { return m_aSub
[m_nActual
].GetStrikeout(); }
287 const Color
& GetColor() const { return m_aSub
[m_nActual
].GetColor(); }
288 bool IsWordLineMode() const { return m_aSub
[m_nActual
].IsWordLineMode(); }
289 short GetEscapement() const { return m_aSub
[m_nActual
].GetEscapement(); }
290 SvxCaseMap
GetCaseMap() const { return m_aSub
[m_nActual
].GetCaseMap(); }
291 sal_uInt8
GetPropr() const { return m_aSub
[m_nActual
].GetPropr(); }
292 FontItalic
GetItalic() const { return m_aSub
[m_nActual
].GetItalic(); }
293 LanguageType
GetLanguage() const { return m_aSub
[m_nActual
].GetLanguage(); }
294 tools::Long
GetHeight() const { return m_aSub
[m_nActual
].GetFontSize().Height(); }
295 FontWeight
GetWeight() const { return m_aSub
[m_nActual
].GetWeight(); }
296 FontEmphasisMark
GetEmphasisMark() const
297 { return m_aSub
[m_nActual
].GetEmphasisMark(); }
298 Degree10
GetOrientation(const bool bVertLayout
= false,
299 const bool bVertFormatLRBT
= false) const;
301 const OUString
& GetName( const SwFontScript nWhich
) const
302 { return m_aSub
[nWhich
].GetFamilyName(); }
303 LanguageType
GetLanguage( const SwFontScript nWhich
) const
304 { return m_aSub
[nWhich
].GetLanguage(); }
305 rtl_TextEncoding
GetCharSet( const SwFontScript nWhich
) const
306 { return m_aSub
[nWhich
].GetCharSet(); }
307 tools::Long
GetHeight( const SwFontScript nWhich
) const
308 { return m_aSub
[nWhich
].GetFontSize().Height(); }
310 // makes the logical font be effective in the OutputDevice
311 void ChgPhysFnt( SwViewShell
const *pSh
, OutputDevice
& rOut
);
313 TextFrameIndex
GetCapitalBreak( SwViewShell
const* pSh
, const OutputDevice
* pOut
,
314 const SwScriptInfo
* pScript
, const OUString
& rText
,
315 tools::Long nTextWidth
, TextFrameIndex nIdx
, TextFrameIndex nLen
);
317 void DoOnCapitals( SwDoCapitals
&rDo
)
318 { m_aSub
[m_nActual
].DoOnCapitals( rDo
); }
320 Size
GetTextSize_( SwDrawTextInfo
& rInf
)
321 { rInf
.SetFont( this ); return m_aSub
[m_nActual
].GetTextSize_( rInf
); }
323 TextFrameIndex
GetTextBreak( SwDrawTextInfo
const & rInf
, tools::Long nTextWidth
);
325 TextFrameIndex
GetModelPositionForViewPoint_( SwDrawTextInfo
& rInf
)
326 { return m_aSub
[m_nActual
].GetModelPositionForViewPoint_( rInf
); }
328 void DrawText_( SwDrawTextInfo
&rInf
)
329 { m_aSub
[m_nActual
].DrawText_( rInf
, IsGreyWave() ); }
331 void DrawStretchText_( SwDrawTextInfo
&rInf
)
332 { m_aSub
[m_nActual
].DrawStretchText_( rInf
); }
335 { return m_aSub
[m_nActual
].CheckKerning(); }
337 sal_uInt16
GetAscent(SwViewShell
const* pSh
, const OutputDevice
& rOut
)
339 return m_aSub
[m_nActual
].GetAscent(pSh
, rOut
);
342 sal_uInt16
GetHeight(SwViewShell
const* pSh
, const OutputDevice
& rOut
,
343 bool bIsCJKGridContext
= false)
345 return m_aSub
[m_nActual
].GetHeight(pSh
, rOut
, bIsCJKGridContext
);
348 sal_uInt16
GetHangingBaseline( SwViewShell
const *pSh
, const OutputDevice
& rOut
)
349 { return m_nActual
== SwFontScript::CTL
? m_aSub
[m_nActual
].GetHangingBaseline( pSh
, rOut
) : 0; }
352 { m_bFontChg
= m_bOrgChg
= true; }
354 void SetTopBorder( const editeng::SvxBorderLine
* pTopBorder
);
355 void SetBottomBorder( const editeng::SvxBorderLine
* pBottomBorder
);
356 void SetRightBorder( const editeng::SvxBorderLine
* pRightBorder
);
357 void SetLeftBorder( const editeng::SvxBorderLine
* pLeftBorder
);
359 const std::optional
<editeng::SvxBorderLine
>& GetTopBorder() const { return m_aTopBorder
; }
360 const std::optional
<editeng::SvxBorderLine
>& GetBottomBorder() const { return m_aBottomBorder
; }
361 const std::optional
<editeng::SvxBorderLine
>& GetRightBorder() const { return m_aRightBorder
; }
362 const std::optional
<editeng::SvxBorderLine
>& GetLeftBorder() const { return m_aLeftBorder
; }
364 // Get absolute border correspond to the layout verticality and orientation.
365 const std::optional
<editeng::SvxBorderLine
>&
366 GetAbsTopBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
367 const std::optional
<editeng::SvxBorderLine
>&
368 GetAbsBottomBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
369 const std::optional
<editeng::SvxBorderLine
>&
370 GetAbsRightBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
371 const std::optional
<editeng::SvxBorderLine
>&
372 GetAbsLeftBorder(const bool bVertLayout
, const bool bVertLayoutLRBT
) const;
374 void SetTopBorderDist( const sal_uInt16 nTopDist
);
375 void SetBottomBorderDist( const sal_uInt16 nBottomDist
);
376 void SetRightBorderDist( const sal_uInt16 nRightDist
);
377 void SetLeftBorderDist( const sal_uInt16 nLeftDist
);
379 sal_uInt16
GetTopBorderDist() const { return m_nTopBorderDist
; }
380 sal_uInt16
GetBottomBorderDist() const { return m_nBottomBorderDist
; }
381 sal_uInt16
GetRightBorderDist() const { return m_nRightBorderDist
; }
382 sal_uInt16
GetLeftBorderDist() const { return m_nLeftBorderDist
; }
384 // Return with the whole space which border holed (border width, spacing and shadow width)
385 sal_uInt16
GetTopBorderSpace() const;
386 sal_uInt16
GetBottomBorderSpace() const;
387 sal_uInt16
GetRightBorderSpace() const;
388 sal_uInt16
GetLeftBorderSpace() const;
390 /// Check whether font has any border on any side
391 bool HasBorder() const;
393 void SetShadowColor( const Color
& rColor
);
394 void SetShadowWidth( const sal_uInt16 nWidth
);
395 void SetShadowLocation( const SvxShadowLocation aLocation
);
397 const Color
& GetShadowColor() const { return m_aShadowColor
; }
398 sal_uInt16
GetShadowWidth() const { return m_nShadowWidth
; }
399 SvxShadowLocation
GetShadowLocation() const { return m_aShadowLocation
; }
402 * Get the absolute shadow location dependent from orientation.
404 * @param[in] bVertLayout true, if the container layout is vertical
406 * @param[in] bVertLayoutLRBT true if the container layout is vertical
407 * (bottom to top, left to right), false otherwise
408 * @return absolute location
410 SvxShadowLocation
GetAbsShadowLocation(const bool bVertLayout
,
411 const bool bVertLayoutLRBT
) const;
414 * Calculate the shadow space on the specified side dependent from
415 * the orientation and connection with neighbours.
416 * @see shaditem.hxx for integer constants of sides
418 * @param[in] nShadow specify the side
419 * @param[in] bVertLayout true, if the container layout is vertical
421 * @param[in] bVertLayoutLRBT true if the container layout is vertical
422 * (bottom to top, left to right), false otherwise
423 * @param[in] bSkipLeft relative left shadow space is skipped
424 * @param[in] bSkipRight relative right shadow space is skipped
425 * @return the shadow space
427 sal_uInt16
CalcShadowSpace(
428 const SvxShadowItemSide nShadow
, const bool bVertLayout
, const bool bVertLayoutLRBT
,
429 const bool bSkipLeft
, const bool bSkipRight
) const;
431 // Extract metrics for font-relative unit conversion
432 SvxFontUnitMetrics
GetFontUnitMetrics() const;
434 void dumpAsXml( xmlTextWriterPtr writer
) const;
437 inline void SwFont::SetColor( const Color
& rColor
)
440 m_aSub
[SwFontScript::Latin
].SetColor( rColor
);
441 m_aSub
[SwFontScript::CJK
].SetColor( rColor
);
442 m_aSub
[SwFontScript::CTL
].SetColor( rColor
);
445 // encapsulated SV-Font-method
446 inline void SwSubFont::SetColor( const Color
& rColor
)
448 m_nFontCacheId
= nullptr;
449 Font::SetColor( rColor
);
452 // encapsulated SV-Font-method
453 inline void SwSubFont::SetFillColor( const Color
& rColor
)
455 m_nFontCacheId
= nullptr;
456 Font::SetFillColor( rColor
);
459 inline void SwFont::SetFillColor( const Color
& rColor
)
462 m_aSub
[SwFontScript::Latin
].SetFillColor( rColor
);
463 m_aSub
[SwFontScript::CJK
].SetFillColor( rColor
);
464 m_aSub
[SwFontScript::CTL
].SetFillColor( rColor
);
467 // encapsulated SV-Font-method
468 inline void SwSubFont::SetFamily( const FontFamily eFamily
)
470 m_nFontCacheId
= nullptr;
471 Font::SetFamily( eFamily
);
474 inline void SwFont::SetFamily( const FontFamily eFamily
, const SwFontScript nWhich
)
477 m_aSub
[nWhich
].SetFamily( eFamily
);
480 // encapsulated SV-Font-method
481 inline void SwSubFont::SetName( const OUString
& rName
)
483 m_nFontCacheId
= nullptr;
484 Font::SetFamilyName( rName
);
487 inline void SwFont::SetName( const OUString
& rName
, const SwFontScript nWhich
)
490 m_aSub
[nWhich
].SetName( rName
);
493 // encapsulated SV-Font-method
494 inline void SwSubFont::SetStyleName( const OUString
& rStyleName
)
496 m_nFontCacheId
= nullptr;
497 Font::SetStyleName( rStyleName
);
500 inline void SwFont::SetStyleName( const OUString
& rStyle
, const SwFontScript nWhich
)
503 m_aSub
[nWhich
].SetStyleName( rStyle
);
506 // encapsulated SV-Font-method
507 inline void SwSubFont::SetCharSet( const rtl_TextEncoding eCharSet
)
509 m_nFontCacheId
= nullptr;
510 Font::SetCharSet( eCharSet
);
513 inline void SwFont::SetCharSet( const rtl_TextEncoding eCharSet
, const SwFontScript nWhich
)
516 m_aSub
[nWhich
].SetCharSet( eCharSet
);
519 // encapsulated SV-Font-method
520 inline void SwSubFont::SetPitch( const FontPitch ePitch
)
522 m_nFontCacheId
= nullptr;
523 Font::SetPitch( ePitch
);
526 // encapsulated SV-Font-method
527 inline void SwFont::SetPitch( const FontPitch ePitch
, const SwFontScript nWhich
)
530 m_aSub
[nWhich
].SetPitch( ePitch
);
533 // encapsulated SV-Font-method
534 inline void SwSubFont::SetAlign( const TextAlign eAlign
)
536 m_nFontCacheId
= nullptr;
537 Font::SetAlignment( eAlign
);
540 inline void SwFont::SetAlign( const TextAlign eAlign
)
543 m_aSub
[SwFontScript::Latin
].SetAlign( eAlign
);
544 m_aSub
[SwFontScript::CJK
].SetAlign( eAlign
);
545 m_aSub
[SwFontScript::CTL
].SetAlign( eAlign
);
548 // encapsulated SV-Font-method
549 inline void SwSubFont::SetWeight( const FontWeight eWeight
)
551 m_nFontCacheId
= nullptr;
552 Font::SetWeight( eWeight
);
555 inline void SwFont::SetWeight( const FontWeight eWeight
, const SwFontScript nWhich
)
558 m_aSub
[nWhich
].SetWeight( eWeight
);
561 // encapsulated SV-Font-method
562 inline void SwSubFont::SetUnderline( const FontLineStyle eUnderline
)
564 m_nFontCacheId
= nullptr;
565 Font::SetUnderline( eUnderline
);
568 inline void SwFont::SetUnderline( const FontLineStyle eUnderline
)
571 m_aSub
[SwFontScript::Latin
].SetUnderline( eUnderline
);
572 m_aSub
[SwFontScript::CJK
].SetUnderline( eUnderline
);
573 m_aSub
[SwFontScript::CTL
].SetUnderline( eUnderline
);
576 // encapsulated SV-Font-method
577 inline void SwSubFont::SetOverline( const FontLineStyle eOverline
)
579 m_nFontCacheId
= nullptr;
580 Font::SetOverline( eOverline
);
583 inline void SwFont::SetOverline( const FontLineStyle eOverline
)
586 m_aSub
[SwFontScript::Latin
].SetOverline( eOverline
);
587 m_aSub
[SwFontScript::CJK
].SetOverline( eOverline
);
588 m_aSub
[SwFontScript::CTL
].SetOverline( eOverline
);
591 // encapsulated SV-Font-method
592 inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout
)
594 m_nFontCacheId
= nullptr;
595 Font::SetStrikeout( eStrikeout
);
598 inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout
)
601 m_aSub
[SwFontScript::Latin
].SetStrikeout( eStrikeout
);
602 m_aSub
[SwFontScript::CJK
].SetStrikeout( eStrikeout
);
603 m_aSub
[SwFontScript::CTL
].SetStrikeout( eStrikeout
);
606 // encapsulated SV-Font-method
607 inline void SwSubFont::SetItalic( const FontItalic eItalic
)
609 m_nFontCacheId
= nullptr;
610 Font::SetItalic( eItalic
);
613 inline void SwFont::SetItalic( const FontItalic eItalic
, const SwFontScript nWhich
)
616 m_aSub
[nWhich
].SetItalic( eItalic
);
619 // encapsulated SV-Font-method
620 inline void SwSubFont::SetOutline( const bool bOutline
)
622 m_nFontCacheId
= nullptr;
623 Font::SetOutline( bOutline
);
626 inline void SwFont::SetOutline( const bool bOutline
)
629 m_aSub
[SwFontScript::Latin
].SetOutline( bOutline
);
630 m_aSub
[SwFontScript::CJK
].SetOutline( bOutline
);
631 m_aSub
[SwFontScript::CTL
].SetOutline( bOutline
);
634 // encapsulated SV-Font-method
635 inline void SwSubFont::SetShadow( const bool bShadow
)
637 m_nFontCacheId
= nullptr;
638 Font::SetShadow( bShadow
);
641 inline void SwFont::SetShadow( const bool bShadow
)
644 m_aSub
[SwFontScript::Latin
].SetShadow( bShadow
);
645 m_aSub
[SwFontScript::CJK
].SetShadow( bShadow
);
646 m_aSub
[SwFontScript::CTL
].SetShadow( bShadow
);
649 // encapsulated SV-Font-method
650 inline void SwSubFont::SetAutoKern( FontKerning nAutoKern
)
652 m_nFontCacheId
= nullptr;
653 Font::SetKerning( nAutoKern
);
656 inline void SwFont::SetAutoKern( FontKerning nAutoKern
)
659 m_aSub
[SwFontScript::CJK
].SetAutoKern( nAutoKern
);
660 if( nAutoKern
!= FontKerning::NONE
)
661 nAutoKern
= FontKerning::FontSpecific
;
662 m_aSub
[SwFontScript::Latin
].SetAutoKern( nAutoKern
);
663 m_aSub
[SwFontScript::CTL
].SetAutoKern( nAutoKern
);
666 inline void SwFont::SetTransparent( const bool bTrans
)
668 m_aSub
[SwFontScript::Latin
].SetTransparent( bTrans
);
669 m_aSub
[SwFontScript::CJK
].SetTransparent( bTrans
);
670 m_aSub
[SwFontScript::CTL
].SetTransparent( bTrans
);
673 inline void SwFont::SetFixKerning( const short nNewKern
)
675 m_aSub
[SwFontScript::Latin
].SetFixKerning( nNewKern
);
676 m_aSub
[SwFontScript::CJK
].SetFixKerning( nNewKern
);
677 m_aSub
[SwFontScript::CTL
].SetFixKerning( nNewKern
);
680 inline void SwFont::SetCaseMap( const SvxCaseMap eNew
)
682 m_aSub
[SwFontScript::Latin
].SetCaseMap( eNew
);
683 m_aSub
[SwFontScript::CJK
].SetCaseMap( eNew
);
684 m_aSub
[SwFontScript::CTL
].SetCaseMap( eNew
);
687 // encapsulated SV-Font-method
688 inline void SwSubFont::SetWordLineMode( const bool bWordLineMode
)
690 m_nFontCacheId
= nullptr;
691 Font::SetWordLineMode( bWordLineMode
);
694 inline void SwFont::SetWordLineMode( const bool bWordLineMode
)
697 m_aSub
[SwFontScript::Latin
].SetWordLineMode( bWordLineMode
);
698 m_aSub
[SwFontScript::CJK
].SetWordLineMode( bWordLineMode
);
699 m_aSub
[SwFontScript::CTL
].SetWordLineMode( bWordLineMode
);
701 // encapsulated SV-Font-method
702 inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue
)
704 m_nFontCacheId
= nullptr;
705 Font::SetEmphasisMark( eValue
);
708 inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue
)
711 m_aSub
[SwFontScript::Latin
].SetEmphasisMark( eValue
);
712 m_aSub
[SwFontScript::CJK
].SetEmphasisMark( eValue
);
713 m_aSub
[SwFontScript::CTL
].SetEmphasisMark( eValue
);
716 inline void SwFont::SetPropWidth( const sal_uInt16 nNew
)
718 if( nNew
!= m_aSub
[SwFontScript::Latin
].GetPropWidth() )
721 m_aSub
[SwFontScript::Latin
].SetPropWidth( nNew
);
722 m_aSub
[SwFontScript::CJK
].SetPropWidth( nNew
);
723 m_aSub
[SwFontScript::CTL
].SetPropWidth( nNew
);
727 // encapsulated SV-Font-method
728 inline void SwSubFont::SetRelief( const FontRelief eNew
)
730 m_nFontCacheId
= nullptr;
731 Font::SetRelief( eNew
);
734 inline void SwFont::SetRelief( const FontRelief eNew
)
736 if( eNew
!= m_aSub
[SwFontScript::Latin
].GetRelief() )
739 m_aSub
[SwFontScript::Latin
].SetRelief( eNew
);
740 m_aSub
[SwFontScript::CJK
].SetRelief( eNew
);
741 m_aSub
[SwFontScript::CTL
].SetRelief( eNew
);
745 // overloaded font-method
746 inline void SwSubFont::SetSize( const Size
& rSize
)
749 if ( GetPropr() == 100 )
750 Font::SetFontSize( m_aSize
);
753 Font::SetFontSize( Size(
754 m_aSize
.Width() * GetPropr() / 100,
755 m_aSize
.Height() * GetPropr() / 100 ) );
757 m_nFontCacheId
= nullptr;
760 inline void SwFont::SetSize( const Size
& rSize
, const SwFontScript nWhich
)
762 if( m_aSub
[nWhich
].m_aSize
!= rSize
)
764 m_aSub
[nWhich
].SetSize( rSize
);
770 inline void SwFont::SetActual( SwFontScript nNew
)
772 if ( m_nActual
!= nNew
)
780 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr
)
782 m_nFontCacheId
= nullptr;
783 Font::SetFontSize( Size( m_aSize
.Width() * nNewPropr
/ 100,
784 m_aSize
.Height() * nNewPropr
/ 100 ) );
785 SvxFont::SetPropr( nNewPropr
);
788 inline void SwFont::SetProportion( const sal_uInt8 nNewPropr
)
790 if( nNewPropr
!= m_aSub
[SwFontScript::Latin
].GetPropr() )
795 m_aSub
[SwFontScript::Latin
].SetProportion( nNewPropr
);
796 m_aSub
[SwFontScript::CJK
].SetProportion( nNewPropr
);
797 m_aSub
[SwFontScript::CTL
].SetProportion( nNewPropr
);
801 inline void SwSubFont::SetEscapement( const short nNewEsc
)
803 m_nFontCacheId
= nullptr;
804 SvxFont::SetEscapement( nNewEsc
);
807 inline void SwFont::SetEscapement( const short nNewEsc
)
809 if( nNewEsc
!= m_aSub
[SwFontScript::Latin
].GetEscapement() )
811 // these have to be set, otherwise nOrgHeight and nOrgAscent will not
816 m_aSub
[SwFontScript::Latin
].SetEscapement( nNewEsc
);
817 m_aSub
[SwFontScript::CJK
].SetEscapement( nNewEsc
);
818 m_aSub
[SwFontScript::CTL
].SetEscapement( nNewEsc
);
822 inline void SwSubFont::SetLanguage( LanguageType eNewLang
)
824 m_nFontCacheId
= nullptr;
825 if( eNewLang
== LANGUAGE_SYSTEM
)
826 eNewLang
= GetAppLanguage();
827 SvxFont::SetLanguage( eNewLang
);
830 inline void SwFont::SetLanguage( const LanguageType eNewLang
, const SwFontScript nWhich
)
832 m_aSub
[nWhich
].SetLanguage( eNewLang
);
833 if( SwFontScript::CJK
== nWhich
)
835 m_aSub
[SwFontScript::Latin
].SetCJKContextLanguage( eNewLang
);
836 m_aSub
[SwFontScript::CJK
].SetCJKContextLanguage( eNewLang
);
837 m_aSub
[SwFontScript::CTL
].SetCJKContextLanguage( eNewLang
);
841 inline void SwFont::SetGreyWave( const bool bNew
)
846 inline void SwSubFont::SetVertical( const Degree10 nDir
, const bool bVertFormat
)
848 m_nFontCacheId
= nullptr;
849 Font::SetVertical( bVertFormat
);
850 Font::SetOrientation( nDir
);
853 inline void SwFont::SetTopBorderDist( const sal_uInt16 nTopDist
)
855 m_nTopBorderDist
= nTopDist
;
857 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
860 inline void SwFont::SetBottomBorderDist( const sal_uInt16 nBottomDist
)
862 m_nBottomBorderDist
= nBottomDist
;
864 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
867 inline void SwFont::SetRightBorderDist( const sal_uInt16 nRightDist
)
869 m_nRightBorderDist
= nRightDist
;
871 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
874 inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist
)
876 m_nLeftBorderDist
= nLeftDist
;
878 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
881 inline sal_uInt16
SwFont::GetTopBorderSpace() const
886 nRet
+= m_aTopBorder
->GetScaledWidth() + m_nTopBorderDist
;
888 if( m_aShadowLocation
== SvxShadowLocation::TopLeft
||
889 m_aShadowLocation
== SvxShadowLocation::TopRight
)
891 nRet
+= m_nShadowWidth
;
896 inline sal_uInt16
SwFont::GetBottomBorderSpace() const
899 if( m_aBottomBorder
)
901 nRet
+= m_aBottomBorder
->GetScaledWidth() + m_nBottomBorderDist
;
903 if( m_aShadowLocation
== SvxShadowLocation::BottomLeft
||
904 m_aShadowLocation
== SvxShadowLocation::BottomRight
)
906 nRet
+= m_nShadowWidth
;
911 inline sal_uInt16
SwFont::GetRightBorderSpace() const
916 nRet
+= m_aRightBorder
->GetScaledWidth() + m_nRightBorderDist
;
918 if( m_aShadowLocation
== SvxShadowLocation::TopRight
||
919 m_aShadowLocation
== SvxShadowLocation::BottomRight
)
921 nRet
+= m_nShadowWidth
;
926 inline sal_uInt16
SwFont::GetLeftBorderSpace() const
931 nRet
+= m_aLeftBorder
->GetScaledWidth() + m_nLeftBorderDist
;
933 if( m_aShadowLocation
== SvxShadowLocation::TopLeft
||
934 m_aShadowLocation
== SvxShadowLocation::BottomLeft
)
936 nRet
+= m_nShadowWidth
;
941 inline bool SwFont::HasBorder() const
943 return m_aTopBorder
|| m_aBottomBorder
|| m_aLeftBorder
|| m_aRightBorder
;
946 inline void SwFont::SetShadowColor( const Color
& rColor
)
948 m_aShadowColor
= rColor
;
950 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
953 inline void SwFont::SetShadowWidth( const sal_uInt16 nWidth
)
955 m_nShadowWidth
= nWidth
;
957 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
960 inline void SwFont::SetShadowLocation( const SvxShadowLocation aLocation
)
962 m_aShadowLocation
= aLocation
;
964 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
967 inline void SwFont::SetHighlightColor( const Color
& aNewColor
)
969 m_aHighlightColor
= aNewColor
;
971 m_aSub
[SwFontScript::Latin
].m_nFontCacheId
= m_aSub
[SwFontScript::CJK
].m_nFontCacheId
= m_aSub
[SwFontScript::CTL
].m_nFontCacheId
= nullptr;
974 // Used for the "continuous underline" feature.
975 class SwUnderlineFont
978 TextFrameIndex m_nEnd
;
979 std::unique_ptr
<SwFont
> m_pFont
;
982 // sets the font which should paint the common baseline,
983 // index where continuous underline ends,
984 // and the starting point of the common baseline
985 SwUnderlineFont(SwFont
& rFnt
, TextFrameIndex nEnd
, const Point
& rPoint
);
990 OSL_ENSURE( m_pFont
, "No underline font" );
993 const Point
& GetPos() const { return m_aPos
; }
994 TextFrameIndex
GetEnd() const { return m_nEnd
; }
995 // the x coordinate of the starting point has to be set for each portion
996 void SetPos( const Point
& rPoint
) { m_aPos
= rPoint
; }
1004 sal_uInt16 nGetTextSize
;
1005 sal_uInt16 nDrawText
;
1006 sal_uInt16 nGetStretchTextSize
;
1007 sal_uInt16 nDrawStretchText
;
1008 sal_uInt16 nChangeFont
;
1011 { nGetTextSize
= nDrawText
= nGetStretchTextSize
= nDrawStretchText
= nChangeFont
= 0; }
1014 // global variable, implemented in swfont.cxx
1015 extern SvStatistics g_SvStat
;
1017 #define SV_STAT(nWhich) ++(g_SvStat.nWhich);
1021 #define SV_STAT(nWhich)
1022 #endif /* DBG_UTIL */
1026 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */