bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svtools / popupmenucontrollerbase.hxx
blobaba659970ec3d90eefe045218c8d1648c8ccee9c
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 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/XInitialization.hpp>
27 #include <com/sun/star/frame/XDispatchProvider.hpp>
28 #include <com/sun/star/frame/XDispatch.hpp>
29 #include <com/sun/star/frame/XStatusListener.hpp>
30 #include <com/sun/star/frame/XPopupMenuController.hpp>
32 #include <tools/link.hxx>
33 #include <cppuhelper/compbase.hxx>
34 #include <cppuhelper/basemutex.hxx>
35 #include <rtl/ustring.hxx>
37 namespace com :: sun :: star :: frame { class XFrame; }
38 namespace com :: sun :: star :: uno { class XComponentContext; }
39 namespace com :: sun :: star :: util { class XURLTransformer; }
41 namespace svt
44 typedef cppu::WeakComponentImplHelper<
45 css::lang::XServiceInfo ,
46 css::frame::XPopupMenuController ,
47 css::lang::XInitialization ,
48 css::frame::XStatusListener ,
49 css::awt::XMenuListener ,
50 css::frame::XDispatchProvider ,
51 css::frame::XDispatch > PopupMenuControllerBaseType;
53 class SVT_DLLPUBLIC PopupMenuControllerBase : protected ::cppu::BaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses.
54 public PopupMenuControllerBaseType
56 public:
57 PopupMenuControllerBase( const css::uno::Reference< css::uno::XComponentContext >& xContext );
58 virtual ~PopupMenuControllerBase() override;
60 // XServiceInfo
61 virtual OUString SAL_CALL getImplementationName( ) override = 0;
62 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
63 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override = 0;
65 // XPopupMenuController
66 virtual void SAL_CALL setPopupMenu( const css::uno::Reference< css::awt::XPopupMenu >& PopupMenu ) override;
67 virtual void SAL_CALL updatePopupMenu() override;
69 // XInitialization
70 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
72 // XStatusListener
73 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override = 0;
75 // XMenuListener
76 virtual void SAL_CALL itemHighlighted( const css::awt::MenuEvent& rEvent ) override;
77 virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override;
78 virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override;
79 virtual void SAL_CALL itemDeactivated( const css::awt::MenuEvent& rEvent ) override;
81 // XDispatchProvider
82 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& sTarget, sal_Int32 nFlags ) override;
83 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override;
85 // XDispatch
86 virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) override;
87 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override;
88 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override;
90 // XEventListener
91 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
93 void dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs, const OUString& sTarget = OUString() );
95 protected:
96 /// @throws css::uno::RuntimeException
97 void throwIfDisposed();
99 /** helper method to cause statusChanged is called once for the given command url */
100 void updateCommand( const OUString& rCommandURL );
102 /** this function is called upon disposing the component
104 virtual void SAL_CALL disposing() override;
106 static void resetPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu );
107 virtual void impl_setPopupMenu();
108 static OUString determineBaseURL( const OUString& aURL );
110 DECL_STATIC_LINK( PopupMenuControllerBase, ExecuteHdl_Impl, void*, void );
113 bool m_bInitialized;
114 OUString m_aCommandURL;
115 OUString m_aBaseURL;
116 OUString m_aModuleName;
117 css::uno::Reference< css::frame::XDispatch > m_xDispatch;
118 css::uno::Reference< css::frame::XFrame > m_xFrame;
119 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
120 css::uno::Reference< css::awt::XPopupMenu > m_xPopupMenu;
124 #endif // INCLUDED_SVTOOLS_POPUPMENUCONTROLLERBASE_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */