xref: /trunk/main/sw/source/core/inc/swfont.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SWFONT_HXX
28 #define _SWFONT_HXX
29 
30 #include <i18npool/lang.h>
31 #include <tools/color.hxx>
32 #ifndef _TOOLS_STREAM_HXX //autogen
33 #include <tools/stream.hxx>
34 #endif
35 #include <editeng/svxfont.hxx>
36 #include <swtypes.hxx>
37 #include <drawfont.hxx>     // SwDrawTextInfo
38 
39 class SfxItemSet;
40 class SwAttrSet;
41 class SwDoCapitals;     // DoCapitals
42 class SwDrawTextInfo;   // _DrawText
43 class SwScriptInfo;     // _GetTxtSize
44 class ViewShell;
45 class IDocumentSettingAccess;
46 
47 const xub_Unicode CH_BLANK = ' ';   // ' ' Leerzeichen
48 const xub_Unicode CH_BREAK = 0x0A;  //
49 const xub_Unicode CH_TAB   = '\t';  // \t
50 const xub_Unicode CH_PAR    = 0xB6;     // Paragraph
51 const xub_Unicode CH_BULLET = 0xB7;     // mittiger Punkt
52 
53 class SwSubFont : public SvxFont
54 {
55     friend class SwFont;
56     const void *pMagic;         // "MagicNumber" innerhalb des Fontcaches
57     Size        aSize;          // Fremde kriegen nur diese Size zu sehen
58     sal_uInt16      nFntIndex;      // Index im Fontcache
59     sal_uInt16      nOrgHeight;     // Hoehe inkl. Escapement/Proportion
60     sal_uInt16      nOrgAscent;     // Ascent inkl. Escapement/Proportion
61     sal_uInt16      nPropWidth;     // proportional width
62     inline SwSubFont() : aSize(0,0)
63     { pMagic = NULL; nFntIndex = nOrgHeight = nOrgAscent = 0; nPropWidth =100; }
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     inline short CheckKerning()
120     {   return GetFixKerning() >= 0 ? GetFixKerning() : _CheckKerning( ); }
121     inline void SetPropWidth( const sal_uInt16 nNew )
122         { pMagic = 0; nPropWidth = nNew; }
123 public:
124     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     inline void ChgFnt( ViewShell *pSh, OutputDevice& rOut )
165         { bPaintBlank = aSub[nActual].ChgFnt( pSh, rOut ); }
166 
167     ~SwFont(){ delete pBackColor; }
168 
169     SwFont& operator=( const SwFont &rFont );
170 
171     inline sal_uInt8 GetActual() const {    return nActual; }
172     inline void SetActual( sal_uInt8 nNew );
173     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     inline const Color* GetBackColor() const{ return pBackColor; }
180 
181     inline void ChkMagic( ViewShell *pSh, sal_uInt8 nWhich )
182         { 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     inline void GetMagic( const void* &rMagic, sal_uInt16 &rIdx, sal_uInt8 nWhich )
187         { rMagic = aSub[nWhich].pMagic; rIdx = aSub[nWhich].nFntIndex; }
188     inline void SetMagic( const void* pNew, const sal_uInt16 nIdx, sal_uInt8 nWhich )
189         { aSub[nWhich].pMagic = pNew; aSub[nWhich].nFntIndex = nIdx; }
190     inline sal_Bool DifferentMagic( const SwFont* pFnt, sal_uInt8 nWhich )
191         { return aSub[nWhich].pMagic != pFnt->aSub[nWhich].pMagic ||
192           !aSub[nWhich].pMagic || !pFnt->aSub[nWhich].pMagic; }
193 
194     inline const Size &GetSize( sal_uInt8 nWhich ) const
195         { return aSub[nWhich].aSize; }
196     inline sal_Bool IsFntChg() const { return bFntChg; }
197     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     inline void SetUnderColor( const Color &rColor ) { aUnderColor = rColor; }
205     inline void SetOverline( const FontUnderline eOverline );
206     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     inline sal_Bool IsBlink() const { return bBlink; }
240     inline sal_uInt8 &GetTox() { return nToxCnt; }
241     inline sal_uInt8 GetTox() const { return nToxCnt; }
242     inline sal_Bool IsTox() const { return ( 0 != nToxCnt ); }
243     inline sal_uInt8 &GetRef() { return nRefCnt; }
244     inline sal_uInt8 GetRef() const { return nRefCnt; }
245     inline sal_Bool IsRef() const { return ( 0 != nRefCnt ); }
246     inline sal_uInt8 &GetMeta() { return m_nMetaCount; }
247     inline sal_uInt8 GetMeta() const { return m_nMetaCount; }
248     inline bool IsMeta() const { return (0 != m_nMetaCount); }
249     inline void SetURL( const sal_Bool bURL );
250     inline sal_Bool IsURL() const { return bURL; }
251     inline void SetGreyWave( const sal_Bool bNew );
252     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     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     inline const SvxFont &GetFnt( const sal_uInt8 nWhich ) const
266         { return aSub[nWhich]; };
267 
268     sal_Bool IsSymbol( ViewShell *pSh )
269         { return aSub[nActual].IsSymbol( pSh ); }
270     FontUnderline GetUnderline() const { return aSub[nActual].GetUnderline(); }
271     const Color& GetUnderColor() const { return aUnderColor; }
272     FontUnderline GetOverline() const { return aSub[nActual].GetOverline(); }
273     const Color& GetOverColor() const { return aOverColor; }
274     short GetFixKerning() const { return aSub[nActual].GetFixKerning(); }
275     FontStrikeout GetStrikeout() const { return aSub[nActual].GetStrikeout(); }
276     const Color& GetColor() const { return aSub[nActual].GetColor(); }
277     sal_Bool IsShadow() const { return aSub[nActual].IsShadow(); }
278     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     short GetEscapement() const { return aSub[nActual].GetEscapement(); }
282     SvxCaseMap GetCaseMap() const { return aSub[nActual].GetCaseMap(); }
283     sal_uInt8 GetPropr() const { return aSub[nActual].GetPropr(); }
284     FontItalic GetItalic() const { return aSub[nActual].GetItalic(); }
285     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     long GetHeight() const { return aSub[nActual].GetSize().Height(); }
293     FontWeight GetWeight() const { return aSub[nActual].GetWeight(); }
294     FontEmphasisMark GetEmphasisMark() const
295         { 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     inline const XubString& GetName( const sal_uInt8 nWhich ) const
300         { return aSub[nWhich].GetName(); }
301     inline LanguageType GetLanguage( const sal_uInt8 nWhich ) const
302         { 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     inline rtl_TextEncoding GetCharSet( const sal_uInt8 nWhich ) const
312         { return aSub[nWhich].GetCharSet(); }
313     inline long GetHeight( const sal_uInt8 nWhich ) const
314         { 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     void DoOnCapitals( SwDoCapitals &rDo )
341         { aSub[nActual].DoOnCapitals( rDo ); }
342 
343     Size _GetTxtSize( SwDrawTextInfo& rInf )
344         { rInf.SetFont( this ); return aSub[nActual]._GetTxtSize( rInf ); }
345 
346     xub_StrLen GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth );
347 
348     xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf )
349         { return aSub[nActual]._GetCrsrOfst( rInf ); }
350 
351     inline void _DrawText( SwDrawTextInfo &rInf )
352         { aSub[nActual]._DrawText( rInf, IsGreyWave() ); }
353 
354     inline void _DrawStretchText( SwDrawTextInfo &rInf )
355         { aSub[nActual]._DrawStretchText( rInf ); }
356 
357     inline short CheckKerning()
358         { return aSub[nActual].CheckKerning(); }
359 
360     inline sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut )
361         { return aSub[nActual].GetAscent( pSh, rOut ); }
362     inline sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut )
363         { return aSub[nActual].GetHeight( pSh, rOut ); }
364 
365     inline void Invalidate()
366         { bFntChg = bOrgChg = sal_True; }
367 };
368 
369 inline void SwFont::SetColor( const Color& rColor )
370 {
371     bFntChg = sal_True;
372     aSub[0].SetColor( rColor );
373     aSub[1].SetColor( rColor );
374     aSub[2].SetColor( rColor );
375 }
376 
377 // gekapselte SV-Font-Methode
378 inline void SwSubFont::SetColor( const Color& rColor )
379 {
380     pMagic = 0;
381     Font::SetColor( rColor );
382 }
383 
384 
385 // gekapselte SV-Font-Methode
386 inline void SwSubFont::SetFillColor( const Color& rColor )
387 {
388     pMagic = 0;
389     Font::SetFillColor( rColor );
390 }
391 
392 inline void SwFont::SetFillColor( const Color& rColor )
393 {
394     bFntChg = sal_True;
395     aSub[0].SetFillColor( rColor );
396     aSub[1].SetFillColor( rColor );
397     aSub[2].SetFillColor( rColor );
398 }
399 
400 // gekapselte SV-Font-Methode
401 inline void SwSubFont::SetFamily( const FontFamily eFamily )
402 {
403     pMagic = 0;
404     Font::SetFamily( eFamily );
405 }
406 
407 inline void SwFont::SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich )
408 {
409     bFntChg = sal_True;
410     aSub[nWhich].SetFamily( eFamily );
411 }
412 
413 // gekapselte SV-Font-Methode
414 inline void SwSubFont::SetName( const XubString& rName )
415 {
416     pMagic = 0;
417     Font::SetName( rName );
418 }
419 
420 inline void SwFont::SetName( const XubString& rName, const sal_uInt8 nWhich )
421 {
422     bFntChg = sal_True;
423     aSub[nWhich].SetName( rName );
424 }
425 
426 // gekapselte SV-Font-Methode
427 inline void SwSubFont::SetStyleName( const XubString& rStyleName )
428 {
429     pMagic = 0;
430     Font::SetStyleName( rStyleName );
431 }
432 
433 inline void SwFont::SetStyleName( const XubString& rStyle, const sal_uInt8 nWhich )
434 {
435     bFntChg = sal_True;
436     aSub[nWhich].SetStyleName( rStyle );
437 }
438 
439 // gekapselte SV-Font-Methode
440 inline void SwSubFont::SetCharSet( const CharSet eCharSet )
441 {
442     pMagic = 0;
443     Font::SetCharSet( eCharSet );
444 }
445 
446 inline void SwFont::SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich )
447 {
448     bFntChg = sal_True;
449     aSub[nWhich].SetCharSet( eCharSet );
450 }
451 
452 // gekapselte SV-Font-Methode
453 inline void SwSubFont::SetPitch( const FontPitch ePitch )
454 {
455     pMagic = 0;
456     Font::SetPitch( ePitch );
457 }
458 
459 // gekapselte SV-Font-Methode
460 inline void SwFont::SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich )
461 {
462     bFntChg = sal_True;
463     aSub[nWhich].SetPitch( ePitch );
464 }
465 
466 // gekapselte SV-Font-Methode
467 inline void SwSubFont::SetAlign( const FontAlign eAlign )
468 {
469     pMagic = 0;
470     Font::SetAlign( eAlign );
471 }
472 
473 inline void SwFont::SetAlign( const FontAlign eAlign )
474 {
475     bFntChg = sal_True;
476     aSub[0].SetAlign( eAlign );
477     aSub[1].SetAlign( eAlign );
478     aSub[2].SetAlign( eAlign );
479 }
480 
481 // gekapselte SV-Font-Methode
482 inline void SwSubFont::SetWeight( const FontWeight eWeight )
483 {
484     pMagic = 0;
485     Font::SetWeight( eWeight );
486 }
487 
488 inline void SwFont::SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich )
489 {
490     bFntChg = sal_True;
491     aSub[nWhich].SetWeight( eWeight );
492 }
493 
494 // gekapselte SV-Font-Methode
495 inline void SwSubFont::SetUnderline( const FontUnderline eUnderline )
496 {
497     pMagic = 0;
498     Font::SetUnderline( eUnderline );
499 }
500 
501 inline void SwFont::SetUnderline( const FontUnderline eUnderline )
502 {
503     bFntChg = sal_True;
504     aSub[0].SetUnderline( eUnderline );
505     aSub[1].SetUnderline( eUnderline );
506     aSub[2].SetUnderline( eUnderline );
507 }
508 
509 // gekapselte SV-Font-Methode
510 inline void SwSubFont::SetOverline( const FontUnderline eOverline )
511 {
512     pMagic = 0;
513     Font::SetOverline( eOverline );
514 }
515 
516 inline void SwFont::SetOverline( const FontUnderline eOverline )
517 {
518     bFntChg = sal_True;
519     aSub[0].SetOverline( eOverline );
520     aSub[1].SetOverline( eOverline );
521     aSub[2].SetOverline( eOverline );
522 }
523 
524 // gekapselte SV-Font-Methode
525 inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout )
526 {
527     pMagic = 0;
528     Font::SetStrikeout( eStrikeout );
529 }
530 
531 inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout )
532 {
533     bFntChg = sal_True;
534     aSub[0].SetStrikeout( eStrikeout );
535     aSub[1].SetStrikeout( eStrikeout );
536     aSub[2].SetStrikeout( eStrikeout );
537 }
538 
539 // gekapselte SV-Font-Methode
540 inline void SwSubFont::SetItalic( const FontItalic eItalic )
541 {
542     pMagic = 0;
543     Font::SetItalic( eItalic );
544 }
545 
546 inline void SwFont::SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich )
547 {
548     bFntChg = sal_True;
549     aSub[nWhich].SetItalic( eItalic );
550 }
551 
552 // gekapselte SV-Font-Methode
553 inline void SwSubFont::SetOutline( const sal_Bool bOutline )
554 {
555     pMagic = 0;
556     Font::SetOutline( bOutline );
557 }
558 
559 inline void SwFont::SetOutline( const sal_Bool bOutline )
560 {
561     bFntChg = sal_True;
562     aSub[0].SetOutline( bOutline );
563     aSub[1].SetOutline( bOutline );
564     aSub[2].SetOutline( bOutline );
565 }
566 
567 // gekapselte SV-Font-Methode
568 inline void SwSubFont::SetShadow( const sal_Bool bShadow )
569 {
570     pMagic = 0;
571     Font::SetShadow( bShadow );
572 }
573 
574 inline void SwFont::SetShadow( const sal_Bool bShadow )
575 {
576     bFntChg = sal_True;
577     aSub[0].SetShadow( bShadow );
578     aSub[1].SetShadow( bShadow );
579     aSub[2].SetShadow( bShadow );
580 }
581 
582 // gekapselte SV-Font-Methode
583 inline void SwSubFont::SetAutoKern( const sal_uInt8 nAutoKern )
584 {
585     pMagic = 0;
586     Font::SetKerning( nAutoKern );
587 }
588 
589 inline void SwFont::SetAutoKern( sal_uInt8 nAutoKern )
590 {
591     bFntChg = sal_True;
592     aSub[1].SetAutoKern( nAutoKern );
593     if( nAutoKern )
594         nAutoKern = KERNING_FONTSPECIFIC;
595     aSub[0].SetAutoKern( nAutoKern );
596     aSub[2].SetAutoKern( nAutoKern );
597 }
598 
599 inline void SwFont::SetTransparent( const sal_Bool bTrans )
600 {
601     aSub[0].SetTransparent( bTrans );
602     aSub[1].SetTransparent( bTrans );
603     aSub[2].SetTransparent( bTrans );
604 }
605 
606 inline void SwFont::SetFixKerning( const short nNewKern )
607 {
608     aSub[SW_LATIN].SetFixKerning( nNewKern );
609     aSub[SW_CJK].SetFixKerning( nNewKern );
610     aSub[SW_CTL].SetFixKerning( nNewKern );
611 }
612 
613 inline void SwFont::SetCaseMap( const SvxCaseMap eNew )
614 {
615     aSub[SW_LATIN].SetCaseMap( eNew );
616     aSub[SW_CJK].SetCaseMap( eNew );
617     aSub[SW_CTL].SetCaseMap( eNew );
618 }
619 
620 // gekapselte SV-Font-Methode
621 inline void SwSubFont::SetWordLineMode( const sal_Bool bWordLineMode )
622 {
623     pMagic = 0;
624     Font::SetWordLineMode( bWordLineMode );
625 }
626 
627 inline void SwFont::SetWordLineMode( const sal_Bool bWordLineMode )
628 {
629     bFntChg = sal_True;
630     aSub[0].SetWordLineMode( bWordLineMode );
631     aSub[1].SetWordLineMode( bWordLineMode );
632     aSub[2].SetWordLineMode( bWordLineMode );
633 }
634 // gekapselte SV-Font-Methode
635 inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue )
636 {
637     pMagic = 0;
638     Font::SetEmphasisMark( eValue );
639 }
640 
641 inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue )
642 {
643     bFntChg = sal_True;
644     aSub[0].SetEmphasisMark( eValue );
645     aSub[1].SetEmphasisMark( eValue );
646     aSub[2].SetEmphasisMark( eValue );
647 }
648 
649 inline void SwFont::SetPropWidth( const sal_uInt16 nNew )
650 {
651     if( nNew != aSub[0].GetPropWidth() )
652     {
653         bFntChg = sal_True;
654         aSub[0].SetPropWidth( nNew );
655         aSub[1].SetPropWidth( nNew );
656         aSub[2].SetPropWidth( nNew );
657     }
658 }
659 
660 // gekapselte SV-Font-Methode
661 inline void SwSubFont::SetRelief( const FontRelief eNew )
662 {
663     pMagic = 0;
664     Font::SetRelief( eNew );
665 }
666 
667 inline void SwFont::SetRelief( const FontRelief eNew )
668 {
669     if( eNew != aSub[0].GetRelief() )
670     {
671         bFntChg = sal_True;
672         aSub[0].SetRelief( eNew );
673         aSub[1].SetRelief( eNew );
674         aSub[2].SetRelief( eNew );
675     }
676 }
677 
678 // ueberladene Font-Methode
679 inline void SwSubFont::SetSize( const Size& rSize )
680 {
681     aSize = rSize;
682     if ( GetPropr() == 100 )
683         Font::SetSize( aSize );
684     else
685     {
686         Font::SetSize( Size(
687             (long) aSize.Width() * GetPropr() / 100L,
688             (long) aSize.Height() * GetPropr() / 100L ) );
689     }
690     pMagic = 0;
691 }
692 
693 inline void SwFont::SetSize( const Size& rSize, const sal_uInt8 nWhich )
694 {
695     if( aSub[nWhich].aSize != rSize )
696     {
697         aSub[nWhich].SetSize( rSize );
698         bFntChg = sal_True;
699         bOrgChg = sal_True;
700     }
701 }
702 
703 inline void SwFont::SetActual( sal_uInt8 nNew )
704 {
705      if ( nActual != nNew )
706      {
707         bFntChg = sal_True;
708         bOrgChg = sal_True;
709         nActual = nNew;
710      }
711 }
712 
713 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
714 {
715     pMagic = 0;
716     Font::SetSize( Size( (long) aSize.Width() * nNewPropr / 100L,
717                          (long) aSize.Height() * nNewPropr / 100L ) );
718     SvxFont::SetPropr( nNewPropr );
719 }
720 
721 inline void SwFont::SetProportion( const sal_uInt8 nNewPropr )
722 {
723     if( nNewPropr != aSub[0].GetPropr() )
724     {
725         bFntChg = sal_True;
726         bOrgChg = sal_True;
727 
728         aSub[0].SetProportion( nNewPropr );
729         aSub[1].SetProportion( nNewPropr );
730         aSub[2].SetProportion( nNewPropr );
731     }
732 }
733 
734 inline void SwSubFont::SetEscapement( const short nNewEsc )
735 {
736     pMagic = 0;
737     SvxFont::SetEscapement( nNewEsc );
738 }
739 
740 inline void SwFont::SetEscapement( const short nNewEsc )
741 {
742     if( nNewEsc != aSub[0].GetEscapement() )
743     {
744         // these have to be set, otherwise nOrgHeight and nOrgAscent will not
745         // be calculated
746         bFntChg = sal_True;
747         bOrgChg = sal_True;
748 
749         aSub[0].SetEscapement( nNewEsc );
750         aSub[1].SetEscapement( nNewEsc );
751         aSub[2].SetEscapement( nNewEsc );
752     }
753 }
754 
755 inline void SwSubFont::SetLanguage( LanguageType eNewLang )
756 {
757     if( eNewLang == LANGUAGE_SYSTEM )
758         eNewLang = (LanguageType)GetAppLanguage();
759     SvxFont::SetLanguage( eNewLang );
760 }
761 
762 inline void SwFont::SetLanguage( const LanguageType eNewLang, const sal_uInt8 nWhich )
763 {
764     aSub[nWhich].SetLanguage( eNewLang );
765     if( SW_CJK == nWhich )
766     {
767         aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
768         aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
769         aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
770     }
771 }
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 inline void SwFont::SetNoHyph( const sal_Bool bNew )
784 {
785     bNoHyph = bNew;
786 }
787 
788 inline void SwFont::SetBlink( const sal_Bool bNew )
789 {
790     bBlink = bNew;
791 }
792 
793 inline void SwFont::SetURL( const sal_Bool bNew )
794 {
795     bURL = bNew;
796 }
797 
798 inline void SwFont::SetGreyWave( const sal_Bool bNew )
799 {
800     bGreyWave = bNew;
801 }
802 
803 inline void SwFont::SetNoCol( const sal_Bool bNew )
804 {
805     bNoColReplace = bNew;
806 }
807 
808 inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat )
809 {
810     pMagic = 0;
811     Font::SetVertical( bVertFormat );
812     Font::SetOrientation( nDir );
813 }
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     SwFont& GetFont()
834     {
835         ASSERT( pFnt, "No underline font" )
836         return *pFnt;
837     }
838     const Point& GetPos() const { return aPos; }
839     // the x coordinate of the starting point has to be set for each portion
840     void SetPos( const Point& rPoint ) { aPos = rPoint;  }
841 };
842 
843 
844 /*************************************************************************
845  *                      class SvStatistics
846  *************************************************************************/
847 
848 #ifndef DBG_UTIL
849 #define SV_STAT(nWhich)
850 #else
851 
852 class SvStatistics
853 {
854 public:
855     sal_uInt16 nGetTextSize;
856     sal_uInt16 nDrawText;
857     sal_uInt16 nGetStretchTextSize;
858     sal_uInt16 nDrawStretchText;
859     sal_uInt16 nChangeFont;
860     sal_uInt16 nGetFontMetric;
861 
862     inline void Reset()
863     {
864         nGetTextSize = nDrawText = nGetStretchTextSize =
865         nDrawStretchText = nChangeFont = nGetFontMetric = 0;
866     }
867 
868     inline SvStatistics() { Reset(); }
869 
870     inline void PrintOn( SvStream &rOS ) const; //$ ostream
871     inline sal_Bool IsEmpty() const
872     {
873         return !( nGetTextSize || nDrawText ||
874                   nDrawStretchText || nChangeFont || nGetFontMetric );
875     }
876 };
877 
878 // globale Variable, implementiert in swfont.cxx
879 extern SvStatistics aSvStat;
880 
881 #define SV_STAT(nWhich) ++(aSvStat.nWhich);
882 
883 inline void SvStatistics::PrintOn( SvStream &rOS ) const //$ ostream
884 {
885     if( IsEmpty() )
886         return;
887 
888     rOS << "{   SV called:" << '\n';
889     if( nGetTextSize )
890         rOS << "\tnGetTextSize: " <<    nGetTextSize    << '\n';        if( nDrawText   )
891         rOS << "\tnDrawText: "  << nDrawText    << '\n';        if( nGetStretchTextSize )
892         rOS << "\tnGetStretchTextSize: "    << nGetStretchTextSize  << '\n';        if( nDrawStretchText    )
893         rOS << "\tnDrawStretchText: "   << nDrawStretchText << '\n';        if( nChangeFont )
894         rOS << "\tnChangeFont: "    << nChangeFont  << '\n';        if( nGetFontMetric  )
895         rOS << "\tnGetFontMetric: " << nGetFontMetric   << '\n';        rOS << "}"  << '\n';    }
896 #endif  /*  PRODUCT */
897 
898 #endif
899 
900