bump product version to 4.1.6.2
[LibreOffice.git] / include / svtools / popupmenucontrollerbase.hxx
blobdaddbed7e9fdf1690b1257285dd2ed0a0aa206d7
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 #ifndef __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_
21 #define __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/util/XURLTransformer.hpp>
38 #include <toolkit/awt/vclxmenu.hxx>
39 #include <cppuhelper/compbase7.hxx>
40 #include <comphelper/broadcasthelper.hxx>
41 #include <cppuhelper/weak.hxx>
42 #include <rtl/ustring.hxx>
44 namespace svt
46 struct PopupMenuControllerBaseDispatchInfo;
48 typedef ::cppu::WeakComponentImplHelper7<
49 com::sun::star::lang::XServiceInfo ,
50 com::sun::star::frame::XPopupMenuController ,
51 com::sun::star::lang::XInitialization ,
52 com::sun::star::frame::XStatusListener ,
53 com::sun::star::awt::XMenuListener ,
54 com::sun::star::frame::XDispatchProvider ,
55 com::sun::star::frame::XDispatch > PopupMenuControllerBaseType;
57 class SVT_DLLPUBLIC PopupMenuControllerBase : protected ::comphelper::OBaseMutex, // Struct for right initalization of mutex member! Must be first of baseclasses.
58 public PopupMenuControllerBaseType
60 public:
61 PopupMenuControllerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
62 virtual ~PopupMenuControllerBase();
64 // XServiceInfo
65 virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0;
66 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
67 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0;
69 // XPopupMenuController
70 virtual void SAL_CALL setPopupMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& PopupMenu ) throw (::com::sun::star::uno::RuntimeException);
71 virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException);
73 // XInitialization
74 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);
76 // XStatusListener
77 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0;
79 // XMenuListener
80 virtual void SAL_CALL highlight( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
81 virtual void SAL_CALL select( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
82 virtual void SAL_CALL activate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
83 virtual void SAL_CALL deactivate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
85 // XDispatchProvider
86 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 );
87 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 );
89 // XDispatch
90 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 );
91 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 );
92 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 );
94 // XEventListener
95 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
97 void dispatchCommand( const OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
99 protected:
100 void throwIfDisposed() throw ( ::com::sun::star::uno::RuntimeException );
102 /** helper method to cause statusChanged is called once for the given command url */
103 void SAL_CALL updateCommand( const OUString& rCommandURL );
105 /** this function is called upon disposing the component
107 virtual void SAL_CALL disposing();
109 virtual void resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
110 virtual void impl_setPopupMenu();
111 virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL);
112 OUString determineBaseURL( const OUString& aURL );
114 DECL_STATIC_LINK( PopupMenuControllerBase, ExecuteHdl_Impl, PopupMenuControllerBaseDispatchInfo* );
117 bool m_bInitialized;
118 OUString m_aCommandURL;
119 OUString m_aBaseURL;
120 OUString m_aModuleName;
121 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xDispatch;
122 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
123 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
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 // __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */