xref: /trunk/main/svtools/source/control/ctrltool.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #define CTRLTOOL_CXX
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <string.h>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <tools/debug.hxx>
36*cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
37*cdf0e10cSrcweir #include <vcl/window.hxx>
38*cdf0e10cSrcweir #include <vcl/svapp.hxx>
39*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
40*cdf0e10cSrcweir #include <svtools/svtools.hrc>
41*cdf0e10cSrcweir #include <svtools/svtdata.hxx>
42*cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir // =======================================================================
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir // Standard Fontgroessen fuer scalierbare Fonts
47*cdf0e10cSrcweir static long aStdSizeAry[] =
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir      60,
50*cdf0e10cSrcweir      70,
51*cdf0e10cSrcweir      80,
52*cdf0e10cSrcweir      90,
53*cdf0e10cSrcweir     100,
54*cdf0e10cSrcweir     105,
55*cdf0e10cSrcweir     110,
56*cdf0e10cSrcweir     120,
57*cdf0e10cSrcweir     130,
58*cdf0e10cSrcweir     140,
59*cdf0e10cSrcweir     150,
60*cdf0e10cSrcweir     160,
61*cdf0e10cSrcweir     180,
62*cdf0e10cSrcweir     200,
63*cdf0e10cSrcweir     220,
64*cdf0e10cSrcweir     240,
65*cdf0e10cSrcweir     260,
66*cdf0e10cSrcweir     280,
67*cdf0e10cSrcweir     320,
68*cdf0e10cSrcweir     360,
69*cdf0e10cSrcweir     400,
70*cdf0e10cSrcweir     440,
71*cdf0e10cSrcweir     480,
72*cdf0e10cSrcweir     540,
73*cdf0e10cSrcweir     600,
74*cdf0e10cSrcweir     660,
75*cdf0e10cSrcweir     720,
76*cdf0e10cSrcweir     800,
77*cdf0e10cSrcweir     880,
78*cdf0e10cSrcweir     960,
79*cdf0e10cSrcweir     0
80*cdf0e10cSrcweir };
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir // =======================================================================
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // -----------------------------
85*cdf0e10cSrcweir // - class ImplFontListFonInfo -
86*cdf0e10cSrcweir // -----------------------------
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir class ImplFontListFontInfo : public FontInfo
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir     friend class FontList;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir private:
93*cdf0e10cSrcweir     OutputDevice*           mpDevice;
94*cdf0e10cSrcweir     ImplFontListFontInfo*   mpNext;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir public:
97*cdf0e10cSrcweir                             ImplFontListFontInfo( const FontInfo& rInfo,
98*cdf0e10cSrcweir                                                   OutputDevice* pDev ) :
99*cdf0e10cSrcweir                                 FontInfo( rInfo )
100*cdf0e10cSrcweir                             {
101*cdf0e10cSrcweir                                 mpDevice = pDev;
102*cdf0e10cSrcweir                             }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     OutputDevice*           GetDevice() const { return mpDevice; }
105*cdf0e10cSrcweir };
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir // ------------------------------
108*cdf0e10cSrcweir // - class ImplFontListNameInfo -
109*cdf0e10cSrcweir // ------------------------------
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir class ImplFontListNameInfo
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir     friend class FontList;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir private:
116*cdf0e10cSrcweir     XubString               maSearchName;
117*cdf0e10cSrcweir     ImplFontListFontInfo*   mpFirst;
118*cdf0e10cSrcweir     sal_uInt16                  mnType;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir                             ImplFontListNameInfo( const XubString& rSearchName ) :
121*cdf0e10cSrcweir                                 maSearchName( rSearchName )
122*cdf0e10cSrcweir                             {}
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     const XubString&        GetSearchName() const { return maSearchName; }
125*cdf0e10cSrcweir };
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir // =======================================================================
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir static StringCompare ImplCompareFontInfo( ImplFontListFontInfo* pInfo1,
130*cdf0e10cSrcweir                                           ImplFontListFontInfo* pInfo2 )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir     if ( pInfo1->GetWeight() < pInfo2->GetWeight() )
133*cdf0e10cSrcweir         return COMPARE_LESS;
134*cdf0e10cSrcweir     else if ( pInfo1->GetWeight() > pInfo2->GetWeight() )
135*cdf0e10cSrcweir         return COMPARE_GREATER;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     if ( pInfo1->GetItalic() < pInfo2->GetItalic() )
138*cdf0e10cSrcweir         return COMPARE_LESS;
139*cdf0e10cSrcweir     else if ( pInfo1->GetItalic() > pInfo2->GetItalic() )
140*cdf0e10cSrcweir         return COMPARE_GREATER;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     return pInfo1->GetStyleName().CompareTo( pInfo2->GetStyleName() );
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir // =======================================================================
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir static void ImplMakeSearchString( XubString& rStr )
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir     rStr.ToLowerAscii();
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir // -----------------------------------------------------------------------
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir static void ImplMakeSearchStringFromName( XubString& rStr )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     // check for features before alternate font separator
157*cdf0e10cSrcweir     if (rStr.Search(':') < rStr.Search(';'))
158*cdf0e10cSrcweir         rStr = rStr.GetToken( 0, ':' );
159*cdf0e10cSrcweir     else
160*cdf0e10cSrcweir         rStr = rStr.GetToken( 0, ';' );
161*cdf0e10cSrcweir     ImplMakeSearchString( rStr );
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir // -----------------------------------------------------------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLong* pIndex ) const
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir     // Wenn kein Eintrag in der Liste oder der Eintrag groesser ist als
169*cdf0e10cSrcweir     // der Letzte, dann hinten dranhaengen. Wir vergleichen erst mit dem
170*cdf0e10cSrcweir     // letzten Eintrag, da die Liste von VCL auch sortiert zurueckkommt
171*cdf0e10cSrcweir     // und somit die Wahrscheinlichkeit das hinten angehaengt werden muss
172*cdf0e10cSrcweir     // sehr gross ist.
173*cdf0e10cSrcweir     StringCompare eComp;
174*cdf0e10cSrcweir     sal_uLong nCnt = Count();
175*cdf0e10cSrcweir     if ( !nCnt )
176*cdf0e10cSrcweir     {
177*cdf0e10cSrcweir         if ( pIndex )
178*cdf0e10cSrcweir             *pIndex = LIST_APPEND;
179*cdf0e10cSrcweir         return NULL;
180*cdf0e10cSrcweir     }
181*cdf0e10cSrcweir     else
182*cdf0e10cSrcweir     {
183*cdf0e10cSrcweir         ImplFontListNameInfo* pCmpData = (ImplFontListNameInfo*)List::GetObject( nCnt-1 );
184*cdf0e10cSrcweir         eComp = rSearchName.CompareTo( pCmpData->maSearchName );
185*cdf0e10cSrcweir         if ( eComp == COMPARE_GREATER )
186*cdf0e10cSrcweir         {
187*cdf0e10cSrcweir             if ( pIndex )
188*cdf0e10cSrcweir                 *pIndex = LIST_APPEND;
189*cdf0e10cSrcweir             return NULL;
190*cdf0e10cSrcweir         }
191*cdf0e10cSrcweir         else if ( eComp == COMPARE_EQUAL )
192*cdf0e10cSrcweir             return pCmpData;
193*cdf0e10cSrcweir     }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     // Fonts in der Liste suchen
196*cdf0e10cSrcweir     ImplFontListNameInfo*   pCompareData;
197*cdf0e10cSrcweir     ImplFontListNameInfo*   pFoundData = NULL;
198*cdf0e10cSrcweir     sal_uLong                   nLow = 0;
199*cdf0e10cSrcweir     sal_uLong                   nHigh = nCnt-1;
200*cdf0e10cSrcweir     sal_uLong                   nMid;
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     do
203*cdf0e10cSrcweir     {
204*cdf0e10cSrcweir         nMid = (nLow + nHigh) / 2;
205*cdf0e10cSrcweir         pCompareData = (ImplFontListNameInfo*)List::GetObject( nMid );
206*cdf0e10cSrcweir         eComp = rSearchName.CompareTo( pCompareData->maSearchName );
207*cdf0e10cSrcweir         if ( eComp == COMPARE_LESS )
208*cdf0e10cSrcweir         {
209*cdf0e10cSrcweir             if ( !nMid )
210*cdf0e10cSrcweir                 break;
211*cdf0e10cSrcweir             nHigh = nMid-1;
212*cdf0e10cSrcweir         }
213*cdf0e10cSrcweir         else
214*cdf0e10cSrcweir         {
215*cdf0e10cSrcweir             if ( eComp == COMPARE_GREATER )
216*cdf0e10cSrcweir                 nLow = nMid + 1;
217*cdf0e10cSrcweir             else
218*cdf0e10cSrcweir             {
219*cdf0e10cSrcweir                 pFoundData = pCompareData;
220*cdf0e10cSrcweir                 break;
221*cdf0e10cSrcweir             }
222*cdf0e10cSrcweir         }
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir     while ( nLow <= nHigh );
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     if ( pIndex )
227*cdf0e10cSrcweir     {
228*cdf0e10cSrcweir         eComp = rSearchName.CompareTo( pCompareData->maSearchName );
229*cdf0e10cSrcweir         if ( eComp == COMPARE_GREATER )
230*cdf0e10cSrcweir             *pIndex = (nMid+1);
231*cdf0e10cSrcweir         else
232*cdf0e10cSrcweir             *pIndex = nMid;
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     return pFoundData;
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir // -----------------------------------------------------------------------
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir ImplFontListNameInfo* FontList::ImplFindByName( const XubString& rStr ) const
241*cdf0e10cSrcweir {
242*cdf0e10cSrcweir     XubString aSearchName = rStr;
243*cdf0e10cSrcweir     ImplMakeSearchStringFromName( aSearchName );
244*cdf0e10cSrcweir     return ImplFind( aSearchName, NULL );
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir // -----------------------------------------------------------------------
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir void FontList::ImplInsertFonts( OutputDevice* pDevice, sal_Bool bAll,
250*cdf0e10cSrcweir                                 sal_Bool bInsertData )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     rtl_TextEncoding eSystemEncoding = gsl_getSystemTextEncoding();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir     sal_uInt16 nType;
255*cdf0e10cSrcweir     if ( pDevice->GetOutDevType() != OUTDEV_PRINTER )
256*cdf0e10cSrcweir         nType = FONTLIST_FONTNAMETYPE_SCREEN;
257*cdf0e10cSrcweir     else
258*cdf0e10cSrcweir         nType = FONTLIST_FONTNAMETYPE_PRINTER;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     // Alle Fonts vom Device abfragen
261*cdf0e10cSrcweir     int n = pDevice->GetDevFontCount();
262*cdf0e10cSrcweir     sal_uInt16  i;
263*cdf0e10cSrcweir     for( i = 0; i < n; i++ )
264*cdf0e10cSrcweir     {
265*cdf0e10cSrcweir         FontInfo aFontInfo = pDevice->GetDevFont( i );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         // Wenn keine Raster-Schriften angezeigt werden sollen,
268*cdf0e10cSrcweir         // dann diese ignorieren
269*cdf0e10cSrcweir         if ( !bAll && (aFontInfo.GetType() == TYPE_RASTER) )
270*cdf0e10cSrcweir             continue;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir         XubString               aSearchName = aFontInfo.GetName();
273*cdf0e10cSrcweir         ImplFontListNameInfo*   pData;
274*cdf0e10cSrcweir         sal_uLong                   nIndex;
275*cdf0e10cSrcweir         ImplMakeSearchString( aSearchName );
276*cdf0e10cSrcweir         pData = ImplFind( aSearchName, &nIndex );
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir         if ( !pData )
279*cdf0e10cSrcweir         {
280*cdf0e10cSrcweir             if ( bInsertData )
281*cdf0e10cSrcweir             {
282*cdf0e10cSrcweir                 ImplFontListFontInfo* pNewInfo = new ImplFontListFontInfo( aFontInfo, pDevice );
283*cdf0e10cSrcweir                 pData = new ImplFontListNameInfo( aSearchName );
284*cdf0e10cSrcweir                 pData->mpFirst      = pNewInfo;
285*cdf0e10cSrcweir                 pNewInfo->mpNext    = NULL;
286*cdf0e10cSrcweir                 pData->mnType       = 0;
287*cdf0e10cSrcweir                 Insert( (void*)pData, nIndex );
288*cdf0e10cSrcweir             }
289*cdf0e10cSrcweir         }
290*cdf0e10cSrcweir         else
291*cdf0e10cSrcweir         {
292*cdf0e10cSrcweir             if ( bInsertData )
293*cdf0e10cSrcweir             {
294*cdf0e10cSrcweir                 sal_Bool                    bInsert = sal_True;
295*cdf0e10cSrcweir                 ImplFontListFontInfo*   pPrev = NULL;
296*cdf0e10cSrcweir                 ImplFontListFontInfo*   pTemp = pData->mpFirst;
297*cdf0e10cSrcweir                 ImplFontListFontInfo*   pNewInfo = new ImplFontListFontInfo( aFontInfo, pDevice );
298*cdf0e10cSrcweir                 while ( pTemp )
299*cdf0e10cSrcweir                 {
300*cdf0e10cSrcweir                     StringCompare eComp = ImplCompareFontInfo( pNewInfo, pTemp );
301*cdf0e10cSrcweir                     if ( (eComp == COMPARE_LESS) || (eComp == COMPARE_EQUAL) )
302*cdf0e10cSrcweir                     {
303*cdf0e10cSrcweir                         if ( eComp == COMPARE_EQUAL )
304*cdf0e10cSrcweir                         {
305*cdf0e10cSrcweir                             // Overwrite charset, because charset should match
306*cdf0e10cSrcweir                             // with the system charset
307*cdf0e10cSrcweir                             if ( (pTemp->GetCharSet() != eSystemEncoding) &&
308*cdf0e10cSrcweir                                  (pNewInfo->GetCharSet() == eSystemEncoding) )
309*cdf0e10cSrcweir                             {
310*cdf0e10cSrcweir                                 ImplFontListFontInfo* pTemp2 = pTemp->mpNext;
311*cdf0e10cSrcweir                                 *((FontInfo*)pTemp) = *((FontInfo*)pNewInfo);
312*cdf0e10cSrcweir                                 pTemp->mpNext = pTemp2;
313*cdf0e10cSrcweir                             }
314*cdf0e10cSrcweir                             delete pNewInfo;
315*cdf0e10cSrcweir                             bInsert = sal_False;
316*cdf0e10cSrcweir                         }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir                         break;
319*cdf0e10cSrcweir                     }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir                     pPrev = pTemp;
322*cdf0e10cSrcweir                     pTemp = pTemp->mpNext;
323*cdf0e10cSrcweir                 }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir                 if ( bInsert )
326*cdf0e10cSrcweir                 {
327*cdf0e10cSrcweir                     pNewInfo->mpNext = pTemp;
328*cdf0e10cSrcweir                     if ( pPrev )
329*cdf0e10cSrcweir                         pPrev->mpNext = pNewInfo;
330*cdf0e10cSrcweir                     else
331*cdf0e10cSrcweir                         pData->mpFirst = pNewInfo;
332*cdf0e10cSrcweir                 }
333*cdf0e10cSrcweir             }
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         if ( pData )
337*cdf0e10cSrcweir         {
338*cdf0e10cSrcweir             pData->mnType |= nType;
339*cdf0e10cSrcweir             if ( aFontInfo.GetType() != TYPE_RASTER )
340*cdf0e10cSrcweir                 pData->mnType |= FONTLIST_FONTNAMETYPE_SCALABLE;
341*cdf0e10cSrcweir         }
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir // =======================================================================
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2, sal_Bool bAll ) :
348*cdf0e10cSrcweir     List( 4096, sal::static_int_cast< sal_uInt16 >(pDevice->GetDevFontCount()), 32 )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     // Variablen initialisieren
351*cdf0e10cSrcweir     mpDev = pDevice;
352*cdf0e10cSrcweir     mpDev2 = pDevice2;
353*cdf0e10cSrcweir     mpSizeAry = NULL;
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     // Stylenamen festlegen
356*cdf0e10cSrcweir     maLight         = XubString( SvtResId( STR_SVT_STYLE_LIGHT ) );
357*cdf0e10cSrcweir     maLightItalic   = XubString( SvtResId( STR_SVT_STYLE_LIGHT_ITALIC ) );
358*cdf0e10cSrcweir     maNormal        = XubString( SvtResId( STR_SVT_STYLE_NORMAL ) );
359*cdf0e10cSrcweir     maNormalItalic  = XubString( SvtResId( STR_SVT_STYLE_NORMAL_ITALIC ) );
360*cdf0e10cSrcweir     maBold          = XubString( SvtResId( STR_SVT_STYLE_BOLD ) );
361*cdf0e10cSrcweir     maBoldItalic    = XubString( SvtResId( STR_SVT_STYLE_BOLD_ITALIC ) );
362*cdf0e10cSrcweir     maBlack         = XubString( SvtResId( STR_SVT_STYLE_BLACK ) );
363*cdf0e10cSrcweir     maBlackItalic   = XubString( SvtResId( STR_SVT_STYLE_BLACK_ITALIC ) );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     ImplInsertFonts( pDevice, bAll, sal_True );
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir     // Gegebenenfalls muessen wir mit den Bildschirmfonts vergleichen,
368*cdf0e10cSrcweir     // damit dort die eigentlich doppelten auf Equal mappen koennen
369*cdf0e10cSrcweir     sal_Bool bCompareWindow = sal_False;
370*cdf0e10cSrcweir     if ( !pDevice2 && (pDevice->GetOutDevType() == OUTDEV_PRINTER) )
371*cdf0e10cSrcweir     {
372*cdf0e10cSrcweir         bCompareWindow = sal_True;
373*cdf0e10cSrcweir         pDevice2 = Application::GetDefaultDevice();
374*cdf0e10cSrcweir     }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     if ( pDevice2 &&
377*cdf0e10cSrcweir          (pDevice2->GetOutDevType() != pDevice->GetOutDevType()) )
378*cdf0e10cSrcweir         ImplInsertFonts( pDevice2, bAll, !bCompareWindow );
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir // -----------------------------------------------------------------------
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir FontList::~FontList()
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir     // Gegebenenfalls SizeArray loeschen
386*cdf0e10cSrcweir     if ( mpSizeAry )
387*cdf0e10cSrcweir         delete[] mpSizeAry;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir     // FontInfos loeschen
390*cdf0e10cSrcweir     ImplFontListNameInfo* pData = (ImplFontListNameInfo*)First();
391*cdf0e10cSrcweir     while ( pData )
392*cdf0e10cSrcweir     {
393*cdf0e10cSrcweir         ImplFontListFontInfo* pTemp;
394*cdf0e10cSrcweir         ImplFontListFontInfo* pInfo = pData->mpFirst;
395*cdf0e10cSrcweir         while ( pInfo )
396*cdf0e10cSrcweir         {
397*cdf0e10cSrcweir             pTemp = pInfo->mpNext;
398*cdf0e10cSrcweir             delete pInfo;
399*cdf0e10cSrcweir             pInfo = pTemp;
400*cdf0e10cSrcweir         }
401*cdf0e10cSrcweir         ImplFontListNameInfo* pNext = (ImplFontListNameInfo*)Next();
402*cdf0e10cSrcweir         delete pData;
403*cdf0e10cSrcweir         pData = pNext;
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir // -----------------------------------------------------------------------
407*cdf0e10cSrcweir FontList* FontList::Clone() const
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir     FontList* pReturn = new FontList(
410*cdf0e10cSrcweir             mpDev, mpDev2, GetFontNameCount() == mpDev->GetDevFontCount());
411*cdf0e10cSrcweir     return pReturn;
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir // -----------------------------------------------------------------------
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir const XubString& FontList::GetStyleName( FontWeight eWeight, FontItalic eItalic ) const
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir     if ( eWeight > WEIGHT_BOLD )
419*cdf0e10cSrcweir     {
420*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
421*cdf0e10cSrcweir             return maBlackItalic;
422*cdf0e10cSrcweir         else
423*cdf0e10cSrcweir             return maBlack;
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir     else if ( eWeight > WEIGHT_MEDIUM )
426*cdf0e10cSrcweir     {
427*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
428*cdf0e10cSrcweir             return maBoldItalic;
429*cdf0e10cSrcweir         else
430*cdf0e10cSrcweir             return maBold;
431*cdf0e10cSrcweir     }
432*cdf0e10cSrcweir     else if ( eWeight > WEIGHT_LIGHT )
433*cdf0e10cSrcweir     {
434*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
435*cdf0e10cSrcweir             return maNormalItalic;
436*cdf0e10cSrcweir         else
437*cdf0e10cSrcweir             return maNormal;
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir     else if ( eWeight != WEIGHT_DONTKNOW )
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
442*cdf0e10cSrcweir             return maLightItalic;
443*cdf0e10cSrcweir         else
444*cdf0e10cSrcweir             return maLight;
445*cdf0e10cSrcweir     }
446*cdf0e10cSrcweir     else
447*cdf0e10cSrcweir     {
448*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
449*cdf0e10cSrcweir             return maNormalItalic;
450*cdf0e10cSrcweir         else
451*cdf0e10cSrcweir             return maNormal;
452*cdf0e10cSrcweir     }
453*cdf0e10cSrcweir }
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir // -----------------------------------------------------------------------
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir XubString FontList::GetStyleName( const FontInfo& rInfo ) const
458*cdf0e10cSrcweir {
459*cdf0e10cSrcweir     XubString   aStyleName = rInfo.GetStyleName();
460*cdf0e10cSrcweir     FontWeight  eWeight = rInfo.GetWeight();
461*cdf0e10cSrcweir     FontItalic  eItalic = rInfo.GetItalic();
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     // Nur wenn kein StyleName gesetzt ist, geben wir einen syntetischen
464*cdf0e10cSrcweir     // Namen zurueck
465*cdf0e10cSrcweir     if ( !aStyleName.Len() )
466*cdf0e10cSrcweir         aStyleName = GetStyleName( eWeight, eItalic );
467*cdf0e10cSrcweir     else
468*cdf0e10cSrcweir     {
469*cdf0e10cSrcweir         // Translate StyleName to localized name
470*cdf0e10cSrcweir         XubString aCompareStyleName = aStyleName;
471*cdf0e10cSrcweir         aCompareStyleName.ToLowerAscii();
472*cdf0e10cSrcweir         aCompareStyleName.EraseAllChars( ' ' );
473*cdf0e10cSrcweir         if ( aCompareStyleName.EqualsAscii( "bold" ) )
474*cdf0e10cSrcweir             aStyleName = maBold;
475*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "bolditalic" ) )
476*cdf0e10cSrcweir             aStyleName = maBoldItalic;
477*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "italic" ) )
478*cdf0e10cSrcweir             aStyleName = maNormalItalic;
479*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "standard" ) )
480*cdf0e10cSrcweir             aStyleName = maNormal;
481*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "regular" ) )
482*cdf0e10cSrcweir             aStyleName = maNormal;
483*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "medium" ) )
484*cdf0e10cSrcweir             aStyleName = maNormal;
485*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "light" ) )
486*cdf0e10cSrcweir             aStyleName = maLight;
487*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "lightitalic" ) )
488*cdf0e10cSrcweir             aStyleName = maLightItalic;
489*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "black" ) )
490*cdf0e10cSrcweir             aStyleName = maBlack;
491*cdf0e10cSrcweir         else if ( aCompareStyleName.EqualsAscii( "blackitalic" ) )
492*cdf0e10cSrcweir             aStyleName = maBlackItalic;
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir         // fix up StyleName, because the PS Printer driver from
495*cdf0e10cSrcweir         // W2000 returns wrong StyleNames (e.g. Bold instead of Bold Italic
496*cdf0e10cSrcweir         // for Helvetica)
497*cdf0e10cSrcweir         if ( eItalic > ITALIC_NONE )
498*cdf0e10cSrcweir         {
499*cdf0e10cSrcweir             if ( (aStyleName == maNormal) ||
500*cdf0e10cSrcweir                  (aStyleName == maBold) ||
501*cdf0e10cSrcweir                  (aStyleName == maLight) ||
502*cdf0e10cSrcweir                  (aStyleName == maBlack) )
503*cdf0e10cSrcweir                 aStyleName = GetStyleName( eWeight, eItalic );
504*cdf0e10cSrcweir         }
505*cdf0e10cSrcweir     }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     return aStyleName;
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir // -----------------------------------------------------------------------
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir XubString FontList::GetFontMapText( const FontInfo& rInfo ) const
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir     if ( !rInfo.GetName().Len() )
515*cdf0e10cSrcweir     {
516*cdf0e10cSrcweir         XubString aEmptryStr;
517*cdf0e10cSrcweir         return aEmptryStr;
518*cdf0e10cSrcweir     }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir     // Search Fontname
521*cdf0e10cSrcweir     ImplFontListNameInfo* pData = ImplFindByName( rInfo.GetName() );
522*cdf0e10cSrcweir     if ( !pData )
523*cdf0e10cSrcweir     {
524*cdf0e10cSrcweir         if ( !maMapNotAvailable.Len() )
525*cdf0e10cSrcweir             ((FontList*)this)->maMapNotAvailable = XubString( SvtResId( STR_SVT_FONTMAP_NOTAVAILABLE ) );
526*cdf0e10cSrcweir         return maMapNotAvailable;
527*cdf0e10cSrcweir     }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir     // search for synthetic style
530*cdf0e10cSrcweir     sal_uInt16              nType       = pData->mnType;
531*cdf0e10cSrcweir     const XubString&    rStyleName  = rInfo.GetStyleName();
532*cdf0e10cSrcweir     if ( rStyleName.Len() )
533*cdf0e10cSrcweir     {
534*cdf0e10cSrcweir         sal_Bool                    bNotSynthetic = sal_False;
535*cdf0e10cSrcweir         sal_Bool                    bNoneAvailable = sal_False;
536*cdf0e10cSrcweir         FontWeight              eWeight = rInfo.GetWeight();
537*cdf0e10cSrcweir         FontItalic              eItalic = rInfo.GetItalic();
538*cdf0e10cSrcweir         ImplFontListFontInfo*   pFontInfo = pData->mpFirst;
539*cdf0e10cSrcweir         while ( pFontInfo )
540*cdf0e10cSrcweir         {
541*cdf0e10cSrcweir             if ( (eWeight == pFontInfo->GetWeight()) &&
542*cdf0e10cSrcweir                  (eItalic == pFontInfo->GetItalic()) )
543*cdf0e10cSrcweir             {
544*cdf0e10cSrcweir                 bNotSynthetic = sal_True;
545*cdf0e10cSrcweir                 break;
546*cdf0e10cSrcweir             }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir             pFontInfo = pFontInfo->mpNext;
549*cdf0e10cSrcweir         }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir         if ( bNoneAvailable )
552*cdf0e10cSrcweir         {
553*cdf0e10cSrcweir             XubString aEmptryStr;
554*cdf0e10cSrcweir             return aEmptryStr;
555*cdf0e10cSrcweir         }
556*cdf0e10cSrcweir         else if ( !bNotSynthetic )
557*cdf0e10cSrcweir         {
558*cdf0e10cSrcweir             if ( !maMapStyleNotAvailable.Len() )
559*cdf0e10cSrcweir                 ((FontList*)this)->maMapStyleNotAvailable = XubString( SvtResId( STR_SVT_FONTMAP_STYLENOTAVAILABLE ) );
560*cdf0e10cSrcweir             return maMapStyleNotAvailable;
561*cdf0e10cSrcweir         }
562*cdf0e10cSrcweir     }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir     /* Size not available not implemented yet
565*cdf0e10cSrcweir     if ( !(nType & FONTLIST_FONTNAMETYPE_SCALABLE) )
566*cdf0e10cSrcweir     {
567*cdf0e10cSrcweir         ...
568*cdf0e10cSrcweir         {
569*cdf0e10cSrcweir             if ( !maMapSizeNotAvailable.Len() )
570*cdf0e10cSrcweir                  ((FontList*)this)->maMapSizeNotAvailable = XubString( SvtResId( STR_SVT_FONTMAP_SIZENOTAVAILABLE ) );
571*cdf0e10cSrcweir             return maMapSizeNotAvailable;
572*cdf0e10cSrcweir         }
573*cdf0e10cSrcweir     }
574*cdf0e10cSrcweir     */
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir     // Only Printer-Font?
577*cdf0e10cSrcweir     if ( (nType & (FONTLIST_FONTNAMETYPE_PRINTER | FONTLIST_FONTNAMETYPE_SCREEN)) == FONTLIST_FONTNAMETYPE_PRINTER )
578*cdf0e10cSrcweir     {
579*cdf0e10cSrcweir         if ( !maMapPrinterOnly.Len() )
580*cdf0e10cSrcweir             ((FontList*)this)->maMapPrinterOnly = XubString( SvtResId( STR_SVT_FONTMAP_PRINTERONLY ) );
581*cdf0e10cSrcweir         return maMapPrinterOnly;
582*cdf0e10cSrcweir     }
583*cdf0e10cSrcweir     // Only Screen-Font?
584*cdf0e10cSrcweir     else if ( (nType & (FONTLIST_FONTNAMETYPE_PRINTER | FONTLIST_FONTNAMETYPE_SCREEN)) == FONTLIST_FONTNAMETYPE_SCREEN
585*cdf0e10cSrcweir             && rInfo.GetType() == TYPE_RASTER )
586*cdf0e10cSrcweir     {
587*cdf0e10cSrcweir         if ( !maMapScreenOnly.Len() )
588*cdf0e10cSrcweir             ((FontList*)this)->maMapScreenOnly = XubString( SvtResId( STR_SVT_FONTMAP_SCREENONLY ) );
589*cdf0e10cSrcweir         return maMapScreenOnly;
590*cdf0e10cSrcweir     }
591*cdf0e10cSrcweir     else
592*cdf0e10cSrcweir     {
593*cdf0e10cSrcweir         if ( !maMapBoth.Len() )
594*cdf0e10cSrcweir             ((FontList*)this)->maMapBoth = XubString( SvtResId( STR_SVT_FONTMAP_BOTH ) );
595*cdf0e10cSrcweir         return maMapBoth;
596*cdf0e10cSrcweir     }
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir // -----------------------------------------------------------------------
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir sal_uInt16 FontList::GetFontNameType( const XubString& rFontName ) const
602*cdf0e10cSrcweir {
603*cdf0e10cSrcweir     ImplFontListNameInfo* pData = ImplFindByName( rFontName );
604*cdf0e10cSrcweir     if ( pData )
605*cdf0e10cSrcweir         return pData->mnType;
606*cdf0e10cSrcweir     else
607*cdf0e10cSrcweir         return 0;
608*cdf0e10cSrcweir }
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir // -----------------------------------------------------------------------
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir FontInfo FontList::Get( const XubString& rName, const XubString& rStyleName ) const
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir     ImplFontListNameInfo* pData = ImplFindByName( rName );
615*cdf0e10cSrcweir     ImplFontListFontInfo* pFontInfo = NULL;
616*cdf0e10cSrcweir     ImplFontListFontInfo* pFontNameInfo = NULL;
617*cdf0e10cSrcweir     if ( pData )
618*cdf0e10cSrcweir     {
619*cdf0e10cSrcweir         ImplFontListFontInfo* pSearchInfo = pData->mpFirst;
620*cdf0e10cSrcweir         pFontNameInfo = pSearchInfo;
621*cdf0e10cSrcweir         pSearchInfo = pData->mpFirst;
622*cdf0e10cSrcweir         while ( pSearchInfo )
623*cdf0e10cSrcweir         {
624*cdf0e10cSrcweir             if ( rStyleName.EqualsIgnoreCaseAscii( GetStyleName( *pSearchInfo ) ) )
625*cdf0e10cSrcweir             {
626*cdf0e10cSrcweir                 pFontInfo = pSearchInfo;
627*cdf0e10cSrcweir                 break;
628*cdf0e10cSrcweir             }
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir             pSearchInfo = pSearchInfo->mpNext;
631*cdf0e10cSrcweir         }
632*cdf0e10cSrcweir     }
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir     // Konnten die Daten nicht gefunden werden, dann muessen bestimmte
635*cdf0e10cSrcweir     // Attribute nachgebildet werden
636*cdf0e10cSrcweir     FontInfo aInfo;
637*cdf0e10cSrcweir     if ( !pFontInfo )
638*cdf0e10cSrcweir     {
639*cdf0e10cSrcweir         if ( pFontNameInfo )
640*cdf0e10cSrcweir             aInfo = *pFontNameInfo;
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir         if ( rStyleName == maNormal )
643*cdf0e10cSrcweir         {
644*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NONE );
645*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_NORMAL );
646*cdf0e10cSrcweir         }
647*cdf0e10cSrcweir         else if ( rStyleName == maNormalItalic )
648*cdf0e10cSrcweir         {
649*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NORMAL );
650*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_NORMAL );
651*cdf0e10cSrcweir         }
652*cdf0e10cSrcweir         else if ( rStyleName == maBold )
653*cdf0e10cSrcweir         {
654*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NONE );
655*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_BOLD );
656*cdf0e10cSrcweir         }
657*cdf0e10cSrcweir         else if ( rStyleName == maBoldItalic )
658*cdf0e10cSrcweir         {
659*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NORMAL );
660*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_BOLD );
661*cdf0e10cSrcweir         }
662*cdf0e10cSrcweir         else if ( rStyleName == maLight )
663*cdf0e10cSrcweir         {
664*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NONE );
665*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_LIGHT );
666*cdf0e10cSrcweir         }
667*cdf0e10cSrcweir         else if ( rStyleName == maLightItalic )
668*cdf0e10cSrcweir         {
669*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NORMAL );
670*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_LIGHT );
671*cdf0e10cSrcweir         }
672*cdf0e10cSrcweir         else if ( rStyleName == maBlack )
673*cdf0e10cSrcweir         {
674*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NONE );
675*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_BLACK );
676*cdf0e10cSrcweir         }
677*cdf0e10cSrcweir         else if ( rStyleName == maBlackItalic )
678*cdf0e10cSrcweir         {
679*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NORMAL );
680*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_BLACK );
681*cdf0e10cSrcweir         }
682*cdf0e10cSrcweir         else
683*cdf0e10cSrcweir         {
684*cdf0e10cSrcweir             aInfo.SetItalic( ITALIC_NONE );
685*cdf0e10cSrcweir             aInfo.SetWeight( WEIGHT_DONTKNOW );
686*cdf0e10cSrcweir         }
687*cdf0e10cSrcweir     }
688*cdf0e10cSrcweir     else
689*cdf0e10cSrcweir         aInfo = *pFontInfo;
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir     // set Fontname to keep FontAlias
692*cdf0e10cSrcweir     aInfo.SetName( rName );
693*cdf0e10cSrcweir     aInfo.SetStyleName( rStyleName );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir     return aInfo;
696*cdf0e10cSrcweir }
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir // -----------------------------------------------------------------------
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir FontInfo FontList::Get( const XubString& rName,
701*cdf0e10cSrcweir                         FontWeight eWeight, FontItalic eItalic ) const
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir     ImplFontListNameInfo* pData = ImplFindByName( rName );
704*cdf0e10cSrcweir     ImplFontListFontInfo* pFontInfo = NULL;
705*cdf0e10cSrcweir     ImplFontListFontInfo* pFontNameInfo = NULL;
706*cdf0e10cSrcweir     if ( pData )
707*cdf0e10cSrcweir     {
708*cdf0e10cSrcweir         ImplFontListFontInfo* pSearchInfo = pData->mpFirst;
709*cdf0e10cSrcweir         pFontNameInfo = pSearchInfo;
710*cdf0e10cSrcweir         while ( pSearchInfo )
711*cdf0e10cSrcweir         {
712*cdf0e10cSrcweir             if ( (eWeight == pSearchInfo->GetWeight()) &&
713*cdf0e10cSrcweir                  (eItalic == pSearchInfo->GetItalic()) )
714*cdf0e10cSrcweir             {
715*cdf0e10cSrcweir                 pFontInfo = pSearchInfo;
716*cdf0e10cSrcweir                 break;
717*cdf0e10cSrcweir             }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir             pSearchInfo = pSearchInfo->mpNext;
720*cdf0e10cSrcweir         }
721*cdf0e10cSrcweir     }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir     // Konnten die Daten nicht gefunden werden, dann muessen bestimmte
724*cdf0e10cSrcweir     // Attribute nachgebildet werden
725*cdf0e10cSrcweir     FontInfo aInfo;
726*cdf0e10cSrcweir     if ( !pFontInfo )
727*cdf0e10cSrcweir     {
728*cdf0e10cSrcweir         // Falls der Fontname stimmt, uebernehmen wir soviel wie moeglich
729*cdf0e10cSrcweir         if ( pFontNameInfo )
730*cdf0e10cSrcweir         {
731*cdf0e10cSrcweir             aInfo = *pFontNameInfo;
732*cdf0e10cSrcweir             aInfo.SetStyleName( XubString() );
733*cdf0e10cSrcweir         }
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir         aInfo.SetWeight( eWeight );
736*cdf0e10cSrcweir         aInfo.SetItalic( eItalic );
737*cdf0e10cSrcweir     }
738*cdf0e10cSrcweir     else
739*cdf0e10cSrcweir         aInfo = *pFontInfo;
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir     // set Fontname to keep FontAlias
742*cdf0e10cSrcweir     aInfo.SetName( rName );
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir     return aInfo;
745*cdf0e10cSrcweir }
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir // -----------------------------------------------------------------------
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir sal_Bool FontList::IsAvailable( const XubString& rName ) const
750*cdf0e10cSrcweir {
751*cdf0e10cSrcweir     return (ImplFindByName( rName ) != 0);
752*cdf0e10cSrcweir }
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir // -----------------------------------------------------------------------
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir const FontInfo& FontList::GetFontName( sal_uInt16 nFont ) const
757*cdf0e10cSrcweir {
758*cdf0e10cSrcweir     DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontName(): nFont >= Count" );
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir     ImplFontListNameInfo* pData = (ImplFontListNameInfo*)List::GetObject( nFont );
761*cdf0e10cSrcweir     return *(pData->mpFirst);
762*cdf0e10cSrcweir }
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir // -----------------------------------------------------------------------
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir sal_uInt16 FontList::GetFontNameType( sal_uInt16 nFont ) const
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir     DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontNameType(): nFont >= Count" );
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir     ImplFontListNameInfo* pData = (ImplFontListNameInfo*)List::GetObject( nFont );
771*cdf0e10cSrcweir     return pData->mnType;
772*cdf0e10cSrcweir }
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir // -----------------------------------------------------------------------
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir sal_Handle FontList::GetFirstFontInfo( const XubString& rName ) const
777*cdf0e10cSrcweir {
778*cdf0e10cSrcweir     ImplFontListNameInfo* pData = ImplFindByName( rName );
779*cdf0e10cSrcweir     if ( !pData )
780*cdf0e10cSrcweir         return (sal_Handle)NULL;
781*cdf0e10cSrcweir     else
782*cdf0e10cSrcweir         return (sal_Handle)pData->mpFirst;
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir // -----------------------------------------------------------------------
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir sal_Handle FontList::GetNextFontInfo( sal_Handle hFontInfo ) const
788*cdf0e10cSrcweir {
789*cdf0e10cSrcweir     ImplFontListFontInfo* pInfo = (ImplFontListFontInfo*)(void*)hFontInfo;
790*cdf0e10cSrcweir     return (sal_Handle)(pInfo->mpNext);
791*cdf0e10cSrcweir }
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir // -----------------------------------------------------------------------
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir const FontInfo& FontList::GetFontInfo( sal_Handle hFontInfo ) const
796*cdf0e10cSrcweir {
797*cdf0e10cSrcweir     ImplFontListFontInfo* pInfo = (ImplFontListFontInfo*)(void*)hFontInfo;
798*cdf0e10cSrcweir     return *pInfo;
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir // -----------------------------------------------------------------------
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir const long* FontList::GetSizeAry( const FontInfo& rInfo ) const
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir     // Size-Array vorher loeschen
806*cdf0e10cSrcweir     if ( mpSizeAry )
807*cdf0e10cSrcweir     {
808*cdf0e10cSrcweir         delete[] ((FontList*)this)->mpSizeAry;
809*cdf0e10cSrcweir         ((FontList*)this)->mpSizeAry = NULL;
810*cdf0e10cSrcweir     }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir     // Falls kein Name, dann Standardgroessen
813*cdf0e10cSrcweir     if ( !rInfo.GetName().Len() )
814*cdf0e10cSrcweir         return aStdSizeAry;
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir     // Zuerst nach dem Fontnamen suchen um das Device dann von dem
817*cdf0e10cSrcweir     // entsprechenden Font zu nehmen
818*cdf0e10cSrcweir     OutputDevice*           pDevice = mpDev;
819*cdf0e10cSrcweir     ImplFontListNameInfo*   pData = ImplFindByName( rInfo.GetName() );
820*cdf0e10cSrcweir     if ( pData )
821*cdf0e10cSrcweir         pDevice = pData->mpFirst->GetDevice();
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir     int nDevSizeCount = pDevice->GetDevFontSizeCount( rInfo );
824*cdf0e10cSrcweir     if ( !nDevSizeCount ||
825*cdf0e10cSrcweir          (pDevice->GetDevFontSize( rInfo, 0 ).Height() == 0) )
826*cdf0e10cSrcweir         return aStdSizeAry;
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir     MapMode aOldMapMode = pDevice->GetMapMode();
829*cdf0e10cSrcweir     MapMode aMap( MAP_10TH_INCH, Point(), Fraction( 1, 72 ), Fraction( 1, 72 ) );
830*cdf0e10cSrcweir     pDevice->SetMapMode( aMap );
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir     sal_uInt16  i;
833*cdf0e10cSrcweir     sal_uInt16  nRealCount = 0;
834*cdf0e10cSrcweir     long    nOldHeight = 0;
835*cdf0e10cSrcweir     ((FontList*)this)->mpSizeAry = new long[nDevSizeCount+1];
836*cdf0e10cSrcweir     for ( i = 0; i < nDevSizeCount; i++ )
837*cdf0e10cSrcweir     {
838*cdf0e10cSrcweir         Size aSize = pDevice->GetDevFontSize( rInfo, i );
839*cdf0e10cSrcweir         if ( aSize.Height() != nOldHeight )
840*cdf0e10cSrcweir         {
841*cdf0e10cSrcweir             nOldHeight = aSize.Height();
842*cdf0e10cSrcweir             ((FontList*)this)->mpSizeAry[nRealCount] = nOldHeight;
843*cdf0e10cSrcweir             nRealCount++;
844*cdf0e10cSrcweir         }
845*cdf0e10cSrcweir     }
846*cdf0e10cSrcweir     ((FontList*)this)->mpSizeAry[nRealCount] = 0;
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir     pDevice->SetMapMode( aOldMapMode );
849*cdf0e10cSrcweir     return mpSizeAry;
850*cdf0e10cSrcweir }
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir // -----------------------------------------------------------------------
853*cdf0e10cSrcweir 
854*cdf0e10cSrcweir const long* FontList::GetStdSizeAry()
855*cdf0e10cSrcweir {
856*cdf0e10cSrcweir     return aStdSizeAry;
857*cdf0e10cSrcweir }
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir // =======================================================================
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir // ---------------------------------
862*cdf0e10cSrcweir // - FontSizeNames & FsizeNameItem -
863*cdf0e10cSrcweir // ---------------------------------
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir struct ImplFSNameItem
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir     long        mnSize;
868*cdf0e10cSrcweir     const char* mszUtf8Name;
869*cdf0e10cSrcweir };
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir //------------------------------------------------------------------------
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir static ImplFSNameItem aImplSimplifiedChinese[] =
874*cdf0e10cSrcweir {
875*cdf0e10cSrcweir     {  50, "\xe5\x85\xab\xe5\x8f\xb7" },
876*cdf0e10cSrcweir     {  55, "\xe4\xb8\x83\xe5\x8f\xb7" },
877*cdf0e10cSrcweir     {  65, "\xe5\xb0\x8f\xe5\x85\xad" },
878*cdf0e10cSrcweir     {  75, "\xe5\x85\xad\xe5\x8f\xb7" },
879*cdf0e10cSrcweir     {  90, "\xe5\xb0\x8f\xe4\xba\x94" },
880*cdf0e10cSrcweir     { 105, "\xe4\xba\x94\xe5\x8f\xb7" },
881*cdf0e10cSrcweir     { 120, "\xe5\xb0\x8f\xe5\x9b\x9b" },
882*cdf0e10cSrcweir     { 140, "\xe5\x9b\x9b\xe5\x8f\xb7" },
883*cdf0e10cSrcweir     { 150, "\xe5\xb0\x8f\xe4\xb8\x89" },
884*cdf0e10cSrcweir     { 160, "\xe4\xb8\x89\xe5\x8f\xb7" },
885*cdf0e10cSrcweir     { 180, "\xe5\xb0\x8f\xe4\xba\x8c" },
886*cdf0e10cSrcweir     { 220, "\xe4\xba\x8c\xe5\x8f\xb7" },
887*cdf0e10cSrcweir     { 240, "\xe5\xb0\x8f\xe4\xb8\x80" },
888*cdf0e10cSrcweir     { 260, "\xe4\xb8\x80\xe5\x8f\xb7" },
889*cdf0e10cSrcweir     { 360, "\xe5\xb0\x8f\xe5\x88\x9d" },
890*cdf0e10cSrcweir     { 420, "\xe5\x88\x9d\xe5\x8f\xb7" }
891*cdf0e10cSrcweir };
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir // -----------------------------------------------------------------------
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir #if 0 // #i89077# disabled by popular request
896*cdf0e10cSrcweir static ImplFSNameItem aImplTraditionalChinese[] =
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir     {  50, "\xe5\x85\xab\xe8\x99\x9f" },
899*cdf0e10cSrcweir     {  55, "\xe4\xb8\x83\xe8\x99\x9f" },
900*cdf0e10cSrcweir     {  65, "\xe5\xb0\x8f\xe5\x85\xad" },
901*cdf0e10cSrcweir     {  75, "\xe5\x85\xad\xe8\x99\x9f" },
902*cdf0e10cSrcweir     {  90, "\xe5\xb0\x8f\xe4\xba\x94" },
903*cdf0e10cSrcweir     { 105, "\xe4\xba\x94\xe8\x99\x9f" },
904*cdf0e10cSrcweir     { 120, "\xe5\xb0\x8f\xe5\x9b\x9b" },
905*cdf0e10cSrcweir     { 140, "\xe5\x9b\x9b\xe8\x99\x9f" },
906*cdf0e10cSrcweir     { 150, "\xe5\xb0\x8f\xe4\xb8\x89" },
907*cdf0e10cSrcweir     { 160, "\xe4\xb8\x89\xe8\x99\x9f" },
908*cdf0e10cSrcweir     { 180, "\xe5\xb0\x8f\xe4\xba\x8c" },
909*cdf0e10cSrcweir     { 220, "\xe4\xba\x8c\xe8\x99\x9f" },
910*cdf0e10cSrcweir     { 240, "\xe5\xb0\x8f\xe4\xb8\x80" },
911*cdf0e10cSrcweir     { 260, "\xe4\xb8\x80\xe8\x99\x9f" },
912*cdf0e10cSrcweir     { 360, "\xe5\xb0\x8f\xe5\x88\x9d" },
913*cdf0e10cSrcweir     { 420, "\xe5\x88\x9d\xe8\x99\x9f" }
914*cdf0e10cSrcweir };
915*cdf0e10cSrcweir #endif
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir //------------------------------------------------------------------------
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir FontSizeNames::FontSizeNames( LanguageType eLanguage )
920*cdf0e10cSrcweir {
921*cdf0e10cSrcweir     if ( eLanguage == LANGUAGE_DONTKNOW )
922*cdf0e10cSrcweir         eLanguage = Application::GetSettings().GetUILanguage();
923*cdf0e10cSrcweir     if ( eLanguage == LANGUAGE_SYSTEM )
924*cdf0e10cSrcweir         eLanguage = MsLangId::getSystemUILanguage();
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir     switch( eLanguage )
927*cdf0e10cSrcweir     {
928*cdf0e10cSrcweir         case LANGUAGE_CHINESE:
929*cdf0e10cSrcweir         case LANGUAGE_CHINESE_SIMPLIFIED:
930*cdf0e10cSrcweir             mpArray = aImplSimplifiedChinese;
931*cdf0e10cSrcweir             mnElem = sizeof(aImplSimplifiedChinese) / sizeof(aImplSimplifiedChinese[0]);
932*cdf0e10cSrcweir             break;
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir #if 0 // #i89077# disabled by popular request
935*cdf0e10cSrcweir         case LANGUAGE_CHINESE_HONGKONG:
936*cdf0e10cSrcweir         case LANGUAGE_CHINESE_SINGAPORE:
937*cdf0e10cSrcweir         case LANGUAGE_CHINESE_MACAU:
938*cdf0e10cSrcweir         case LANGUAGE_CHINESE_TRADITIONAL:
939*cdf0e10cSrcweir             mpArray = aImplTraditionalChinese;
940*cdf0e10cSrcweir             mnElem = sizeof(aImplTraditionalChinese) / sizeof(aImplTraditionalChinese[0]);
941*cdf0e10cSrcweir             break;
942*cdf0e10cSrcweir #endif
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir         default:
945*cdf0e10cSrcweir             mpArray = NULL;
946*cdf0e10cSrcweir             mnElem = 0;
947*cdf0e10cSrcweir             break;
948*cdf0e10cSrcweir     };
949*cdf0e10cSrcweir }
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir //------------------------------------------------------------------------
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir long FontSizeNames::Name2Size( const String& rName ) const
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir     if ( mnElem )
956*cdf0e10cSrcweir     {
957*cdf0e10cSrcweir         ByteString aName( rName, RTL_TEXTENCODING_UTF8 );
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir         // linear search is sufficient for this rare case
960*cdf0e10cSrcweir         for( long i = mnElem; --i >= 0; )
961*cdf0e10cSrcweir             if ( aName == mpArray[i].mszUtf8Name )
962*cdf0e10cSrcweir                 return mpArray[i].mnSize;
963*cdf0e10cSrcweir     }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir     return 0;
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir //------------------------------------------------------------------------
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir String FontSizeNames::Size2Name( long nValue ) const
971*cdf0e10cSrcweir {
972*cdf0e10cSrcweir     String aStr;
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir     // binary search
975*cdf0e10cSrcweir     for( long lower = 0, upper = mnElem - 1; lower <= upper; )
976*cdf0e10cSrcweir     {
977*cdf0e10cSrcweir         long mid = (upper + lower) >> 1;
978*cdf0e10cSrcweir         if ( nValue == mpArray[mid].mnSize )
979*cdf0e10cSrcweir         {
980*cdf0e10cSrcweir             aStr = String( mpArray[mid].mszUtf8Name, RTL_TEXTENCODING_UTF8 );
981*cdf0e10cSrcweir             break;
982*cdf0e10cSrcweir         }
983*cdf0e10cSrcweir         else if ( nValue < mpArray[mid].mnSize )
984*cdf0e10cSrcweir             upper = mid - 1;
985*cdf0e10cSrcweir         else /* ( nValue > mpArray[mid].mnSize ) */
986*cdf0e10cSrcweir             lower = mid + 1;
987*cdf0e10cSrcweir     }
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir     return aStr;
990*cdf0e10cSrcweir }
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir //------------------------------------------------------------------------
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir String FontSizeNames::GetIndexName( sal_uLong nIndex ) const
995*cdf0e10cSrcweir {
996*cdf0e10cSrcweir     String aStr;
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir     if ( nIndex < mnElem )
999*cdf0e10cSrcweir         aStr = String( mpArray[nIndex].mszUtf8Name, RTL_TEXTENCODING_UTF8 );
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir     return aStr;
1002*cdf0e10cSrcweir }
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir //------------------------------------------------------------------------
1005*cdf0e10cSrcweir 
1006*cdf0e10cSrcweir long FontSizeNames::GetIndexSize( sal_uLong nIndex ) const
1007*cdf0e10cSrcweir {
1008*cdf0e10cSrcweir     if ( nIndex >= mnElem )
1009*cdf0e10cSrcweir         return 0;
1010*cdf0e10cSrcweir     return mpArray[nIndex].mnSize;
1011*cdf0e10cSrcweir }
1012