xref: /aoo42x/main/sw/source/core/inc/swfont.hxx (revision 69a74367)
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 
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 );
CheckKerning()115 	inline short CheckKerning()
116 	{   return GetFixKerning() >= 0 ? GetFixKerning() : _CheckKerning( ); }
SetPropWidth(const sal_uInt16 nNew)117 	inline void SetPropWidth( const sal_uInt16 nNew )
118 		{ pMagic = 0; nPropWidth = nNew; }
119 public:
GetPropWidth() const120 	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 
133     Color* pBackColor;     // background color (i.e. at character styles)
134     Color  aUnderColor;    // color of the underlining
135     Color  aOverColor;     // color of the overlining
136 
137     sal_uInt8   nToxCnt;        // Zaehlt die Schachtelungstiefe der Tox
138     sal_uInt8   nRefCnt;        // Zaehlt die Schachtelungstiefe der Refs
139     sal_uInt8   m_nMetaCount;   // count META/METAFIELD
140     sal_uInt8   m_nInputFieldCount; // count INPUTFIELD
141 
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:
SwFont()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 
ChgFnt(ViewShell * pSh,OutputDevice & rOut)164     inline void ChgFnt( ViewShell *pSh, OutputDevice& rOut )
165         { bPaintBlank = aSub[nActual].ChgFnt( pSh, rOut ); }
166 
~SwFont()167 	~SwFont(){ delete pBackColor; }
168 
169 	SwFont& operator=( const SwFont &rFont );
170 
GetActual() const171 	inline sal_uInt8 GetActual() const {	return nActual;	}
172     inline void SetActual( sal_uInt8 nNew );
GetActualFont() const173 	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 );
GetBackColor() const179 	inline const Color* GetBackColor() const{ return pBackColor; }
180 
ChkMagic(ViewShell * pSh,sal_uInt8 nWhich)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
CopyMagic(const SwFont * pFnt,sal_uInt8 nWhich)184 	inline void CopyMagic( const SwFont* pFnt, sal_uInt8 nWhich )
185 		{ aSub[nWhich].CopyMagic( pFnt->aSub[nWhich] ); }
GetMagic(const void * & rMagic,sal_uInt16 & rIdx,sal_uInt8 nWhich)186 	inline void GetMagic( const void* &rMagic, sal_uInt16 &rIdx, sal_uInt8 nWhich )
187 		{ rMagic = aSub[nWhich].pMagic; rIdx = aSub[nWhich].nFntIndex; }
SetMagic(const void * pNew,const sal_uInt16 nIdx,sal_uInt8 nWhich)188 	inline void SetMagic( const void* pNew, const sal_uInt16 nIdx, sal_uInt8 nWhich )
189 		{ aSub[nWhich].pMagic = pNew; aSub[nWhich].nFntIndex = nIdx; }
DifferentMagic(const SwFont * pFnt,sal_uInt8 nWhich)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 
GetSize(sal_uInt8 nWhich) const194 	inline const Size &GetSize( sal_uInt8 nWhich ) const
195 		{ return aSub[nWhich].aSize; }
IsFntChg() const196 	inline sal_Bool IsFntChg() const { return bFntChg; }
SetFntChg(const sal_Bool bNew)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 );
SetUnderColor(const Color & rColor)204 	inline void SetUnderColor( const Color &rColor ) { aUnderColor = rColor; }
205 	inline void SetOverline( const FontUnderline eOverline );
SetOverColor(const Color & rColor)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 );
IsNoHyph() const237 	inline sal_Bool IsNoHyph() const { return bNoHyph; }
238 	inline void SetBlink( const sal_Bool bBlink );
IsBlink() const239 	inline sal_Bool IsBlink() const { return bBlink; }
GetTox()240 	inline sal_uInt8 &GetTox() { return nToxCnt; }
GetTox() const241 	inline sal_uInt8 GetTox() const { return nToxCnt; }
IsTox() const242 	inline sal_Bool IsTox() const { return ( 0 != nToxCnt ); }
GetRef()243 	inline sal_uInt8 &GetRef() { return nRefCnt; }
GetRef() const244 	inline sal_uInt8 GetRef() const { return nRefCnt; }
IsRef() const245 	inline sal_Bool IsRef() const { return ( 0 != nRefCnt ); }
GetMeta()246     inline sal_uInt8 &GetMeta() { return m_nMetaCount; }
GetMeta() const247     inline sal_uInt8 GetMeta() const { return m_nMetaCount; }
IsMeta() const248     inline bool IsMeta() const { return (0 != m_nMetaCount); }
GetInputField()249     inline sal_uInt8 &GetInputField() { return m_nInputFieldCount; }
GetInputField() const250     inline sal_uInt8 GetInputField() const { return m_nInputFieldCount; }
IsInputField() const251     inline bool IsInputField() const { return (0 != m_nInputFieldCount); }
252 	inline void SetURL( const sal_Bool bURL );
IsURL() const253 	inline sal_Bool IsURL() const { return bURL; }
254 	inline void SetGreyWave( const sal_Bool bNew );
IsGreyWave() const255 	inline sal_Bool IsGreyWave() const { return bGreyWave; }
256 	inline void SetNoCol( const sal_Bool bNew );
IsNoCol() const257 	inline sal_Bool IsNoCol() const { return bNoColReplace; }
258 
259 	inline void SetPaintBlank( const sal_Bool bNew );
IsPaintBlank() const260 	inline sal_Bool IsPaintBlank() const { return bPaintBlank; }
261 	inline void SetPaintWrong( const sal_Bool bNew );
IsPaintWrong() const262 	inline sal_Bool IsPaintWrong() const { return bPaintWrong; }
263 
264 	// Setzen der Basisklasse Font fuer SwTxtCharFmt
265     void SetDiffFnt( const SfxItemSet* pSet,
266                      const IDocumentSettingAccess* pIDocumentSettingAccess );
267 
GetFnt(const sal_uInt8 nWhich) const268     inline const SvxFont &GetFnt( const sal_uInt8 nWhich ) const
269         { return aSub[nWhich]; };
270 
IsSymbol(ViewShell * pSh)271 	sal_Bool IsSymbol( ViewShell *pSh )
272 		{ return aSub[nActual].IsSymbol( pSh ); }
GetUnderline() const273 	FontUnderline GetUnderline() const { return aSub[nActual].GetUnderline(); }
GetUnderColor() const274 	const Color& GetUnderColor() const { return aUnderColor; }
GetOverline() const275 	FontUnderline GetOverline() const { return aSub[nActual].GetOverline(); }
GetOverColor() const276 	const Color& GetOverColor() const { return aOverColor; }
GetFixKerning() const277 	short GetFixKerning() const { return aSub[nActual].GetFixKerning(); }
GetStrikeout() const278 	FontStrikeout GetStrikeout() const { return aSub[nActual].GetStrikeout(); }
GetColor() const279 	const Color& GetColor() const { return aSub[nActual].GetColor(); }
IsShadow() const280 	sal_Bool IsShadow() const { return aSub[nActual].IsShadow(); }
IsWordLineMode() const281 	sal_Bool IsWordLineMode() const { return aSub[nActual].IsWordLineMode(); }
IsOutline() const282 	sal_Bool IsOutline() const { return aSub[nActual].IsOutline(); }
IsKerning() const283 	sal_Bool IsKerning() const { return aSub[nActual].IsKerning(); }
GetEscapement() const284 	short GetEscapement() const { return aSub[nActual].GetEscapement(); }
GetCaseMap() const285 	SvxCaseMap GetCaseMap() const { return aSub[nActual].GetCaseMap(); }
GetPropr() const286 	sal_uInt8 GetPropr() const { return aSub[nActual].GetPropr(); }
GetItalic() const287 	FontItalic GetItalic() const { return aSub[nActual].GetItalic(); }
GetLanguage() const288 	LanguageType GetLanguage() const { return aSub[nActual].GetLanguage(); }
GetAlign() const289 	FontAlign GetAlign() const { return aSub[nActual].GetAlign(); }
GetName() const290 	const XubString& GetName() const { return aSub[nActual].GetName(); }
GetStyleName() const291 	const XubString& GetStyleName() const {return aSub[nActual].GetStyleName();}
GetFamily() const292 	FontFamily GetFamily() const { return aSub[nActual].GetFamily(); }
GetPitch() const293 	FontPitch GetPitch() const { return aSub[nActual].GetPitch(); }
GetCharSet() const294 	rtl_TextEncoding GetCharSet() const	{ return aSub[nActual].GetCharSet(); }
GetHeight() const295 	long GetHeight() const { return aSub[nActual].GetSize().Height(); }
GetWeight() const296 	FontWeight GetWeight() const { return aSub[nActual].GetWeight(); }
GetEmphasisMark() const297 	FontEmphasisMark GetEmphasisMark() const
298 		{ return aSub[nActual].GetEmphasisMark(); }
GetPropWidth() const299     sal_uInt16 GetPropWidth() const { return aSub[nActual].GetPropWidth(); }
300     sal_uInt16 GetOrientation( const sal_Bool nVertLayout = sal_False ) const;
301 
GetName(const sal_uInt8 nWhich) const302 	inline const XubString& GetName( const sal_uInt8 nWhich ) const
303 		{ return aSub[nWhich].GetName(); }
GetLanguage(const sal_uInt8 nWhich) const304 	inline LanguageType GetLanguage( const sal_uInt8 nWhich ) const
305 		{ return aSub[nWhich].GetLanguage(); }
GetStyleName(const sal_uInt8 nWhich) const306 	inline const XubString& GetStyleName( const sal_uInt8 nWhich ) const
307 		{ return aSub[nWhich].GetStyleName(); }
GetFamily(const sal_uInt8 nWhich) const308 	inline FontFamily GetFamily( const sal_uInt8 nWhich ) const
309 		{ return aSub[nWhich].GetFamily(); }
GetItalic(const sal_uInt8 nWhich) const310 	inline FontItalic GetItalic( const sal_uInt8 nWhich ) const
311 		{ return aSub[nWhich].GetItalic(); }
GetPitch(const sal_uInt8 nWhich) const312 	inline FontPitch GetPitch( const sal_uInt8 nWhich ) const
313 		{ return aSub[nWhich].GetPitch(); }
GetCharSet(const sal_uInt8 nWhich) const314 	inline rtl_TextEncoding GetCharSet( const sal_uInt8 nWhich ) const
315 		{ return aSub[nWhich].GetCharSet(); }
GetHeight(const sal_uInt8 nWhich) const316 	inline long GetHeight( const sal_uInt8 nWhich ) const
317 		{ return aSub[nWhich].GetSize().Height(); }
GetWeight(const sal_uInt8 nWhich) const318 	inline FontWeight GetWeight( const sal_uInt8 nWhich ) const
319 		{ return aSub[nWhich].GetWeight(); }
GetEmphasisMark(const sal_uInt8 nWhich) const320 	inline FontEmphasisMark GetEmphasisMark( const sal_uInt8 nWhich ) const
321 		{ return aSub[nWhich].GetEmphasisMark(); }
322 
323 	// Macht den logischen Font im OutputDevice wirksam.
324     void ChgPhysFnt( ViewShell *pSh, OutputDevice& rOut );
325 
GetCapitalSize(SwDrawTextInfo & rInf)326 	Size GetCapitalSize( SwDrawTextInfo& rInf )
327 		{ return aSub[nActual].GetCapitalSize( rInf ); }
328 
329     xub_StrLen GetCapitalBreak( ViewShell* pSh,  const OutputDevice* pOut,
330         const SwScriptInfo* pScript, const XubString& rTxt,
331         long nTextWidth, xub_StrLen* pExtra, const xub_StrLen nIdx,
332 		const xub_StrLen nLen );
333 
GetCapitalCrsrOfst(SwDrawTextInfo & rInf)334 	xub_StrLen GetCapitalCrsrOfst( SwDrawTextInfo& rInf )
335 		{ return aSub[nActual].GetCapitalCrsrOfst( rInf ); }
336 
DrawCapital(SwDrawTextInfo & rInf)337 	void DrawCapital( SwDrawTextInfo &rInf )
338 		{ aSub[nActual].DrawCapital( rInf ); }
339 
DrawStretchCapital(SwDrawTextInfo & rInf)340 	void DrawStretchCapital( SwDrawTextInfo &rInf )
341 		{ aSub[nActual].DrawStretchCapital( rInf ); }
342 
DoOnCapitals(SwDoCapitals & rDo)343 	void DoOnCapitals( SwDoCapitals &rDo )
344 		{ aSub[nActual].DoOnCapitals( rDo ); }
345 
_GetTxtSize(SwDrawTextInfo & rInf)346 	Size _GetTxtSize( SwDrawTextInfo& rInf )
347         { rInf.SetFont( this ); return aSub[nActual]._GetTxtSize( rInf ); }
348 
349 	xub_StrLen GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth );
350 
_GetCrsrOfst(SwDrawTextInfo & rInf)351 	xub_StrLen _GetCrsrOfst( SwDrawTextInfo& rInf )
352 		{ return aSub[nActual]._GetCrsrOfst( rInf ); }
353 
_DrawText(SwDrawTextInfo & rInf)354 	inline void _DrawText( SwDrawTextInfo &rInf )
355 		{ aSub[nActual]._DrawText( rInf, IsGreyWave() ); }
356 
_DrawStretchText(SwDrawTextInfo & rInf)357 	inline void _DrawStretchText( SwDrawTextInfo &rInf )
358 		{ aSub[nActual]._DrawStretchText( rInf ); }
359 
CheckKerning()360 	inline short CheckKerning()
361 		{ return aSub[nActual].CheckKerning(); }
362 
GetAscent(ViewShell * pSh,const OutputDevice & rOut)363     inline sal_uInt16 GetAscent( ViewShell *pSh, const OutputDevice& rOut )
364         { return aSub[nActual].GetAscent( pSh, rOut ); }
GetHeight(ViewShell * pSh,const OutputDevice & rOut)365     inline sal_uInt16 GetHeight( ViewShell *pSh, const OutputDevice& rOut )
366         { return aSub[nActual].GetHeight( pSh, rOut ); }
367 
Invalidate()368     inline void Invalidate()
369 		{ bFntChg = bOrgChg = sal_True; }
370 };
371 
SetColor(const Color & rColor)372 inline void SwFont::SetColor( const Color& rColor )
373 {
374 	bFntChg = sal_True;
375 	aSub[0].SetColor( rColor );
376 	aSub[1].SetColor( rColor );
377 	aSub[2].SetColor( rColor );
378 }
379 
380 // gekapselte SV-Font-Methode
SetColor(const Color & rColor)381 inline void SwSubFont::SetColor( const Color& rColor )
382 {
383 	pMagic = 0;
384 	Font::SetColor( rColor );
385 }
386 
387 
388 // gekapselte SV-Font-Methode
SetFillColor(const Color & rColor)389 inline void SwSubFont::SetFillColor( const Color& rColor )
390 {
391 	pMagic = 0;
392 	Font::SetFillColor( rColor );
393 }
394 
SetFillColor(const Color & rColor)395 inline void SwFont::SetFillColor( const Color& rColor )
396 {
397 	bFntChg = sal_True;
398 	aSub[0].SetFillColor( rColor );
399 	aSub[1].SetFillColor( rColor );
400 	aSub[2].SetFillColor( rColor );
401 }
402 
403 // gekapselte SV-Font-Methode
SetFamily(const FontFamily eFamily)404 inline void SwSubFont::SetFamily( const FontFamily eFamily )
405 {
406 	pMagic = 0;
407 	Font::SetFamily( eFamily );
408 }
409 
SetFamily(const FontFamily eFamily,const sal_uInt8 nWhich)410 inline void SwFont::SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich )
411 {
412 	bFntChg = sal_True;
413 	aSub[nWhich].SetFamily( eFamily );
414 }
415 
416 // gekapselte SV-Font-Methode
SetName(const XubString & rName)417 inline void SwSubFont::SetName( const XubString& rName )
418 {
419 	pMagic = 0;
420 	Font::SetName( rName );
421 }
422 
SetName(const XubString & rName,const sal_uInt8 nWhich)423 inline void SwFont::SetName( const XubString& rName, const sal_uInt8 nWhich )
424 {
425 	bFntChg = sal_True;
426 	aSub[nWhich].SetName( rName );
427 }
428 
429 // gekapselte SV-Font-Methode
SetStyleName(const XubString & rStyleName)430 inline void SwSubFont::SetStyleName( const XubString& rStyleName )
431 {
432 	pMagic = 0;
433 	Font::SetStyleName( rStyleName );
434 }
435 
SetStyleName(const XubString & rStyle,const sal_uInt8 nWhich)436 inline void SwFont::SetStyleName( const XubString& rStyle, const sal_uInt8 nWhich )
437 {
438 	bFntChg = sal_True;
439 	aSub[nWhich].SetStyleName( rStyle );
440 }
441 
442 // gekapselte SV-Font-Methode
SetCharSet(const CharSet eCharSet)443 inline void SwSubFont::SetCharSet( const CharSet eCharSet )
444 {
445 	pMagic = 0;
446 	Font::SetCharSet( eCharSet );
447 }
448 
SetCharSet(const CharSet eCharSet,const sal_uInt8 nWhich)449 inline void SwFont::SetCharSet( const CharSet eCharSet, const sal_uInt8 nWhich )
450 {
451 	bFntChg = sal_True;
452 	aSub[nWhich].SetCharSet( eCharSet );
453 }
454 
455 // gekapselte SV-Font-Methode
SetPitch(const FontPitch ePitch)456 inline void SwSubFont::SetPitch( const FontPitch ePitch )
457 {
458 	pMagic = 0;
459 	Font::SetPitch( ePitch );
460 }
461 
462 // gekapselte SV-Font-Methode
SetPitch(const FontPitch ePitch,const sal_uInt8 nWhich)463 inline void SwFont::SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich )
464 {
465 	bFntChg = sal_True;
466 	aSub[nWhich].SetPitch( ePitch );
467 }
468 
469 // gekapselte SV-Font-Methode
SetAlign(const FontAlign eAlign)470 inline void SwSubFont::SetAlign( const FontAlign eAlign )
471 {
472 	pMagic = 0;
473 	Font::SetAlign( eAlign );
474 }
475 
SetAlign(const FontAlign eAlign)476 inline void SwFont::SetAlign( const FontAlign eAlign )
477 {
478 	bFntChg = sal_True;
479 	aSub[0].SetAlign( eAlign );
480 	aSub[1].SetAlign( eAlign );
481 	aSub[2].SetAlign( eAlign );
482 }
483 
484 // gekapselte SV-Font-Methode
SetWeight(const FontWeight eWeight)485 inline void SwSubFont::SetWeight( const FontWeight eWeight )
486 {
487 	pMagic = 0;
488 	Font::SetWeight( eWeight );
489 }
490 
SetWeight(const FontWeight eWeight,const sal_uInt8 nWhich)491 inline void SwFont::SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich )
492 {
493 	bFntChg = sal_True;
494 	aSub[nWhich].SetWeight( eWeight );
495 }
496 
497 // gekapselte SV-Font-Methode
SetUnderline(const FontUnderline eUnderline)498 inline void SwSubFont::SetUnderline( const FontUnderline eUnderline )
499 {
500 	pMagic = 0;
501 	Font::SetUnderline( eUnderline );
502 }
503 
SetUnderline(const FontUnderline eUnderline)504 inline void SwFont::SetUnderline( const FontUnderline eUnderline )
505 {
506 	bFntChg = sal_True;
507 	aSub[0].SetUnderline( eUnderline );
508 	aSub[1].SetUnderline( eUnderline );
509 	aSub[2].SetUnderline( eUnderline );
510 }
511 
512 // gekapselte SV-Font-Methode
SetOverline(const FontUnderline eOverline)513 inline void SwSubFont::SetOverline( const FontUnderline eOverline )
514 {
515 	pMagic = 0;
516 	Font::SetOverline( eOverline );
517 }
518 
SetOverline(const FontUnderline eOverline)519 inline void SwFont::SetOverline( const FontUnderline eOverline )
520 {
521 	bFntChg = sal_True;
522 	aSub[0].SetOverline( eOverline );
523 	aSub[1].SetOverline( eOverline );
524 	aSub[2].SetOverline( eOverline );
525 }
526 
527 // gekapselte SV-Font-Methode
SetStrikeout(const FontStrikeout eStrikeout)528 inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout )
529 {
530 	pMagic = 0;
531 	Font::SetStrikeout( eStrikeout );
532 }
533 
SetStrikeout(const FontStrikeout eStrikeout)534 inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout )
535 {
536 	bFntChg = sal_True;
537 	aSub[0].SetStrikeout( eStrikeout );
538 	aSub[1].SetStrikeout( eStrikeout );
539 	aSub[2].SetStrikeout( eStrikeout );
540 }
541 
542 // gekapselte SV-Font-Methode
SetItalic(const FontItalic eItalic)543 inline void SwSubFont::SetItalic( const FontItalic eItalic )
544 {
545 	pMagic = 0;
546 	Font::SetItalic( eItalic );
547 }
548 
SetItalic(const FontItalic eItalic,const sal_uInt8 nWhich)549 inline void SwFont::SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich )
550 {
551 	bFntChg = sal_True;
552 	aSub[nWhich].SetItalic( eItalic );
553 }
554 
555 // gekapselte SV-Font-Methode
SetOutline(const sal_Bool bOutline)556 inline void SwSubFont::SetOutline( const sal_Bool bOutline )
557 {
558 	pMagic = 0;
559 	Font::SetOutline( bOutline );
560 }
561 
SetOutline(const sal_Bool bOutline)562 inline void SwFont::SetOutline( const sal_Bool bOutline )
563 {
564 	bFntChg = sal_True;
565 	aSub[0].SetOutline( bOutline );
566 	aSub[1].SetOutline( bOutline );
567 	aSub[2].SetOutline( bOutline );
568 }
569 
570 // gekapselte SV-Font-Methode
SetShadow(const sal_Bool bShadow)571 inline void SwSubFont::SetShadow( const sal_Bool bShadow )
572 {
573 	pMagic = 0;
574 	Font::SetShadow( bShadow );
575 }
576 
SetShadow(const sal_Bool bShadow)577 inline void SwFont::SetShadow( const sal_Bool bShadow )
578 {
579 	bFntChg = sal_True;
580 	aSub[0].SetShadow( bShadow );
581 	aSub[1].SetShadow( bShadow );
582 	aSub[2].SetShadow( bShadow );
583 }
584 
585 // gekapselte SV-Font-Methode
SetAutoKern(const sal_uInt8 nAutoKern)586 inline void SwSubFont::SetAutoKern( const sal_uInt8 nAutoKern )
587 {
588 	pMagic = 0;
589 	Font::SetKerning( nAutoKern );
590 }
591 
SetAutoKern(sal_uInt8 nAutoKern)592 inline void SwFont::SetAutoKern( sal_uInt8 nAutoKern )
593 {
594 	bFntChg = sal_True;
595 	aSub[1].SetAutoKern( nAutoKern );
596 	if( nAutoKern )
597 		nAutoKern = KERNING_FONTSPECIFIC;
598 	aSub[0].SetAutoKern( nAutoKern );
599 	aSub[2].SetAutoKern( nAutoKern );
600 }
601 
SetTransparent(const sal_Bool bTrans)602 inline void SwFont::SetTransparent( const sal_Bool bTrans )
603 {
604 	aSub[0].SetTransparent( bTrans );
605 	aSub[1].SetTransparent( bTrans );
606 	aSub[2].SetTransparent( bTrans );
607 }
608 
SetFixKerning(const short nNewKern)609 inline void SwFont::SetFixKerning( const short nNewKern )
610 {
611 	aSub[SW_LATIN].SetFixKerning( nNewKern );
612 	aSub[SW_CJK].SetFixKerning( nNewKern );
613 	aSub[SW_CTL].SetFixKerning( nNewKern );
614 }
615 
SetCaseMap(const SvxCaseMap eNew)616 inline void SwFont::SetCaseMap( const SvxCaseMap eNew )
617 {
618 	aSub[SW_LATIN].SetCaseMap( eNew );
619 	aSub[SW_CJK].SetCaseMap( eNew );
620 	aSub[SW_CTL].SetCaseMap( eNew );
621 }
622 
623 // gekapselte SV-Font-Methode
SetWordLineMode(const sal_Bool bWordLineMode)624 inline void SwSubFont::SetWordLineMode( const sal_Bool bWordLineMode )
625 {
626 	pMagic = 0;
627 	Font::SetWordLineMode( bWordLineMode );
628 }
629 
SetWordLineMode(const sal_Bool bWordLineMode)630 inline void SwFont::SetWordLineMode( const sal_Bool bWordLineMode )
631 {
632 	bFntChg = sal_True;
633 	aSub[0].SetWordLineMode( bWordLineMode );
634 	aSub[1].SetWordLineMode( bWordLineMode );
635 	aSub[2].SetWordLineMode( bWordLineMode );
636 }
637 // gekapselte SV-Font-Methode
SetEmphasisMark(const FontEmphasisMark eValue)638 inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue )
639 {
640 	pMagic = 0;
641 	Font::SetEmphasisMark( eValue );
642 }
643 
SetEmphasisMark(const FontEmphasisMark eValue)644 inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue )
645 {
646 	bFntChg = sal_True;
647 	aSub[0].SetEmphasisMark( eValue );
648 	aSub[1].SetEmphasisMark( eValue );
649 	aSub[2].SetEmphasisMark( eValue );
650 }
651 
SetPropWidth(const sal_uInt16 nNew)652 inline void SwFont::SetPropWidth( const sal_uInt16 nNew )
653 {
654 	if( nNew != aSub[0].GetPropWidth() )
655 	{
656 		bFntChg = sal_True;
657 		aSub[0].SetPropWidth( nNew );
658 		aSub[1].SetPropWidth( nNew );
659 		aSub[2].SetPropWidth( nNew );
660 	}
661 }
662 
663 // gekapselte SV-Font-Methode
SetRelief(const FontRelief eNew)664 inline void SwSubFont::SetRelief( const FontRelief eNew )
665 {
666 	pMagic = 0;
667 	Font::SetRelief( eNew );
668 }
669 
SetRelief(const FontRelief eNew)670 inline void SwFont::SetRelief( const FontRelief eNew )
671 {
672 	if( eNew != aSub[0].GetRelief() )
673 	{
674 		bFntChg = sal_True;
675 		aSub[0].SetRelief( eNew );
676 		aSub[1].SetRelief( eNew );
677 		aSub[2].SetRelief( eNew );
678 	}
679 }
680 
681 // ueberladene Font-Methode
SetSize(const Size & rSize)682 inline void SwSubFont::SetSize( const Size& rSize )
683 {
684 	aSize = rSize;
685 	if ( GetPropr() == 100 )
686 		Font::SetSize( aSize );
687 	else
688 	{
689 		Font::SetSize( Size(
690 			(long) aSize.Width() * GetPropr() / 100L,
691 			(long) aSize.Height() * GetPropr() / 100L ) );
692 	}
693 	pMagic = 0;
694 }
695 
SetSize(const Size & rSize,const sal_uInt8 nWhich)696 inline void SwFont::SetSize( const Size& rSize, const sal_uInt8 nWhich )
697 {
698 	if( aSub[nWhich].aSize != rSize )
699 	{
700 		aSub[nWhich].SetSize( rSize );
701 		bFntChg = sal_True;
702 		bOrgChg = sal_True;
703 	}
704 }
705 
SetActual(sal_uInt8 nNew)706 inline void SwFont::SetActual( sal_uInt8 nNew )
707 {
708      if ( nActual != nNew )
709      {
710         bFntChg = sal_True;
711         bOrgChg = sal_True;
712         nActual = nNew;
713      }
714 }
715 
SetProportion(const sal_uInt8 nNewPropr)716 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
717 {
718 	pMagic = 0;
719 	Font::SetSize( Size( (long) aSize.Width() * nNewPropr / 100L,
720 						 (long) aSize.Height() * nNewPropr / 100L ) );
721 	SvxFont::SetPropr( nNewPropr );
722 }
723 
SetProportion(const sal_uInt8 nNewPropr)724 inline void SwFont::SetProportion( const sal_uInt8 nNewPropr )
725 {
726     if( nNewPropr != aSub[0].GetPropr() )
727     {
728         bFntChg = sal_True;
729         bOrgChg = sal_True;
730 
731         aSub[0].SetProportion( nNewPropr );
732         aSub[1].SetProportion( nNewPropr );
733         aSub[2].SetProportion( nNewPropr );
734     }
735 }
736 
SetEscapement(const short nNewEsc)737 inline void SwSubFont::SetEscapement( const short nNewEsc )
738 {
739 	pMagic = 0;
740 	SvxFont::SetEscapement( nNewEsc );
741 }
742 
SetEscapement(const short nNewEsc)743 inline void SwFont::SetEscapement( const short nNewEsc )
744 {
745 	if( nNewEsc != aSub[0].GetEscapement() )
746 	{
747         // these have to be set, otherwise nOrgHeight and nOrgAscent will not
748         // be calculated
749         bFntChg = sal_True;
750         bOrgChg = sal_True;
751 
752 		aSub[0].SetEscapement( nNewEsc );
753 		aSub[1].SetEscapement( nNewEsc );
754 		aSub[2].SetEscapement( nNewEsc );
755 	}
756 }
757 
SetLanguage(LanguageType eNewLang)758 inline void SwSubFont::SetLanguage( LanguageType eNewLang )
759 {
760 	if( eNewLang == LANGUAGE_SYSTEM )
761 		eNewLang = (LanguageType)GetAppLanguage();
762 	SvxFont::SetLanguage( eNewLang );
763 }
764 
SetLanguage(const LanguageType eNewLang,const sal_uInt8 nWhich)765 inline void SwFont::SetLanguage( const LanguageType eNewLang, const sal_uInt8 nWhich )
766 {
767 	aSub[nWhich].SetLanguage( eNewLang );
768 	if( SW_CJK == nWhich )
769 	{
770 		aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
771 		aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
772 		aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
773 	}
774 }
775 
SetPaintBlank(const sal_Bool bNew)776 inline void SwFont::SetPaintBlank( const sal_Bool bNew )
777 {
778 	bPaintBlank = bNew;
779 }
780 
SetPaintWrong(const sal_Bool bNew)781 inline void SwFont::SetPaintWrong( const sal_Bool bNew )
782 {
783 	bPaintWrong = bNew;
784 }
785 
SetNoHyph(const sal_Bool bNew)786 inline void SwFont::SetNoHyph( const sal_Bool bNew )
787 {
788 	bNoHyph = bNew;
789 }
790 
SetBlink(const sal_Bool bNew)791 inline void SwFont::SetBlink( const sal_Bool bNew )
792 {
793 	bBlink = bNew;
794 }
795 
SetURL(const sal_Bool bNew)796 inline void SwFont::SetURL( const sal_Bool bNew )
797 {
798 	bURL = bNew;
799 }
800 
SetGreyWave(const sal_Bool bNew)801 inline void SwFont::SetGreyWave( const sal_Bool bNew )
802 {
803 	bGreyWave = bNew;
804 }
805 
SetNoCol(const sal_Bool bNew)806 inline void SwFont::SetNoCol( const sal_Bool bNew )
807 {
808 	bNoColReplace = bNew;
809 }
810 
SetVertical(const sal_uInt16 nDir,const sal_Bool bVertFormat)811 inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertFormat )
812 {
813 	pMagic = 0;
814     Font::SetVertical( bVertFormat );
815 	Font::SetOrientation( nDir );
816 }
817 
818 
819 /*************************************************************************
820  *                      class SwUnderlineFont
821  *
822  * Used for the "continuous underline" feature.
823  *************************************************************************/
824 
825 class SwUnderlineFont
826 {
827     Point aPos;
828     SwFont* pFnt;
829 
830 public:
831     // sets the font which should paint the common baseline
832     // and the starting point of the common baseline
833     SwUnderlineFont( SwFont& rFnt, const Point& rPoint );
834     ~SwUnderlineFont();
835 
GetFont()836     SwFont& GetFont()
837     {
838         ASSERT( pFnt, "No underline font" )
839         return *pFnt;
840     }
GetPos() const841     const Point& GetPos() const { return aPos; }
842     // the x coordinate of the starting point has to be set for each portion
SetPos(const Point & rPoint)843     void SetPos( const Point& rPoint ) { aPos = rPoint;  }
844 };
845 
846 
847 /*************************************************************************
848  *						class SvStatistics
849  *************************************************************************/
850 
851 #ifndef DBG_UTIL
852 #define SV_STAT(nWhich)
853 #else
854 
855 class SvStatistics
856 {
857 public:
858 	sal_uInt16 nGetTextSize;
859 	sal_uInt16 nDrawText;
860 	sal_uInt16 nGetStretchTextSize;
861 	sal_uInt16 nDrawStretchText;
862 	sal_uInt16 nChangeFont;
863 	sal_uInt16 nGetFontMetric;
864 
Reset()865 	inline void Reset()
866 	{
867 		nGetTextSize = nDrawText = nGetStretchTextSize =
868 		nDrawStretchText = nChangeFont = nGetFontMetric = 0;
869 	}
870 
SvStatistics()871 	inline SvStatistics() { Reset(); }
872 
873 	inline void PrintOn( SvStream &rOS ) const; //$ ostream
IsEmpty() const874 	inline sal_Bool IsEmpty() const
875 	{
876 		return !( nGetTextSize || nDrawText ||
877 				  nDrawStretchText || nChangeFont || nGetFontMetric );
878 	}
879 };
880 
881 // globale Variable, implementiert in swfont.cxx
882 extern SvStatistics aSvStat;
883 
884 #define SV_STAT(nWhich) ++(aSvStat.nWhich);
885 
PrintOn(SvStream & rOS) const886 inline void SvStatistics::PrintOn( SvStream &rOS ) const //$ ostream
887 {
888 	if( IsEmpty() )
889 		return;
890 
891 	rOS << "{	SV called:" << '\n';
892 	if( nGetTextSize )
893 		rOS << "\tnGetTextSize:	" <<	nGetTextSize	<< '\n';		if(	nDrawText	)
894 		rOS	<< "\tnDrawText: "	<< nDrawText	<< '\n';		if(	nGetStretchTextSize	)
895 		rOS	<< "\tnGetStretchTextSize: "	<< nGetStretchTextSize	<< '\n';		if(	nDrawStretchText	)
896 		rOS	<< "\tnDrawStretchText: "	<< nDrawStretchText	<< '\n';		if(	nChangeFont	)
897 		rOS	<< "\tnChangeFont: "	<< nChangeFont	<< '\n';		if(	nGetFontMetric	)
898 		rOS	<< "\tnGetFontMetric: "	<< nGetFontMetric	<< '\n';		rOS	<< "}"	<< '\n';	}
899 #endif	/*	PRODUCT	*/
900 
901 #endif
902 
903