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_extensions.hxx" 30 #include <comphelper/processfactory.hxx> 31 #include <osl/mutex.hxx> 32 #include <tools/urlobj.hxx> 33 #include <com/sun/star/frame/XDispatch.hpp> 34 #include <com/sun/star/frame/XDispatchProvider.hpp> 35 #include <com/sun/star/util/XURLTransformer.hpp> 36 #include <com/sun/star/frame/FrameSearchFlag.hpp> 37 #include <datman.hxx> 38 #include <tools/debug.hxx> 39 #ifndef _SVX_SVXIDS_HRC 40 #include <svx/svxids.hrc> 41 #endif 42 #include <svtools/miscopt.hxx> 43 #include <svtools/imgdef.hxx> 44 #include <vcl/svapp.hxx> 45 #include <vcl/mnemonic.hxx> 46 #include "bibbeam.hxx" 47 #include "toolbar.hrc" 48 #include "bibresid.hxx" 49 50 #ifndef BIBTOOLS_HXX 51 #include "bibtools.hxx" 52 #endif 53 #include <vos/mutex.hxx> 54 55 using namespace ::rtl; 56 using namespace ::com::sun::star; 57 using namespace ::com::sun::star::uno; 58 using namespace ::com::sun::star::beans; 59 #define C2U(cChar) OUString::createFromAscii(cChar) 60 61 62 // Konstanten ------------------------------------------------------------- 63 64 65 BibToolBarListener::BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 66 nIndex(nId), 67 aCommand(aStr), 68 pToolBar(pTB) 69 { 70 } 71 72 BibToolBarListener::~BibToolBarListener() 73 { 74 } 75 76 void BibToolBarListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) 77 { 78 if(rEvt.FeatureURL.Complete == aCommand) 79 { 80 vos::OGuard aGuard(Application::GetSolarMutex()); 81 pToolBar->EnableItem(nIndex,rEvt.IsEnabled); 82 83 ::com::sun::star::uno::Any aState=rEvt.State; 84 if(aState.getValueType()==::getBooleanCppuType()) 85 { 86 sal_Bool bChecked= *(sal_Bool*)aState.getValue(); 87 pToolBar->CheckItem(nIndex, bChecked); 88 } 89 90 /* 91 rtl::OUString FeatureDescriptor; 92 sal_Bool Requery; 93 ::com::sun::star::uno::Any State;*/ 94 } 95 }; 96 97 rtl::OUString BibToolBarListener::GetCommand() 98 { 99 return aCommand; 100 } 101 102 BibTBListBoxListener::BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 103 BibToolBarListener(pTB,aStr,nId) 104 { 105 } 106 107 BibTBListBoxListener::~BibTBListBoxListener() 108 { 109 } 110 111 void BibTBListBoxListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) 112 { 113 if(rEvt.FeatureURL.Complete == GetCommand()) 114 { 115 vos::OGuard aGuard(Application::GetSolarMutex()); 116 pToolBar->EnableSourceList(rEvt.IsEnabled); 117 118 Any aState = rEvt.State; 119 if(aState.getValueType() == ::getCppuType((Sequence<rtl::OUString>*)0)) 120 { 121 pToolBar->UpdateSourceList(sal_False); 122 pToolBar->ClearSourceList(); 123 124 Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*)aState.getValue(); 125 const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); 126 127 sal_uInt32 nCount = pStringSeq->getLength(); 128 XubString aEntry; 129 for( sal_uInt32 i=0; i<nCount; i++ ) 130 { 131 aEntry = String(pStringArray[i]); 132 pToolBar->InsertSourceEntry(aEntry); 133 } 134 pToolBar->UpdateSourceList(sal_True); 135 } 136 137 XubString aStr = String(rEvt.FeatureDescriptor); 138 pToolBar->SelectSourceEntry(aStr); 139 } 140 }; 141 142 BibTBQueryMenuListener::BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 143 BibToolBarListener(pTB,aStr,nId) 144 { 145 } 146 147 BibTBQueryMenuListener::~BibTBQueryMenuListener() 148 { 149 } 150 151 void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) 152 { 153 if(rEvt.FeatureURL.Complete == GetCommand()) 154 { 155 vos::OGuard aGuard(Application::GetSolarMutex()); 156 pToolBar->EnableSourceList(rEvt.IsEnabled); 157 158 uno::Any aState=rEvt.State; 159 if(aState.getValueType()==::getCppuType((Sequence<rtl::OUString>*)0)) 160 { 161 pToolBar->ClearFilterMenu(); 162 163 Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*) aState.getValue(); 164 const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); 165 166 sal_uInt32 nCount = pStringSeq->getLength(); 167 for( sal_uInt32 i=0; i<nCount; i++ ) 168 { 169 sal_uInt16 nID=pToolBar->InsertFilterItem(String(pStringArray[i])); 170 if(pStringArray[i]==rEvt.FeatureDescriptor) 171 { 172 // XubString aStr = rEvt.FeatureDescriptor; 173 pToolBar->SelectFilterItem(nID); 174 } 175 } 176 } 177 } 178 }; 179 180 BibTBEditListener::BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): 181 BibToolBarListener(pTB,aStr,nId) 182 { 183 } 184 185 BibTBEditListener::~BibTBEditListener() 186 { 187 } 188 189 void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) 190 { 191 if(rEvt.FeatureURL.Complete == GetCommand()) 192 { 193 vos::OGuard aGuard(Application::GetSolarMutex()); 194 pToolBar->EnableQuery(rEvt.IsEnabled); 195 196 uno::Any aState=rEvt.State; 197 if(aState.getValueType()==::getCppuType((const OUString*)0)) 198 { 199 String aStr = String(*(OUString*) aState.getValue()); 200 pToolBar->SetQueryString(aStr); 201 } 202 } 203 } 204 205 SV_IMPL_PTRARR( BibToolBarListenerArr, BibToolBarListenerPtr); 206 207 BibToolBar::BibToolBar(Window* pParent, Link aLink, WinBits nStyle): 208 ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)), 209 aImgLst(BibResId( RID_TOOLBAR_IMGLIST )), 210 aImgLstHC(BibResId(RID_TOOLBAR_IMGLIST_HC )), 211 aBigImgLst(BibResId( RID_TOOLBAR_BIGIMGLIST )), 212 aBigImgLstHC(BibResId( RID_TOOLBAR_BIGIMGLIST_HC )), 213 aFtSource(this,WB_VCENTER), 214 aLBSource(this,WB_DROPDOWN), 215 aFtQuery(this,WB_VCENTER), 216 aEdQuery(this), 217 nMenuId(0), 218 nSelMenuItem(0), 219 aLayoutManager( aLink ), 220 nSymbolsSize( SFX_SYMBOLS_SIZE_SMALL ), 221 nOutStyle( 0 ) 222 { 223 SvtMiscOptions aSvtMiscOptions; 224 nSymbolsSize = aSvtMiscOptions.GetCurrentSymbolsSize(); 225 nOutStyle = aSvtMiscOptions.GetToolboxStyle(); 226 227 ApplyImageList(); 228 SetStyle(GetStyle()|nStyle); 229 SetOutStyle(TOOLBOX_STYLE_FLAT); 230 Size aSize=GetSizePixel(); 231 Size a2Size(GetOutputSizePixel()); 232 a2Size.Width()=100; 233 aLBSource.SetSizePixel(a2Size); 234 aLBSource.SetDropDownLineCount(9); 235 aLBSource.Show(); 236 aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl)); 237 238 SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); 239 Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); 240 241 aTimer.SetTimeoutHdl(LINK( this, BibToolBar, SendSelHdl)); 242 aTimer.SetTimeout(400); 243 244 SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl)); 245 246 aEdQuery.SetSizePixel(aLBSource.GetSizePixel()); 247 aEdQuery.Show(); 248 249 XubString aStr=GetItemText(TBC_FT_SOURCE); 250 Rectangle aRect=GetItemRect(TBC_FT_SOURCE); 251 aFtSource.SetText(aStr); 252 aFtSource.SetSizePixel(aRect.GetSize()); 253 aFtSource.SetBackground(Wallpaper( COL_TRANSPARENT )); 254 255 aStr=GetItemText(TBC_FT_QUERY); 256 aRect=GetItemRect(TBC_FT_QUERY); 257 aFtQuery.SetText(aStr); 258 aFtQuery.SetSizePixel(aRect.GetSize()); 259 aFtQuery.SetBackground(Wallpaper( COL_TRANSPARENT )); 260 261 SetItemWindow(TBC_FT_SOURCE,&aFtSource); 262 SetItemWindow(TBC_LB_SOURCE,&aLBSource); 263 SetItemWindow(TBC_FT_QUERY ,&aFtQuery); 264 SetItemWindow(TBC_ED_QUERY ,&aEdQuery); 265 266 ::bib::AddToTaskPaneList( this ); 267 } 268 269 BibToolBar::~BibToolBar() 270 { 271 SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); 272 Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); 273 ::bib::RemoveFromTaskPaneList( this ); 274 } 275 276 void BibToolBar::InitListener() 277 { 278 sal_uInt16 nCount=GetItemCount(); 279 280 uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 281 uno::Reference< frame::XDispatch > xDisp(xController,UNO_QUERY); 282 283 uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); 284 if( xTrans.is() ) 285 { 286 util::URL aQueryURL; 287 aQueryURL.Complete = C2U(".uno:Bib/MenuFilter"); 288 xTrans->parseStrict( aQueryURL); 289 BibToolBarListener* pQuery=new BibTBQueryMenuListener(this,aQueryURL.Complete,TBC_BT_AUTOFILTER); 290 xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL); 291 292 for(sal_uInt16 nPos=0;nPos<nCount;nPos++) 293 { 294 sal_uInt16 nId=GetItemId(nPos); 295 if(!nId || nId==TBC_FT_SOURCE || nId==TBC_FT_QUERY) 296 continue; 297 298 util::URL aURL; 299 aURL.Complete = GetItemCommand(nId); 300 if(!aURL.Complete.getLength()) 301 continue; 302 303 xTrans->parseStrict( aURL ); 304 305 BibToolBarListener* pListener=NULL; 306 if(nId==TBC_LB_SOURCE) 307 { 308 pListener=new BibTBListBoxListener(this,aURL.Complete,nId); 309 } 310 else if(nId==TBC_ED_QUERY) 311 { 312 pListener=new BibTBEditListener(this,aURL.Complete,nId); 313 } 314 else 315 { 316 pListener=new BibToolBarListener(this,aURL.Complete,nId); 317 } 318 319 BibToolBarListenerPtr pxInsert = new Reference<frame::XStatusListener>; 320 (*pxInsert) = pListener; 321 aListenerArr.Insert( pxInsert, aListenerArr.Count() ); 322 xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pListener),aURL); 323 } 324 } 325 } 326 327 void BibToolBar::SetXController(const uno::Reference< frame::XController > & xCtr) 328 { 329 xController=xCtr; 330 InitListener(); 331 332 } 333 334 void BibToolBar::Select() 335 { 336 sal_uInt16 nId=GetCurItemId(); 337 338 if(nId!=TBC_BT_AUTOFILTER) 339 { 340 SendDispatch(nId,Sequence<PropertyValue>() ); 341 } 342 else 343 { 344 Sequence<PropertyValue> aPropVal(2); 345 PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 346 pPropertyVal[0].Name=C2U("QueryText"); 347 rtl::OUString aSelection = aEdQuery.GetText(); 348 pPropertyVal[0].Value <<= aSelection; 349 350 pPropertyVal[1].Name=C2U("QueryField"); 351 pPropertyVal[1].Value <<= aQueryField; 352 SendDispatch(nId,aPropVal); 353 } 354 } 355 356 void BibToolBar::SendDispatch(sal_uInt16 nId, const Sequence< PropertyValue >& rArgs) 357 { 358 rtl::OUString aCommand = GetItemCommand(nId); 359 360 uno::Reference< frame::XDispatchProvider > xDSP( xController, UNO_QUERY ); 361 362 if( xDSP.is() && aCommand.getLength()) 363 { 364 uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 365 366 uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); 367 if( xTrans.is() ) 368 { 369 // Datei laden 370 util::URL aURL; 371 aURL.Complete = aCommand; 372 373 xTrans->parseStrict( aURL ); 374 375 uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, rtl::OUString(), frame::FrameSearchFlag::SELF ); 376 377 if ( xDisp.is() ) 378 xDisp->dispatch( aURL, rArgs); 379 } 380 } 381 382 } 383 384 void BibToolBar::Click() 385 { 386 sal_uInt16 nId=GetCurItemId(); 387 388 if(nId == TBC_BT_COL_ASSIGN ) 389 { 390 if(pDatMan) 391 pDatMan->CreateMappingDialog(GetParent()); 392 CheckItem( nId, sal_False ); 393 } 394 else if(nId == TBC_BT_CHANGESOURCE) 395 { 396 if(pDatMan) 397 { 398 OUString sNew = pDatMan->CreateDBChangeDialog(GetParent()); 399 if(sNew.getLength()) 400 pDatMan->setActiveDataSource(sNew); 401 } 402 CheckItem( nId, sal_False ); 403 } 404 } 405 406 void BibToolBar::ClearFilterMenu() 407 { 408 aPopupMenu.Clear(); 409 nMenuId=0; 410 } 411 sal_uInt16 BibToolBar::InsertFilterItem(const XubString& aMenuEntry) 412 { 413 nMenuId++; 414 aPopupMenu.InsertItem(nMenuId,aMenuEntry); 415 416 return nMenuId; 417 } 418 void BibToolBar::SelectFilterItem(sal_uInt16 nId) 419 { 420 aPopupMenu.CheckItem(nId); 421 nSelMenuItem=nId; 422 aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) ); 423 } 424 425 void BibToolBar::EnableSourceList(sal_Bool bFlag) 426 { 427 aFtSource.Enable(bFlag); 428 aLBSource.Enable(bFlag); 429 } 430 431 void BibToolBar::ClearSourceList() 432 { 433 aLBSource.Clear(); 434 } 435 436 void BibToolBar::UpdateSourceList(sal_Bool bFlag) 437 { 438 aLBSource.SetUpdateMode(bFlag); 439 } 440 441 void BibToolBar::InsertSourceEntry(const XubString& aEntry, sal_uInt16 nPos) 442 { 443 aLBSource.InsertEntry(aEntry, nPos); 444 } 445 446 void BibToolBar::SelectSourceEntry(const XubString& aStr) 447 { 448 aLBSource.SelectEntry(aStr); 449 } 450 451 void BibToolBar::EnableQuery(sal_Bool bFlag) 452 { 453 aFtQuery.Enable(bFlag); 454 aEdQuery.Enable(bFlag); 455 } 456 457 void BibToolBar::SetQueryString(const XubString& aStr) 458 { 459 aEdQuery.SetText(aStr); 460 } 461 462 463 long BibToolBar::PreNotify( NotifyEvent& rNEvt ) 464 { 465 long nResult=sal_True; 466 467 sal_uInt16 nSwitch=rNEvt.GetType(); 468 if(aEdQuery.HasFocus() && nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP) 469 { 470 const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); 471 sal_uInt16 nKey = aKeyCode.GetCode(); 472 if(nKey == KEY_RETURN) 473 { 474 Sequence<PropertyValue> aPropVal(2); 475 PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 476 pPropertyVal[0].Name = C2U("QueryText"); 477 rtl::OUString aSelection = aEdQuery.GetText(); 478 pPropertyVal[0].Value <<= aSelection; 479 pPropertyVal[1].Name=C2U("QueryField"); 480 pPropertyVal[1].Value <<= aQueryField; 481 SendDispatch(TBC_BT_AUTOFILTER,aPropVal); 482 return nResult; 483 } 484 485 } 486 487 nResult=ToolBox::PreNotify(rNEvt); 488 489 return nResult; 490 } 491 492 IMPL_LINK( BibToolBar, SelHdl, ListBox*, /*pLb*/ ) 493 { 494 aTimer.Start(); 495 return 0; 496 } 497 498 IMPL_LINK( BibToolBar, SendSelHdl, Timer*,/*pT*/) 499 { 500 Sequence<PropertyValue> aPropVal(1); 501 PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 502 pPropertyVal[0].Name = C2U("DataSourceName"); 503 String aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) ); 504 rtl::OUString aSelection = aEntry; 505 pPropertyVal[0].Value <<= aSelection; 506 SendDispatch(TBC_LB_SOURCE,aPropVal); 507 508 return 0; 509 } 510 //----------------------------------------------------------------------------- 511 IMPL_LINK( BibToolBar, MenuHdl, ToolBox*, /*pToolbox*/) 512 { 513 sal_uInt16 nId=GetCurItemId(); 514 if(nId==TBC_BT_AUTOFILTER) 515 { 516 EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage) 517 518 SetItemDown(TBC_BT_AUTOFILTER,sal_True); 519 nId = aPopupMenu.Execute(this, GetItemRect(TBC_BT_AUTOFILTER)); 520 521 522 if(nId>0) 523 { 524 aPopupMenu.CheckItem(nSelMenuItem,sal_False); 525 aPopupMenu.CheckItem(nId); 526 nSelMenuItem=nId; 527 aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) ); 528 Sequence<PropertyValue> aPropVal(2); 529 PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); 530 pPropertyVal[0].Name = C2U("QueryText"); 531 rtl::OUString aSelection = aEdQuery.GetText(); 532 pPropertyVal[0].Value <<= aSelection; 533 pPropertyVal[1].Name=C2U("QueryField"); 534 pPropertyVal[1].Value <<= aQueryField; 535 SendDispatch(TBC_BT_AUTOFILTER,aPropVal); 536 } 537 538 Point aPoint; 539 MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC ); 540 MouseMove( aLeave ); 541 SetItemDown(TBC_BT_AUTOFILTER,sal_False); 542 543 544 } 545 return 0; 546 } 547 //----------------------------------------------------------------------------- 548 void BibToolBar::statusChanged(const frame::FeatureStateEvent& rEvent) 549 throw( uno::RuntimeException ) 550 { 551 for(sal_uInt16 i = 0; i < aListenerArr.Count(); i++) 552 { 553 BibToolBarListenerPtr pListener = aListenerArr.GetObject(i); 554 (*pListener)->statusChanged(rEvent); 555 } 556 } 557 /* -----------------------------07.05.2002 15:08------------------------------ 558 559 ---------------------------------------------------------------------------*/ 560 void BibToolBar::DataChanged( const DataChangedEvent& rDCEvt ) 561 { 562 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 563 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 564 ApplyImageList(); 565 ToolBox::DataChanged( rDCEvt ); 566 } 567 /* -----------------------------07.05.2002 15:09------------------------------ 568 ---------------------------------------------------------------------------*/ 569 570 IMPL_LINK( BibToolBar, OptionsChanged_Impl, void*, /*pVoid*/ ) 571 { 572 sal_Bool bRebuildToolBar = sal_False; 573 sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 574 if ( nSymbolsSize != eSymbolsSize ) 575 { 576 nSymbolsSize = eSymbolsSize; 577 bRebuildToolBar = sal_True; 578 } 579 else if ( nOutStyle != SvtMiscOptions().GetToolboxStyle() ) 580 { 581 nOutStyle = SvtMiscOptions().GetToolboxStyle(); 582 SetOutStyle( nOutStyle ); 583 bRebuildToolBar = sal_True; 584 } 585 586 if ( bRebuildToolBar ) 587 RebuildToolbar(); 588 589 return 0L; 590 } 591 592 //----------------------------------------------------------------------------- 593 594 IMPL_LINK( BibToolBar, SettingsChanged_Impl, void*, /*pVoid*/ ) 595 { 596 // Check if toolbar button size have changed and we have to use system settings 597 sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 598 if ( eSymbolsSize != nSymbolsSize ) 599 { 600 nSymbolsSize = eSymbolsSize; 601 RebuildToolbar(); 602 } 603 604 return 0L; 605 } 606 607 //----------------------------------------------------------------------------- 608 void BibToolBar::RebuildToolbar() 609 { 610 ApplyImageList(); 611 // We have to call parent asynchronously as SetSize works also asynchronously! 612 Application::PostUserEvent( aLayoutManager, 0 ); 613 } 614 615 //----------------------------------------------------------------------------- 616 617 void BibToolBar::ApplyImageList() 618 { 619 ImageList& rList = ( nSymbolsSize == SFX_SYMBOLS_SIZE_SMALL ) ? 620 ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImgLstHC : aImgLst ) : 621 ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aBigImgLstHC : aBigImgLst ); 622 623 SetItemImage(TBC_BT_AUTOFILTER , rList.GetImage(SID_FM_AUTOFILTER)); 624 SetItemImage(TBC_BT_FILTERCRIT , rList.GetImage(SID_FM_FILTERCRIT)); 625 SetItemImage(TBC_BT_REMOVEFILTER, rList.GetImage(SID_FM_REMOVE_FILTER_SORT )); 626 AdjustToolBox(); 627 } 628 629 void BibToolBar::AdjustToolBox() 630 { 631 Size aOldSize = GetSizePixel(); 632 Size aSize = CalcWindowSizePixel(); 633 if ( !aSize.Width() ) 634 aSize.Width() = aOldSize.Width(); 635 else if ( !aSize.Height() ) 636 aSize.Height() = aOldSize.Height(); 637 638 Size aTbSize = GetSizePixel(); 639 if ( 640 (aSize.Width() && aSize.Width() != aTbSize.Width()) || 641 (aSize.Height() && aSize.Height() != aTbSize.Height()) 642 ) 643 { 644 SetPosSizePixel( GetPosPixel(), aSize ); 645 Invalidate(); 646 } 647 } 648