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