1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SVTOOLS_POPUPMENUCONTROLLERBASE_HXX
21 #define INCLUDED_SVTOOLS_POPUPMENUCONTROLLERBASE_HXX
23 #include <svtools/svtdllapi.h>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/lang/XTypeProvider.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/frame/XFrame.hpp>
30 #include <com/sun/star/frame/XDispatchProvider.hpp>
31 #include <com/sun/star/frame/XDispatch.hpp>
32 #include <com/sun/star/frame/XStatusListener.hpp>
33 #include <com/sun/star/frame/XPopupMenuController.hpp>
34 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
35 #include <com/sun/star/uri/XUriReference.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/util/XURLTransformer.hpp>
39 #include <toolkit/awt/vclxmenu.hxx>
40 #include <cppuhelper/compbase7.hxx>
41 #include <comphelper/broadcasthelper.hxx>
42 #include <cppuhelper/weak.hxx>
43 #include <rtl/ustring.hxx>
47 struct PopupMenuControllerBaseDispatchInfo
;
49 typedef ::cppu::WeakComponentImplHelper7
<
50 com::sun::star::lang::XServiceInfo
,
51 com::sun::star::frame::XPopupMenuController
,
52 com::sun::star::lang::XInitialization
,
53 com::sun::star::frame::XStatusListener
,
54 com::sun::star::awt::XMenuListener
,
55 com::sun::star::frame::XDispatchProvider
,
56 com::sun::star::frame::XDispatch
> PopupMenuControllerBaseType
;
58 class SVT_DLLPUBLIC PopupMenuControllerBase
: protected ::comphelper::OBaseMutex
, // Struct for right initalization of mutex member! Must be first of baseclasses.
59 public PopupMenuControllerBaseType
62 PopupMenuControllerBase( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
63 virtual ~PopupMenuControllerBase();
66 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
67 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
70 // XPopupMenuController
71 virtual void SAL_CALL
setPopupMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPopupMenu
>& PopupMenu
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
72 virtual void SAL_CALL
updatePopupMenu() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
75 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
) throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
78 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
81 virtual void SAL_CALL
itemHighlighted( const ::com::sun::star::awt::MenuEvent
& rEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
82 virtual void SAL_CALL
itemSelected( const ::com::sun::star::awt::MenuEvent
& rEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
83 virtual void SAL_CALL
itemActivated( const ::com::sun::star::awt::MenuEvent
& rEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
84 virtual void SAL_CALL
itemDeactivated( const ::com::sun::star::awt::MenuEvent
& rEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> SAL_CALL
queryDispatch( const ::com::sun::star::util::URL
& aURL
, const OUString
& sTarget
, sal_Int32 nFlags
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> > SAL_CALL
queryDispatches( const ::com::sun::star::uno::Sequence
< ::com::sun::star::frame::DispatchDescriptor
>& lDescriptor
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& aURL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& seqProperties
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
92 virtual void SAL_CALL
addStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
, const ::com::sun::star::util::URL
& aURL
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual void SAL_CALL
removeStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
, const ::com::sun::star::util::URL
& aURL
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
96 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
& Source
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 void dispatchCommand( const OUString
& sCommandURL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArgs
);
101 void throwIfDisposed() throw ( ::com::sun::star::uno::RuntimeException
);
103 /** helper method to cause statusChanged is called once for the given command url */
104 void SAL_CALL
updateCommand( const OUString
& rCommandURL
);
106 /** this function is called upon disposing the component
108 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
110 static void resetPopupMenu( com::sun::star::uno::Reference
< com::sun::star::awt::XPopupMenu
>& rPopupMenu
);
111 virtual void impl_setPopupMenu();
112 virtual void impl_select(const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>& _xDispatch
,const ::com::sun::star::util::URL
& aURL
);
113 static OUString
determineBaseURL( const OUString
& aURL
);
115 DECL_STATIC_LINK( PopupMenuControllerBase
, ExecuteHdl_Impl
, PopupMenuControllerBaseDispatchInfo
* );
119 OUString m_aCommandURL
;
121 OUString m_aModuleName
;
122 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> m_xDispatch
;
123 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
124 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> m_xURLTransformer
;
125 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPopupMenu
> m_xPopupMenu
;
129 #endif // INCLUDED_SVTOOLS_POPUPMENUCONTROLLERBASE_HXX
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */