20#ifndef INCLUDED_DBACCESS_GENERICCONTROLLER_HXX
21#define INCLUDED_DBACCESS_GENERICCONTROLLER_HXX
34#include <com/sun/star/awt/XUserInputInterception.hpp>
35#include <com/sun/star/frame/CommandGroup.hpp>
36#include <com/sun/star/frame/DispatchInformation.hpp>
37#include <com/sun/star/frame/XController2.hpp>
38#include <com/sun/star/frame/XDispatch.hpp>
39#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
40#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
41#include <com/sun/star/frame/XLayoutManager.hpp>
42#include <com/sun/star/frame/XTitle.hpp>
43#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
44#include <com/sun/star/lang/EventObject.hpp>
45#include <com/sun/star/lang/XInitialization.hpp>
46#include <com/sun/star/lang/XServiceInfo.hpp>
47#include <com/sun/star/uno/Any.hxx>
48#include <com/sun/star/uno/Reference.hxx>
49#include <com/sun/star/uno/Sequence.hxx>
50#include <com/sun/star/util/URL.hpp>
51#include <com/sun/star/util/XModifyListener.hpp>
61#include <osl/mutex.hxx>
62#include <rtl/ustring.hxx>
69 namespace awt {
class XKeyHandler; }
70 namespace awt {
class XMouseClickHandler; }
71 namespace awt {
class XWindow; }
72 namespace beans {
struct PropertyValue; }
73 namespace frame {
class XController; }
75 namespace frame {
class XFrame; }
76 namespace frame {
class XFrameActionListener; }
77 namespace frame {
class XModel; }
78 namespace frame {
class XStatusListener; }
79 namespace frame {
class XTitleChangeListener; }
80 namespace frame {
struct DispatchDescriptor; }
81 namespace frame {
struct FrameActionEvent; }
82 namespace lang {
class XEventListener; }
83 namespace sdb {
class XDatabaseContext; }
84 namespace sdbc {
class XConnection; }
85 namespace sdbc {
class XDataSource; }
86 namespace ui {
class XSidebarProvider; }
87 namespace uno {
class XComponentContext; }
88 namespace util {
class XURLTransformer; }
99 template<
typename T >
100 inline bool SAL_CALL
operator >>= (
const css::uno::Any& _any, std::optional< T >& _value)
105 if ( _any >>= directValue )
106 _value = directValue;
142 typedef ::std::map < OUString
144 , ::std::less< OUString >
155 bool operator()(
const SupportedFeatures::value_type& _aType )
const
157 return m_nId == _aType.second.nFeatureId;
164 css::uno::Reference< css::frame::XStatusListener >
173 const css::uno::Reference< css::frame::XStatusListener >&
m_xListener;
188 typedef ::cppu::WeakComponentImplHelper< css::frame::XDispatch
189 , css::frame::XDispatchProviderInterceptor
190 , css::util::XModifyListener
191 , css::frame::XFrameActionListener
192 , css::lang::XInitialization
193 , css::lang::XServiceInfo
194 , css::frame::XDispatchInformationProvider
195 , css::frame::XController2
197 , css::frame::XTitleChangeBroadcaster
198 , css::awt::XUserInputInterception
201 struct OGenericUnoController_Data;
225 css::uno::Reference< css::frame::XStatusListener >
xListener;
227 DispatchTarget(css::util::URL _aURL, css::uno::Reference< css::frame::XStatusListener > xRef) :
aURL(
std::move(_aURL)), xListener(
std::move(xRef)) { }
233 ::std::deque< FeatureListener >
243 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
265 const ::comphelper::NamedValueCollection&
272 virtual void loadMenu(
const css::uno::Reference< css::frame::XFrame >& _xFrame);
279 virtual void onLoadedMenu(
const css::uno::Reference< css::frame::XLayoutManager >& _xLayoutManager);
282 virtual void describeSupportedFeatures();
287 virtual void Execute(sal_uInt16 nId ,
const css::uno::Sequence< css::beans::PropertyValue>& aArgs);
302 void implDescribeSupportedFeature(
303 const OUString& _rCommandURL,
304 sal_uInt16 _nFeatureId,
305 sal_Int16 _nCommandGroup = css::frame::CommandGroup::INTERNAL
312 bool isFeatureSupported( sal_Int32 _nId );
315 css::util::URL getURLForId(sal_Int32 _nId)
const;
321 static bool isUserDefinedFeature(
const sal_uInt16 nFeatureId );
327 bool isUserDefinedFeature(
const OUString& _rFeatureURL )
const;
330 css::uno::Reference< css::sdbc::XConnection >
connect(
331 const css::uno::Reference< css::sdbc::XDataSource>& _xDataSource
335 css::uno::Reference< css::sdbc::XConnection > connect(
336 const OUString& _rsDataSourceName,
337 const OUString& _rContextInformation,
341 void startConnectionListening(
const css::uno::Reference< css::sdbc::XConnection >& _rxConnection);
342 void stopConnectionListening(
const css::uno::Reference< css::sdbc::XConnection >& _rxConnection);
348 css::uno::Reference< css::awt::XWindow> getTopMostContainerWindow()
const;
351 virtual void impl_initialize();
355 css::uno::Reference< css::frame::XTitle > impl_getTitleHelper_throw(
bool bCreateIfNecessary =
true);
358 return css::uno::Reference< css::frame::XModel >();
361 virtual void startFrameListening(
const css::uno::Reference< css::frame::XFrame >& _rxFrame );
362 virtual void stopFrameListening(
const css::uno::Reference< css::frame::XFrame >& _rxFrame );
364 void releaseNumberForComponent();
369 void fillSupportedFeatures();
371 void InvalidateAll_Impl();
372 void InvalidateFeature_Impl();
374 void ImplInvalidateFeature( sal_Int32 _nId,
const css::uno::Reference< css::frame::XStatusListener >& _xListener,
bool _bForceBroadcast );
376 void ImplBroadcastFeatureState(
const OUString& _rFeature,
const css::uno::Reference< css::frame::XStatusListener > & xListener,
bool _bIgnoreCache);
378 void executeUserDefinedFeatures(
const css::util::URL& _rFeatureURL,
const css::uno::Sequence< css::beans::PropertyValue>& _rArgs );
385 const css::uno::Reference< css::uno::XComponentContext >&
getORB()
const {
return m_xContext; }
391 void showError(const ::dbtools::SQLExceptionInfo& _rInfo);
398 void InvalidateFeature(sal_uInt16 nId,
const css::uno::Reference< css::frame::XStatusListener > & xListener =
nullptr,
bool _bForceBroadcast =
false);
402 void InvalidateAll();
412 static css::uno::Reference< css::frame::XLayoutManager > getLayoutManager(
const css::uno::Reference< css::frame::XFrame >& _xFrame);
415 virtual void executeUnChecked(
const css::util::URL& _rCommand,
const css::uno::Sequence< css::beans::PropertyValue>& aArgs)
override;
416 virtual void executeChecked(
const css::util::URL& _rCommand,
const css::uno::Sequence< css::beans::PropertyValue>& aArgs)
override;
417 virtual void executeUnChecked(sal_uInt16 _nCommandId,
const css::uno::Sequence< css::beans::PropertyValue>& aArgs)
override;
418 virtual void executeChecked(sal_uInt16 _nCommandId,
const css::uno::Sequence< css::beans::PropertyValue>& aArgs)
override;
419 virtual bool isCommandEnabled(sal_uInt16 _nCommandId)
const override;
420 virtual bool isCommandEnabled(
const OUString& _rCompleteCommandURL)
const override;
421 virtual bool isDataSourceReadOnly()
const override;
422 virtual css::uno::Reference< css::frame::XController > getXController()
override;
423 virtual bool interceptUserInput(
const NotifyEvent& _rEvent )
override;
426 bool isCommandChecked(sal_uInt16 _nCommandId)
const;
429 virtual void SAL_CALL
disposing(
const css::lang::EventObject& Source)
override;
432 virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent)
override;
435 virtual void SAL_CALL acquire( ) noexcept override;
436 virtual
void SAL_CALL release( ) noexcept override;
439 virtual css::
uno::
Reference< css::awt::XWindow > SAL_CALL getComponentWindow() override;
440 virtual OUString SAL_CALL getViewControllerName() override;
441 virtual css::
uno::
Sequence< css::beans::PropertyValue > SAL_CALL getCreationArguments() override;
443 virtual css::
uno::
Reference< css::ui::XSidebarProvider > SAL_CALL getSidebar() override;
447 virtual
void SAL_CALL attachFrame(const css::
uno::
Reference< css::frame::XFrame > &
xFrame) override;
450 virtual css::
uno::Any SAL_CALL getViewData() override;
451 virtual
void SAL_CALL restoreViewData(const css::
uno::Any& Data) override;
452 virtual css::
uno::
Reference< css::frame::XModel > SAL_CALL getModel() override;
453 virtual css::
uno::
Reference< css::frame::XFrame > SAL_CALL getFrame() override;
456 virtual
void SAL_CALL dispatch(const css::util::URL&
aURL, const css::
uno::
Sequence< css::beans::PropertyValue>& aArgs) override;
457 virtual
void SAL_CALL addStatusListener(const css::
uno::
Reference< css::frame::XStatusListener > & aListener, const css::util::URL&
aURL) override;
458 virtual
void SAL_CALL removeStatusListener(const css::
uno::
Reference< css::frame::XStatusListener > & aListener, const css::util::URL&
aURL) override;
467 virtual css::
uno::
Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL&
aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) override;
468 virtual css::
uno::
Sequence< css::
uno::
Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::
uno::
Sequence< css::frame::DispatchDescriptor >& aDescripts) override;
471 virtual
void SAL_CALL dispose() override;
472 virtual
void SAL_CALL disposing() override;
473 virtual
void SAL_CALL addEventListener(const css::
uno::
Reference< css::lang::XEventListener > & aListener) override;
474 virtual
void SAL_CALL removeEventListener(const css::
uno::
Reference< css::lang::XEventListener > & aListener) override;
477 virtual
void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
482 virtual OUString SAL_CALL getImplementationName() override = 0;
483 virtual
sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
484 virtual css::
uno::
Sequence< OUString> SAL_CALL getSupportedServiceNames() override = 0;
487 virtual css::
uno::
Sequence< ::sal_Int16 > SAL_CALL getSupportedCommandGroups() override;
488 virtual css::
uno::
Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( ::sal_Int16 ) override;
491 virtual OUString SAL_CALL getTitle( ) override;
492 virtual
void SAL_CALL setTitle( const OUString& sTitle ) override;
495 virtual
void SAL_CALL addTitleChangeListener( const css::
uno::
Reference< css::frame::XTitleChangeListener >& xListener ) override;
496 virtual
void SAL_CALL removeTitleChangeListener( const css::
uno::
Reference< css::frame::XTitleChangeListener >& xListener ) override;
499 virtual
void SAL_CALL addKeyHandler( const css::
uno::
Reference< css::awt::XKeyHandler >& xHandler ) override;
500 virtual
void SAL_CALL removeKeyHandler( const css::
uno::
Reference< css::awt::XKeyHandler >& xHandler ) override;
501 virtual
void SAL_CALL addMouseClickHandler( const css::
uno::
Reference< css::awt::XMouseClickHandler >& xHandler ) override;
502 virtual
void SAL_CALL removeMouseClickHandler( const css::
uno::
Reference< css::awt::XMouseClickHandler >& xHandler ) override;
::osl::Mutex & getMutex() const
bool operator()(const SupportedFeatures::value_type &_aType) const
CompareFeatureById(sal_Int32 _nId)
helper class to encapsulate the frame which a controller is plugged into, doing some common actions o...
const css::uno::Reference< css::frame::XStatusListener > & m_xListener
bool operator()(const FeatureListener &lhs) const
FindFeatureListener(const css::uno::Reference< css::frame::XStatusListener > &_xListener)
handles asynchronous links which may be called in multi-threaded environments If you use an instance ...
OGenericUnoController(const css::uno::Reference< css::uno::XComponentContext > &_rM)
css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer
ControllerFrame m_aCurrentFrame
css::uno::Reference< css::frame::XTitle > m_xTitleHelper
Dispatch m_arrStatusListener
css::uno::Reference< css::sdb::XDatabaseContext > m_xDatabaseContext
::cppu::OBroadcastHelper & getBroadcastHelper()
std::mutex m_aFeatureMutex
virtual OUString getPrivateTitle() const
::std::deque< FeatureListener > m_aFeaturesToInvalidate
css::uno::Reference< css::sdbc::XConnection > connect(const css::uno::Reference< css::sdbc::XDataSource > &_xDataSource)
::sfx2::UserInputInterception m_aUserInputInterception
DECL_DLLPRIVATE_LINK(OnAsyncInvalidateAll, void *, void)
OGenericUnoController()=delete
std::vector< DispatchTarget > Dispatch
const ::comphelper::NamedValueCollection & getInitParams() const
virtual void executeChecked(sal_uInt16 _nCommandId, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
executes the given command only when it is allowed
css::uno::Reference< css::frame::XDispatchProvider > m_xSlaveDispatcher
::comphelper::NamedValueCollection m_aInitParameters
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
ODataView * getView() const
virtual void executeChecked(const css::util::URL &_rCommand, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
executes the given command only when it is allowed
VclPtr< ODataView > m_pView
virtual css::uno::Reference< css::frame::XModel > getPrivateModel() const
css::uno::Reference< css::frame::XDispatchProvider > m_xMasterDispatcher
OAsynchronousLink m_aAsyncInvalidateAll
OAsynchronousLink m_aAsyncCloseTask
std::map< sal_uInt16, FeatureState > StateCache
virtual void executeUnChecked(const css::util::URL &_rCommand, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
executes the given command without checking if it is allowed
virtual void executeUnChecked(sal_uInt16 _nCommandId, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
executes the given command without checking if it is allowed
bool m_bCurrentlyModified
bool m_bDescribingSupportedFeatures
css::uno::Reference< css::uno::XComponentContext > m_xContext
DECL_DLLPRIVATE_LINK(OnAsyncCloseTask, void *, void)
const css::uno::Reference< css::uno::XComponentContext > & getORB() const
SupportedFeatures m_aSupportedFeatures
Reference< XComponentContext > m_xContext
#define DBACCESS_DLLPUBLIC
Sequence< PropertyValue > aArguments
bool SAL_CALL operator>>=(const css::uno::Any &_any, std::optional< T > &_value)
::std::map< OUString, ControllerFeature, ::std::less< OUString > > SupportedFeatures
::comphelper::SharedMutexBase OGenericUnoController_MBASE
::cppu::WeakComponentImplHelper< css::frame::XDispatch, css::frame::XDispatchProviderInterceptor, css::util::XModifyListener, css::frame::XFrameActionListener, css::lang::XInitialization, css::lang::XServiceInfo, css::frame::XDispatchInformationProvider, css::frame::XController2, css::frame::XTitle, css::frame::XTitleChangeBroadcaster, css::awt::XUserInputInterception > OGenericUnoController_Base
css::uno::Reference< css::frame::XStatusListener > xListener
describes the state of a feature
std::optional< bool > bChecked
std::optional< OUString > sTitle
std::optional< bool > bInvisible
DispatchTarget(css::util::URL _aURL, css::uno::Reference< css::frame::XStatusListener > xRef)
css::uno::Reference< css::frame::XStatusListener > xListener
Reference< XFrame > xFrame
the frame which the component resides in. Must not be <NULL>
Reference< XModel > xModel
the model of the sub component. Might be <NULL>