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