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