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