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