xref: /trunk/main/sw/source/core/inc/swfont.hxx (revision cea84f56765a2ac06f0f5a2718f45f6430edc781) !
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
SwSubFont()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 
CopyMagic(const SwSubFont & rFnt)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 public:
72     SwSubFont(const SwSubFont&) = default;
73 private:
74 
75     short _CheckKerning( );
76 
77     sal_Bool ChgFnt( ViewShell *pSh, OutputDevice& rOut );
78     sal_Bool IsSymbol( ViewShell *pSh );
79     sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut );
80     sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut );
81     Size _GetTxtSize( SwDrawTextInfo& rInf );
82     Size GetCapitalSize( SwDrawTextInfo& rInf );
83     void _DrawText( SwDrawTextInfo &rInf, const sal_Bool bGrey );
84     void DrawCapital( SwDrawTextInfo &rInf );
85     void DrawStretchCapital( SwDrawTextInfo &rInf );
86     void DoOnCapitals( SwDoCapitals &rDo );
87     void _DrawStretchText( SwDrawTextInfo &rInf );
88     xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf );
89     xub_StrLen GetCapitalCrsrOfst( SwDrawTextInfo& rInf );
90 
91     inline void SetColor( const Color& rColor );
92     inline void SetFillColor( const Color& rColor );
93     inline void SetCharSet( const CharSet eCharSet );
94     inline void SetPitch( const FontPitch ePitch );
95     inline void SetAlign( const FontAlign eAlign );
96     inline void SetUnderline( const FontUnderline eUnderline );
97     inline void SetOverline( const FontUnderline eOverline );
98     inline void SetStrikeout( const FontStrikeout eStrikeout );
99     inline void SetItalic( const FontItalic eItalic );
100     inline void SetOutline( const sal_Bool bOutline );
101     inline void SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat );
102     inline void SetShadow( const sal_Bool bShadow );
103     inline void SetAutoKern( const sal_uInt8 nAutoKern );
104     inline void SetWordLineMode( const sal_Bool bWordLineMode );
105     inline void SetEmphasisMark( const FontEmphasisMark eValue );
106     inline void SetRelief( const FontRelief eNew );
107 
108     // Methoden fuer die Hoch-/Tiefstellung
109     inline void SetEscapement( const short nNewEsc );
110     inline void SetProportion( const sal_uInt8 nNewPropr );
111 
112     inline void SetFamily( const FontFamily eFamily );
113     inline void SetName( const XubString& rName );
114     inline void SetStyleName( const XubString& rStyleName );
115     inline void SetSize( const Size& rSize );
116     inline void SetWeight( const FontWeight eWeight );
117     inline void SetLanguage( LanguageType eNewLang );
CheckKerning()118     inline short CheckKerning()
119     {   return GetFixKerning() >= 0 ? GetFixKerning() : _CheckKerning( ); }
SetPropWidth(const sal_uInt16 nNew)120     inline void SetPropWidth( const sal_uInt16 nNew )
121         { pMagic = 0; nPropWidth = nNew; }
122 public:
GetPropWidth() const123     sal_uInt16 GetPropWidth() const { return nPropWidth; }
124 };
125 
126 #define SW_LATIN 0
127 #define SW_CJK 1
128 #define SW_CTL 2
129 #define SW_SCRIPTS 3
130 
131 class SwFont
132 {   // CJK == Chinese, Japanese, Korean
133     // CTL == Complex text layout ( Hebrew, Arabic )
134     SwSubFont aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font
135 
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 
140     sal_uInt8   nToxCnt;        // Zaehlt die Schachtelungstiefe der Tox
141     sal_uInt8   nRefCnt;        // Zaehlt die Schachtelungstiefe der Refs
142     sal_uInt8   m_nMetaCount;   // count META/METAFIELD
143     sal_uInt8   m_nInputFieldCount; // count INPUTFIELD
144 
145         sal_uInt8   nActual;        // actual font (Latin, CJK or CTL)
146 
147     // Schalter fuer die Font-Extensions
148     sal_Bool bNoHyph        :1;  // SwTxtNoHyphenHere:    keine Trennstelle
149     sal_Bool bBlink         :1;  // blinkender Font
150     sal_Bool bPaintBlank    :1;  // Blanks nicht mit DrawRect
151     sal_Bool bFntChg        :1;
152     sal_Bool bOrgChg        :1;  // nOrgHeight/Ascent sind invalid
153     sal_Bool bURL           :1;
154     sal_Bool bPaintWrong    :1;  // Flag fuer Rechtschreibfehler
155     sal_Bool bGreyWave      :1;  // Fuers extended TextInput: Graue Wellenlinie
156     sal_Bool bNoColReplace  :1;  // Replacement without colormanipulation
157 
158     sal_Bool operator==( const SwFont &rFnt ) const;
159 
160 protected:
SwFont()161     inline SwFont() { pBackColor = NULL; nActual = SW_LATIN; }
162 
163 public:
164     SwFont( const SwAttrSet* pSet, const IDocumentSettingAccess* pIDocumentSettingAccess );
165     SwFont( const SwFont& rFont );
166 
ChgFnt(ViewShell * pSh,OutputDevice & rOut)167     inline void ChgFnt( ViewShell *pSh, OutputDevice& rOut )
168         { bPaintBlank = aSub[nActual].ChgFnt( pSh, rOut ); }
169 
~SwFont()170     ~SwFont(){ delete pBackColor; }
171 
172     SwFont& operator=( const SwFont &rFont );
173 
GetActual() const174     inline sal_uInt8 GetActual() const {    return nActual; }
175     inline void SetActual( sal_uInt8 nNew );
GetActualFont() const176     inline const SvxFont& GetActualFont() const { return aSub[nActual]; }
177 
178     // holt sich eine MagicNumber ueber SwFntAccess
179     void GoMagic( ViewShell *pSh, sal_uInt8 nWhich );
180     // set background color
181     void SetBackColor( Color* pNewColor );
GetBackColor() const182     inline const Color* GetBackColor() const{ return pBackColor; }
183 
ChkMagic(ViewShell * pSh,sal_uInt8 nWhich)184     inline void ChkMagic( ViewShell *pSh, sal_uInt8 nWhich )
185         { if( !aSub[ nWhich ].pMagic ) GoMagic( pSh, nWhich ); }
186     // uebernimmt die MagicNumber eines (hoffentlich ident.) Kollegen
CopyMagic(const SwFont * pFnt,sal_uInt8 nWhich)187     inline void CopyMagic( const SwFont* pFnt, sal_uInt8 nWhich )
188         { aSub[nWhich].CopyMagic( pFnt->aSub[nWhich] ); }
GetMagic(const void * & rMagic,sal_uInt16 & rIdx,sal_uInt8 nWhich)189     inline void GetMagic( const void* &rMagic, sal_uInt16 &rIdx, sal_uInt8 nWhich )
190         { rMagic = aSub[nWhich].pMagic; rIdx = aSub[nWhich].nFntIndex; }
SetMagic(const void * pNew,const sal_uInt16 nIdx,sal_uInt8 nWhich)191     inline void SetMagic( const void* pNew, const sal_uInt16 nIdx, sal_uInt8 nWhich )
192         { aSub[nWhich].pMagic = pNew; aSub[nWhich].nFntIndex = nIdx; }
DifferentMagic(const SwFont * pFnt,sal_uInt8 nWhich)193     inline sal_Bool DifferentMagic( const SwFont* pFnt, sal_uInt8 nWhich )
194         { return aSub[nWhich].pMagic != pFnt->aSub[nWhich].pMagic ||
195           !aSub[nWhich].pMagic || !pFnt->aSub[nWhich].pMagic; }
196 
GetSize(sal_uInt8 nWhich) const197     inline const Size &GetSize( sal_uInt8 nWhich ) const
198         { return aSub[nWhich].aSize; }
IsFntChg() const199     inline sal_Bool IsFntChg() const { return bFntChg; }
SetFntChg(const sal_Bool bNew)200     inline void SetFntChg( const sal_Bool bNew ) { bFntChg = bNew; }
201 
202     // die gekapselten SV-Font-Methoden (setzen bFntChg auf sal_True)
203     inline void SetColor( const Color& rColor );
204     inline void SetFillColor( const Color& rColor );
205     inline void SetAlign( const FontAlign eAlign );
206     inline void SetUnderline( const FontUnderline eUnderline );
SetUnderColor(const Color & rColor)207     inline void SetUnderColor( const Color &rColor ) { aUnderColor = rColor; }
208     inline void SetOverline( const FontUnderline eOverline );
SetOverColor(const Color & rColor)209     inline void SetOverColor( const Color &rColor ) { aOverColor = rColor; }
210     inline void SetStrikeout( const FontStrikeout eStrikeout );
211     inline void SetOutline( const sal_Bool bOutline );
212            void SetVertical( sal_uInt16 nDir, const sal_Bool nVertLayout = sal_False );
213     inline void SetShadow( const sal_Bool bShadow );
214     inline void SetAutoKern( sal_uInt8 nAutoKern );
215     inline void SetTransparent( const sal_Bool bTrans );
216     inline void SetWordLineMode( const sal_Bool bWordLineMode );
217     inline void SetFixKerning( const short nNewKern );
218     inline void SetCaseMap( const SvxCaseMap eNew );
219     inline void SetEmphasisMark( const FontEmphasisMark eValue );
220 
221     // Methoden fuer die Hoch-/Tiefstellung
222     inline void SetEscapement( const short nNewEsc );
223     inline void SetProportion( const sal_uInt8 nNewPropr );
224 
225     inline void SetPropWidth( const sal_uInt16 nNew );
226 
227     inline void SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich );
228     inline void SetName( const XubString& rName, const sal_uInt8 nWhich );
229     inline void SetStyleName( const XubString& rStyleName, const sal_uInt8 nWhich );
230     inline void SetSize( const Size& rSize, const sal_uInt8 nWhich );
231     inline void SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich );
232     inline void SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich );
233     inline void SetLanguage( LanguageType eNewLang, const sal_uInt8 nWhich );
234     inline void SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich );
235     inline void SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich );
236     inline void SetRelief( const FontRelief eNew );
237 
238     // Get/Set-Methoden fuer die aktuelle Einstellung
239     inline void SetNoHyph( const sal_Bool bNew );
IsNoHyph() const240     inline sal_Bool IsNoHyph() const { return bNoHyph; }
241     inline void SetBlink( const sal_Bool bBlink );
IsBlink() const242     inline sal_Bool IsBlink() const { return bBlink; }
GetTox()243     inline sal_uInt8 &GetTox() { return nToxCnt; }
GetTox() const244     inline sal_uInt8 GetTox() const { return nToxCnt; }
IsTox() const245     inline sal_Bool IsTox() const { return ( 0 != nToxCnt ); }
GetRef()246     inline sal_uInt8 &GetRef() { return nRefCnt; }
GetRef() const247     inline sal_uInt8 GetRef() const { return nRefCnt; }
IsRef() const248     inline sal_Bool IsRef() const { return ( 0 != nRefCnt ); }
GetMeta()249     inline sal_uInt8 &GetMeta() { return m_nMetaCount; }
GetMeta() const250     inline sal_uInt8 GetMeta() const { return m_nMetaCount; }
IsMeta() const251     inline bool IsMeta() const { return (0 != m_nMetaCount); }
GetInputField()252     inline sal_uInt8 &GetInputField() { return m_nInputFieldCount; }
GetInputField() const253     inline sal_uInt8 GetInputField() const { return m_nInputFieldCount; }
IsInputField() const254     inline bool IsInputField() const { return (0 != m_nInputFieldCount); }
255     inline void SetURL( const sal_Bool bURL );
IsURL() const256     inline sal_Bool IsURL() const { return bURL; }
257     inline void SetGreyWave( const sal_Bool bNew );
IsGreyWave() const258     inline sal_Bool IsGreyWave() const { return bGreyWave; }
259     inline void SetNoCol( const sal_Bool bNew );
IsNoCol() const260     inline sal_Bool IsNoCol() const { return bNoColReplace; }
261 
262     inline void SetPaintBlank( const sal_Bool bNew );
IsPaintBlank() const263     inline sal_Bool IsPaintBlank() const { return bPaintBlank; }
264     inline void SetPaintWrong( const sal_Bool bNew );
IsPaintWrong() const265     inline sal_Bool IsPaintWrong() const { return bPaintWrong; }
266 
267     // Setzen der Basisklasse Font fuer SwTxtCharFmt
268     void SetDiffFnt( const SfxItemSet* pSet,
269                      const IDocumentSettingAccess* pIDocumentSettingAccess );
270 
GetFnt(const sal_uInt8 nWhich) const271     inline const SvxFont &GetFnt( const sal_uInt8 nWhich ) const
272         { return aSub[nWhich]; };
273 
IsSymbol(ViewShell * pSh)274     sal_Bool IsSymbol( ViewShell *pSh )
275         { return aSub[nActual].IsSymbol( pSh ); }
GetUnderline() const276     FontUnderline GetUnderline() const { return aSub[nActual].GetUnderline(); }
GetUnderColor() const277     const Color& GetUnderColor() const { return aUnderColor; }
GetOverline() const278     FontUnderline GetOverline() const { return aSub[nActual].GetOverline(); }
GetOverColor() const279     const Color& GetOverColor() const { return aOverColor; }
GetFixKerning() const280     short GetFixKerning() const { return aSub[nActual].GetFixKerning(); }
GetStrikeout() const281     FontStrikeout GetStrikeout() const { return aSub[nActual].GetStrikeout(); }
GetColor() const282     const Color& GetColor() const { return aSub[nActual].GetColor(); }
IsShadow() const283     sal_Bool IsShadow() const { return aSub[nActual].IsShadow(); }
IsWordLineMode() const284     sal_Bool IsWordLineMode() const { return aSub[nActual].IsWordLineMode(); }
IsOutline() const285     sal_Bool IsOutline() const { return aSub[nActual].IsOutline(); }
IsKerning() const286     sal_Bool IsKerning() const { return aSub[nActual].IsKerning(); }
GetEscapement() const287     short GetEscapement() const { return aSub[nActual].GetEscapement(); }
GetCaseMap() const288     SvxCaseMap GetCaseMap() const { return aSub[nActual].GetCaseMap(); }
GetPropr() const289     sal_uInt8 GetPropr() const { return aSub[nActual].GetPropr(); }
GetItalic() const290     FontItalic GetItalic() const { return aSub[nActual].GetItalic(); }
GetLanguage() const291     LanguageType GetLanguage() const { return aSub[nActual].GetLanguage(); }
GetAlign() const292     FontAlign GetAlign() const { return aSub[nActual].GetAlign(); }
GetName() const293     const XubString& GetName() const { return aSub[nActual].GetName(); }
GetStyleName() const294     const XubString& GetStyleName() const {return aSub[nActual].GetStyleName();}
GetFamily() const295     FontFamily GetFamily() const { return aSub[nActual].GetFamily(); }
GetPitch() const296     FontPitch GetPitch() const { return aSub[nActual].GetPitch(); }
GetCharSet() const297     rtl_TextEncoding GetCharSet() const { return aSub[nActual].GetCharSet(); }
GetHeight() const298     long GetHeight() const { return aSub[nActual].GetSize().Height(); }
GetWeight() const299     FontWeight GetWeight() const { return aSub[nActual].GetWeight(); }
GetEmphasisMark() const300     FontEmphasisMark GetEmphasisMark() const
301         { return aSub[nActual].GetEmphasisMark(); }
GetPropWidth() const302     sal_uInt16 GetPropWidth() const { return aSub[nActual].GetPropWidth(); }
303     sal_uInt16 GetOrientation( const sal_Bool nVertLayout = sal_False ) const;
304 
GetName(const sal_uInt8 nWhich) const305     inline const XubString& GetName( const sal_uInt8 nWhich ) const
306         { return aSub[nWhich].GetName(); }
GetLanguage(const sal_uInt8 nWhich) const307     inline LanguageType GetLanguage( const sal_uInt8 nWhich ) const
308         { return aSub[nWhich].GetLanguage(); }
GetStyleName(const sal_uInt8 nWhich) const309     inline const XubString& GetStyleName( const sal_uInt8 nWhich ) const
310         { return aSub[nWhich].GetStyleName(); }
GetFamily(const sal_uInt8 nWhich) const311     inline FontFamily GetFamily( const sal_uInt8 nWhich ) const
312         { return aSub[nWhich].GetFamily(); }
GetItalic(const sal_uInt8 nWhich) const313     inline FontItalic GetItalic( const sal_uInt8 nWhich ) const
314         { return aSub[nWhich].GetItalic(); }
GetPitch(const sal_uInt8 nWhich) const315     inline FontPitch GetPitch( const sal_uInt8 nWhich ) const
316         { return aSub[nWhich].GetPitch(); }
GetCharSet(const sal_uInt8 nWhich) const317     inline rtl_TextEncoding GetCharSet( const sal_uInt8 nWhich ) const
318         { return aSub[nWhich].GetCharSet(); }
GetHeight(const sal_uInt8 nWhich) const319     inline long GetHeight( const sal_uInt8 nWhich ) const
320         { return aSub[nWhich].GetSize().Height(); }
GetWeight(const sal_uInt8 nWhich) const321     inline FontWeight GetWeight( const sal_uInt8 nWhich ) const
322         { return aSub[nWhich].GetWeight(); }
GetEmphasisMark(const sal_uInt8 nWhich) const323     inline FontEmphasisMark GetEmphasisMark( const sal_uInt8 nWhich ) const
324         { return aSub[nWhich].GetEmphasisMark(); }
325 
326     // Macht den logischen Font im OutputDevice wirksam.
327     void ChgPhysFnt( ViewShell *pSh, OutputDevice& rOut );
328 
GetCapitalSize(SwDrawTextInfo & rInf)329     Size GetCapitalSize( SwDrawTextInfo& rInf )
330         { return aSub[nActual].GetCapitalSize( rInf ); }
331 
332     xub_StrLen GetCapitalBreak( ViewShell* pSh,  const OutputDevice* pOut,
333         const SwScriptInfo* pScript, const XubString& rTxt,
334         long nTextWidth, xub_StrLen* pExtra, const xub_StrLen nIdx,
335         const xub_StrLen nLen );
336 
GetCapitalCrsrOfst(SwDrawTextInfo & rInf)337     xub_StrLen GetCapitalCrsrOfst( SwDrawTextInfo& rInf )
338         { return aSub[nActual].GetCapitalCrsrOfst( rInf ); }
339 
DrawCapital(SwDrawTextInfo & rInf)340     void DrawCapital( SwDrawTextInfo &rInf )
341         { aSub[nActual].DrawCapital( rInf ); }
342 
DrawStretchCapital(SwDrawTextInfo & rInf)343     void DrawStretchCapital( SwDrawTextInfo &rInf )
344         { aSub[nActual].DrawStretchCapital( rInf ); }
345 
DoOnCapitals(SwDoCapitals & rDo)346     void DoOnCapitals( SwDoCapitals &rDo )
347         { aSub[nActual].DoOnCapitals( rDo ); }
348 
_GetTxtSize(SwDrawTextInfo & rInf)349     Size _GetTxtSize( SwDrawTextInfo& rInf )
350         { rInf.SetFont( this ); return aSub[nActual]._GetTxtSize( rInf ); }
351 
352     xub_StrLen GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth );
353 
_GetCrsrOfst(SwDrawTextInfo & rInf)354     xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf )
355         { return aSub[nActual]._GetCrsrOfst( rInf ); }
356 
_DrawText(SwDrawTextInfo & rInf)357     inline void _DrawText( SwDrawTextInfo &rInf )
358         { aSub[nActual]._DrawText( rInf, IsGreyWave() ); }
359 
_DrawStretchText(SwDrawTextInfo & rInf)360     inline void _DrawStretchText( SwDrawTextInfo &rInf )
361         { aSub[nActual]._DrawStretchText( rInf ); }
362 
CheckKerning()363     inline short CheckKerning()
364         { return aSub[nActual].CheckKerning(); }
365 
GetAscent(ViewShell * pSh,const OutputDevice & rOut)366     inline sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut )
367         { return aSub[nActual].GetAscent( pSh, rOut ); }
GetHeight(ViewShell * pSh,const OutputDevice & rOut)368     inline sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut )
369         { return aSub[nActual].GetHeight( pSh, rOut ); }
370 
Invalidate()371     inline void Invalidate()
372         { bFntChg = bOrgChg = sal_True; }
373 };
374 
SetColor(const Color & rColor)375 inline void SwFont::SetColor( const Color& rColor )
376 {
377     bFntChg = sal_True;
378     aSub[0].SetColor( rColor );
379     aSub[1].SetColor( rColor );
380     aSub[2].SetColor( rColor );
381 }
382 
383 // gekapselte SV-Font-Methode
SetColor(const Color & rColor)384 inline void SwSubFont::SetColor( const Color& rColor )
385 {
386     pMagic = 0;
387     Font::SetColor( rColor );
388 }
389 
390 
391 // gekapselte SV-Font-Methode
SetFillColor(const Color & rColor)392 inline void SwSubFont::SetFillColor( const Color& rColor )
393 {
394     pMagic = 0;
395     Font::SetFillColor( rColor );
396 }
397 
SetFillColor(const Color & rColor)398 inline void SwFont::SetFillColor( const Color& rColor )
399 {
400     bFntChg = sal_True;
401     aSub[0].SetFillColor( rColor );
402     aSub[1].SetFillColor( rColor );
403     aSub[2].SetFillColor( rColor );
404 }
405 
406 // gekapselte SV-Font-Methode
SetFamily(const FontFamily eFamily)407 inline void SwSubFont::SetFamily( const FontFamily eFamily )
408 {
409     pMagic = 0;
410     Font::SetFamily( eFamily );
411 }
412 
SetFamily(const FontFamily eFamily,const sal_uInt8 nWhich)413 inline void SwFont::SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich )
414 {
415     bFntChg = sal_True;
416     aSub[nWhich].SetFamily( eFamily );
417 }
418 
419 // gekapselte SV-Font-Methode
SetName(const XubString & rName)420 inline void SwSubFont::SetName( const XubString& rName )
421 {
422     pMagic = 0;
423     Font::SetName( rName );
424 }
425 
SetName(const XubString & rName,const sal_uInt8 nWhich)426 inline void SwFont::SetName( const XubString& rName, const sal_uInt8 nWhich )
427 {
428     bFntChg = sal_True;
429     aSub[nWhich].SetName( rName );
430 }
431 
432 // gekapselte SV-Font-Methode
SetStyleName(const XubString & rStyleName)433 inline void SwSubFont::SetStyleName( const XubString& rStyleName )
434 {
435     pMagic = 0;
436     Font::SetStyleName( rStyleName );
437 }
438 
SetStyleName(const XubString & rStyle,const sal_uInt8 nWhich)439 inline void SwFont::SetStyleName( const XubString& rStyle, const sal_uInt8 nWhich )
440 {
441     bFntChg = sal_True;
442     aSub[nWhich].SetStyleName( rStyle );
443 }
444 
445 // gekapselte SV-Font-Methode
SetCharSet(const CharSet eCharSet)446 inline void SwSubFont::SetCharSet( const CharSet eCharSet )
447 {
448     pMagic = 0;
449     Font::SetCharSet( eCharSet );
450 }
451 
SetCharSet(const CharSet eCharSet,const sal_uInt8 nWhich)452 inline void SwFont::SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich )
453 {
454     bFntChg = sal_True;
455     aSub[nWhich].SetCharSet( eCharSet );
456 }
457 
458 // gekapselte SV-Font-Methode
SetPitch(const FontPitch ePitch)459 inline void SwSubFont::SetPitch( const FontPitch ePitch )
460 {
461     pMagic = 0;
462     Font::SetPitch( ePitch );
463 }
464 
465 // gekapselte SV-Font-Methode
SetPitch(const FontPitch ePitch,const sal_uInt8 nWhich)466 inline void SwFont::SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich )
467 {
468     bFntChg = sal_True;
469     aSub[nWhich].SetPitch( ePitch );
470 }
471 
472 // gekapselte SV-Font-Methode
SetAlign(const FontAlign eAlign)473 inline void SwSubFont::SetAlign( const FontAlign eAlign )
474 {
475     pMagic = 0;
476     Font::SetAlign( eAlign );
477 }
478 
SetAlign(const FontAlign eAlign)479 inline void SwFont::SetAlign( const FontAlign eAlign )
480 {
481     bFntChg = sal_True;
482     aSub[0].SetAlign( eAlign );
483     aSub[1].SetAlign( eAlign );
484     aSub[2].SetAlign( eAlign );
485 }
486 
487 // gekapselte SV-Font-Methode
SetWeight(const FontWeight eWeight)488 inline void SwSubFont::SetWeight( const FontWeight eWeight )
489 {
490     pMagic = 0;
491     Font::SetWeight( eWeight );
492 }
493 
SetWeight(const FontWeight eWeight,const sal_uInt8 nWhich)494 inline void SwFont::SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich )
495 {
496     bFntChg = sal_True;
497     aSub[nWhich].SetWeight( eWeight );
498 }
499 
500 // gekapselte SV-Font-Methode
SetUnderline(const FontUnderline eUnderline)501 inline void SwSubFont::SetUnderline( const FontUnderline eUnderline )
502 {
503     pMagic = 0;
504     Font::SetUnderline( eUnderline );
505 }
506 
SetUnderline(const FontUnderline eUnderline)507 inline void SwFont::SetUnderline( const FontUnderline eUnderline )
508 {
509     bFntChg = sal_True;
510     aSub[0].SetUnderline( eUnderline );
511     aSub[1].SetUnderline( eUnderline );
512     aSub[2].SetUnderline( eUnderline );
513 }
514 
515 // gekapselte SV-Font-Methode
SetOverline(const FontUnderline eOverline)516 inline void SwSubFont::SetOverline( const FontUnderline eOverline )
517 {
518     pMagic = 0;
519     Font::SetOverline( eOverline );
520 }
521 
SetOverline(const FontUnderline eOverline)522 inline void SwFont::SetOverline( const FontUnderline eOverline )
523 {
524     bFntChg = sal_True;
525     aSub[0].SetOverline( eOverline );
526     aSub[1].SetOverline( eOverline );
527     aSub[2].SetOverline( eOverline );
528 }
529 
530 // gekapselte SV-Font-Methode
SetStrikeout(const FontStrikeout eStrikeout)531 inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout )
532 {
533     pMagic = 0;
534     Font::SetStrikeout( eStrikeout );
535 }
536 
SetStrikeout(const FontStrikeout eStrikeout)537 inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout )
538 {
539     bFntChg = sal_True;
540     aSub[0].SetStrikeout( eStrikeout );
541     aSub[1].SetStrikeout( eStrikeout );
542     aSub[2].SetStrikeout( eStrikeout );
543 }
544 
545 // gekapselte SV-Font-Methode
SetItalic(const FontItalic eItalic)546 inline void SwSubFont::SetItalic( const FontItalic eItalic )
547 {
548     pMagic = 0;
549     Font::SetItalic( eItalic );
550 }
551 
SetItalic(const FontItalic eItalic,const sal_uInt8 nWhich)552 inline void SwFont::SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich )
553 {
554     bFntChg = sal_True;
555     aSub[nWhich].SetItalic( eItalic );
556 }
557 
558 // gekapselte SV-Font-Methode
SetOutline(const sal_Bool bOutline)559 inline void SwSubFont::SetOutline( const sal_Bool bOutline )
560 {
561     pMagic = 0;
562     Font::SetOutline( bOutline );
563 }
564 
SetOutline(const sal_Bool bOutline)565 inline void SwFont::SetOutline( const sal_Bool bOutline )
566 {
567     bFntChg = sal_True;
568     aSub[0].SetOutline( bOutline );
569     aSub[1].SetOutline( bOutline );
570     aSub[2].SetOutline( bOutline );
571 }
572 
573 // gekapselte SV-Font-Methode
SetShadow(const sal_Bool bShadow)574 inline void SwSubFont::SetShadow( const sal_Bool bShadow )
575 {
576     pMagic = 0;
577     Font::SetShadow( bShadow );
578 }
579 
SetShadow(const sal_Bool bShadow)580 inline void SwFont::SetShadow( const sal_Bool bShadow )
581 {
582     bFntChg = sal_True;
583     aSub[0].SetShadow( bShadow );
584     aSub[1].SetShadow( bShadow );
585     aSub[2].SetShadow( bShadow );
586 }
587 
588 // gekapselte SV-Font-Methode
SetAutoKern(const sal_uInt8 nAutoKern)589 inline void SwSubFont::SetAutoKern( const sal_uInt8 nAutoKern )
590 {
591     pMagic = 0;
592     Font::SetKerning( nAutoKern );
593 }
594 
SetAutoKern(sal_uInt8 nAutoKern)595 inline void SwFont::SetAutoKern( sal_uInt8 nAutoKern )
596 {
597     bFntChg = sal_True;
598     aSub[1].SetAutoKern( nAutoKern );
599     if( nAutoKern )
600         nAutoKern = KERNING_FONTSPECIFIC;
601     aSub[0].SetAutoKern( nAutoKern );
602     aSub[2].SetAutoKern( nAutoKern );
603 }
604 
SetTransparent(const sal_Bool bTrans)605 inline void SwFont::SetTransparent( const sal_Bool bTrans )
606 {
607     aSub[0].SetTransparent( bTrans );
608     aSub[1].SetTransparent( bTrans );
609     aSub[2].SetTransparent( bTrans );
610 }
611 
SetFixKerning(const short nNewKern)612 inline void SwFont::SetFixKerning( const short nNewKern )
613 {
614     aSub[SW_LATIN].SetFixKerning( nNewKern );
615     aSub[SW_CJK].SetFixKerning( nNewKern );
616     aSub[SW_CTL].SetFixKerning( nNewKern );
617 }
618 
SetCaseMap(const SvxCaseMap eNew)619 inline void SwFont::SetCaseMap( const SvxCaseMap eNew )
620 {
621     aSub[SW_LATIN].SetCaseMap( eNew );
622     aSub[SW_CJK].SetCaseMap( eNew );
623     aSub[SW_CTL].SetCaseMap( eNew );
624 }
625 
626 // gekapselte SV-Font-Methode
SetWordLineMode(const sal_Bool bWordLineMode)627 inline void SwSubFont::SetWordLineMode( const sal_Bool bWordLineMode )
628 {
629     pMagic = 0;
630     Font::SetWordLineMode( bWordLineMode );
631 }
632 
SetWordLineMode(const sal_Bool bWordLineMode)633 inline void SwFont::SetWordLineMode( const sal_Bool bWordLineMode )
634 {
635     bFntChg = sal_True;
636     aSub[0].SetWordLineMode( bWordLineMode );
637     aSub[1].SetWordLineMode( bWordLineMode );
638     aSub[2].SetWordLineMode( bWordLineMode );
639 }
640 // gekapselte SV-Font-Methode
SetEmphasisMark(const FontEmphasisMark eValue)641 inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue )
642 {
643     pMagic = 0;
644     Font::SetEmphasisMark( eValue );
645 }
646 
SetEmphasisMark(const FontEmphasisMark eValue)647 inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue )
648 {
649     bFntChg = sal_True;
650     aSub[0].SetEmphasisMark( eValue );
651     aSub[1].SetEmphasisMark( eValue );
652     aSub[2].SetEmphasisMark( eValue );
653 }
654 
SetPropWidth(const sal_uInt16 nNew)655 inline void SwFont::SetPropWidth( const sal_uInt16 nNew )
656 {
657     if( nNew != aSub[0].GetPropWidth() )
658     {
659         bFntChg = sal_True;
660         aSub[0].SetPropWidth( nNew );
661         aSub[1].SetPropWidth( nNew );
662         aSub[2].SetPropWidth( nNew );
663     }
664 }
665 
666 // gekapselte SV-Font-Methode
SetRelief(const FontRelief eNew)667 inline void SwSubFont::SetRelief( const FontRelief eNew )
668 {
669     pMagic = 0;
670     Font::SetRelief( eNew );
671 }
672 
SetRelief(const FontRelief eNew)673 inline void SwFont::SetRelief( const FontRelief eNew )
674 {
675     if( eNew != aSub[0].GetRelief() )
676     {
677         bFntChg = sal_True;
678         aSub[0].SetRelief( eNew );
679         aSub[1].SetRelief( eNew );
680         aSub[2].SetRelief( eNew );
681     }
682 }
683 
684 // ueberladene Font-Methode
SetSize(const Size & rSize)685 inline void SwSubFont::SetSize( const Size& rSize )
686 {
687     aSize = rSize;
688     if ( GetPropr() == 100 )
689         Font::SetSize( aSize );
690     else
691     {
692         Font::SetSize( Size(
693             (long) aSize.Width() * GetPropr() / 100L,
694             (long) aSize.Height() * GetPropr() / 100L ) );
695     }
696     pMagic = 0;
697 }
698 
SetSize(const Size & rSize,const sal_uInt8 nWhich)699 inline void SwFont::SetSize( const Size& rSize, const sal_uInt8 nWhich )
700 {
701     if( aSub[nWhich].aSize != rSize )
702     {
703         aSub[nWhich].SetSize( rSize );
704         bFntChg = sal_True;
705         bOrgChg = sal_True;
706     }
707 }
708 
SetActual(sal_uInt8 nNew)709 inline void SwFont::SetActual( sal_uInt8 nNew )
710 {
711      if ( nActual != nNew )
712      {
713         bFntChg = sal_True;
714         bOrgChg = sal_True;
715         nActual = nNew;
716      }
717 }
718 
SetProportion(const sal_uInt8 nNewPropr)719 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
720 {
721     pMagic = 0;
722     Font::SetSize( Size( (long) aSize.Width() * nNewPropr / 100L,
723                          (long) aSize.Height() * nNewPropr / 100L ) );
724     SvxFont::SetPropr( nNewPropr );
725 }
726 
SetProportion(const sal_uInt8 nNewPropr)727 inline void SwFont::SetProportion( const sal_uInt8 nNewPropr )
728 {
729     if( nNewPropr != aSub[0].GetPropr() )
730     {
731         bFntChg = sal_True;
732         bOrgChg = sal_True;
733 
734         aSub[0].SetProportion( nNewPropr );
735         aSub[1].SetProportion( nNewPropr );
736         aSub[2].SetProportion( nNewPropr );
737     }
738 }
739 
SetEscapement(const short nNewEsc)740 inline void SwSubFont::SetEscapement( const short nNewEsc )
741 {
742     pMagic = 0;
743     SvxFont::SetEscapement( nNewEsc );
744 }
745 
SetEscapement(const short nNewEsc)746 inline void SwFont::SetEscapement( const short nNewEsc )
747 {
748     if( nNewEsc != aSub[0].GetEscapement() )
749     {
750         // these have to be set, otherwise nOrgHeight and nOrgAscent will not
751         // be calculated
752         bFntChg = sal_True;
753         bOrgChg = sal_True;
754 
755         aSub[0].SetEscapement( nNewEsc );
756         aSub[1].SetEscapement( nNewEsc );
757         aSub[2].SetEscapement( nNewEsc );
758     }
759 }
760 
SetLanguage(LanguageType eNewLang)761 inline void SwSubFont::SetLanguage( LanguageType eNewLang )
762 {
763     if( eNewLang == LANGUAGE_SYSTEM )
764         eNewLang = (LanguageType)GetAppLanguage();
765     SvxFont::SetLanguage( eNewLang );
766 }
767 
SetLanguage(const LanguageType eNewLang,const sal_uInt8 nWhich)768 inline void SwFont::SetLanguage( const LanguageType eNewLang, const sal_uInt8 nWhich )
769 {
770     aSub[nWhich].SetLanguage( eNewLang );
771     if( SW_CJK == nWhich )
772     {
773         aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
774         aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
775         aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
776     }
777 }
778 
SetPaintBlank(const sal_Bool bNew)779 inline void SwFont::SetPaintBlank( const sal_Bool bNew )
780 {
781     bPaintBlank = bNew;
782 }
783 
SetPaintWrong(const sal_Bool bNew)784 inline void SwFont::SetPaintWrong( const sal_Bool bNew )
785 {
786     bPaintWrong = bNew;
787 }
788 
SetNoHyph(const sal_Bool bNew)789 inline void SwFont::SetNoHyph( const sal_Bool bNew )
790 {
791     bNoHyph = bNew;
792 }
793 
SetBlink(const sal_Bool bNew)794 inline void SwFont::SetBlink( const sal_Bool bNew )
795 {
796     bBlink = bNew;
797 }
798 
SetURL(const sal_Bool bNew)799 inline void SwFont::SetURL( const sal_Bool bNew )
800 {
801     bURL = bNew;
802 }
803 
SetGreyWave(const sal_Bool bNew)804 inline void SwFont::SetGreyWave( const sal_Bool bNew )
805 {
806     bGreyWave = bNew;
807 }
808 
SetNoCol(const sal_Bool bNew)809 inline void SwFont::SetNoCol( const sal_Bool bNew )
810 {
811     bNoColReplace = bNew;
812 }
813 
SetVertical(const sal_uInt16 nDir,const sal_Bool bVertFormat)814 inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat )
815 {
816     pMagic = 0;
817     Font::SetVertical( bVertFormat );
818     Font::SetOrientation( nDir );
819 }
820 
821 
822 /*************************************************************************
823  *                      class SwUnderlineFont
824  *
825  * Used for the "continuous underline" feature.
826  *************************************************************************/
827 
828 class SwUnderlineFont
829 {
830     Point aPos;
831     SwFont* pFnt;
832 
833 public:
834     // sets the font which should paint the common baseline
835     // and the starting point of the common baseline
836     SwUnderlineFont( SwFont& rFnt, const Point& rPoint );
837     ~SwUnderlineFont();
838 
GetFont()839     SwFont& GetFont()
840     {
841         ASSERT( pFnt, "No underline font" )
842         return *pFnt;
843     }
GetPos() const844     const Point& GetPos() const { return aPos; }
845     // the x coordinate of the starting point has to be set for each portion
SetPos(const Point & rPoint)846     void SetPos( const Point& rPoint ) { aPos = rPoint;  }
847 };
848 
849 
850 /*************************************************************************
851  *                      class SvStatistics
852  *************************************************************************/
853 
854 #ifndef DBG_UTIL
855 #define SV_STAT(nWhich)
856 #else
857 
858 class SvStatistics
859 {
860 public:
861     sal_uInt16 nGetTextSize;
862     sal_uInt16 nDrawText;
863     sal_uInt16 nGetStretchTextSize;
864     sal_uInt16 nDrawStretchText;
865     sal_uInt16 nChangeFont;
866     sal_uInt16 nGetFontMetric;
867 
Reset()868     inline void Reset()
869     {
870         nGetTextSize = nDrawText = nGetStretchTextSize =
871         nDrawStretchText = nChangeFont = nGetFontMetric = 0;
872     }
873 
SvStatistics()874     inline SvStatistics() { Reset(); }
875 
876     inline void PrintOn( SvStream &rOS ) const; //$ ostream
IsEmpty() const877     inline sal_Bool IsEmpty() const
878     {
879         return !( nGetTextSize || nDrawText ||
880                   nDrawStretchText || nChangeFont || nGetFontMetric );
881     }
882 };
883 
884 // globale Variable, implementiert in swfont.cxx
885 extern SvStatistics aSvStat;
886 
887 #define SV_STAT(nWhich) ++(aSvStat.nWhich);
888 
PrintOn(SvStream & rOS) const889 inline void SvStatistics::PrintOn( SvStream &rOS ) const //$ ostream
890 {
891     if( IsEmpty() )
892         return;
893 
894     rOS << "{   SV called:" << '\n';
895     if( nGetTextSize )
896         rOS << "\tnGetTextSize: " <<    nGetTextSize    << '\n';        if( nDrawText   )
897         rOS << "\tnDrawText: "  << nDrawText    << '\n';        if( nGetStretchTextSize )
898         rOS << "\tnGetStretchTextSize: "    << nGetStretchTextSize  << '\n';        if( nDrawStretchText    )
899         rOS << "\tnDrawStretchText: "   << nDrawStretchText << '\n';        if( nChangeFont )
900         rOS << "\tnChangeFont: "    << nChangeFont  << '\n';        if( nGetFontMetric  )
901         rOS << "\tnGetFontMetric: " << nGetFontMetric   << '\n';        rOS << "}"  << '\n';    }
902 #endif  /*  PRODUCT */
903 
904 #endif
905