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 #include <string.h> 32*cdf0e10cSrcweir #include <vcl/svapp.hxx> 33*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx> 34*cdf0e10cSrcweir #include <svtools/ctrltool.hxx> 35*cdf0e10cSrcweir #include <svtools/stdmenu.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir // ======================================================================== 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir FontNameMenu::FontNameMenu() 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir SetMenuFlags( GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); 42*cdf0e10cSrcweir } 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir // ----------------------------------------------------------------------- 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir FontNameMenu::~FontNameMenu() 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir } 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // ----------------------------------------------------------------------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir void FontNameMenu::Select() 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir maCurName = GetItemText( GetCurItemId() ); 55*cdf0e10cSrcweir maSelectHdl.Call( this ); 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // ----------------------------------------------------------------------- 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir void FontNameMenu::Highlight() 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir XubString aTempName = maCurName; 63*cdf0e10cSrcweir maCurName = GetItemText( GetCurItemId() ); 64*cdf0e10cSrcweir maHighlightHdl.Call( this ); 65*cdf0e10cSrcweir maCurName = aTempName; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // ----------------------------------------------------------------------- 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir void FontNameMenu::Fill( const FontList* pList ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir // clear menu 73*cdf0e10cSrcweir Clear(); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // add fonts 76*cdf0e10cSrcweir const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper(); 77*cdf0e10cSrcweir // more than 100 fonts reduces the speed of opening the menu. 78*cdf0e10cSrcweir // So only the first 100 fonts will be displayed. 79*cdf0e10cSrcweir sal_uInt16 nFontCount = ::std::min( pList->GetFontNameCount(), static_cast< sal_uInt16 >(100) ); 80*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nFontCount; i++ ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir const XubString& rName = pList->GetFontName( i ).GetName(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // sort with the I18nHelper 85*cdf0e10cSrcweir sal_uInt16 j = GetItemCount(); 86*cdf0e10cSrcweir while ( j ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir XubString aText = GetItemText( GetItemId( j-1 ) ); 89*cdf0e10cSrcweir if ( rI18nHelper.CompareString( rName, aText ) > 0 ) 90*cdf0e10cSrcweir break; 91*cdf0e10cSrcweir j--; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir InsertItem( i+1, rName, MIB_RADIOCHECK | MIB_AUTOCHECK, j ); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir SetCurName( maCurName ); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir // ----------------------------------------------------------------------- 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir void FontNameMenu::SetCurName( const XubString& rName ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir maCurName = rName; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // Menueintrag checken 106*cdf0e10cSrcweir sal_uInt16 nChecked = 0; 107*cdf0e10cSrcweir sal_uInt16 nItemCount = GetItemCount(); 108*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nItemCount; i++ ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( i ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir if ( IsItemChecked( nItemId ) ) 113*cdf0e10cSrcweir nChecked = nItemId; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir XubString aText = GetItemText( nItemId ); 116*cdf0e10cSrcweir if ( aText == maCurName ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir CheckItem( nItemId, sal_True ); 119*cdf0e10cSrcweir return; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir if ( nChecked ) 124*cdf0e10cSrcweir CheckItem( nChecked, sal_False ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir // ======================================================================== 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir FontStyleMenu::FontStyleMenu() 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir SetMenuFlags( GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // ----------------------------------------------------------------------- 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir FontStyleMenu::~FontStyleMenu() 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // ----------------------------------------------------------------------- 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void FontStyleMenu::Select() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir sal_uInt16 nCurId = GetCurItemId(); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if ( (nCurId >= FONTSTYLEMENU_FIRSTID) && (nCurId <= FONTSTYLEMENU_LASTID) ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir maCurStyle = GetItemText( nCurId ); 149*cdf0e10cSrcweir maSelectHdl.Call( this ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir else 152*cdf0e10cSrcweir PopupMenu::Select(); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // ----------------------------------------------------------------------- 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void FontStyleMenu::Highlight() 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir sal_uInt16 nCurId = GetCurItemId(); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir if ( (nCurId >= FONTSTYLEMENU_FIRSTID) && (nCurId <= FONTSTYLEMENU_LASTID) ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir XubString aTempName = maCurStyle; 164*cdf0e10cSrcweir maCurStyle = GetItemText( nCurId ); 165*cdf0e10cSrcweir maHighlightHdl.Call( this ); 166*cdf0e10cSrcweir maCurStyle = aTempName; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir else 169*cdf0e10cSrcweir PopupMenu::Highlight(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // ----------------------------------------------------------------------- 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir sal_Bool FontStyleMenu::ImplIsAlreadyInserted( const XubString& rStyleName, sal_uInt16 nCount ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; i++ ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if ( GetItemText( i+FONTSTYLEMENU_FIRSTID ) == rStyleName ) 179*cdf0e10cSrcweir return sal_True; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir return sal_False; 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // ----------------------------------------------------------------------- 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir void FontStyleMenu::Fill( const XubString& rName, const FontList* pList ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( 0 ); 190*cdf0e10cSrcweir while ( (nItemId >= FONTSTYLEMENU_FIRSTID) && 191*cdf0e10cSrcweir (nItemId <= FONTSTYLEMENU_LASTID) ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir RemoveItem( 0 ); 194*cdf0e10cSrcweir nItemId = GetItemId( 0 ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir // Existiert ein Font mit diesem Namen 198*cdf0e10cSrcweir sal_Handle hFontInfo = pList->GetFirstFontInfo( rName ); 199*cdf0e10cSrcweir if ( hFontInfo ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir XubString aStyleText; 202*cdf0e10cSrcweir sal_uInt16 nPos = 0; 203*cdf0e10cSrcweir sal_uInt16 nId = FONTSTYLEMENU_FIRSTID; 204*cdf0e10cSrcweir FontWeight eLastWeight = WEIGHT_DONTKNOW; 205*cdf0e10cSrcweir FontItalic eLastItalic = ITALIC_NONE; 206*cdf0e10cSrcweir FontWidth eLastWidth = WIDTH_DONTKNOW; 207*cdf0e10cSrcweir sal_Bool bNormal = sal_False; 208*cdf0e10cSrcweir sal_Bool bItalic = sal_False; 209*cdf0e10cSrcweir sal_Bool bBold = sal_False; 210*cdf0e10cSrcweir sal_Bool bBoldItalic = sal_False; 211*cdf0e10cSrcweir sal_Bool bInsert = sal_False; 212*cdf0e10cSrcweir FontInfo aInfo; 213*cdf0e10cSrcweir while ( hFontInfo ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir aInfo = pList->GetFontInfo( hFontInfo ); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir FontWeight eWeight = aInfo.GetWeight(); 218*cdf0e10cSrcweir FontItalic eItalic = aInfo.GetItalic(); 219*cdf0e10cSrcweir FontWidth eWidth = aInfo.GetWidthType(); 220*cdf0e10cSrcweir // Only if the attributes are different, we insert the 221*cdf0e10cSrcweir // Font to avoid double Entries in different languages 222*cdf0e10cSrcweir if ( (eWeight != eLastWeight) || (eItalic != eLastItalic) || 223*cdf0e10cSrcweir (eWidth != eLastWidth) ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir if ( bInsert ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir InsertItem( nId, aStyleText, 228*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, nPos ); 229*cdf0e10cSrcweir nPos++; 230*cdf0e10cSrcweir nId++; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir if ( eWeight <= WEIGHT_NORMAL ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir if ( eItalic != ITALIC_NONE ) 236*cdf0e10cSrcweir bItalic = sal_True; 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir bNormal = sal_True; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir else 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir if ( eItalic != ITALIC_NONE ) 243*cdf0e10cSrcweir bBoldItalic = sal_True; 244*cdf0e10cSrcweir else 245*cdf0e10cSrcweir bBold = sal_True; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir // For wrong StyleNames we replace this with the correct once 249*cdf0e10cSrcweir aStyleText = pList->GetStyleName( aInfo ); 250*cdf0e10cSrcweir bInsert = !ImplIsAlreadyInserted( aStyleText, nPos ); 251*cdf0e10cSrcweir if ( !bInsert ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir aStyleText = pList->GetStyleName( eWeight, eItalic ); 254*cdf0e10cSrcweir bInsert = !ImplIsAlreadyInserted( aStyleText, nPos ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir eLastWeight = eWeight; 258*cdf0e10cSrcweir eLastItalic = eItalic; 259*cdf0e10cSrcweir eLastWidth = eWidth; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir else 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir if ( bInsert ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir // If we have two names for the same attributes 266*cdf0e10cSrcweir // we prefer the translated standard names 267*cdf0e10cSrcweir const XubString& rAttrStyleText = pList->GetStyleName( eWeight, eItalic ); 268*cdf0e10cSrcweir if ( rAttrStyleText != aStyleText ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir XubString aTempStyleText = pList->GetStyleName( aInfo ); 271*cdf0e10cSrcweir if ( rAttrStyleText == aTempStyleText ) 272*cdf0e10cSrcweir aStyleText = rAttrStyleText; 273*cdf0e10cSrcweir bInsert = !ImplIsAlreadyInserted( aStyleText, nPos ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir if ( !bItalic && (aStyleText == pList->GetItalicStr()) ) 279*cdf0e10cSrcweir bItalic = sal_True; 280*cdf0e10cSrcweir else if ( !bBold && (aStyleText == pList->GetBoldStr()) ) 281*cdf0e10cSrcweir bBold = sal_True; 282*cdf0e10cSrcweir else if ( !bBoldItalic && (aStyleText == pList->GetBoldItalicStr()) ) 283*cdf0e10cSrcweir bBoldItalic = sal_True; 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir hFontInfo = pList->GetNextFontInfo( hFontInfo ); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir if ( bInsert ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir InsertItem( nId, aStyleText, 291*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, nPos ); 292*cdf0e10cSrcweir nPos++; 293*cdf0e10cSrcweir nId++; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir // Bestimmte Styles als Nachbildung 297*cdf0e10cSrcweir if ( bNormal ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if ( !bItalic ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir InsertItem( nId, pList->GetItalicStr(), 302*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, nPos ); 303*cdf0e10cSrcweir nPos++; 304*cdf0e10cSrcweir nId++; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir if ( !bBold ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir InsertItem( nId, pList->GetBoldStr(), 309*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, nPos ); 310*cdf0e10cSrcweir nPos++; 311*cdf0e10cSrcweir nId++; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir if ( !bBoldItalic ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir if ( bNormal || bItalic || bBold ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir InsertItem( nId, pList->GetBoldItalicStr(), 319*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, nPos ); 320*cdf0e10cSrcweir nPos++; 321*cdf0e10cSrcweir nId++; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir else 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir // Wenn Font nicht, dann Standard-Styles einfuegen 328*cdf0e10cSrcweir InsertItem( FONTSTYLEMENU_FIRSTID, pList->GetNormalStr(), 329*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, 0 ); 330*cdf0e10cSrcweir InsertItem( FONTSTYLEMENU_FIRSTID+1, pList->GetItalicStr(), 331*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, 0 ); 332*cdf0e10cSrcweir InsertItem( FONTSTYLEMENU_FIRSTID+2, pList->GetBoldStr(), 333*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, 0 ); 334*cdf0e10cSrcweir InsertItem( FONTSTYLEMENU_FIRSTID+3, pList->GetBoldItalicStr(), 335*cdf0e10cSrcweir MIB_RADIOCHECK | MIB_AUTOCHECK, 0 ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir SetCurStyle( maCurStyle ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir // ----------------------------------------------------------------------- 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir void FontStyleMenu::SetCurStyle( const XubString& rStyle ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir maCurStyle = rStyle; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // Menueintrag checken 348*cdf0e10cSrcweir sal_uInt16 nChecked = 0; 349*cdf0e10cSrcweir sal_uInt16 nItemCount = GetItemCount(); 350*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nItemCount; i++ ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( i ); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if ( (nItemId < FONTSTYLEMENU_FIRSTID) || 355*cdf0e10cSrcweir (nItemId > FONTSTYLEMENU_LASTID) ) 356*cdf0e10cSrcweir break; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if ( IsItemChecked( nItemId ) ) 359*cdf0e10cSrcweir nChecked = nItemId; 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir XubString aText = GetItemText( nItemId ); 362*cdf0e10cSrcweir if ( aText == maCurStyle ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir CheckItem( nItemId, sal_True ); 365*cdf0e10cSrcweir return; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir if ( nChecked ) 370*cdf0e10cSrcweir CheckItem( nChecked, sal_False ); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir // ======================================================================== 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir FontSizeMenu::FontSizeMenu() 376*cdf0e10cSrcweir : mpHeightAry( NULL ) 377*cdf0e10cSrcweir , mnCurHeight( 100 ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir SetMenuFlags( GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir // ----------------------------------------------------------------------- 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir FontSizeMenu::~FontSizeMenu() 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir if ( mpHeightAry ) 387*cdf0e10cSrcweir delete[] mpHeightAry; 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir // ----------------------------------------------------------------------- 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir void FontSizeMenu::Select() 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir const sal_uInt16 nCurItemId = GetCurItemId(); 395*cdf0e10cSrcweir mnCurHeight = mpHeightAry[ nCurItemId - 1 ]; 396*cdf0e10cSrcweir maSelectHdl.Call( this ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir // ----------------------------------------------------------------------- 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir void FontSizeMenu::Highlight() 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir const long nTempHeight = mnCurHeight; 404*cdf0e10cSrcweir const sal_uInt16 nCurItemId = GetCurItemId(); 405*cdf0e10cSrcweir if ( !nCurItemId ) 406*cdf0e10cSrcweir mnCurHeight = 0; 407*cdf0e10cSrcweir else 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir //sal_Int32 nValue = GetItemText( nCurItemId ).ToInt32(); 410*cdf0e10cSrcweir mnCurHeight = mpHeightAry[ nCurItemId - 1 ]; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir maHighlightHdl.Call( this ); 413*cdf0e10cSrcweir mnCurHeight = nTempHeight; 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir // ----------------------------------------------------------------------- 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir void FontSizeMenu::Fill( const FontInfo& rInfo, const FontList* pList ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir Clear(); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir // setup font size array 423*cdf0e10cSrcweir if ( mpHeightAry ) 424*cdf0e10cSrcweir delete[] mpHeightAry; 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir const long* pTempAry; 427*cdf0e10cSrcweir const long* pAry = pList->GetSizeAry( rInfo ); 428*cdf0e10cSrcweir sal_uInt16 nSizeCount = 0; 429*cdf0e10cSrcweir while ( pAry[nSizeCount] ) 430*cdf0e10cSrcweir nSizeCount++; 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir sal_uInt16 nPos = 0; 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // first insert font size names (for simplified/traditional chinese) 435*cdf0e10cSrcweir FontSizeNames aFontSizeNames( Application::GetSettings().GetUILanguage() ); 436*cdf0e10cSrcweir mpHeightAry = new long[nSizeCount+aFontSizeNames.Count()]; 437*cdf0e10cSrcweir if ( !aFontSizeNames.IsEmpty() ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir if ( pAry == pList->GetStdSizeAry() ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir // for scalable fonts all font size names 442*cdf0e10cSrcweir sal_uLong nCount = aFontSizeNames.Count(); 443*cdf0e10cSrcweir for( sal_uLong i = 0; i < nCount; i++ ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir String aSizeName = aFontSizeNames.GetIndexName( i ); 446*cdf0e10cSrcweir long nSize = aFontSizeNames.GetIndexSize( i ); 447*cdf0e10cSrcweir mpHeightAry[nPos] = nSize; 448*cdf0e10cSrcweir nPos++; // Id is nPos+1 449*cdf0e10cSrcweir InsertItem( nPos, aSizeName, MIB_RADIOCHECK | MIB_AUTOCHECK ); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir else 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir // for fixed size fonts only selectable font size names 455*cdf0e10cSrcweir pTempAry = pAry; 456*cdf0e10cSrcweir while ( *pTempAry ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir String aSizeName = aFontSizeNames.Size2Name( *pTempAry ); 459*cdf0e10cSrcweir if ( aSizeName.Len() ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir mpHeightAry[nPos] = *pTempAry; 462*cdf0e10cSrcweir nPos++; // Id is nPos+1 463*cdf0e10cSrcweir InsertItem( nPos, aSizeName, MIB_RADIOCHECK | MIB_AUTOCHECK ); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir pTempAry++; 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir // then insert numerical font size values 471*cdf0e10cSrcweir const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper(); 472*cdf0e10cSrcweir pTempAry = pAry; 473*cdf0e10cSrcweir while ( *pTempAry ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir mpHeightAry[nPos] = *pTempAry; 476*cdf0e10cSrcweir nPos++; // Id is nPos+1 477*cdf0e10cSrcweir InsertItem( nPos, rI18nHelper.GetNum( *pTempAry, 1, sal_True, sal_False ), MIB_RADIOCHECK | MIB_AUTOCHECK ); 478*cdf0e10cSrcweir pTempAry++; 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir SetCurHeight( mnCurHeight ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir // ----------------------------------------------------------------------- 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir void FontSizeMenu::SetCurHeight( long nHeight ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir mnCurHeight = nHeight; 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir // check menue item 491*cdf0e10cSrcweir XubString aHeight = Application::GetSettings().GetUILocaleI18nHelper().GetNum( nHeight, 1, sal_True, sal_False ); 492*cdf0e10cSrcweir sal_uInt16 nChecked = 0; 493*cdf0e10cSrcweir sal_uInt16 nItemCount = GetItemCount(); 494*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nItemCount; i++ ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( i ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir if ( mpHeightAry[i] == nHeight ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir CheckItem( nItemId, sal_True ); 501*cdf0e10cSrcweir return; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir if ( IsItemChecked( nItemId ) ) 505*cdf0e10cSrcweir nChecked = nItemId; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir if ( nChecked ) 509*cdf0e10cSrcweir CheckItem( nChecked, sal_False ); 510*cdf0e10cSrcweir } 511