Line data Source code
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 : #ifndef _SWFONT_HXX
20 : #define _SWFONT_HXX
21 :
22 : #include <i18nlangtag/lang.h>
23 : #include <tools/color.hxx>
24 : #include <tools/stream.hxx>
25 : #include <tools/gen.hxx>
26 : #include <editeng/svxfont.hxx>
27 : #include <swtypes.hxx>
28 : #include <drawfont.hxx> // SwDrawTextInfo
29 :
30 : class SfxItemSet;
31 : class SwAttrSet;
32 : class SwDoCapitals; // DoCapitals
33 : class SwDrawTextInfo; // _DrawText
34 : class SwScriptInfo; // _GetTxtSize
35 : class ViewShell;
36 : class IDocumentSettingAccess;
37 :
38 : const sal_Unicode CH_BLANK = ' '; // ' ' Leerzeichen
39 : const sal_Unicode CH_BREAK = 0x0A; //
40 : const sal_Unicode CH_TAB = '\t'; // \t
41 : const sal_Unicode CH_PAR = 0xB6; // Paragraph
42 : const sal_Unicode CH_BULLET = 0xB7; // mittiger Punkt
43 :
44 337557 : class SwSubFont : public SvxFont
45 : {
46 : friend class SwFont;
47 : const void *pMagic; // "MagicNumber" innerhalb des Fontcaches
48 : Size aSize; // Fremde kriegen nur diese Size zu sehen
49 : sal_uInt16 nFntIndex; // Index im Fontcache
50 : sal_uInt16 nOrgHeight; // Hoehe inkl. Escapement/Proportion
51 : sal_uInt16 nOrgAscent; // Ascent inkl. Escapement/Proportion
52 : sal_uInt16 nPropWidth; // proportional width
53 : bool smallCapsPercentage66;
54 337563 : inline SwSubFont() : aSize(0,0)
55 337563 : { pMagic = NULL; nFntIndex = nOrgHeight = nOrgAscent = 0; nPropWidth =100; smallCapsPercentage66 = false; }
56 :
57 : sal_uInt16 CalcEscAscent( const sal_uInt16 nOldAscent ) const;
58 : sal_uInt16 CalcEscHeight( const sal_uInt16 nOldHeight,
59 : const sal_uInt16 nOldAscent ) const;
60 : void CalcEsc( SwDrawTextInfo& rInf, Point& rPos );
61 :
62 : inline void CopyMagic( const SwSubFont& rFnt )
63 : { pMagic = rFnt.pMagic; nFntIndex = rFnt.nFntIndex; }
64 :
65 : sal_Bool operator==( const SwFont &rFnt ) const;
66 : SwSubFont& operator=( const SwSubFont &rFont );
67 :
68 : short _CheckKerning( );
69 :
70 : sal_Bool ChgFnt( ViewShell *pSh, OutputDevice& rOut );
71 : sal_Bool IsSymbol( ViewShell *pSh );
72 : sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut );
73 : sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut );
74 : Size _GetTxtSize( SwDrawTextInfo& rInf );
75 : Size GetCapitalSize( SwDrawTextInfo& rInf );
76 : void _DrawText( SwDrawTextInfo &rInf, const sal_Bool bGrey );
77 : void DrawCapital( SwDrawTextInfo &rInf );
78 : void DrawStretchCapital( SwDrawTextInfo &rInf );
79 : void DoOnCapitals( SwDoCapitals &rDo );
80 : void _DrawStretchText( SwDrawTextInfo &rInf );
81 : xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf );
82 : xub_StrLen GetCapitalCrsrOfst( SwDrawTextInfo& rInf );
83 :
84 : inline void SetColor( const Color& rColor );
85 : inline void SetFillColor( const Color& rColor );
86 : inline void SetCharSet( const CharSet eCharSet );
87 : inline void SetPitch( const FontPitch ePitch );
88 : inline void SetAlign( const FontAlign eAlign );
89 : inline void SetUnderline( const FontUnderline eUnderline );
90 : inline void SetOverline( const FontUnderline eOverline );
91 : inline void SetStrikeout( const FontStrikeout eStrikeout );
92 : inline void SetItalic( const FontItalic eItalic );
93 : inline void SetOutline( const sal_Bool bOutline );
94 : inline void SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat );
95 : inline void SetShadow( const sal_Bool bShadow );
96 : inline void SetAutoKern( const sal_uInt8 nAutoKern );
97 : inline void SetWordLineMode( const sal_Bool bWordLineMode );
98 : inline void SetEmphasisMark( const FontEmphasisMark eValue );
99 : inline void SetRelief( const FontRelief eNew );
100 :
101 : // Methoden fuer die Hoch-/Tiefstellung
102 : inline void SetEscapement( const short nNewEsc );
103 : inline void SetProportion( const sal_uInt8 nNewPropr );
104 :
105 : inline void SetFamily( const FontFamily eFamily );
106 : inline void SetName( const XubString& rName );
107 : inline void SetStyleName( const XubString& rStyleName );
108 : inline void SetSize( const Size& rSize );
109 : inline void SetWeight( const FontWeight eWeight );
110 : inline void SetLanguage( LanguageType eNewLang );
111 61008 : inline short CheckKerning()
112 61008 : { return GetFixKerning() >= 0 ? GetFixKerning() : _CheckKerning( ); }
113 2532 : inline void SetPropWidth( const sal_uInt16 nNew )
114 2532 : { pMagic = 0; nPropWidth = nNew; }
115 : public:
116 159962 : sal_uInt16 GetPropWidth() const { return nPropWidth; }
117 : };
118 :
119 : #define SW_LATIN 0
120 : #define SW_CJK 1
121 : #define SW_CTL 2
122 : #define SW_SCRIPTS 3
123 :
124 : class SwFont
125 : { // CJK == Chinese, Japanese, Korean
126 : // CTL == Complex text layout ( Hebrew, Arabic )
127 : SwSubFont aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font
128 : Color* pBackColor; // background color (i.e. at character styles)
129 : Color aUnderColor; // color of the underlining
130 : Color aOverColor; // color of the overlining
131 : sal_uInt8 nToxCnt; // Zaehlt die Schachtelungstiefe der Tox
132 : sal_uInt8 nRefCnt; // Zaehlt die Schachtelungstiefe der Refs
133 : sal_uInt8 m_nMetaCount; // count META/METAFIELD
134 : sal_uInt8 nActual; // actual font (Latin, CJK or CTL)
135 :
136 : // Schalter fuer die Font-Extensions
137 : sal_Bool bNoHyph :1; // SwTxtNoHyphenHere: keine Trennstelle
138 : sal_Bool bBlink :1; // blinkender Font
139 : sal_Bool bPaintBlank :1; // Blanks nicht mit DrawRect
140 : sal_Bool bFntChg :1;
141 : sal_Bool bOrgChg :1; // nOrgHeight/Ascent sind invalid
142 : sal_Bool bURL :1;
143 : sal_Bool bPaintWrong :1; // Flag fuer Rechtschreibfehler
144 : sal_Bool bGreyWave :1; // Fuers extended TextInput: Graue Wellenlinie
145 : sal_Bool bNoColReplace :1; // Replacement without colormanipulation
146 :
147 : sal_Bool operator==( const SwFont &rFnt ) const;
148 :
149 : protected:
150 : inline SwFont() { pBackColor = NULL; nActual = SW_LATIN; }
151 :
152 : public:
153 : SwFont( const SwAttrSet* pSet, const IDocumentSettingAccess* pIDocumentSettingAccess );
154 : SwFont( const SwFont& rFont );
155 :
156 123809 : inline void ChgFnt( ViewShell *pSh, OutputDevice& rOut )
157 123809 : { bPaintBlank = aSub[nActual].ChgFnt( pSh, rOut ); }
158 :
159 112509 : ~SwFont(){ delete pBackColor; }
160 :
161 : SwFont& operator=( const SwFont &rFont );
162 :
163 394433 : inline sal_uInt8 GetActual() const { return nActual; }
164 : inline void SetActual( sal_uInt8 nNew );
165 0 : inline const SvxFont& GetActualFont() const { return aSub[nActual]; }
166 :
167 : // holt sich eine MagicNumber ueber SwFntAccess
168 : void GoMagic( ViewShell *pSh, sal_uInt8 nWhich );
169 : // set background color
170 : void SetBackColor( Color* pNewColor );
171 24792 : inline const Color* GetBackColor() const{ return pBackColor; }
172 :
173 55006 : inline void ChkMagic( ViewShell *pSh, sal_uInt8 nWhich )
174 55006 : { if( !aSub[ nWhich ].pMagic ) GoMagic( pSh, nWhich ); }
175 : // uebernimmt die MagicNumber eines (hoffentlich ident.) Kollegen
176 : inline void CopyMagic( const SwFont* pFnt, sal_uInt8 nWhich )
177 : { aSub[nWhich].CopyMagic( pFnt->aSub[nWhich] ); }
178 48700 : inline void GetMagic( const void* &rMagic, sal_uInt16 &rIdx, sal_uInt8 nWhich )
179 48700 : { rMagic = aSub[nWhich].pMagic; rIdx = aSub[nWhich].nFntIndex; }
180 81012 : inline void SetMagic( const void* pNew, const sal_uInt16 nIdx, sal_uInt8 nWhich )
181 81012 : { aSub[nWhich].pMagic = pNew; aSub[nWhich].nFntIndex = nIdx; }
182 1512 : inline sal_Bool DifferentMagic( const SwFont* pFnt, sal_uInt8 nWhich )
183 1857 : { return aSub[nWhich].pMagic != pFnt->aSub[nWhich].pMagic ||
184 1857 : !aSub[nWhich].pMagic || !pFnt->aSub[nWhich].pMagic; }
185 :
186 91 : inline const Size &GetSize( sal_uInt8 nWhich ) const
187 91 : { return aSub[nWhich].aSize; }
188 112212 : inline sal_Bool IsFntChg() const { return bFntChg; }
189 24930 : inline void SetFntChg( const sal_Bool bNew ) { bFntChg = bNew; }
190 :
191 : // die gekapselten SV-Font-Methoden (setzen bFntChg auf sal_True)
192 : inline void SetColor( const Color& rColor );
193 : inline void SetFillColor( const Color& rColor );
194 : inline void SetAlign( const FontAlign eAlign );
195 : inline void SetUnderline( const FontUnderline eUnderline );
196 10372 : inline void SetUnderColor( const Color &rColor ) { aUnderColor = rColor; }
197 : inline void SetOverline( const FontUnderline eOverline );
198 7825 : inline void SetOverColor( const Color &rColor ) { aOverColor = rColor; }
199 : inline void SetStrikeout( const FontStrikeout eStrikeout );
200 : inline void SetOutline( const sal_Bool bOutline );
201 : void SetVertical( sal_uInt16 nDir, const sal_Bool nVertLayout = sal_False );
202 : inline void SetShadow( const sal_Bool bShadow );
203 : inline void SetAutoKern( sal_uInt8 nAutoKern );
204 : inline void SetTransparent( const sal_Bool bTrans );
205 : inline void SetWordLineMode( const sal_Bool bWordLineMode );
206 : inline void SetFixKerning( const short nNewKern );
207 : inline void SetCaseMap( const SvxCaseMap eNew );
208 : inline void SetEmphasisMark( const FontEmphasisMark eValue );
209 :
210 : // Methoden fuer die Hoch-/Tiefstellung
211 : inline void SetEscapement( const short nNewEsc );
212 : inline void SetProportion( const sal_uInt8 nNewPropr );
213 :
214 : inline void SetPropWidth( const sal_uInt16 nNew );
215 :
216 : inline void SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich );
217 : inline void SetName( const XubString& rName, const sal_uInt8 nWhich );
218 : inline void SetStyleName( const XubString& rStyleName, const sal_uInt8 nWhich );
219 : inline void SetSize( const Size& rSize, const sal_uInt8 nWhich );
220 : inline void SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich );
221 : inline void SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich );
222 : inline void SetLanguage( LanguageType eNewLang, const sal_uInt8 nWhich );
223 : inline void SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich );
224 : inline void SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich );
225 : inline void SetRelief( const FontRelief eNew );
226 :
227 : // Get/Set-Methoden fuer die aktuelle Einstellung
228 : inline void SetNoHyph( const sal_Bool bNew );
229 : inline sal_Bool IsNoHyph() const { return bNoHyph; }
230 : inline void SetBlink( const sal_Bool bBlink );
231 11197 : inline sal_Bool IsBlink() const { return bBlink; }
232 940 : inline sal_uInt8 &GetTox() { return nToxCnt; }
233 : inline sal_uInt8 GetTox() const { return nToxCnt; }
234 23338 : inline sal_Bool IsTox() const { return ( 0 != nToxCnt ); }
235 155 : inline sal_uInt8 &GetRef() { return nRefCnt; }
236 : inline sal_uInt8 GetRef() const { return nRefCnt; }
237 23317 : inline sal_Bool IsRef() const { return ( 0 != nRefCnt ); }
238 1120 : inline sal_uInt8 &GetMeta() { return m_nMetaCount; }
239 : inline sal_uInt8 GetMeta() const { return m_nMetaCount; }
240 23299 : inline bool IsMeta() const { return (0 != m_nMetaCount); }
241 : inline void SetURL( const sal_Bool bURL );
242 40260 : inline sal_Bool IsURL() const { return bURL; }
243 : inline void SetGreyWave( const sal_Bool bNew );
244 11205 : inline sal_Bool IsGreyWave() const { return bGreyWave; }
245 : inline void SetNoCol( const sal_Bool bNew );
246 : inline sal_Bool IsNoCol() const { return bNoColReplace; }
247 :
248 : inline void SetPaintBlank( const sal_Bool bNew );
249 18 : inline sal_Bool IsPaintBlank() const { return bPaintBlank; }
250 : inline void SetPaintWrong( const sal_Bool bNew );
251 : inline sal_Bool IsPaintWrong() const { return bPaintWrong; }
252 :
253 : // Setzen der Basisklasse Font fuer SwTxtCharFmt
254 : void SetDiffFnt( const SfxItemSet* pSet,
255 : const IDocumentSettingAccess* pIDocumentSettingAccess );
256 :
257 0 : inline const SvxFont &GetFnt( const sal_uInt8 nWhich ) const
258 0 : { return aSub[nWhich]; };
259 :
260 0 : sal_Bool IsSymbol( ViewShell *pSh )
261 0 : { return aSub[nActual].IsSymbol( pSh ); }
262 70383 : FontUnderline GetUnderline() const { return aSub[nActual].GetUnderline(); }
263 110676 : const Color& GetUnderColor() const { return aUnderColor; }
264 43 : FontUnderline GetOverline() const { return aSub[nActual].GetOverline(); }
265 110633 : const Color& GetOverColor() const { return aOverColor; }
266 0 : short GetFixKerning() const { return aSub[nActual].GetFixKerning(); }
267 43 : FontStrikeout GetStrikeout() const { return aSub[nActual].GetStrikeout(); }
268 0 : const Color& GetColor() const { return aSub[nActual].GetColor(); }
269 : sal_Bool IsShadow() const { return aSub[nActual].IsShadow(); }
270 1243 : sal_Bool IsWordLineMode() const { return aSub[nActual].IsWordLineMode(); }
271 : sal_Bool IsOutline() const { return aSub[nActual].IsOutline(); }
272 : sal_Bool IsKerning() const { return aSub[nActual].IsKerning(); }
273 1764 : short GetEscapement() const { return aSub[nActual].GetEscapement(); }
274 644 : SvxCaseMap GetCaseMap() const { return aSub[nActual].GetCaseMap(); }
275 155 : sal_uInt8 GetPropr() const { return aSub[nActual].GetPropr(); }
276 24970 : FontItalic GetItalic() const { return aSub[nActual].GetItalic(); }
277 53757 : LanguageType GetLanguage() const { return aSub[nActual].GetLanguage(); }
278 : FontAlign GetAlign() const { return aSub[nActual].GetAlign(); }
279 : const XubString& GetName() const { return aSub[nActual].GetName(); }
280 : const XubString& GetStyleName() const {return aSub[nActual].GetStyleName();}
281 : FontFamily GetFamily() const { return aSub[nActual].GetFamily(); }
282 : FontPitch GetPitch() const { return aSub[nActual].GetPitch(); }
283 : rtl_TextEncoding GetCharSet() const { return aSub[nActual].GetCharSet(); }
284 1330 : long GetHeight() const { return aSub[nActual].GetSize().Height(); }
285 156 : FontWeight GetWeight() const { return aSub[nActual].GetWeight(); }
286 0 : FontEmphasisMark GetEmphasisMark() const
287 0 : { return aSub[nActual].GetEmphasisMark(); }
288 : sal_uInt16 GetPropWidth() const { return aSub[nActual].GetPropWidth(); }
289 : sal_uInt16 GetOrientation( const sal_Bool nVertLayout = sal_False ) const;
290 :
291 0 : inline const XubString& GetName( const sal_uInt8 nWhich ) const
292 0 : { return aSub[nWhich].GetName(); }
293 0 : inline LanguageType GetLanguage( const sal_uInt8 nWhich ) const
294 0 : { return aSub[nWhich].GetLanguage(); }
295 : inline const XubString& GetStyleName( const sal_uInt8 nWhich ) const
296 : { return aSub[nWhich].GetStyleName(); }
297 : inline FontFamily GetFamily( const sal_uInt8 nWhich ) const
298 : { return aSub[nWhich].GetFamily(); }
299 : inline FontItalic GetItalic( const sal_uInt8 nWhich ) const
300 : { return aSub[nWhich].GetItalic(); }
301 : inline FontPitch GetPitch( const sal_uInt8 nWhich ) const
302 : { return aSub[nWhich].GetPitch(); }
303 15 : inline rtl_TextEncoding GetCharSet( const sal_uInt8 nWhich ) const
304 15 : { return aSub[nWhich].GetCharSet(); }
305 0 : inline long GetHeight( const sal_uInt8 nWhich ) const
306 0 : { return aSub[nWhich].GetSize().Height(); }
307 : inline FontWeight GetWeight( const sal_uInt8 nWhich ) const
308 : { return aSub[nWhich].GetWeight(); }
309 : inline FontEmphasisMark GetEmphasisMark( const sal_uInt8 nWhich ) const
310 : { return aSub[nWhich].GetEmphasisMark(); }
311 :
312 : // Macht den logischen Font im OutputDevice wirksam.
313 : void ChgPhysFnt( ViewShell *pSh, OutputDevice& rOut );
314 :
315 : Size GetCapitalSize( SwDrawTextInfo& rInf )
316 : { return aSub[nActual].GetCapitalSize( rInf ); }
317 :
318 : xub_StrLen GetCapitalBreak( ViewShell* pSh, const OutputDevice* pOut,
319 : const SwScriptInfo* pScript, const XubString& rTxt,
320 : long nTextWidth, const xub_StrLen nIdx,
321 : const xub_StrLen nLen );
322 :
323 : xub_StrLen GetCapitalCrsrOfst( SwDrawTextInfo& rInf )
324 : { return aSub[nActual].GetCapitalCrsrOfst( rInf ); }
325 :
326 : void DrawCapital( SwDrawTextInfo &rInf )
327 : { aSub[nActual].DrawCapital( rInf ); }
328 :
329 : void DrawStretchCapital( SwDrawTextInfo &rInf )
330 : { aSub[nActual].DrawStretchCapital( rInf ); }
331 :
332 0 : void DoOnCapitals( SwDoCapitals &rDo )
333 0 : { aSub[nActual].DoOnCapitals( rDo ); }
334 :
335 25025 : Size _GetTxtSize( SwDrawTextInfo& rInf )
336 25025 : { rInf.SetFont( this ); return aSub[nActual]._GetTxtSize( rInf ); }
337 :
338 : xub_StrLen GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth );
339 :
340 0 : xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf )
341 0 : { return aSub[nActual]._GetCrsrOfst( rInf ); }
342 :
343 11205 : inline void _DrawText( SwDrawTextInfo &rInf )
344 11205 : { aSub[nActual]._DrawText( rInf, IsGreyWave() ); }
345 :
346 49 : inline void _DrawStretchText( SwDrawTextInfo &rInf )
347 49 : { aSub[nActual]._DrawStretchText( rInf ); }
348 :
349 24685 : inline short CheckKerning()
350 24685 : { return aSub[nActual].CheckKerning(); }
351 :
352 50794 : inline sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut )
353 50794 : { return aSub[nActual].GetAscent( pSh, rOut ); }
354 63488 : inline sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut )
355 63488 : { return aSub[nActual].GetHeight( pSh, rOut ); }
356 :
357 3042 : inline void Invalidate()
358 3042 : { bFntChg = bOrgChg = sal_True; }
359 : };
360 :
361 10766 : inline void SwFont::SetColor( const Color& rColor )
362 : {
363 10766 : bFntChg = sal_True;
364 10766 : aSub[0].SetColor( rColor );
365 10766 : aSub[1].SetColor( rColor );
366 10766 : aSub[2].SetColor( rColor );
367 10766 : }
368 :
369 : // gekapselte SV-Font-Methode
370 32298 : inline void SwSubFont::SetColor( const Color& rColor )
371 : {
372 32298 : pMagic = 0;
373 32298 : Font::SetColor( rColor );
374 32298 : }
375 :
376 :
377 : // gekapselte SV-Font-Methode
378 129 : inline void SwSubFont::SetFillColor( const Color& rColor )
379 : {
380 129 : pMagic = 0;
381 129 : Font::SetFillColor( rColor );
382 129 : }
383 :
384 43 : inline void SwFont::SetFillColor( const Color& rColor )
385 : {
386 43 : bFntChg = sal_True;
387 43 : aSub[0].SetFillColor( rColor );
388 43 : aSub[1].SetFillColor( rColor );
389 43 : aSub[2].SetFillColor( rColor );
390 43 : }
391 :
392 : // gekapselte SV-Font-Methode
393 28196 : inline void SwSubFont::SetFamily( const FontFamily eFamily )
394 : {
395 28196 : pMagic = 0;
396 28196 : Font::SetFamily( eFamily );
397 28196 : }
398 :
399 4751 : inline void SwFont::SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich )
400 : {
401 4751 : bFntChg = sal_True;
402 4751 : aSub[nWhich].SetFamily( eFamily );
403 4751 : }
404 :
405 : // gekapselte SV-Font-Methode
406 28070 : inline void SwSubFont::SetName( const XubString& rName )
407 : {
408 28070 : pMagic = 0;
409 28070 : Font::SetName( rName );
410 28070 : }
411 :
412 4751 : inline void SwFont::SetName( const XubString& rName, const sal_uInt8 nWhich )
413 : {
414 4751 : bFntChg = sal_True;
415 4751 : aSub[nWhich].SetName( rName );
416 4751 : }
417 :
418 : // gekapselte SV-Font-Methode
419 28070 : inline void SwSubFont::SetStyleName( const XubString& rStyleName )
420 : {
421 28070 : pMagic = 0;
422 28070 : Font::SetStyleName( rStyleName );
423 28070 : }
424 :
425 4751 : inline void SwFont::SetStyleName( const XubString& rStyle, const sal_uInt8 nWhich )
426 : {
427 4751 : bFntChg = sal_True;
428 4751 : aSub[nWhich].SetStyleName( rStyle );
429 4751 : }
430 :
431 : // gekapselte SV-Font-Methode
432 28070 : inline void SwSubFont::SetCharSet( const CharSet eCharSet )
433 : {
434 28070 : pMagic = 0;
435 28070 : Font::SetCharSet( eCharSet );
436 28070 : }
437 :
438 4751 : inline void SwFont::SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich )
439 : {
440 4751 : bFntChg = sal_True;
441 4751 : aSub[nWhich].SetCharSet( eCharSet );
442 4751 : }
443 :
444 : // gekapselte SV-Font-Methode
445 28068 : inline void SwSubFont::SetPitch( const FontPitch ePitch )
446 : {
447 28068 : pMagic = 0;
448 28068 : Font::SetPitch( ePitch );
449 28068 : }
450 :
451 : // gekapselte SV-Font-Methode
452 4749 : inline void SwFont::SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich )
453 : {
454 4749 : bFntChg = sal_True;
455 4749 : aSub[nWhich].SetPitch( ePitch );
456 4749 : }
457 :
458 : // gekapselte SV-Font-Methode
459 28422 : inline void SwSubFont::SetAlign( const FontAlign eAlign )
460 : {
461 28422 : pMagic = 0;
462 28422 : Font::SetAlign( eAlign );
463 28422 : }
464 :
465 9474 : inline void SwFont::SetAlign( const FontAlign eAlign )
466 : {
467 9474 : bFntChg = sal_True;
468 9474 : aSub[0].SetAlign( eAlign );
469 9474 : aSub[1].SetAlign( eAlign );
470 9474 : aSub[2].SetAlign( eAlign );
471 9474 : }
472 :
473 : // gekapselte SV-Font-Methode
474 26106 : inline void SwSubFont::SetWeight( const FontWeight eWeight )
475 : {
476 26106 : pMagic = 0;
477 26106 : Font::SetWeight( eWeight );
478 26106 : }
479 :
480 2787 : inline void SwFont::SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich )
481 : {
482 2787 : bFntChg = sal_True;
483 2787 : aSub[nWhich].SetWeight( eWeight );
484 2787 : }
485 :
486 : // gekapselte SV-Font-Methode
487 31999 : inline void SwSubFont::SetUnderline( const FontUnderline eUnderline )
488 : {
489 31999 : pMagic = 0;
490 31999 : Font::SetUnderline( eUnderline );
491 31999 : }
492 :
493 10634 : inline void SwFont::SetUnderline( const FontUnderline eUnderline )
494 : {
495 10634 : bFntChg = sal_True;
496 10634 : aSub[0].SetUnderline( eUnderline );
497 10634 : aSub[1].SetUnderline( eUnderline );
498 10634 : aSub[2].SetUnderline( eUnderline );
499 10634 : }
500 :
501 : // gekapselte SV-Font-Methode
502 24303 : inline void SwSubFont::SetOverline( const FontUnderline eOverline )
503 : {
504 24303 : pMagic = 0;
505 24303 : Font::SetOverline( eOverline );
506 24303 : }
507 :
508 8098 : inline void SwFont::SetOverline( const FontUnderline eOverline )
509 : {
510 8098 : bFntChg = sal_True;
511 8098 : aSub[0].SetOverline( eOverline );
512 8098 : aSub[1].SetOverline( eOverline );
513 8098 : aSub[2].SetOverline( eOverline );
514 8098 : }
515 :
516 : // gekapselte SV-Font-Methode
517 27603 : inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout )
518 : {
519 27603 : pMagic = 0;
520 27603 : Font::SetStrikeout( eStrikeout );
521 27603 : }
522 :
523 9198 : inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout )
524 : {
525 9198 : bFntChg = sal_True;
526 9198 : aSub[0].SetStrikeout( eStrikeout );
527 9198 : aSub[1].SetStrikeout( eStrikeout );
528 9198 : aSub[2].SetStrikeout( eStrikeout );
529 9198 : }
530 :
531 : // gekapselte SV-Font-Methode
532 26820 : inline void SwSubFont::SetItalic( const FontItalic eItalic )
533 : {
534 26820 : pMagic = 0;
535 26820 : Font::SetItalic( eItalic );
536 26820 : }
537 :
538 3501 : inline void SwFont::SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich )
539 : {
540 3501 : bFntChg = sal_True;
541 3501 : aSub[nWhich].SetItalic( eItalic );
542 3501 : }
543 :
544 : // gekapselte SV-Font-Methode
545 26322 : inline void SwSubFont::SetOutline( const sal_Bool bOutline )
546 : {
547 26322 : pMagic = 0;
548 26322 : Font::SetOutline( bOutline );
549 26322 : }
550 :
551 8774 : inline void SwFont::SetOutline( const sal_Bool bOutline )
552 : {
553 8774 : bFntChg = sal_True;
554 8774 : aSub[0].SetOutline( bOutline );
555 8774 : aSub[1].SetOutline( bOutline );
556 8774 : aSub[2].SetOutline( bOutline );
557 8774 : }
558 :
559 : // gekapselte SV-Font-Methode
560 26730 : inline void SwSubFont::SetShadow( const sal_Bool bShadow )
561 : {
562 26730 : pMagic = 0;
563 26730 : Font::SetShadow( bShadow );
564 26730 : }
565 :
566 8910 : inline void SwFont::SetShadow( const sal_Bool bShadow )
567 : {
568 8910 : bFntChg = sal_True;
569 8910 : aSub[0].SetShadow( bShadow );
570 8910 : aSub[1].SetShadow( bShadow );
571 8910 : aSub[2].SetShadow( bShadow );
572 8910 : }
573 :
574 : // gekapselte SV-Font-Methode
575 27855 : inline void SwSubFont::SetAutoKern( const sal_uInt8 nAutoKern )
576 : {
577 27855 : pMagic = 0;
578 27855 : Font::SetKerning( nAutoKern );
579 27855 : }
580 :
581 9285 : inline void SwFont::SetAutoKern( sal_uInt8 nAutoKern )
582 : {
583 9285 : bFntChg = sal_True;
584 9285 : aSub[1].SetAutoKern( nAutoKern );
585 9285 : if( nAutoKern )
586 5014 : nAutoKern = KERNING_FONTSPECIFIC;
587 9285 : aSub[0].SetAutoKern( nAutoKern );
588 9285 : aSub[2].SetAutoKern( nAutoKern );
589 9285 : }
590 :
591 9474 : inline void SwFont::SetTransparent( const sal_Bool bTrans )
592 : {
593 9474 : aSub[0].SetTransparent( bTrans );
594 9474 : aSub[1].SetTransparent( bTrans );
595 9474 : aSub[2].SetTransparent( bTrans );
596 9474 : }
597 :
598 8982 : inline void SwFont::SetFixKerning( const short nNewKern )
599 : {
600 8982 : aSub[SW_LATIN].SetFixKerning( nNewKern );
601 8982 : aSub[SW_CJK].SetFixKerning( nNewKern );
602 8982 : aSub[SW_CTL].SetFixKerning( nNewKern );
603 8982 : }
604 :
605 9165 : inline void SwFont::SetCaseMap( const SvxCaseMap eNew )
606 : {
607 9165 : aSub[SW_LATIN].SetCaseMap( eNew );
608 9165 : aSub[SW_CJK].SetCaseMap( eNew );
609 9165 : aSub[SW_CTL].SetCaseMap( eNew );
610 9165 : }
611 :
612 : // gekapselte SV-Font-Methode
613 27000 : inline void SwSubFont::SetWordLineMode( const sal_Bool bWordLineMode )
614 : {
615 27000 : pMagic = 0;
616 27000 : Font::SetWordLineMode( bWordLineMode );
617 27000 : }
618 :
619 9000 : inline void SwFont::SetWordLineMode( const sal_Bool bWordLineMode )
620 : {
621 9000 : bFntChg = sal_True;
622 9000 : aSub[0].SetWordLineMode( bWordLineMode );
623 9000 : aSub[1].SetWordLineMode( bWordLineMode );
624 9000 : aSub[2].SetWordLineMode( bWordLineMode );
625 9000 : }
626 : // gekapselte SV-Font-Methode
627 26286 : inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue )
628 : {
629 26286 : pMagic = 0;
630 26286 : Font::SetEmphasisMark( eValue );
631 26286 : }
632 :
633 8762 : inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue )
634 : {
635 8762 : bFntChg = sal_True;
636 8762 : aSub[0].SetEmphasisMark( eValue );
637 8762 : aSub[1].SetEmphasisMark( eValue );
638 8762 : aSub[2].SetEmphasisMark( eValue );
639 8762 : }
640 :
641 8216 : inline void SwFont::SetPropWidth( const sal_uInt16 nNew )
642 : {
643 8216 : if( nNew != aSub[0].GetPropWidth() )
644 : {
645 844 : bFntChg = sal_True;
646 844 : aSub[0].SetPropWidth( nNew );
647 844 : aSub[1].SetPropWidth( nNew );
648 844 : aSub[2].SetPropWidth( nNew );
649 : }
650 8216 : }
651 :
652 : // gekapselte SV-Font-Methode
653 4533 : inline void SwSubFont::SetRelief( const FontRelief eNew )
654 : {
655 4533 : pMagic = 0;
656 4533 : Font::SetRelief( eNew );
657 4533 : }
658 :
659 8573 : inline void SwFont::SetRelief( const FontRelief eNew )
660 : {
661 8573 : if( eNew != aSub[0].GetRelief() )
662 : {
663 1511 : bFntChg = sal_True;
664 1511 : aSub[0].SetRelief( eNew );
665 1511 : aSub[1].SetRelief( eNew );
666 1511 : aSub[2].SetRelief( eNew );
667 : }
668 8573 : }
669 :
670 : // ueberladene Font-Methode
671 29744 : inline void SwSubFont::SetSize( const Size& rSize )
672 : {
673 29744 : aSize = rSize;
674 29744 : if ( GetPropr() == 100 )
675 29314 : Font::SetSize( aSize );
676 : else
677 : {
678 : Font::SetSize( Size(
679 430 : (long) aSize.Width() * GetPropr() / 100L,
680 860 : (long) aSize.Height() * GetPropr() / 100L ) );
681 : }
682 29744 : pMagic = 0;
683 29744 : }
684 :
685 6223 : inline void SwFont::SetSize( const Size& rSize, const sal_uInt8 nWhich )
686 : {
687 6223 : if( aSub[nWhich].aSize != rSize )
688 : {
689 5991 : aSub[nWhich].SetSize( rSize );
690 5991 : bFntChg = sal_True;
691 5991 : bOrgChg = sal_True;
692 : }
693 6223 : }
694 :
695 154133 : inline void SwFont::SetActual( sal_uInt8 nNew )
696 : {
697 154133 : if ( nActual != nNew )
698 : {
699 40 : bFntChg = sal_True;
700 40 : bOrgChg = sal_True;
701 40 : nActual = nNew;
702 : }
703 154133 : }
704 :
705 9978 : inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
706 : {
707 9978 : pMagic = 0;
708 9978 : Font::SetSize( Size( (long) aSize.Width() * nNewPropr / 100L,
709 19956 : (long) aSize.Height() * nNewPropr / 100L ) );
710 9978 : SvxFont::SetPropr( nNewPropr );
711 9978 : }
712 :
713 11235 : inline void SwFont::SetProportion( const sal_uInt8 nNewPropr )
714 : {
715 11235 : if( nNewPropr != aSub[0].GetPropr() )
716 : {
717 3321 : bFntChg = sal_True;
718 3321 : bOrgChg = sal_True;
719 :
720 3321 : aSub[0].SetProportion( nNewPropr );
721 3321 : aSub[1].SetProportion( nNewPropr );
722 3321 : aSub[2].SetProportion( nNewPropr );
723 : }
724 11235 : }
725 :
726 11199 : inline void SwSubFont::SetEscapement( const short nNewEsc )
727 : {
728 11199 : pMagic = 0;
729 11199 : SvxFont::SetEscapement( nNewEsc );
730 11199 : }
731 :
732 9735 : inline void SwFont::SetEscapement( const short nNewEsc )
733 : {
734 9735 : if( nNewEsc != aSub[0].GetEscapement() )
735 : {
736 : // these have to be set, otherwise nOrgHeight and nOrgAscent will not
737 : // be calculated
738 3733 : bFntChg = sal_True;
739 3733 : bOrgChg = sal_True;
740 :
741 3733 : aSub[0].SetEscapement( nNewEsc );
742 3733 : aSub[1].SetEscapement( nNewEsc );
743 3733 : aSub[2].SetEscapement( nNewEsc );
744 : }
745 9735 : }
746 :
747 27997 : inline void SwSubFont::SetLanguage( LanguageType eNewLang )
748 : {
749 27997 : pMagic = 0;
750 27997 : if( eNewLang == LANGUAGE_SYSTEM )
751 63 : eNewLang = (LanguageType)GetAppLanguage();
752 27997 : SvxFont::SetLanguage( eNewLang );
753 27997 : }
754 :
755 4678 : inline void SwFont::SetLanguage( const LanguageType eNewLang, const sal_uInt8 nWhich )
756 : {
757 4678 : aSub[nWhich].SetLanguage( eNewLang );
758 4678 : if( SW_CJK == nWhich )
759 : {
760 1113 : aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
761 1113 : aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
762 1113 : aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
763 : }
764 4678 : }
765 :
766 : inline void SwFont::SetPaintBlank( const sal_Bool bNew )
767 : {
768 : bPaintBlank = bNew;
769 : }
770 :
771 : inline void SwFont::SetPaintWrong( const sal_Bool bNew )
772 : {
773 : bPaintWrong = bNew;
774 : }
775 :
776 0 : inline void SwFont::SetNoHyph( const sal_Bool bNew )
777 : {
778 0 : bNoHyph = bNew;
779 0 : }
780 :
781 1297 : inline void SwFont::SetBlink( const sal_Bool bNew )
782 : {
783 1297 : bBlink = bNew;
784 1297 : }
785 :
786 : inline void SwFont::SetURL( const sal_Bool bNew )
787 : {
788 : bURL = bNew;
789 : }
790 :
791 0 : inline void SwFont::SetGreyWave( const sal_Bool bNew )
792 : {
793 0 : bGreyWave = bNew;
794 0 : }
795 :
796 56 : inline void SwFont::SetNoCol( const sal_Bool bNew )
797 : {
798 56 : bNoColReplace = bNew;
799 56 : }
800 :
801 2295 : inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat )
802 : {
803 2295 : pMagic = 0;
804 2295 : Font::SetVertical( bVertFormat );
805 2295 : Font::SetOrientation( nDir );
806 2295 : }
807 :
808 :
809 : /*************************************************************************
810 : * class SwUnderlineFont
811 : *
812 : * Used for the "continuous underline" feature.
813 : *************************************************************************/
814 :
815 : class SwUnderlineFont
816 : {
817 : Point aPos;
818 : SwFont* pFnt;
819 :
820 : public:
821 : // sets the font which should paint the common baseline
822 : // and the starting point of the common baseline
823 : SwUnderlineFont( SwFont& rFnt, const Point& rPoint );
824 : ~SwUnderlineFont();
825 :
826 87 : SwFont& GetFont()
827 : {
828 : OSL_ENSURE( pFnt, "No underline font" );
829 87 : return *pFnt;
830 : }
831 44 : const Point& GetPos() const { return aPos; }
832 : // the x coordinate of the starting point has to be set for each portion
833 43 : void SetPos( const Point& rPoint ) { aPos = rPoint; }
834 : };
835 :
836 :
837 : /*************************************************************************
838 : * class SvStatistics
839 : *************************************************************************/
840 :
841 : #ifdef DBG_UTIL
842 :
843 : class SvStatistics
844 : {
845 : public:
846 : sal_uInt16 nGetTextSize;
847 : sal_uInt16 nDrawText;
848 : sal_uInt16 nGetStretchTextSize;
849 : sal_uInt16 nDrawStretchText;
850 : sal_uInt16 nChangeFont;
851 : sal_uInt16 nGetFontMetric;
852 :
853 : inline void Reset()
854 : {
855 : nGetTextSize = nDrawText = nGetStretchTextSize =
856 : nDrawStretchText = nChangeFont = nGetFontMetric = 0;
857 : }
858 :
859 : inline SvStatistics() { Reset(); }
860 :
861 : inline void PrintOn( SvStream &rOS ) const; //$ ostream
862 : inline sal_Bool IsEmpty() const
863 : {
864 : return !( nGetTextSize || nDrawText ||
865 : nDrawStretchText || nChangeFont || nGetFontMetric );
866 : }
867 : };
868 :
869 : // globale Variable, implementiert in swfont.cxx
870 : extern SvStatistics g_SvStat;
871 :
872 : #define SV_STAT(nWhich) ++(g_SvStat.nWhich);
873 :
874 : inline void SvStatistics::PrintOn( SvStream &rOS ) const //$ ostream
875 : {
876 : if( IsEmpty() )
877 : return;
878 :
879 : rOS << "{ SV called:" << '\n';
880 : if( nGetTextSize )
881 : rOS << "\tnGetTextSize: " << nGetTextSize << '\n'; if( nDrawText )
882 : rOS << "\tnDrawText: " << nDrawText << '\n'; if( nGetStretchTextSize )
883 : rOS << "\tnGetStretchTextSize: " << nGetStretchTextSize << '\n'; if( nDrawStretchText )
884 : rOS << "\tnDrawStretchText: " << nDrawStretchText << '\n'; if( nChangeFont )
885 : rOS << "\tnChangeFont: " << nChangeFont << '\n'; if( nGetFontMetric )
886 : rOS << "\tnGetFontMetric: " << nGetFontMetric << '\n'; rOS << "}" << '\n'; }
887 : #else
888 : #define SV_STAT(nWhich)
889 : #endif /* DBG_UTIL */
890 :
891 : #endif
892 :
893 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|