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