xref: /aoo41x/main/sfx2/source/toolbox/tbxitem.cxx (revision 595fd105)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SOLARIS
28cdf0e10cSrcweir // HACK: prevent conflict between STLPORT and Workshop headers on Solaris 8
29cdf0e10cSrcweir #include <ctime>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <string>			// prevent conflict with STL includes
33cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
34cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
36cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
37cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
38cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
40cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
41cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
42cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
43cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
45cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/status/ItemStatus.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/status/ItemState.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ui/XUIElementFactory.hpp>
49cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
50cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ui/XUIFunctionListener.hpp>
52cdf0e10cSrcweir #include <com/sun/star/frame/status/Visibility.hpp>
53cdf0e10cSrcweir #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
54cdf0e10cSrcweir #include <svl/eitem.hxx>
55cdf0e10cSrcweir #include <svl/stritem.hxx>
56cdf0e10cSrcweir #include <svl/intitem.hxx>
57cdf0e10cSrcweir #include <svl/imageitm.hxx>
58cdf0e10cSrcweir #include <svl/visitem.hxx>
59cdf0e10cSrcweir #include <svl/urlbmk.hxx>
60cdf0e10cSrcweir #include <vcl/toolbox.hxx>
61cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include <svtools/imagemgr.hxx>
64cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
65cdf0e10cSrcweir #include <framework/addonmenu.hxx>
66cdf0e10cSrcweir #include <framework/addonsoptions.hxx>
67cdf0e10cSrcweir #include <framework/menuconfiguration.hxx>
68cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx>
69cdf0e10cSrcweir #include <vcl/taskpanelist.hxx>
70cdf0e10cSrcweir #ifndef _TOOLKIT_UNOHLP_HXX
71cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
74cdf0e10cSrcweir #include <svtools/miscopt.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #ifndef GCC
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx>
80cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
81cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
82cdf0e10cSrcweir #include "fltfnc.hxx"
83cdf0e10cSrcweir #include <sfx2/msg.hxx>
84cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
85cdf0e10cSrcweir #include "statcach.hxx"
86cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
87cdf0e10cSrcweir #include "arrdecl.hxx"
88cdf0e10cSrcweir #include "sfxtypes.hxx"
89cdf0e10cSrcweir #include <sfx2/genlink.hxx>
90cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
91cdf0e10cSrcweir #include <sfx2/sfx.hrc>
92cdf0e10cSrcweir #include <sfx2/module.hxx>
93cdf0e10cSrcweir #include <sfx2/docfile.hxx>
94cdf0e10cSrcweir #include <sfx2/docfac.hxx>
95cdf0e10cSrcweir #include "referers.hxx"
96cdf0e10cSrcweir #include <sfx2/frmhtmlw.hxx>
97cdf0e10cSrcweir #include <sfx2/app.hxx>
98cdf0e10cSrcweir #include <sfx2/unoctitm.hxx>
99cdf0e10cSrcweir #include "helpid.hrc"
100cdf0e10cSrcweir #include "workwin.hxx"
101cdf0e10cSrcweir #include "sfx2/imgmgr.hxx"
102cdf0e10cSrcweir #include "virtmenu.hxx"
103cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
104cdf0e10cSrcweir #include <sfx2/module.hxx>
105cdf0e10cSrcweir #include "sfx2/imagemgr.hxx"
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx>
108cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //using namespace ::com::sun::star::awt;
111cdf0e10cSrcweir using namespace ::com::sun::star::beans;
112cdf0e10cSrcweir using namespace ::com::sun::star::frame;
113cdf0e10cSrcweir using namespace ::com::sun::star::frame::status;
114cdf0e10cSrcweir using namespace ::com::sun::star::lang;
115cdf0e10cSrcweir using namespace ::com::sun::star::uno;
116cdf0e10cSrcweir using namespace ::com::sun::star::util;
117cdf0e10cSrcweir using namespace ::com::sun::star::container;
118cdf0e10cSrcweir using namespace ::com::sun::star::frame;
119cdf0e10cSrcweir using namespace ::com::sun::star::ui;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir //====================================================================
122cdf0e10cSrcweir 
123cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, sal_True);
124cdf0e10cSrcweir 
GetTopMostParentSystemWindow(Window * pWindow)125cdf0e10cSrcweir static Window* GetTopMostParentSystemWindow( Window* pWindow )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     OSL_ASSERT( pWindow );
128cdf0e10cSrcweir     if ( pWindow )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         // ->manually search topmost system window
131cdf0e10cSrcweir         // required because their might be another system window between this and the top window
132cdf0e10cSrcweir         pWindow = pWindow->GetParent();
133cdf0e10cSrcweir         SystemWindow* pTopMostSysWin = NULL;
134cdf0e10cSrcweir         while ( pWindow )
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             if ( pWindow->IsSystemWindow() )
137cdf0e10cSrcweir                 pTopMostSysWin = (SystemWindow*)pWindow;
138cdf0e10cSrcweir             pWindow = pWindow->GetParent();
139cdf0e10cSrcweir         }
140cdf0e10cSrcweir         pWindow = pTopMostSysWin;
141cdf0e10cSrcweir         OSL_ASSERT( pWindow );
142cdf0e10cSrcweir         return pWindow;
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     return NULL;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
SfxToolBoxControllerFactory(const Reference<XFrame> & rFrame,ToolBox * pToolbox,unsigned short nID,const::rtl::OUString & aCommandURL)148cdf0e10cSrcweir svt::ToolboxController* SAL_CALL SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     URL aTargetURL;
153cdf0e10cSrcweir     aTargetURL.Complete = aCommandURL;
154cdf0e10cSrcweir     Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY );
155cdf0e10cSrcweir     xTrans->parseStrict( aTargetURL );
156cdf0e10cSrcweir     if ( aTargetURL.Arguments.getLength() )
157cdf0e10cSrcweir         return NULL;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     SfxObjectShell* pObjShell = NULL;
160cdf0e10cSrcweir     Reference < XController > xController;
161cdf0e10cSrcweir     Reference < XModel > xModel;
162cdf0e10cSrcweir     if ( rFrame.is() )
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         xController = rFrame->getController();
165cdf0e10cSrcweir         if ( xController.is() )
166cdf0e10cSrcweir             xModel = xController->getModel();
167cdf0e10cSrcweir     }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     if ( xModel.is() )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         // Get tunnel from model to retrieve the SfxObjectShell pointer from it
172cdf0e10cSrcweir         ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, UNO_QUERY );
173cdf0e10cSrcweir 		if ( xObj.is() )
174cdf0e10cSrcweir 		{
175cdf0e10cSrcweir 			::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence();
176cdf0e10cSrcweir 			sal_Int64 nHandle = xObj->getSomething( aSeq );
177cdf0e10cSrcweir 			if ( nHandle )
178cdf0e10cSrcweir                 pObjShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir     }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     SfxModule*     pModule   = pObjShell ? pObjShell->GetModule() : NULL;
183cdf0e10cSrcweir     SfxSlotPool*   pSlotPool = 0;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     if ( pModule )
186cdf0e10cSrcweir         pSlotPool = pModule->GetSlotPool();
187cdf0e10cSrcweir     else
188cdf0e10cSrcweir         pSlotPool = &(SfxSlotPool::GetSlotPool( NULL ));
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path );
191cdf0e10cSrcweir     if ( pSlot )
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         sal_uInt16 nSlotId = pSlot->GetSlotId();
194cdf0e10cSrcweir         if ( nSlotId > 0 )
195cdf0e10cSrcweir             return SfxToolBoxControl::CreateControl( nSlotId, nID, pToolbox, pModule );
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     return NULL;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir struct SfxToolBoxControl_Impl
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	ToolBox*				pBox;
204cdf0e10cSrcweir 	sal_Bool					bShowString;
205cdf0e10cSrcweir 	sal_uInt16                  nSelectModifier;
206cdf0e10cSrcweir 	SfxTbxCtrlFactory*		pFact;
207cdf0e10cSrcweir     sal_uInt16                  nTbxId;
208cdf0e10cSrcweir     sal_uInt16                  nSlotId;
209cdf0e10cSrcweir     SfxPopupWindow*         mpFloatingWindow;
210cdf0e10cSrcweir     SfxPopupWindow*         mpPopupWindow;
211cdf0e10cSrcweir     Reference< XUIElement > mxUIElement;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     DECL_LINK( WindowEventListener, VclSimpleEvent* );
214cdf0e10cSrcweir };
215cdf0e10cSrcweir 
IMPL_LINK(SfxToolBoxControl_Impl,WindowEventListener,VclSimpleEvent *,pEvent)216cdf0e10cSrcweir IMPL_LINK( SfxToolBoxControl_Impl, WindowEventListener, VclSimpleEvent*, pEvent )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir     if ( pEvent &&
219cdf0e10cSrcweir          pEvent->ISA( VclWindowEvent ) &&
220cdf0e10cSrcweir          (( pEvent->GetId() == VCLEVENT_WINDOW_MOVE ) ||
221cdf0e10cSrcweir           ( pEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE )))
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() );
224cdf0e10cSrcweir         if (( pWindow == mpFloatingWindow ) &&
225cdf0e10cSrcweir             ( mpPopupWindow != 0 ))
226cdf0e10cSrcweir         {
227cdf0e10cSrcweir             delete mpPopupWindow;
228cdf0e10cSrcweir             mpPopupWindow = 0;
229cdf0e10cSrcweir         }
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     return 1;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir //--------------------------------------------------------------------
236cdf0e10cSrcweir 
SfxToolBoxControl(sal_uInt16 nSlotID,sal_uInt16 nID,ToolBox & rBox,sal_Bool bShowStringItems)237cdf0e10cSrcweir SfxToolBoxControl::SfxToolBoxControl(
238cdf0e10cSrcweir     sal_uInt16          nSlotID,
239cdf0e10cSrcweir     sal_uInt16          nID,
240cdf0e10cSrcweir     ToolBox&        rBox,
241cdf0e10cSrcweir     sal_Bool            bShowStringItems     )
242cdf0e10cSrcweir :   svt::ToolboxController()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     pImpl = new SfxToolBoxControl_Impl;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     pImpl->pBox = &rBox;
247cdf0e10cSrcweir     pImpl->bShowString = bShowStringItems;
248cdf0e10cSrcweir     pImpl->nSelectModifier = 0;
249cdf0e10cSrcweir     pImpl->pFact = 0;
250cdf0e10cSrcweir     pImpl->nTbxId = nID;
251cdf0e10cSrcweir     pImpl->nSlotId = nSlotID;
252cdf0e10cSrcweir     pImpl->mpFloatingWindow = 0;
253cdf0e10cSrcweir     pImpl->mpPopupWindow = 0;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir //--------------------------------------------------------------------
257cdf0e10cSrcweir 
~SfxToolBoxControl()258cdf0e10cSrcweir SfxToolBoxControl::~SfxToolBoxControl()
259cdf0e10cSrcweir {
260cdf0e10cSrcweir     if ( pImpl->mxUIElement.is() )
261cdf0e10cSrcweir     {
262cdf0e10cSrcweir         Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
263cdf0e10cSrcweir         xComponent->dispose();
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     pImpl->mxUIElement = 0;
266cdf0e10cSrcweir     delete pImpl;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir //--------------------------------------------------------------------
270cdf0e10cSrcweir 
GetToolBox() const271cdf0e10cSrcweir ToolBox& SfxToolBoxControl::GetToolBox() const
272cdf0e10cSrcweir {
273cdf0e10cSrcweir     return *pImpl->pBox;
274cdf0e10cSrcweir }
GetId() const275cdf0e10cSrcweir unsigned short SfxToolBoxControl::GetId() const
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     return pImpl->nTbxId;
278cdf0e10cSrcweir }
GetSlotId() const279cdf0e10cSrcweir unsigned short SfxToolBoxControl::GetSlotId() const
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     return pImpl->nSlotId;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir //--------------------------------------------------------------------
285cdf0e10cSrcweir 
dispose()286cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::dispose() throw (::com::sun::star::uno::RuntimeException)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     if ( m_bDisposed )
289cdf0e10cSrcweir         return;
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     svt::ToolboxController::dispose();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     // Remove and destroy our item window at our toolbox
294cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
295cdf0e10cSrcweir     Window* pWindow = pImpl->pBox->GetItemWindow( pImpl->nTbxId );
296cdf0e10cSrcweir     pImpl->pBox->SetItemWindow( pImpl->nTbxId, 0 );
297cdf0e10cSrcweir     delete pWindow;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir     // Dispose an open sub toolbar. It's possible that we have an open
300cdf0e10cSrcweir     // sub toolbar while we get disposed. Therefore we have to dispose
301cdf0e10cSrcweir     // it now! Not doing so would result in a crash. The sub toolbar
302cdf0e10cSrcweir     // gets destroyed asynchronously and would access a non-existing
303cdf0e10cSrcweir     // parent toolbar! See #126569#
304cdf0e10cSrcweir     if ( pImpl->mxUIElement.is() )
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir         Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
307cdf0e10cSrcweir         xComponent->dispose();
308cdf0e10cSrcweir     }
309cdf0e10cSrcweir     pImpl->mxUIElement = 0;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     // Delete my popup windows
312cdf0e10cSrcweir     delete pImpl->mpFloatingWindow;
313cdf0e10cSrcweir     delete pImpl->mpPopupWindow;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     pImpl->mpFloatingWindow = 0;
316cdf0e10cSrcweir     pImpl->mpPopupWindow = 0;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir //--------------------------------------------------------------------
RegisterToolBoxControl(SfxModule * pMod,SfxTbxCtrlFactory * pFact)320cdf0e10cSrcweir void SfxToolBoxControl::RegisterToolBoxControl( SfxModule* pMod, SfxTbxCtrlFactory* pFact)
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     SFX_APP()->RegisterToolBoxControl_Impl( pMod, pFact );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
CreateControl(sal_uInt16 nSlotId,sal_uInt16 nTbxId,ToolBox * pBox,SfxModule * pMod)325cdf0e10cSrcweir SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule* pMod  )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 	SfxToolBoxControl *pCtrl;
330cdf0e10cSrcweir 	SfxApplication *pApp = SFX_APP();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     SfxSlotPool *pSlotPool;
333cdf0e10cSrcweir 	if ( pMod )
334cdf0e10cSrcweir 		pSlotPool = pMod->GetSlotPool();
335cdf0e10cSrcweir 	else
336cdf0e10cSrcweir         pSlotPool = &SfxSlotPool::GetSlotPool();
337cdf0e10cSrcweir 	TypeId aSlotType = pSlotPool->GetSlotType( nSlotId );
338cdf0e10cSrcweir 	if ( aSlotType )
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		if ( pMod )
341cdf0e10cSrcweir 		{
342cdf0e10cSrcweir 			SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl();
343cdf0e10cSrcweir 			if ( pFactories )
344cdf0e10cSrcweir 			{
345cdf0e10cSrcweir 				SfxTbxCtrlFactArr_Impl &rFactories = *pFactories;
346cdf0e10cSrcweir 				sal_uInt16 nFactory;
347cdf0e10cSrcweir 				const sal_uInt16 nCount = rFactories.Count();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 				// search for a factory with the given slot id
350cdf0e10cSrcweir 				for( nFactory = 0; nFactory < nCount; ++nFactory )
351cdf0e10cSrcweir 					if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) )
352cdf0e10cSrcweir 						break;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 				if( nFactory == nCount )
355cdf0e10cSrcweir 				{
356cdf0e10cSrcweir 					// if no factory exists for the given slot id, see if we
357cdf0e10cSrcweir 					// have a generic factory with the correct slot type and slot id == 0
358cdf0e10cSrcweir 					for ( nFactory = 0; nFactory < nCount; ++nFactory )
359cdf0e10cSrcweir 						if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) )
360cdf0e10cSrcweir 							break;
361cdf0e10cSrcweir 				}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 				if( nFactory < nCount )
364cdf0e10cSrcweir 				{
365cdf0e10cSrcweir 					pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox );
366cdf0e10cSrcweir 					pCtrl->pImpl->pFact = rFactories[nFactory];
367cdf0e10cSrcweir 					return pCtrl;
368cdf0e10cSrcweir 				}
369cdf0e10cSrcweir 			}
370cdf0e10cSrcweir 		}
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		SfxTbxCtrlFactArr_Impl &rFactories = pApp->GetTbxCtrlFactories_Impl();
373cdf0e10cSrcweir 		sal_uInt16 nFactory;
374cdf0e10cSrcweir 		const sal_uInt16 nCount = rFactories.Count();
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 		for( nFactory = 0; nFactory < nCount; ++nFactory )
377cdf0e10cSrcweir 			if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) )
378cdf0e10cSrcweir 				break;
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 		if( nFactory == nCount )
381cdf0e10cSrcweir 		{
382cdf0e10cSrcweir 			// if no factory exists for the given slot id, see if we
383cdf0e10cSrcweir 			// have a generic factory with the correct slot type and slot id == 0
384cdf0e10cSrcweir 			for( nFactory = 0; nFactory < nCount; ++nFactory )
385cdf0e10cSrcweir 				if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) )
386cdf0e10cSrcweir 					break;
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		if( nFactory < nCount )
390cdf0e10cSrcweir 		{
391cdf0e10cSrcweir 			pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox );
392cdf0e10cSrcweir 			pCtrl->pImpl->pFact = rFactories[nFactory];
393cdf0e10cSrcweir 			return pCtrl;
394cdf0e10cSrcweir 		}
395cdf0e10cSrcweir 	}
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	return NULL;
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
GetItemState(const SfxPoolItem * pState)400cdf0e10cSrcweir SfxItemState SfxToolBoxControl::GetItemState(
401cdf0e10cSrcweir 	const SfxPoolItem* pState )
402cdf0e10cSrcweir /*	[Beschreibung]
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	Statische Methode zum Ermitteln des Status des SfxPoolItem-Pointers,
405cdf0e10cSrcweir 	in der Methode <SfxControllerItem::StateChanged(const SfxPoolItem*)>
406cdf0e10cSrcweir 	zu verwenden.
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	[R"uckgabewert]
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	SfxItemState		SFX_ITEM_UNKNOWN
411cdf0e10cSrcweir 						Enabled, aber keine weitere Statusinformation
412cdf0e10cSrcweir 						verf"ugbar. Typisch f"ur <Slot>s, die allenfalls
413cdf0e10cSrcweir 						zeitweise disabled sind, aber ihre Darstellung sonst
414cdf0e10cSrcweir 						nicht "andern.
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 						SFX_ITEM_DISABLED
417cdf0e10cSrcweir 						Disabled und keine weiter Statusinformation
418cdf0e10cSrcweir 						verf"ugbar. Alle anderen ggf. angezeigten Werte sollten
419cdf0e10cSrcweir 						auf den Default zur"uckgesetzt werden.
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 						SFX_ITEM_DONTCARE
422cdf0e10cSrcweir 						Enabled aber es waren nur uneindeutige Werte
423cdf0e10cSrcweir 						verf"ugbar (also keine, die abgefragt werden k"onnen).
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 						SFX_ITEM_AVAILABLE
426cdf0e10cSrcweir 						Enabled und mit verf"ugbarem Wert, der von 'pState'
427cdf0e10cSrcweir 						erfragbar ist. Der Typ ist dabei im gesamten
428cdf0e10cSrcweir 						Programm eindeutig und durch den Slot festgelegt.
429cdf0e10cSrcweir */
430cdf0e10cSrcweir 
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	return !pState
433cdf0e10cSrcweir 				? SFX_ITEM_DISABLED
434cdf0e10cSrcweir 				: IsInvalidItem(pState)
435cdf0e10cSrcweir 					? SFX_ITEM_DONTCARE
436cdf0e10cSrcweir 					: pState->ISA(SfxVoidItem) && !pState->Which()
437cdf0e10cSrcweir 						? SFX_ITEM_UNKNOWN
438cdf0e10cSrcweir 						: SFX_ITEM_AVAILABLE;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
Dispatch(const Reference<XDispatchProvider> & rProvider,const rtl::OUString & rCommand,Sequence<::PropertyValue> & aArgs)441cdf0e10cSrcweir void SfxToolBoxControl::Dispatch(
442cdf0e10cSrcweir     const Reference< XDispatchProvider >& rProvider,
443cdf0e10cSrcweir     const rtl::OUString& rCommand,
444cdf0e10cSrcweir     Sequence< ::PropertyValue >& aArgs )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     if ( rProvider.is() )
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir         ::com::sun::star::util::URL aTargetURL;
449cdf0e10cSrcweir         aTargetURL.Complete = rCommand;
450cdf0e10cSrcweir 		Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
451cdf0e10cSrcweir                                             rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )),
452cdf0e10cSrcweir                                           UNO_QUERY );
453cdf0e10cSrcweir         xTrans->parseStrict( aTargetURL );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir         Reference < XDispatch > xDispatch = rProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
456cdf0e10cSrcweir         if ( xDispatch.is() )
457cdf0e10cSrcweir             xDispatch->dispatch( aTargetURL, aArgs );
458cdf0e10cSrcweir     }
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
Dispatch(const::rtl::OUString & aCommand,::com::sun::star::uno::Sequence<::com::sun::star::beans::PropertyValue> & aArgs)461cdf0e10cSrcweir void SfxToolBoxControl::Dispatch( const ::rtl::OUString& aCommand, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     Reference < XController > xController;
464cdf0e10cSrcweir 
465cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
466cdf0e10cSrcweir     if ( getFrameInterface().is() )
467cdf0e10cSrcweir         xController = getFrameInterface()->getController();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
470cdf0e10cSrcweir     if ( xProvider.is() )
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir         ::com::sun::star::util::URL aTargetURL;
473cdf0e10cSrcweir         aTargetURL.Complete = aCommand;
474cdf0e10cSrcweir         getURLTransformer()->parseStrict( aTargetURL );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         Reference < XDispatch > xDispatch = xProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
477cdf0e10cSrcweir         if ( xDispatch.is() )
478cdf0e10cSrcweir         {
479cdf0e10cSrcweir             if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
480cdf0e10cSrcweir             {
481cdf0e10cSrcweir                 ::rtl::OUString sAppName;
482cdf0e10cSrcweir                 try
483cdf0e10cSrcweir                 {
484cdf0e10cSrcweir                     static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager");
485cdf0e10cSrcweir                     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager =
486cdf0e10cSrcweir                         ::comphelper::getProcessServiceFactory();
487cdf0e10cSrcweir                     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager(
488cdf0e10cSrcweir                         xServiceManager->createInstance(our_aModuleManagerName)
489cdf0e10cSrcweir                         , ::com::sun::star::uno::UNO_QUERY_THROW);
490cdf0e10cSrcweir                     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame(
491cdf0e10cSrcweir                         getFrameInterface(), UNO_QUERY_THROW);
492cdf0e10cSrcweir                     sAppName = xModuleManager->identify(xFrame);
493cdf0e10cSrcweir                 } catch(::com::sun::star::uno::Exception&) {}
494cdf0e10cSrcweir                 Sequence<PropertyValue> source;
495cdf0e10cSrcweir                 ::comphelper::UiEventsLogger::appendDispatchOrigin(source, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl"));
496cdf0e10cSrcweir                 ::comphelper::UiEventsLogger::logDispatch(aTargetURL, source);
497cdf0e10cSrcweir             }
498cdf0e10cSrcweir             xDispatch->dispatch( aTargetURL, aArgs );
499cdf0e10cSrcweir         }
500cdf0e10cSrcweir     }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir // XInterface
queryInterface(const Type & rType)504cdf0e10cSrcweir Any SAL_CALL SfxToolBoxControl::queryInterface( const Type & rType )
505cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
508cdf0e10cSrcweir    										SAL_STATIC_CAST( ::com::sun::star::awt::XDockableWindowListener*, this ),
509cdf0e10cSrcweir                                         SAL_STATIC_CAST( ::com::sun::star::frame::XSubToolbarController*, this ));
510cdf0e10cSrcweir     return (aRet.hasValue() ? aRet : svt::ToolboxController::queryInterface( rType ));
511cdf0e10cSrcweir }
512cdf0e10cSrcweir 
acquire()513cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::acquire() throw()
514cdf0e10cSrcweir {
515cdf0e10cSrcweir     OWeakObject::acquire();
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
release()518cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::release() throw()
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     OWeakObject::release();
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
disposing(const::com::sun::star::lang::EventObject & aEvent)523cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::disposing( const ::com::sun::star::lang::EventObject& aEvent )
524cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir     svt::ToolboxController::disposing( aEvent );
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir // XStatusListener
statusChanged(const FeatureStateEvent & rEvent)530cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent )
531cdf0e10cSrcweir throw ( ::com::sun::star::uno::RuntimeException )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     SfxViewFrame* pViewFrame = NULL;
534cdf0e10cSrcweir     Reference < XController > xController;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
537cdf0e10cSrcweir     if ( getFrameInterface().is() )
538cdf0e10cSrcweir         xController = getFrameInterface()->getController();
539cdf0e10cSrcweir 
540cdf0e10cSrcweir     Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
541cdf0e10cSrcweir     if ( xProvider.is() )
542cdf0e10cSrcweir     {
543cdf0e10cSrcweir         Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
544cdf0e10cSrcweir         if ( xDisp.is() )
545cdf0e10cSrcweir         {
546cdf0e10cSrcweir             Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY );
547cdf0e10cSrcweir             SfxOfficeDispatch* pDisp = NULL;
548cdf0e10cSrcweir             if ( xTunnel.is() )
549cdf0e10cSrcweir             {
550cdf0e10cSrcweir                 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
551cdf0e10cSrcweir                 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation ));
552cdf0e10cSrcweir             }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir             if ( pDisp )
555cdf0e10cSrcweir                 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
556cdf0e10cSrcweir         }
557cdf0e10cSrcweir     }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir     sal_uInt16 nSlotId = 0;
560cdf0e10cSrcweir     SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame );
561cdf0e10cSrcweir     const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
562cdf0e10cSrcweir     if ( pSlot )
563cdf0e10cSrcweir         nSlotId = pSlot->GetSlotId();
564cdf0e10cSrcweir     else if ( m_aCommandURL == rEvent.FeatureURL.Path )
565cdf0e10cSrcweir         nSlotId = GetSlotId();
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     if ( nSlotId > 0 )
568cdf0e10cSrcweir     {
569cdf0e10cSrcweir         if ( rEvent.Requery )
570cdf0e10cSrcweir             svt::ToolboxController::statusChanged( rEvent );
571cdf0e10cSrcweir 	    else
572cdf0e10cSrcweir 	    {
573cdf0e10cSrcweir             SfxItemState eState = SFX_ITEM_DISABLED;
574cdf0e10cSrcweir 		    SfxPoolItem* pItem = NULL;
575cdf0e10cSrcweir 		    if ( rEvent.IsEnabled )
576cdf0e10cSrcweir 		    {
577cdf0e10cSrcweir 			    eState = SFX_ITEM_AVAILABLE;
578cdf0e10cSrcweir 			    ::com::sun::star::uno::Type pType =	rEvent.State.getValueType();
579cdf0e10cSrcweir 
580cdf0e10cSrcweir                 if ( pType == ::getVoidCppuType() )
581cdf0e10cSrcweir                 {
582cdf0e10cSrcweir                     pItem = new SfxVoidItem( nSlotId );
583cdf0e10cSrcweir                     eState = SFX_ITEM_UNKNOWN;
584cdf0e10cSrcweir                 }
585cdf0e10cSrcweir                 else if ( pType == ::getBooleanCppuType() )
586cdf0e10cSrcweir 			    {
587cdf0e10cSrcweir 				    sal_Bool bTemp = false;
588cdf0e10cSrcweir 				    rEvent.State >>= bTemp ;
589cdf0e10cSrcweir 				    pItem = new SfxBoolItem( nSlotId, bTemp );
590cdf0e10cSrcweir 			    }
591cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const sal_uInt16*)0) )
592cdf0e10cSrcweir 			    {
593cdf0e10cSrcweir 				    sal_uInt16 nTemp = 0;
594cdf0e10cSrcweir 				    rEvent.State >>= nTemp ;
595cdf0e10cSrcweir 				    pItem = new SfxUInt16Item( nSlotId, nTemp );
596cdf0e10cSrcweir 			    }
597cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const sal_uInt32*)0) )
598cdf0e10cSrcweir 			    {
599cdf0e10cSrcweir 				    sal_uInt32 nTemp = 0;
600cdf0e10cSrcweir 				    rEvent.State >>= nTemp ;
601cdf0e10cSrcweir 				    pItem = new SfxUInt32Item( nSlotId, nTemp );
602cdf0e10cSrcweir 			    }
603cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
604cdf0e10cSrcweir 			    {
605cdf0e10cSrcweir 				    ::rtl::OUString sTemp ;
606cdf0e10cSrcweir 				    rEvent.State >>= sTemp ;
607cdf0e10cSrcweir 				    pItem = new SfxStringItem( nSlotId, sTemp );
608cdf0e10cSrcweir 			    }
609cdf0e10cSrcweir                 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
610cdf0e10cSrcweir                 {
611cdf0e10cSrcweir                     ItemStatus aItemStatus;
612cdf0e10cSrcweir                     rEvent.State >>= aItemStatus;
613cdf0e10cSrcweir                     eState = aItemStatus.State;
614cdf0e10cSrcweir                     pItem = new SfxVoidItem( nSlotId );
615cdf0e10cSrcweir                 }
616cdf0e10cSrcweir                 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) )
617cdf0e10cSrcweir                 {
618cdf0e10cSrcweir                     Visibility aVisibilityStatus;
619cdf0e10cSrcweir                     rEvent.State >>= aVisibilityStatus;
620cdf0e10cSrcweir                     pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible );
621cdf0e10cSrcweir                 }
622cdf0e10cSrcweir 			    else
623cdf0e10cSrcweir                 {
624cdf0e10cSrcweir                     if ( pSlot )
625cdf0e10cSrcweir                         pItem = pSlot->GetType()->CreateItem();
626cdf0e10cSrcweir                     if ( pItem )
627cdf0e10cSrcweir                     {
628cdf0e10cSrcweir                         pItem->SetWhich( nSlotId );
629cdf0e10cSrcweir                         pItem->PutValue( rEvent.State );
630cdf0e10cSrcweir                     }
631cdf0e10cSrcweir                     else
632cdf0e10cSrcweir                         pItem = new SfxVoidItem( nSlotId );
633cdf0e10cSrcweir                 }
634cdf0e10cSrcweir 		    }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir             StateChanged( nSlotId, eState, pItem );
637cdf0e10cSrcweir             delete pItem;
638cdf0e10cSrcweir 	    }
639cdf0e10cSrcweir     }
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir // XSubToolbarController
opensSubToolbar()643cdf0e10cSrcweir ::sal_Bool SAL_CALL SfxToolBoxControl::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     return sal_False;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
getSubToolbarName()648cdf0e10cSrcweir ::rtl::OUString SAL_CALL SfxToolBoxControl::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     return rtl::OUString();
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
functionSelected(const::rtl::OUString &)653cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::functionSelected( const ::rtl::OUString& /*aCommand*/ ) throw (::com::sun::star::uno::RuntimeException)
654cdf0e10cSrcweir {
655cdf0e10cSrcweir     // must be implemented by sub-class
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
updateImage()658cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::updateImage() throw (::com::sun::star::uno::RuntimeException)
659cdf0e10cSrcweir {
660cdf0e10cSrcweir     // must be implemented by sub-class
661cdf0e10cSrcweir }
662cdf0e10cSrcweir 
663cdf0e10cSrcweir // XToolbarController
execute(sal_Int16 KeyModifier)664cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException)
665cdf0e10cSrcweir {
666cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
667cdf0e10cSrcweir     Select( (sal_uInt16)KeyModifier );
668cdf0e10cSrcweir }
click()669cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::click() throw (::com::sun::star::uno::RuntimeException)
670cdf0e10cSrcweir {
671cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
672cdf0e10cSrcweir     Click();
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
doubleClick()675cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::doubleClick() throw (::com::sun::star::uno::RuntimeException)
676cdf0e10cSrcweir {
677cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
678cdf0e10cSrcweir     DoubleClick();
679cdf0e10cSrcweir }
680cdf0e10cSrcweir 
createPopupWindow()681cdf0e10cSrcweir Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createPopupWindow() throw (::com::sun::star::uno::RuntimeException)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
684cdf0e10cSrcweir     Window* pWindow = CreatePopupWindow();
685cdf0e10cSrcweir     if ( pWindow )
686cdf0e10cSrcweir         return VCLUnoHelper::GetInterface( pWindow );
687cdf0e10cSrcweir     else
688cdf0e10cSrcweir         return Reference< ::com::sun::star::awt::XWindow >();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
createItemWindow(const Reference<::com::sun::star::awt::XWindow> & rParent)691cdf0e10cSrcweir Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( const Reference< ::com::sun::star::awt::XWindow >& rParent ) throw (::com::sun::star::uno::RuntimeException)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
694cdf0e10cSrcweir     return VCLUnoHelper::GetInterface( CreateItemWindow( VCLUnoHelper::GetWindow( rParent )));
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir // XDockableWindowListener
startDocking(const::com::sun::star::awt::DockingEvent &)698cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::startDocking( const ::com::sun::star::awt::DockingEvent& )
699cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
700cdf0e10cSrcweir {
701cdf0e10cSrcweir }
docking(const::com::sun::star::awt::DockingEvent &)702cdf0e10cSrcweir ::com::sun::star::awt::DockingData SAL_CALL SfxToolBoxControl::docking( const ::com::sun::star::awt::DockingEvent& )
703cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
704cdf0e10cSrcweir {
705cdf0e10cSrcweir     return ::com::sun::star::awt::DockingData();
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
endDocking(const::com::sun::star::awt::EndDockingEvent &)708cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::endDocking( const ::com::sun::star::awt::EndDockingEvent& )
709cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
prepareToggleFloatingMode(const::com::sun::star::lang::EventObject &)713cdf0e10cSrcweir sal_Bool SAL_CALL SfxToolBoxControl::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& )
714cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir     return sal_False;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
toggleFloatingMode(const::com::sun::star::lang::EventObject &)719cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::toggleFloatingMode( const ::com::sun::star::lang::EventObject& )
720cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
721cdf0e10cSrcweir {
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
closed(const::com::sun::star::lang::EventObject &)724cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::closed( const ::com::sun::star::lang::EventObject& )
725cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
726cdf0e10cSrcweir {
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
endPopupMode(const::com::sun::star::awt::EndPopupModeEvent & aEvent)729cdf0e10cSrcweir void SAL_CALL SfxToolBoxControl::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& aEvent )
730cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
731cdf0e10cSrcweir {
732cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
733cdf0e10cSrcweir 
734cdf0e10cSrcweir     ::rtl::OUString aSubToolBarResName;
735cdf0e10cSrcweir     if ( pImpl->mxUIElement.is() )
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir         Reference< XPropertySet > xPropSet( pImpl->mxUIElement, UNO_QUERY );
738cdf0e10cSrcweir         if ( xPropSet.is() )
739cdf0e10cSrcweir         {
740cdf0e10cSrcweir             try
741cdf0e10cSrcweir             {
742cdf0e10cSrcweir                 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ))) >>= aSubToolBarResName;
743cdf0e10cSrcweir             }
744cdf0e10cSrcweir             catch ( com::sun::star::beans::UnknownPropertyException& )
745cdf0e10cSrcweir             {
746cdf0e10cSrcweir             }
747cdf0e10cSrcweir 			catch ( com::sun::star::lang::WrappedTargetException& )
748cdf0e10cSrcweir             {
749cdf0e10cSrcweir             }
750cdf0e10cSrcweir         }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir         Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
753cdf0e10cSrcweir         xComponent->dispose();
754cdf0e10cSrcweir     }
755cdf0e10cSrcweir     pImpl->mxUIElement = 0;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir     // if the toolbar was teared-off recreate it and place it at the given position
758cdf0e10cSrcweir     if( aEvent.bTearoff )
759cdf0e10cSrcweir     {
760cdf0e10cSrcweir         Reference< XUIElement >     xUIElement;
761cdf0e10cSrcweir         Reference< XLayoutManager > xLayoutManager = getLayoutManager();
762cdf0e10cSrcweir 
763cdf0e10cSrcweir         if ( !xLayoutManager.is() )
764cdf0e10cSrcweir             return;
765cdf0e10cSrcweir 
766cdf0e10cSrcweir         xLayoutManager->createElement( aSubToolBarResName );
767cdf0e10cSrcweir         xUIElement = xLayoutManager->getElement( aSubToolBarResName );
768cdf0e10cSrcweir         if ( xUIElement.is() )
769cdf0e10cSrcweir         {
770cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow();
771cdf0e10cSrcweir 
772cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY );
773cdf0e10cSrcweir             Reference< ::com::sun::star::beans::XPropertySet > xProp( xUIElement, UNO_QUERY );
774cdf0e10cSrcweir             if ( xSubToolBar.is() && xProp.is() )
775cdf0e10cSrcweir             {
776cdf0e10cSrcweir                 rtl::OUString aPersistentString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
777cdf0e10cSrcweir                 try
778cdf0e10cSrcweir                 {
779cdf0e10cSrcweir                     Window*  pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar );
780cdf0e10cSrcweir                     ToolBox* pToolBar( 0 );
781cdf0e10cSrcweir                     if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX )
782cdf0e10cSrcweir                     {
783cdf0e10cSrcweir                         pToolBar = (ToolBox *)pTbxWindow;
784cdf0e10cSrcweir 
785cdf0e10cSrcweir                         Any a;
786cdf0e10cSrcweir                         a = xProp->getPropertyValue( aPersistentString );
787cdf0e10cSrcweir                         xProp->setPropertyValue( aPersistentString, makeAny( sal_False ));
788cdf0e10cSrcweir 
789cdf0e10cSrcweir                         xLayoutManager->hideElement( aSubToolBarResName );
790cdf0e10cSrcweir                         xLayoutManager->floatWindow( aSubToolBarResName );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir                         xLayoutManager->setElementPos( aSubToolBarResName, aEvent.FloatingPosition );
793cdf0e10cSrcweir                         xLayoutManager->showElement( aSubToolBarResName );
794cdf0e10cSrcweir 
795cdf0e10cSrcweir                         xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )), a );
796cdf0e10cSrcweir                     }
797cdf0e10cSrcweir                 }
798cdf0e10cSrcweir                 catch ( ::com::sun::star::uno::RuntimeException& )
799cdf0e10cSrcweir                 {
800cdf0e10cSrcweir                     throw;
801cdf0e10cSrcweir                 }
802cdf0e10cSrcweir                 catch ( ::com::sun::star::uno::Exception& )
803cdf0e10cSrcweir                 {
804cdf0e10cSrcweir                 }
805cdf0e10cSrcweir             }
806cdf0e10cSrcweir         }
807cdf0e10cSrcweir     }
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
getPersistentFloatingSize(const Reference<XFrame> &,const::rtl::OUString &)810cdf0e10cSrcweir ::Size  SfxToolBoxControl::getPersistentFloatingSize( const Reference< XFrame >& /*xFrame*/, const ::rtl::OUString& /*rSubToolBarResName*/ )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir     ::Size  aToolboxSize;
813cdf0e10cSrcweir     return aToolboxSize;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
createAndPositionSubToolBar(const::rtl::OUString & rSubToolBarResName)816cdf0e10cSrcweir void SfxToolBoxControl::createAndPositionSubToolBar( const ::rtl::OUString& rSubToolBarResName )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
819cdf0e10cSrcweir 
820cdf0e10cSrcweir     if ( pImpl->pBox )
821cdf0e10cSrcweir     {
822cdf0e10cSrcweir         static WeakReference< XUIElementFactory > xWeakUIElementFactory;
823cdf0e10cSrcweir 
824cdf0e10cSrcweir         sal_uInt16 nItemId = pImpl->pBox->GetDownItemId();
825cdf0e10cSrcweir 
826cdf0e10cSrcweir         if ( !nItemId )
827cdf0e10cSrcweir             return;
828cdf0e10cSrcweir 
829cdf0e10cSrcweir         // create element with factory
830cdf0e10cSrcweir         Reference< XMultiServiceFactory >   xServiceManager = getServiceManager();
831cdf0e10cSrcweir         Reference< XFrame >                 xFrame          = getFrameInterface();
832cdf0e10cSrcweir         Reference< XUIElement >             xUIElement;
833cdf0e10cSrcweir         Reference< XUIElementFactory >      xUIEementFactory;
834cdf0e10cSrcweir 
835cdf0e10cSrcweir         xUIEementFactory = xWeakUIElementFactory;
836cdf0e10cSrcweir         if ( !xUIEementFactory.is() )
837cdf0e10cSrcweir         {
838cdf0e10cSrcweir             xUIEementFactory = Reference< XUIElementFactory >(
839cdf0e10cSrcweir                 xServiceManager->createInstance(
840cdf0e10cSrcweir                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
841cdf0e10cSrcweir                         "com.sun.star.ui.UIElementFactoryManager" ))),
842cdf0e10cSrcweir                 UNO_QUERY );
843cdf0e10cSrcweir             xWeakUIElementFactory = xUIEementFactory;
844cdf0e10cSrcweir         }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir         Sequence< PropertyValue > aPropSeq( 3 );
847cdf0e10cSrcweir         aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
848cdf0e10cSrcweir         aPropSeq[0].Value <<= xFrame;
849cdf0e10cSrcweir         aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
850cdf0e10cSrcweir         aPropSeq[1].Value <<= sal_False;
851cdf0e10cSrcweir         aPropSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PopupMode" ));
852cdf0e10cSrcweir         aPropSeq[2].Value <<= sal_True;
853cdf0e10cSrcweir 
854cdf0e10cSrcweir         try
855cdf0e10cSrcweir         {
856cdf0e10cSrcweir             xUIElement = xUIEementFactory->createUIElement( rSubToolBarResName, aPropSeq );
857cdf0e10cSrcweir         }
858cdf0e10cSrcweir         catch ( ::com::sun::star::container::NoSuchElementException& )
859cdf0e10cSrcweir         {
860cdf0e10cSrcweir         }
861cdf0e10cSrcweir         catch ( IllegalArgumentException& )
862cdf0e10cSrcweir         {
863cdf0e10cSrcweir         }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir         if ( xUIElement.is() )
866cdf0e10cSrcweir         {
867cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow();
868cdf0e10cSrcweir 
869cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY );
870cdf0e10cSrcweir             if ( xSubToolBar.is() )
871cdf0e10cSrcweir             {
872cdf0e10cSrcweir                 Reference< ::com::sun::star::awt::XDockableWindow > xDockWindow( xSubToolBar, UNO_QUERY );
873cdf0e10cSrcweir                 xDockWindow->addDockableWindowListener( Reference< ::com::sun::star::awt::XDockableWindowListener >(
874cdf0e10cSrcweir                     static_cast< OWeakObject * >( this ), UNO_QUERY ));
875cdf0e10cSrcweir                 xDockWindow->enableDocking( sal_True );
876cdf0e10cSrcweir 
877cdf0e10cSrcweir                 // keep refererence to UIElement to avoid its destruction
878cdf0e10cSrcweir                 if ( pImpl->mxUIElement.is() )
879cdf0e10cSrcweir                 {
880cdf0e10cSrcweir                     Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
881cdf0e10cSrcweir                     xComponent->dispose();
882cdf0e10cSrcweir                 }
883cdf0e10cSrcweir                 pImpl->mxUIElement = xUIElement;
884cdf0e10cSrcweir 
885cdf0e10cSrcweir                 Window*  pParentTbxWindow( pImpl->pBox );
886cdf0e10cSrcweir                 Window*  pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar );
887cdf0e10cSrcweir                 ToolBox* pToolBar( 0 );
888cdf0e10cSrcweir                 if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX )
889cdf0e10cSrcweir                     pToolBar = (ToolBox *)pTbxWindow;
890cdf0e10cSrcweir 
891cdf0e10cSrcweir                 if ( pToolBar )
892cdf0e10cSrcweir                 {
893cdf0e10cSrcweir                     pToolBar->SetParent( pParentTbxWindow );
894cdf0e10cSrcweir                     ::Size aSize = getPersistentFloatingSize( xFrame, rSubToolBarResName );
895cdf0e10cSrcweir                     if ( aSize.Width() == 0 || aSize.Height() == 0 )
896cdf0e10cSrcweir                     {
897cdf0e10cSrcweir                         // calc and set size for popup mode
898cdf0e10cSrcweir                         aSize = pToolBar->CalcPopupWindowSizePixel();
899cdf0e10cSrcweir                     }
900cdf0e10cSrcweir                     pToolBar->SetSizePixel( aSize );
901cdf0e10cSrcweir 
902cdf0e10cSrcweir                     // open subtoolbox in popup mode
903cdf0e10cSrcweir                     Window::GetDockingManager()->StartPopupMode( pImpl->pBox, pToolBar );
904cdf0e10cSrcweir                 }
905cdf0e10cSrcweir             }
906cdf0e10cSrcweir         }
907cdf0e10cSrcweir     }
908cdf0e10cSrcweir }
909cdf0e10cSrcweir 
910cdf0e10cSrcweir //--------------------------------------------------------------------
911cdf0e10cSrcweir 
SetPopupWindow(SfxPopupWindow * pWindow)912cdf0e10cSrcweir void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir     pImpl->mpPopupWindow = pWindow;
915cdf0e10cSrcweir     pImpl->mpPopupWindow->SetPopupModeEndHdl( LINK( this, SfxToolBoxControl, PopupModeEndHdl ));
916cdf0e10cSrcweir     pImpl->mpPopupWindow->SetDeleteLink_Impl( LINK( this, SfxToolBoxControl, ClosePopupWindow ));
917cdf0e10cSrcweir }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir //--------------------------------------------------------------------
920cdf0e10cSrcweir 
IMPL_LINK(SfxToolBoxControl,PopupModeEndHdl,void *,EMPTYARG)921cdf0e10cSrcweir IMPL_LINK( SfxToolBoxControl, PopupModeEndHdl, void *, EMPTYARG )
922cdf0e10cSrcweir {
923cdf0e10cSrcweir 	if ( pImpl->mpPopupWindow->IsVisible() )
924cdf0e10cSrcweir     {
925cdf0e10cSrcweir         // Replace floating window with popup window and destroy
926cdf0e10cSrcweir         // floating window instance.
927cdf0e10cSrcweir         delete pImpl->mpFloatingWindow;
928cdf0e10cSrcweir         pImpl->mpFloatingWindow = pImpl->mpPopupWindow;
929cdf0e10cSrcweir         pImpl->mpPopupWindow    = 0;
930cdf0e10cSrcweir         // We also need to know when the user tries to use the
931cdf0e10cSrcweir         // floating window.
932cdf0e10cSrcweir         pImpl->mpFloatingWindow->AddEventListener( LINK( pImpl, SfxToolBoxControl_Impl, WindowEventListener ));
933cdf0e10cSrcweir     }
934cdf0e10cSrcweir     else
935cdf0e10cSrcweir     {
936cdf0e10cSrcweir         // Popup window has been closed by the user. No replacement, instance
937cdf0e10cSrcweir         // will destroy itself.
938cdf0e10cSrcweir         pImpl->mpPopupWindow = 0;
939cdf0e10cSrcweir     }
940cdf0e10cSrcweir 
941cdf0e10cSrcweir     return 1;
942cdf0e10cSrcweir }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir //--------------------------------------------------------------------
IMPL_LINK(SfxToolBoxControl,ClosePopupWindow,SfxPopupWindow *,pWindow)945cdf0e10cSrcweir IMPL_LINK( SfxToolBoxControl, ClosePopupWindow, SfxPopupWindow *, pWindow )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir     if ( pWindow == pImpl->mpFloatingWindow )
948cdf0e10cSrcweir         pImpl->mpFloatingWindow = 0;
949cdf0e10cSrcweir     else
950cdf0e10cSrcweir         pImpl->mpPopupWindow = 0;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir     return 1;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir 
955cdf0e10cSrcweir //--------------------------------------------------------------------
956cdf0e10cSrcweir 
StateChanged(sal_uInt16 nId,SfxItemState eState,const SfxPoolItem * pState)957cdf0e10cSrcweir void SfxToolBoxControl::StateChanged
958cdf0e10cSrcweir (
959cdf0e10cSrcweir 	sal_uInt16              nId,
960cdf0e10cSrcweir 	SfxItemState        eState,
961cdf0e10cSrcweir 	const SfxPoolItem*  pState
962cdf0e10cSrcweir )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir 	DBG_MEMTEST();
965cdf0e10cSrcweir 	DBG_ASSERT( pImpl->pBox != 0, "setting state to dangling ToolBox" );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 	if ( GetId() >= SID_OBJECTMENU0 && GetId() <= SID_OBJECTMENU_LAST )
968cdf0e10cSrcweir 		return;
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 	// enabled/disabled-Flag pauschal korrigieren
971cdf0e10cSrcweir 	pImpl->pBox->EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	sal_uInt16 nItemBits = pImpl->pBox->GetItemBits( GetId() );
974cdf0e10cSrcweir 	nItemBits &= ~TIB_CHECKABLE;
975cdf0e10cSrcweir 	TriState eTri = STATE_NOCHECK;
976cdf0e10cSrcweir 	switch ( eState )
977cdf0e10cSrcweir 	{
978cdf0e10cSrcweir 		case SFX_ITEM_AVAILABLE:
979cdf0e10cSrcweir 		{
980cdf0e10cSrcweir 			if ( pState->ISA(SfxBoolItem) )
981cdf0e10cSrcweir 			{
982cdf0e10cSrcweir 				// BoolItem fuer checken
983cdf0e10cSrcweir 				if ( ((const SfxBoolItem*)pState)->GetValue() )
984cdf0e10cSrcweir 					eTri = STATE_CHECK;
985cdf0e10cSrcweir 				nItemBits |= TIB_CHECKABLE;
986cdf0e10cSrcweir 			}
987cdf0e10cSrcweir 			else if ( pState->ISA(SfxEnumItemInterface) &&
988cdf0e10cSrcweir 				((SfxEnumItemInterface *)pState)->HasBoolValue())
989cdf0e10cSrcweir 			{
990cdf0e10cSrcweir 				// EnumItem wie Bool behandeln
991cdf0e10cSrcweir 				if ( ((const SfxEnumItemInterface *)pState)->GetBoolValue() )
992cdf0e10cSrcweir 					eTri = STATE_CHECK;
993cdf0e10cSrcweir 				nItemBits |= TIB_CHECKABLE;
994cdf0e10cSrcweir 			}
995cdf0e10cSrcweir 			else if ( pImpl->bShowString && pState->ISA(SfxStringItem) )
996cdf0e10cSrcweir 				pImpl->pBox->SetItemText(nId, ((const SfxStringItem*)pState)->GetValue() );
997cdf0e10cSrcweir 			break;
998cdf0e10cSrcweir 		}
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir 		case SFX_ITEM_DONTCARE:
1001cdf0e10cSrcweir         {
1002cdf0e10cSrcweir 			eTri = STATE_DONTKNOW;
1003cdf0e10cSrcweir             nItemBits |= TIB_CHECKABLE;
1004cdf0e10cSrcweir         }
1005cdf0e10cSrcweir 	}
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 	pImpl->pBox->SetItemState( GetId(), eTri );
1008cdf0e10cSrcweir 	pImpl->pBox->SetItemBits( GetId(), nItemBits );
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir //--------------------------------------------------------------------
1012cdf0e10cSrcweir 
Select(sal_uInt16 nModifier)1013cdf0e10cSrcweir void SfxToolBoxControl::Select( sal_uInt16 nModifier )
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	pImpl->nSelectModifier = nModifier;
1016cdf0e10cSrcweir 	Select( sal_Bool((nModifier & KEY_MOD1)!=0) );
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir //--------------------------------------------------------------------
1020cdf0e10cSrcweir 
Select(sal_Bool)1021cdf0e10cSrcweir void SfxToolBoxControl::Select( sal_Bool /*bMod1*/ )
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir     if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# #i102805#
1024cdf0e10cSrcweir     {
1025cdf0e10cSrcweir         ::rtl::OUString sAppName;
1026cdf0e10cSrcweir         try
1027cdf0e10cSrcweir         {
1028cdf0e10cSrcweir             static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager");
1029cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager =
1030cdf0e10cSrcweir                 ::comphelper::getProcessServiceFactory();
1031cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager(
1032cdf0e10cSrcweir                 xServiceManager->createInstance(our_aModuleManagerName)
1033cdf0e10cSrcweir                 , ::com::sun::star::uno::UNO_QUERY_THROW);
1034cdf0e10cSrcweir             sAppName = xModuleManager->identify(m_xFrame);
1035cdf0e10cSrcweir         } catch(::com::sun::star::uno::Exception&) {}
1036cdf0e10cSrcweir         Sequence<PropertyValue> vSource;
1037cdf0e10cSrcweir         ::comphelper::UiEventsLogger::appendDispatchOrigin(vSource, sAppName, ::rtl::OUString::createFromAscii("SfxToolBoxControl"));
1038cdf0e10cSrcweir         URL aURL;
1039cdf0e10cSrcweir         aURL.Complete = m_aCommandURL;
1040cdf0e10cSrcweir         ::comphelper::UiEventsLogger::logDispatch(aURL, vSource);
1041cdf0e10cSrcweir     }
1042cdf0e10cSrcweir     svt::ToolboxController::execute( pImpl->nSelectModifier );
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir //--------------------------------------------------------------------
1046cdf0e10cSrcweir 
DoubleClick()1047cdf0e10cSrcweir void SfxToolBoxControl::DoubleClick()
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir //--------------------------------------------------------------------
1052cdf0e10cSrcweir 
Click()1053cdf0e10cSrcweir void SfxToolBoxControl::Click()
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir //--------------------------------------------------------------------
1058cdf0e10cSrcweir 
GetPopupWindowType() const1059cdf0e10cSrcweir SfxPopupWindowType SfxToolBoxControl::GetPopupWindowType() const
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir 	return SFX_POPUPWINDOW_NONE;
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir //--------------------------------------------------------------------
1065cdf0e10cSrcweir 
CreatePopupWindow()1066cdf0e10cSrcweir SfxPopupWindow* SfxToolBoxControl::CreatePopupWindow()
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir 	return 0;
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir 
CreatePopupWindowCascading()1071cdf0e10cSrcweir SfxPopupWindow* SfxToolBoxControl::CreatePopupWindowCascading()
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir 	return 0;
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir //--------------------------------------------------------------------
1077cdf0e10cSrcweir 
CreateItemWindow(Window *)1078cdf0e10cSrcweir Window* SfxToolBoxControl::CreateItemWindow( Window * )
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir 	return 0;
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir //--------------------------------------------------------------------
1084cdf0e10cSrcweir 
SfxFrameStatusListener(const Reference<XMultiServiceFactory> & rServiceManager,const Reference<XFrame> & xFrame,SfxStatusListenerInterface * pCallee)1085cdf0e10cSrcweir SfxFrameStatusListener::SfxFrameStatusListener(
1086cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& rServiceManager,
1087cdf0e10cSrcweir     const Reference< XFrame >& xFrame,
1088cdf0e10cSrcweir     SfxStatusListenerInterface* pCallee ) :
1089cdf0e10cSrcweir     svt::FrameStatusListener( rServiceManager, xFrame ),
1090cdf0e10cSrcweir     m_pCallee( pCallee )
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir //--------------------------------------------------------------------
1095cdf0e10cSrcweir 
~SfxFrameStatusListener()1096cdf0e10cSrcweir SfxFrameStatusListener::~SfxFrameStatusListener()
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir //--------------------------------------------------------------------
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir // XStatusListener
statusChanged(const::com::sun::star::frame::FeatureStateEvent & rEvent)1103cdf0e10cSrcweir void SAL_CALL SfxFrameStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent )
1104cdf0e10cSrcweir throw ( ::com::sun::star::uno::RuntimeException )
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir     SfxViewFrame* pViewFrame = NULL;
1107cdf0e10cSrcweir     Reference < XController > xController;
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
1110cdf0e10cSrcweir     if ( m_xFrame.is() )
1111cdf0e10cSrcweir         xController = m_xFrame->getController();
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
1114cdf0e10cSrcweir     if ( xProvider.is() )
1115cdf0e10cSrcweir     {
1116cdf0e10cSrcweir         Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
1117cdf0e10cSrcweir         if ( xDisp.is() )
1118cdf0e10cSrcweir         {
1119cdf0e10cSrcweir             Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY );
1120cdf0e10cSrcweir             SfxOfficeDispatch* pDisp = NULL;
1121cdf0e10cSrcweir             if ( xTunnel.is() )
1122cdf0e10cSrcweir             {
1123cdf0e10cSrcweir                 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
1124cdf0e10cSrcweir                 pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation ));
1125cdf0e10cSrcweir             }
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir             if ( pDisp )
1128cdf0e10cSrcweir                 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
1129cdf0e10cSrcweir         }
1130cdf0e10cSrcweir     }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir     sal_uInt16 nSlotId = 0;
1133cdf0e10cSrcweir     SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame );
1134cdf0e10cSrcweir     const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
1135cdf0e10cSrcweir     if ( pSlot )
1136cdf0e10cSrcweir         nSlotId = pSlot->GetSlotId();
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir     if ( nSlotId > 0 )
1139cdf0e10cSrcweir     {
1140cdf0e10cSrcweir         if ( rEvent.Requery )
1141cdf0e10cSrcweir         {
1142cdf0e10cSrcweir             // requery for the notified state
1143cdf0e10cSrcweir             addStatusListener( rEvent.FeatureURL.Complete );
1144cdf0e10cSrcweir         }
1145cdf0e10cSrcweir 	    else
1146cdf0e10cSrcweir 	    {
1147cdf0e10cSrcweir             SfxItemState eState = SFX_ITEM_DISABLED;
1148cdf0e10cSrcweir 		    SfxPoolItem* pItem = NULL;
1149cdf0e10cSrcweir 		    if ( rEvent.IsEnabled )
1150cdf0e10cSrcweir 		    {
1151cdf0e10cSrcweir 			    eState = SFX_ITEM_AVAILABLE;
1152cdf0e10cSrcweir 			    ::com::sun::star::uno::Type pType =	rEvent.State.getValueType();
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir                 if ( pType == ::getVoidCppuType() )
1155cdf0e10cSrcweir                 {
1156cdf0e10cSrcweir                     pItem = new SfxVoidItem( nSlotId );
1157cdf0e10cSrcweir                     eState = SFX_ITEM_UNKNOWN;
1158cdf0e10cSrcweir                 }
1159cdf0e10cSrcweir                 else if ( pType == ::getBooleanCppuType() )
1160cdf0e10cSrcweir 			    {
1161cdf0e10cSrcweir 				    sal_Bool bTemp = false;
1162cdf0e10cSrcweir 				    rEvent.State >>= bTemp ;
1163cdf0e10cSrcweir 				    pItem = new SfxBoolItem( nSlotId, bTemp );
1164cdf0e10cSrcweir 			    }
1165cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const sal_uInt16*)0) )
1166cdf0e10cSrcweir 			    {
1167cdf0e10cSrcweir 				    sal_uInt16 nTemp = 0;
1168cdf0e10cSrcweir 				    rEvent.State >>= nTemp ;
1169cdf0e10cSrcweir 				    pItem = new SfxUInt16Item( nSlotId, nTemp );
1170cdf0e10cSrcweir 			    }
1171cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const sal_uInt32*)0) )
1172cdf0e10cSrcweir 			    {
1173cdf0e10cSrcweir 				    sal_uInt32 nTemp = 0;
1174cdf0e10cSrcweir 				    rEvent.State >>= nTemp ;
1175cdf0e10cSrcweir 				    pItem = new SfxUInt32Item( nSlotId, nTemp );
1176cdf0e10cSrcweir 			    }
1177cdf0e10cSrcweir 			    else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
1178cdf0e10cSrcweir 			    {
1179cdf0e10cSrcweir 				    ::rtl::OUString sTemp ;
1180cdf0e10cSrcweir 				    rEvent.State >>= sTemp ;
1181cdf0e10cSrcweir 				    pItem = new SfxStringItem( nSlotId, sTemp );
1182cdf0e10cSrcweir 			    }
1183cdf0e10cSrcweir                 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
1184cdf0e10cSrcweir                 {
1185cdf0e10cSrcweir                     ItemStatus aItemStatus;
1186cdf0e10cSrcweir                     rEvent.State >>= aItemStatus;
1187cdf0e10cSrcweir                     eState = aItemStatus.State;
1188cdf0e10cSrcweir                     pItem = new SfxVoidItem( nSlotId );
1189cdf0e10cSrcweir                 }
1190cdf0e10cSrcweir                 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) )
1191cdf0e10cSrcweir                 {
1192cdf0e10cSrcweir                     Visibility aVisibilityStatus;
1193cdf0e10cSrcweir                     rEvent.State >>= aVisibilityStatus;
1194cdf0e10cSrcweir                     pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible );
1195cdf0e10cSrcweir                 }
1196cdf0e10cSrcweir 			    else
1197cdf0e10cSrcweir                 {
1198cdf0e10cSrcweir                     if ( pSlot )
1199cdf0e10cSrcweir                         pItem = pSlot->GetType()->CreateItem();
1200cdf0e10cSrcweir                     if ( pItem )
1201cdf0e10cSrcweir                     {
1202cdf0e10cSrcweir                         pItem->SetWhich( nSlotId );
1203cdf0e10cSrcweir                         pItem->PutValue( rEvent.State );
1204cdf0e10cSrcweir                     }
1205cdf0e10cSrcweir                     else
1206cdf0e10cSrcweir                         pItem = new SfxVoidItem( nSlotId );
1207cdf0e10cSrcweir                 }
1208cdf0e10cSrcweir 		    }
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir             if ( m_pCallee )
1211cdf0e10cSrcweir                 m_pCallee->StateChanged( nSlotId, eState, pItem );
1212cdf0e10cSrcweir             delete pItem;
1213cdf0e10cSrcweir 	    }
1214cdf0e10cSrcweir     }
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir //--------------------------------------------------------------------
1218cdf0e10cSrcweir 
SfxPopupWindow(sal_uInt16 nId,const Reference<XFrame> & rFrame,WinBits nBits)1219cdf0e10cSrcweir SfxPopupWindow::SfxPopupWindow(
1220cdf0e10cSrcweir     sal_uInt16 nId,
1221cdf0e10cSrcweir     const Reference< XFrame >& rFrame,
1222cdf0e10cSrcweir     WinBits nBits ) :
1223cdf0e10cSrcweir     FloatingWindow( SFX_APP()->GetTopWindow(), nBits )
1224cdf0e10cSrcweir     , m_bFloating(sal_False)
1225cdf0e10cSrcweir     , m_bCascading( sal_False )
1226cdf0e10cSrcweir     , m_nId( nId )
1227cdf0e10cSrcweir     , m_xFrame( rFrame )
1228cdf0e10cSrcweir     , m_pStatusListener( 0 )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     m_xServiceManager = ::comphelper::getProcessServiceFactory();
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
1233cdf0e10cSrcweir     if ( pWindow )
1234cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir //--------------------------------------------------------------------
1238cdf0e10cSrcweir 
SfxPopupWindow(sal_uInt16 nId,const Reference<XFrame> & rFrame,const ResId & rId)1239cdf0e10cSrcweir SfxPopupWindow::SfxPopupWindow(
1240cdf0e10cSrcweir     sal_uInt16 nId,
1241cdf0e10cSrcweir     const Reference< XFrame >& rFrame,
1242cdf0e10cSrcweir     const ResId &rId ) :
1243cdf0e10cSrcweir     FloatingWindow( SFX_APP()->GetTopWindow(), rId )
1244cdf0e10cSrcweir     , m_bFloating(sal_False)
1245cdf0e10cSrcweir     , m_bCascading( sal_False )
1246cdf0e10cSrcweir     , m_nId( nId )
1247cdf0e10cSrcweir     , m_xFrame( rFrame )
1248cdf0e10cSrcweir     , m_pStatusListener( 0 )
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir     m_xServiceManager = ::comphelper::getProcessServiceFactory();
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
1253cdf0e10cSrcweir     if ( pWindow )
1254cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir //--------------------------------------------------------------------
1258cdf0e10cSrcweir 
SfxPopupWindow(sal_uInt16 nId,const Reference<XFrame> & rFrame,Window * pParentWindow,WinBits nBits)1259cdf0e10cSrcweir SfxPopupWindow::SfxPopupWindow(
1260cdf0e10cSrcweir     sal_uInt16 nId,
1261cdf0e10cSrcweir     const Reference< XFrame >& rFrame,
1262cdf0e10cSrcweir     Window* pParentWindow,
1263cdf0e10cSrcweir     WinBits nBits ) :
1264cdf0e10cSrcweir     FloatingWindow( pParentWindow, nBits )
1265cdf0e10cSrcweir     , m_bFloating(sal_False)
1266cdf0e10cSrcweir     , m_bCascading( sal_False )
1267cdf0e10cSrcweir     , m_nId( nId )
1268cdf0e10cSrcweir     , m_xFrame( rFrame )
1269cdf0e10cSrcweir     , m_pStatusListener( 0 )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir     m_xServiceManager = ::comphelper::getProcessServiceFactory();
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
1274cdf0e10cSrcweir     if ( pWindow )
1275cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir //--------------------------------------------------------------------
1279cdf0e10cSrcweir 
SfxPopupWindow(sal_uInt16 nId,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & rFrame,Window * pParentWindow,const ResId & rId)1280cdf0e10cSrcweir SfxPopupWindow::SfxPopupWindow(
1281cdf0e10cSrcweir     sal_uInt16 nId,
1282cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
1283cdf0e10cSrcweir     Window* pParentWindow,
1284cdf0e10cSrcweir     const ResId &rId ) :
1285cdf0e10cSrcweir     FloatingWindow( pParentWindow, rId )
1286cdf0e10cSrcweir     , m_bFloating(sal_False)
1287cdf0e10cSrcweir     , m_bCascading( sal_False )
1288cdf0e10cSrcweir     , m_nId( nId )
1289cdf0e10cSrcweir     , m_xFrame( rFrame )
1290cdf0e10cSrcweir     , m_pStatusListener( 0 )
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir     m_xServiceManager = ::comphelper::getProcessServiceFactory();
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
1295cdf0e10cSrcweir     if ( pWindow )
1296cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir //--------------------------------------------------------------------
1300cdf0e10cSrcweir 
~SfxPopupWindow()1301cdf0e10cSrcweir SfxPopupWindow::~SfxPopupWindow()
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         m_xStatusListener->dispose();
1306cdf0e10cSrcweir         m_xStatusListener.clear();
1307cdf0e10cSrcweir     }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir     Window* pWindow = GetTopMostParentSystemWindow( this );
1310cdf0e10cSrcweir     if ( pWindow )
1311cdf0e10cSrcweir         ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( this );
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir //--------------------------------------------------------------------
1315cdf0e10cSrcweir 
GetOrCreateStatusListener()1316cdf0e10cSrcweir SfxFrameStatusListener* SfxPopupWindow::GetOrCreateStatusListener()
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir     if ( !m_xStatusListener.is() )
1319cdf0e10cSrcweir     {
1320cdf0e10cSrcweir         m_pStatusListener = new SfxFrameStatusListener(
1321cdf0e10cSrcweir                                     m_xServiceManager,
1322cdf0e10cSrcweir                                     m_xFrame,
1323cdf0e10cSrcweir                                     this );
1324cdf0e10cSrcweir         m_xStatusListener = Reference< XComponent >( static_cast< cppu::OWeakObject* >(
1325cdf0e10cSrcweir                                                         m_pStatusListener ), UNO_QUERY );
1326cdf0e10cSrcweir     }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir     return m_pStatusListener;
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir //--------------------------------------------------------------------
1332cdf0e10cSrcweir 
BindListener()1333cdf0e10cSrcweir void SfxPopupWindow::BindListener()
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir     GetOrCreateStatusListener();
1336cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1337cdf0e10cSrcweir         m_pStatusListener->bindListener();
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir //--------------------------------------------------------------------
1341cdf0e10cSrcweir 
UnbindListener()1342cdf0e10cSrcweir void SfxPopupWindow::UnbindListener()
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir     GetOrCreateStatusListener();
1345cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1346cdf0e10cSrcweir         m_pStatusListener->unbindListener();
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir //--------------------------------------------------------------------
1350cdf0e10cSrcweir 
AddStatusListener(const rtl::OUString & rCommandURL)1351cdf0e10cSrcweir void SfxPopupWindow::AddStatusListener( const rtl::OUString& rCommandURL )
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir     GetOrCreateStatusListener();
1354cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1355cdf0e10cSrcweir         m_pStatusListener->addStatusListener( rCommandURL );
1356cdf0e10cSrcweir }
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir //--------------------------------------------------------------------
1359cdf0e10cSrcweir 
RemoveStatusListener(const rtl::OUString & rCommandURL)1360cdf0e10cSrcweir void SfxPopupWindow::RemoveStatusListener( const rtl::OUString& rCommandURL )
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir     GetOrCreateStatusListener();
1363cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1364cdf0e10cSrcweir         m_pStatusListener->removeStatusListener( rCommandURL );
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir //--------------------------------------------------------------------
1368cdf0e10cSrcweir 
UpdateStatus(const rtl::OUString & rCommandURL)1369cdf0e10cSrcweir void SfxPopupWindow::UpdateStatus( const rtl::OUString& rCommandURL )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir     GetOrCreateStatusListener();
1372cdf0e10cSrcweir     if ( m_xStatusListener.is() )
1373cdf0e10cSrcweir         m_pStatusListener->updateStatus( rCommandURL );
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir //--------------------------------------------------------------------
1377cdf0e10cSrcweir 
Close()1378cdf0e10cSrcweir sal_Bool SfxPopupWindow::Close()
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir 	m_bFloating = sal_False;
1381cdf0e10cSrcweir 	FloatingWindow::Close();
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir 	Delete(0);
1384cdf0e10cSrcweir 	return sal_True;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir //--------------------------------------------------------------------
1388cdf0e10cSrcweir 
PopupModeEnd()1389cdf0e10cSrcweir void SfxPopupWindow::PopupModeEnd()
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir 	//! to allow PopupModeEndHdl to be called
1392cdf0e10cSrcweir 	FloatingWindow::PopupModeEnd();
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 	if ( IsVisible() )
1395cdf0e10cSrcweir 	{
1396cdf0e10cSrcweir 		// wurde abgerissen
1397cdf0e10cSrcweir         DeleteFloatingWindow();
1398cdf0e10cSrcweir 		m_bFloating = sal_True;
1399cdf0e10cSrcweir 	}
1400cdf0e10cSrcweir 	else
1401cdf0e10cSrcweir 		Close();
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir //--------------------------------------------------------------------
1405cdf0e10cSrcweir 
DeleteFloatingWindow()1406cdf0e10cSrcweir void SfxPopupWindow::DeleteFloatingWindow()
1407cdf0e10cSrcweir {
1408cdf0e10cSrcweir 	if ( m_bFloating )
1409cdf0e10cSrcweir 	{
1410cdf0e10cSrcweir 		Hide();
1411cdf0e10cSrcweir 		Delete(0);
1412cdf0e10cSrcweir 	}
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir //--------------------------------------------------------------------
1416cdf0e10cSrcweir 
MouseMove(const::MouseEvent & rMEvt)1417cdf0e10cSrcweir void SfxPopupWindow::MouseMove( const ::MouseEvent& rMEvt )
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir 	if ( m_bCascading == sal_False )
1420cdf0e10cSrcweir 		FloatingWindow::MouseMove( rMEvt );
1421cdf0e10cSrcweir 	else
1422cdf0e10cSrcweir 	{
1423cdf0e10cSrcweir 		// MouseMove-Event an die Children forwarden
1424cdf0e10cSrcweir         ::Point       aPos = rMEvt.GetPosPixel();
1425cdf0e10cSrcweir         ::Point       aScrPos = OutputToScreenPixel( aPos );
1426cdf0e10cSrcweir 		sal_uInt16 i = 0;
1427cdf0e10cSrcweir 		Window* pWindow = GetChild( i );
1428cdf0e10cSrcweir 		while ( pWindow )
1429cdf0e10cSrcweir 		{
1430cdf0e10cSrcweir             ::MouseEvent aMEvt( pWindow->ScreenToOutputPixel( aScrPos ),
1431cdf0e10cSrcweir 							  rMEvt.GetClicks(), rMEvt.GetMode(),
1432cdf0e10cSrcweir 							  rMEvt.GetButtons(), rMEvt.GetModifier() );
1433cdf0e10cSrcweir 			pWindow->MouseMove( rMEvt );
1434cdf0e10cSrcweir 			pWindow->Update();
1435cdf0e10cSrcweir 			i++;
1436cdf0e10cSrcweir 			pWindow = GetChild( i );
1437cdf0e10cSrcweir 		}
1438cdf0e10cSrcweir 	}
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir //--------------------------------------------------------------------
1442cdf0e10cSrcweir 
StartCascading()1443cdf0e10cSrcweir void SfxPopupWindow::StartCascading()
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir 	m_bCascading= sal_True;
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir 
EndCascading()1448cdf0e10cSrcweir void SfxPopupWindow::EndCascading()
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir 	m_bCascading = sal_False;
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir //--------------------------------------------------------------------
1454cdf0e10cSrcweir 
Clone() const1455cdf0e10cSrcweir SfxPopupWindow* SfxPopupWindow::Clone() const
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir /*  [Beschreibung]
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir 	Diese Methode mu\s "uberladen werden, um dieses Popup auch im
1460cdf0e10cSrcweir 	Presentations-Modus anzuzeigen. Sie wird gerufen, wenn ein Show()
1461cdf0e10cSrcweir 	sinnlos w"are, da der Parent nicht das Presentations-Window ist.
1462cdf0e10cSrcweir 	Beim neu erzeugen wird automatisch das neue Top-Window verwendet, so
1463cdf0e10cSrcweir 	da\s der Parent das Presentations-Window ist und das neue Popup somit
1464cdf0e10cSrcweir 	sichtbar ist.
1465cdf0e10cSrcweir */
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir 	return 0;
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir //--------------------------------------------------------------------
1472cdf0e10cSrcweir 
StateChanged(sal_uInt16,SfxItemState eState,const SfxPoolItem *)1473cdf0e10cSrcweir void SfxPopupWindow::StateChanged(
1474cdf0e10cSrcweir     sal_uInt16 /*nSID*/,
1475cdf0e10cSrcweir     SfxItemState eState,
1476cdf0e10cSrcweir 	const SfxPoolItem* /*pState*/ )
1477cdf0e10cSrcweir /*  [Bescheibung]
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir 	Siehe auch <SfxControllerItem::StateChanged()>. Au\serdem wird
1480cdf0e10cSrcweir 	bei eState==SFX_ITEM_DISABLED das Popup gehided und in allen anderen
1481cdf0e10cSrcweir 	F"allen, falls es floating ist, wieder angezeigt. Daher mu\s die
1482cdf0e10cSrcweir 	Basisklasse i.d.R. gerufen werden.
1483cdf0e10cSrcweir 
1484cdf0e10cSrcweir 	Es findet wegen des Parents eine Sonderbehandlung f"ur den
1485cdf0e10cSrcweir 	Presentationsmodus statt.
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir */
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir 	if ( SFX_ITEM_DISABLED == eState )
1491cdf0e10cSrcweir 	{
1492cdf0e10cSrcweir 		Hide();
1493cdf0e10cSrcweir 	}
1494cdf0e10cSrcweir 	else if ( m_bFloating )
1495cdf0e10cSrcweir 	{
1496cdf0e10cSrcweir 		Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1497cdf0e10cSrcweir 	}
1498cdf0e10cSrcweir }
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir //--------------------------------------------------------------------
1501cdf0e10cSrcweir 
IMPL_LINK(SfxPopupWindow,Delete,void *,EMPTYARG)1502cdf0e10cSrcweir IMPL_LINK( SfxPopupWindow, Delete, void *, EMPTYARG )
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir 	if ( m_aDeleteLink.IsSet() )
1505cdf0e10cSrcweir 		m_aDeleteLink.Call( this );
1506cdf0e10cSrcweir 	delete this;
1507cdf0e10cSrcweir 	return 0;
1508cdf0e10cSrcweir }
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir //--------------------------------------------------------------------
1511cdf0e10cSrcweir 
1512