GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / uno / toolboxcontroller.cxx
blob3722c4d4111cd7d9735495fc1430b88217dc34aa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svtools/toolboxcontroller.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/frame/XDispatchProvider.hpp>
25 #include <com/sun/star/lang/DisposedException.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/frame/XLayoutManager.hpp>
28 #include <com/sun/star/util/URLTransformer.hpp>
29 #include <osl/mutex.hxx>
30 #include <vcl/svapp.hxx>
31 #include <svtools/imgdef.hxx>
32 #include <svtools/miscopt.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <vcl/toolbox.hxx>
35 #include <comphelper/processfactory.hxx>
37 const int TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE = 1;
38 const char TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE[] = "SupportsVisible";
41 using namespace ::cppu;
42 using namespace ::com::sun::star::awt;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::util;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::lang;
47 using namespace ::com::sun::star::frame;
49 namespace svt
52 ToolboxController::ToolboxController(
53 const Reference< XComponentContext >& rxContext,
54 const Reference< XFrame >& xFrame,
55 const OUString& aCommandURL ) :
56 OPropertyContainer(GetBroadcastHelper())
57 , OWeakObject()
58 , m_bSupportVisible(sal_False)
59 , m_bInitialized( sal_False )
60 , m_bDisposed( sal_False )
61 , m_nToolBoxId( SAL_MAX_UINT16 )
62 , m_xFrame(xFrame)
63 , m_xContext( rxContext )
64 , m_aCommandURL( aCommandURL )
65 , m_aListenerContainer( m_aMutex )
67 OSL_ASSERT( m_xContext.is() );
68 registerProperty( OUString(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE),
69 TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE,
70 css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
71 &m_bSupportVisible, getCppuType(&m_bSupportVisible));
73 try
75 m_xUrlTransformer = URLTransformer::create( rxContext );
77 catch(const Exception&)
82 ToolboxController::ToolboxController() :
83 OPropertyContainer(GetBroadcastHelper())
84 , OWeakObject()
85 , m_bSupportVisible(sal_False)
86 , m_bInitialized( sal_False )
87 , m_bDisposed( sal_False )
88 , m_nToolBoxId( SAL_MAX_UINT16 )
89 , m_aListenerContainer( m_aMutex )
91 registerProperty( OUString(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE),
92 TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE,
93 css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
94 &m_bSupportVisible, getCppuType(&m_bSupportVisible));
97 ToolboxController::~ToolboxController()
101 Reference< XFrame > ToolboxController::getFrameInterface() const
103 SolarMutexGuard aSolarMutexGuard;
104 return m_xFrame;
107 const Reference< XComponentContext > & ToolboxController::getContext() const
109 SolarMutexGuard aSolarMutexGuard;
110 return m_xContext;
113 Reference< XLayoutManager > ToolboxController::getLayoutManager() const
115 Reference< XLayoutManager > xLayoutManager;
116 Reference< XPropertySet > xPropSet;
118 SolarMutexGuard aSolarMutexGuard;
119 xPropSet = Reference< XPropertySet >( m_xFrame, UNO_QUERY );
122 if ( xPropSet.is() )
126 xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"),UNO_QUERY);
128 catch ( Exception& )
133 return xLayoutManager;
136 // XInterface
137 Any SAL_CALL ToolboxController::queryInterface( const Type& rType )
138 throw ( RuntimeException )
140 Any a = ::cppu::queryInterface(
141 rType ,
142 static_cast< XToolbarController* >( this ),
143 static_cast< XStatusListener* >( this ),
144 static_cast< XEventListener* >( this ),
145 static_cast< XInitialization* >( this ),
146 static_cast< XComponent* >( this ),
147 static_cast< XUpdatable* >( this ));
148 if ( !a.hasValue())
150 a = ::cppu::queryInterface(rType
151 ,static_cast<XPropertySet*>(this)
152 ,static_cast<XMultiPropertySet*>(this)
153 ,static_cast<XFastPropertySet*>(this));
154 if (!a.hasValue())
155 return OWeakObject::queryInterface( rType );
157 return a;
160 void SAL_CALL ToolboxController::acquire() throw ()
162 OWeakObject::acquire();
165 void SAL_CALL ToolboxController::release() throw ()
167 OWeakObject::release();
170 void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments )
171 throw ( Exception, RuntimeException )
173 bool bInitialized( true );
176 SolarMutexGuard aSolarMutexGuard;
178 if ( m_bDisposed )
179 throw DisposedException();
181 bInitialized = m_bInitialized;
184 if ( !bInitialized )
186 SolarMutexGuard aSolarMutexGuard;
187 m_bInitialized = sal_True;
188 //shizhoubo add
189 m_bSupportVisible = sal_False;
190 PropertyValue aPropValue;
191 for ( int i = 0; i < aArguments.getLength(); i++ )
193 if ( aArguments[i] >>= aPropValue )
195 if ( aPropValue.Name == "Frame" )
196 m_xFrame.set(aPropValue.Value,UNO_QUERY);
197 else if ( aPropValue.Name == "CommandURL" )
198 aPropValue.Value >>= m_aCommandURL;
199 else if ( aPropValue.Name == "ServiceManager" )
201 Reference<XMultiServiceFactory> xMSF(aPropValue.Value, UNO_QUERY);
202 if (xMSF.is())
203 m_xContext = comphelper::getComponentContext(xMSF);
205 else if ( aPropValue.Name == "ParentWindow" )
206 m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
207 else if ( aPropValue.Name == "ModuleIdentifier" )
208 aPropValue.Value >>= m_sModuleName;
209 else if ( aPropValue.Name == "Identifier" )
210 aPropValue.Value >>= m_nToolBoxId;
216 if ( !m_xUrlTransformer.is() && m_xContext.is() )
217 m_xUrlTransformer = URLTransformer::create( m_xContext );
219 catch(const Exception&)
223 if ( !m_aCommandURL.isEmpty() )
224 m_aListenerMap.insert( URLToDispatchMap::value_type( m_aCommandURL, Reference< XDispatch >() ));
228 void SAL_CALL ToolboxController::update()
229 throw ( RuntimeException )
232 SolarMutexGuard aSolarMutexGuard;
233 if ( m_bDisposed )
234 throw DisposedException();
237 // Bind all registered listeners to their dispatch objects
238 bindListener();
241 // XComponent
242 void SAL_CALL ToolboxController::dispose()
243 throw (::com::sun::star::uno::RuntimeException)
245 Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
248 SolarMutexGuard aSolarMutexGuard;
249 if ( m_bDisposed )
250 throw DisposedException();
253 com::sun::star::lang::EventObject aEvent( xThis );
254 m_aListenerContainer.disposeAndClear( aEvent );
256 SolarMutexGuard aSolarMutexGuard;
257 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
258 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
259 while ( pIter != m_aListenerMap.end() )
263 Reference< XDispatch > xDispatch( pIter->second );
265 com::sun::star::util::URL aTargetURL;
266 aTargetURL.Complete = pIter->first;
267 if ( m_xUrlTransformer.is() )
268 m_xUrlTransformer->parseStrict( aTargetURL );
270 if ( xDispatch.is() && xStatusListener.is() )
271 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
273 catch ( Exception& )
277 ++pIter;
280 m_bDisposed = sal_True;
283 void SAL_CALL ToolboxController::addEventListener( const Reference< XEventListener >& xListener )
284 throw ( RuntimeException )
286 m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
289 void SAL_CALL ToolboxController::removeEventListener( const Reference< XEventListener >& aListener )
290 throw ( RuntimeException )
292 m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), aListener );
295 // XEventListener
296 void SAL_CALL ToolboxController::disposing( const EventObject& Source )
297 throw ( RuntimeException )
299 Reference< XInterface > xSource( Source.Source );
301 SolarMutexGuard aSolarMutexGuard;
303 if ( m_bDisposed )
304 return;
306 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
307 while ( pIter != m_aListenerMap.end() )
309 // Compare references and release dispatch references if they are equal.
310 Reference< XInterface > xIfac( pIter->second, UNO_QUERY );
311 if ( xSource == xIfac )
312 pIter->second.clear();
313 ++pIter;
316 Reference< XInterface > xIfac( m_xFrame, UNO_QUERY );
317 if ( xIfac == xSource )
318 m_xFrame.clear();
321 // XStatusListener
322 void SAL_CALL ToolboxController::statusChanged( const FeatureStateEvent& )
323 throw ( RuntimeException )
325 // must be implemented by sub class
328 // XToolbarController
329 void SAL_CALL ToolboxController::execute( sal_Int16 KeyModifier )
330 throw (::com::sun::star::uno::RuntimeException)
332 Reference< XDispatch > xDispatch;
333 OUString aCommandURL;
336 SolarMutexGuard aSolarMutexGuard;
338 if ( m_bDisposed )
339 throw DisposedException();
341 if ( m_bInitialized &&
342 m_xFrame.is() &&
343 m_xContext.is() &&
344 !m_aCommandURL.isEmpty() )
347 aCommandURL = m_aCommandURL;
348 URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL );
349 if ( pIter != m_aListenerMap.end() )
350 xDispatch = pIter->second;
354 if ( xDispatch.is() )
358 com::sun::star::util::URL aTargetURL;
359 Sequence<PropertyValue> aArgs( 1 );
361 // Provide key modifier information to dispatch function
362 aArgs[0].Name = "KeyModifier";
363 aArgs[0].Value = makeAny( KeyModifier );
365 aTargetURL.Complete = aCommandURL;
366 if ( m_xUrlTransformer.is() )
367 m_xUrlTransformer->parseStrict( aTargetURL );
368 xDispatch->dispatch( aTargetURL, aArgs );
370 catch ( DisposedException& )
376 void SAL_CALL ToolboxController::click()
377 throw (::com::sun::star::uno::RuntimeException)
381 void SAL_CALL ToolboxController::doubleClick()
382 throw (::com::sun::star::uno::RuntimeException)
386 Reference< XWindow > SAL_CALL ToolboxController::createPopupWindow()
387 throw (::com::sun::star::uno::RuntimeException)
389 return Reference< XWindow >();
392 Reference< XWindow > SAL_CALL ToolboxController::createItemWindow( const Reference< XWindow >& )
393 throw (::com::sun::star::uno::RuntimeException)
395 return Reference< XWindow >();
398 void ToolboxController::addStatusListener( const OUString& aCommandURL )
400 Reference< XDispatch > xDispatch;
401 Reference< XStatusListener > xStatusListener;
402 com::sun::star::util::URL aTargetURL;
405 SolarMutexGuard aSolarMutexGuard;
406 URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
408 // Already in the list of status listener. Do nothing.
409 if ( pIter != m_aListenerMap.end() )
410 return;
412 // Check if we are already initialized. Implementation starts adding itself as status listener when
413 // intialize is called.
414 if ( !m_bInitialized )
416 // Put into the boost::unordered_map of status listener. Will be activated when initialized is called
417 m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, Reference< XDispatch >() ));
418 return;
420 else
422 // Add status listener directly as intialize has already been called.
423 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
424 if ( m_xContext.is() && xDispatchProvider.is() )
426 aTargetURL.Complete = aCommandURL;
427 if ( m_xUrlTransformer.is() )
428 m_xUrlTransformer->parseStrict( aTargetURL );
429 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
431 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
432 URLToDispatchMap::iterator aIter = m_aListenerMap.find( aCommandURL );
433 if ( aIter != m_aListenerMap.end() )
435 Reference< XDispatch > xOldDispatch( aIter->second );
436 aIter->second = xDispatch;
440 if ( xOldDispatch.is() )
441 xOldDispatch->removeStatusListener( xStatusListener, aTargetURL );
443 catch ( Exception& )
447 else
448 m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, xDispatch ));
453 // Call without locked mutex as we are called back from dispatch implementation
456 if ( xDispatch.is() )
457 xDispatch->addStatusListener( xStatusListener, aTargetURL );
459 catch ( Exception& )
464 void ToolboxController::removeStatusListener( const OUString& aCommandURL )
466 SolarMutexGuard aSolarMutexGuard;
468 URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
469 if ( pIter != m_aListenerMap.end() )
471 Reference< XDispatch > xDispatch( pIter->second );
472 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
473 m_aListenerMap.erase( pIter );
477 com::sun::star::util::URL aTargetURL;
478 aTargetURL.Complete = aCommandURL;
479 if ( m_xUrlTransformer.is() )
480 m_xUrlTransformer->parseStrict( aTargetURL );
482 if ( xDispatch.is() && xStatusListener.is() )
483 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
485 catch ( Exception& )
491 void ToolboxController::bindListener()
493 std::vector< Listener > aDispatchVector;
494 Reference< XStatusListener > xStatusListener;
497 SolarMutexGuard aSolarMutexGuard;
499 if ( !m_bInitialized )
500 return;
502 // Collect all registered command URL's and store them temporary
503 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
504 if ( m_xContext.is() && xDispatchProvider.is() )
506 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
507 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
508 while ( pIter != m_aListenerMap.end() )
510 com::sun::star::util::URL aTargetURL;
511 aTargetURL.Complete = pIter->first;
512 if ( m_xUrlTransformer.is() )
513 m_xUrlTransformer->parseStrict( aTargetURL );
515 Reference< XDispatch > xDispatch( pIter->second );
516 if ( xDispatch.is() )
518 // We already have a dispatch object => we have to requery.
519 // Release old dispatch object and remove it as listener
522 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
524 catch ( Exception& )
529 pIter->second.clear();
530 xDispatch.clear();
532 // Query for dispatch object. Old dispatch will be released with this, too.
535 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
537 catch ( Exception& )
540 pIter->second = xDispatch;
542 Listener aListener( aTargetURL, xDispatch );
543 aDispatchVector.push_back( aListener );
544 ++pIter;
549 // Call without locked mutex as we are called back from dispatch implementation
550 if ( xStatusListener.is() )
554 for ( sal_uInt32 i = 0; i < aDispatchVector.size(); i++ )
556 Listener& rListener = aDispatchVector[i];
557 if ( rListener.xDispatch.is() )
558 rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL );
559 else if ( rListener.aURL.Complete == m_aCommandURL )
563 // Send status changed for the main URL, if we cannot get a valid dispatch object.
564 // UI disables the button. Catch exception as we release our mutex, it is possible
565 // that someone else already disposed this instance!
566 FeatureStateEvent aFeatureStateEvent;
567 aFeatureStateEvent.IsEnabled = sal_False;
568 aFeatureStateEvent.FeatureURL = rListener.aURL;
569 aFeatureStateEvent.State = Any();
570 xStatusListener->statusChanged( aFeatureStateEvent );
572 catch ( Exception& )
578 catch ( Exception& )
584 void ToolboxController::unbindListener()
586 SolarMutexGuard aSolarMutexGuard;
588 if ( !m_bInitialized )
589 return;
591 // Collect all registered command URL's and store them temporary
592 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
593 if ( m_xContext.is() && xDispatchProvider.is() )
595 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
596 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
597 while ( pIter != m_aListenerMap.end() )
599 com::sun::star::util::URL aTargetURL;
600 aTargetURL.Complete = pIter->first;
601 if ( m_xUrlTransformer.is() )
602 m_xUrlTransformer->parseStrict( aTargetURL );
604 Reference< XDispatch > xDispatch( pIter->second );
605 if ( xDispatch.is() )
607 // We already have a dispatch object => we have to requery.
608 // Release old dispatch object and remove it as listener
611 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
613 catch ( Exception& )
617 pIter->second.clear();
618 ++pIter;
623 sal_Bool ToolboxController::isBound() const
625 SolarMutexGuard aSolarMutexGuard;
627 if ( !m_bInitialized )
628 return sal_False;
630 URLToDispatchMap::const_iterator pIter = m_aListenerMap.find( m_aCommandURL );
631 if ( pIter != m_aListenerMap.end() )
632 return ( pIter->second.is() );
634 return sal_False;
637 void ToolboxController::updateStatus()
639 bindListener();
642 void ToolboxController::updateStatus( const OUString aCommandURL )
644 Reference< XDispatch > xDispatch;
645 Reference< XStatusListener > xStatusListener;
646 com::sun::star::util::URL aTargetURL;
649 SolarMutexGuard aSolarMutexGuard;
651 if ( !m_bInitialized )
652 return;
654 // Try to find a dispatch object for the requested command URL
655 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
656 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
657 if ( m_xContext.is() && xDispatchProvider.is() )
659 aTargetURL.Complete = aCommandURL;
660 if ( m_xUrlTransformer.is() )
661 m_xUrlTransformer->parseStrict( aTargetURL );
662 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
666 if ( xDispatch.is() && xStatusListener.is() )
668 // Catch exception as we release our mutex, it is possible that someone else
669 // has already disposed this instance!
670 // Add/remove status listener to get a update status information from the
671 // requested command.
674 xDispatch->addStatusListener( xStatusListener, aTargetURL );
675 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
677 catch ( Exception& )
683 Reference< XURLTransformer > ToolboxController::getURLTransformer() const
685 return m_xUrlTransformer;
688 Reference< ::com::sun::star::awt::XWindow > ToolboxController::getParent() const
690 return m_xParentWindow;
693 void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs, const OUString &sTarget )
697 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY_THROW );
698 URL aURL;
699 aURL.Complete = sCommandURL;
700 getURLTransformer()->parseStrict( aURL );
702 Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, sTarget, 0 ), UNO_QUERY_THROW );
704 DispatchInfo *pDispatchInfo = new DispatchInfo( xDispatch, aURL, rArgs );
705 if ( !Application::PostUserEvent( STATIC_LINK(0, ToolboxController, ExecuteHdl_Impl),
706 pDispatchInfo ) )
707 delete pDispatchInfo;
710 catch( Exception& )
716 //-------------------------------------------------------------------------
717 // XPropertySet by shizhoubo
718 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL ToolboxController::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException)
720 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
721 return xInfo;
723 //-------------------------------------------------------------------------
724 ::cppu::IPropertyArrayHelper& ToolboxController::getInfoHelper()
726 return *const_cast<ToolboxController*>(this)->getArrayHelper();
728 //OPropertyArrayUsageHelper by shizhoubo
729 //------------------------------------------------------------------------------
730 ::cppu::IPropertyArrayHelper* ToolboxController::createArrayHelper( ) const
732 com::sun::star::uno::Sequence< Property > aProps;
733 describeProperties(aProps);
734 return new ::cppu::OPropertyArrayHelper(aProps);
736 //shizhoubo for supportsvisiable
737 void ToolboxController::setSupportVisibleProperty(sal_Bool bValue)
739 m_bSupportVisible = bValue;
741 //OPropertySetHelper by shizhoubo
742 sal_Bool SAL_CALL ToolboxController::convertFastPropertyValue( com::sun::star::uno::Any& aConvertedValue ,
743 com::sun::star::uno::Any& aOldValue ,
744 sal_Int32 nHandle ,
745 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException )
747 switch (nHandle)
749 case TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE:
751 sal_Bool aNewValue(sal_False);
752 aValue >>= aNewValue;
753 if (aNewValue != m_bSupportVisible)
755 aConvertedValue <<= aNewValue;
756 aOldValue <<= m_bSupportVisible;
757 return sal_True;
759 return sal_False;
762 return OPropertyContainer::convertFastPropertyValue(aConvertedValue, aOldValue, nHandle, aValue);
765 void SAL_CALL ToolboxController::setFastPropertyValue_NoBroadcast(
766 sal_Int32 nHandle,
767 const com::sun::star::uno::Any& aValue )
768 throw( com::sun::star::uno::Exception)
770 OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle, aValue);
771 if (TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE == nHandle)
773 sal_Bool rValue(sal_False);
774 if (( aValue >>= rValue ) && m_bInitialized)
775 this->setSupportVisibleProperty( rValue );
779 //--------------------------------------------------------------------
781 IMPL_STATIC_LINK_NOINSTANCE( ToolboxController, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
783 pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs );
784 delete pDispatchInfo;
785 return 0;
788 void ToolboxController::enable( bool bEnable )
790 ToolBox* pToolBox = 0;
791 sal_uInt16 nItemId = 0;
792 if( getToolboxId( nItemId, &pToolBox ) )
794 pToolBox->EnableItem( nItemId, bEnable ? sal_True : sal_False );
798 bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
800 if( (m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
801 return m_nToolBoxId;
803 ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
805 if( (m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
807 const sal_uInt16 nCount = pToolBox->GetItemCount();
808 for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
810 const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
811 if ( pToolBox->GetItemCommand( nItemId ) == m_aCommandURL )
813 m_nToolBoxId = nItemId;
814 break;
819 if( ppToolBox )
820 *ppToolBox = pToolBox;
822 rItemId = m_nToolBoxId;
824 return (rItemId != SAL_MAX_UINT16) && (( ppToolBox == 0) || (*ppToolBox != 0) );
826 //end
828 } // svt
830 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */