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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <tools/shl.hxx> 33 #include <sfx2/dispatch.hxx> 34 #include <sfx2/objsh.hxx> 35 #include <sfx2/viewsh.hxx> 36 #include <sfx2/module.hxx> 37 #include <tools/urlobj.hxx> 38 39 #define _SVX_ITEMWIN_CXX 40 41 #include <vcl/svapp.hxx> 42 43 #include <svx/dialogs.hrc> 44 45 #define DELAY_TIMEOUT 100 46 47 #include <svx/xlnclit.hxx> 48 #include <svx/xlnwtit.hxx> 49 #include <svx/xlineit0.hxx> 50 #include <svx/xlndsit.hxx> 51 #include <svx/xtable.hxx> 52 #include "svx/drawitem.hxx" 53 #include <svx/dialmgr.hxx> 54 #include "svx/dlgutil.hxx" 55 #include <svx/itemwin.hxx> 56 #include "svx/linectrl.hxx" 57 #include <svtools/colorcfg.hxx> 58 59 #include "linectrl.hrc" 60 61 using namespace ::com::sun::star::uno; 62 using namespace ::com::sun::star::frame; 63 using namespace ::com::sun::star::util; 64 using namespace ::com::sun::star::lang; 65 using namespace ::com::sun::star::beans; 66 67 #define LOGICAL_EDIT_HEIGHT 12 68 //======================================================================== 69 // SvxLineBox 70 //======================================================================== 71 72 SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) : 73 LineLB( pParent, nBits ), 74 meBmpMode ( GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ), 75 nCurPos ( 0 ), 76 aLogicalSize(40,140), 77 bRelease ( sal_True ), 78 mpSh ( NULL ), 79 mxFrame ( rFrame ) 80 { 81 SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT )); 82 Show(); 83 84 aDelayTimer.SetTimeout( DELAY_TIMEOUT ); 85 aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) ); 86 aDelayTimer.Start(); 87 } 88 89 // ----------------------------------------------------------------------- 90 91 SvxLineBox::~SvxLineBox() 92 { 93 } 94 95 // ----------------------------------------------------------------------- 96 97 IMPL_LINK( SvxLineBox, DelayHdl_Impl, Timer *, EMPTYARG ) 98 { 99 if ( GetEntryCount() == 0 ) 100 { 101 mpSh = SfxObjectShell::Current(); 102 FillControl(); 103 } 104 return 0; 105 } 106 107 // ----------------------------------------------------------------------- 108 109 void SvxLineBox::Select() 110 { 111 // Call the parent's Select() member to trigger accessibility events. 112 LineLB::Select(); 113 114 if ( !IsTravelSelect() ) 115 { 116 XLineStyle eXLS; 117 sal_uInt16 nPos = GetSelectEntryPos(); 118 // SfxDispatcher* pDisp = rBindings.GetDispatcher(); 119 //DBG_ASSERT( pDisp, "invalid Dispatcher" ); 120 121 switch ( nPos ) 122 { 123 case 0: 124 eXLS = XLINE_NONE; 125 break; 126 127 case 1: 128 eXLS = XLINE_SOLID; 129 break; 130 131 default: 132 { 133 eXLS = XLINE_DASH; 134 135 if ( nPos != LISTBOX_ENTRY_NOTFOUND && 136 SfxObjectShell::Current() && 137 SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) 138 { 139 // LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt. 140 // Notify k"ummert sich darum! 141 SvxDashListItem aItem( *(const SvxDashListItem*)( 142 SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) ); 143 XLineDashItem aLineDashItem( GetSelectEntry(), 144 aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() ); 145 146 Any a; 147 Sequence< PropertyValue > aArgs( 1 ); 148 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" )); 149 aLineDashItem.QueryValue ( a ); 150 aArgs[0].Value = a; 151 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 152 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )), 153 aArgs ); 154 // pDisp->Execute( SID_ATTR_LINE_DASH, SFX_CALLMODE_RECORD, &aLineDashItem, 0L ); 155 } 156 } 157 break; 158 } 159 160 XLineStyleItem aLineStyleItem( eXLS ); 161 Any a; 162 Sequence< PropertyValue > aArgs( 1 ); 163 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" )); 164 aLineStyleItem.QueryValue ( a ); 165 aArgs[0].Value = a; 166 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 167 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )), 168 aArgs ); 169 // pDisp->Execute( SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aLineStyleItem, 0L ); 170 171 nCurPos = GetSelectEntryPos(); 172 ReleaseFocus_Impl(); 173 } 174 } 175 176 // ----------------------------------------------------------------------- 177 178 long SvxLineBox::PreNotify( NotifyEvent& rNEvt ) 179 { 180 sal_uInt16 nType = rNEvt.GetType(); 181 182 switch(nType) 183 { 184 case EVENT_MOUSEBUTTONDOWN: 185 case EVENT_GETFOCUS: 186 nCurPos = GetSelectEntryPos(); 187 break; 188 case EVENT_LOSEFOCUS: 189 SelectEntryPos(nCurPos); 190 break; 191 case EVENT_KEYINPUT: 192 { 193 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 194 if( pKEvt->GetKeyCode().GetCode() == KEY_TAB) 195 { 196 bRelease = sal_False; 197 Select(); 198 } 199 } 200 break; 201 } 202 return LineLB::PreNotify( rNEvt ); 203 } 204 205 // ----------------------------------------------------------------------- 206 207 long SvxLineBox::Notify( NotifyEvent& rNEvt ) 208 { 209 long nHandled = LineLB::Notify( rNEvt ); 210 211 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 212 { 213 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 214 215 switch ( pKEvt->GetKeyCode().GetCode() ) 216 { 217 case KEY_RETURN: 218 Select(); 219 nHandled = 1; 220 break; 221 222 case KEY_ESCAPE: 223 SelectEntryPos( nCurPos ); 224 ReleaseFocus_Impl(); 225 nHandled = 1; 226 break; 227 } 228 } 229 return nHandled; 230 } 231 232 // ----------------------------------------------------------------------- 233 234 void SvxLineBox::ReleaseFocus_Impl() 235 { 236 if(!bRelease) 237 { 238 bRelease = sal_True; 239 return; 240 } 241 242 if( SfxViewShell::Current() ) 243 { 244 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 245 246 if ( pShellWnd ) 247 pShellWnd->GrabFocus(); 248 } 249 } 250 /* -----------------------------08.03.2002 15:39------------------------------ 251 252 ---------------------------------------------------------------------------*/ 253 void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt ) 254 { 255 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 256 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 257 { 258 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); 259 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); 260 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); 261 } 262 263 LineLB::DataChanged( rDCEvt ); 264 265 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 266 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 267 { 268 BmpColorMode eMode = GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL; 269 if( eMode != meBmpMode ) 270 { 271 meBmpMode = eMode; 272 FillControl(); 273 } 274 } 275 } 276 277 void SvxLineBox::FillControl() 278 { 279 FillStyles(); 280 if ( !mpSh ) 281 mpSh = SfxObjectShell::Current(); 282 283 if( mpSh ) 284 { 285 const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) ); 286 if ( pItem ) 287 Fill( pItem->GetDashList() ); 288 } 289 290 291 // rBindings.Invalidate( SID_ATTR_LINE_DASH ); 292 } 293 //======================================================================== 294 // SvxColorBox 295 //======================================================================== 296 297 SvxColorBox::SvxColorBox( 298 Window* pParent, 299 const ::rtl::OUString& rCommand, 300 const Reference< XFrame >& rFrame, 301 WinBits nBits ) : 302 ColorLB( pParent, nBits ), 303 nCurPos ( 0 ), 304 aLogicalSize(45,80), 305 bRelease ( sal_True ), 306 maCommand ( rCommand ), 307 mxFrame ( rFrame ) 308 { 309 SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT)); 310 Show(); 311 312 SfxObjectShell* pSh = SfxObjectShell::Current(); 313 314 if ( pSh ) 315 { 316 const SvxColorTableItem* pItem = 317 (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) ); 318 if(pItem) 319 Fill( pItem->GetColorTable() ); 320 } 321 } 322 323 // ----------------------------------------------------------------------- 324 325 IMPL_LINK( SvxColorBox, DelayHdl_Impl, Timer *, EMPTYARG ) 326 { 327 SfxObjectShell* pSh = SfxObjectShell::Current(); 328 329 if ( pSh ) 330 { 331 const SvxColorTableItem* pItem = (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) ); 332 if ( pItem ) 333 Fill( pItem->GetColorTable() ); 334 // rBindings.Invalidate( nId ); 335 } 336 return 0; 337 } 338 339 // ----------------------------------------------------------------------- 340 341 SvxColorBox::~SvxColorBox() 342 { 343 } 344 345 // ----------------------------------------------------------------------- 346 347 void SvxColorBox::Update( const XLineColorItem* pItem ) 348 { 349 if ( pItem ) 350 SelectEntry( pItem->GetColorValue() ); 351 else 352 SetNoSelection(); 353 } 354 355 // ----------------------------------------------------------------------- 356 357 void SvxColorBox::Select() 358 { 359 // OJ: base class call needed here because otherwise no event is send for accessibility 360 ColorLB::Select(); 361 if ( !IsTravelSelect() ) 362 { 363 XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() ); 364 365 INetURLObject aObj( maCommand ); 366 367 Any a; 368 Sequence< PropertyValue > aArgs( 1 ); 369 aArgs[0].Name = aObj.GetURLPath(); 370 aLineColorItem.QueryValue( a ); 371 aArgs[0].Value = a; 372 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 373 maCommand, 374 aArgs ); 375 // rBindings.GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, &aLineColorItem, 0L ); 376 377 nCurPos = GetSelectEntryPos(); 378 ReleaseFocus_Impl(); 379 } 380 } 381 382 // ----------------------------------------------------------------------- 383 384 long SvxColorBox::PreNotify( NotifyEvent& rNEvt ) 385 { 386 sal_uInt16 nType = rNEvt.GetType(); 387 388 switch(nType) 389 { 390 case EVENT_MOUSEBUTTONDOWN: 391 case EVENT_GETFOCUS: 392 nCurPos = GetSelectEntryPos(); 393 break; 394 case EVENT_LOSEFOCUS: 395 SelectEntryPos(nCurPos); 396 break; 397 case EVENT_KEYINPUT: 398 { 399 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 400 401 if( pKEvt->GetKeyCode().GetCode() == KEY_TAB) 402 { 403 bRelease = sal_False; 404 Select(); 405 } 406 } 407 } 408 409 return ColorLB::PreNotify( rNEvt ); 410 } 411 412 // ----------------------------------------------------------------------- 413 414 long SvxColorBox::Notify( NotifyEvent& rNEvt ) 415 { 416 long nHandled = ColorLB::Notify( rNEvt ); 417 418 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 419 { 420 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 421 422 switch ( pKEvt->GetKeyCode().GetCode() ) 423 { 424 case KEY_RETURN: 425 Select(); 426 nHandled = 1; 427 break; 428 429 case KEY_ESCAPE: 430 SelectEntryPos( nCurPos ); 431 ReleaseFocus_Impl(); 432 nHandled = 1; 433 break; 434 } 435 } 436 return nHandled; 437 } 438 /* -----------------------------08.03.2002 15:35------------------------------ 439 440 ---------------------------------------------------------------------------*/ 441 void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt ) 442 { 443 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 444 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 445 { 446 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); 447 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); 448 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); 449 } 450 451 ColorLB::DataChanged( rDCEvt ); 452 } 453 // ----------------------------------------------------------------------- 454 455 void SvxColorBox::ReleaseFocus_Impl() 456 { 457 if(!bRelease) 458 { 459 bRelease = sal_True; 460 return; 461 } 462 463 if( SfxViewShell::Current() ) 464 { 465 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 466 467 if ( pShellWnd ) 468 pShellWnd->GrabFocus(); 469 } 470 } 471 472 //======================================================================== 473 // SvxMetricField 474 //======================================================================== 475 476 SvxMetricField::SvxMetricField( 477 Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) : 478 MetricField( pParent, nBits ), 479 aCurTxt( String() ), 480 mxFrame( rFrame ) 481 { 482 Size aSize = Size(GetTextWidth( String::CreateFromAscii("99,99mm") ),GetTextHeight()); 483 aSize.Width() += 20; 484 aSize.Height() += 6; 485 SetSizePixel( aSize ); 486 aLogicalSize = PixelToLogic(aSize, MAP_APPFONT); 487 SetUnit( FUNIT_MM ); 488 SetDecimalDigits( 2 ); 489 SetMax( 5000 ); 490 SetMin( 0 ); 491 SetLast( 5000 ); 492 SetFirst( 0 ); 493 494 eDlgUnit = SfxModule::GetModuleFieldUnit( mxFrame ); 495 SetFieldUnit( *this, eDlgUnit, sal_False ); 496 Show(); 497 } 498 499 // ----------------------------------------------------------------------- 500 501 SvxMetricField::~SvxMetricField() 502 { 503 } 504 505 // ----------------------------------------------------------------------- 506 507 void SvxMetricField::Update( const XLineWidthItem* pItem ) 508 { 509 if ( pItem ) 510 { 511 if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) ) 512 SetMetricValue( *this, pItem->GetValue(), ePoolUnit ); 513 } 514 else 515 SetText( String() ); 516 } 517 518 // ----------------------------------------------------------------------- 519 520 void SvxMetricField::Modify() 521 { 522 MetricField::Modify(); 523 long nTmp = GetCoreValue( *this, ePoolUnit ); 524 XLineWidthItem aLineWidthItem( nTmp ); 525 526 Any a; 527 Sequence< PropertyValue > aArgs( 1 ); 528 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" )); 529 aLineWidthItem.QueryValue( a ); 530 aArgs[0].Value = a; 531 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 532 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )), 533 aArgs ); 534 // rBindings.GetDispatcher()->Execute( SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aLineWidthItem, 0L ); 535 } 536 537 // ----------------------------------------------------------------------- 538 539 void SvxMetricField::ReleaseFocus_Impl() 540 { 541 if( SfxViewShell::Current() ) 542 { 543 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 544 if ( pShellWnd ) 545 pShellWnd->GrabFocus(); 546 } 547 } 548 549 // ----------------------------------------------------------------------- 550 551 void SvxMetricField::Down() 552 { 553 sal_Int64 nValue = GetValue(); 554 nValue -= GetSpinSize(); 555 556 // Um unter OS/2 einen Sprung auf Max zu verhindern 557 if ( nValue >= GetMin() ) 558 MetricField::Down(); 559 } 560 561 // ----------------------------------------------------------------------- 562 563 void SvxMetricField::Up() 564 { 565 MetricField::Up(); 566 } 567 568 // ----------------------------------------------------------------------- 569 570 void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit ) 571 { 572 ePoolUnit = eUnit; 573 } 574 575 // ----------------------------------------------------------------------- 576 577 void SvxMetricField::RefreshDlgUnit() 578 { 579 FieldUnit eTmpUnit = SfxModule::GetModuleFieldUnit( mxFrame ); 580 if ( eDlgUnit != eTmpUnit ) 581 { 582 eDlgUnit = eTmpUnit; 583 SetFieldUnit( *this, eDlgUnit, sal_False ); 584 } 585 } 586 587 // ----------------------------------------------------------------------- 588 589 long SvxMetricField::PreNotify( NotifyEvent& rNEvt ) 590 { 591 sal_uInt16 nType = rNEvt.GetType(); 592 593 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) 594 aCurTxt = GetText(); 595 596 return MetricField::PreNotify( rNEvt ); 597 } 598 599 // ----------------------------------------------------------------------- 600 601 long SvxMetricField::Notify( NotifyEvent& rNEvt ) 602 { 603 long nHandled = MetricField::Notify( rNEvt ); 604 605 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 606 { 607 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 608 const KeyCode& rKey = pKEvt->GetKeyCode(); 609 SfxViewShell* pSh = SfxViewShell::Current(); 610 611 if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh ) 612 pSh->KeyInput( *pKEvt ); 613 else 614 { 615 bool bHandled = sal_False; 616 617 switch ( rKey.GetCode() ) 618 { 619 case KEY_RETURN: 620 Reformat(); 621 bHandled = sal_True; 622 break; 623 624 case KEY_ESCAPE: 625 SetText( aCurTxt ); 626 bHandled = sal_True; 627 break; 628 } 629 630 if ( bHandled ) 631 { 632 nHandled = 1; 633 Modify(); 634 ReleaseFocus_Impl(); 635 } 636 } 637 } 638 return nHandled; 639 } 640 /* -----------------------------08.03.2002 15:32------------------------------ 641 642 ---------------------------------------------------------------------------*/ 643 void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt ) 644 { 645 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 646 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 647 { 648 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); 649 } 650 651 MetricField::DataChanged( rDCEvt ); 652 } 653 654 //======================================================================== 655 // SvxFillTypeBox 656 //======================================================================== 657 658 SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) : 659 FillTypeLB( pParent, nBits | WB_TABSTOP ), 660 nCurPos ( 0 ), 661 bSelect ( sal_False ), 662 bRelease(sal_True) 663 { 664 SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT )); 665 Fill(); 666 SelectEntryPos( XFILL_SOLID ); 667 Show(); 668 } 669 670 // ----------------------------------------------------------------------- 671 672 SvxFillTypeBox::~SvxFillTypeBox() 673 { 674 } 675 676 // ----------------------------------------------------------------------- 677 678 long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt ) 679 { 680 sal_uInt16 nType = rNEvt.GetType(); 681 682 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) 683 nCurPos = GetSelectEntryPos(); 684 else if ( EVENT_LOSEFOCUS == nType 685 && Application::GetFocusWindow() 686 && !IsWindowOrChild( Application::GetFocusWindow(), sal_True ) ) 687 { 688 if ( !bSelect ) 689 SelectEntryPos( nCurPos ); 690 else 691 bSelect = sal_False; 692 } 693 694 return FillTypeLB::PreNotify( rNEvt ); 695 } 696 697 // ----------------------------------------------------------------------- 698 699 long SvxFillTypeBox::Notify( NotifyEvent& rNEvt ) 700 { 701 long nHandled = FillTypeLB::Notify( rNEvt ); 702 703 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 704 { 705 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 706 switch ( pKEvt->GetKeyCode().GetCode() ) 707 { 708 case KEY_RETURN: 709 nHandled = 1; 710 ( (Link&)GetSelectHdl() ).Call( this ); 711 break; 712 case KEY_TAB: 713 bRelease = sal_False; 714 ( (Link&)GetSelectHdl() ).Call( this ); 715 bRelease = sal_True; 716 break; 717 718 case KEY_ESCAPE: 719 SelectEntryPos( nCurPos ); 720 ReleaseFocus_Impl(); 721 nHandled = 1; 722 break; 723 } 724 } 725 return nHandled; 726 } 727 728 // ----------------------------------------------------------------------- 729 730 void SvxFillTypeBox::ReleaseFocus_Impl() 731 { 732 if( SfxViewShell::Current() ) 733 { 734 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 735 736 if ( pShellWnd ) 737 pShellWnd->GrabFocus(); 738 } 739 } 740 741 //======================================================================== 742 // SvxFillAttrBox 743 //======================================================================== 744 745 SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) : 746 747 FillAttrLB( pParent, nBits | WB_TABSTOP ), 748 749 nCurPos( 0 ), 750 bRelease( sal_True ) 751 752 { 753 SetPosPixel( Point( 90, 0 ) ); 754 SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT )); 755 Show(); 756 } 757 758 // ----------------------------------------------------------------------- 759 760 SvxFillAttrBox::~SvxFillAttrBox() 761 { 762 } 763 764 // ----------------------------------------------------------------------- 765 766 long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt ) 767 { 768 sal_uInt16 nType = rNEvt.GetType(); 769 770 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) 771 nCurPos = GetSelectEntryPos(); 772 773 return FillAttrLB::PreNotify( rNEvt ); 774 } 775 776 // ----------------------------------------------------------------------- 777 778 long SvxFillAttrBox::Notify( NotifyEvent& rNEvt ) 779 { 780 long nHandled = FillAttrLB::Notify( rNEvt ); 781 782 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 783 { 784 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 785 786 switch ( pKEvt->GetKeyCode().GetCode() ) 787 { 788 case KEY_RETURN: 789 ( (Link&)GetSelectHdl() ).Call( this ); 790 nHandled = 1; 791 break; 792 case KEY_TAB: 793 bRelease = sal_False; 794 GetSelectHdl().Call( this ); 795 bRelease = sal_True; 796 break; 797 case KEY_ESCAPE: 798 SelectEntryPos( nCurPos ); 799 ReleaseFocus_Impl(); 800 nHandled = 1; 801 break; 802 } 803 } 804 return nHandled; 805 } 806 807 // ----------------------------------------------------------------------- 808 809 void SvxFillAttrBox::Select() 810 { 811 FillAttrLB::Select(); 812 } 813 814 // ----------------------------------------------------------------------- 815 816 void SvxFillAttrBox::ReleaseFocus_Impl() 817 { 818 if( SfxViewShell::Current() ) 819 { 820 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 821 822 if ( pShellWnd ) 823 pShellWnd->GrabFocus(); 824 } 825 } 826