xref: /aoo41x/main/sw/source/core/txtnode/swfont.cxx (revision 69a74367)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
31cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hdl>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _OUTDEV_HXX //autogen
34cdf0e10cSrcweir #include <vcl/outdev.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
37cdf0e10cSrcweir #include <editeng/unolingu.hxx>
38cdf0e10cSrcweir #include <editeng/brshitem.hxx>
39cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
40cdf0e10cSrcweir #include <editeng/blnkitem.hxx>
41cdf0e10cSrcweir #include <editeng/nhypitem.hxx>
42cdf0e10cSrcweir #include <editeng/kernitem.hxx>
43cdf0e10cSrcweir #include <editeng/cmapitem.hxx>
44cdf0e10cSrcweir #include <editeng/langitem.hxx>
45cdf0e10cSrcweir #include <editeng/escpitem.hxx>
46cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
47cdf0e10cSrcweir #include <editeng/shdditem.hxx>
48cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
49cdf0e10cSrcweir #ifndef _SVX_CNTRITEM_HXX //autogen
50cdf0e10cSrcweir #include <editeng/cntritem.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <editeng/colritem.hxx>
53cdf0e10cSrcweir #include <editeng/cscoitem.hxx>
54cdf0e10cSrcweir #include <editeng/crsditem.hxx>
55cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
56cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
57cdf0e10cSrcweir #include <editeng/postitem.hxx>
58cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
59cdf0e10cSrcweir #include <editeng/fontitem.hxx>
60cdf0e10cSrcweir #ifndef _SVX_EMPHITEM_HXX //autogen
61cdf0e10cSrcweir #include <editeng/emphitem.hxx>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
64cdf0e10cSrcweir #include <editeng/charrotateitem.hxx>
65cdf0e10cSrcweir #include <editeng/twolinesitem.hxx>
66cdf0e10cSrcweir #include <editeng/charhiddenitem.hxx>
67cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
68cdf0e10cSrcweir #include <vcl/window.hxx>
69cdf0e10cSrcweir #include <charatr.hxx>
70cdf0e10cSrcweir #include <viewsh.hxx>		// Bildschirmabgleich
71cdf0e10cSrcweir #include <swfont.hxx>
72cdf0e10cSrcweir #include <fntcache.hxx>     // FontCache
73cdf0e10cSrcweir #include <txtfrm.hxx>       // SwTxtFrm
74cdf0e10cSrcweir #include <scriptinfo.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #if defined(WNT) || defined(PM2)
77cdf0e10cSrcweir #define FNT_LEADING_HACK
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir 
80cdf0e10cSrcweir #if defined(WNT)
81cdf0e10cSrcweir #define FNT_ATM_HACK
82cdf0e10cSrcweir #endif
83cdf0e10cSrcweir 
84cdf0e10cSrcweir #ifdef DBG_UTIL
85cdf0e10cSrcweir // globale Variable
86cdf0e10cSrcweir SvStatistics aSvStat;
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir 
89cdf0e10cSrcweir using namespace ::com::sun::star;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /************************************************************************
92cdf0e10cSrcweir  * Hintergrundbrush setzen, z.B. bei Zeichenvorlagen
93cdf0e10cSrcweir  ***********************************************************************/
94cdf0e10cSrcweir 
SetBackColor(Color * pNewColor)95cdf0e10cSrcweir void SwFont::SetBackColor( Color* pNewColor )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	delete pBackColor;
98cdf0e10cSrcweir 	pBackColor = pNewColor;
99cdf0e10cSrcweir 	bFntChg = sal_True;
100cdf0e10cSrcweir 	aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // maps directions for vertical layout
MapDirection(sal_uInt16 nDir,const sal_Bool bVertFormat)104cdf0e10cSrcweir sal_uInt16 MapDirection( sal_uInt16 nDir, const sal_Bool bVertFormat )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     if ( bVertFormat )
107cdf0e10cSrcweir     {
108cdf0e10cSrcweir         switch ( nDir )
109cdf0e10cSrcweir         {
110cdf0e10cSrcweir         case 0 :
111cdf0e10cSrcweir             nDir = 2700;
112cdf0e10cSrcweir             break;
113cdf0e10cSrcweir         case 900 :
114cdf0e10cSrcweir             nDir = 0;
115cdf0e10cSrcweir             break;
116cdf0e10cSrcweir         case 2700 :
117cdf0e10cSrcweir             nDir = 1800;
118cdf0e10cSrcweir             break;
119cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
120cdf0e10cSrcweir         default :
121cdf0e10cSrcweir             ASSERT( sal_False, "Unsupported direction" );
122cdf0e10cSrcweir             break;
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir     return nDir;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // maps the absolute direction set at the font to its logical conterpart
130cdf0e10cSrcweir // in the rotated environment
UnMapDirection(sal_uInt16 nDir,const sal_Bool bVertFormat)131cdf0e10cSrcweir sal_uInt16 UnMapDirection( sal_uInt16 nDir, const sal_Bool bVertFormat )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     if ( bVertFormat )
134cdf0e10cSrcweir     {
135cdf0e10cSrcweir         switch ( nDir )
136cdf0e10cSrcweir         {
137cdf0e10cSrcweir         case 0 :
138cdf0e10cSrcweir             nDir = 900;
139cdf0e10cSrcweir             break;
140cdf0e10cSrcweir         case 1800 :
141cdf0e10cSrcweir             nDir = 2700;
142cdf0e10cSrcweir             break;
143cdf0e10cSrcweir         case 2700 :
144cdf0e10cSrcweir             nDir = 0;
145cdf0e10cSrcweir             break;
146cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
147cdf0e10cSrcweir         default :
148cdf0e10cSrcweir             ASSERT( sal_False, "Unsupported direction" );
149cdf0e10cSrcweir             break;
150cdf0e10cSrcweir #endif
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir     return nDir;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
GetOrientation(const sal_Bool bVertFormat) const156cdf0e10cSrcweir sal_uInt16 SwFont::GetOrientation( const sal_Bool bVertFormat ) const
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     return UnMapDirection( aSub[nActual].GetOrientation(), bVertFormat );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
SetVertical(sal_uInt16 nDir,const sal_Bool bVertFormat)161cdf0e10cSrcweir void SwFont::SetVertical( sal_uInt16 nDir, const sal_Bool bVertFormat )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     // map direction if frame has vertical layout
164cdf0e10cSrcweir     nDir = MapDirection( nDir, bVertFormat );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     if( nDir != aSub[0].GetOrientation() )
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		bFntChg = sal_True;
169cdf0e10cSrcweir 		aSub[0].SetVertical( nDir, bVertFormat );
170cdf0e10cSrcweir         aSub[1].SetVertical( nDir, bVertFormat || nDir > 1000 );
171cdf0e10cSrcweir 		aSub[2].SetVertical( nDir, bVertFormat );
172cdf0e10cSrcweir 	}
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir /*************************************************************************
176cdf0e10cSrcweir  Escapement:
177cdf0e10cSrcweir 	frEsc:  Fraction, Grad des Escapements
178cdf0e10cSrcweir 	Esc = resultierendes Escapement
179cdf0e10cSrcweir 	A1 = Original-Ascent			(nOrgAscent)
180cdf0e10cSrcweir 	A2 = verkleinerter Ascent		(nEscAscent)
181cdf0e10cSrcweir 	Ax = resultierender Ascent		(GetAscent())
182cdf0e10cSrcweir 	H1 = Original-Hoehe 			(nOrgHeight)
183cdf0e10cSrcweir 	H2 = verkleinerter Hoehe		(nEscHeight)
184cdf0e10cSrcweir 	Hx = resultierender Hoehe		(GetHeight())
185cdf0e10cSrcweir 	Bx = resultierende Baseline fuer die Textausgabe (CalcPos())
186cdf0e10cSrcweir 		 (Vorsicht: Y - A1!)
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	Escapement:
189cdf0e10cSrcweir 		Esc = H1 * frEsc;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	Hochstellung:
192cdf0e10cSrcweir 		Ax = A2 + Esc;
193cdf0e10cSrcweir 		Hx = H2 + Esc;
194cdf0e10cSrcweir 		Bx = A1 - Esc;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	Tiefstellung:
197cdf0e10cSrcweir 		Ax = A1;
198cdf0e10cSrcweir 		Hx = A1 + Esc + (H2 - A2);
199cdf0e10cSrcweir 		Bx = A1 + Esc;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir *************************************************************************/
202cdf0e10cSrcweir 
203cdf0e10cSrcweir /*************************************************************************
204cdf0e10cSrcweir  *					SwSubFont::CalcEscAscent( const sal_uInt16 nOldAscent )
205cdf0e10cSrcweir  *************************************************************************/
206cdf0e10cSrcweir 
207cdf0e10cSrcweir // nEsc ist der Prozentwert
CalcEscAscent(const sal_uInt16 nOldAscent) const208cdf0e10cSrcweir sal_uInt16 SwSubFont::CalcEscAscent( const sal_uInt16 nOldAscent ) const
209cdf0e10cSrcweir {
210cdf0e10cSrcweir 	if( DFLT_ESC_AUTO_SUPER != GetEscapement() &&
211cdf0e10cSrcweir 		DFLT_ESC_AUTO_SUB != GetEscapement() )
212cdf0e10cSrcweir 	{
213cdf0e10cSrcweir 		const long nAscent = nOldAscent +
214cdf0e10cSrcweir 							 ( (long) nOrgHeight * GetEscapement() ) / 100L;
215cdf0e10cSrcweir 		if ( nAscent>0 )
216cdf0e10cSrcweir 			return ( Max( sal_uInt16 (nAscent), nOrgAscent ));
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir 	return nOrgAscent;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir /*************************************************************************
222cdf0e10cSrcweir  *                      SwFont::SetDiffFnt()
223cdf0e10cSrcweir  *************************************************************************/
224cdf0e10cSrcweir 
SetDiffFnt(const SfxItemSet * pAttrSet,const IDocumentSettingAccess * pIDocumentSettingAccess)225cdf0e10cSrcweir void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
226cdf0e10cSrcweir                          const IDocumentSettingAccess *pIDocumentSettingAccess )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir 	delete pBackColor;
229cdf0e10cSrcweir 	pBackColor = NULL;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     if( pAttrSet )
232cdf0e10cSrcweir 	{
233cdf0e10cSrcweir 		const SfxPoolItem* pItem;
234cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_FONT,
235cdf0e10cSrcweir 			sal_True, &pItem ))
236cdf0e10cSrcweir 		{
237cdf0e10cSrcweir 			const SvxFontItem *pFont = (const SvxFontItem *)pItem;
238cdf0e10cSrcweir 			aSub[SW_LATIN].SetFamily( pFont->GetFamily() );
239cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetName( pFont->GetFamilyName() );
240cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetStyleName( pFont->GetStyleName() );
241cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetPitch( pFont->GetPitch() );
242cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetCharSet( pFont->GetCharSet() );
243cdf0e10cSrcweir 		}
244cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_FONTSIZE,
245cdf0e10cSrcweir 			sal_True, &pItem ))
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir 			const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
248cdf0e10cSrcweir 			aSub[SW_LATIN].SvxFont::SetPropr( 100 );
249cdf0e10cSrcweir 			aSub[SW_LATIN].aSize = aSub[SW_LATIN].Font::GetSize();
250cdf0e10cSrcweir 			Size aTmpSize = aSub[SW_LATIN].aSize;
251cdf0e10cSrcweir 			aTmpSize.Height() = pHeight->GetHeight();
252cdf0e10cSrcweir 			aSub[SW_LATIN].SetSize( aTmpSize );
253cdf0e10cSrcweir 		}
254cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_POSTURE,
255cdf0e10cSrcweir 			sal_True, &pItem ))
256cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
257cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_WEIGHT,
258cdf0e10cSrcweir 			sal_True, &pItem ))
259cdf0e10cSrcweir 			aSub[SW_LATIN].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
260cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_LANGUAGE,
261cdf0e10cSrcweir 			sal_True, &pItem ))
262cdf0e10cSrcweir 			aSub[SW_LATIN].SetLanguage( ((SvxLanguageItem*)pItem)->GetLanguage() );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONT,
265cdf0e10cSrcweir 			sal_True, &pItem ))
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			const SvxFontItem *pFont = (const SvxFontItem *)pItem;
268cdf0e10cSrcweir 			aSub[SW_CJK].SetFamily( pFont->GetFamily() );
269cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetName( pFont->GetFamilyName() );
270cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetStyleName( pFont->GetStyleName() );
271cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetPitch( pFont->GetPitch() );
272cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetCharSet( pFont->GetCharSet() );
273cdf0e10cSrcweir 		}
274cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_FONTSIZE,
275cdf0e10cSrcweir 			sal_True, &pItem ))
276cdf0e10cSrcweir 		{
277cdf0e10cSrcweir 			const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
278cdf0e10cSrcweir 			aSub[SW_CJK].SvxFont::SetPropr( 100 );
279cdf0e10cSrcweir 			aSub[SW_CJK].aSize = aSub[SW_CJK].Font::GetSize();
280cdf0e10cSrcweir 			Size aTmpSize = aSub[SW_CJK].aSize;
281cdf0e10cSrcweir 			aTmpSize.Height() = pHeight->GetHeight();
282cdf0e10cSrcweir 			aSub[SW_CJK].SetSize( aTmpSize );
283cdf0e10cSrcweir 		}
284cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_POSTURE,
285cdf0e10cSrcweir 			sal_True, &pItem ))
286cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
287cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_WEIGHT,
288cdf0e10cSrcweir 			sal_True, &pItem ))
289cdf0e10cSrcweir 			aSub[SW_CJK].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
290cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CJK_LANGUAGE,
291cdf0e10cSrcweir 			sal_True, &pItem ))
292cdf0e10cSrcweir 		{
293cdf0e10cSrcweir 			LanguageType eNewLang = ((SvxLanguageItem*)pItem)->GetLanguage();
294cdf0e10cSrcweir 			aSub[SW_CJK].SetLanguage( eNewLang );
295cdf0e10cSrcweir 			aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
296cdf0e10cSrcweir 			aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
297cdf0e10cSrcweir 			aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
298cdf0e10cSrcweir 		}
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONT,
301cdf0e10cSrcweir 			sal_True, &pItem ))
302cdf0e10cSrcweir 		{
303cdf0e10cSrcweir 			const SvxFontItem *pFont = (const SvxFontItem *)pItem;
304cdf0e10cSrcweir 			aSub[SW_CTL].SetFamily( pFont->GetFamily() );
305cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetName( pFont->GetFamilyName() );
306cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetStyleName( pFont->GetStyleName() );
307cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetPitch( pFont->GetPitch() );
308cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetCharSet( pFont->GetCharSet() );
309cdf0e10cSrcweir 		}
310cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_FONTSIZE,
311cdf0e10cSrcweir 			sal_True, &pItem ))
312cdf0e10cSrcweir 		{
313cdf0e10cSrcweir 			const SvxFontHeightItem *pHeight = (const SvxFontHeightItem *)pItem;
314cdf0e10cSrcweir 			aSub[SW_CTL].SvxFont::SetPropr( 100 );
315cdf0e10cSrcweir 			aSub[SW_CTL].aSize = aSub[SW_CTL].Font::GetSize();
316cdf0e10cSrcweir 			Size aTmpSize = aSub[SW_CTL].aSize;
317cdf0e10cSrcweir 			aTmpSize.Height() = pHeight->GetHeight();
318cdf0e10cSrcweir 			aSub[SW_CTL].SetSize( aTmpSize );
319cdf0e10cSrcweir 		}
320cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_POSTURE,
321cdf0e10cSrcweir 			sal_True, &pItem ))
322cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
323cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_WEIGHT,
324cdf0e10cSrcweir 			sal_True, &pItem ))
325cdf0e10cSrcweir 			aSub[SW_CTL].Font::SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
326cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CTL_LANGUAGE,
327cdf0e10cSrcweir 			sal_True, &pItem ))
328cdf0e10cSrcweir 			aSub[SW_CTL].SetLanguage( ((SvxLanguageItem*)pItem)->GetLanguage() );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_UNDERLINE,
331cdf0e10cSrcweir 			sal_True, &pItem ))
332cdf0e10cSrcweir 		{
333cdf0e10cSrcweir 			SetUnderline( ((SvxUnderlineItem*)pItem)->GetLineStyle() );
334cdf0e10cSrcweir 			SetUnderColor( ((SvxUnderlineItem*)pItem)->GetColor() );
335cdf0e10cSrcweir 		}
336cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_OVERLINE,
337cdf0e10cSrcweir 			sal_True, &pItem ))
338cdf0e10cSrcweir         {
339cdf0e10cSrcweir 			SetOverline( ((SvxOverlineItem*)pItem)->GetLineStyle() );
340cdf0e10cSrcweir 			SetOverColor( ((SvxOverlineItem*)pItem)->GetColor() );
341cdf0e10cSrcweir         }
342cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CROSSEDOUT,
343cdf0e10cSrcweir 			sal_True, &pItem ))
344cdf0e10cSrcweir 			SetStrikeout( ((SvxCrossedOutItem*)pItem)->GetStrikeout() );
345cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_COLOR,
346cdf0e10cSrcweir 			sal_True, &pItem ))
347cdf0e10cSrcweir 			SetColor( ((SvxColorItem*)pItem)->GetValue() );
348cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_EMPHASIS_MARK,
349cdf0e10cSrcweir 			sal_True, &pItem ))
350cdf0e10cSrcweir 			SetEmphasisMark( ((SvxEmphasisMarkItem*)pItem)->GetEmphasisMark() );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 		SetTransparent( sal_True );
353cdf0e10cSrcweir 		SetAlign( ALIGN_BASELINE );
354cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CONTOUR,
355cdf0e10cSrcweir 			sal_True, &pItem ))
356cdf0e10cSrcweir 			SetOutline( ((SvxContourItem*)pItem)->GetValue() );
357cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
358cdf0e10cSrcweir 			sal_True, &pItem ))
359cdf0e10cSrcweir 			SetShadow( ((SvxShadowedItem*)pItem)->GetValue() );
360cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_RELIEF,
361cdf0e10cSrcweir 			sal_True, &pItem ))
362cdf0e10cSrcweir 			SetRelief( (FontRelief)((SvxCharReliefItem*)pItem)->GetValue() );
363cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_SHADOWED,
364cdf0e10cSrcweir 			sal_True, &pItem ))
365cdf0e10cSrcweir 			SetPropWidth(((SvxShadowedItem*)pItem)->GetValue() ? 50 : 100 );
366cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_AUTOKERN,
367cdf0e10cSrcweir 			sal_True, &pItem ))
368cdf0e10cSrcweir 		{
369cdf0e10cSrcweir 			if( ((SvxAutoKernItem*)pItem)->GetValue() )
370cdf0e10cSrcweir             {
371cdf0e10cSrcweir                 SetAutoKern( ( !pIDocumentSettingAccess ||
372cdf0e10cSrcweir                                !pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
373cdf0e10cSrcweir                                 KERNING_FONTSPECIFIC :
374cdf0e10cSrcweir                                 KERNING_ASIAN );
375cdf0e10cSrcweir             }
376cdf0e10cSrcweir 			else
377cdf0e10cSrcweir     			SetAutoKern( 0 );
378cdf0e10cSrcweir 		}
379cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_WORDLINEMODE,
380cdf0e10cSrcweir 			sal_True, &pItem ))
381cdf0e10cSrcweir 			SetWordLineMode( ((SvxWordLineModeItem*)pItem)->GetValue() );
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_ESCAPEMENT,
384cdf0e10cSrcweir 			sal_True, &pItem ))
385cdf0e10cSrcweir 		{
386cdf0e10cSrcweir 			const SvxEscapementItem *pEsc = (const SvxEscapementItem *)pItem;
387cdf0e10cSrcweir 			SetEscapement( pEsc->GetEsc() );
388cdf0e10cSrcweir 			if( aSub[SW_LATIN].IsEsc() )
389cdf0e10cSrcweir 				SetProportion( pEsc->GetProp() );
390cdf0e10cSrcweir 		}
391cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_CASEMAP,
392cdf0e10cSrcweir 			sal_True, &pItem ))
393cdf0e10cSrcweir 			SetCaseMap( ((SvxCaseMapItem*)pItem)->GetCaseMap() );
394cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_KERNING,
395cdf0e10cSrcweir 			sal_True, &pItem ))
396cdf0e10cSrcweir 			SetFixKerning( ((SvxKerningItem*)pItem)->GetValue() );
397cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_NOHYPHEN,
398cdf0e10cSrcweir 			sal_True, &pItem ))
399cdf0e10cSrcweir 			SetNoHyph( ((SvxNoHyphenItem*)pItem)->GetValue() );
400cdf0e10cSrcweir 		if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BLINK,
401cdf0e10cSrcweir 			sal_True, &pItem ))
402cdf0e10cSrcweir 			SetBlink( ((SvxBlinkItem*)pItem)->GetValue() );
403cdf0e10cSrcweir         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_ROTATE,
404cdf0e10cSrcweir             sal_True, &pItem ))
405cdf0e10cSrcweir             SetVertical( ((SvxCharRotateItem*)pItem)->GetValue() );
406cdf0e10cSrcweir         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
407cdf0e10cSrcweir             sal_True, &pItem ))
408cdf0e10cSrcweir             pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
409cdf0e10cSrcweir         else
410cdf0e10cSrcweir             pBackColor = NULL;
411cdf0e10cSrcweir         const SfxPoolItem* pTwoLinesItem = 0;
412cdf0e10cSrcweir         if( SFX_ITEM_SET ==
413cdf0e10cSrcweir                 pAttrSet->GetItemState( RES_CHRATR_TWO_LINES, sal_True, &pTwoLinesItem ))
414cdf0e10cSrcweir             if ( ((SvxTwoLinesItem*)pTwoLinesItem)->GetValue() )
415cdf0e10cSrcweir                 SetVertical( 0 );
416cdf0e10cSrcweir 	}
417cdf0e10cSrcweir 	else
418cdf0e10cSrcweir 	{
419cdf0e10cSrcweir 		Invalidate();
420cdf0e10cSrcweir 		bNoHyph = sal_False;
421cdf0e10cSrcweir 		bBlink = sal_False;
422cdf0e10cSrcweir 	}
423cdf0e10cSrcweir 	bPaintBlank = sal_False;
424cdf0e10cSrcweir 	bPaintWrong = sal_False;
425cdf0e10cSrcweir 	ASSERT( aSub[SW_LATIN].IsTransparent(), "SwFont: Transparent revolution" );
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir /*************************************************************************
429cdf0e10cSrcweir  *						class SwFont
430cdf0e10cSrcweir  *************************************************************************/
431cdf0e10cSrcweir 
SwFont(const SwFont & rFont)432cdf0e10cSrcweir SwFont::SwFont( const SwFont &rFont )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	aSub[SW_LATIN] = rFont.aSub[SW_LATIN];
435cdf0e10cSrcweir 	aSub[SW_CJK] = rFont.aSub[SW_CJK];
436cdf0e10cSrcweir 	aSub[SW_CTL] = rFont.aSub[SW_CTL];
437cdf0e10cSrcweir     nActual = rFont.nActual;
438cdf0e10cSrcweir 	pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
439cdf0e10cSrcweir 	aUnderColor = rFont.GetUnderColor();
440cdf0e10cSrcweir 	aOverColor  = rFont.GetOverColor();
441cdf0e10cSrcweir     nToxCnt = 0;
442cdf0e10cSrcweir     nRefCnt = 0;
443cdf0e10cSrcweir     m_nMetaCount = 0;
444*69a74367SOliver-Rainer Wittmann     m_nInputFieldCount = 0;
445cdf0e10cSrcweir 	bFntChg = rFont.bFntChg;
446cdf0e10cSrcweir 	bOrgChg = rFont.bOrgChg;
447cdf0e10cSrcweir 	bPaintBlank = rFont.bPaintBlank;
448cdf0e10cSrcweir 	bPaintWrong = sal_False;
449cdf0e10cSrcweir 	bURL = rFont.bURL;
450cdf0e10cSrcweir 	bGreyWave = rFont.bGreyWave;
451cdf0e10cSrcweir 	bNoColReplace = rFont.bNoColReplace;
452cdf0e10cSrcweir 	bNoHyph = rFont.bNoHyph;
453cdf0e10cSrcweir 	bBlink = rFont.bBlink;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
SwFont(const SwAttrSet * pAttrSet,const IDocumentSettingAccess * pIDocumentSettingAccess)456cdf0e10cSrcweir SwFont::SwFont( const SwAttrSet* pAttrSet,
457cdf0e10cSrcweir                 const IDocumentSettingAccess* pIDocumentSettingAccess )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir     nActual = SW_LATIN;
460cdf0e10cSrcweir     nToxCnt = 0;
461cdf0e10cSrcweir     nRefCnt = 0;
462cdf0e10cSrcweir     m_nMetaCount = 0;
463*69a74367SOliver-Rainer Wittmann     m_nInputFieldCount = 0;
464cdf0e10cSrcweir     bPaintBlank = sal_False;
465cdf0e10cSrcweir     bPaintWrong = sal_False;
466cdf0e10cSrcweir     bURL = sal_False;
467cdf0e10cSrcweir     bGreyWave = sal_False;
468cdf0e10cSrcweir     bNoColReplace = sal_False;
469cdf0e10cSrcweir     bNoHyph = pAttrSet->GetNoHyphenHere().GetValue();
470cdf0e10cSrcweir     bBlink = pAttrSet->GetBlink().GetValue();
471cdf0e10cSrcweir     bOrgChg = sal_True;
472cdf0e10cSrcweir     {
473cdf0e10cSrcweir         const SvxFontItem& rFont = pAttrSet->GetFont();
474cdf0e10cSrcweir         aSub[SW_LATIN].SetFamily( rFont.GetFamily() );
475cdf0e10cSrcweir         aSub[SW_LATIN].SetName( rFont.GetFamilyName() );
476cdf0e10cSrcweir         aSub[SW_LATIN].SetStyleName( rFont.GetStyleName() );
477cdf0e10cSrcweir         aSub[SW_LATIN].SetPitch( rFont.GetPitch() );
478cdf0e10cSrcweir         aSub[SW_LATIN].SetCharSet( rFont.GetCharSet() );
479cdf0e10cSrcweir         aSub[SW_LATIN].SvxFont::SetPropr( 100 );   // 100% der FontSize
480cdf0e10cSrcweir         Size aTmpSize = aSub[SW_LATIN].aSize;
481cdf0e10cSrcweir         aTmpSize.Height() = pAttrSet->GetSize().GetHeight();
482cdf0e10cSrcweir         aSub[SW_LATIN].SetSize( aTmpSize );
483cdf0e10cSrcweir         aSub[SW_LATIN].SetItalic( pAttrSet->GetPosture().GetPosture() );
484cdf0e10cSrcweir         aSub[SW_LATIN].SetWeight( pAttrSet->GetWeight().GetWeight() );
485cdf0e10cSrcweir         aSub[SW_LATIN].SetLanguage( pAttrSet->GetLanguage().GetLanguage() );
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir     {
489cdf0e10cSrcweir         const SvxFontItem& rFont = pAttrSet->GetCJKFont();
490cdf0e10cSrcweir         aSub[SW_CJK].SetFamily( rFont.GetFamily() );
491cdf0e10cSrcweir         aSub[SW_CJK].SetName( rFont.GetFamilyName() );
492cdf0e10cSrcweir         aSub[SW_CJK].SetStyleName( rFont.GetStyleName() );
493cdf0e10cSrcweir         aSub[SW_CJK].SetPitch( rFont.GetPitch() );
494cdf0e10cSrcweir         aSub[SW_CJK].SetCharSet( rFont.GetCharSet() );
495cdf0e10cSrcweir         aSub[SW_CJK].SvxFont::SetPropr( 100 );   // 100% der FontSize
496cdf0e10cSrcweir         Size aTmpSize = aSub[SW_CJK].aSize;
497cdf0e10cSrcweir         aTmpSize.Height() = pAttrSet->GetCJKSize().GetHeight();
498cdf0e10cSrcweir         aSub[SW_CJK].SetSize( aTmpSize );
499cdf0e10cSrcweir         aSub[SW_CJK].SetItalic( pAttrSet->GetCJKPosture().GetPosture() );
500cdf0e10cSrcweir         aSub[SW_CJK].SetWeight( pAttrSet->GetCJKWeight().GetWeight() );
501cdf0e10cSrcweir         LanguageType eNewLang = pAttrSet->GetCJKLanguage().GetLanguage();
502cdf0e10cSrcweir         aSub[SW_CJK].SetLanguage( eNewLang );
503cdf0e10cSrcweir         aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
504cdf0e10cSrcweir         aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
505cdf0e10cSrcweir         aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
506cdf0e10cSrcweir     }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir     {
509cdf0e10cSrcweir         const SvxFontItem& rFont = pAttrSet->GetCTLFont();
510cdf0e10cSrcweir         aSub[SW_CTL].SetFamily( rFont.GetFamily() );
511cdf0e10cSrcweir         aSub[SW_CTL].SetName( rFont.GetFamilyName() );
512cdf0e10cSrcweir         aSub[SW_CTL].SetStyleName( rFont.GetStyleName() );
513cdf0e10cSrcweir         aSub[SW_CTL].SetPitch( rFont.GetPitch() );
514cdf0e10cSrcweir         aSub[SW_CTL].SetCharSet( rFont.GetCharSet() );
515cdf0e10cSrcweir         aSub[SW_CTL].SvxFont::SetPropr( 100 );   // 100% der FontSize
516cdf0e10cSrcweir         Size aTmpSize = aSub[SW_CTL].aSize;
517cdf0e10cSrcweir         aTmpSize.Height() = pAttrSet->GetCTLSize().GetHeight();
518cdf0e10cSrcweir         aSub[SW_CTL].SetSize( aTmpSize );
519cdf0e10cSrcweir         aSub[SW_CTL].SetItalic( pAttrSet->GetCTLPosture().GetPosture() );
520cdf0e10cSrcweir         aSub[SW_CTL].SetWeight( pAttrSet->GetCTLWeight().GetWeight() );
521cdf0e10cSrcweir         aSub[SW_CTL].SetLanguage( pAttrSet->GetCTLLanguage().GetLanguage() );
522cdf0e10cSrcweir     }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     const FontUnderline eUnderline = pAttrSet->GetUnderline().GetLineStyle();
525cdf0e10cSrcweir     if ( pAttrSet->GetCharHidden().GetValue() )
526cdf0e10cSrcweir         SetUnderline( UNDERLINE_DOTTED );
527cdf0e10cSrcweir     else
528cdf0e10cSrcweir         SetUnderline( eUnderline );
529cdf0e10cSrcweir     SetUnderColor( pAttrSet->GetUnderline().GetColor() );
530cdf0e10cSrcweir     SetOverline( pAttrSet->GetOverline().GetLineStyle() );
531cdf0e10cSrcweir     SetOverColor( pAttrSet->GetOverline().GetColor() );
532cdf0e10cSrcweir     SetEmphasisMark( pAttrSet->GetEmphasisMark().GetEmphasisMark() );
533cdf0e10cSrcweir     SetStrikeout( pAttrSet->GetCrossedOut().GetStrikeout() );
534cdf0e10cSrcweir     SetColor( pAttrSet->GetColor().GetValue() );
535cdf0e10cSrcweir     SetTransparent( sal_True );
536cdf0e10cSrcweir     SetAlign( ALIGN_BASELINE );
537cdf0e10cSrcweir     SetOutline( pAttrSet->GetContour().GetValue() );
538cdf0e10cSrcweir     SetShadow( pAttrSet->GetShadowed().GetValue() );
539cdf0e10cSrcweir     SetPropWidth( pAttrSet->GetCharScaleW().GetValue() );
540cdf0e10cSrcweir     SetRelief( (FontRelief)pAttrSet->GetCharRelief().GetValue() );
541cdf0e10cSrcweir 	if( pAttrSet->GetAutoKern().GetValue() )
542cdf0e10cSrcweir     {
543cdf0e10cSrcweir         SetAutoKern( ( !pIDocumentSettingAccess ||
544cdf0e10cSrcweir                        !pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
545cdf0e10cSrcweir                         KERNING_FONTSPECIFIC :
546cdf0e10cSrcweir                         KERNING_ASIAN );
547cdf0e10cSrcweir     }
548cdf0e10cSrcweir 	else
549cdf0e10cSrcweir     	SetAutoKern( 0 );
550cdf0e10cSrcweir     SetWordLineMode( pAttrSet->GetWordLineMode().GetValue() );
551cdf0e10cSrcweir     const SvxEscapementItem &rEsc = pAttrSet->GetEscapement();
552cdf0e10cSrcweir     SetEscapement( rEsc.GetEsc() );
553cdf0e10cSrcweir     if( aSub[SW_LATIN].IsEsc() )
554cdf0e10cSrcweir         SetProportion( rEsc.GetProp() );
555cdf0e10cSrcweir     SetCaseMap( pAttrSet->GetCaseMap().GetCaseMap() );
556cdf0e10cSrcweir     SetFixKerning( pAttrSet->GetKerning().GetValue() );
557cdf0e10cSrcweir     const SfxPoolItem* pItem;
558cdf0e10cSrcweir     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
559cdf0e10cSrcweir         sal_True, &pItem ))
560cdf0e10cSrcweir         pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
561cdf0e10cSrcweir     else
562cdf0e10cSrcweir         pBackColor = NULL;
563cdf0e10cSrcweir     const SvxTwoLinesItem& rTwoLinesItem = pAttrSet->Get2Lines();
564cdf0e10cSrcweir     if ( ! rTwoLinesItem.GetValue() )
565cdf0e10cSrcweir         SetVertical( pAttrSet->GetCharRotate().GetValue() );
566cdf0e10cSrcweir     else
567cdf0e10cSrcweir         SetVertical( 0 );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
operator =(const SwSubFont & rFont)570cdf0e10cSrcweir SwSubFont& SwSubFont::operator=( const SwSubFont &rFont )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir 	SvxFont::operator=( rFont );
573cdf0e10cSrcweir 	pMagic = rFont.pMagic;
574cdf0e10cSrcweir 	nFntIndex = rFont.nFntIndex;
575cdf0e10cSrcweir 	nOrgHeight = rFont.nOrgHeight;
576cdf0e10cSrcweir 	nOrgAscent = rFont.nOrgAscent;
577cdf0e10cSrcweir 	nPropWidth = rFont.nPropWidth;
578cdf0e10cSrcweir 	aSize = rFont.aSize;
579cdf0e10cSrcweir 	return *this;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
operator =(const SwFont & rFont)582cdf0e10cSrcweir SwFont& SwFont::operator=( const SwFont &rFont )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	aSub[SW_LATIN] = rFont.aSub[SW_LATIN];
585cdf0e10cSrcweir 	aSub[SW_CJK] = rFont.aSub[SW_CJK];
586cdf0e10cSrcweir 	aSub[SW_CTL] = rFont.aSub[SW_CTL];
587cdf0e10cSrcweir     nActual = rFont.nActual;
588cdf0e10cSrcweir 	delete pBackColor;
589cdf0e10cSrcweir 	pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
590cdf0e10cSrcweir 	aUnderColor = rFont.GetUnderColor();
591cdf0e10cSrcweir 	aOverColor  = rFont.GetOverColor();
592cdf0e10cSrcweir     nToxCnt = 0;
593cdf0e10cSrcweir     nRefCnt = 0;
594cdf0e10cSrcweir     m_nMetaCount = 0;
595*69a74367SOliver-Rainer Wittmann     m_nInputFieldCount = 0;
596cdf0e10cSrcweir 	bFntChg = rFont.bFntChg;
597cdf0e10cSrcweir 	bOrgChg = rFont.bOrgChg;
598cdf0e10cSrcweir 	bPaintBlank = rFont.bPaintBlank;
599cdf0e10cSrcweir 	bPaintWrong = sal_False;
600cdf0e10cSrcweir 	bURL = rFont.bURL;
601cdf0e10cSrcweir 	bGreyWave = rFont.bGreyWave;
602cdf0e10cSrcweir 	bNoColReplace = rFont.bNoColReplace;
603cdf0e10cSrcweir 	bNoHyph = rFont.bNoHyph;
604cdf0e10cSrcweir 	bBlink = rFont.bBlink;
605cdf0e10cSrcweir 	return *this;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir /*************************************************************************
609cdf0e10cSrcweir  *						SwFont::GoMagic()
610cdf0e10cSrcweir  *************************************************************************/
611cdf0e10cSrcweir 
GoMagic(ViewShell * pSh,sal_uInt8 nWhich)612cdf0e10cSrcweir void SwFont::GoMagic( ViewShell *pSh, sal_uInt8 nWhich )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	SwFntAccess aFntAccess( aSub[nWhich].pMagic, aSub[nWhich].nFntIndex,
615cdf0e10cSrcweir 							&aSub[nWhich], pSh, sal_True );
616cdf0e10cSrcweir }
617cdf0e10cSrcweir 
618cdf0e10cSrcweir /*************************************************************************
619cdf0e10cSrcweir  *						SwSubFont::IsSymbol()
620cdf0e10cSrcweir  *************************************************************************/
621cdf0e10cSrcweir 
IsSymbol(ViewShell * pSh)622cdf0e10cSrcweir sal_Bool SwSubFont::IsSymbol( ViewShell *pSh )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir 	SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh, sal_False );
625cdf0e10cSrcweir 	return aFntAccess.Get()->IsSymbol();
626cdf0e10cSrcweir }
627cdf0e10cSrcweir 
628cdf0e10cSrcweir /*************************************************************************
629cdf0e10cSrcweir  *						SwSubFont::ChgFnt()
630cdf0e10cSrcweir  *************************************************************************/
631cdf0e10cSrcweir 
ChgFnt(ViewShell * pSh,OutputDevice & rOut)632cdf0e10cSrcweir sal_Bool SwSubFont::ChgFnt( ViewShell *pSh, OutputDevice& rOut )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir     if ( pLastFont )
635cdf0e10cSrcweir 		pLastFont->Unlock();
636cdf0e10cSrcweir 	SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh, sal_True );
637cdf0e10cSrcweir 	SV_STAT( nChangeFont );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	pLastFont = aFntAccess.Get();
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     pLastFont->SetDevFont( pSh, rOut );
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 	pLastFont->Lock();
644cdf0e10cSrcweir 	return UNDERLINE_NONE != GetUnderline() ||
645cdf0e10cSrcweir            UNDERLINE_NONE != GetOverline()  ||
646cdf0e10cSrcweir            STRIKEOUT_NONE != GetStrikeout();
647cdf0e10cSrcweir }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir /*************************************************************************
650cdf0e10cSrcweir  *					  SwFont::ChgPhysFnt()
651cdf0e10cSrcweir  *************************************************************************/
652cdf0e10cSrcweir 
ChgPhysFnt(ViewShell * pSh,OutputDevice & rOut)653cdf0e10cSrcweir void SwFont::ChgPhysFnt( ViewShell *pSh, OutputDevice& rOut )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir 	if( bOrgChg && aSub[nActual].IsEsc() )
656cdf0e10cSrcweir 	{
657cdf0e10cSrcweir 		const sal_uInt8 nOldProp = aSub[nActual].GetPropr();
658cdf0e10cSrcweir         SetProportion( 100 );
659cdf0e10cSrcweir         ChgFnt( pSh, rOut );
660cdf0e10cSrcweir 		SwFntAccess aFntAccess( aSub[nActual].pMagic, aSub[nActual].nFntIndex,
661cdf0e10cSrcweir 								&aSub[nActual], pSh );
662cdf0e10cSrcweir         aSub[nActual].nOrgHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
663cdf0e10cSrcweir         aSub[nActual].nOrgAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
664cdf0e10cSrcweir 		SetProportion( nOldProp );
665cdf0e10cSrcweir 		bOrgChg = sal_False;
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	if( bFntChg )
669cdf0e10cSrcweir 	{
670cdf0e10cSrcweir         ChgFnt( pSh, rOut );
671cdf0e10cSrcweir 		bFntChg = bOrgChg;
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir     if( rOut.GetTextLineColor() != aUnderColor )
674cdf0e10cSrcweir         rOut.SetTextLineColor( aUnderColor );
675cdf0e10cSrcweir     if( rOut.GetOverlineColor() != aOverColor )
676cdf0e10cSrcweir         rOut.SetOverlineColor( aOverColor );
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir /*************************************************************************
680cdf0e10cSrcweir  *						SwFont::CalcEscHeight()
681cdf0e10cSrcweir  *         Height = MaxAscent + MaxDescent
682cdf0e10cSrcweir  *      MaxAscent = Max (T1_ascent, T2_ascent + (Esc * T1_height) );
683cdf0e10cSrcweir  *     MaxDescent = Max (T1_height-T1_ascent,
684cdf0e10cSrcweir  * 						 T2_height-T2_ascent - (Esc * T1_height)
685cdf0e10cSrcweir  *************************************************************************/
686cdf0e10cSrcweir 
CalcEscHeight(const sal_uInt16 nOldHeight,const sal_uInt16 nOldAscent) const687cdf0e10cSrcweir sal_uInt16 SwSubFont::CalcEscHeight( const sal_uInt16 nOldHeight,
688cdf0e10cSrcweir 							  const sal_uInt16 nOldAscent  ) const
689cdf0e10cSrcweir {
690cdf0e10cSrcweir 	if( DFLT_ESC_AUTO_SUPER != GetEscapement() &&
691cdf0e10cSrcweir 		DFLT_ESC_AUTO_SUB != GetEscapement() )
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		long nDescent = nOldHeight - nOldAscent -
694cdf0e10cSrcweir 							 ( (long) nOrgHeight * GetEscapement() ) / 100L;
695cdf0e10cSrcweir 		const sal_uInt16 nDesc = ( nDescent>0 ) ? Max ( sal_uInt16(nDescent),
696cdf0e10cSrcweir 				   sal_uInt16(nOrgHeight - nOrgAscent) ) : nOrgHeight - nOrgAscent;
697cdf0e10cSrcweir 		return ( nDesc + CalcEscAscent( nOldAscent ) );
698cdf0e10cSrcweir 	}
699cdf0e10cSrcweir 	return nOrgHeight;
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
_CheckKerning()702cdf0e10cSrcweir short SwSubFont::_CheckKerning( )
703cdf0e10cSrcweir {
704cdf0e10cSrcweir 	short nKernx = - short( Font::GetSize().Height() / 6 );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 	if ( nKernx < GetFixKerning() )
707cdf0e10cSrcweir 		return GetFixKerning();
708cdf0e10cSrcweir 	return nKernx;
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir /*************************************************************************
712cdf0e10cSrcweir  *                    SwSubFont::GetAscent()
713cdf0e10cSrcweir  *************************************************************************/
714cdf0e10cSrcweir 
GetAscent(ViewShell * pSh,const OutputDevice & rOut)715cdf0e10cSrcweir sal_uInt16 SwSubFont::GetAscent( ViewShell *pSh, const OutputDevice& rOut )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	sal_uInt16 nAscent;
718cdf0e10cSrcweir 	SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh );
719cdf0e10cSrcweir     nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
720cdf0e10cSrcweir 	if( GetEscapement() )
721cdf0e10cSrcweir 		nAscent = CalcEscAscent( nAscent );
722cdf0e10cSrcweir 	return nAscent;
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
725cdf0e10cSrcweir /*************************************************************************
726cdf0e10cSrcweir  *					  SwSubFont::GetHeight()
727cdf0e10cSrcweir  *************************************************************************/
728cdf0e10cSrcweir 
GetHeight(ViewShell * pSh,const OutputDevice & rOut)729cdf0e10cSrcweir sal_uInt16 SwSubFont::GetHeight( ViewShell *pSh, const OutputDevice& rOut )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir 	SV_STAT( nGetTextSize );
732cdf0e10cSrcweir 	SwFntAccess aFntAccess( pMagic, nFntIndex, this, pSh );
733cdf0e10cSrcweir     const sal_uInt16 nHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
734cdf0e10cSrcweir 	if ( GetEscapement() )
735cdf0e10cSrcweir 	{
736cdf0e10cSrcweir         const sal_uInt16 nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut );
737cdf0e10cSrcweir 		return CalcEscHeight( nHeight, nAscent ); // + nLeading;
738cdf0e10cSrcweir 	}
739cdf0e10cSrcweir 	return nHeight; // + nLeading;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
742cdf0e10cSrcweir /*************************************************************************
743cdf0e10cSrcweir  *					  SwSubFont::_GetTxtSize()
744cdf0e10cSrcweir  *************************************************************************/
_GetTxtSize(SwDrawTextInfo & rInf)745cdf0e10cSrcweir Size SwSubFont::_GetTxtSize( SwDrawTextInfo& rInf )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir     // Robust: Eigentlich sollte der Font bereits eingestellt sein, aber
748cdf0e10cSrcweir     // sicher ist sicher ...
749cdf0e10cSrcweir     if ( !pLastFont || pLastFont->GetOwner()!=pMagic ||
750cdf0e10cSrcweir          !IsSameInstance( rInf.GetpOut()->GetFont() ) )
751cdf0e10cSrcweir         ChgFnt( rInf.GetShell(), rInf.GetOut() );
752cdf0e10cSrcweir 
753cdf0e10cSrcweir     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir     Size aTxtSize;
756cdf0e10cSrcweir     xub_StrLen nLn = ( rInf.GetLen() == STRING_LEN ? rInf.GetText().Len()
757cdf0e10cSrcweir                                                    : rInf.GetLen() );
758cdf0e10cSrcweir     rInf.SetLen( nLn );
759cdf0e10cSrcweir     if( IsCapital() && nLn )
760cdf0e10cSrcweir         aTxtSize = GetCapitalSize( rInf );
761cdf0e10cSrcweir     else
762cdf0e10cSrcweir     {
763cdf0e10cSrcweir         SV_STAT( nGetTextSize );
764cdf0e10cSrcweir         long nOldKern = rInf.GetKern();
765cdf0e10cSrcweir         const XubString &rOldTxt = rInf.GetText();
766cdf0e10cSrcweir         rInf.SetKern( CheckKerning() );
767cdf0e10cSrcweir         if ( !IsCaseMap() )
768cdf0e10cSrcweir             aTxtSize = pLastFont->GetTextSize( rInf );
769cdf0e10cSrcweir         else
770cdf0e10cSrcweir         {
771cdf0e10cSrcweir             String aTmp = CalcCaseMap( rInf.GetText() );
772cdf0e10cSrcweir             const XubString &rOldStr = rInf.GetText();
773cdf0e10cSrcweir             sal_Bool bCaseMapLengthDiffers(aTmp.Len() != rOldStr.Len());
774cdf0e10cSrcweir 
775cdf0e10cSrcweir             if(bCaseMapLengthDiffers && rInf.GetLen())
776cdf0e10cSrcweir             {
777cdf0e10cSrcweir                 // #108203#
778cdf0e10cSrcweir                 // If the length of the original string and the CaseMapped one
779cdf0e10cSrcweir                 // are different, it is necessary to handle the given text part as
780cdf0e10cSrcweir                 // a single snippet since it�s size may differ, too.
781cdf0e10cSrcweir                 xub_StrLen nOldIdx(rInf.GetIdx());
782cdf0e10cSrcweir                 xub_StrLen nOldLen(rInf.GetLen());
783cdf0e10cSrcweir                 const XubString aSnippet(rOldStr, nOldIdx, nOldLen);
784cdf0e10cSrcweir                 XubString aNewText(CalcCaseMap(aSnippet));
785cdf0e10cSrcweir 
786cdf0e10cSrcweir                 rInf.SetText( aNewText );
787cdf0e10cSrcweir                 rInf.SetIdx( 0 );
788cdf0e10cSrcweir                 rInf.SetLen( aNewText.Len() );
789cdf0e10cSrcweir 
790cdf0e10cSrcweir                 aTxtSize = pLastFont->GetTextSize( rInf );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir                 rInf.SetIdx( nOldIdx );
793cdf0e10cSrcweir                 rInf.SetLen( nOldLen );
794cdf0e10cSrcweir             }
795cdf0e10cSrcweir             else
796cdf0e10cSrcweir             {
797cdf0e10cSrcweir                 rInf.SetText( aTmp );
798cdf0e10cSrcweir                 aTxtSize = pLastFont->GetTextSize( rInf );
799cdf0e10cSrcweir             }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir             rInf.SetText( rOldStr );
802cdf0e10cSrcweir         }
803cdf0e10cSrcweir         rInf.SetKern( nOldKern );
804cdf0e10cSrcweir         rInf.SetText( rOldTxt );
805cdf0e10cSrcweir         // 15142: Ein Wort laenger als eine Zeile, beim Zeilenumbruch
806cdf0e10cSrcweir         //        hochgestellt, muss seine effektive Hoehe melden.
807cdf0e10cSrcweir         if( GetEscapement() )
808cdf0e10cSrcweir         {
809cdf0e10cSrcweir             const sal_uInt16 nAscent = pLastFont->GetFontAscent( rInf.GetShell(),
810cdf0e10cSrcweir                                                              rInf.GetOut() );
811cdf0e10cSrcweir             aTxtSize.Height() =
812cdf0e10cSrcweir                 (long)CalcEscHeight( (sal_uInt16)aTxtSize.Height(), nAscent);
813cdf0e10cSrcweir         }
814cdf0e10cSrcweir     }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir     if (1==rInf.GetLen() && CH_TXT_ATR_FIELDSTART==rInf.GetText().GetChar(rInf.GetIdx()))
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir         xub_StrLen nOldIdx(rInf.GetIdx());
819cdf0e10cSrcweir         xub_StrLen nOldLen(rInf.GetLen());
820cdf0e10cSrcweir         String aNewText=String::CreateFromAscii(CH_TXT_ATR_SUBST_FIELDSTART);
821cdf0e10cSrcweir         rInf.SetText( aNewText );
822cdf0e10cSrcweir         rInf.SetIdx( 0 );
823cdf0e10cSrcweir         rInf.SetLen( aNewText.Len() );
824cdf0e10cSrcweir         aTxtSize = pLastFont->GetTextSize( rInf );
825cdf0e10cSrcweir         rInf.SetIdx( nOldIdx );
826cdf0e10cSrcweir         rInf.SetLen( nOldLen );
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir     else if (1==rInf.GetLen() && CH_TXT_ATR_FIELDEND==rInf.GetText().GetChar(rInf.GetIdx()))
829cdf0e10cSrcweir     {
830cdf0e10cSrcweir         xub_StrLen nOldIdx(rInf.GetIdx());
831cdf0e10cSrcweir         xub_StrLen nOldLen(rInf.GetLen());
832cdf0e10cSrcweir         String aNewText=String::CreateFromAscii(CH_TXT_ATR_SUBST_FIELDEND);
833cdf0e10cSrcweir         rInf.SetText( aNewText );
834cdf0e10cSrcweir         rInf.SetIdx( 0 );
835cdf0e10cSrcweir         rInf.SetLen( aNewText.Len() );
836cdf0e10cSrcweir         aTxtSize = pLastFont->GetTextSize( rInf );
837cdf0e10cSrcweir         rInf.SetIdx( nOldIdx );
838cdf0e10cSrcweir         rInf.SetLen( nOldLen );
839cdf0e10cSrcweir     }
840cdf0e10cSrcweir 
841cdf0e10cSrcweir     return aTxtSize;
842cdf0e10cSrcweir }
843cdf0e10cSrcweir 
844cdf0e10cSrcweir /*************************************************************************
845cdf0e10cSrcweir  *					  SwSubFont::_DrawText()
846cdf0e10cSrcweir  *************************************************************************/
847cdf0e10cSrcweir 
_DrawText(SwDrawTextInfo & rInf,const sal_Bool bGrey)848cdf0e10cSrcweir void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const sal_Bool bGrey )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     rInf.SetGreyWave( bGrey );
851cdf0e10cSrcweir 	xub_StrLen nLn = rInf.GetText().Len();
852cdf0e10cSrcweir 	if( !rInf.GetLen() || !nLn )
853cdf0e10cSrcweir 		return;
854cdf0e10cSrcweir 	if( STRING_LEN == rInf.GetLen() )
855cdf0e10cSrcweir 		rInf.SetLen( nLn );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir     FontUnderline nOldUnder = UNDERLINE_NONE;
858cdf0e10cSrcweir     SwUnderlineFont* pUnderFnt = 0;
859cdf0e10cSrcweir 
860cdf0e10cSrcweir     if( rInf.GetUnderFnt() )
861cdf0e10cSrcweir 	{
862cdf0e10cSrcweir 		nOldUnder = GetUnderline();
863cdf0e10cSrcweir 		SetUnderline( UNDERLINE_NONE );
864cdf0e10cSrcweir         pUnderFnt = rInf.GetUnderFnt();
865cdf0e10cSrcweir 	}
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 	if( !pLastFont || pLastFont->GetOwner()!=pMagic )
868cdf0e10cSrcweir         ChgFnt( rInf.GetShell(), rInf.GetOut() );
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 	Point aPos( rInf.GetPos() );
873cdf0e10cSrcweir 	const Point &rOld = rInf.GetPos();
874cdf0e10cSrcweir 	rInf.SetPos( aPos );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 	if( GetEscapement() )
877cdf0e10cSrcweir         CalcEsc( rInf, aPos );
878cdf0e10cSrcweir 
879cdf0e10cSrcweir     rInf.SetKern( CheckKerning() + rInf.GetSperren() / SPACING_PRECISION_FACTOR );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 	if( IsCapital() )
882cdf0e10cSrcweir         DrawCapital( rInf );
883cdf0e10cSrcweir 	else
884cdf0e10cSrcweir 	{
885cdf0e10cSrcweir 		SV_STAT( nDrawText );
886cdf0e10cSrcweir 		if ( !IsCaseMap() )
887cdf0e10cSrcweir 			pLastFont->DrawText( rInf );
888cdf0e10cSrcweir 		else
889cdf0e10cSrcweir 		{
890cdf0e10cSrcweir 			const XubString &rOldStr = rInf.GetText();
891cdf0e10cSrcweir 			XubString aString( CalcCaseMap( rOldStr ) );
892cdf0e10cSrcweir 			sal_Bool bCaseMapLengthDiffers(aString.Len() != rOldStr.Len());
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 			if(bCaseMapLengthDiffers && rInf.GetLen())
895cdf0e10cSrcweir 			{
896cdf0e10cSrcweir 				// #108203#
897cdf0e10cSrcweir 				// If the length of the original string and the CaseMapped one
898cdf0e10cSrcweir 				// are different, it is necessary to handle the given text part as
899cdf0e10cSrcweir 				// a single snippet since it�s size may differ, too.
900cdf0e10cSrcweir 				xub_StrLen nOldIdx(rInf.GetIdx());
901cdf0e10cSrcweir 				xub_StrLen nOldLen(rInf.GetLen());
902cdf0e10cSrcweir 				const XubString aSnippet(rOldStr, nOldIdx, nOldLen);
903cdf0e10cSrcweir 				XubString aNewText = CalcCaseMap(aSnippet);
904cdf0e10cSrcweir 
905cdf0e10cSrcweir 				rInf.SetText( aNewText );
906cdf0e10cSrcweir 				rInf.SetIdx( 0 );
907cdf0e10cSrcweir 				rInf.SetLen( aNewText.Len() );
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 				pLastFont->DrawText( rInf );
910cdf0e10cSrcweir 
911cdf0e10cSrcweir 				rInf.SetIdx( nOldIdx );
912cdf0e10cSrcweir 				rInf.SetLen( nOldLen );
913cdf0e10cSrcweir 			}
914cdf0e10cSrcweir 			else
915cdf0e10cSrcweir 			{
916cdf0e10cSrcweir 				rInf.SetText( aString );
917cdf0e10cSrcweir 				pLastFont->DrawText( rInf );
918cdf0e10cSrcweir 			}
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 			rInf.SetText( rOldStr );
921cdf0e10cSrcweir 		}
922cdf0e10cSrcweir 	}
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
925cdf0e10cSrcweir 	{
926cdf0e10cSrcweir static sal_Char __READONLY_DATA sDoubleSpace[] = "  ";
927cdf0e10cSrcweir         Size aFontSize = _GetTxtSize( rInf );
928cdf0e10cSrcweir         const XubString &rOldStr = rInf.GetText();
929cdf0e10cSrcweir         XubString aStr( sDoubleSpace, RTL_TEXTENCODING_MS_1252 );
930cdf0e10cSrcweir 
931cdf0e10cSrcweir         xub_StrLen nOldIdx = rInf.GetIdx();
932cdf0e10cSrcweir 		xub_StrLen nOldLen = rInf.GetLen();
933cdf0e10cSrcweir         long nSpace = 0;
934cdf0e10cSrcweir 		if( rInf.GetSpace() )
935cdf0e10cSrcweir 		{
936cdf0e10cSrcweir             xub_StrLen nTmpEnd = nOldIdx + nOldLen;
937cdf0e10cSrcweir 			if( nTmpEnd > rOldStr.Len() )
938cdf0e10cSrcweir 				nTmpEnd = rOldStr.Len();
939cdf0e10cSrcweir 
940cdf0e10cSrcweir             const SwScriptInfo* pSI = rInf.GetScriptInfo();
941cdf0e10cSrcweir 
942cdf0e10cSrcweir             const sal_Bool bAsianFont =
943cdf0e10cSrcweir                 ( rInf.GetFont() && SW_CJK == rInf.GetFont()->GetActual() );
944cdf0e10cSrcweir             for( xub_StrLen nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp )
945cdf0e10cSrcweir             {
946cdf0e10cSrcweir                 if( CH_BLANK == rOldStr.GetChar( nTmp ) || bAsianFont ||
947cdf0e10cSrcweir                     ( nTmp + 1 < rOldStr.Len() && pSI &&
948cdf0e10cSrcweir                       i18n::ScriptType::ASIAN == pSI->ScriptType( nTmp + 1 ) ) )
949cdf0e10cSrcweir 					++nSpace;
950cdf0e10cSrcweir             }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir             // if next portion if a hole portion we do not consider any
953cdf0e10cSrcweir             // extra space added because the last character was ASIAN
954cdf0e10cSrcweir             if ( nSpace && rInf.IsSpaceStop() && bAsianFont )
955cdf0e10cSrcweir                  --nSpace;
956cdf0e10cSrcweir 
957cdf0e10cSrcweir             nSpace *= rInf.GetSpace() / SPACING_PRECISION_FACTOR;
958cdf0e10cSrcweir 		}
959cdf0e10cSrcweir 
960cdf0e10cSrcweir         rInf.SetWidth( sal_uInt16(aFontSize.Width() + nSpace) );
961cdf0e10cSrcweir         rInf.SetText( aStr );
962cdf0e10cSrcweir 		rInf.SetIdx( 0 );
963cdf0e10cSrcweir 		rInf.SetLen( 2 );
964cdf0e10cSrcweir         SetUnderline( nOldUnder );
965cdf0e10cSrcweir         rInf.SetUnderFnt( 0 );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir         // set position for underline font
968cdf0e10cSrcweir         rInf.SetPos( pUnderFnt->GetPos() );
969cdf0e10cSrcweir 
970cdf0e10cSrcweir         pUnderFnt->GetFont()._DrawStretchText( rInf );
971cdf0e10cSrcweir 
972cdf0e10cSrcweir         rInf.SetUnderFnt( pUnderFnt );
973cdf0e10cSrcweir         rInf.SetText( rOldStr );
974cdf0e10cSrcweir 		rInf.SetIdx( nOldIdx );
975cdf0e10cSrcweir 		rInf.SetLen( nOldLen );
976cdf0e10cSrcweir 	}
977cdf0e10cSrcweir 
978cdf0e10cSrcweir     rInf.SetPos( rOld );
979cdf0e10cSrcweir }
980cdf0e10cSrcweir 
_DrawStretchText(SwDrawTextInfo & rInf)981cdf0e10cSrcweir void SwSubFont::_DrawStretchText( SwDrawTextInfo &rInf )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir 	if( !rInf.GetLen() || !rInf.GetText().Len() )
984cdf0e10cSrcweir 		return;
985cdf0e10cSrcweir 
986cdf0e10cSrcweir     FontUnderline nOldUnder = UNDERLINE_NONE;
987cdf0e10cSrcweir     SwUnderlineFont* pUnderFnt = 0;
988cdf0e10cSrcweir 
989cdf0e10cSrcweir     if( rInf.GetUnderFnt() )
990cdf0e10cSrcweir 	{
991cdf0e10cSrcweir 		nOldUnder = GetUnderline();
992cdf0e10cSrcweir 		SetUnderline( UNDERLINE_NONE );
993cdf0e10cSrcweir         pUnderFnt = rInf.GetUnderFnt();
994cdf0e10cSrcweir 	}
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     if ( !pLastFont || pLastFont->GetOwner() != pMagic )
997cdf0e10cSrcweir         ChgFnt( rInf.GetShell(), rInf.GetOut() );
998cdf0e10cSrcweir 
999cdf0e10cSrcweir     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir     rInf.ApplyAutoColor();
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 	Point aPos( rInf.GetPos() );
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 	if( GetEscapement() )
1006cdf0e10cSrcweir         CalcEsc( rInf, aPos );
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir     rInf.SetKern( CheckKerning() + rInf.GetSperren() / SPACING_PRECISION_FACTOR );
1009cdf0e10cSrcweir     const Point &rOld = rInf.GetPos();
1010cdf0e10cSrcweir     rInf.SetPos( aPos );
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 	if( IsCapital() )
1013cdf0e10cSrcweir 		DrawStretchCapital( rInf );
1014cdf0e10cSrcweir 	else
1015cdf0e10cSrcweir 	{
1016cdf0e10cSrcweir 		SV_STAT( nDrawStretchText );
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir         if ( rInf.GetFrm() )
1019cdf0e10cSrcweir         {
1020cdf0e10cSrcweir             if ( rInf.GetFrm()->IsRightToLeft() )
1021cdf0e10cSrcweir                 rInf.GetFrm()->SwitchLTRtoRTL( aPos );
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir             if ( rInf.GetFrm()->IsVertical() )
1024cdf0e10cSrcweir                 rInf.GetFrm()->SwitchHorizontalToVertical( aPos );
1025cdf0e10cSrcweir         }
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 		if ( !IsCaseMap() )
1028cdf0e10cSrcweir 			rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(),
1029cdf0e10cSrcweir 							rInf.GetText(), rInf.GetIdx(), rInf.GetLen() );
1030cdf0e10cSrcweir 		else
1031cdf0e10cSrcweir 			rInf.GetOut().DrawStretchText( aPos, rInf.GetWidth(), CalcCaseMap(
1032cdf0e10cSrcweir 							rInf.GetText() ), rInf.GetIdx(), rInf.GetLen() );
1033cdf0e10cSrcweir 	}
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
1036cdf0e10cSrcweir 	{
1037cdf0e10cSrcweir static sal_Char __READONLY_DATA sDoubleSpace[] = "  ";
1038cdf0e10cSrcweir 		const XubString &rOldStr = rInf.GetText();
1039cdf0e10cSrcweir 		XubString aStr( sDoubleSpace, RTL_TEXTENCODING_MS_1252 );
1040cdf0e10cSrcweir 		xub_StrLen nOldIdx = rInf.GetIdx();
1041cdf0e10cSrcweir 		xub_StrLen nOldLen = rInf.GetLen();
1042cdf0e10cSrcweir 		rInf.SetText( aStr );
1043cdf0e10cSrcweir 		rInf.SetIdx( 0 );
1044cdf0e10cSrcweir 		rInf.SetLen( 2 );
1045cdf0e10cSrcweir 		SetUnderline( nOldUnder );
1046cdf0e10cSrcweir         rInf.SetUnderFnt( 0 );
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir         // set position for underline font
1049cdf0e10cSrcweir         rInf.SetPos( pUnderFnt->GetPos() );
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir         pUnderFnt->GetFont()._DrawStretchText( rInf );
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir         rInf.SetUnderFnt( pUnderFnt );
1054cdf0e10cSrcweir         rInf.SetText( rOldStr );
1055cdf0e10cSrcweir 		rInf.SetIdx( nOldIdx );
1056cdf0e10cSrcweir 		rInf.SetLen( nOldLen );
1057cdf0e10cSrcweir 	}
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir     rInf.SetPos( rOld );
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir /*************************************************************************
1063cdf0e10cSrcweir  *					  SwSubFont::_GetCrsrOfst()
1064cdf0e10cSrcweir  *************************************************************************/
1065cdf0e10cSrcweir 
_GetCrsrOfst(SwDrawTextInfo & rInf)1066cdf0e10cSrcweir xub_StrLen SwSubFont::_GetCrsrOfst( SwDrawTextInfo& rInf )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir 	if ( !pLastFont || pLastFont->GetOwner()!=pMagic )
1069cdf0e10cSrcweir         ChgFnt( rInf.GetShell(), rInf.GetOut() );
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir     SwDigitModeModifier aDigitModeModifier( rInf.GetOut(), rInf.GetFont()->GetLanguage() );
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 	xub_StrLen nLn = rInf.GetLen() == STRING_LEN ? rInf.GetText().Len()
1074cdf0e10cSrcweir 												 : rInf.GetLen();
1075cdf0e10cSrcweir 	rInf.SetLen( nLn );
1076cdf0e10cSrcweir 	xub_StrLen nCrsr = 0;
1077cdf0e10cSrcweir 	if( IsCapital() && nLn )
1078cdf0e10cSrcweir 		nCrsr = GetCapitalCrsrOfst( rInf );
1079cdf0e10cSrcweir 	else
1080cdf0e10cSrcweir 	{
1081cdf0e10cSrcweir 		const XubString &rOldTxt = rInf.GetText();
1082cdf0e10cSrcweir         long nOldKern = rInf.GetKern();
1083cdf0e10cSrcweir 		rInf.SetKern( CheckKerning() );
1084cdf0e10cSrcweir 		SV_STAT( nGetTextSize );
1085cdf0e10cSrcweir 		if ( !IsCaseMap() )
1086cdf0e10cSrcweir 			nCrsr = pLastFont->GetCrsrOfst( rInf );
1087cdf0e10cSrcweir 		else
1088cdf0e10cSrcweir 		{
1089cdf0e10cSrcweir 			String aTmp = CalcCaseMap( rInf.GetText() );
1090cdf0e10cSrcweir 			rInf.SetText( aTmp );
1091cdf0e10cSrcweir 			nCrsr = pLastFont->GetCrsrOfst( rInf );
1092cdf0e10cSrcweir 		}
1093cdf0e10cSrcweir 		rInf.SetKern( nOldKern );
1094cdf0e10cSrcweir 		rInf.SetText( rOldTxt );
1095cdf0e10cSrcweir 	}
1096cdf0e10cSrcweir 	return nCrsr;
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir /*************************************************************************
1100cdf0e10cSrcweir  *                    SwSubFont::CalcEsc()
1101cdf0e10cSrcweir  *************************************************************************/
1102cdf0e10cSrcweir 
CalcEsc(SwDrawTextInfo & rInf,Point & rPos)1103cdf0e10cSrcweir void SwSubFont::CalcEsc( SwDrawTextInfo& rInf, Point& rPos )
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir     long nOfst;
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir     sal_uInt16 nDir = UnMapDirection(
1108cdf0e10cSrcweir                 GetOrientation(), rInf.GetFrm() && rInf.GetFrm()->IsVertical() );
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir     switch ( GetEscapement() )
1111cdf0e10cSrcweir     {
1112cdf0e10cSrcweir     case DFLT_ESC_AUTO_SUB :
1113cdf0e10cSrcweir         nOfst = nOrgHeight - nOrgAscent -
1114cdf0e10cSrcweir             pLastFont->GetFontHeight( rInf.GetShell(), rInf.GetOut() ) +
1115cdf0e10cSrcweir             pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() );
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir         switch ( nDir )
1118cdf0e10cSrcweir         {
1119cdf0e10cSrcweir         case 0 :
1120cdf0e10cSrcweir             rPos.Y() += nOfst;
1121cdf0e10cSrcweir             break;
1122cdf0e10cSrcweir         case 900 :
1123cdf0e10cSrcweir             rPos.X() += nOfst;
1124cdf0e10cSrcweir             break;
1125cdf0e10cSrcweir         case 2700 :
1126cdf0e10cSrcweir             rPos.X() -= nOfst;
1127cdf0e10cSrcweir             break;
1128cdf0e10cSrcweir         }
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir         break;
1131cdf0e10cSrcweir     case DFLT_ESC_AUTO_SUPER :
1132cdf0e10cSrcweir         nOfst = pLastFont->GetFontAscent( rInf.GetShell(), rInf.GetOut() ) -
1133cdf0e10cSrcweir                 nOrgAscent;
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir         switch ( nDir )
1137cdf0e10cSrcweir         {
1138cdf0e10cSrcweir         case 0 :
1139cdf0e10cSrcweir             rPos.Y() += nOfst;
1140cdf0e10cSrcweir             break;
1141cdf0e10cSrcweir         case 900 :
1142cdf0e10cSrcweir             rPos.X() += nOfst;
1143cdf0e10cSrcweir             break;
1144cdf0e10cSrcweir         case 2700 :
1145cdf0e10cSrcweir             rPos.X() -= nOfst;
1146cdf0e10cSrcweir             break;
1147cdf0e10cSrcweir         }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir         break;
1150cdf0e10cSrcweir     default :
1151cdf0e10cSrcweir         nOfst = ((long)nOrgHeight * GetEscapement()) / 100L;
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir         switch ( nDir )
1154cdf0e10cSrcweir         {
1155cdf0e10cSrcweir         case 0 :
1156cdf0e10cSrcweir             rPos.Y() -= nOfst;
1157cdf0e10cSrcweir             break;
1158cdf0e10cSrcweir         case 900 :
1159cdf0e10cSrcweir             rPos.X() -= nOfst;
1160cdf0e10cSrcweir             break;
1161cdf0e10cSrcweir         case 2700 :
1162cdf0e10cSrcweir             rPos.X() += nOfst;
1163cdf0e10cSrcweir             break;
1164cdf0e10cSrcweir         }
1165cdf0e10cSrcweir     }
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir // used during painting of small capitals
Shift(sal_uInt16 nDir)1169cdf0e10cSrcweir void SwDrawTextInfo::Shift( sal_uInt16 nDir )
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir     ASSERT( bPos, "DrawTextInfo: Undefined Position" );
1172cdf0e10cSrcweir     ASSERT( bSize, "DrawTextInfo: Undefined Width" );
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir     const sal_Bool bBidiPor = ( GetFrm() && GetFrm()->IsRightToLeft() ) !=
1175cdf0e10cSrcweir                           ( 0 != ( TEXT_LAYOUT_BIDI_RTL & GetpOut()->GetLayoutMode() ) );
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     nDir = bBidiPor ?
1178cdf0e10cSrcweir             1800 :
1179cdf0e10cSrcweir             UnMapDirection( nDir, GetFrm() && GetFrm()->IsVertical() );
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir     switch ( nDir )
1182cdf0e10cSrcweir     {
1183cdf0e10cSrcweir     case 0 :
1184cdf0e10cSrcweir         ((Point*)pPos)->X() += GetSize().Width();
1185cdf0e10cSrcweir         break;
1186cdf0e10cSrcweir     case 900 :
1187cdf0e10cSrcweir         ASSERT( ((Point*)pPos)->Y() >= GetSize().Width(), "Going underground" );
1188cdf0e10cSrcweir         ((Point*)pPos)->Y() -= GetSize().Width();
1189cdf0e10cSrcweir         break;
1190cdf0e10cSrcweir     case 1800 :
1191cdf0e10cSrcweir         ((Point*)pPos)->X() -= GetSize().Width();
1192cdf0e10cSrcweir         break;
1193cdf0e10cSrcweir     case 2700 :
1194cdf0e10cSrcweir         ((Point*)pPos)->Y() += GetSize().Width();
1195cdf0e10cSrcweir         break;
1196cdf0e10cSrcweir     }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir /*************************************************************************
1200cdf0e10cSrcweir  *                      SwUnderlineFont::~SwUnderlineFont
1201cdf0e10cSrcweir  *
1202cdf0e10cSrcweir  * Used for the "continuous underline" feature.
1203cdf0e10cSrcweir  *************************************************************************/
1204cdf0e10cSrcweir 
SwUnderlineFont(SwFont & rFnt,const Point & rPoint)1205cdf0e10cSrcweir SwUnderlineFont::SwUnderlineFont( SwFont& rFnt, const Point& rPoint )
1206cdf0e10cSrcweir         : aPos( rPoint ), pFnt( &rFnt )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir };
1209cdf0e10cSrcweir 
~SwUnderlineFont()1210cdf0e10cSrcweir SwUnderlineFont::~SwUnderlineFont()
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir      delete pFnt;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir //Helper for filters to find true lineheight of a font
AttrSetToLineHeight(const IDocumentSettingAccess & rIDocumentSettingAccess,const SwAttrSet & rSet,const OutputDevice & rOut,sal_Int16 nScript)1216cdf0e10cSrcweir long AttrSetToLineHeight( const IDocumentSettingAccess& rIDocumentSettingAccess,
1217cdf0e10cSrcweir                           const SwAttrSet &rSet,
1218cdf0e10cSrcweir                           const OutputDevice &rOut, sal_Int16 nScript)
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir     SwFont aFont(&rSet, &rIDocumentSettingAccess);
1221cdf0e10cSrcweir     sal_uInt8 nActual;
1222cdf0e10cSrcweir     switch (nScript)
1223cdf0e10cSrcweir     {
1224cdf0e10cSrcweir         default:
1225cdf0e10cSrcweir         case i18n::ScriptType::LATIN:
1226cdf0e10cSrcweir             nActual = SW_LATIN;
1227cdf0e10cSrcweir             break;
1228cdf0e10cSrcweir         case i18n::ScriptType::ASIAN:
1229cdf0e10cSrcweir             nActual = SW_CJK;
1230cdf0e10cSrcweir             break;
1231cdf0e10cSrcweir         case i18n::ScriptType::COMPLEX:
1232cdf0e10cSrcweir             nActual = SW_CTL;
1233cdf0e10cSrcweir             break;
1234cdf0e10cSrcweir     }
1235cdf0e10cSrcweir     aFont.SetActual(nActual);
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir     OutputDevice &rMutableOut = const_cast<OutputDevice &>(rOut);
1238cdf0e10cSrcweir     const Font aOldFont(rMutableOut.GetFont());
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir     rMutableOut.SetFont(aFont.GetActualFont());
1241cdf0e10cSrcweir     long nHeight = rMutableOut.GetTextHeight();
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir     rMutableOut.SetFont(aOldFont);
1244cdf0e10cSrcweir     return nHeight;
1245cdf0e10cSrcweir }
1246