LibreOffice Module svx (master) 1
fmtextcontrolshell.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
20#define INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
21
22#include <com/sun/star/frame/XDispatchProvider.hpp>
23#include <com/sun/star/awt/FocusEvent.hpp>
24#include <com/sun/star/awt/XTextComponent.hpp>
25#include <com/sun/star/form/runtime/XFormController.hpp>
26#include <com/sun/star/awt/XControl.hpp>
27#include <com/sun/star/util/XURLTransformer.hpp>
28#include <rtl/ref.hxx>
29#include <tools/link.hxx>
30#include <vcl/timer.hxx>
31#include "fmslotinvalidator.hxx"
32
33#include <vector>
34#include <map>
35
36class SfxRequest;
37class SfxItemSet;
38class SfxAllItemSet;
39class SfxBindings;
40class SfxViewFrame;
41class SfxApplication;
42
43
44namespace svx
45{
46
47
48 class FmFocusListenerAdapter;
49 class FmTextControlFeature;
50 class FmMouseListenerAdapter;
51
53 {
54 public:
55 virtual void focusGained( const css::awt::FocusEvent& _rEvent ) = 0;
56 virtual void focusLost( const css::awt::FocusEvent& _rEvent ) = 0;
57
58 protected:
60 };
61
62
63 //= IFocusObserver
64
66 {
67 public:
68 virtual void contextMenuRequested() = 0;
69
70 protected:
72 };
73
76 {
77 private:
78 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
79 css::uno::Reference< css::awt::XControl > m_xActiveControl;
80 css::uno::Reference< css::awt::XTextComponent > m_xActiveTextComponent;
81 css::uno::Reference< css::form::runtime::XFormController > m_xActiveController;
82#ifndef DONT_REMEMBER_LAST_CONTROL
83 // without this define, m_xActiveControl remembers the *last* active control, even
84 // if it, in the meantime, already lost the focus
86 // so we need an additional boolean flag telling whether the active control
87 // is really focused
88#endif
91
92 // listening at all controls of the active controller for focus changes
94 typedef ::std::vector< FocusListenerAdapter > FocusListenerAdapters;
96
99
100 // translating between "slots" of the framework and "features" of the active control
102 typedef ::std::map< SfxSlotId, ControlFeature > ControlFeatures;
104
106 // invalidating slots
111
112 public:
114 virtual ~FmTextControlShell();
115
116 // clean up any resources associated with this instance
117 void dispose();
118
119 void ExecuteTextAttribute( SfxRequest& _rReq );
120 void GetTextAttributeState( SfxItemSet& _rSet );
121 bool IsActiveControl( bool _bCountRichTextOnly = false ) const;
122 void ForgetActiveControl();
124
127 void formActivated( const css::uno::Reference< css::form::runtime::XFormController >& _rxController );
130 void formDeactivated( const css::uno::Reference< css::form::runtime::XFormController >& _rxController );
131
134 void designModeChanged();
135
136 void Invalidate( SfxSlotId _nSlot );
137
138 private:
139 // IFocusObserver
140 virtual void focusGained( const css::awt::FocusEvent& _rEvent ) override;
141 virtual void focusLost( const css::awt::FocusEvent& _rEvent ) override;
142
143 // IContextRequestObserver
144 virtual void contextMenuRequested() override;
145
147 void executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq );
148 void executeSelectAll( );
149 void executeClipboardSlot( SfxSlotId _nSlot );
150
151 bool isControllerListening() const { return !m_aControlObservers.empty(); }
152
155 const css::uno::Reference< css::frame::XDispatchProvider >& _rxProvider,
156 SfxApplication const * _pApplication,
157 SfxSlotId _nSlot
158 );
159
160 // fills the given structure with dispatchers for the given slots, for the given control
162 const css::uno::Reference< css::awt::XControl >& _rxControl,
163 SfxSlotId* _pZeroTerminatedSlots,
164 ControlFeatures& _rDispatchers
165 );
166
169 ControlFeatures& _rDispatchers,
170 SfxAllItemSet& _rSet,
171 bool _bTranslateLatin
172 );
173
175 void controlActivated( const css::uno::Reference< css::awt::XControl >& _rxControl );
177 void controlDeactivated( );
178
180
185 void startControllerListening( const css::uno::Reference< css::form::runtime::XFormController >& _rxController );
191
192 DECL_LINK( OnInvalidateClipboard, Timer*, void );
193 };
194
195
196}
197
198
199#endif // INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetControlActivationHandler(const Link< LinkParamNone *, void > &_rHdl)
ControlFeatures m_aControlFeatures
void controlDeactivated()
to be called when the currently active control has been deactivated
css::uno::Reference< css::awt::XTextComponent > m_xActiveTextComponent
::std::map< SfxSlotId, ControlFeature > ControlFeatures
Link< LinkParamNone *, void > m_aControlActivationHandler
void stopControllerListening()
stops listening at the active controller @precond we have an active controller currently
void GetTextAttributeState(SfxItemSet &_rSet)
void ExecuteTextAttribute(SfxRequest &_rReq)
void Invalidate(SfxSlotId _nSlot)
static void transferFeatureStatesToItemSet(ControlFeatures &_rDispatchers, SfxAllItemSet &_rSet, bool _bTranslateLatin)
creates SfxPoolItes for all features in the given set, and puts them into the given SfxAllItemSet
css::uno::Reference< css::form::runtime::XFormController > m_xActiveController
::std::vector< FocusListenerAdapter > FocusListenerAdapters
void controlActivated(const css::uno::Reference< css::awt::XControl > &_rxControl)
to be called when a control has been activated
css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer
void designModeChanged()
notifies the instance that the design mode has changed
bool IsActiveControl(bool _bCountRichTextOnly=false) const
void formActivated(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
to be called when a form in our document has been activated
DECL_LINK(OnInvalidateClipboard, Timer *, void)
MouseListenerAdapter m_aContextMenuObserver
void startControllerListening(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
starts listening at all controls of the given controller for focus events @precond we don't have an a...
FocusListenerAdapters m_aControlObservers
FmTextControlShell(SfxViewFrame *_pFrame)
virtual void focusGained(const css::awt::FocusEvent &_rEvent) override
css::uno::Reference< css::awt::XControl > m_xActiveControl
virtual void focusLost(const css::awt::FocusEvent &_rEvent) override
rtl::Reference< FmTextControlFeature > ControlFeature
virtual void contextMenuRequested() override
void executeAttributeDialog(AttributeSet _eSet, SfxRequest &_rReq)
rtl::Reference< FmTextControlFeature > implGetFeatureDispatcher(const css::uno::Reference< css::frame::XDispatchProvider > &_rxProvider, SfxApplication const *_pApplication, SfxSlotId _nSlot)
void fillFeatureDispatchers(const css::uno::Reference< css::awt::XControl > &_rxControl, SfxSlotId *_pZeroTerminatedSlots, ControlFeatures &_rDispatchers)
void executeClipboardSlot(SfxSlotId _nSlot)
rtl::Reference< FmFocusListenerAdapter > FocusListenerAdapter
void formDeactivated(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
to be called when a form in our document has been deactivated
rtl::Reference< FmMouseListenerAdapter > MouseListenerAdapter
virtual void contextMenuRequested()=0
virtual void focusGained(const css::awt::FocusEvent &_rEvent)=0
virtual void focusLost(const css::awt::FocusEvent &_rEvent)=0
sal_uInt16 SfxSlotId