1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ctrltool.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
38 #ifndef TOOLS_DEBUG_HXX
39 #include <tools/debug.hxx>
41 #include <i18npool/mslangid.hxx>
42 #ifndef _VCL_WINDOW_HXX
43 #include <vcl/window.hxx>
45 #include <vcl/svapp.hxx>
46 #include <vcl/wrkwin.hxx>
48 #include <svtools/svtools.hrc>
49 #include <svtools/svtdata.hxx>
50 #include <ctrltool.hxx>
52 // =======================================================================
54 // Standard Fontgroessen fuer scalierbare Fonts
55 static long aStdSizeAry
[] =
90 // =======================================================================
92 // -----------------------------
93 // - class ImplFontListFonInfo -
94 // -----------------------------
96 class ImplFontListFontInfo
: public FontInfo
98 friend class FontList
;
101 OutputDevice
* mpDevice
;
102 ImplFontListFontInfo
* mpNext
;
105 ImplFontListFontInfo( const FontInfo
& rInfo
,
106 OutputDevice
* pDev
) :
112 OutputDevice
* GetDevice() const { return mpDevice
; }
115 // ------------------------------
116 // - class ImplFontListNameInfo -
117 // ------------------------------
119 class ImplFontListNameInfo
121 friend class FontList
;
124 XubString maSearchName
;
125 ImplFontListFontInfo
* mpFirst
;
128 ImplFontListNameInfo( const XubString
& rSearchName
) :
129 maSearchName( rSearchName
)
132 const XubString
& GetSearchName() const { return maSearchName
; }
135 // =======================================================================
137 static StringCompare
ImplCompareFontInfo( ImplFontListFontInfo
* pInfo1
,
138 ImplFontListFontInfo
* pInfo2
)
140 if ( pInfo1
->GetWeight() < pInfo2
->GetWeight() )
142 else if ( pInfo1
->GetWeight() > pInfo2
->GetWeight() )
143 return COMPARE_GREATER
;
145 if ( pInfo1
->GetItalic() < pInfo2
->GetItalic() )
147 else if ( pInfo1
->GetItalic() > pInfo2
->GetItalic() )
148 return COMPARE_GREATER
;
150 return pInfo1
->GetStyleName().CompareTo( pInfo2
->GetStyleName() );
153 // =======================================================================
155 static void ImplMakeSearchString( XubString
& rStr
)
160 // -----------------------------------------------------------------------
162 static void ImplMakeSearchStringFromName( XubString
& rStr
)
164 // check for features before alternate font separator
165 if (rStr
.Search(':') < rStr
.Search(';'))
166 rStr
= rStr
.GetToken( 0, ':' );
168 rStr
= rStr
.GetToken( 0, ';' );
169 ImplMakeSearchString( rStr
);
172 // -----------------------------------------------------------------------
174 ImplFontListNameInfo
* FontList::ImplFind( const XubString
& rSearchName
, ULONG
* pIndex
) const
176 // Wenn kein Eintrag in der Liste oder der Eintrag groesser ist als
177 // der Letzte, dann hinten dranhaengen. Wir vergleichen erst mit dem
178 // letzten Eintrag, da die Liste von VCL auch sortiert zurueckkommt
179 // und somit die Wahrscheinlichkeit das hinten angehaengt werden muss
182 ULONG nCnt
= Count();
186 *pIndex
= LIST_APPEND
;
191 ImplFontListNameInfo
* pCmpData
= (ImplFontListNameInfo
*)List::GetObject( nCnt
-1 );
192 eComp
= rSearchName
.CompareTo( pCmpData
->maSearchName
);
193 if ( eComp
== COMPARE_GREATER
)
196 *pIndex
= LIST_APPEND
;
199 else if ( eComp
== COMPARE_EQUAL
)
203 // Fonts in der Liste suchen
204 ImplFontListNameInfo
* pCompareData
;
205 ImplFontListNameInfo
* pFoundData
= NULL
;
207 ULONG nHigh
= nCnt
-1;
212 nMid
= (nLow
+ nHigh
) / 2;
213 pCompareData
= (ImplFontListNameInfo
*)List::GetObject( nMid
);
214 eComp
= rSearchName
.CompareTo( pCompareData
->maSearchName
);
215 if ( eComp
== COMPARE_LESS
)
223 if ( eComp
== COMPARE_GREATER
)
227 pFoundData
= pCompareData
;
232 while ( nLow
<= nHigh
);
236 eComp
= rSearchName
.CompareTo( pCompareData
->maSearchName
);
237 if ( eComp
== COMPARE_GREATER
)
246 // -----------------------------------------------------------------------
248 ImplFontListNameInfo
* FontList::ImplFindByName( const XubString
& rStr
) const
250 XubString aSearchName
= rStr
;
251 ImplMakeSearchStringFromName( aSearchName
);
252 return ImplFind( aSearchName
, NULL
);
255 // -----------------------------------------------------------------------
257 void FontList::ImplInsertFonts( OutputDevice
* pDevice
, BOOL bAll
,
260 rtl_TextEncoding eSystemEncoding
= gsl_getSystemTextEncoding();
263 if ( pDevice
->GetOutDevType() != OUTDEV_PRINTER
)
264 nType
= FONTLIST_FONTNAMETYPE_SCREEN
;
266 nType
= FONTLIST_FONTNAMETYPE_PRINTER
;
268 // Alle Fonts vom Device abfragen
269 int n
= pDevice
->GetDevFontCount();
271 for( i
= 0; i
< n
; i
++ )
273 FontInfo aFontInfo
= pDevice
->GetDevFont( i
);
275 // Wenn keine Raster-Schriften angezeigt werden sollen,
276 // dann diese ignorieren
277 if ( !bAll
&& (aFontInfo
.GetType() == TYPE_RASTER
) )
280 XubString aSearchName
= aFontInfo
.GetName();
281 ImplFontListNameInfo
* pData
;
283 ImplMakeSearchString( aSearchName
);
284 pData
= ImplFind( aSearchName
, &nIndex
);
290 ImplFontListFontInfo
* pNewInfo
= new ImplFontListFontInfo( aFontInfo
, pDevice
);
291 pData
= new ImplFontListNameInfo( aSearchName
);
292 pData
->mpFirst
= pNewInfo
;
293 pNewInfo
->mpNext
= NULL
;
295 Insert( (void*)pData
, nIndex
);
303 ImplFontListFontInfo
* pPrev
= NULL
;
304 ImplFontListFontInfo
* pTemp
= pData
->mpFirst
;
305 ImplFontListFontInfo
* pNewInfo
= new ImplFontListFontInfo( aFontInfo
, pDevice
);
308 StringCompare eComp
= ImplCompareFontInfo( pNewInfo
, pTemp
);
309 if ( (eComp
== COMPARE_LESS
) || (eComp
== COMPARE_EQUAL
) )
311 if ( eComp
== COMPARE_EQUAL
)
313 // Overwrite charset, because charset should match
314 // with the system charset
315 if ( (pTemp
->GetCharSet() != eSystemEncoding
) &&
316 (pNewInfo
->GetCharSet() == eSystemEncoding
) )
318 ImplFontListFontInfo
* pTemp2
= pTemp
->mpNext
;
319 *((FontInfo
*)pTemp
) = *((FontInfo
*)pNewInfo
);
320 pTemp
->mpNext
= pTemp2
;
330 pTemp
= pTemp
->mpNext
;
335 pNewInfo
->mpNext
= pTemp
;
337 pPrev
->mpNext
= pNewInfo
;
339 pData
->mpFirst
= pNewInfo
;
346 pData
->mnType
|= nType
;
347 if ( aFontInfo
.GetType() != TYPE_RASTER
)
348 pData
->mnType
|= FONTLIST_FONTNAMETYPE_SCALABLE
;
353 // =======================================================================
355 FontList::FontList( OutputDevice
* pDevice
, OutputDevice
* pDevice2
, BOOL bAll
) :
356 List( 4096, sal::static_int_cast
< USHORT
>(pDevice
->GetDevFontCount()), 32 )
358 // Variablen initialisieren
363 // Stylenamen festlegen
364 maLight
= XubString( SvtResId( STR_SVT_STYLE_LIGHT
) );
365 maLightItalic
= XubString( SvtResId( STR_SVT_STYLE_LIGHT_ITALIC
) );
366 maNormal
= XubString( SvtResId( STR_SVT_STYLE_NORMAL
) );
367 maNormalItalic
= XubString( SvtResId( STR_SVT_STYLE_NORMAL_ITALIC
) );
368 maBold
= XubString( SvtResId( STR_SVT_STYLE_BOLD
) );
369 maBoldItalic
= XubString( SvtResId( STR_SVT_STYLE_BOLD_ITALIC
) );
370 maBlack
= XubString( SvtResId( STR_SVT_STYLE_BLACK
) );
371 maBlackItalic
= XubString( SvtResId( STR_SVT_STYLE_BLACK_ITALIC
) );
373 ImplInsertFonts( pDevice
, bAll
, TRUE
);
375 // Gegebenenfalls muessen wir mit den Bildschirmfonts vergleichen,
376 // damit dort die eigentlich doppelten auf Equal mappen koennen
377 BOOL bCompareWindow
= FALSE
;
378 if ( !pDevice2
&& (pDevice
->GetOutDevType() == OUTDEV_PRINTER
) )
380 bCompareWindow
= TRUE
;
381 pDevice2
= Application::GetDefaultDevice();
385 (pDevice2
->GetOutDevType() != pDevice
->GetOutDevType()) )
386 ImplInsertFonts( pDevice2
, bAll
, !bCompareWindow
);
389 // -----------------------------------------------------------------------
391 FontList::~FontList()
393 // Gegebenenfalls SizeArray loeschen
397 // FontInfos loeschen
398 ImplFontListNameInfo
* pData
= (ImplFontListNameInfo
*)First();
401 ImplFontListFontInfo
* pTemp
;
402 ImplFontListFontInfo
* pInfo
= pData
->mpFirst
;
405 pTemp
= pInfo
->mpNext
;
409 ImplFontListNameInfo
* pNext
= (ImplFontListNameInfo
*)Next();
414 // -----------------------------------------------------------------------
415 FontList
* FontList::Clone() const
417 FontList
* pReturn
= new FontList(
418 mpDev
, mpDev2
, GetFontNameCount() == mpDev
->GetDevFontCount());
422 // -----------------------------------------------------------------------
424 const XubString
& FontList::GetStyleName( FontWeight eWeight
, FontItalic eItalic
) const
426 if ( eWeight
> WEIGHT_BOLD
)
428 if ( eItalic
> ITALIC_NONE
)
429 return maBlackItalic
;
433 else if ( eWeight
> WEIGHT_MEDIUM
)
435 if ( eItalic
> ITALIC_NONE
)
440 else if ( eWeight
> WEIGHT_LIGHT
)
442 if ( eItalic
> ITALIC_NONE
)
443 return maNormalItalic
;
447 else if ( eWeight
!= WEIGHT_DONTKNOW
)
449 if ( eItalic
> ITALIC_NONE
)
450 return maLightItalic
;
456 if ( eItalic
> ITALIC_NONE
)
457 return maNormalItalic
;
463 // -----------------------------------------------------------------------
465 XubString
FontList::GetStyleName( const FontInfo
& rInfo
) const
467 XubString aStyleName
= rInfo
.GetStyleName();
468 FontWeight eWeight
= rInfo
.GetWeight();
469 FontItalic eItalic
= rInfo
.GetItalic();
471 // Nur wenn kein StyleName gesetzt ist, geben wir einen syntetischen
473 if ( !aStyleName
.Len() )
474 aStyleName
= GetStyleName( eWeight
, eItalic
);
477 // Translate StyleName to localized name
478 XubString aCompareStyleName
= aStyleName
;
479 aCompareStyleName
.ToLowerAscii();
480 aCompareStyleName
.EraseAllChars( ' ' );
481 if ( aCompareStyleName
.EqualsAscii( "bold" ) )
483 else if ( aCompareStyleName
.EqualsAscii( "bolditalic" ) )
484 aStyleName
= maBoldItalic
;
485 else if ( aCompareStyleName
.EqualsAscii( "italic" ) )
486 aStyleName
= maNormalItalic
;
487 else if ( aCompareStyleName
.EqualsAscii( "standard" ) )
488 aStyleName
= maNormal
;
489 else if ( aCompareStyleName
.EqualsAscii( "regular" ) )
490 aStyleName
= maNormal
;
491 else if ( aCompareStyleName
.EqualsAscii( "medium" ) )
492 aStyleName
= maNormal
;
493 else if ( aCompareStyleName
.EqualsAscii( "light" ) )
494 aStyleName
= maLight
;
495 else if ( aCompareStyleName
.EqualsAscii( "lightitalic" ) )
496 aStyleName
= maLightItalic
;
497 else if ( aCompareStyleName
.EqualsAscii( "black" ) )
498 aStyleName
= maBlack
;
499 else if ( aCompareStyleName
.EqualsAscii( "blackitalic" ) )
500 aStyleName
= maBlackItalic
;
502 // fix up StyleName, because the PS Printer driver from
503 // W2000 returns wrong StyleNames (e.g. Bold instead of Bold Italic
505 if ( eItalic
> ITALIC_NONE
)
507 if ( (aStyleName
== maNormal
) ||
508 (aStyleName
== maBold
) ||
509 (aStyleName
== maLight
) ||
510 (aStyleName
== maBlack
) )
511 aStyleName
= GetStyleName( eWeight
, eItalic
);
518 // -----------------------------------------------------------------------
520 XubString
FontList::GetFontMapText( const FontInfo
& rInfo
) const
522 if ( !rInfo
.GetName().Len() )
524 XubString aEmptryStr
;
529 ImplFontListNameInfo
* pData
= ImplFindByName( rInfo
.GetName() );
532 if ( !maMapNotAvailable
.Len() )
533 ((FontList
*)this)->maMapNotAvailable
= XubString( SvtResId( STR_SVT_FONTMAP_NOTAVAILABLE
) );
534 return maMapNotAvailable
;
537 // search for synthetic style
538 USHORT nType
= pData
->mnType
;
539 const XubString
& rStyleName
= rInfo
.GetStyleName();
540 if ( rStyleName
.Len() )
542 BOOL bNotSynthetic
= FALSE
;
543 BOOL bNoneAvailable
= FALSE
;
544 FontWeight eWeight
= rInfo
.GetWeight();
545 FontItalic eItalic
= rInfo
.GetItalic();
546 ImplFontListFontInfo
* pFontInfo
= pData
->mpFirst
;
549 if ( (eWeight
== pFontInfo
->GetWeight()) &&
550 (eItalic
== pFontInfo
->GetItalic()) )
552 bNotSynthetic
= TRUE
;
556 pFontInfo
= pFontInfo
->mpNext
;
559 if ( bNoneAvailable
)
561 XubString aEmptryStr
;
564 else if ( !bNotSynthetic
)
566 if ( !maMapStyleNotAvailable
.Len() )
567 ((FontList
*)this)->maMapStyleNotAvailable
= XubString( SvtResId( STR_SVT_FONTMAP_STYLENOTAVAILABLE
) );
568 return maMapStyleNotAvailable
;
572 /* Size not available not implemented yet
573 if ( !(nType & FONTLIST_FONTNAMETYPE_SCALABLE) )
577 if ( !maMapSizeNotAvailable.Len() )
578 ((FontList*)this)->maMapSizeNotAvailable = XubString( SvtResId( STR_SVT_FONTMAP_SIZENOTAVAILABLE ) );
579 return maMapSizeNotAvailable;
584 // Only Printer-Font?
585 if ( (nType
& (FONTLIST_FONTNAMETYPE_PRINTER
| FONTLIST_FONTNAMETYPE_SCREEN
)) == FONTLIST_FONTNAMETYPE_PRINTER
)
587 if ( !maMapPrinterOnly
.Len() )
588 ((FontList
*)this)->maMapPrinterOnly
= XubString( SvtResId( STR_SVT_FONTMAP_PRINTERONLY
) );
589 return maMapPrinterOnly
;
592 else if ( (nType
& (FONTLIST_FONTNAMETYPE_PRINTER
| FONTLIST_FONTNAMETYPE_SCREEN
)) == FONTLIST_FONTNAMETYPE_SCREEN
593 && rInfo
.GetType() == TYPE_RASTER
)
595 if ( !maMapScreenOnly
.Len() )
596 ((FontList
*)this)->maMapScreenOnly
= XubString( SvtResId( STR_SVT_FONTMAP_SCREENONLY
) );
597 return maMapScreenOnly
;
601 if ( !maMapBoth
.Len() )
602 ((FontList
*)this)->maMapBoth
= XubString( SvtResId( STR_SVT_FONTMAP_BOTH
) );
607 // -----------------------------------------------------------------------
609 USHORT
FontList::GetFontNameType( const XubString
& rFontName
) const
611 ImplFontListNameInfo
* pData
= ImplFindByName( rFontName
);
613 return pData
->mnType
;
618 // -----------------------------------------------------------------------
620 FontInfo
FontList::Get( const XubString
& rName
, const XubString
& rStyleName
) const
622 ImplFontListNameInfo
* pData
= ImplFindByName( rName
);
623 ImplFontListFontInfo
* pFontInfo
= NULL
;
624 ImplFontListFontInfo
* pFontNameInfo
= NULL
;
627 ImplFontListFontInfo
* pSearchInfo
= pData
->mpFirst
;
628 pFontNameInfo
= pSearchInfo
;
629 pSearchInfo
= pData
->mpFirst
;
630 while ( pSearchInfo
)
632 if ( rStyleName
.EqualsIgnoreCaseAscii( GetStyleName( *pSearchInfo
) ) )
634 pFontInfo
= pSearchInfo
;
638 pSearchInfo
= pSearchInfo
->mpNext
;
642 // Konnten die Daten nicht gefunden werden, dann muessen bestimmte
643 // Attribute nachgebildet werden
648 aInfo
= *pFontNameInfo
;
650 if ( rStyleName
== maNormal
)
652 aInfo
.SetItalic( ITALIC_NONE
);
653 aInfo
.SetWeight( WEIGHT_NORMAL
);
655 else if ( rStyleName
== maNormalItalic
)
657 aInfo
.SetItalic( ITALIC_NORMAL
);
658 aInfo
.SetWeight( WEIGHT_NORMAL
);
660 else if ( rStyleName
== maBold
)
662 aInfo
.SetItalic( ITALIC_NONE
);
663 aInfo
.SetWeight( WEIGHT_BOLD
);
665 else if ( rStyleName
== maBoldItalic
)
667 aInfo
.SetItalic( ITALIC_NORMAL
);
668 aInfo
.SetWeight( WEIGHT_BOLD
);
670 else if ( rStyleName
== maLight
)
672 aInfo
.SetItalic( ITALIC_NONE
);
673 aInfo
.SetWeight( WEIGHT_LIGHT
);
675 else if ( rStyleName
== maLightItalic
)
677 aInfo
.SetItalic( ITALIC_NORMAL
);
678 aInfo
.SetWeight( WEIGHT_LIGHT
);
680 else if ( rStyleName
== maBlack
)
682 aInfo
.SetItalic( ITALIC_NONE
);
683 aInfo
.SetWeight( WEIGHT_BLACK
);
685 else if ( rStyleName
== maBlackItalic
)
687 aInfo
.SetItalic( ITALIC_NORMAL
);
688 aInfo
.SetWeight( WEIGHT_BLACK
);
692 aInfo
.SetItalic( ITALIC_NONE
);
693 aInfo
.SetWeight( WEIGHT_DONTKNOW
);
699 // set Fontname to keep FontAlias
700 aInfo
.SetName( rName
);
701 aInfo
.SetStyleName( rStyleName
);
706 // -----------------------------------------------------------------------
708 FontInfo
FontList::Get( const XubString
& rName
,
709 FontWeight eWeight
, FontItalic eItalic
) const
711 ImplFontListNameInfo
* pData
= ImplFindByName( rName
);
712 ImplFontListFontInfo
* pFontInfo
= NULL
;
713 ImplFontListFontInfo
* pFontNameInfo
= NULL
;
716 ImplFontListFontInfo
* pSearchInfo
= pData
->mpFirst
;
717 pFontNameInfo
= pSearchInfo
;
718 while ( pSearchInfo
)
720 if ( (eWeight
== pSearchInfo
->GetWeight()) &&
721 (eItalic
== pSearchInfo
->GetItalic()) )
723 pFontInfo
= pSearchInfo
;
727 pSearchInfo
= pSearchInfo
->mpNext
;
731 // Konnten die Daten nicht gefunden werden, dann muessen bestimmte
732 // Attribute nachgebildet werden
736 // Falls der Fontname stimmt, uebernehmen wir soviel wie moeglich
739 aInfo
= *pFontNameInfo
;
740 aInfo
.SetStyleName( XubString() );
743 aInfo
.SetWeight( eWeight
);
744 aInfo
.SetItalic( eItalic
);
749 // set Fontname to keep FontAlias
750 aInfo
.SetName( rName
);
755 // -----------------------------------------------------------------------
757 BOOL
FontList::IsAvailable( const XubString
& rName
) const
759 return (ImplFindByName( rName
) != 0);
762 // -----------------------------------------------------------------------
764 const FontInfo
& FontList::GetFontName( USHORT nFont
) const
766 DBG_ASSERT( nFont
< GetFontNameCount(), "FontList::GetFontName(): nFont >= Count" );
768 ImplFontListNameInfo
* pData
= (ImplFontListNameInfo
*)List::GetObject( nFont
);
769 return *(pData
->mpFirst
);
772 // -----------------------------------------------------------------------
774 USHORT
FontList::GetFontNameType( USHORT nFont
) const
776 DBG_ASSERT( nFont
< GetFontNameCount(), "FontList::GetFontNameType(): nFont >= Count" );
778 ImplFontListNameInfo
* pData
= (ImplFontListNameInfo
*)List::GetObject( nFont
);
779 return pData
->mnType
;
782 // -----------------------------------------------------------------------
784 sal_Handle
FontList::GetFirstFontInfo( const XubString
& rName
) const
786 ImplFontListNameInfo
* pData
= ImplFindByName( rName
);
788 return (sal_Handle
)NULL
;
790 return (sal_Handle
)pData
->mpFirst
;
793 // -----------------------------------------------------------------------
795 sal_Handle
FontList::GetNextFontInfo( sal_Handle hFontInfo
) const
797 ImplFontListFontInfo
* pInfo
= (ImplFontListFontInfo
*)(void*)hFontInfo
;
798 return (sal_Handle
)(pInfo
->mpNext
);
801 // -----------------------------------------------------------------------
803 const FontInfo
& FontList::GetFontInfo( sal_Handle hFontInfo
) const
805 ImplFontListFontInfo
* pInfo
= (ImplFontListFontInfo
*)(void*)hFontInfo
;
809 // -----------------------------------------------------------------------
811 const long* FontList::GetSizeAry( const FontInfo
& rInfo
) const
813 // Size-Array vorher loeschen
816 delete[] ((FontList
*)this)->mpSizeAry
;
817 ((FontList
*)this)->mpSizeAry
= NULL
;
820 // Falls kein Name, dann Standardgroessen
821 if ( !rInfo
.GetName().Len() )
824 // Zuerst nach dem Fontnamen suchen um das Device dann von dem
825 // entsprechenden Font zu nehmen
826 OutputDevice
* pDevice
= mpDev
;
827 ImplFontListNameInfo
* pData
= ImplFindByName( rInfo
.GetName() );
829 pDevice
= pData
->mpFirst
->GetDevice();
831 int nDevSizeCount
= pDevice
->GetDevFontSizeCount( rInfo
);
832 if ( !nDevSizeCount
||
833 (pDevice
->GetDevFontSize( rInfo
, 0 ).Height() == 0) )
836 MapMode aOldMapMode
= pDevice
->GetMapMode();
837 MapMode
aMap( MAP_10TH_INCH
, Point(), Fraction( 1, 72 ), Fraction( 1, 72 ) );
838 pDevice
->SetMapMode( aMap
);
841 USHORT nRealCount
= 0;
843 ((FontList
*)this)->mpSizeAry
= new long[nDevSizeCount
+1];
844 for ( i
= 0; i
< nDevSizeCount
; i
++ )
846 Size aSize
= pDevice
->GetDevFontSize( rInfo
, i
);
847 if ( aSize
.Height() != nOldHeight
)
849 nOldHeight
= aSize
.Height();
850 ((FontList
*)this)->mpSizeAry
[nRealCount
] = nOldHeight
;
854 ((FontList
*)this)->mpSizeAry
[nRealCount
] = 0;
856 pDevice
->SetMapMode( aOldMapMode
);
860 // -----------------------------------------------------------------------
862 const long* FontList::GetStdSizeAry()
867 // =======================================================================
869 // ---------------------------------
870 // - FontSizeNames & FsizeNameItem -
871 // ---------------------------------
873 struct ImplFSNameItem
876 const char* mszUtf8Name
;
879 //------------------------------------------------------------------------
881 static ImplFSNameItem aImplSimplifiedChinese
[] =
883 { 50, "\xe5\x85\xab\xe5\x8f\xb7" },
884 { 55, "\xe4\xb8\x83\xe5\x8f\xb7" },
885 { 65, "\xe5\xb0\x8f\xe5\x85\xad" },
886 { 75, "\xe5\x85\xad\xe5\x8f\xb7" },
887 { 90, "\xe5\xb0\x8f\xe4\xba\x94" },
888 { 105, "\xe4\xba\x94\xe5\x8f\xb7" },
889 { 120, "\xe5\xb0\x8f\xe5\x9b\x9b" },
890 { 140, "\xe5\x9b\x9b\xe5\x8f\xb7" },
891 { 150, "\xe5\xb0\x8f\xe4\xb8\x89" },
892 { 160, "\xe4\xb8\x89\xe5\x8f\xb7" },
893 { 180, "\xe5\xb0\x8f\xe4\xba\x8c" },
894 { 220, "\xe4\xba\x8c\xe5\x8f\xb7" },
895 { 240, "\xe5\xb0\x8f\xe4\xb8\x80" },
896 { 260, "\xe4\xb8\x80\xe5\x8f\xb7" },
897 { 360, "\xe5\xb0\x8f\xe5\x88\x9d" },
898 { 420, "\xe5\x88\x9d\xe5\x8f\xb7" }
901 // -----------------------------------------------------------------------
903 #if 0 // #i89077# disabled by popular request
904 static ImplFSNameItem aImplTraditionalChinese
[] =
906 { 50, "\xe5\x85\xab\xe8\x99\x9f" },
907 { 55, "\xe4\xb8\x83\xe8\x99\x9f" },
908 { 65, "\xe5\xb0\x8f\xe5\x85\xad" },
909 { 75, "\xe5\x85\xad\xe8\x99\x9f" },
910 { 90, "\xe5\xb0\x8f\xe4\xba\x94" },
911 { 105, "\xe4\xba\x94\xe8\x99\x9f" },
912 { 120, "\xe5\xb0\x8f\xe5\x9b\x9b" },
913 { 140, "\xe5\x9b\x9b\xe8\x99\x9f" },
914 { 150, "\xe5\xb0\x8f\xe4\xb8\x89" },
915 { 160, "\xe4\xb8\x89\xe8\x99\x9f" },
916 { 180, "\xe5\xb0\x8f\xe4\xba\x8c" },
917 { 220, "\xe4\xba\x8c\xe8\x99\x9f" },
918 { 240, "\xe5\xb0\x8f\xe4\xb8\x80" },
919 { 260, "\xe4\xb8\x80\xe8\x99\x9f" },
920 { 360, "\xe5\xb0\x8f\xe5\x88\x9d" },
921 { 420, "\xe5\x88\x9d\xe8\x99\x9f" }
925 //------------------------------------------------------------------------
927 FontSizeNames::FontSizeNames( LanguageType eLanguage
)
929 if ( eLanguage
== LANGUAGE_DONTKNOW
)
930 eLanguage
= Application::GetSettings().GetUILanguage();
931 if ( eLanguage
== LANGUAGE_SYSTEM
)
932 eLanguage
= MsLangId::getSystemUILanguage();
936 case LANGUAGE_CHINESE
:
937 case LANGUAGE_CHINESE_SIMPLIFIED
:
938 mpArray
= aImplSimplifiedChinese
;
939 mnElem
= sizeof(aImplSimplifiedChinese
) / sizeof(aImplSimplifiedChinese
[0]);
942 #if 0 // #i89077# disabled by popular request
943 case LANGUAGE_CHINESE_HONGKONG
:
944 case LANGUAGE_CHINESE_SINGAPORE
:
945 case LANGUAGE_CHINESE_MACAU
:
946 case LANGUAGE_CHINESE_TRADITIONAL
:
947 mpArray
= aImplTraditionalChinese
;
948 mnElem
= sizeof(aImplTraditionalChinese
) / sizeof(aImplTraditionalChinese
[0]);
959 //------------------------------------------------------------------------
961 long FontSizeNames::Name2Size( const String
& rName
) const
965 ByteString
aName( rName
, RTL_TEXTENCODING_UTF8
);
967 // linear search is sufficient for this rare case
968 for( long i
= mnElem
; --i
>= 0; )
969 if ( aName
== mpArray
[i
].mszUtf8Name
)
970 return mpArray
[i
].mnSize
;
976 //------------------------------------------------------------------------
978 String
FontSizeNames::Size2Name( long nValue
) const
983 for( long lower
= 0, upper
= mnElem
- 1; lower
<= upper
; )
985 long mid
= (upper
+ lower
) >> 1;
986 if ( nValue
== mpArray
[mid
].mnSize
)
988 aStr
= String( mpArray
[mid
].mszUtf8Name
, RTL_TEXTENCODING_UTF8
);
991 else if ( nValue
< mpArray
[mid
].mnSize
)
993 else /* ( nValue > mpArray[mid].mnSize ) */
1000 //------------------------------------------------------------------------
1002 String
FontSizeNames::GetIndexName( ULONG nIndex
) const
1006 if ( nIndex
< mnElem
)
1007 aStr
= String( mpArray
[nIndex
].mszUtf8Name
, RTL_TEXTENCODING_UTF8
);
1012 //------------------------------------------------------------------------
1014 long FontSizeNames::GetIndexSize( ULONG nIndex
) const
1016 if ( nIndex
>= mnElem
)
1018 return mpArray
[nIndex
].mnSize
;