LibreOffice Module svx (master) 1
fmvwimp.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_FMVWIMP_HXX
20#define INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
21
22#include <sal/config.h>
23
24#include <map>
25#include <memory>
26#include <set>
27#include <string_view>
28
29#include <svx/svdmark.hxx>
30#include <svx/svdobj.hxx>
32
33#include <com/sun/star/form/XForm.hpp>
34#include <com/sun/star/container/XIndexAccess.hpp>
35#include <com/sun/star/form/runtime/XFormController.hpp>
36#include <com/sun/star/form/runtime/XFormControllerContext.hpp>
37#include <com/sun/star/container/XContainerListener.hpp>
38#include <com/sun/star/container/ContainerEvent.hpp>
39#include <com/sun/star/awt/XFocusListener.hpp>
40#include <com/sun/star/sdb/SQLErrorEvent.hpp>
41#include <com/sun/star/sdbc/XDataSource.hpp>
42#include <com/sun/star/uno/XComponentContext.hpp>
43
44#include <tools/link.hxx>
46#include <rtl/ref.hxx>
47#include <vcl/vclptr.hxx>
48
49class SdrPageWindow;
50
51class SdrObject;
52class FmFormObj;
53class FmFormModel;
54class FmFormView;
55class FmFormShell;
56namespace vcl { class Window; }
57class OutputDevice;
58class SdrUnoObj;
59struct ImplSVEvent;
60enum class SdrInventor : sal_uInt32;
61
62namespace com::sun::star {
63 namespace awt {
64 class XControl;
65 class XWindow;
66 }
67 namespace beans {
68 class XPropertySet;
69 }
70 namespace util {
71 class XNumberFormats;
72 }
73}
74
75class FmXFormView;
76
77namespace svx {
78 class ODataAccessDescriptor;
79 struct OXFormsDescriptor;
80}
81
82
83// FormViewPageWindowAdapter
84
85typedef ::cppu::WeakImplHelper < css::container::XIndexAccess
86 , css::form::runtime::XFormControllerContext
88
90{
91 friend class FmXFormView;
92
93 ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList;
94 css::uno::Reference< css::awt::XControlContainer > m_xControlContainer;
95 css::uno::Reference<css::uno::XComponentContext> m_xContext;
98
99public:
100 FormViewPageWindowAdapter( css::uno::Reference<css::uno::XComponentContext> _xContext,
101 const SdrPageWindow&, FmXFormView* pView);
102 //const SdrPageViewWinRec*, FmXFormView* pView);
103
104 // XElementAccess
105 virtual css::uno::Type SAL_CALL getElementType() override;
106 virtual sal_Bool SAL_CALL hasElements() override;
107
108 // XIndexAccess
109 virtual sal_Int32 SAL_CALL getCount() override;
110 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override;
111
112 // XFormControllerContext
113 virtual void SAL_CALL makeVisible( const css::uno::Reference< css::awt::XControl >& Control ) override;
114
115 const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > >& GetList() const {return m_aControllerList;}
116
117private:
118 virtual ~FormViewPageWindowAdapter() override;
119
120 css::uno::Reference< css::form::runtime::XFormController > getController( const css::uno::Reference< css::form::XForm >& xForm ) const;
121 void setController(
122 const css::uno::Reference< css::form::XForm >& xForm,
123 const css::uno::Reference< css::form::runtime::XFormController >& _rxParentController );
124 const css::uno::Reference< css::awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
125 void updateTabOrder( const css::uno::Reference< css::form::XForm >& _rxForm );
126 void dispose();
127 vcl::Window* getWindow() const {return m_pWindow;}
128};
129
130class SdrModel;
131
132class FmXFormView final : public ::cppu::WeakImplHelper<
133 css::form::XFormControllerListener,
134 css::awt::XFocusListener,
135 css::container::XContainerListener>
136{
137 friend class FmFormView;
138 friend class FmFormShell;
139 friend class FmXFormShell;
143
144 css::uno::Reference< css::awt::XWindow> m_xWindow;
145 css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel;
146
147 FmFormObj* m_pMarkedGrid;
150 ImplSVEvent * m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
151 ImplSVEvent * m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
152 ImplSVEvent * m_nControlWizardEvent; // event for asynchronously setting the focus to a control
153
154 css::sdb::SQLErrorEvent
155 m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
156
157 std::vector< rtl::Reference< FormViewPageWindowAdapter > >
158 m_aPageWindowAdapters; // to be filled in alive mode only
159 typedef ::std::set< css::uno::Reference< css::form::XForm > > SetOfForms;
160 std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms >
161 m_aNeedTabOrderUpdate; // map control container to set of forms
162
163 // list of selected objects, used for restoration when switching from Alive to DesignMode
165 std::unique_ptr<ObjectRemoveListener>
167
170
171 FmFormShell* GetFormShell() const;
172
173 css::uno::Reference<css::awt::XWindow> GetParentWindow() const;
174
175 FmXFormView( FmFormView* _pView );
176 virtual ~FmXFormView() override;
177
178 void saveMarkList();
179 void restoreMarkList( SdrMarkList& _rRestoredMarkList );
182
183 void notifyViewDying( );
184 // notifies this impl class that the anti-impl instance (m_pView) is going to die
185
186public:
187 // UNO binding
188
189// css::lang::XEventListener
190 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
191
192// css::container::XContainerListener
193 virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
194 virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
195 virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
196
197// css::form::XFormControllerListener
198 virtual void SAL_CALL formActivated(const css::lang::EventObject& rEvent) override;
199 virtual void SAL_CALL formDeactivated(const css::lang::EventObject& rEvent) override;
200
201 // XFocusListener
202 virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override;
203 virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override;
204
205 FmFormView* getView() const {return m_pView;}
206 rtl::Reference< FormViewPageWindowAdapter > findWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ) const;
207
208 css::uno::Reference< css::form::runtime::XFormController >
209 getFormController( const css::uno::Reference< css::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
210
211 // activation handling
212 bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
214
215 void onFirstViewActivation( const FmFormModel* _pDocModel );
216
222
227
228 void onCreatedFormObject( FmFormObj const & _rFormObject );
229
231
232 static bool
233 isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl );
234
235private:
236 //void addWindow(const SdrPageViewWinRec*);
237 void addWindow(const SdrPageWindow&);
238 void removeWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC );
239 void Activate(bool bSync = false);
240 void Deactivate(bool bDeactivateController = true);
241
244
246 OutputDevice const & _rOutDev,
247 sal_Int32 _nXOffsetMM,
248 sal_Int32 _nYOffsetMM,
249 const css::uno::Reference< css::beans::XPropertySet >& _rxField,
250 const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
251 SdrObjKind _nControlObjectID,
252 std::u16string_view _rFieldPostfix,
253 SdrInventor _nInventor,
254 SdrObjKind _nLabelObjectID,
255
256 // tdf#118963 Need a SdrModel for SdrObject creation. To make the
257 // demand clear, hand over a SdrMldel&
258 SdrModel& _rModel,
259
261 rtl::Reference<SdrUnoObj>& _rpControl
262 );
263
265 OutputDevice const & _rOutDev,
266 sal_Int32 _nXOffsetMM,
267 sal_Int32 _nYOffsetMM,
268 const css::uno::Reference< css::beans::XPropertySet >& _rxField,
269 const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
270 SdrObjKind _nControlObjectID,
271 std::u16string_view _rFieldPostfix,
273 rtl::Reference<SdrUnoObj>& _rpControl,
274 const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource,
275 const OUString& _rDataSourceName,
276 const OUString& _rCommand,
277 const sal_Int32 _nCommandType
278 );
279
280 void ObjectRemovedInAliveMode(const SdrObject* pObject);
281
282 // asynchronously displays an error message. See also OnDelayedErrorMessage.
283 void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent& _rEvent );
284
285 // cancels all pending async events
286 void cancelEvents();
287
289 void AutoFocus();
290 DECL_LINK( OnActivate, void*, void );
291 DECL_LINK( OnAutoFocus, void*, void );
292 DECL_LINK( OnDelayedErrorMessage, void*, void );
293 DECL_LINK( OnStartControlWizard, void*, void );
294
295private:
297};
298
299
300#endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
301
302/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
void Activate(bool bSync=false)
Definition: fmvwimp.cxx:732
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:478
void setHasBeenActivated()
Definition: fmvwimp.hxx:213
css::uno::Reference< css::form::runtime::XFormController > getFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const OutputDevice &_rDevice) const
Definition: fmvwimp.cxx:875
std::vector< rtl::Reference< FormViewPageWindowAdapter > > m_aPageWindowAdapters
Definition: fmvwimp.hxx:158
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:968
bool m_isTabOrderUpdateSuspended
Definition: fmvwimp.hxx:169
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:149
FmXFormView(FmFormView *_pView)
Definition: fmvwimp.cxx:386
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:435
rtl::Reference< SdrObject > implCreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
Definition: fmvwimp.cxx:1347
css::uno::Reference< css::awt::XWindow > m_xWindow
Definition: fmvwimp.hxx:144
void suspendTabOrderUpdate()
suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of th...
Definition: fmvwimp.cxx:590
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmvwimp.cxx:448
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:749
css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel
Definition: fmvwimp.hxx:145
rtl::Reference< FormViewPageWindowAdapter > findWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC) const
Definition: fmvwimp.cxx:517
void removeWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC)
Definition: fmvwimp.cxx:549
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:155
::std::set< css::uno::Reference< css::form::XForm > > SetOfForms
Definition: fmvwimp.hxx:159
FmFormView * getView() const
Definition: fmvwimp.hxx:205
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:152
void breakCreateFormObject()
Definition: fmvwimp.cxx:1004
void AutoFocus()
the auto focus to the first (in terms of the tab order) control
Definition: fmvwimp.cxx:768
DECL_LINK(OnDelayedErrorMessage, void *, void)
DECL_LINK(OnActivate, void *, void)
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:512
SdrMarkList m_aMark
Definition: fmvwimp.hxx:164
virtual void SAL_CALL formActivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:463
std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > m_aNeedTabOrderUpdate
Definition: fmvwimp.hxx:161
FmFormObj * m_pMarkedGrid
Definition: fmvwimp.hxx:147
css::uno::Reference< css::awt::XWindow > GetParentWindow() const
Definition: fmvwimp.cxx:1014
bool m_bFirstActivation
Definition: fmvwimp.hxx:168
void notifyViewDying()
Definition: fmvwimp.cxx:427
FmFormShell * GetFormShell() const
Definition: fmvwimp.cxx:763
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1902
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1702
DECL_LINK(OnAutoFocus, void *, void)
virtual void SAL_CALL formDeactivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:470
static bool createControlLabelPair(OutputDevice const &_rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, const css::uno::Reference< css::beans::XPropertySet > &_rxField, const css::uno::Reference< css::util::XNumberFormats > &_rxNumberFormats, SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix, SdrInventor _nInventor, SdrObjKind _nLabelObjectID, SdrModel &_rModel, rtl::Reference< SdrUnoObj > &_rpLabel, rtl::Reference< SdrUnoObj > &_rpControl)
bool hasEverBeenActivated() const
Definition: fmvwimp.hxx:212
void onFirstViewActivation(const FmFormModel *_pDocModel)
Definition: fmvwimp.cxx:584
void resumeTabOrderUpdate()
resumes calls to activateTabOrder, and also does all pending calls which were collected since the las...
Definition: fmvwimp.cxx:596
void cancelEvents()
Definition: fmvwimp.cxx:399
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1807
friend class FmXFormShell
Definition: fmvwimp.hxx:139
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:150
std::unique_ptr< ObjectRemoveListener > m_pWatchStoredList
Definition: fmvwimp.hxx:166
void startMarkListWatching()
Definition: fmvwimp.cxx:1735
void saveMarkList()
Definition: fmvwimp.cxx:1753
void addWindow(const SdrPageWindow &)
Definition: fmvwimp.cxx:527
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1894
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:151
DECL_LINK(OnStartControlWizard, void *, void)
bool createControlLabelPair(OutputDevice const &_rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, const css::uno::Reference< css::beans::XPropertySet > &_rxField, const css::uno::Reference< css::util::XNumberFormats > &_rxNumberFormats, SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix, rtl::Reference< SdrUnoObj > &_rpLabel, rtl::Reference< SdrUnoObj > &_rpControl, const css::uno::Reference< css::sdbc::XDataSource > &_rxDataSource, const OUString &_rDataSourceName, const OUString &_rCommand, const sal_Int32 _nCommandType)
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:506
FmFormView * m_pView
Definition: fmvwimp.hxx:148
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
::svxform::DocumentType impl_getDocumentType() const
Definition: fmvwimp.cxx:1912
void stopMarkListWatching()
Definition: fmvwimp.cxx:1725
rtl::Reference< SdrObject > implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1115
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:777
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmvwimp.cxx:228
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fmvwimp.cxx:222
virtual ~FormViewPageWindowAdapter() override
Definition: fmvwimp.cxx:181
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
Definition: fmvwimp.cxx:352
VclPtr< vcl::Window > m_pWindow
Definition: fmvwimp.hxx:97
css::uno::Reference< css::form::runtime::XFormController > getController(const css::uno::Reference< css::form::XForm > &xForm) const
Definition: fmvwimp.cxx:281
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: fmvwimp.hxx:95
::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList
Definition: fmvwimp.hxx:93
FormViewPageWindowAdapter(css::uno::Reference< css::uno::XComponentContext > _xContext, const SdrPageWindow &, FmXFormView *pView)
Definition: fmvwimp.cxx:151
virtual void SAL_CALL makeVisible(const css::uno::Reference< css::awt::XControl > &Control) override
Definition: fmvwimp.cxx:244
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmvwimp.cxx:233
const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > & GetList() const
Definition: fmvwimp.hxx:115
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
Definition: fmvwimp.hxx:94
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmvwimp.cxx:217
void setController(const css::uno::Reference< css::form::XForm > &xForm, const css::uno::Reference< css::form::runtime::XFormController > &_rxParentController)
Definition: fmvwimp.cxx:298
vcl::Window * getWindow() const
Definition: fmvwimp.hxx:127
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:96
const css::uno::Reference< css::awt::XControlContainer > & getControlContainer() const
Definition: fmvwimp.hxx:124
Abstract DrawObject.
Definition: svdobj.hxx:260
class encapsulating the css::sdb::DataAccessDescriptor service.
::cppu::WeakImplHelper< css::container::XIndexAccess, css::form::runtime::XFormControllerContext > FormViewPageWindowAdapter_Base
Definition: fmvwimp.hxx:87
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:29
SdrInventor
Definition: svdobj.hxx:98
SdrObjKind
Definition: svdobjkind.hxx:25
unsigned char sal_Bool