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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 // include --------------------------------------------------------------- 28 29 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 30 31 #ifndef _TOOLBOX_HXX //autogen 32 #include <vcl/toolbox.hxx> 33 #endif 34 #include <sfx2/app.hxx> 35 #include <sfx2/dispatch.hxx> 36 #include <sfx2/objsh.hxx> 37 38 #include <svx/dialogs.hrc> 39 #include "helpid.hrc" 40 41 #include "svx/drawitem.hxx" 42 #include "svx/xattr.hxx" 43 #include <svx/xtable.hxx> 44 #include "svx/linectrl.hxx" 45 #include <svx/itemwin.hxx> 46 #include <svx/dialmgr.hxx> 47 48 using namespace ::com::sun::star::uno; 49 using namespace ::com::sun::star::beans; 50 using namespace ::com::sun::star::util; 51 using namespace ::com::sun::star::frame; 52 using namespace ::com::sun::star::lang; 53 54 // Fuer Linienenden-Controller 55 #define MAX_LINES 12 56 57 // STATIC DATA ----------------------------------------------------------- 58 59 #define RESIZE_VALUE_POPUP(value_set) \ 60 { \ 61 Size aSize = GetOutputSizePixel(); \ 62 aSize.Width() -= 4; \ 63 aSize.Height() -= 4; \ 64 (value_set).SetPosSizePixel( Point(2,2), aSize ); \ 65 } 66 67 #define CALCSIZE_VALUE_POPUP(value_set,item_size) \ 68 { \ 69 Size aSize = (value_set).CalcWindowSizePixel( (item_size) ); \ 70 aSize.Width() += 4; \ 71 aSize.Height() += 4; \ 72 SetOutputSizePixel( aSize ); \ 73 } 74 75 76 SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem ); 77 SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem ); 78 SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem ); 79 SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl, SfxBoolItem ); 80 81 /************************************************************************* 82 |* 83 |* SvxLineStyleToolBoxControl 84 |* 85 \************************************************************************/ 86 87 SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId, 88 sal_uInt16 nId, 89 ToolBox& rTbx ) : 90 SfxToolBoxControl( nSlotId, nId, rTbx ), 91 pStyleItem ( NULL ), 92 pDashItem ( NULL ), 93 bUpdate ( sal_False ) 94 { 95 addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" ))); 96 addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DashListState" ))); 97 } 98 99 //======================================================================== 100 101 SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl() 102 { 103 delete pStyleItem; 104 delete pDashItem; 105 } 106 107 //======================================================================== 108 109 void SvxLineStyleToolBoxControl::StateChanged ( 110 111 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) 112 113 { 114 SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); 115 DBG_ASSERT( pBox, "Window not found!" ); 116 117 if( eState == SFX_ITEM_DISABLED ) 118 { 119 pBox->Disable(); 120 pBox->SetNoSelection(); 121 } 122 else 123 { 124 pBox->Enable(); 125 126 if ( eState == SFX_ITEM_AVAILABLE ) 127 { 128 if( nSID == SID_ATTR_LINE_STYLE ) 129 { 130 delete pStyleItem; 131 pStyleItem = (XLineStyleItem*)pState->Clone(); 132 } 133 else if( nSID == SID_ATTR_LINE_DASH ) 134 { 135 delete pDashItem; 136 pDashItem = (XLineDashItem*)pState->Clone(); 137 } 138 139 bUpdate = sal_True; 140 Update( pState ); 141 } 142 else if ( nSID != SID_DASH_LIST ) 143 { 144 // kein oder uneindeutiger Status 145 pBox->SetNoSelection(); 146 } 147 } 148 } 149 150 //======================================================================== 151 152 void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState ) 153 { 154 if ( pState && bUpdate ) 155 { 156 bUpdate = sal_False; 157 158 SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); 159 DBG_ASSERT( pBox, "Window not found!" ); 160 161 // Da der Timer unerwartet zuschlagen kann, kann es vorkommen, dass 162 // die LB noch nicht gefuellt ist. Ein ClearCache() am Control im 163 // DelayHdl() blieb ohne Erfolg. 164 if( pBox->GetEntryCount() == 0 ) 165 pBox->FillControl(); 166 167 XLineStyle eXLS; 168 169 if ( pStyleItem ) 170 eXLS = ( XLineStyle )pStyleItem->GetValue(); 171 else 172 eXLS = XLINE_NONE; 173 174 switch( eXLS ) 175 { 176 case XLINE_NONE: 177 pBox->SelectEntryPos( 0 ); 178 break; 179 180 case XLINE_SOLID: 181 pBox->SelectEntryPos( 1 ); 182 break; 183 184 case XLINE_DASH: 185 { 186 if( pDashItem ) 187 { 188 String aString( pDashItem->GetName() ); 189 pBox->SelectEntry( aString ); 190 } 191 else 192 pBox->SetNoSelection(); 193 } 194 break; 195 196 default: 197 DBG_ERROR( "Nicht unterstuetzter Linientyp" ); 198 break; 199 } 200 } 201 202 if ( pState && ( pState->ISA( SvxDashListItem ) ) ) 203 { 204 // Die Liste der Linienstile hat sich geaendert 205 SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); 206 DBG_ASSERT( pBox, "Window not found!" ); 207 208 String aString( pBox->GetSelectEntry() ); 209 pBox->Clear(); 210 pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) ); 211 pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID) ); 212 pBox->Fill( ((SvxDashListItem*)pState )->GetDashList() ); 213 pBox->SelectEntry( aString ); 214 } 215 } 216 217 //======================================================================== 218 219 Window* SvxLineStyleToolBoxControl::CreateItemWindow( Window *pParent ) 220 { 221 return new SvxLineBox( pParent, m_xFrame ); 222 } 223 224 /************************************************************************* 225 |* 226 |* SvxLineWidthToolBoxControl 227 |* 228 \************************************************************************/ 229 230 SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl( 231 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 232 SfxToolBoxControl( nSlotId, nId, rTbx ) 233 { 234 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ))); 235 } 236 237 //======================================================================== 238 239 SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl() 240 { 241 } 242 243 //======================================================================== 244 245 void SvxLineWidthToolBoxControl::StateChanged( 246 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) 247 { 248 SvxMetricField* pFld = (SvxMetricField*) 249 GetToolBox().GetItemWindow( GetId() ); 250 DBG_ASSERT( pFld, "Window not found" ); 251 252 if ( nSID == SID_ATTR_METRIC ) 253 { 254 pFld->RefreshDlgUnit(); 255 } 256 else 257 { 258 if ( eState == SFX_ITEM_DISABLED ) 259 { 260 pFld->Disable(); 261 pFld->SetText( String() ); 262 } 263 else 264 { 265 pFld->Enable(); 266 267 if ( eState == SFX_ITEM_AVAILABLE ) 268 { 269 DBG_ASSERT( pState->ISA(XLineWidthItem), "falscher ItemType" ); 270 271 // Core-Unit an MetricField uebergeben 272 // Darf nicht in CreateItemWin() geschehen! 273 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; // CD!!! GetCoreMetric(); 274 pFld->SetCoreUnit( eUnit ); 275 276 pFld->Update( (const XLineWidthItem*)pState ); 277 } 278 else 279 pFld->Update( NULL ); 280 } 281 } 282 } 283 284 //======================================================================== 285 286 Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent ) 287 { 288 return( new SvxMetricField( pParent, m_xFrame ) ); 289 } 290 291 /************************************************************************* 292 |* 293 |* SvxLineColorToolBoxControl 294 |* 295 \************************************************************************/ 296 297 SvxLineColorToolBoxControl::SvxLineColorToolBoxControl( 298 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 299 SfxToolBoxControl( nSlotId, nId, rTbx ) 300 { 301 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" ))); 302 } 303 304 //======================================================================== 305 306 SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl() 307 { 308 } 309 310 //======================================================================== 311 312 void SvxLineColorToolBoxControl::StateChanged( 313 314 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) 315 316 { 317 SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() ); 318 DBG_ASSERT( pBox, "Window not found" ); 319 320 if ( nSID != SID_COLOR_TABLE ) 321 { 322 if ( eState == SFX_ITEM_DISABLED ) 323 { 324 pBox->Disable(); 325 pBox->SetNoSelection(); 326 } 327 else 328 { 329 pBox->Enable(); 330 331 if ( eState == SFX_ITEM_AVAILABLE ) 332 { 333 DBG_ASSERT( pState->ISA(XLineColorItem), "falscher ItemTyoe" ); 334 pBox->Update( (const XLineColorItem*) pState ); 335 } 336 else 337 pBox->Update( NULL ); 338 } 339 } 340 else 341 Update( pState ); 342 } 343 344 //======================================================================== 345 346 void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState ) 347 { 348 if ( pState && ( pState->ISA( SvxColorTableItem ) ) ) 349 { 350 SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() ); 351 352 DBG_ASSERT( pBox, "Window not found" ); 353 354 // Die Liste der Farben (ColorTable) hat sich geaendert: 355 ::Color aTmpColor( pBox->GetSelectEntryColor() ); 356 pBox->Clear(); 357 pBox->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() ); 358 pBox->SelectEntry( aTmpColor ); 359 } 360 } 361 362 //======================================================================== 363 364 Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent ) 365 { 366 return new SvxColorBox( pParent, m_aCommandURL, m_xFrame ); 367 } 368 369 /************************************************************************* 370 |* 371 |* SvxLineEndWindow 372 |* 373 \************************************************************************/ 374 375 SvxLineEndWindow::SvxLineEndWindow( 376 sal_uInt16 nSlotId, 377 const Reference< XFrame >& rFrame, 378 const String& rWndTitle ) : 379 SfxPopupWindow( nSlotId, 380 rFrame, 381 WinBits( WB_BORDER | WB_STDFLOATWIN | WB_SIZEABLE | WB_3DLOOK ) ), 382 pLineEndList ( NULL ), 383 aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), 384 nCols ( 2 ), 385 nLines ( 12 ), 386 nLineEndWidth ( 400 ), 387 bPopupMode ( sal_True ), 388 mbInResize ( false ), 389 mxFrame ( rFrame ) 390 { 391 SetText( rWndTitle ); 392 implInit(); 393 } 394 395 SvxLineEndWindow::SvxLineEndWindow( 396 sal_uInt16 nSlotId, 397 const Reference< XFrame >& rFrame, 398 Window* pParentWindow, 399 const String& rWndTitle ) : 400 SfxPopupWindow( nSlotId, 401 rFrame, 402 pParentWindow, 403 WinBits( WB_BORDER | WB_STDFLOATWIN | WB_SIZEABLE | WB_3DLOOK ) ), 404 pLineEndList ( NULL ), 405 aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), 406 nCols ( 2 ), 407 nLines ( 12 ), 408 nLineEndWidth ( 400 ), 409 bPopupMode ( sal_True ), 410 mbInResize ( false ), 411 mxFrame ( rFrame ) 412 { 413 SetText( rWndTitle ); 414 implInit(); 415 } 416 417 void SvxLineEndWindow::implInit() 418 { 419 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 420 const SfxPoolItem* pItem = NULL; 421 422 SetHelpId( HID_POPUP_LINEEND ); 423 aLineEndSet.SetHelpId( HID_POPUP_LINEEND_CTRL ); 424 425 if ( pDocSh ) 426 { 427 pItem = pDocSh->GetItem( SID_LINEEND_LIST ); 428 if( pItem ) 429 pLineEndList = ( (SvxLineEndListItem*) pItem )->GetLineEndList(); 430 431 pItem = pDocSh->GetItem( SID_ATTR_LINEEND_WIDTH_DEFAULT ); 432 if( pItem ) 433 nLineEndWidth = ( (SfxUInt16Item*) pItem )->GetValue(); 434 } 435 DBG_ASSERT( pLineEndList, "LineEndList wurde nicht gefunden" ); 436 437 aLineEndSet.SetSelectHdl( LINK( this, SvxLineEndWindow, SelectHdl ) ); 438 aLineEndSet.SetColCount( nCols ); 439 440 // ValueSet mit Eintraegen der LineEndList fuellen 441 FillValueSet(); 442 443 AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndListState" ))); 444 445 //ChangeHelpId( HID_POPUP_LINEENDSTYLE ); 446 aLineEndSet.Show(); 447 } 448 449 SfxPopupWindow* SvxLineEndWindow::Clone() const 450 { 451 return new SvxLineEndWindow( GetId(), mxFrame, GetText() ); 452 } 453 454 // ----------------------------------------------------------------------- 455 456 SvxLineEndWindow::~SvxLineEndWindow() 457 { 458 } 459 460 // ----------------------------------------------------------------------- 461 462 IMPL_LINK( SvxLineEndWindow, SelectHdl, void *, EMPTYARG ) 463 { 464 XLineEndItem* pLineEndItem = NULL; 465 XLineStartItem* pLineStartItem = NULL; 466 sal_uInt16 nId = aLineEndSet.GetSelectItemId(); 467 468 if( nId == 1 ) 469 { 470 pLineStartItem = new XLineStartItem(); 471 } 472 else if( nId == 2 ) 473 { 474 pLineEndItem = new XLineEndItem(); 475 } 476 else if( nId % 2 ) // LinienAnfang 477 { 478 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 ); 479 pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ); 480 } 481 else // LinienEnde 482 { 483 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 ); 484 pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ); 485 } 486 487 if ( IsInPopupMode() ) 488 EndPopupMode(); 489 490 Sequence< PropertyValue > aArgs( 1 ); 491 Any a; 492 493 if ( pLineStartItem ) 494 { 495 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStart" )); 496 pLineStartItem->QueryValue( a ); 497 aArgs[0].Value = a; 498 } 499 else 500 { 501 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" )); 502 pLineEndItem->QueryValue( a ); 503 aArgs[0].Value = a; 504 } 505 506 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. 507 This instance may be deleted in the meantime (i.e. when a dialog is opened 508 while in Dispatch()), accessing members will crash in this case. */ 509 aLineEndSet.SetNoSelection(); 510 511 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 512 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndStyle" )), 513 aArgs ); 514 515 delete pLineEndItem; 516 delete pLineStartItem; 517 518 return 0; 519 } 520 521 // ----------------------------------------------------------------------- 522 523 void SvxLineEndWindow::FillValueSet() 524 { 525 if( pLineEndList ) 526 { 527 XLineEndEntry* pEntry = NULL; 528 Bitmap* pBmp = NULL; 529 VirtualDevice aVD; 530 531 long nCount = pLineEndList->Count(); 532 533 // Erster Eintrag: kein LinienEnde 534 // Temporaer wird ein Eintrag hinzugefuegt, um die UI-Bitmap zu erhalten 535 basegfx::B2DPolyPolygon aNothing; 536 pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) ); 537 pEntry = pLineEndList->GetLineEnd( nCount ); 538 pBmp = pLineEndList->GetBitmap( nCount ); 539 DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" ); 540 541 aBmpSize = pBmp->GetSizePixel(); 542 aVD.SetOutputSizePixel( aBmpSize, sal_False ); 543 aBmpSize.Width() = aBmpSize.Width() / 2; 544 Point aPt0( 0, 0 ); 545 Point aPt1( aBmpSize.Width(), 0 ); 546 547 aVD.DrawBitmap( Point(), *pBmp ); 548 aLineEndSet.InsertItem( 1, aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() ); 549 aLineEndSet.InsertItem( 2, aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() ); 550 551 delete pLineEndList->Remove( nCount ); 552 553 for( long i = 0; i < nCount; i++ ) 554 { 555 pEntry = pLineEndList->GetLineEnd( i ); 556 DBG_ASSERT( pEntry, "Konnte auf LineEndEntry nicht zugreifen" ); 557 pBmp = pLineEndList->GetBitmap( i ); 558 DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" ); 559 560 aVD.DrawBitmap( aPt0, *pBmp ); 561 aLineEndSet.InsertItem( (sal_uInt16)((i+1L)*2L+1L), aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() ); 562 aLineEndSet.InsertItem( (sal_uInt16)((i+2L)*2L), aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() ); 563 } 564 nLines = Min( (sal_uInt16)(nCount + 1), (sal_uInt16) MAX_LINES ); 565 aLineEndSet.SetLineCount( nLines ); 566 567 SetSize(); 568 } 569 } 570 571 // ----------------------------------------------------------------------- 572 573 void SvxLineEndWindow::Resize() 574 { 575 // since we change the size inside this call, check if we 576 // are called recursive 577 if( !mbInResize ) 578 { 579 mbInResize = true; 580 if ( !IsRollUp() ) 581 { 582 aLineEndSet.SetColCount( nCols ); 583 aLineEndSet.SetLineCount( nLines ); 584 585 SetSize(); 586 587 Size aSize = GetOutputSizePixel(); 588 aSize.Width() -= 4; 589 aSize.Height() -= 4; 590 aLineEndSet.SetPosSizePixel( Point( 2, 2 ), aSize ); 591 } 592 //SfxPopupWindow::Resize(); 593 mbInResize = false; 594 } 595 } 596 597 // ----------------------------------------------------------------------- 598 599 void __EXPORT SvxLineEndWindow::Resizing( Size& rNewSize ) 600 { 601 Size aBitmapSize = aBmpSize; // -> Member 602 aBitmapSize.Width() += 6; // 603 aBitmapSize.Height() += 6; // 604 605 Size aItemSize = aLineEndSet.CalcItemSizePixel( aBitmapSize ); // -> Member 606 //Size aOldSize = GetOutputSizePixel(); // fuer Breite 607 608 sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member 609 610 // Spalten ermitteln 611 long nItemW = aItemSize.Width(); 612 long nW = rNewSize.Width(); 613 nCols = (sal_uInt16) Max( ( (sal_uIntPtr)(( nW + nItemW ) / ( nItemW * 2 ) )), 614 (sal_uIntPtr) 1L ); 615 nCols *= 2; 616 617 // Reihen ermitteln 618 long nItemH = aItemSize.Height(); 619 long nH = rNewSize.Height(); 620 nLines = (sal_uInt16) Max( ( ( nH + nItemH / 2 ) / nItemH ), 1L ); 621 622 sal_uInt16 nMaxCols = nItemCount / nLines; 623 if( nItemCount % nLines ) 624 nMaxCols++; 625 if( nCols > nMaxCols ) 626 nCols = nMaxCols; 627 nW = nItemW * nCols; 628 629 // Keine ungerade Anzahl von Spalten 630 if( nCols % 2 ) 631 nCols--; 632 nCols = Max( nCols, (sal_uInt16) 2 ); 633 634 sal_uInt16 nMaxLines = nItemCount / nCols; 635 if( nItemCount % nCols ) 636 nMaxLines++; 637 if( nLines > nMaxLines ) 638 nLines = nMaxLines; 639 nH = nItemH * nLines; 640 641 rNewSize.Width() = nW; 642 rNewSize.Height() = nH; 643 } 644 // ----------------------------------------------------------------------- 645 646 void SvxLineEndWindow::StartSelection() 647 { 648 aLineEndSet.StartSelection(); 649 } 650 651 // ----------------------------------------------------------------------- 652 653 sal_Bool SvxLineEndWindow::Close() 654 { 655 return SfxPopupWindow::Close(); 656 } 657 658 // ----------------------------------------------------------------------- 659 660 void SvxLineEndWindow::StateChanged( 661 sal_uInt16 nSID, SfxItemState, const SfxPoolItem* pState ) 662 { 663 if ( nSID == SID_LINEEND_LIST ) 664 { 665 // Die Liste der LinienEnden (LineEndList) hat sich geaendert: 666 if ( pState && pState->ISA( SvxLineEndListItem )) 667 { 668 pLineEndList = ((SvxLineEndListItem*)pState)->GetLineEndList(); 669 DBG_ASSERT( pLineEndList, "LineEndList nicht gefunden" ); 670 671 aLineEndSet.Clear(); 672 FillValueSet(); 673 674 Size aSize = GetOutputSizePixel(); 675 Resizing( aSize ); 676 Resize(); 677 } 678 } 679 } 680 681 // ----------------------------------------------------------------------- 682 683 void SvxLineEndWindow::PopupModeEnd() 684 { 685 if ( IsVisible() ) 686 { 687 bPopupMode = sal_False; 688 SetSize(); 689 } 690 SfxPopupWindow::PopupModeEnd(); 691 } 692 693 // ----------------------------------------------------------------------- 694 695 void SvxLineEndWindow::SetSize() 696 { 697 //if( !bPopupMode ) 698 if( !IsInPopupMode() ) 699 { 700 sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member 701 sal_uInt16 nMaxLines = nItemCount / nCols; // -> Member ? 702 if( nItemCount % nCols ) 703 nMaxLines++; 704 705 WinBits nBits = aLineEndSet.GetStyle(); 706 if ( nLines == nMaxLines ) 707 nBits &= ~WB_VSCROLL; 708 else 709 nBits |= WB_VSCROLL; 710 aLineEndSet.SetStyle( nBits ); 711 } 712 713 Size aSize( aBmpSize ); 714 aSize.Width() += 6; 715 aSize.Height() += 6; 716 aSize = aLineEndSet.CalcWindowSizePixel( aSize ); 717 aSize.Width() += 4; 718 aSize.Height() += 4; 719 SetOutputSizePixel( aSize ); 720 aSize.Height() = aBmpSize.Height(); 721 aSize.Height() += 14; 722 //SetMinOutputSizePixel( aSize ); 723 } 724 725 void SvxLineEndWindow::GetFocus (void) 726 { 727 SfxPopupWindow::GetFocus(); 728 // Grab the focus to the line ends value set so that it can be controlled 729 // with the keyboard. 730 aLineEndSet.GrabFocus(); 731 } 732 733 /************************************************************************* 734 |* 735 |* SvxLineEndToolBoxControl 736 |* 737 \************************************************************************/ 738 739 SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) : 740 SfxToolBoxControl( nSlotId, nId, rTbx ) 741 { 742 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); 743 rTbx.Invalidate(); 744 } 745 746 // ----------------------------------------------------------------------- 747 748 SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl() 749 { 750 } 751 752 // ----------------------------------------------------------------------- 753 754 SfxPopupWindowType SvxLineEndToolBoxControl::GetPopupWindowType() const 755 { 756 return SFX_POPUPWINDOW_ONCLICK; 757 } 758 759 // ----------------------------------------------------------------------- 760 761 SfxPopupWindow* SvxLineEndToolBoxControl::CreatePopupWindow() 762 { 763 SvxLineEndWindow* pLineEndWin = 764 new SvxLineEndWindow( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) ); 765 pLineEndWin->StartPopupMode( &GetToolBox(), sal_True ); 766 pLineEndWin->StartSelection(); 767 SetPopupWindow( pLineEndWin ); 768 return pLineEndWin; 769 } 770 771 // ----------------------------------------------------------------------- 772 773 void SvxLineEndToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* ) 774 { 775 sal_uInt16 nId = GetId(); 776 ToolBox& rTbx = GetToolBox(); 777 778 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); 779 rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); 780 } 781