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 #include <dispatch/menudispatcher.hxx>
31cdf0e10cSrcweir #include <general.h>
32cdf0e10cSrcweir #include <framework/menuconfiguration.hxx>
33cdf0e10cSrcweir #include <framework/addonmenu.hxx>
34cdf0e10cSrcweir #include <services.h>
35cdf0e10cSrcweir
36cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37cdf0e10cSrcweir // interface includes
38cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
40cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp>
41cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
42cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
44cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/UnknownPropertyException.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/WrappedTargetException.hpp>
47cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
48cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
49cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <vcl/window.hxx>
52cdf0e10cSrcweir #include <vcl/syswin.hxx>
53cdf0e10cSrcweir #include <vcl/menu.hxx>
54cdf0e10cSrcweir #include <vcl/svapp.hxx>
55cdf0e10cSrcweir #include <tools/resmgr.hxx>
56cdf0e10cSrcweir #include <tools/rcid.h>
57cdf0e10cSrcweir #include <vos/mutex.hxx>
58cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
59cdf0e10cSrcweir #include <rtl/logfile.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir //_________________________________________________________________________________________________________________
62cdf0e10cSrcweir // includes of other projects
63cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64cdf0e10cSrcweir
65cdf0e10cSrcweir #include <ucbhelper/content.hxx>
66cdf0e10cSrcweir
67cdf0e10cSrcweir //_________________________________________________________________________________________________________________
68cdf0e10cSrcweir // namespace
69cdf0e10cSrcweir //_________________________________________________________________________________________________________________
70cdf0e10cSrcweir
71cdf0e10cSrcweir namespace framework{
72cdf0e10cSrcweir
73cdf0e10cSrcweir using namespace ::com::sun::star ;
74cdf0e10cSrcweir using namespace ::com::sun::star::awt ;
75cdf0e10cSrcweir using namespace ::com::sun::star::beans ;
76cdf0e10cSrcweir using namespace ::com::sun::star::container ;
77cdf0e10cSrcweir using namespace ::com::sun::star::frame ;
78cdf0e10cSrcweir using namespace ::com::sun::star::lang ;
79cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
80cdf0e10cSrcweir using namespace ::com::sun::star::util ;
81cdf0e10cSrcweir using namespace ::cppu ;
82cdf0e10cSrcweir using namespace ::osl ;
83cdf0e10cSrcweir using namespace ::rtl ;
84cdf0e10cSrcweir using namespace ::vos ;
85cdf0e10cSrcweir
86cdf0e10cSrcweir //_________________________________________________________________________________________________________________
87cdf0e10cSrcweir // non exported const
88cdf0e10cSrcweir //_________________________________________________________________________________________________________________
89cdf0e10cSrcweir
90cdf0e10cSrcweir const sal_uInt16 SLOTID_MDIWINDOWLIST = 5610;
91cdf0e10cSrcweir
92cdf0e10cSrcweir //_________________________________________________________________________________________________________________
93cdf0e10cSrcweir // non exported definitions
94cdf0e10cSrcweir //_________________________________________________________________________________________________________________
95cdf0e10cSrcweir
96cdf0e10cSrcweir //_________________________________________________________________________________________________________________
97cdf0e10cSrcweir // declarations
98cdf0e10cSrcweir //_________________________________________________________________________________________________________________
99cdf0e10cSrcweir
100cdf0e10cSrcweir //*****************************************************************************************************************
101cdf0e10cSrcweir // constructor
102cdf0e10cSrcweir //*****************************************************************************************************************
MenuDispatcher(const uno::Reference<XMultiServiceFactory> & xFactory,const uno::Reference<XFrame> & xOwner)103cdf0e10cSrcweir MenuDispatcher::MenuDispatcher( const uno::Reference< XMultiServiceFactory >& xFactory ,
104cdf0e10cSrcweir const uno::Reference< XFrame >& xOwner )
105cdf0e10cSrcweir // Init baseclasses first
106cdf0e10cSrcweir : ThreadHelpBase ( &Application::GetSolarMutex() )
107cdf0e10cSrcweir , OWeakObject ( )
108cdf0e10cSrcweir // Init member
109cdf0e10cSrcweir , m_xOwnerWeak ( xOwner )
110cdf0e10cSrcweir , m_xFactory ( xFactory )
111cdf0e10cSrcweir , m_aListenerContainer ( m_aLock.getShareableOslMutex() )
112cdf0e10cSrcweir , m_bAlreadyDisposed ( sal_False )
113cdf0e10cSrcweir , m_bActivateListener ( sal_False )
114cdf0e10cSrcweir , m_pMenuManager ( NULL )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir // Safe impossible cases
117cdf0e10cSrcweir // We need valid informations about ouer ownerfor work.
118cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_MenuDispatcher( xFactory, xOwner ), "MenuDispatcher::MenuDispatcher()\nInvalid parameter detected!\n" )
119cdf0e10cSrcweir
120cdf0e10cSrcweir m_bActivateListener = sal_True;
121cdf0e10cSrcweir xOwner->addFrameActionListener( uno::Reference< XFrameActionListener >( (OWeakObject *)this, UNO_QUERY ));
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir //*****************************************************************************************************************
125cdf0e10cSrcweir // destructor
126cdf0e10cSrcweir //*****************************************************************************************************************
~MenuDispatcher()127cdf0e10cSrcweir MenuDispatcher::~MenuDispatcher()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir // Warn programmer if he forgot to dispose this instance.
130cdf0e10cSrcweir // We must release all our references ...
131cdf0e10cSrcweir // and a dtor isn't the best place to do that!
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir //*****************************************************************************************************************
135cdf0e10cSrcweir // XInterface, XTypeProvider
136cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XINTERFACE_4(MenuDispatcher,OWeakObject,DIRECT_INTERFACE (XTypeProvider),DIRECT_INTERFACE (XDispatch),DIRECT_INTERFACE (XEventListener),DERIVED_INTERFACE (XFrameActionListener,XEventListener))137cdf0e10cSrcweir DEFINE_XINTERFACE_4 ( MenuDispatcher ,
138cdf0e10cSrcweir OWeakObject ,
139cdf0e10cSrcweir DIRECT_INTERFACE( XTypeProvider ),
140cdf0e10cSrcweir DIRECT_INTERFACE( XDispatch ),
141cdf0e10cSrcweir DIRECT_INTERFACE( XEventListener ),
142cdf0e10cSrcweir DERIVED_INTERFACE( XFrameActionListener, XEventListener )
143cdf0e10cSrcweir )
144cdf0e10cSrcweir
145cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_4 ( MenuDispatcher ,
146cdf0e10cSrcweir XTypeProvider ,
147cdf0e10cSrcweir XDispatch ,
148cdf0e10cSrcweir XEventListener ,
149cdf0e10cSrcweir XFrameActionListener
150cdf0e10cSrcweir )
151cdf0e10cSrcweir
152cdf0e10cSrcweir
153cdf0e10cSrcweir //*****************************************************************************************************************
154cdf0e10cSrcweir // XDispatch
155cdf0e10cSrcweir //*****************************************************************************************************************
156cdf0e10cSrcweir void SAL_CALL MenuDispatcher::dispatch( const URL& /*aURL*/ ,
157cdf0e10cSrcweir const Sequence< PropertyValue >& /*seqProperties*/ ) throw( RuntimeException )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir //*****************************************************************************************************************
162cdf0e10cSrcweir // XDispatch
163cdf0e10cSrcweir //*****************************************************************************************************************
addStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)164cdf0e10cSrcweir void SAL_CALL MenuDispatcher::addStatusListener( const uno::Reference< XStatusListener >& xControl,
165cdf0e10cSrcweir const URL& aURL ) throw( RuntimeException )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir // Ready for multithreading
168cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
169cdf0e10cSrcweir // Safe impossible cases
170cdf0e10cSrcweir // Method not defined for all incoming parameter
171cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_addStatusListener( xControl, aURL ), "MenuDispatcher::addStatusListener()\nInvalid parameter detected.\n" )
172cdf0e10cSrcweir // Add listener to container.
173cdf0e10cSrcweir m_aListenerContainer.addInterface( aURL.Complete, xControl );
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir //*****************************************************************************************************************
177cdf0e10cSrcweir // XDispatch
178cdf0e10cSrcweir //*****************************************************************************************************************
removeStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)179cdf0e10cSrcweir void SAL_CALL MenuDispatcher::removeStatusListener( const uno::Reference< XStatusListener >& xControl,
180cdf0e10cSrcweir const URL& aURL ) throw( RuntimeException )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir // Ready for multithreading
183cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
184cdf0e10cSrcweir // Safe impossible cases
185cdf0e10cSrcweir // Method not defined for all incoming parameter
186cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_removeStatusListener( xControl, aURL ), "MenuDispatcher::removeStatusListener()\nInvalid parameter detected.\n" )
187cdf0e10cSrcweir // Add listener to container.
188cdf0e10cSrcweir m_aListenerContainer.removeInterface( aURL.Complete, xControl );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir //*****************************************************************************************************************
192cdf0e10cSrcweir // XFrameActionListener
193cdf0e10cSrcweir //*****************************************************************************************************************
194cdf0e10cSrcweir
frameAction(const FrameActionEvent & aEvent)195cdf0e10cSrcweir void SAL_CALL MenuDispatcher::frameAction( const FrameActionEvent& aEvent ) throw ( RuntimeException )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
198cdf0e10cSrcweir
199cdf0e10cSrcweir if ( m_pMenuManager && aEvent.Action == FrameAction_FRAME_UI_ACTIVATED )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir MenuBar* pMenuBar = (MenuBar *)m_pMenuManager->GetMenu();
202cdf0e10cSrcweir uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
203cdf0e10cSrcweir aGuard.unlock();
204cdf0e10cSrcweir
205cdf0e10cSrcweir if ( xFrame.is() && pMenuBar )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir uno::Reference< ::com::sun::star::awt::XWindow >xContainerWindow = xFrame->getContainerWindow();
208cdf0e10cSrcweir
209cdf0e10cSrcweir OGuard aSolarGuard( Application::GetSolarMutex() );
210cdf0e10cSrcweir {
211cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
212cdf0e10cSrcweir while ( pWindow && !pWindow->IsSystemWindow() )
213cdf0e10cSrcweir pWindow = pWindow->GetParent();
214cdf0e10cSrcweir
215cdf0e10cSrcweir if ( pWindow )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir SystemWindow* pSysWindow = (SystemWindow *)pWindow;
218cdf0e10cSrcweir pSysWindow->SetMenuBar( pMenuBar );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir }
222cdf0e10cSrcweir }
223cdf0e10cSrcweir else if ( m_pMenuManager && aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if ( m_pMenuManager )
226cdf0e10cSrcweir impl_setMenuBar( NULL );
227cdf0e10cSrcweir }
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir //*****************************************************************************************************************
231cdf0e10cSrcweir // XEventListener
232cdf0e10cSrcweir //*****************************************************************************************************************
disposing(const EventObject &)233cdf0e10cSrcweir void SAL_CALL MenuDispatcher::disposing( const EventObject& ) throw( RuntimeException )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir // Ready for multithreading
236cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
237cdf0e10cSrcweir // Safe impossible cases
238cdf0e10cSrcweir LOG_ASSERT( !(m_bAlreadyDisposed==sal_True), "MenuDispatcher::disposing()\nObject already disposed .. don't call it again!\n" )
239cdf0e10cSrcweir
240cdf0e10cSrcweir if( m_bAlreadyDisposed == sal_False )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir m_bAlreadyDisposed = sal_True;
243cdf0e10cSrcweir
244cdf0e10cSrcweir if ( m_bActivateListener )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
247cdf0e10cSrcweir if ( xFrame.is() )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( (OWeakObject *)this, UNO_QUERY ));
250cdf0e10cSrcweir m_bActivateListener = sal_False;
251cdf0e10cSrcweir if ( m_pMenuManager )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir EventObject aEventObj;
254cdf0e10cSrcweir aEventObj.Source = xFrame;
255cdf0e10cSrcweir m_pMenuManager->disposing( aEventObj );
256cdf0e10cSrcweir }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir // Forget our factory.
261cdf0e10cSrcweir m_xFactory = uno::Reference< XMultiServiceFactory >();
262cdf0e10cSrcweir
263cdf0e10cSrcweir // Remove our menu from system window if it is still there!
264cdf0e10cSrcweir if ( m_pMenuManager )
265cdf0e10cSrcweir impl_setMenuBar( NULL );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir //*****************************************************************************************************************
270cdf0e10cSrcweir // private method
271cdf0e10cSrcweir //
272cdf0e10cSrcweir //
273cdf0e10cSrcweir //*****************************************************************************************************************
impl_setAccelerators(Menu * pMenu,const Accelerator & aAccel)274cdf0e10cSrcweir void MenuDispatcher::impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); ++nPos )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir sal_uInt16 nId = pMenu->GetItemId(nPos);
279cdf0e10cSrcweir PopupMenu* pPopup = pMenu->GetPopupMenu(nId);
280cdf0e10cSrcweir if ( pPopup )
281cdf0e10cSrcweir impl_setAccelerators( (Menu *)pPopup, aAccel );
282cdf0e10cSrcweir else if ( nId && !pMenu->GetPopupMenu(nId))
283cdf0e10cSrcweir {
284cdf0e10cSrcweir KeyCode aCode = aAccel.GetKeyCode( nId );
285cdf0e10cSrcweir if ( aCode.GetCode() )
286cdf0e10cSrcweir pMenu->SetAccelKey( nId, aCode );
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir //*****************************************************************************************************************
292cdf0e10cSrcweir // private method
293cdf0e10cSrcweir //
294cdf0e10cSrcweir //
295cdf0e10cSrcweir //*****************************************************************************************************************
impl_setMenuBar(MenuBar * pMenuBar,sal_Bool bMenuFromResource)296cdf0e10cSrcweir sal_Bool MenuDispatcher::impl_setMenuBar( MenuBar* pMenuBar, sal_Bool bMenuFromResource )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
299cdf0e10cSrcweir if ( xFrame.is() )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir uno::Reference< ::com::sun::star::awt::XWindow >xContainerWindow = xFrame->getContainerWindow();
302cdf0e10cSrcweir Window* pWindow = NULL;
303cdf0e10cSrcweir
304cdf0e10cSrcweir // Use SolarMutex for threadsafe code too!
305cdf0e10cSrcweir OGuard aSolarGuard( Application::GetSolarMutex() );
306cdf0e10cSrcweir {
307cdf0e10cSrcweir pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
308cdf0e10cSrcweir while ( pWindow && !pWindow->IsSystemWindow() )
309cdf0e10cSrcweir pWindow = pWindow->GetParent();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir if ( pWindow )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir // Ready for multithreading
315cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
316cdf0e10cSrcweir
317cdf0e10cSrcweir SystemWindow* pSysWindow = (SystemWindow *)pWindow;
318cdf0e10cSrcweir
319cdf0e10cSrcweir if ( m_pMenuManager )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir // remove old menu from our system window if it was set before
322cdf0e10cSrcweir if ( m_pMenuManager->GetMenu() == (Menu *)pSysWindow->GetMenuBar() )
323cdf0e10cSrcweir pSysWindow->SetMenuBar( NULL );
324cdf0e10cSrcweir
325cdf0e10cSrcweir // remove listener before we destruct ourself, so we cannot be called back afterwards
326cdf0e10cSrcweir m_pMenuManager->RemoveListener();
327cdf0e10cSrcweir
328cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::uno::XInterface*, (OWeakObject*)m_pMenuManager )->release();
329cdf0e10cSrcweir
330cdf0e10cSrcweir m_pMenuManager = 0;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir if ( pMenuBar != NULL )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir sal_uInt16 nPos = pMenuBar->GetItemPos( SLOTID_MDIWINDOWLIST );
336cdf0e10cSrcweir if ( nPos != MENU_ITEM_NOTFOUND )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir OUString aNoContext;
339cdf0e10cSrcweir
340cdf0e10cSrcweir uno::Reference< XModel > xModel;
341cdf0e10cSrcweir uno::Reference< XController > xController( xFrame->getController(), UNO_QUERY );
342cdf0e10cSrcweir
343cdf0e10cSrcweir if ( xController.is() )
344cdf0e10cSrcweir xModel = uno::Reference< XModel >( xController->getModel(), UNO_QUERY );
345cdf0e10cSrcweir
346cdf0e10cSrcweir // retrieve addon popup menus and add them to our menu bar
347cdf0e10cSrcweir AddonMenuManager::MergeAddonPopupMenus( xFrame, xModel, nPos, pMenuBar );
348cdf0e10cSrcweir
349cdf0e10cSrcweir // retrieve addon help menu items and add them to our help menu
350cdf0e10cSrcweir AddonMenuManager::MergeAddonHelpMenu( xFrame, pMenuBar );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir // set new menu on our system window and create new menu manager
354cdf0e10cSrcweir if ( bMenuFromResource )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir // #110897#
357cdf0e10cSrcweir // m_pMenuManager = new MenuManager( xFrame, pMenuBar, sal_True, sal_False );
358cdf0e10cSrcweir m_pMenuManager = new MenuManager( m_xFactory, xFrame, pMenuBar, sal_True, sal_False );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir else
361cdf0e10cSrcweir {
362cdf0e10cSrcweir // #110897#
363cdf0e10cSrcweir // m_pMenuManager = new MenuManager( xFrame, pMenuBar, sal_True, sal_True );
364cdf0e10cSrcweir m_pMenuManager = new MenuManager( m_xFactory, xFrame, pMenuBar, sal_True, sal_True );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
367cdf0e10cSrcweir pSysWindow->SetMenuBar( pMenuBar );
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir return sal_True;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
374cdf0e10cSrcweir return sal_False;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
IMPL_LINK(MenuDispatcher,Close_Impl,void *,EMPTYARG)377cdf0e10cSrcweir IMPL_LINK( MenuDispatcher, Close_Impl, void*, EMPTYARG )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir css::uno::Reference < css::frame::XFrame > xFrame( m_xOwnerWeak.get(), css::uno::UNO_QUERY );
380cdf0e10cSrcweir if ( !xFrame.is() )
381cdf0e10cSrcweir return 0;
382cdf0e10cSrcweir
383cdf0e10cSrcweir css::util::URL aURL;
384cdf0e10cSrcweir aURL.Complete = ::rtl::OUString::createFromAscii(".uno:CloseWin");
385cdf0e10cSrcweir css::uno::Reference< css::util::XURLTransformer > xTrans ( m_xFactory->createInstance(
386cdf0e10cSrcweir SERVICENAME_URLTRANSFORMER ), css::uno::UNO_QUERY );
387cdf0e10cSrcweir if( xTrans.is() )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir // Datei laden
390cdf0e10cSrcweir xTrans->parseStrict( aURL );
391cdf0e10cSrcweir uno::Reference< XDispatchProvider > xProv( xFrame, UNO_QUERY );
392cdf0e10cSrcweir if ( xProv.is() )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir css::uno::Reference < css::frame::XDispatch > aDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
395cdf0e10cSrcweir if ( aDisp.is() )
396cdf0e10cSrcweir aDisp->dispatch( aURL, css::uno::Sequence < css::beans::PropertyValue>() );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir
400cdf0e10cSrcweir return 0;
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir
404cdf0e10cSrcweir //_________________________________________________________________________________________________________________
405cdf0e10cSrcweir // debug methods
406cdf0e10cSrcweir //_________________________________________________________________________________________________________________
407cdf0e10cSrcweir
408cdf0e10cSrcweir /*-----------------------------------------------------------------------------------------------------------------
409cdf0e10cSrcweir The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
410cdf0e10cSrcweir we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
411cdf0e10cSrcweir
412cdf0e10cSrcweir ATTENTION
413cdf0e10cSrcweir
414cdf0e10cSrcweir If you miss a test for one of this parameters, contact the autor or add it himself !(?)
415cdf0e10cSrcweir But ... look for right testing! See using of this methods!
416cdf0e10cSrcweir -----------------------------------------------------------------------------------------------------------------*/
417cdf0e10cSrcweir
418cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS
419cdf0e10cSrcweir
420cdf0e10cSrcweir //*****************************************************************************************************************
impldbg_checkParameter_MenuDispatcher(const uno::Reference<XMultiServiceFactory> & xFactory,const uno::Reference<XFrame> & xOwner)421cdf0e10cSrcweir sal_Bool MenuDispatcher::impldbg_checkParameter_MenuDispatcher( const uno::Reference< XMultiServiceFactory >& xFactory ,
422cdf0e10cSrcweir const uno::Reference< XFrame >& xOwner )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir // Set default return value.
425cdf0e10cSrcweir sal_Bool bOK = sal_True;
426cdf0e10cSrcweir // Check parameter.
427cdf0e10cSrcweir if (
428cdf0e10cSrcweir ( &xFactory == NULL ) ||
429cdf0e10cSrcweir ( &xOwner == NULL ) ||
430cdf0e10cSrcweir ( xFactory.is() == sal_False ) ||
431cdf0e10cSrcweir ( xOwner.is() == sal_False )
432cdf0e10cSrcweir )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir bOK = sal_False ;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir // Return result of check.
437cdf0e10cSrcweir return bOK ;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir //*****************************************************************************************************************
441cdf0e10cSrcweir // We need a valid URL. What is meaning with "register for nothing"?!
442cdf0e10cSrcweir // xControl must correct to - nobody can advised otherwise!
impldbg_checkParameter_addStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)443cdf0e10cSrcweir sal_Bool MenuDispatcher::impldbg_checkParameter_addStatusListener( const uno::Reference< XStatusListener >& xControl,
444cdf0e10cSrcweir const URL& aURL )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir // Set default return value.
447cdf0e10cSrcweir sal_Bool bOK = sal_True;
448cdf0e10cSrcweir // Check parameter.
449cdf0e10cSrcweir if (
450cdf0e10cSrcweir ( &xControl == NULL ) ||
451cdf0e10cSrcweir ( &aURL == NULL ) ||
452cdf0e10cSrcweir ( aURL.Complete.getLength() < 1 )
453cdf0e10cSrcweir )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir bOK = sal_False ;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir // Return result of check.
458cdf0e10cSrcweir return bOK ;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir //*****************************************************************************************************************
462cdf0e10cSrcweir // The same goes for these case! We have added valid listener for correct URL only.
463cdf0e10cSrcweir // We can't remove invalid listener for nothing!
impldbg_checkParameter_removeStatusListener(const uno::Reference<XStatusListener> & xControl,const URL & aURL)464cdf0e10cSrcweir sal_Bool MenuDispatcher::impldbg_checkParameter_removeStatusListener( const uno::Reference< XStatusListener >& xControl,
465cdf0e10cSrcweir const URL& aURL )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir // Set default return value.
468cdf0e10cSrcweir sal_Bool bOK = sal_True;
469cdf0e10cSrcweir // Check parameter.
470cdf0e10cSrcweir if (
471cdf0e10cSrcweir ( &xControl == NULL ) ||
472cdf0e10cSrcweir ( &aURL == NULL ) ||
473cdf0e10cSrcweir ( aURL.Complete.getLength() < 1 )
474cdf0e10cSrcweir )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir bOK = sal_False ;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir // Return result of check.
479cdf0e10cSrcweir return bOK ;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
482cdf0e10cSrcweir #endif // #ifdef ENABLE_ASSERTIONS
483cdf0e10cSrcweir
484cdf0e10cSrcweir } // namespace framework
485