xref: /AOO42X/main/framework/source/dispatch/popupmenudispatcher.cxx (revision b1c5455db1639c48e26c568e4fa7ee78ca5d60ee)
1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir //#include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //  my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <dispatch/popupmenudispatcher.hxx>
32cdf0e10cSrcweir #include <general.h>
33cdf0e10cSrcweir #include <framework/menuconfiguration.hxx>
34cdf0e10cSrcweir #include <framework/addonmenu.hxx>
35cdf0e10cSrcweir #include <services.h>
36cdf0e10cSrcweir #include <properties.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39cdf0e10cSrcweir //  interface includes
40cdf0e10cSrcweir //_________________________________________________________________________________________________________________
41cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
42cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
44cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp>
45cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
47cdf0e10cSrcweir #include <com/sun/star/beans/UnknownPropertyException.hpp>
48cdf0e10cSrcweir #include <com/sun/star/lang/WrappedTargetException.hpp>
49cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
50cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir //  includes of other projects
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <ucbhelper/content.hxx>
57cdf0e10cSrcweir #include <vos/mutex.hxx>
58cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
59cdf0e10cSrcweir #include <vcl/svapp.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //_________________________________________________________________________________________________________________
62cdf0e10cSrcweir //  namespace
63cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64cdf0e10cSrcweir 
65cdf0e10cSrcweir namespace framework{
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace ::com::sun::star                ;
68cdf0e10cSrcweir using namespace ::com::sun::star::awt           ;
69cdf0e10cSrcweir using namespace ::com::sun::star::beans         ;
70cdf0e10cSrcweir using namespace ::com::sun::star::container     ;
71cdf0e10cSrcweir using namespace ::com::sun::star::frame         ;
72cdf0e10cSrcweir using namespace ::com::sun::star::lang          ;
73cdf0e10cSrcweir using namespace ::com::sun::star::uno           ;
74cdf0e10cSrcweir using namespace ::com::sun::star::util          ;
75cdf0e10cSrcweir using namespace ::cppu                          ;
76cdf0e10cSrcweir using namespace ::osl                           ;
77cdf0e10cSrcweir using namespace ::rtl                           ;
78cdf0e10cSrcweir using namespace ::vos                           ;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //_________________________________________________________________________________________________________________
81cdf0e10cSrcweir //  non exported const
82cdf0e10cSrcweir //_________________________________________________________________________________________________________________
83cdf0e10cSrcweir const char*     PROTOCOL_VALUE      = "vnd.sun.star.popup:";
84cdf0e10cSrcweir const sal_Int32 PROTOCOL_LENGTH     = 19;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //_________________________________________________________________________________________________________________
87cdf0e10cSrcweir //  non exported definitions
88cdf0e10cSrcweir //_________________________________________________________________________________________________________________
89cdf0e10cSrcweir 
90cdf0e10cSrcweir //_________________________________________________________________________________________________________________
91cdf0e10cSrcweir //  declarations
92cdf0e10cSrcweir //_________________________________________________________________________________________________________________
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //*****************************************************************************************************************
95cdf0e10cSrcweir //  constructor
96cdf0e10cSrcweir //*****************************************************************************************************************
PopupMenuDispatcher(const uno::Reference<XMultiServiceFactory> & xFactory)97cdf0e10cSrcweir PopupMenuDispatcher::PopupMenuDispatcher(
98cdf0e10cSrcweir     const uno::Reference< XMultiServiceFactory >& xFactory )
99cdf0e10cSrcweir         //  Init baseclasses first
100cdf0e10cSrcweir         :   ThreadHelpBase          ( &Application::GetSolarMutex()  )
101cdf0e10cSrcweir         ,   OWeakObject             (                                )
102cdf0e10cSrcweir         // Init member
103cdf0e10cSrcweir         ,   m_xFactory              ( xFactory                       )
104cdf0e10cSrcweir         ,   m_aListenerContainer    ( m_aLock.getShareableOslMutex() )
105cdf0e10cSrcweir         ,   m_bAlreadyDisposed      ( sal_False                      )
106cdf0e10cSrcweir         ,   m_bActivateListener     ( sal_False                      )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //*****************************************************************************************************************
111cdf0e10cSrcweir //  destructor
112cdf0e10cSrcweir //*****************************************************************************************************************
~PopupMenuDispatcher()113cdf0e10cSrcweir PopupMenuDispatcher::~PopupMenuDispatcher()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     // Warn programmer if he forgot to dispose this instance.
116cdf0e10cSrcweir     // We must release all our references ...
117cdf0e10cSrcweir     // and a dtor isn't the best place to do that!
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //*****************************************************************************************************************
121cdf0e10cSrcweir //  XInterface, XTypeProvider
122cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XINTERFACE_7(PopupMenuDispatcher,::cppu::OWeakObject,DIRECT_INTERFACE (XTypeProvider),DIRECT_INTERFACE (XServiceInfo),DIRECT_INTERFACE (XDispatchProvider),DIRECT_INTERFACE (XDispatch),DIRECT_INTERFACE (XEventListener),DIRECT_INTERFACE (XInitialization),DERIVED_INTERFACE (XFrameActionListener,XEventListener))123cdf0e10cSrcweir DEFINE_XINTERFACE_7     ( PopupMenuDispatcher                                     ,
124cdf0e10cSrcweir                           ::cppu::OWeakObject                                     ,
125cdf0e10cSrcweir                           DIRECT_INTERFACE( XTypeProvider                         ),
126cdf0e10cSrcweir                           DIRECT_INTERFACE( XServiceInfo                          ),
127cdf0e10cSrcweir                           DIRECT_INTERFACE( XDispatchProvider                     ),
128cdf0e10cSrcweir                           DIRECT_INTERFACE( XDispatch                             ),
129cdf0e10cSrcweir                           DIRECT_INTERFACE( XEventListener                        ),
130cdf0e10cSrcweir                           DIRECT_INTERFACE( XInitialization                       ),
131cdf0e10cSrcweir                           DERIVED_INTERFACE( XFrameActionListener, XEventListener )
132cdf0e10cSrcweir                         )
133cdf0e10cSrcweir 
134cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_7  (   PopupMenuDispatcher ,
135cdf0e10cSrcweir                             XTypeProvider       ,
136cdf0e10cSrcweir                             XServiceInfo        ,
137cdf0e10cSrcweir                             XDispatchProvider   ,
138cdf0e10cSrcweir                             XDispatch           ,
139cdf0e10cSrcweir                             XEventListener      ,
140cdf0e10cSrcweir                             XInitialization     ,
141cdf0e10cSrcweir                             XFrameActionListener
142cdf0e10cSrcweir                         )
143cdf0e10cSrcweir 
144cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE( PopupMenuDispatcher                    ,
145cdf0e10cSrcweir                                   ::cppu::OWeakObject                    ,
146cdf0e10cSrcweir                                   SERVICENAME_PROTOCOLHANDLER            ,
147cdf0e10cSrcweir                                   IMPLEMENTATIONNAME_POPUPMENUDISPATCHER )
148cdf0e10cSrcweir 
149cdf0e10cSrcweir DEFINE_INIT_SERVICE(PopupMenuDispatcher,
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     /*Attention
152cdf0e10cSrcweir     I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
153cdf0e10cSrcweir     to create a new instance of this class by our own supported service factory.
154cdf0e10cSrcweir     see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
155cdf0e10cSrcweir     */
156cdf0e10cSrcweir }
157cdf0e10cSrcweir )
158cdf0e10cSrcweir 
159cdf0e10cSrcweir //*****************************************************************************************************************
160cdf0e10cSrcweir //  XInitialization
161cdf0e10cSrcweir //*****************************************************************************************************************
162cdf0e10cSrcweir void SAL_CALL PopupMenuDispatcher::initialize(
163cdf0e10cSrcweir     const css::uno::Sequence< css::uno::Any >& lArguments )
164cdf0e10cSrcweir throw( css::uno::Exception, css::uno::RuntimeException)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xFrame;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     /* SAFE { */
169cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     for (int a=0; a<lArguments.getLength(); ++a)
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         if (a==0)
174cdf0e10cSrcweir         {
175cdf0e10cSrcweir             lArguments[a] >>= xFrame;
176cdf0e10cSrcweir             m_xWeakFrame = xFrame;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir             m_bActivateListener = sal_True;
179cdf0e10cSrcweir             uno::Reference< css::frame::XFrameActionListener > xFrameActionListener(
180cdf0e10cSrcweir                 (OWeakObject *)this, css::uno::UNO_QUERY );
181cdf0e10cSrcweir             xFrame->addFrameActionListener( xFrameActionListener );
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     aWriteLock.unlock();
186cdf0e10cSrcweir     /* } SAFE */
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir //*****************************************************************************************************************
190cdf0e10cSrcweir //  XDispatchProvider
191cdf0e10cSrcweir //*****************************************************************************************************************
192cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch >
queryDispatch(const css::util::URL & rURL,const::rtl::OUString & sTarget,sal_Int32 nFlags)193cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::queryDispatch(
194cdf0e10cSrcweir     const css::util::URL&  rURL    ,
195cdf0e10cSrcweir     const ::rtl::OUString& sTarget ,
196cdf0e10cSrcweir     sal_Int32              nFlags  )
197cdf0e10cSrcweir throw( css::uno::RuntimeException )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatch > xDispatch;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     if ( rURL.Complete.compareToAscii( PROTOCOL_VALUE, PROTOCOL_LENGTH ) == 0 )
202cdf0e10cSrcweir     {
203cdf0e10cSrcweir         // --- SAFE ---
204cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
205cdf0e10cSrcweir         impl_RetrievePopupControllerQuery();
206cdf0e10cSrcweir         impl_CreateUriRefFactory();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xPopupCtrlQuery( m_xPopupCtrlQuery );
209cdf0e10cSrcweir         css::uno::Reference< css::uri::XUriReferenceFactory > xUriRefFactory( m_xUriRefFactory );
210cdf0e10cSrcweir         aGuard.unlock();
211cdf0e10cSrcweir         // --- SAFE ---
212cdf0e10cSrcweir 
213cdf0e10cSrcweir         if ( xPopupCtrlQuery.is() )
214cdf0e10cSrcweir         {
215cdf0e10cSrcweir             try
216cdf0e10cSrcweir             {
217cdf0e10cSrcweir                 // Just use the main part of the URL for popup menu controllers
218cdf0e10cSrcweir                 sal_Int32     nQueryPart( 0 );
219cdf0e10cSrcweir                 sal_Int32     nSchemePart( 0 );
220cdf0e10cSrcweir                 rtl::OUString aBaseURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.popup:" ));
221cdf0e10cSrcweir                 rtl::OUString aURL( rURL.Complete );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir                 nSchemePart = aURL.indexOf( ':' );
224cdf0e10cSrcweir                 if (( nSchemePart > 0 ) &&
225cdf0e10cSrcweir                     ( aURL.getLength() > ( nSchemePart+1 )))
226cdf0e10cSrcweir                 {
227cdf0e10cSrcweir                     nQueryPart  = aURL.indexOf( '?', nSchemePart );
228cdf0e10cSrcweir                     if ( nQueryPart > 0 )
229cdf0e10cSrcweir                         aBaseURL += aURL.copy( nSchemePart+1, nQueryPart-(nSchemePart+1) );
230cdf0e10cSrcweir                     else if ( nQueryPart == -1 )
231cdf0e10cSrcweir                         aBaseURL += aURL.copy( nSchemePart+1 );
232cdf0e10cSrcweir                 }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir                 css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir                 // Find popup menu controller using the base URL
237cdf0e10cSrcweir                 xPopupCtrlQuery->getByName( aBaseURL ) >>= xDispatchProvider;
238cdf0e10cSrcweir                 aGuard.unlock();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir                 // Ask popup menu dispatch provider for dispatch object
241cdf0e10cSrcweir                 if ( xDispatchProvider.is() )
242cdf0e10cSrcweir                     xDispatch = xDispatchProvider->queryDispatch( rURL, sTarget, nFlags );
243cdf0e10cSrcweir             }
244cdf0e10cSrcweir             catch ( RuntimeException& )
245cdf0e10cSrcweir             {
246cdf0e10cSrcweir                 throw;
247cdf0e10cSrcweir             }
248cdf0e10cSrcweir             catch ( Exception& )
249cdf0e10cSrcweir             {
250cdf0e10cSrcweir             }
251cdf0e10cSrcweir         }
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir     return xDispatch;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL
queryDispatches(const css::uno::Sequence<css::frame::DispatchDescriptor> & lDescriptor)257cdf0e10cSrcweir PopupMenuDispatcher::queryDispatches(
258cdf0e10cSrcweir     const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor )
259cdf0e10cSrcweir throw( css::uno::RuntimeException )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     sal_Int32 nCount = lDescriptor.getLength();
262cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount );
263cdf0e10cSrcweir     for( sal_Int32 i=0; i<nCount; ++i )
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir         lDispatcher[i] = this->queryDispatch(
266cdf0e10cSrcweir                             lDescriptor[i].FeatureURL,
267cdf0e10cSrcweir                             lDescriptor[i].FrameName,
268cdf0e10cSrcweir                             lDescriptor[i].SearchFlags);
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir     return lDispatcher;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir //*****************************************************************************************************************
274cdf0e10cSrcweir //  XDispatch
275cdf0e10cSrcweir //*****************************************************************************************************************
276cdf0e10cSrcweir void
dispatch(const URL &,const Sequence<PropertyValue> &)277cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::dispatch(
278cdf0e10cSrcweir     const URL&                        /*aURL*/            ,
279cdf0e10cSrcweir     const Sequence< PropertyValue >&  /*seqProperties*/ )
280cdf0e10cSrcweir throw( RuntimeException )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir //*****************************************************************************************************************
285cdf0e10cSrcweir //  XDispatch
286cdf0e10cSrcweir //*****************************************************************************************************************
287cdf0e10cSrcweir void
addStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)288cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::addStatusListener(
289cdf0e10cSrcweir     const uno::Reference< XStatusListener >& xControl,
290cdf0e10cSrcweir     const URL&                          aURL    )
291cdf0e10cSrcweir throw( RuntimeException )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     // Ready for multithreading
294cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
295cdf0e10cSrcweir     // Safe impossible cases
296cdf0e10cSrcweir     // Add listener to container.
297cdf0e10cSrcweir     m_aListenerContainer.addInterface( aURL.Complete, xControl );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir //*****************************************************************************************************************
301cdf0e10cSrcweir //  XDispatch
302cdf0e10cSrcweir //*****************************************************************************************************************
303cdf0e10cSrcweir void
removeStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)304cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::removeStatusListener(
305cdf0e10cSrcweir     const uno::Reference< XStatusListener >& xControl,
306cdf0e10cSrcweir     const URL&                          aURL    )
307cdf0e10cSrcweir throw( RuntimeException )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     // Ready for multithreading
310cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
311cdf0e10cSrcweir     // Safe impossible cases
312cdf0e10cSrcweir     // Add listener to container.
313cdf0e10cSrcweir     m_aListenerContainer.removeInterface( aURL.Complete, xControl );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //*****************************************************************************************************************
317cdf0e10cSrcweir //   XFrameActionListener
318cdf0e10cSrcweir //*****************************************************************************************************************
319cdf0e10cSrcweir 
320cdf0e10cSrcweir void
frameAction(const FrameActionEvent & aEvent)321cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::frameAction(
322cdf0e10cSrcweir     const FrameActionEvent& aEvent )
323cdf0e10cSrcweir throw ( RuntimeException )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     if (( aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING ) ||
328cdf0e10cSrcweir         ( aEvent.Action == css::frame::FrameAction_COMPONENT_ATTACHED  ))
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         // Reset query reference to requery it again next time
331cdf0e10cSrcweir         m_xPopupCtrlQuery.clear();
332cdf0e10cSrcweir     }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir //*****************************************************************************************************************
336cdf0e10cSrcweir //   XEventListener
337cdf0e10cSrcweir //*****************************************************************************************************************
338cdf0e10cSrcweir void
disposing(const EventObject &)339cdf0e10cSrcweir SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) throw( RuntimeException )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir     // Ready for multithreading
342cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
343cdf0e10cSrcweir     // Safe impossible cases
344cdf0e10cSrcweir     LOG_ASSERT( !(m_bAlreadyDisposed==sal_True), "MenuDispatcher::disposing()\nObject already disposed .. don't call it again!\n" )
345cdf0e10cSrcweir 
346cdf0e10cSrcweir     if( m_bAlreadyDisposed == sal_False )
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         m_bAlreadyDisposed = sal_True;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir         if ( m_bActivateListener )
351cdf0e10cSrcweir         {
352cdf0e10cSrcweir             uno::Reference< XFrame > xFrame( m_xWeakFrame.get(), UNO_QUERY );
353cdf0e10cSrcweir             if ( xFrame.is() )
354cdf0e10cSrcweir             {
355cdf0e10cSrcweir                 xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( (OWeakObject *)this, UNO_QUERY ));
356cdf0e10cSrcweir                 m_bActivateListener = sal_False;
357cdf0e10cSrcweir             }
358cdf0e10cSrcweir         }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         // Forget our factory.
361cdf0e10cSrcweir         m_xFactory = uno::Reference< XMultiServiceFactory >();
362cdf0e10cSrcweir     }
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
impl_RetrievePopupControllerQuery()365cdf0e10cSrcweir void PopupMenuDispatcher::impl_RetrievePopupControllerQuery()
366cdf0e10cSrcweir {
367cdf0e10cSrcweir     if ( !m_xPopupCtrlQuery.is() )
368cdf0e10cSrcweir     {
369cdf0e10cSrcweir         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
370cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame > xFrame( m_xWeakFrame );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir         if ( xFrame.is() )
373cdf0e10cSrcweir         {
374cdf0e10cSrcweir             css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
375cdf0e10cSrcweir             if ( xPropSet.is() )
376cdf0e10cSrcweir             {
377cdf0e10cSrcweir                 try
378cdf0e10cSrcweir                 {
379cdf0e10cSrcweir                     xPropSet->getPropertyValue( FRAME_PROPNAME_LAYOUTMANAGER ) >>= xLayoutManager;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir                     if ( xLayoutManager.is() )
382cdf0e10cSrcweir                     {
383cdf0e10cSrcweir                         css::uno::Reference< css::ui::XUIElement > xMenuBar;
384cdf0e10cSrcweir                         rtl::OUString aMenuBar( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
385cdf0e10cSrcweir                         xMenuBar = xLayoutManager->getElement( aMenuBar );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir                         m_xPopupCtrlQuery = css::uno::Reference< css::container::XNameAccess >(
388cdf0e10cSrcweir                                                 xMenuBar, css::uno::UNO_QUERY );
389cdf0e10cSrcweir                     }
390cdf0e10cSrcweir                 }
391cdf0e10cSrcweir                 catch ( css::uno::RuntimeException& )
392cdf0e10cSrcweir                 {
393cdf0e10cSrcweir                     throw;
394cdf0e10cSrcweir                 }
395cdf0e10cSrcweir                 catch ( css::uno::Exception& )
396cdf0e10cSrcweir                 {
397cdf0e10cSrcweir                 }
398cdf0e10cSrcweir             }
399cdf0e10cSrcweir         }
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
impl_CreateUriRefFactory()403cdf0e10cSrcweir void PopupMenuDispatcher::impl_CreateUriRefFactory()
404cdf0e10cSrcweir {
405cdf0e10cSrcweir     if ( !m_xUriRefFactory.is() )
406cdf0e10cSrcweir     {
407cdf0e10cSrcweir         rtl::OUString aUriRefFactoryService(
408cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ));
409cdf0e10cSrcweir 
410cdf0e10cSrcweir         m_xUriRefFactory = css::uno::Reference< css::uri::XUriReferenceFactory >(
411cdf0e10cSrcweir                                 m_xFactory->createInstance( aUriRefFactoryService ),
412cdf0e10cSrcweir                                 css::uno::UNO_QUERY);
413cdf0e10cSrcweir 
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir }       //  namespace framework
418