1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef DBAUI_DBTREELISTBOX_HXX
28cdf0e10cSrcweir #include "dbtreelistbox.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _DBU_RESOURCE_HRC_
31cdf0e10cSrcweir #include "dbu_resource.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX
34cdf0e10cSrcweir #include "browserids.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBAUI_LISTVIEWITEMS_HXX_
37cdf0e10cSrcweir #include "listviewitems.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBACCESS_UI_CALLBACKS_HXX_
40cdf0e10cSrcweir #include "callbacks.hxx"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir
43cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURELISTENER_HDL_
44cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureListener.hdl>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURERECOGNIZER_HPP_
47cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_XCONTEXTMENUINTERCEPTOR_HPP_
50cdf0e10cSrcweir #include <com/sun/star/ui/XContextMenuInterceptor.hpp>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_URL_HPP_
54cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE1_HXX_
57cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
60cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #ifndef _SV_HELP_HXX
63cdf0e10cSrcweir #include <vcl/help.hxx>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef _DBAUI_TABLETREE_HRC_
66cdf0e10cSrcweir #include "tabletree.hrc"
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef DBAUI_ICONTROLLER_HXX
69cdf0e10cSrcweir #include "IController.hxx"
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_
72cdf0e10cSrcweir #include <framework/actiontriggerhelper.hxx>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
75cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir #include <framework/imageproducer.hxx>
78cdf0e10cSrcweir #include <vcl/svapp.hxx>
79cdf0e10cSrcweir #include <memory>
80cdf0e10cSrcweir
81cdf0e10cSrcweir // .........................................................................
82cdf0e10cSrcweir namespace dbaui
83cdf0e10cSrcweir {
84cdf0e10cSrcweir // .........................................................................
85cdf0e10cSrcweir
86cdf0e10cSrcweir using namespace ::com::sun::star;
87cdf0e10cSrcweir using namespace ::com::sun::star::uno;
88cdf0e10cSrcweir using namespace ::com::sun::star::beans;
89cdf0e10cSrcweir using namespace ::com::sun::star::lang;
90cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
91cdf0e10cSrcweir using namespace ::com::sun::star::frame;
92cdf0e10cSrcweir using namespace ::com::sun::star::ui;
93cdf0e10cSrcweir using namespace ::com::sun::star::view;
94cdf0e10cSrcweir
DBG_NAME(DBTreeListBox)95cdf0e10cSrcweir DBG_NAME(DBTreeListBox)
96cdf0e10cSrcweir #define SPACEBETWEENENTRIES 4
97cdf0e10cSrcweir //========================================================================
98cdf0e10cSrcweir // class DBTreeListBox
99cdf0e10cSrcweir //========================================================================
100cdf0e10cSrcweir //------------------------------------------------------------------------
101cdf0e10cSrcweir DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle ,sal_Bool _bHandleEnterKey)
102cdf0e10cSrcweir :SvTreeListBox(pParent,nWinStyle)
103cdf0e10cSrcweir ,m_pDragedEntry(NULL)
104cdf0e10cSrcweir ,m_pActionListener(NULL)
105cdf0e10cSrcweir ,m_pContextMenuProvider( NULL )
106cdf0e10cSrcweir ,m_bHandleEnterKey(_bHandleEnterKey)
107cdf0e10cSrcweir ,m_xORB(_rxORB)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir DBG_CTOR(DBTreeListBox,NULL);
110cdf0e10cSrcweir init();
111cdf0e10cSrcweir }
112cdf0e10cSrcweir // -----------------------------------------------------------------------------
DBTreeListBox(Window * pParent,const Reference<XMultiServiceFactory> & _rxORB,const ResId & rResId,sal_Bool _bHandleEnterKey)113cdf0e10cSrcweir DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId,sal_Bool _bHandleEnterKey)
114cdf0e10cSrcweir :SvTreeListBox(pParent,rResId)
115cdf0e10cSrcweir ,m_pDragedEntry(NULL)
116cdf0e10cSrcweir ,m_pActionListener(NULL)
117cdf0e10cSrcweir ,m_pContextMenuProvider( NULL )
118cdf0e10cSrcweir ,m_bHandleEnterKey(_bHandleEnterKey)
119cdf0e10cSrcweir ,m_xORB(_rxORB)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir DBG_CTOR(DBTreeListBox,NULL);
122cdf0e10cSrcweir init();
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // -----------------------------------------------------------------------------
init()125cdf0e10cSrcweir void DBTreeListBox::init()
126cdf0e10cSrcweir {
127cdf0e10cSrcweir sal_uInt16 nSize = SPACEBETWEENENTRIES;
128cdf0e10cSrcweir SetSpaceBetweenEntries(nSize);
129cdf0e10cSrcweir
130cdf0e10cSrcweir m_aTimer.SetTimeout(900);
131cdf0e10cSrcweir m_aTimer.SetTimeoutHdl(LINK(this, DBTreeListBox, OnTimeOut));
132cdf0e10cSrcweir
133cdf0e10cSrcweir m_aScrollHelper.setUpScrollMethod( LINK(this, DBTreeListBox, ScrollUpHdl) );
134cdf0e10cSrcweir m_aScrollHelper.setDownScrollMethod( LINK(this, DBTreeListBox, ScrollDownHdl) );
135cdf0e10cSrcweir
136cdf0e10cSrcweir SetNodeDefaultImages( );
137cdf0e10cSrcweir
138cdf0e10cSrcweir EnableContextMenuHandling();
139cdf0e10cSrcweir
140cdf0e10cSrcweir SetStyle( GetStyle() | WB_QUICK_SEARCH );
141cdf0e10cSrcweir }
142cdf0e10cSrcweir //------------------------------------------------------------------------
~DBTreeListBox()143cdf0e10cSrcweir DBTreeListBox::~DBTreeListBox()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir DBG_DTOR(DBTreeListBox,NULL);
146cdf0e10cSrcweir implStopSelectionTimer();
147cdf0e10cSrcweir }
148cdf0e10cSrcweir //------------------------------------------------------------------------
GetEntryPosByName(const String & aName,SvLBoxEntry * pStart,const IEntryFilter * _pFilter) const149cdf0e10cSrcweir SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvLBoxEntry* pStart, const IEntryFilter* _pFilter ) const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir SvLBoxTreeList* myModel = GetModel();
152cdf0e10cSrcweir SvTreeEntryList* pChilds = myModel->GetChildList(pStart);
153cdf0e10cSrcweir SvLBoxEntry* pEntry = NULL;
154cdf0e10cSrcweir if ( pChilds )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir sal_uLong nCount = pChilds->Count();
157cdf0e10cSrcweir for (sal_uLong i=0; i < nCount; ++i)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir pEntry = static_cast<SvLBoxEntry*>(pChilds->GetObject(i));
160cdf0e10cSrcweir SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
161cdf0e10cSrcweir if ( pItem->GetText().Equals(aName) )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir if ( !_pFilter || _pFilter->includeEntry( pEntry ) )
164cdf0e10cSrcweir // found
165cdf0e10cSrcweir break;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir pEntry = NULL;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir return pEntry;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir // -------------------------------------------------------------------------
EnableExpandHandler(SvLBoxEntry * _pEntry)175cdf0e10cSrcweir void DBTreeListBox::EnableExpandHandler(SvLBoxEntry* _pEntry)
176cdf0e10cSrcweir {
177cdf0e10cSrcweir LINK(this, DBTreeListBox, OnResetEntry).Call(_pEntry);
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir // -------------------------------------------------------------------------
RequestingChilds(SvLBoxEntry * pParent)181cdf0e10cSrcweir void DBTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir if (m_aPreExpandHandler.IsSet())
184cdf0e10cSrcweir {
185cdf0e10cSrcweir if (!m_aPreExpandHandler.Call(pParent))
186cdf0e10cSrcweir {
187cdf0e10cSrcweir // an error occured. The method calling us will reset the entry flags, so it can't be expanded again.
188cdf0e10cSrcweir // But we want that the user may do a second try (i.e. because he misstypes a password in this try), so
189cdf0e10cSrcweir // we have to reset these flags controlling the expand ability
190cdf0e10cSrcweir PostUserEvent(LINK(this, DBTreeListBox, OnResetEntry), pParent);
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir // -------------------------------------------------------------------------
InitEntry(SvLBoxEntry * _pEntry,const XubString & aStr,const Image & _rCollEntryBmp,const Image & _rExpEntryBmp,SvLBoxButtonKind eButtonKind)196cdf0e10cSrcweir void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, const Image& _rCollEntryBmp, const Image& _rExpEntryBmp, SvLBoxButtonKind eButtonKind)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir SvTreeListBox::InitEntry( _pEntry, aStr, _rCollEntryBmp,_rExpEntryBmp, eButtonKind);
199cdf0e10cSrcweir SvLBoxItem* pTextItem(_pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
200cdf0e10cSrcweir SvLBoxString* pString = new OBoldListboxString( _pEntry, 0, aStr );
201cdf0e10cSrcweir _pEntry->ReplaceItem( pString,_pEntry->GetPos(pTextItem));
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir // -------------------------------------------------------------------------
implStopSelectionTimer()205cdf0e10cSrcweir void DBTreeListBox::implStopSelectionTimer()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir if ( m_aTimer.IsActive() )
208cdf0e10cSrcweir m_aTimer.Stop();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // -------------------------------------------------------------------------
implStartSelectionTimer()212cdf0e10cSrcweir void DBTreeListBox::implStartSelectionTimer()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir implStopSelectionTimer();
215cdf0e10cSrcweir m_aTimer.Start();
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir // -----------------------------------------------------------------------------
219cdf0e10cSrcweir
DeselectHdl()220cdf0e10cSrcweir void DBTreeListBox::DeselectHdl()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir m_aSelectedEntries.erase( GetHdlEntry() );
223cdf0e10cSrcweir SvTreeListBox::DeselectHdl();
224cdf0e10cSrcweir implStartSelectionTimer();
225cdf0e10cSrcweir }
226cdf0e10cSrcweir // -------------------------------------------------------------------------
SelectHdl()227cdf0e10cSrcweir void DBTreeListBox::SelectHdl()
228cdf0e10cSrcweir {
229cdf0e10cSrcweir m_aSelectedEntries.insert( GetHdlEntry() );
230cdf0e10cSrcweir SvTreeListBox::SelectHdl();
231cdf0e10cSrcweir implStartSelectionTimer();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir // -------------------------------------------------------------------------
MouseButtonDown(const MouseEvent & rMEvt)235cdf0e10cSrcweir void DBTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir sal_Bool bHitEmptySpace = (NULL == GetEntry(rMEvt.GetPosPixel(), sal_True));
238cdf0e10cSrcweir if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1())
239cdf0e10cSrcweir Control::MouseButtonDown(rMEvt);
240cdf0e10cSrcweir else
241cdf0e10cSrcweir SvTreeListBox::MouseButtonDown(rMEvt);
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244cdf0e10cSrcweir // -------------------------------------------------------------------------
IMPL_LINK(DBTreeListBox,OnResetEntry,SvLBoxEntry *,pEntry)245cdf0e10cSrcweir IMPL_LINK(DBTreeListBox, OnResetEntry, SvLBoxEntry*, pEntry)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir // set the flag which allows if the entry can be expanded
248cdf0e10cSrcweir pEntry->SetFlags( (pEntry->GetFlags() & ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN)) | SV_ENTRYFLAG_CHILDS_ON_DEMAND );
249cdf0e10cSrcweir // redraw the entry
250cdf0e10cSrcweir GetModel()->InvalidateEntry( pEntry );
251cdf0e10cSrcweir return 0L;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir // -----------------------------------------------------------------------------
ModelHasEntryInvalidated(SvListEntry * _pEntry)254cdf0e10cSrcweir void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
257cdf0e10cSrcweir
258cdf0e10cSrcweir if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir SvLBoxItem* pTextItem = static_cast< SvLBoxEntry* >( _pEntry )->GetFirstItem( SV_ITEM_ID_BOLDLBSTRING );
261cdf0e10cSrcweir if ( pTextItem && !static_cast< OBoldListboxString* >( pTextItem )->isEmphasized() )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir implStopSelectionTimer();
264cdf0e10cSrcweir m_aSelectedEntries.erase( _pEntry );
265cdf0e10cSrcweir // ehm - why?
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir // -------------------------------------------------------------------------
ModelHasRemoved(SvListEntry * _pEntry)270cdf0e10cSrcweir void DBTreeListBox::ModelHasRemoved( SvListEntry* _pEntry )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir SvTreeListBox::ModelHasRemoved(_pEntry);
273cdf0e10cSrcweir if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir implStopSelectionTimer();
276cdf0e10cSrcweir m_aSelectedEntries.erase( _pEntry );
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir // -------------------------------------------------------------------------
AcceptDrop(const AcceptDropEvent & _rEvt)281cdf0e10cSrcweir sal_Int8 DBTreeListBox::AcceptDrop( const AcceptDropEvent& _rEvt )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir sal_Int8 nDropOption = DND_ACTION_NONE;
284cdf0e10cSrcweir if ( m_pActionListener )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir SvLBoxEntry* pDroppedEntry = GetEntry(_rEvt.maPosPixel);
287cdf0e10cSrcweir // check if drag is on child entry, which is not allowed
288cdf0e10cSrcweir SvLBoxEntry* pParent = NULL;
289cdf0e10cSrcweir if ( _rEvt.mnAction & DND_ACTION_MOVE )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir if ( !m_pDragedEntry ) // no entry to move
292cdf0e10cSrcweir {
293cdf0e10cSrcweir nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
294cdf0e10cSrcweir m_aMousePos = _rEvt.maPosPixel;
295cdf0e10cSrcweir m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
296cdf0e10cSrcweir return nDropOption;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir pParent = pDroppedEntry ? GetParent(pDroppedEntry) : NULL;
300cdf0e10cSrcweir while ( pParent && pParent != m_pDragedEntry )
301cdf0e10cSrcweir pParent = GetParent(pParent);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir if ( !pParent )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
307cdf0e10cSrcweir // check if move is allowed
308cdf0e10cSrcweir if ( nDropOption & DND_ACTION_MOVE )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir if ( m_pDragedEntry == pDroppedEntry || GetEntryPosByName(GetEntryText(m_pDragedEntry),pDroppedEntry) )
311cdf0e10cSrcweir nDropOption = nDropOption & ~DND_ACTION_MOVE;//DND_ACTION_NONE;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir m_aMousePos = _rEvt.maPosPixel;
314cdf0e10cSrcweir m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
315cdf0e10cSrcweir }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir return nDropOption;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir // -------------------------------------------------------------------------
ExecuteDrop(const ExecuteDropEvent & _rEvt)322cdf0e10cSrcweir sal_Int8 DBTreeListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir if ( m_pActionListener )
325cdf0e10cSrcweir return m_pActionListener->executeDrop( _rEvt );
326cdf0e10cSrcweir
327cdf0e10cSrcweir return DND_ACTION_NONE;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir // -------------------------------------------------------------------------
StartDrag(sal_Int8 _nAction,const Point & _rPosPixel)331cdf0e10cSrcweir void DBTreeListBox::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir if ( m_pActionListener )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir m_pDragedEntry = GetEntry(_rPosPixel);
336cdf0e10cSrcweir if ( m_pDragedEntry && m_pActionListener->requestDrag( _nAction, _rPosPixel ) )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir // if the (asynchronous) drag started, stop the selection timer
339cdf0e10cSrcweir implStopSelectionTimer();
340cdf0e10cSrcweir // and stop selecting entries by simply moving the mouse
341cdf0e10cSrcweir EndSelection();
342cdf0e10cSrcweir }
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir // -------------------------------------------------------------------------
RequestHelp(const HelpEvent & rHEvt)347cdf0e10cSrcweir void DBTreeListBox::RequestHelp( const HelpEvent& rHEvt )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir if ( !m_pActionListener )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir SvTreeListBox::RequestHelp( rHEvt );
352cdf0e10cSrcweir return;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
355cdf0e10cSrcweir if( rHEvt.GetMode() & HELPMODE_QUICK )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
358cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( aPos );
359cdf0e10cSrcweir if( pEntry )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir String sQuickHelpText;
362cdf0e10cSrcweir if ( m_pActionListener->requestQuickHelp( pEntry, sQuickHelpText ) )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir Size aSize( GetOutputSizePixel().Width(), GetEntryHeight() );
365cdf0e10cSrcweir Rectangle aScreenRect( OutputToScreenPixel( GetEntryPosition( pEntry ) ), aSize );
366cdf0e10cSrcweir
367cdf0e10cSrcweir Help::ShowQuickHelp( this, aScreenRect,
368cdf0e10cSrcweir sQuickHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
369cdf0e10cSrcweir return;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
374cdf0e10cSrcweir SvTreeListBox::RequestHelp( rHEvt );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir // -----------------------------------------------------------------------------
KeyInput(const KeyEvent & rKEvt)378cdf0e10cSrcweir void DBTreeListBox::KeyInput( const KeyEvent& rKEvt )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
381cdf0e10cSrcweir sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
382cdf0e10cSrcweir sal_Bool bHandled = sal_False;
383cdf0e10cSrcweir
384cdf0e10cSrcweir if(eFunc != KEYFUNC_DONTKNOW)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir switch(eFunc)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir case KEYFUNC_CUT:
389cdf0e10cSrcweir bHandled = ( m_aCutHandler.IsSet() && !m_aSelectedEntries.empty() );
390cdf0e10cSrcweir if ( bHandled )
391cdf0e10cSrcweir m_aCutHandler.Call( NULL );
392cdf0e10cSrcweir break;
393cdf0e10cSrcweir case KEYFUNC_COPY:
394cdf0e10cSrcweir bHandled = ( m_aCopyHandler.IsSet() && !m_aSelectedEntries.empty() );
395cdf0e10cSrcweir if ( bHandled )
396cdf0e10cSrcweir m_aCopyHandler.Call( NULL );
397cdf0e10cSrcweir break;
398cdf0e10cSrcweir case KEYFUNC_PASTE:
399cdf0e10cSrcweir bHandled = ( m_aPasteHandler.IsSet() && !m_aSelectedEntries.empty() );
400cdf0e10cSrcweir if ( bHandled )
401cdf0e10cSrcweir m_aPasteHandler.Call( NULL );
402cdf0e10cSrcweir break;
403cdf0e10cSrcweir case KEYFUNC_DELETE:
404cdf0e10cSrcweir bHandled = ( m_aDeleteHandler.IsSet() && !m_aSelectedEntries.empty() );
405cdf0e10cSrcweir if ( bHandled )
406cdf0e10cSrcweir m_aDeleteHandler.Call( NULL );
407cdf0e10cSrcweir break;
408cdf0e10cSrcweir default:
409cdf0e10cSrcweir break;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir if ( KEY_RETURN == nCode )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir bHandled = m_bHandleEnterKey;
416cdf0e10cSrcweir if ( m_aEnterKeyHdl.IsSet() )
417cdf0e10cSrcweir m_aEnterKeyHdl.Call(this);
418cdf0e10cSrcweir // this is a HACK. If the data source browser is opened in the "beamer", while the main frame
419cdf0e10cSrcweir // contains a writer document, then pressing enter in the DSB would be rerouted to the writer
420cdf0e10cSrcweir // document if we would not do this hack here.
421cdf0e10cSrcweir // The problem is that the Writer uses RETURN as _accelerator_ (which is quite weird itself),
422cdf0e10cSrcweir // so the SFX framework is _obligated_ to pass it to the Writer if nobody else handled it. There
423cdf0e10cSrcweir // is no chance to distinguish between
424cdf0e10cSrcweir // "accelerators which are to be executed if the main document has the focus"
425cdf0e10cSrcweir // and
426cdf0e10cSrcweir // "accelerators which are always to be executed"
427cdf0e10cSrcweir //
428cdf0e10cSrcweir // Thus we cannot prevent the handling of this key in the writer without declaring the key event
429cdf0e10cSrcweir // as "handled" herein.
430cdf0e10cSrcweir //
431cdf0e10cSrcweir // The bad thing about this approach is that it does not scale. Every other accelerator which
432cdf0e10cSrcweir // is used by the document will raise a similar bug once somebody discovers it.
433cdf0e10cSrcweir // If this is the case, we should discuss a real solution with the framework (SFX) and the
434cdf0e10cSrcweir // applications.
435cdf0e10cSrcweir //
436cdf0e10cSrcweir // 2002-12-02 - 105831 - fs@openoffice.org
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
439cdf0e10cSrcweir if ( !bHandled )
440cdf0e10cSrcweir SvTreeListBox::KeyInput(rKEvt);
441cdf0e10cSrcweir }
442cdf0e10cSrcweir // -----------------------------------------------------------------------------
EditingEntry(SvLBoxEntry * pEntry,Selection &)443cdf0e10cSrcweir sal_Bool DBTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& /*_aSelection*/)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir return m_aEditingHandler.Call(pEntry) != 0;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir // -----------------------------------------------------------------------------
EditedEntry(SvLBoxEntry * pEntry,const XubString & rNewText)448cdf0e10cSrcweir sal_Bool DBTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir DBTreeEditedEntry aEntry;
451cdf0e10cSrcweir aEntry.pEntry = pEntry;
452cdf0e10cSrcweir aEntry.aNewText =rNewText;
453cdf0e10cSrcweir if(m_aEditedHandler.Call(&aEntry) != 0)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir implStopSelectionTimer();
456cdf0e10cSrcweir m_aSelectedEntries.erase( pEntry );
457cdf0e10cSrcweir }
458cdf0e10cSrcweir SetEntryText(pEntry,aEntry.aNewText);
459cdf0e10cSrcweir
460cdf0e10cSrcweir return sal_False; // we never want that the base change our text
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir // -----------------------------------------------------------------------------
DoubleClickHdl()464cdf0e10cSrcweir sal_Bool DBTreeListBox::DoubleClickHdl()
465cdf0e10cSrcweir {
466cdf0e10cSrcweir long nResult = aDoubleClickHdl.Call( this );
467cdf0e10cSrcweir // continue default processing if the DoubleClickHandler didn't handle it
468cdf0e10cSrcweir return nResult == 0;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
471cdf0e10cSrcweir // -----------------------------------------------------------------------------
scrollWindow(DBTreeListBox * _pListBox,const Point & _rPos,sal_Bool _bUp)472cdf0e10cSrcweir void scrollWindow(DBTreeListBox* _pListBox, const Point& _rPos,sal_Bool _bUp)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir SvLBoxEntry* pEntry = _pListBox->GetEntry( _rPos );
475cdf0e10cSrcweir if( pEntry && pEntry != _pListBox->Last() )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir _pListBox->ScrollOutputArea( _bUp ? -1 : 1 );
478cdf0e10cSrcweir }
479cdf0e10cSrcweir }
480cdf0e10cSrcweir // -----------------------------------------------------------------------------
481cdf0e10cSrcweir IMPL_LINK( DBTreeListBox, ScrollUpHdl, SvTreeListBox*, /*pBox*/ )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir scrollWindow(this,m_aMousePos,sal_True);
484cdf0e10cSrcweir return 0;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
487cdf0e10cSrcweir //------------------------------------------------------------------------------
488cdf0e10cSrcweir IMPL_LINK( DBTreeListBox, ScrollDownHdl, SvTreeListBox*, /*pBox*/ )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir scrollWindow(this,m_aMousePos,sal_False);
491cdf0e10cSrcweir return 0;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir // -----------------------------------------------------------------------------
494cdf0e10cSrcweir namespace
495cdf0e10cSrcweir {
lcl_enableEntries(PopupMenu * _pPopup,IController & _rController)496cdf0e10cSrcweir void lcl_enableEntries( PopupMenu* _pPopup, IController& _rController )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir if ( !_pPopup )
499cdf0e10cSrcweir return;
500cdf0e10cSrcweir
501cdf0e10cSrcweir sal_uInt16 nCount = _pPopup->GetItemCount();
502cdf0e10cSrcweir for (sal_uInt16 i=0; i < nCount; ++i)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir if ( _pPopup->GetItemType(i) != MENUITEM_SEPARATOR )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir sal_uInt16 nId = _pPopup->GetItemId(i);
507cdf0e10cSrcweir PopupMenu* pSubPopUp = _pPopup->GetPopupMenu(nId);
508cdf0e10cSrcweir if ( pSubPopUp )
509cdf0e10cSrcweir {
510cdf0e10cSrcweir lcl_enableEntries( pSubPopUp, _rController );
511cdf0e10cSrcweir _pPopup->EnableItem(nId,pSubPopUp->HasValidEntries());
512cdf0e10cSrcweir }
513cdf0e10cSrcweir else
514cdf0e10cSrcweir {
515cdf0e10cSrcweir ::rtl::OUString sCommandURL( _pPopup->GetItemCommand( nId ) );
516cdf0e10cSrcweir bool bEnabled = ( sCommandURL.getLength() )
517cdf0e10cSrcweir ? _rController.isCommandEnabled( sCommandURL )
518cdf0e10cSrcweir : _rController.isCommandEnabled( nId );
519cdf0e10cSrcweir _pPopup->EnableItem( nId, bEnabled );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir }
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir _pPopup->RemoveDisabledEntries();
525cdf0e10cSrcweir }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
528cdf0e10cSrcweir // -----------------------------------------------------------------------------
529cdf0e10cSrcweir namespace
530cdf0e10cSrcweir {
lcl_adjustMenuItemIDs(Menu & _rMenu,IController & _rCommandController)531cdf0e10cSrcweir void lcl_adjustMenuItemIDs( Menu& _rMenu, IController& _rCommandController )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir sal_uInt16 nCount = _rMenu.GetItemCount();
534cdf0e10cSrcweir for ( sal_uInt16 pos = 0; pos < nCount; ++pos )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir // do not adjust separators
537cdf0e10cSrcweir if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
538cdf0e10cSrcweir continue;
539cdf0e10cSrcweir
540cdf0e10cSrcweir sal_uInt16 nId = _rMenu.GetItemId(pos);
541cdf0e10cSrcweir String aCommand = _rMenu.GetItemCommand( nId );
542cdf0e10cSrcweir PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
543cdf0e10cSrcweir if ( pPopup )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir lcl_adjustMenuItemIDs( *pPopup, _rCommandController );
546cdf0e10cSrcweir continue;
547cdf0e10cSrcweir } // if ( pPopup )
548cdf0e10cSrcweir
549cdf0e10cSrcweir const sal_uInt16 nCommandId = _rCommandController.registerCommandURL( aCommand );
550cdf0e10cSrcweir _rMenu.InsertItem( nCommandId, _rMenu.GetItemText( nId ), _rMenu.GetItemImage( nId ),
551cdf0e10cSrcweir _rMenu.GetItemBits( nId ), pos );
552cdf0e10cSrcweir
553cdf0e10cSrcweir // more things to preserve:
554cdf0e10cSrcweir // - the help command
555cdf0e10cSrcweir ::rtl::OUString sHelpURL = _rMenu.GetHelpCommand( nId );
556cdf0e10cSrcweir if ( sHelpURL.getLength() )
557cdf0e10cSrcweir _rMenu.SetHelpCommand( nCommandId, sHelpURL );
558cdf0e10cSrcweir
559cdf0e10cSrcweir // remove the "old" item
560cdf0e10cSrcweir _rMenu.RemoveItem( pos+1 );
561cdf0e10cSrcweir }
562cdf0e10cSrcweir }
lcl_insertMenuItemImages(Menu & _rMenu,IController & _rCommandController)563cdf0e10cSrcweir void lcl_insertMenuItemImages( Menu& _rMenu, IController& _rCommandController )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
566cdf0e10cSrcweir const sal_Bool bHiContrast = rSettings.GetHighContrastMode();
567cdf0e10cSrcweir uno::Reference< frame::XController > xController = _rCommandController.getXController();
568cdf0e10cSrcweir uno::Reference< frame::XFrame> xFrame;
569cdf0e10cSrcweir if ( xController.is() )
570cdf0e10cSrcweir xFrame = xController->getFrame();
571cdf0e10cSrcweir sal_uInt16 nCount = _rMenu.GetItemCount();
572cdf0e10cSrcweir for ( sal_uInt16 pos = 0; pos < nCount; ++pos )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir // do not adjust separators
575cdf0e10cSrcweir if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
576cdf0e10cSrcweir continue;
577cdf0e10cSrcweir
578cdf0e10cSrcweir sal_uInt16 nId = _rMenu.GetItemId(pos);
579cdf0e10cSrcweir String aCommand = _rMenu.GetItemCommand( nId );
580cdf0e10cSrcweir PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
581cdf0e10cSrcweir if ( pPopup )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir lcl_insertMenuItemImages( *pPopup, _rCommandController );
584cdf0e10cSrcweir continue;
585cdf0e10cSrcweir } // if ( pPopup )
586cdf0e10cSrcweir
587cdf0e10cSrcweir if ( xFrame.is() )
588cdf0e10cSrcweir _rMenu.SetItemImage(nId,framework::GetImageFromURL(xFrame,aCommand,sal_False,bHiContrast));
589cdf0e10cSrcweir }
590cdf0e10cSrcweir }
591cdf0e10cSrcweir // =========================================================================
592cdf0e10cSrcweir // = SelectionSupplier
593cdf0e10cSrcweir // =========================================================================
594cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < XSelectionSupplier
595cdf0e10cSrcweir > SelectionSupplier_Base;
596cdf0e10cSrcweir class SelectionSupplier : public SelectionSupplier_Base
597cdf0e10cSrcweir {
598cdf0e10cSrcweir public:
SelectionSupplier(const Any & _rSelection)599cdf0e10cSrcweir SelectionSupplier( const Any& _rSelection )
600cdf0e10cSrcweir :m_aSelection( _rSelection )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
604cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL select( const Any& xSelection ) throw (IllegalArgumentException, RuntimeException);
605cdf0e10cSrcweir virtual Any SAL_CALL getSelection( ) throw (RuntimeException);
606cdf0e10cSrcweir virtual void SAL_CALL addSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
607cdf0e10cSrcweir virtual void SAL_CALL removeSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
608cdf0e10cSrcweir
609cdf0e10cSrcweir protected:
~SelectionSupplier()610cdf0e10cSrcweir virtual ~SelectionSupplier()
611cdf0e10cSrcweir {
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir private:
615cdf0e10cSrcweir Any m_aSelection;
616cdf0e10cSrcweir };
617cdf0e10cSrcweir
618cdf0e10cSrcweir //--------------------------------------------------------------------
select(const Any &)619cdf0e10cSrcweir ::sal_Bool SAL_CALL SelectionSupplier::select( const Any& /*_Selection*/ ) throw (IllegalArgumentException, RuntimeException)
620cdf0e10cSrcweir {
621cdf0e10cSrcweir throw IllegalArgumentException();
622cdf0e10cSrcweir // API bug: this should be a NoSupportException
623cdf0e10cSrcweir }
624cdf0e10cSrcweir
625cdf0e10cSrcweir //--------------------------------------------------------------------
getSelection()626cdf0e10cSrcweir Any SAL_CALL SelectionSupplier::getSelection( ) throw (RuntimeException)
627cdf0e10cSrcweir {
628cdf0e10cSrcweir return m_aSelection;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir
631cdf0e10cSrcweir //--------------------------------------------------------------------
addSelectionChangeListener(const Reference<XSelectionChangeListener> &)632cdf0e10cSrcweir void SAL_CALL SelectionSupplier::addSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir OSL_ENSURE( false, "SelectionSupplier::removeSelectionChangeListener: no support!" );
635cdf0e10cSrcweir // API bug: this should be a NoSupportException
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
638cdf0e10cSrcweir //--------------------------------------------------------------------
removeSelectionChangeListener(const Reference<XSelectionChangeListener> &)639cdf0e10cSrcweir void SAL_CALL SelectionSupplier::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir OSL_ENSURE( false, "SelectionSupplier::removeSelectionChangeListener: no support!" );
642cdf0e10cSrcweir // API bug: this should be a NoSupportException
643cdf0e10cSrcweir }
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir // -----------------------------------------------------------------------------
CreateContextMenu(void)647cdf0e10cSrcweir PopupMenu* DBTreeListBox::CreateContextMenu( void )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir ::std::auto_ptr< PopupMenu > pContextMenu;
650cdf0e10cSrcweir
651cdf0e10cSrcweir if ( !m_pContextMenuProvider )
652cdf0e10cSrcweir return pContextMenu.release();
653cdf0e10cSrcweir
654cdf0e10cSrcweir // the basic context menu
655cdf0e10cSrcweir pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) );
656cdf0e10cSrcweir // disable what is not available currently
657cdf0e10cSrcweir lcl_enableEntries( pContextMenu.get(), m_pContextMenuProvider->getCommandController() );
658cdf0e10cSrcweir // set images
659cdf0e10cSrcweir lcl_insertMenuItemImages( *pContextMenu, m_pContextMenuProvider->getCommandController() );
660cdf0e10cSrcweir // allow context menu interception
661cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pInterceptors = m_pContextMenuProvider->getContextMenuInterceptors();
662cdf0e10cSrcweir if ( !pInterceptors || !pInterceptors->getLength() )
663cdf0e10cSrcweir return pContextMenu.release();
664cdf0e10cSrcweir
665cdf0e10cSrcweir ContextMenuExecuteEvent aEvent;
666cdf0e10cSrcweir aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
667cdf0e10cSrcweir aEvent.ExecutePosition.X = -1;
668cdf0e10cSrcweir aEvent.ExecutePosition.Y = -1;
669cdf0e10cSrcweir aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
670cdf0e10cSrcweir m_xORB, pContextMenu.get(), 0 );
671cdf0e10cSrcweir aEvent.Selection = new SelectionSupplier( m_pContextMenuProvider->getCurrentSelection( *this ) );
672cdf0e10cSrcweir
673cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( *pInterceptors );
674cdf0e10cSrcweir bool bModifiedMenu = false;
675cdf0e10cSrcweir bool bAskInterceptors = true;
676cdf0e10cSrcweir while ( aIter.hasMoreElements() && bAskInterceptors )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir Reference< XContextMenuInterceptor > xInterceptor( aIter.next(), UNO_QUERY );
679cdf0e10cSrcweir if ( !xInterceptor.is() )
680cdf0e10cSrcweir continue;
681cdf0e10cSrcweir
682cdf0e10cSrcweir try
683cdf0e10cSrcweir {
684cdf0e10cSrcweir ContextMenuInterceptorAction eAction = xInterceptor->notifyContextMenuExecute( aEvent );
685cdf0e10cSrcweir switch ( eAction )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir case ContextMenuInterceptorAction_CANCELLED:
688cdf0e10cSrcweir return NULL;
689cdf0e10cSrcweir
690cdf0e10cSrcweir case ContextMenuInterceptorAction_EXECUTE_MODIFIED:
691cdf0e10cSrcweir bModifiedMenu = true;
692cdf0e10cSrcweir bAskInterceptors = false;
693cdf0e10cSrcweir break;
694cdf0e10cSrcweir
695cdf0e10cSrcweir case ContextMenuInterceptorAction_CONTINUE_MODIFIED:
696cdf0e10cSrcweir bModifiedMenu = true;
697cdf0e10cSrcweir bAskInterceptors = true;
698cdf0e10cSrcweir break;
699cdf0e10cSrcweir
700cdf0e10cSrcweir default:
701cdf0e10cSrcweir DBG_ERROR( "DBTreeListBox::CreateContextMenu: unexpected return value of the interceptor call!" );
702cdf0e10cSrcweir
703cdf0e10cSrcweir case ContextMenuInterceptorAction_IGNORED:
704cdf0e10cSrcweir break;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir }
707cdf0e10cSrcweir catch( const DisposedException& e )
708cdf0e10cSrcweir {
709cdf0e10cSrcweir if ( e.Context == xInterceptor )
710cdf0e10cSrcweir aIter.remove();
711cdf0e10cSrcweir }
712cdf0e10cSrcweir }
713cdf0e10cSrcweir
714cdf0e10cSrcweir if ( bModifiedMenu )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir // the interceptor(s) modified the menu description => create a new PopupMenu
717cdf0e10cSrcweir PopupMenu* pModifiedMenu = new PopupMenu;
718cdf0e10cSrcweir ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(
719cdf0e10cSrcweir pModifiedMenu, aEvent.ActionTriggerContainer );
720cdf0e10cSrcweir aEvent.ActionTriggerContainer.clear();
721cdf0e10cSrcweir pContextMenu.reset( pModifiedMenu );
722cdf0e10cSrcweir
723cdf0e10cSrcweir // the interceptors only know command URLs, but our menus primarily work
724cdf0e10cSrcweir // with IDs -> we need to translate the commands to IDs
725cdf0e10cSrcweir lcl_adjustMenuItemIDs( *pModifiedMenu, m_pContextMenuProvider->getCommandController() );
726cdf0e10cSrcweir } // if ( bModifiedMenu )
727cdf0e10cSrcweir
728cdf0e10cSrcweir return pContextMenu.release();
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
731cdf0e10cSrcweir // -----------------------------------------------------------------------------
ExcecuteContextMenuAction(sal_uInt16 _nSelectedPopupEntry)732cdf0e10cSrcweir void DBTreeListBox::ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir if ( m_pContextMenuProvider && _nSelectedPopupEntry )
735cdf0e10cSrcweir m_pContextMenuProvider->getCommandController().executeChecked( _nSelectedPopupEntry, Sequence< PropertyValue >() );
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
738cdf0e10cSrcweir // -----------------------------------------------------------------------------
739cdf0e10cSrcweir IMPL_LINK(DBTreeListBox, OnTimeOut, void*, /*EMPTY_ARG*/)
740cdf0e10cSrcweir {
741cdf0e10cSrcweir implStopSelectionTimer();
742cdf0e10cSrcweir
743cdf0e10cSrcweir m_aSelChangeHdl.Call( NULL );
744cdf0e10cSrcweir return 0L;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir // -----------------------------------------------------------------------------
StateChanged(StateChangedType nStateChange)747cdf0e10cSrcweir void DBTreeListBox::StateChanged( StateChangedType nStateChange )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_VISIBLE )
750cdf0e10cSrcweir implStopSelectionTimer();
751cdf0e10cSrcweir }
752cdf0e10cSrcweir // .........................................................................
753cdf0e10cSrcweir } // namespace dbaui
754cdf0e10cSrcweir // .........................................................................
755