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