1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #if !ENABLE_LAYOUT_EXPERIMENTAL 29 //#undef ENABLE_LAYOUT 30 #endif 31 32 // MARKER(update_precomp.py): autogen include statement, do not remove 33 #include "precompiled_cui.hxx" 34 35 // include --------------------------------------------------------------- 36 #include <svl/eitem.hxx> 37 #include <svl/intitem.hxx> 38 #include <sfx2/objsh.hxx> 39 #include <vcl/svapp.hxx> 40 #include <unotools/localedatawrapper.hxx> 41 #include <i18npool/lang.h> 42 #include <svx/dialogs.hrc> 43 #define _SVSTDARR_STRINGS 44 #define _SVSTDARR_STRINGSDTOR 45 #include <svl/svstdarr.hxx> 46 #include <svtools/colorcfg.hxx> 47 48 #define _SVX_NUMFMT_CXX 49 50 #include <cuires.hrc> 51 #include "numfmt.hrc" 52 53 #include <svx/numinf.hxx> 54 55 #include "numfmt.hxx" 56 #include <svx/numfmtsh.hxx> 57 #include <dialmgr.hxx> 58 #include <sfx2/request.hxx> //CHINA001 59 #include <sfx2/app.hxx> //CHINA001 60 #include <sfx2/basedlgs.hxx> 61 #include "svx/flagsdef.hxx" //CHINA001 62 63 #define NUMKEY_UNDEFINED SAL_MAX_UINT32 64 65 // static ---------------------------------------------------------------- 66 67 static sal_uInt16 pRanges[] = 68 { 69 SID_ATTR_NUMBERFORMAT_VALUE, 70 SID_ATTR_NUMBERFORMAT_INFO, 71 SID_ATTR_NUMBERFORMAT_NOLANGUAGE, 72 SID_ATTR_NUMBERFORMAT_NOLANGUAGE, 73 SID_ATTR_NUMBERFORMAT_ONE_AREA, 74 SID_ATTR_NUMBERFORMAT_ONE_AREA, 75 SID_ATTR_NUMBERFORMAT_SOURCE, 76 SID_ATTR_NUMBERFORMAT_SOURCE, 77 0 78 }; 79 80 /************************************************************************* 81 #* Methode: SvxNumberPreviewImpl Datum:02.10.97 82 #*------------------------------------------------------------------------ 83 #* 84 #* Klasse: SvxNumberPreview 85 #* 86 #* Funktion: Konstruktor der Klasse SvxNumberPreviewImpl 87 #* 88 #* Input: Fenster, Resource-ID 89 #* 90 #* Output: --- 91 #* 92 #************************************************************************/ 93 94 SvxNumberPreviewImpl::SvxNumberPreviewImpl( Window* pParent, const ResId& rResId ) : 95 96 Window( pParent, rResId ) 97 98 { 99 Font aFont( GetFont() ); 100 aFont.SetTransparent( sal_True ); 101 aFont.SetColor( Application::GetSettings().GetStyleSettings().GetFieldColor() ); 102 SetFont( aFont ); 103 InitSettings( sal_True, sal_True ); 104 SetBorderStyle( WINDOW_BORDER_MONO ); 105 } 106 107 /************************************************************************* 108 #* Methode: SvxNumberPreviewImpl Datum:02.10.97 109 #*------------------------------------------------------------------------ 110 #* 111 #* Klasse: SvxNumberPreview 112 #* 113 #* Funktion: Destruktor der Klasse SvxNumberPreviewImpl 114 #* 115 #* Input: --- 116 #* 117 #* Output: --- 118 #* 119 #************************************************************************/ 120 121 SvxNumberPreviewImpl::~SvxNumberPreviewImpl() 122 { 123 } 124 125 /************************************************************************* 126 #* Methode: NotifyChange Datum:02.10.97 127 #*------------------------------------------------------------------------ 128 #* 129 #* Klasse: SvxNumberPreviewImpl 130 #* 131 #* Funktion: Funktion fuer das Aendern des Preview- Strings 132 #* 133 #* Input: String, Farbe 134 #* 135 #* Output: --- 136 #* 137 #************************************************************************/ 138 139 void SvxNumberPreviewImpl::NotifyChange( const String& rPrevStr, 140 const Color* pColor ) 141 { 142 aPrevStr = rPrevStr; 143 svtools::ColorConfig aColorConfig; 144 Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 145 aPrevCol = pColor ? *pColor : aWindowTextColor; 146 Invalidate(); 147 Update(); 148 } 149 150 /************************************************************************* 151 #* Methode: Paint Datum:02.10.97 152 #*------------------------------------------------------------------------ 153 #* 154 #* Klasse: SvxNumberPreviewImpl 155 #* 156 #* Funktion: Funktion fuer das neu zeichnen des Fensters. 157 #* 158 #* Input: --- 159 #* 160 #* Output: --- 161 #* 162 #************************************************************************/ 163 164 void SvxNumberPreviewImpl::Paint( const Rectangle& ) 165 { 166 Font aDrawFont = GetFont(); 167 Size aSzWnd = GetOutputSizePixel(); 168 Point aPosText = Point( (aSzWnd.Width() - GetTextWidth( aPrevStr )) /2, 169 (aSzWnd.Height() - GetTextHeight())/2 ); 170 171 aDrawFont.SetColor( aPrevCol ); 172 SetFont( aDrawFont ); 173 DrawText( aPosText, aPrevStr ); 174 } 175 176 // ----------------------------------------------------------------------- 177 178 void SvxNumberPreviewImpl::InitSettings( sal_Bool bForeground, sal_Bool bBackground ) 179 { 180 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 181 182 if ( bForeground ) 183 { 184 svtools::ColorConfig aColorConfig; 185 Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 186 187 if ( IsControlForeground() ) 188 aTextColor = GetControlForeground(); 189 SetTextColor( aTextColor ); 190 } 191 192 if ( bBackground ) 193 { 194 if ( IsControlBackground() ) 195 SetBackground( GetControlBackground() ); 196 else 197 SetBackground( rStyleSettings.GetWindowColor() ); 198 } 199 Invalidate(); 200 } 201 202 // ----------------------------------------------------------------------- 203 204 void SvxNumberPreviewImpl::StateChanged( StateChangedType nType ) 205 { 206 if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 207 InitSettings( sal_True, sal_False ); 208 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 209 InitSettings( sal_False, sal_True ); 210 211 Window::StateChanged( nType ); 212 } 213 214 // ----------------------------------------------------------------------- 215 216 void SvxNumberPreviewImpl::DataChanged( const DataChangedEvent& rDCEvt ) 217 { 218 Window::DataChanged( rDCEvt ); 219 220 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 221 InitSettings( sal_True, sal_True ); 222 } 223 224 // class SvxNumberFormatTabPage ------------------------------------------ 225 226 #define REMOVE_DONTKNOW() \ 227 if ( !aFtLanguage.IsEnabled() ) \ 228 { \ 229 aFtLanguage .Enable(); \ 230 aLbLanguage .Enable(); \ 231 aLbLanguage .SelectLanguage( pNumFmtShell->GetCurLanguage() ); \ 232 } 233 234 #define HDL(hdl) LINK( this, SvxNumberFormatTabPage, hdl ) 235 236 #include <layout/layout-pre.hxx> 237 238 #if ENABLE_LAYOUT 239 #undef CUI_RES 240 #define CUI_RES(x) #x 241 #define CUI_RES_PLAIN(x) ResId (x, CUI_MGR ()) 242 #define THIS_CUI_RES(x) this, #x 243 #undef SfxTabPage 244 #define SfxTabPage( parent, id, args ) SfxTabPage( parent, "number-format.xml", id, &args ) 245 #else /* !ENABLE_LAYOUT */ 246 #define CUI_RES_PLAIN CUI_RES 247 #define THIS_CUI_RES CUI_RES 248 #endif /* !ENABLE_LAYOUT */ 249 250 SvxNumberFormatTabPage::SvxNumberFormatTabPage( Window* pParent, 251 const SfxItemSet& rCoreAttrs ) 252 253 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_NUMBERFORMAT ), rCoreAttrs ), 254 255 aFtCategory ( this, CUI_RES( FT_CATEGORY ) ), 256 aLbCategory ( this, CUI_RES( LB_CATEGORY ) ), 257 aFtFormat ( this, CUI_RES( FT_FORMAT ) ), 258 aLbCurrency ( this, CUI_RES( LB_CURRENCY) ), 259 aLbFormat ( this, CUI_RES( LB_FORMAT ) ), 260 aFtLanguage ( this, CUI_RES( FT_LANGUAGE ) ), 261 aLbLanguage ( this, CUI_RES( LB_LANGUAGE ), sal_False ), 262 aCbSourceFormat ( this, CUI_RES( CB_SOURCEFORMAT ) ), 263 #if ENABLE_LAYOUT 264 aWndPreview ( LAYOUT_THIS_WINDOW(this), CUI_RES_PLAIN( WND_NUMBER_PREVIEW ) ), 265 #else 266 aWndPreview ( this, CUI_RES_PLAIN( WND_NUMBER_PREVIEW ) ), 267 #endif 268 aFlOptions ( this, CUI_RES( FL_OPTIONS ) ), 269 aFtDecimals ( this, CUI_RES( FT_DECIMALS ) ), 270 aEdDecimals ( this, CUI_RES( ED_DECIMALS ) ), 271 aBtnNegRed ( this, CUI_RES( BTN_NEGRED ) ), 272 aFtLeadZeroes ( this, CUI_RES( FT_LEADZEROES ) ), 273 aEdLeadZeroes ( this, CUI_RES( ED_LEADZEROES ) ), 274 aBtnThousand ( this, CUI_RES( BTN_THOUSAND ) ), 275 276 aFtEdFormat ( this, CUI_RES( FT_EDFORMAT ) ), 277 aEdFormat ( this, CUI_RES( ED_FORMAT ) ), 278 aIbAdd ( this, CUI_RES( IB_ADD ) ), 279 aIbInfo ( this, CUI_RES( IB_INFO ) ), 280 aIbRemove ( this, CUI_RES( IB_REMOVE ) ), 281 aFtComment ( this, CUI_RES( FT_COMMENT ) ), 282 aEdComment ( this, CUI_RES( ED_COMMENT ) ), 283 284 pNumItem ( NULL ), 285 pNumFmtShell ( NULL ), 286 nInitFormat ( ULONG_MAX ), 287 288 sAutomaticEntry ( THIS_CUI_RES( STR_AUTO_ENTRY)), 289 pLastActivWindow( NULL ) 290 { 291 #if ENABLE_LAYOUT 292 aLbFormat.Clear (); 293 #endif /* ENABLE_LAYOUT */ 294 295 Init_Impl(); 296 SetExchangeSupport(); // diese Page braucht ExchangeSupport 297 FreeResource(); 298 nFixedCategory=-1; 299 } 300 301 SvxNumberFormatTabPage::~SvxNumberFormatTabPage() 302 { 303 delete pNumFmtShell; 304 delete pNumItem; 305 } 306 307 void SvxNumberFormatTabPage::Init_Impl() 308 { 309 ImageList aIconList( CUI_RES_PLAIN ( IL_ICON ) ); 310 ImageList aIconListHC( CUI_RES_PLAIN ( IL_ICON_HC ) ); 311 312 bNumItemFlag=sal_True; 313 bOneAreaFlag=sal_False; 314 315 nCatHeight=aLbCategory.GetSizePixel().Height(); 316 317 nCurFormatY =aLbFormat.GetPosPixel().Y(); 318 nCurFormatHeight=aLbFormat.GetSizePixel().Height(); 319 nStdFormatY =aLbCurrency.GetPosPixel().Y(); 320 nStdFormatHeight=nCurFormatY-nStdFormatY+nCurFormatHeight; 321 322 aIbAdd. SetModeImage( aIconList.GetImage( IID_ADD ) ); 323 aIbAdd. SetModeImage( aIconListHC.GetImage( IID_ADD ), BMP_COLOR_HIGHCONTRAST ); 324 325 aIbRemove. SetModeImage( aIconList.GetImage( IID_REMOVE ) ); 326 aIbRemove. SetModeImage( aIconListHC.GetImage( IID_REMOVE ), BMP_COLOR_HIGHCONTRAST ); 327 328 aIbInfo. SetModeImage( aIconList.GetImage( IID_INFO ) ); 329 aIbInfo. SetModeImage( aIconListHC.GetImage( IID_INFO ), BMP_COLOR_HIGHCONTRAST ); 330 331 aIbAdd.Enable(sal_False ); 332 aIbRemove.Enable(sal_False ); 333 aIbInfo.Enable(sal_False ); 334 335 aEdComment.SetText(aLbCategory.GetEntry(1)); //String fuer Benutzerdefiniert 336 //holen 337 aEdComment.Hide(); 338 339 aCbSourceFormat.Check( sal_False ); 340 aCbSourceFormat.Disable(); 341 aCbSourceFormat.Hide(); 342 343 // Handler verbinden 344 Link aLink = LINK( this, SvxNumberFormatTabPage, SelFormatHdl_Impl ); 345 346 aLbCategory .SetSelectHdl( aLink ); 347 aLbFormat .SetSelectHdl( aLink ); 348 aLbLanguage .SetSelectHdl( aLink ); 349 aLbCurrency .SetSelectHdl( aLink ); 350 aCbSourceFormat .SetClickHdl( aLink ); 351 352 aLink = LINK( this, SvxNumberFormatTabPage, OptHdl_Impl ); 353 354 aEdDecimals .SetModifyHdl( aLink ); 355 aEdLeadZeroes .SetModifyHdl( aLink ); 356 aBtnNegRed .SetClickHdl( aLink ); 357 aBtnThousand .SetClickHdl( aLink ); 358 aLbFormat .SetDoubleClickHdl( HDL( DoubleClickHdl_Impl ) ); 359 aEdFormat .SetModifyHdl( HDL( EditHdl_Impl ) ); 360 aIbAdd.SetClickHdl( HDL( ClickHdl_Impl ) ); 361 aIbRemove.SetClickHdl( HDL( ClickHdl_Impl ) ); 362 aIbInfo.SetClickHdl( HDL( ClickHdl_Impl ) ); 363 364 aLink = LINK( this, SvxNumberFormatTabPage, LostFocusHdl_Impl); 365 366 aEdComment .SetLoseFocusHdl( aLink); 367 aResetWinTimer .SetTimeoutHdl(LINK( this, SvxNumberFormatTabPage, TimeHdl_Impl)); 368 aResetWinTimer .SetTimeout( 10); 369 370 // Sprachen-ListBox initialisieren 371 372 aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM ); 373 // Don't list ambiguous locales where we won't be able to convert the 374 // LanguageType back to an identical Language_Country name and therefore 375 // couldn't load the i18n LocaleData. Show DebugMsg in non-PRODUCT version. 376 ::com::sun::star::uno::Sequence< sal_uInt16 > xLang = 377 LocaleDataWrapper::getInstalledLanguageTypes(); 378 sal_Int32 nCount = xLang.getLength(); 379 for ( sal_Int32 i=0; i<nCount; i++ ) 380 { 381 aLbLanguage.InsertLanguage( xLang[i] ); 382 } 383 384 aIbAdd.SetAccessibleRelationLabeledBy( &aFtEdFormat ); 385 aIbInfo.SetAccessibleRelationLabeledBy( &aFtEdFormat ); 386 aIbRemove.SetAccessibleRelationLabeledBy( &aFtEdFormat ); 387 aIbAdd.SetAccessibleRelationMemberOf( &aIbAdd ); 388 aIbInfo.SetAccessibleRelationMemberOf( &aIbInfo ); 389 aIbRemove.SetAccessibleRelationMemberOf( &aIbRemove ); 390 } 391 392 /************************************************************************* 393 #* Methode: GetRanges Datum:02.10.97 394 #*------------------------------------------------------------------------ 395 #* 396 #* Klasse: SvxNumberFormatTabPage 397 #* 398 #* Funktion: Liefert Bereichsangaben zurueck. 399 #* 400 #* Input: --- 401 #* 402 #* Output: Bereich 403 #* 404 #************************************************************************/ 405 406 sal_uInt16* SvxNumberFormatTabPage::GetRanges() 407 { 408 return pRanges; 409 } 410 411 412 /************************************************************************* 413 #* Methode: Create Datum:02.10.97 414 #*------------------------------------------------------------------------ 415 #* 416 #* Klasse: SvxNumberFormatTabPage 417 #* 418 #* Funktion: Erzeugt eine neue Zahlenformat- Seite. 419 #* 420 #* Input: Fenster, SfxItemSet 421 #* 422 #* Output: neue TabPage 423 #* 424 #************************************************************************/ 425 426 SfxTabPage* SvxNumberFormatTabPage::Create( Window* pParent, 427 const SfxItemSet& rAttrSet ) 428 { 429 return ( new SvxNumberFormatTabPage( pParent, rAttrSet ) ); 430 } 431 432 433 /************************************************************************* 434 #* Methode: Reset Datum:02.10.97 435 #*------------------------------------------------------------------------ 436 #* 437 #* Klasse: SvxNumberFormatTabPage 438 #* 439 #* Funktion: Die Attribute des Dialogs werden mit Hilfe 440 #* des Itemsets neu eingestellt. 441 #* 442 #* Input: SfxItemSet 443 #* 444 #* Output: --- 445 #* 446 #************************************************************************/ 447 448 void SvxNumberFormatTabPage::Reset( const SfxItemSet& rSet ) 449 { 450 const SfxUInt32Item* pValFmtAttr = NULL; 451 const SfxPoolItem* pItem = NULL; 452 const SfxBoolItem* pAutoEntryAttr = NULL; 453 454 sal_uInt16 nCatLbSelPos = 0; 455 sal_uInt16 nFmtLbSelPos = 0; 456 LanguageType eLangType = LANGUAGE_DONTKNOW; 457 SvxDelStrgs aFmtEntryList; 458 SvxNumberValueType eValType = SVX_VALUE_TYPE_UNDEFINED; 459 double nValDouble = 0; 460 String aValString; 461 SfxItemState eState = SFX_ITEM_DONTCARE; 462 463 464 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_NOLANGUAGE ),sal_True,&pItem); 465 466 if(eState==SFX_ITEM_SET) 467 { 468 const SfxBoolItem* pBoolLangItem = (const SfxBoolItem*) 469 GetItem( rSet, SID_ATTR_NUMBERFORMAT_NOLANGUAGE); 470 471 if(pBoolLangItem!=NULL && pBoolLangItem->GetValue()) 472 { 473 HideLanguage(); 474 } 475 else 476 { 477 HideLanguage(sal_False); 478 } 479 480 } 481 482 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),sal_True,&pItem); 483 484 if(eState==SFX_ITEM_SET) 485 { 486 if(pNumItem==NULL) 487 { 488 bNumItemFlag=sal_True; 489 pNumItem= (SvxNumberInfoItem *) pItem->Clone(); 490 } 491 else 492 { 493 bNumItemFlag=sal_False; 494 } 495 } 496 else 497 { 498 bNumItemFlag=sal_False; 499 } 500 501 502 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ONE_AREA )); 503 504 if(eState==SFX_ITEM_SET) 505 { 506 const SfxBoolItem* pBoolItem = (const SfxBoolItem*) 507 GetItem( rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA); 508 509 if(pBoolItem!=NULL) 510 { 511 bOneAreaFlag= pBoolItem->GetValue(); 512 } 513 } 514 //bOneAreaFlag=sal_True; //@@ Debug-Test 515 516 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ) ); 517 518 if ( eState == SFX_ITEM_SET ) 519 { 520 const SfxBoolItem* pBoolItem = (const SfxBoolItem*) 521 GetItem( rSet, SID_ATTR_NUMBERFORMAT_SOURCE ); 522 if ( pBoolItem ) 523 aCbSourceFormat.Check( pBoolItem->GetValue() ); 524 else 525 aCbSourceFormat.Check( sal_False ); 526 aCbSourceFormat.Enable(); 527 aCbSourceFormat.Show(); 528 } 529 else 530 { 531 sal_Bool bInit = sal_False; // set to sal_True for debug test 532 aCbSourceFormat.Check( bInit ); 533 aCbSourceFormat.Enable( bInit ); 534 aCbSourceFormat.Show( bInit ); 535 } 536 537 // pNumItem muss von aussen gesetzt worden sein! 538 DBG_ASSERT( pNumItem, "No NumberInfo, no NumberFormatter, good bye.CRASH. :-(" ); 539 540 // aktuellen Zahlenformat-Tabellenindex holen 541 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ) ); 542 543 if ( SFX_ITEM_DONTCARE != eState ) 544 pValFmtAttr = (const SfxUInt32Item*) 545 GetItem( rSet, SID_ATTR_NUMBERFORMAT_VALUE ); 546 547 eValType = pNumItem->GetValueType(); 548 549 switch ( eValType ) 550 { 551 case SVX_VALUE_TYPE_STRING: 552 aValString = pNumItem->GetValueString(); 553 break; 554 case SVX_VALUE_TYPE_NUMBER: 555 // #50441# string may be set in addition to the value 556 aValString = pNumItem->GetValueString(); 557 nValDouble = pNumItem->GetValueDouble(); 558 break; 559 case SVX_VALUE_TYPE_UNDEFINED: 560 default: 561 break; 562 } 563 564 // nun sind alle Informationen fuer die Formatierer-Shell beisammen: 565 566 if ( pNumFmtShell ) 567 delete pNumFmtShell; // ggF. alte Shell loeschen (==Reset) 568 569 nInitFormat = ( pValFmtAttr ) // Init-Key merken 570 ? pValFmtAttr->GetValue() // (fuer FillItemSet()) 571 : ULONG_MAX; // == DONT_KNOW 572 573 574 if ( eValType == SVX_VALUE_TYPE_STRING ) 575 pNumFmtShell =SvxNumberFormatShell::Create( 576 pNumItem->GetNumberFormatter(), 577 (pValFmtAttr) ? nInitFormat : 0L, 578 eValType, 579 aValString ); 580 else 581 pNumFmtShell =SvxNumberFormatShell::Create( 582 pNumItem->GetNumberFormatter(), 583 (pValFmtAttr) ? nInitFormat : 0L, 584 eValType, 585 nValDouble, 586 &aValString ); 587 588 FillCurrencyBox(); 589 590 String aPrevString; 591 Color* pDummy = NULL; 592 pNumFmtShell->GetInitSettings( nCatLbSelPos, eLangType, nFmtLbSelPos, 593 aFmtEntryList, aPrevString, pDummy ); 594 595 aLbCurrency.SelectEntryPos((sal_uInt16)pNumFmtShell->GetCurrencySymbol()); 596 597 nFixedCategory=nCatLbSelPos; 598 if(bOneAreaFlag) 599 { 600 String sFixedCategory=aLbCategory.GetEntry(nFixedCategory); 601 aLbCategory.Clear(); 602 aLbCategory.InsertEntry(sFixedCategory); 603 SetCategory(0); 604 } 605 else 606 { 607 SetCategory(nCatLbSelPos ); 608 } 609 eState = rSet.GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ADD_AUTO ) ); 610 if(SFX_ITEM_SET == eState) 611 pAutoEntryAttr = (const SfxBoolItem*) 612 GetItem( rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO ); 613 // no_NO is an alias for nb_NO and normally isn't listed, we need it for 614 // backwards compatibility, but only if the format passed is of 615 // LanguageType no_NO. 616 if ( eLangType == LANGUAGE_NORWEGIAN ) 617 { 618 aLbLanguage.RemoveLanguage( eLangType ); // in case we're already called 619 aLbLanguage.InsertLanguage( eLangType ); 620 } 621 aLbLanguage.SelectLanguage( eLangType ); 622 if(pAutoEntryAttr) 623 AddAutomaticLanguage_Impl(eLangType, pAutoEntryAttr->GetValue()); 624 UpdateFormatListBox_Impl(sal_False,sal_True); 625 626 //! erAck 26.01.01 627 //! This spoils everything because it rematches currency formats based on 628 //! the selected aLbCurrency entry instead of the current format. 629 //! Besides that everything seems to be initialized by now, so why call it? 630 // SelFormatHdl_Impl( &aLbCategory ); 631 632 if ( pValFmtAttr ) 633 { 634 EditHdl_Impl( &aEdFormat ); // UpdateOptions_Impl() als Seiteneffekt 635 } 636 else // DONT_KNOW 637 { 638 // Kategoriewechsel und direkte Eingabe sind moeglich, sonst nix: 639 Obstructing(); 640 } 641 642 if ( aCbSourceFormat.IsChecked() ) 643 { 644 // everything disabled except SourceFormat checkbox 645 EnableBySourceFormat_Impl(); 646 } 647 648 DeleteEntryList_Impl(aFmtEntryList); 649 } 650 651 /************************************************************************* 652 #* Methode: Obstructing Datum:02.10.97 653 #*------------------------------------------------------------------------ 654 #* 655 #* Klasse: SvxNumberFormatTabPage 656 #* 657 #* Funktion: Sperren der Controls mit Ausnahme von Kategoriewechsel 658 #* und direkter Eingabe. 659 #* 660 #* Input: --- 661 #* 662 #* Output: --- 663 #* 664 #************************************************************************/ 665 void SvxNumberFormatTabPage::Obstructing() 666 { 667 aLbFormat .SetNoSelection(); 668 aLbLanguage .SetNoSelection(); 669 aFtLanguage .Disable(); 670 aLbLanguage .Disable(); 671 672 aIbAdd.Enable(sal_False ); 673 aIbRemove.Enable(sal_False ); 674 aIbInfo.Enable(sal_False ); 675 676 aBtnNegRed .Disable(); 677 aBtnThousand .Disable(); 678 aFtLeadZeroes .Disable(); 679 aFtDecimals .Disable(); 680 aEdLeadZeroes .Disable(); 681 aEdDecimals .Disable(); 682 aFlOptions .Disable(); 683 aEdDecimals .SetText( String() ); 684 aEdLeadZeroes .SetText( String() ); 685 aBtnNegRed .Check( sal_False ); 686 aBtnThousand .Check( sal_False ); 687 aWndPreview .NotifyChange( String() ); 688 689 aLbCategory .SelectEntryPos( 0 ); 690 aEdFormat .SetText( String() ); 691 aFtComment .SetText( String() ); 692 aEdComment .SetText(aLbCategory.GetEntry(1)); //String fuer Benutzerdefiniert 693 //holen 694 695 aEdFormat .GrabFocus(); 696 } 697 698 699 /************************************************************************* 700 #* Enable/Disable dialog parts depending on the value of the SourceFormat 701 #* checkbox. 702 #************************************************************************/ 703 void SvxNumberFormatTabPage::EnableBySourceFormat_Impl() 704 { 705 sal_Bool bEnable = !aCbSourceFormat.IsChecked(); 706 if ( !bEnable ) 707 aCbSourceFormat.GrabFocus(); 708 aFtCategory .Enable( bEnable ); 709 aLbCategory .Enable( bEnable ); 710 aFtFormat .Enable( bEnable ); 711 aLbCurrency .Enable( bEnable ); 712 aLbFormat .Enable( bEnable ); 713 aFtLanguage .Enable( bEnable ); 714 aLbLanguage .Enable( bEnable ); 715 aFtDecimals .Enable( bEnable ); 716 aEdDecimals .Enable( bEnable ); 717 aFtLeadZeroes .Enable( bEnable ); 718 aEdLeadZeroes .Enable( bEnable ); 719 aBtnNegRed .Enable( bEnable ); 720 aBtnThousand .Enable( bEnable ); 721 aFlOptions .Enable( bEnable ); 722 aFtEdFormat .Enable( bEnable ); 723 aEdFormat .Enable( bEnable ); 724 aIbAdd .Enable( bEnable ); 725 aIbRemove .Enable( bEnable ); 726 aIbInfo .Enable( bEnable ); 727 aFtComment .Enable( bEnable ); 728 aEdComment .Enable( bEnable ); 729 aLbFormat.Invalidate(); // #i43322# 730 } 731 732 733 /************************************************************************* 734 #* Methode: HideLanguage Datum:14.05.98 735 #*------------------------------------------------------------------------ 736 #* 737 #* Klasse: SvxNumberFormatTabPage 738 #* 739 #* Funktion: Versteckt die Spracheinstellung: 740 #* 741 #* Input: sal_Bool nFlag 742 #* 743 #* Output: --- 744 #* 745 #************************************************************************/ 746 747 void SvxNumberFormatTabPage::HideLanguage(sal_Bool nFlag) 748 { 749 Size aSize=aLbCategory.GetSizePixel(); 750 751 if(nFlag) 752 { 753 aSize.Height()=aLbFormat.GetSizePixel().Height(); 754 } 755 else 756 { 757 aSize.Height()=nCatHeight; 758 } 759 760 aLbCategory.SetSizePixel(aSize); 761 762 aFtLanguage.Show(!nFlag); 763 aLbLanguage.Show(!nFlag); 764 } 765 766 /************************************************************************* 767 #* Methode: FillItemSet Datum:02.10.97 768 #*------------------------------------------------------------------------ 769 #* 770 #* Klasse: SvxNumberFormatTabPage 771 #* 772 #* Funktion: Stellt die Attribute im ItemSet ein, 773 #* sowie in der DocShell den numItem, wenn 774 #* bNumItemFlag nicht gesetzt ist. 775 #* 776 #* Input: SfxItemSet 777 #* 778 #* Output: --- 779 #* 780 #************************************************************************/ 781 782 sal_Bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs ) 783 { 784 sal_Bool bDataChanged = aFtLanguage.IsEnabled() || aCbSourceFormat.IsEnabled(); 785 if ( bDataChanged ) 786 { 787 const SfxItemSet& rMyItemSet = GetItemSet(); 788 sal_uInt16 nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); 789 SfxItemState eItemState = rMyItemSet.GetItemState( nWhich, sal_False ); 790 791 // OK chosen - Is format code input entered already taken over? 792 // If not, simulate Add. Upon syntax error ignore input and prevent Put. 793 String aFormat = aEdFormat.GetText(); 794 sal_uInt32 nCurKey = pNumFmtShell->GetCurNumFmtKey(); 795 796 if ( aIbAdd.IsEnabled() || pNumFmtShell->IsTmpCurrencyFormat(aFormat) ) 797 { // #79599# It is not sufficient to just add the format code (or 798 // delete it in case of bOneAreaFlag and resulting category change). 799 // Upon switching tab pages we need all settings to be consistent 800 // in case this page will be redisplayed later. 801 bDataChanged = (ClickHdl_Impl( &aIbAdd ) != 0); 802 nCurKey = pNumFmtShell->GetCurNumFmtKey(); 803 } 804 else if(nCurKey == NUMKEY_UNDEFINED) 805 { // something went wrong, e.g. in Writer #70281# 806 pNumFmtShell->FindEntry(aFormat, &nCurKey); 807 } 808 809 //--------------------------------------------------------------- 810 // Chosen format: 811 // -------------- 812 if ( bDataChanged ) 813 { 814 bDataChanged = ( nInitFormat != nCurKey ); 815 816 if (bDataChanged) 817 { 818 rCoreAttrs.Put( SfxUInt32Item( nWhich, nCurKey ) ); 819 } 820 else if(SFX_ITEM_DEFAULT == eItemState) 821 { 822 rCoreAttrs.ClearItem( nWhich ); 823 } 824 } 825 826 // -------------------------------------------------------------- 827 // List of changed user defined formats: 828 // ------------------------------------- 829 const sal_uInt32 nDelCount = pNumFmtShell->GetUpdateDataCount(); 830 831 if ( nDelCount > 0 ) 832 { 833 sal_uInt32* pDelArr = new sal_uInt32[nDelCount]; 834 835 pNumFmtShell->GetUpdateData( pDelArr, nDelCount ); 836 pNumItem->SetDelFormatArray( pDelArr, nDelCount ); 837 838 if(bNumItemFlag==sal_True) 839 { 840 rCoreAttrs.Put( *pNumItem ); 841 } 842 else 843 { 844 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 845 846 DBG_ASSERT( pDocSh, "DocShell not found!" ); 847 848 849 if ( pDocSh ) 850 pDocSh->PutItem( *pNumItem ); 851 } 852 delete [] pDelArr; 853 } 854 855 //--------------------------------------------------------------- 856 // Whether source format is to be taken or not: 857 // -------------------------------------------- 858 if ( aCbSourceFormat.IsEnabled() ) 859 { 860 sal_uInt16 _nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ); 861 SfxItemState _eItemState = rMyItemSet.GetItemState( _nWhich, sal_False ); 862 const SfxBoolItem* pBoolItem = (const SfxBoolItem*) 863 GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE ); 864 sal_Bool bOld = (pBoolItem ? pBoolItem->GetValue() : sal_False); 865 rCoreAttrs.Put( SfxBoolItem( _nWhich, aCbSourceFormat.IsChecked() ) ); 866 if ( !bDataChanged ) 867 bDataChanged = (bOld != (sal_Bool) aCbSourceFormat.IsChecked() || 868 _eItemState != SFX_ITEM_SET); 869 } 870 871 // FillItemSet is only called on OK, here we can notify the 872 // NumberFormatShell that all new user defined formats are valid. 873 pNumFmtShell->ValidateNewEntries(); 874 if(aLbLanguage.IsVisible() && 875 LISTBOX_ENTRY_NOTFOUND != aLbLanguage.GetEntryPos(sAutomaticEntry)) 876 rCoreAttrs.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, 877 aLbLanguage.GetSelectEntry() == sAutomaticEntry)); 878 } 879 880 return bDataChanged; 881 } 882 883 884 int SvxNumberFormatTabPage::DeactivatePage( SfxItemSet* _pSet ) 885 { 886 /* if ( (ULONG_MAX != nInitFormat) && _pSet ) 887 { 888 const sal_uLong nCurKey = pNumFmtShell->GetCurNumFmtKey(); 889 const sal_uInt16 nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); 890 SfxItemState eItemState = GetItemSet().GetItemState( nWhich, sal_False ); 891 892 if ( (nInitFormat == nCurKey) && (SFX_ITEM_DEFAULT == eItemState) ) 893 _pSet->ClearItem( nWhich ); 894 else 895 _pSet->Put( SfxUInt32Item( nWhich, nCurKey ) ); 896 } 897 */ 898 if ( _pSet ) 899 FillItemSet( *_pSet ); 900 return LEAVE_PAGE; 901 } 902 903 void SvxNumberFormatTabPage::SetInfoItem( const SvxNumberInfoItem& rItem ) 904 { 905 if(pNumItem==NULL) 906 { 907 pNumItem = (SvxNumberInfoItem*)rItem.Clone(); 908 } 909 } 910 911 void SvxNumberFormatTabPage::FillFormatListBox_Impl( SvxDelStrgs& rEntries ) 912 { 913 String* pEntry; 914 String aTmpString; 915 String aTmpCatString; 916 Font aFont=aLbCategory.GetFont(); 917 sal_uInt16 i = 0; 918 short nTmpCatPos; 919 short aPrivCat; 920 921 aLbFormat.Clear(); 922 aLbFormat.SetUpdateMode( sal_False ); 923 924 sal_uInt16 nCount = rEntries.Count(); 925 926 if(nCount<1) return; 927 928 if(bOneAreaFlag) 929 { 930 nTmpCatPos=nFixedCategory; 931 } 932 else 933 { 934 nTmpCatPos=aLbCategory.GetSelectEntryPos(); 935 } 936 937 switch (nTmpCatPos) 938 { 939 case CAT_ALL: 940 case CAT_TEXT: 941 case CAT_NUMBER: i=1; 942 pEntry=rEntries[0]; 943 if(pEntry!=NULL) 944 { 945 if (nTmpCatPos == CAT_TEXT) 946 aTmpString=*pEntry; 947 else 948 aTmpString = pNumFmtShell->GetStandardName(); 949 aPrivCat=pNumFmtShell->GetCategory4Entry(0); 950 aLbFormat.InsertFontEntry( aTmpString, aFont ); 951 } 952 break; 953 954 default: break; 955 } 956 957 if(pNumFmtShell!=NULL) 958 { 959 for ( ; i < nCount; ++i ) 960 { 961 pEntry = rEntries[i]; 962 aPrivCat=pNumFmtShell->GetCategory4Entry(i); 963 if(aPrivCat!=CAT_TEXT) 964 { 965 Color* pPreviewColor = NULL; 966 String aPreviewString( GetExpColorString( pPreviewColor, *pEntry, aPrivCat ) ); 967 Font aEntryFont( aLbFormat.GetFont() ); 968 aLbFormat.InsertFontEntry( aPreviewString, aEntryFont, pPreviewColor ); 969 } 970 else 971 { 972 aLbFormat.InsertFontEntry(*pEntry,aFont); 973 } 974 } 975 } 976 aLbFormat.SetUpdateMode( sal_True ); 977 DeleteEntryList_Impl(rEntries); 978 } 979 980 981 /************************************************************************* 982 #* Methode: DeleteEntryList_Impl Datum:02.10.97 983 #*------------------------------------------------------------------------ 984 #* 985 #* Klasse: SvxNumberFormatTabPage 986 #* 987 #* Funktion: Loescht eine SvStrings- Liste 988 #* 989 #* Input: String-liste 990 #* 991 #* Output: --- 992 #* 993 #************************************************************************/ 994 995 void SvxNumberFormatTabPage::DeleteEntryList_Impl( SvxDelStrgs& rEntries ) 996 { 997 sal_uInt16 nCount = rEntries.Count(); 998 rEntries.DeleteAndDestroy(0,nCount); 999 } 1000 1001 1002 /************************************************************************* 1003 #* Methode: UpdateOptions_Impl Datum:02.10.97 1004 #*------------------------------------------------------------------------ 1005 #* 1006 #* Klasse: SvxNumberFormatTabPage 1007 #* 1008 #* Funktion: Stellt je nach eingestelltem Format die Options- 1009 #* attribute neu ein. 1010 #* 1011 #* Input: Flag, ob sich die Kategorie geaendert hat. 1012 #* 1013 #* Output: --- 1014 #* 1015 #***?********************************************************************/ 1016 1017 void SvxNumberFormatTabPage::UpdateOptions_Impl( sal_Bool bCheckCatChange /*= sal_False*/ ) 1018 { 1019 SvxDelStrgs aEntryList; 1020 String theFormat = aEdFormat.GetText(); 1021 sal_uInt16 nCurCategory = aLbCategory.GetSelectEntryPos(); 1022 sal_uInt16 nCategory = nCurCategory; 1023 sal_uInt16 nDecimals = 0; 1024 sal_uInt16 nZeroes = 0; 1025 sal_Bool bNegRed = sal_False; 1026 sal_Bool bThousand = sal_False; 1027 short nTmpCatPos; 1028 sal_uInt16 nCurrencyPos =aLbCurrency.GetSelectEntryPos(); 1029 1030 if(bOneAreaFlag) 1031 { 1032 nTmpCatPos=nFixedCategory; 1033 nCurCategory=nFixedCategory; 1034 } 1035 else 1036 { 1037 nTmpCatPos=nCurCategory; 1038 } 1039 1040 1041 pNumFmtShell->GetOptions( theFormat, 1042 bThousand, bNegRed, 1043 nDecimals, nZeroes, 1044 nCategory ); 1045 sal_Bool bDoIt=sal_False; 1046 if(nCategory==CAT_CURRENCY) 1047 { 1048 sal_uInt16 nTstPos=pNumFmtShell->FindCurrencyFormat(theFormat); 1049 if(nCurrencyPos!=nTstPos && nTstPos!=(sal_uInt16)-1) 1050 { 1051 aLbCurrency.SelectEntryPos(nTstPos); 1052 pNumFmtShell->SetCurrencySymbol(nTstPos); 1053 bDoIt=sal_True; 1054 } 1055 } 1056 1057 1058 1059 if ( nCategory != nCurCategory || bDoIt) 1060 { 1061 if ( bCheckCatChange ) 1062 { 1063 if(bOneAreaFlag) 1064 SetCategory(0); 1065 else 1066 SetCategory(nCategory ); 1067 1068 UpdateFormatListBox_Impl( sal_True, sal_False ); 1069 } 1070 } 1071 else if ( aLbFormat.GetEntryCount() > 0 ) 1072 { 1073 sal_uInt32 nCurEntryKey=NUMKEY_UNDEFINED; 1074 if(!pNumFmtShell->FindEntry( aEdFormat.GetText(),&nCurEntryKey)) 1075 { 1076 aLbFormat.SetNoSelection(); 1077 } 1078 } 1079 if(bOneAreaFlag) 1080 { 1081 nCategory=nFixedCategory; 1082 } 1083 1084 switch ( nCategory ) 1085 { 1086 case CAT_NUMBER: 1087 case CAT_PERCENT: 1088 case CAT_CURRENCY: 1089 aFlOptions.Enable(); 1090 aFtDecimals.Enable(); 1091 aEdDecimals.Enable(); 1092 aFtLeadZeroes.Enable(); 1093 aEdLeadZeroes.Enable(); 1094 aBtnNegRed.Enable(); 1095 aBtnThousand.Enable(); 1096 /* 1097 aEdDecimals .SetValue( nDecimals ); 1098 aEdLeadZeroes.SetValue( nZeroes ); 1099 */ 1100 aEdDecimals .SetText( UniString::CreateFromInt32( nDecimals ) ); 1101 aEdLeadZeroes.SetText( UniString::CreateFromInt32( nZeroes ) ); 1102 aBtnNegRed .Check( bNegRed ); 1103 aBtnThousand .Check( bThousand ); 1104 break; 1105 1106 case CAT_ALL: 1107 case CAT_USERDEFINED: 1108 case CAT_TEXT: 1109 case CAT_DATE: 1110 case CAT_TIME: 1111 case CAT_BOOLEAN: 1112 case CAT_SCIENTIFIC: 1113 case CAT_FRACTION: 1114 default: 1115 aFlOptions .Disable(); 1116 aFtDecimals .Disable(); 1117 aEdDecimals .Disable(); 1118 aFtLeadZeroes .Disable(); 1119 aEdLeadZeroes .Disable(); 1120 aBtnNegRed .Disable(); 1121 aBtnThousand .Disable(); 1122 aEdDecimals .SetText( UniString::CreateFromInt32( 0 ) ); 1123 aEdLeadZeroes .SetText( UniString::CreateFromInt32( 0 ) ); 1124 aBtnNegRed .Check( sal_False ); 1125 aBtnThousand .Check( sal_False ); 1126 } 1127 } 1128 1129 1130 /************************************************************************* 1131 #* Methode: UpdateFormatListBox_Impl Datum:02.10.97 1132 #*------------------------------------------------------------------------ 1133 #* 1134 #* Klasse: SvxNumberFormatTabPage 1135 #* 1136 #* Funktion: Aktualisiert die Format- Listbox und zusaetzlich 1137 #* wird abhaengig vom bUpdateEdit- Flag der String 1138 #* in der Editbox geaendert. 1139 #* 1140 #* Input: Flags fuer Kategorie und Editbox 1141 #* 1142 #* Output: --- 1143 #* 1144 #************************************************************************/ 1145 1146 void SvxNumberFormatTabPage::UpdateFormatListBox_Impl 1147 ( 1148 sal_uInt16 bCat, // Category oder Land/Sprache ListBox? 1149 sal_Bool bUpdateEdit // Format-Edit aktualisieren? 1150 ) 1151 { 1152 SvxDelStrgs aEntryList; 1153 short nFmtLbSelPos = 0; 1154 short nTmpCatPos; 1155 1156 if(bOneAreaFlag) 1157 { 1158 nTmpCatPos=nFixedCategory; 1159 } 1160 else 1161 { 1162 nTmpCatPos=aLbCategory.GetSelectEntryPos(); 1163 } 1164 1165 1166 if ( bCat ) 1167 { 1168 Point aPos=aLbFormat.GetPosPixel(); 1169 Size aSize=aLbFormat.GetSizePixel(); 1170 1171 if(nTmpCatPos!=CAT_CURRENCY) 1172 { 1173 aPos.Y()=nStdFormatY; 1174 aSize.Height()=nStdFormatHeight; 1175 aLbFormat.SetPosSizePixel(aPos,aSize); 1176 #if ENABLE_LAYOUT 1177 aLbCurrency.Disable(); 1178 #else /* !ENABLE_LAYOUT */ 1179 aLbCurrency.Hide(); 1180 #endif /* !ENABLE_LAYOUT */ 1181 } 1182 else 1183 { 1184 aPos.Y()=nCurFormatY; 1185 aSize.Height()=nCurFormatHeight; 1186 aLbFormat.SetPosSizePixel(aPos,aSize); 1187 #if ENABLE_LAYOUT 1188 aLbCurrency.Enable(); 1189 #else /* !ENABLE_LAYOUT */ 1190 aLbCurrency.Show(); 1191 #endif /* !ENABLE_LAYOUT */ 1192 } 1193 1194 pNumFmtShell->CategoryChanged( nTmpCatPos,nFmtLbSelPos, aEntryList ); 1195 } 1196 else 1197 pNumFmtShell->LanguageChanged( aLbLanguage.GetSelectLanguage(), 1198 nFmtLbSelPos,aEntryList ); 1199 1200 REMOVE_DONTKNOW() // ggF. UI-Enable 1201 1202 1203 if ( (aEntryList.Count() > 0) && (nFmtLbSelPos != SELPOS_NONE) ) 1204 { 1205 if(bUpdateEdit) 1206 { 1207 String aFormat=*aEntryList[nFmtLbSelPos]; 1208 aEdFormat.SetText(aFormat); 1209 aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos)); 1210 1211 //@23.09.97 aEdFormat.SetText( aLbFormat.GetSelectEntry() ); 1212 } 1213 1214 if(!bOneAreaFlag || !bCat) 1215 { 1216 FillFormatListBox_Impl( aEntryList ); 1217 aLbFormat.SelectEntryPos( nFmtLbSelPos ); 1218 1219 aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos)); 1220 if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos)) 1221 { 1222 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0) 1223 { 1224 aFtComment.SetText(aLbCategory.GetEntry(1)); 1225 } 1226 } 1227 ChangePreviewText( (sal_uInt16)nFmtLbSelPos ); 1228 } 1229 1230 } 1231 else 1232 { 1233 FillFormatListBox_Impl( aEntryList ); 1234 if(nFmtLbSelPos != SELPOS_NONE) 1235 { 1236 aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos ); 1237 1238 aFtComment.SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos)); 1239 if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos)) 1240 { 1241 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0) 1242 { 1243 aFtComment.SetText(aLbCategory.GetEntry(1)); 1244 } 1245 } 1246 } 1247 else 1248 { 1249 aLbFormat.SetNoSelection(); 1250 } 1251 1252 if ( bUpdateEdit ) 1253 { 1254 aEdFormat.SetText( String() ); 1255 aWndPreview.NotifyChange( String() ); 1256 } 1257 } 1258 } 1259 1260 1261 /************************************************************************* 1262 #* Handle: DoubleClickHdl_Impl Datum:02.10.97 1263 #*------------------------------------------------------------------------ 1264 #* 1265 #* Klasse: SvxNumberFormatTabPage 1266 #* 1267 #* Funktion: Bei einem Doppelklick in die Format- Listbox 1268 #* wird der Wert uebernommen und der OK-Button 1269 #* ausgeloest 1270 #* 1271 #* Input: Pointer auf Listbox 1272 #* 1273 #* Output: --- 1274 #* 1275 #************************************************************************/ 1276 1277 IMPL_LINK( SvxNumberFormatTabPage, DoubleClickHdl_Impl, SvxFontListBox*, pLb ) 1278 { 1279 if ( pLb == &aLbFormat ) 1280 { 1281 SelFormatHdl_Impl( pLb ); 1282 1283 if ( fnOkHdl.IsSet() ) 1284 { // Uebergangsloesung, sollte von SfxTabPage angeboten werden 1285 fnOkHdl.Call( NULL ); 1286 } 1287 else 1288 { 1289 SfxSingleTabDialog* pParent = dynamic_cast< SfxSingleTabDialog* >( GetParent() ); 1290 OKButton* pOKButton = pParent ? pParent->GetOKButton() : NULL; 1291 if ( pOKButton ) 1292 pOKButton->Click(); 1293 } 1294 } 1295 return 0; 1296 } 1297 1298 1299 /************************************************************************* 1300 #* Methode: SelFormatHdl_Impl Datum:02.10.97 1301 #*------------------------------------------------------------------------ 1302 #* 1303 #* Klasse: SvxNumberFormatTabPage 1304 #* 1305 #* Funktion: Wird aufgerufen, wenn sich die Sprache, die Kategorie 1306 #* oder das Format aendert. Dem entsprechend werden die 1307 #* Einstellungen geaendert. 1308 #* 1309 #* Input: Pointer auf Listbox 1310 #* 1311 #* Output: --- 1312 #* 1313 #************************************************************************/ 1314 1315 IMPL_LINK( SvxNumberFormatTabPage, SelFormatHdl_Impl, void *, pLb ) 1316 { 1317 if ( (CheckBox*)pLb == &aCbSourceFormat ) 1318 { 1319 EnableBySourceFormat_Impl(); // enable/disable everything else 1320 if ( aCbSourceFormat.IsChecked() ) 1321 return 0; // just disabled everything else 1322 1323 // Reinit options enable/disable for current selection. 1324 1325 #if ENABLE_LAYOUT 1326 if (aLbFormat.GetSelectEntryPos () == LISTBOX_ENTRY_NOTFOUND) 1327 #else /* !ENABLE_LAYOUT */ 1328 // Current category may be UserDefined with no format entries defined. 1329 // And yes, aLbFormat is a SvxFontListBox with sal_uLong list positions, 1330 // implementation returns a LIST_APPEND if empty, comparison with 1331 // sal_uInt16 LISTBOX_ENTRY_NOTFOUND wouldn't match. 1332 if ( aLbFormat.GetSelectEntryPos() == LIST_APPEND ) 1333 #endif /* !ENABLE_LAYOUT */ 1334 pLb = &aLbCategory; // continue with the current category selected 1335 else 1336 pLb = &aLbFormat; // continue with the current format selected 1337 } 1338 1339 short nTmpCatPos; 1340 1341 if(bOneAreaFlag) 1342 { 1343 nTmpCatPos=nFixedCategory; 1344 } 1345 else 1346 { 1347 nTmpCatPos=aLbCategory.GetSelectEntryPos(); 1348 } 1349 1350 sal_uInt16 nCurrencyPos=LISTBOX_ENTRY_NOTFOUND ; 1351 1352 if(nTmpCatPos==CAT_CURRENCY && (ListBox *)pLb == &aLbCurrency ) 1353 { 1354 nCurrencyPos=aLbCurrency.GetSelectEntryPos(); 1355 pNumFmtShell->SetCurrencySymbol(nCurrencyPos); 1356 } 1357 1358 //-------------------------------------------------------------------- 1359 // Format-ListBox ---------------------------------------------------- 1360 if ( (SvxFontListBox *)pLb == &aLbFormat ) 1361 { 1362 sal_uInt16 nSelPos = (sal_uInt16) aLbFormat.GetSelectEntryPos(); 1363 String aFormat = aLbFormat.GetSelectEntry(); 1364 String aComment; 1365 SvxDelStrgs aEntryList; 1366 1367 short nFmtLbSelPos = nSelPos; 1368 1369 aFormat=pNumFmtShell->GetFormat4Entry(nSelPos); 1370 aComment=pNumFmtShell->GetComment4Entry(nSelPos); 1371 if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos)) 1372 { 1373 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).Len()==0) 1374 { 1375 aComment=aLbCategory.GetEntry(1); 1376 } 1377 } 1378 1379 if ( aFormat.Len() > 0 ) 1380 { 1381 if(!aEdFormat.HasFocus()) aEdFormat.SetText( aFormat ); 1382 aFtComment.SetText(aComment); 1383 ChangePreviewText( nSelPos ); 1384 } 1385 1386 REMOVE_DONTKNOW() // ggF. UI-Enable 1387 1388 if ( pNumFmtShell->FindEntry( aFormat) ) 1389 { 1390 aIbAdd.Enable(sal_False ); 1391 sal_Bool bIsUserDef=pNumFmtShell->IsUserDefined( aFormat ); 1392 aIbRemove.Enable(bIsUserDef); 1393 aIbInfo.Enable(bIsUserDef); 1394 1395 } 1396 else 1397 { 1398 aIbAdd.Enable(sal_True ); 1399 aIbInfo.Enable(sal_True ); 1400 aIbRemove.Enable(sal_False ); 1401 aFtComment.SetText(aEdComment.GetText()); 1402 1403 } 1404 UpdateOptions_Impl( sal_False ); 1405 1406 //------- 1407 return 0; 1408 //------- 1409 } 1410 1411 //-------------------------------------------------------------------- 1412 // Kategorie-ListBox ------------------------------------------------- 1413 if ( pLb == &aLbCategory || pLb == &aLbCurrency) 1414 { 1415 UpdateFormatListBox_Impl( sal_True, sal_True ); 1416 EditHdl_Impl( NULL ); 1417 UpdateOptions_Impl( sal_False ); 1418 1419 //------- 1420 return 0; 1421 //------- 1422 } 1423 1424 //-------------------------------------------------------------------- 1425 // Sprache/Land-ListBox ---------------------------------------------- 1426 if ( pLb == &aLbLanguage ) 1427 { 1428 UpdateFormatListBox_Impl( sal_False, sal_True ); 1429 EditHdl_Impl( &aEdFormat ); 1430 1431 //------- 1432 return 0; 1433 //------- 1434 } 1435 return 0; 1436 } 1437 1438 1439 /************************************************************************* 1440 #* Methode: ClickHdl_Impl, ImageButton* pIB Datum:02.10.97 1441 #*------------------------------------------------------------------------ 1442 #* 1443 #* Klasse: SvxNumberFormatTabPage 1444 #* 1445 #* Funktion: Wenn, der Hinzufuegen- oder Entfernen- Button 1446 #* wird diese Funktion aufgerufen und die Zahlenformat- 1447 #* Liste den entsprechend geaendert. 1448 #* 1449 #* Input: Toolbox- Button 1450 #* 1451 #* Output: --- 1452 #* 1453 #************************************************************************/ 1454 1455 IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB) 1456 { 1457 sal_Bool bAdded = sal_False; 1458 sal_Bool bDeleted = sal_False; 1459 sal_uLong nReturn = 0; 1460 const sal_uLong nReturnChanged = 0x1; // THE boolean return value 1461 const sal_uLong nReturnAdded = 0x2; // temp: format added 1462 const sal_uLong nReturnOneArea = 0x4; // temp: one area but category changed => ignored 1463 1464 if(pIB==&aIbAdd) 1465 { // Also called from FillItemSet() if a temporary currency format has 1466 // to be added, not only if the Add button is enabled. 1467 String aFormat = aEdFormat.GetText(); 1468 SvxDelStrgs aEntryList; 1469 SvxDelStrgs a2EntryList; 1470 sal_uInt16 nCatLbSelPos = 0; 1471 short nFmtLbSelPos = SELPOS_NONE; 1472 xub_StrLen nErrPos=0; 1473 1474 pNumFmtShell->SetCurCurrencyEntry(NULL); 1475 bAdded = pNumFmtShell->AddFormat( aFormat, nErrPos, 1476 nCatLbSelPos, nFmtLbSelPos, 1477 aEntryList); 1478 if ( bAdded ) 1479 nReturn |= nReturnChanged | nReturnAdded; 1480 1481 if(pLastActivWindow== (Window *) &aEdComment) 1482 { 1483 aEdFormat.GrabFocus(); 1484 aEdComment.Hide(); 1485 aFtComment.Show(); 1486 aFtComment.SetText(aEdComment.GetText()); 1487 } 1488 1489 if ( !nErrPos ) // Syntax ok? 1490 { 1491 if(nCatLbSelPos==CAT_CURRENCY) 1492 { 1493 aLbCurrency.SelectEntryPos((sal_uInt16)pNumFmtShell->GetCurrencySymbol()); 1494 } 1495 1496 if(bOneAreaFlag && (nFixedCategory!=nCatLbSelPos)) 1497 { 1498 if(bAdded) DeleteEntryList_Impl(aEntryList); 1499 bDeleted = pNumFmtShell->RemoveFormat( aFormat, 1500 nCatLbSelPos, 1501 nFmtLbSelPos, 1502 a2EntryList); 1503 if(bDeleted) DeleteEntryList_Impl(a2EntryList); 1504 aEdFormat.GrabFocus(); 1505 aEdFormat.SetSelection( Selection( (short)nErrPos, SELECTION_MAX ) ); 1506 nReturn |= nReturnOneArea; 1507 } 1508 else 1509 { 1510 if ( bAdded && (nFmtLbSelPos != SELPOS_NONE) ) 1511 { 1512 // Alles klar 1513 if(bOneAreaFlag) //@@ ??? 1514 SetCategory(0); 1515 else 1516 SetCategory(nCatLbSelPos ); 1517 1518 FillFormatListBox_Impl( aEntryList ); 1519 if(aEdComment.GetText()!=aLbCategory.GetEntry(1)) 1520 { 1521 pNumFmtShell->SetComment4Entry(nFmtLbSelPos, 1522 aEdComment.GetText()); 1523 } 1524 else 1525 { 1526 pNumFmtShell->SetComment4Entry(nFmtLbSelPos, 1527 String()); 1528 } 1529 aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos ); 1530 aEdFormat.SetText( aFormat ); 1531 1532 //aEdComment.SetText(String()); //@@ ??? 1533 aEdComment.SetText(aLbCategory.GetEntry(1)); //String fuer Benutzerdefiniert 1534 //holen 1535 ChangePreviewText( (sal_uInt16)nFmtLbSelPos ); 1536 } 1537 } 1538 } 1539 else // Syntaxfehler 1540 { 1541 aEdFormat.GrabFocus(); 1542 aEdFormat.SetSelection( Selection( (short)nErrPos, SELECTION_MAX ) ); 1543 } 1544 EditHdl_Impl( &aEdFormat ); 1545 nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged)); 1546 } 1547 else if(pIB==&aIbRemove) 1548 { 1549 String aFormat = aEdFormat.GetText(); 1550 SvxDelStrgs aEntryList; 1551 sal_uInt16 nCatLbSelPos = 0; 1552 short nFmtLbSelPos = SELPOS_NONE; 1553 1554 bDeleted = pNumFmtShell->RemoveFormat( aFormat, 1555 nCatLbSelPos, 1556 nFmtLbSelPos, 1557 aEntryList ); 1558 1559 aEdComment.SetText(aLbCategory.GetEntry(1)); 1560 if ( bDeleted ) 1561 { 1562 if(nFmtLbSelPos>=0 && nFmtLbSelPos<aEntryList.Count()) 1563 { 1564 aFormat = *aEntryList[nFmtLbSelPos]; 1565 } 1566 1567 FillFormatListBox_Impl( aEntryList ); 1568 1569 if ( nFmtLbSelPos != SELPOS_NONE ) 1570 { 1571 if(bOneAreaFlag) //@@ ??? 1572 SetCategory(0); 1573 else 1574 SetCategory(nCatLbSelPos ); 1575 1576 aLbFormat.SelectEntryPos( (sal_uInt16)nFmtLbSelPos ); 1577 aEdFormat.SetText( aFormat ); 1578 ChangePreviewText( (sal_uInt16)nFmtLbSelPos ); 1579 } 1580 else 1581 { 1582 // auf "Alle/Standard" setzen 1583 SetCategory(0 ); 1584 SelFormatHdl_Impl( &aLbCategory ); 1585 } 1586 } 1587 EditHdl_Impl( &aEdFormat ); 1588 } 1589 else if(pIB==&aIbInfo) 1590 { 1591 if(!(pLastActivWindow== (Window *) &aEdComment)) 1592 { 1593 aEdComment.SetText(aFtComment.GetText()); 1594 aEdComment.Show(); 1595 aFtComment.Hide(); 1596 aEdComment.GrabFocus(); 1597 } 1598 else 1599 { 1600 aEdFormat.GrabFocus(); 1601 aEdComment.Hide(); 1602 aFtComment.Show(); 1603 } 1604 } 1605 1606 return nReturn; 1607 } 1608 1609 1610 /************************************************************************* 1611 #* Methode: EditHdl_Impl Datum:02.10.97 1612 #*------------------------------------------------------------------------ 1613 #* 1614 #* Klasse: SvxNumberFormatTabPage 1615 #* 1616 #* Funktion: Wenn der Eintrag im Eingabefeld geaendert wird, 1617 #* so wird die Vorschau aktualisiert und 1618 #* 1619 #* Input: Pointer auf Editbox 1620 #* 1621 #* Output: --- 1622 #* 1623 #************************************************************************/ 1624 1625 IMPL_LINK( SvxNumberFormatTabPage, EditHdl_Impl, Edit*, pEdFormat ) 1626 { 1627 sal_uInt32 nCurKey = NUMKEY_UNDEFINED; 1628 1629 if ( aEdFormat.GetText().Len() == 0 ) 1630 { 1631 aIbAdd.Enable(sal_False ); 1632 aIbRemove.Enable(sal_False ); 1633 aIbInfo.Enable(sal_False ); 1634 aFtComment.SetText(String()); 1635 } 1636 else 1637 { 1638 String aFormat = aEdFormat.GetText(); 1639 //aFtComment.SetText(String()); 1640 MakePreviewText( aFormat ); 1641 1642 if ( pNumFmtShell->FindEntry( aFormat, &nCurKey ) ) 1643 { 1644 aIbAdd.Enable(sal_False ); 1645 sal_Bool bUserDef=pNumFmtShell->IsUserDefined( aFormat ); 1646 1647 aIbRemove.Enable(bUserDef); 1648 aIbInfo.Enable(bUserDef); 1649 1650 if(bUserDef) 1651 { 1652 sal_uInt16 nTmpCurPos=pNumFmtShell->FindCurrencyFormat(aFormat ); 1653 1654 if(nTmpCurPos!=(sal_uInt16)-1) 1655 aLbCurrency.SelectEntryPos(nTmpCurPos); 1656 } 1657 short nPosi=pNumFmtShell->GetListPos4Entry(aFormat); 1658 if(nPosi>=0) 1659 aLbFormat.SelectEntryPos( (sal_uInt16)nPosi); 1660 1661 } 1662 else 1663 { 1664 1665 aIbAdd.Enable(sal_True ); 1666 aIbInfo.Enable(sal_True); 1667 aIbRemove.Enable(sal_False ); 1668 1669 aFtComment.SetText(aEdComment.GetText()); 1670 1671 } 1672 } 1673 1674 if ( pEdFormat ) 1675 { 1676 pNumFmtShell->SetCurNumFmtKey( nCurKey ); 1677 UpdateOptions_Impl( sal_True ); 1678 } 1679 1680 return 0; 1681 } 1682 1683 1684 /************************************************************************* 1685 #* Methode: NotifyChange Datum:02.10.97 1686 #*------------------------------------------------------------------------ 1687 #* 1688 #* Klasse: SvxNumberFormatTabPage 1689 #* 1690 #* Funktion: Fuehrt Aenderungen in den Zahlen- Attributen durch. 1691 #* 1692 #* Input: Options- Controls 1693 #* 1694 #* Output: --- 1695 #* 1696 #************************************************************************/ 1697 1698 IMPL_LINK( SvxNumberFormatTabPage, OptHdl_Impl, void *, pOptCtrl ) 1699 { 1700 if ( ((NumericField*)pOptCtrl == &aEdLeadZeroes) 1701 || ((NumericField*)pOptCtrl == &aEdDecimals) 1702 || ((CheckBox*) pOptCtrl == &aBtnNegRed) 1703 || ((CheckBox*) pOptCtrl == &aBtnThousand) ) 1704 { 1705 String aFormat; 1706 sal_Bool bThousand = aBtnThousand.IsEnabled() 1707 && aBtnThousand.IsChecked(); 1708 sal_Bool bNegRed = aBtnNegRed.IsEnabled() 1709 && aBtnNegRed.IsChecked(); 1710 sal_uInt16 nPrecision = (aEdDecimals.IsEnabled()) 1711 ? (sal_uInt16)aEdDecimals.GetValue() 1712 : (sal_uInt16)0; 1713 sal_uInt16 nLeadZeroes = (aEdLeadZeroes.IsEnabled()) 1714 ? (sal_uInt16)aEdLeadZeroes.GetValue() 1715 : (sal_uInt16)0; 1716 1717 pNumFmtShell->MakeFormat( aFormat, 1718 bThousand, bNegRed, 1719 nPrecision, nLeadZeroes, 1720 (sal_uInt16)aLbFormat.GetSelectEntryPos() ); 1721 1722 aEdFormat.SetText( aFormat ); 1723 //aFtComment.SetText(String()); 1724 MakePreviewText( aFormat ); 1725 1726 if ( pNumFmtShell->FindEntry( aFormat ) ) 1727 { 1728 aIbAdd.Enable(sal_False ); 1729 sal_Bool bUserDef=pNumFmtShell->IsUserDefined( aFormat ); 1730 aIbRemove.Enable(bUserDef); 1731 aIbInfo.Enable(bUserDef); 1732 EditHdl_Impl( &aEdFormat); 1733 1734 } 1735 else 1736 { 1737 EditHdl_Impl( NULL ); 1738 aLbFormat.SetNoSelection(); 1739 } 1740 } 1741 return 0; 1742 } 1743 1744 IMPL_LINK( SvxNumberFormatTabPage, TimeHdl_Impl, Timer*, EMPTYARG) 1745 { 1746 pLastActivWindow=NULL; 1747 return 0; 1748 } 1749 1750 1751 /************************************************************************* 1752 #* Methode: LostFocusHdl_Impl Datum:30.10.97 1753 #*------------------------------------------------------------------------ 1754 #* 1755 #* Klasse: SvxNumberFormatTabPage 1756 #* 1757 #* Funktion: Fuehrt Aenderungen in den Zahlen- Attributen durch. 1758 #* 1759 #* Input: Options- Controls 1760 #* 1761 #* Output: --- 1762 #* 1763 #************************************************************************/ 1764 1765 IMPL_LINK( SvxNumberFormatTabPage, LostFocusHdl_Impl, Edit *, pEd) 1766 { 1767 if (pEd==&aEdComment) 1768 { 1769 aResetWinTimer.Start(); 1770 aFtComment.SetText(aEdComment.GetText()); 1771 aEdComment.Hide(); 1772 aFtComment.Show(); 1773 if(!aIbAdd.IsEnabled()) 1774 { 1775 sal_uInt16 nSelPos = (sal_uInt16) aLbFormat.GetSelectEntryPos(); 1776 pNumFmtShell->SetComment4Entry(nSelPos, 1777 aEdComment.GetText()); 1778 aEdComment.SetText(aLbCategory.GetEntry(1)); //String fuer Benutzerdefiniert 1779 //holen 1780 } 1781 } 1782 return 0; 1783 } 1784 1785 /************************************************************************* 1786 #* Methode: NotifyChange Datum:02.10.97 1787 #*------------------------------------------------------------------------ 1788 #* 1789 #* Klasse: SvxNumberFormatTabPage 1790 #* 1791 #* Funktion: Fuehrt Aenderungen in den Zahlen- Attributen durch. 1792 #* 1793 #* Input: Options- Controls 1794 #* 1795 #* Output: --- 1796 #* 1797 #************************************************************************/ 1798 1799 String SvxNumberFormatTabPage::GetExpColorString( 1800 Color*& rpPreviewColor, const String& rFormatStr, short nTmpCatPos) 1801 { 1802 double nVal = 0; 1803 switch (nTmpCatPos) 1804 { 1805 case CAT_CURRENCY: nVal=SVX_NUMVAL_CURRENCY; break; 1806 1807 case CAT_SCIENTIFIC: 1808 case CAT_FRACTION: 1809 case CAT_NUMBER: nVal=SVX_NUMVAL_STANDARD; break; 1810 1811 case CAT_PERCENT: nVal=SVX_NUMVAL_PERCENT; break; 1812 1813 case CAT_ALL: nVal=SVX_NUMVAL_STANDARD; break; 1814 1815 case CAT_TIME: nVal=SVX_NUMVAL_TIME; break; 1816 case CAT_DATE: nVal=SVX_NUMVAL_DATE; break; 1817 1818 case CAT_BOOLEAN: nVal=SVX_NUMVAL_BOOLEAN; break; 1819 1820 case CAT_USERDEFINED: 1821 case CAT_TEXT: 1822 default: nVal=0;break; 1823 } 1824 1825 String aPreviewString; 1826 pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, nVal ); 1827 return aPreviewString; 1828 } 1829 1830 void SvxNumberFormatTabPage::MakePreviewText( const String& rFormat ) 1831 { 1832 String aPreviewString; 1833 Color* pPreviewColor = NULL; 1834 pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor ); 1835 aWndPreview.NotifyChange( aPreviewString, pPreviewColor ); 1836 } 1837 1838 void SvxNumberFormatTabPage::ChangePreviewText( sal_uInt16 nPos ) 1839 { 1840 String aPreviewString; 1841 Color* pPreviewColor = NULL; 1842 pNumFmtShell->FormatChanged( nPos, aPreviewString, pPreviewColor ); 1843 aWndPreview.NotifyChange( aPreviewString, pPreviewColor ); 1844 } 1845 1846 long SvxNumberFormatTabPage::PreNotify( NotifyEvent& rNEvt ) 1847 { 1848 if(rNEvt.GetType()==EVENT_LOSEFOCUS) 1849 { 1850 if ( rNEvt.GetWindow() == dynamic_cast< Window* >( &aEdComment ) && !aEdComment.IsVisible() ) 1851 { 1852 pLastActivWindow = NULL; 1853 } 1854 else 1855 { 1856 pLastActivWindow = rNEvt.GetWindow(); 1857 } 1858 } 1859 1860 return SfxTabPage::PreNotify( rNEvt ); 1861 } 1862 /************************************************************************* 1863 #* Methode: SetOkHdl Datum:01.11.97 1864 #*------------------------------------------------------------------------ 1865 #* 1866 #* Klasse: SvxNumberFormatTabPage 1867 #* 1868 #* Funktion: Setzt den OkHandler neu. 1869 #* 1870 #* Input: Neuer OkHandler 1871 #* 1872 #* Output: --- 1873 #* 1874 #************************************************************************/ 1875 1876 void SvxNumberFormatTabPage::SetOkHdl( const Link& rOkHandler ) 1877 { 1878 fnOkHdl = rOkHandler; 1879 } 1880 1881 void SvxNumberFormatTabPage::FillCurrencyBox() 1882 { 1883 SvStringsDtor aList; 1884 NfShCurrencyEntries rEntries; 1885 XubString* pEntry = NULL; 1886 sal_uInt16 nPos=0; 1887 sal_uInt16 nSelPos=0; 1888 1889 pNumFmtShell->GetCurrencySymbols( aList, &nSelPos); 1890 1891 for(sal_uInt16 i=1;i<aList.Count();i++) 1892 { 1893 pEntry=aList[i]; 1894 nPos=aLbCurrency.InsertEntry( *pEntry); 1895 } 1896 aLbCurrency.SelectEntryPos(nSelPos); 1897 } 1898 1899 void SvxNumberFormatTabPage::SetCategory(sal_uInt16 nPos) 1900 { 1901 sal_uInt16 nCurCategory = aLbCategory.GetSelectEntryPos(); 1902 Point aPos=aLbFormat.GetPosPixel(); 1903 Size aSize=aLbFormat.GetSizePixel(); 1904 sal_uInt16 nTmpCatPos; 1905 1906 if(bOneAreaFlag) 1907 { 1908 nTmpCatPos=nFixedCategory; 1909 } 1910 else 1911 { 1912 nTmpCatPos=nPos; 1913 } 1914 1915 if(aLbCategory.GetEntryCount()==1 || nCurCategory!=nPos) 1916 { 1917 if(nTmpCatPos!=CAT_CURRENCY) 1918 { 1919 aPos.Y()=nStdFormatY; 1920 aSize.Height()=nStdFormatHeight; 1921 aLbFormat.SetPosSizePixel(aPos,aSize); 1922 aLbCurrency.Hide(); 1923 } 1924 else 1925 { 1926 aPos.Y()=nCurFormatY; 1927 aSize.Height()=nCurFormatHeight; 1928 aLbFormat.SetPosSizePixel(aPos,aSize); 1929 aLbCurrency.Show(); 1930 } 1931 } 1932 aLbCategory.SelectEntryPos(nPos); 1933 } 1934 /* -----------------12.11.2002 14:35----------------- 1935 * to support Writer text field language handling an 1936 * additional entry needs to be inserted into the ListBox 1937 * which marks a certain language as automatically detected 1938 * Additionally the "Default" language is removed 1939 * --------------------------------------------------*/ 1940 void SvxNumberFormatTabPage::AddAutomaticLanguage_Impl(LanguageType eAutoLang, sal_Bool bSelect) 1941 { 1942 aLbLanguage.RemoveLanguage(LANGUAGE_SYSTEM); 1943 sal_uInt16 nPos = aLbLanguage.InsertEntry(sAutomaticEntry); 1944 aLbLanguage.SetEntryData(nPos, (void*)(sal_uLong)eAutoLang); 1945 if(bSelect) 1946 aLbLanguage.SelectEntryPos(nPos); 1947 } 1948 1949 void SvxNumberFormatTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001 1950 { 1951 SFX_ITEMSET_ARG (&aSet,pNumberInfoItem,SvxNumberInfoItem,SID_ATTR_NUMBERFORMAT_INFO,sal_False); 1952 SFX_ITEMSET_ARG (&aSet,pLinkItem,SfxLinkItem,SID_LINK_TYPE,sal_False); 1953 if (pNumberInfoItem) 1954 SetNumberFormatList(*pNumberInfoItem); 1955 if (pLinkItem) 1956 SetOkHdl(pLinkItem->GetValue()); 1957 } 1958