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>
45 #include <cppuhelper/implbase.hxx>
46 #include <rtl/ref.hxx>
47 #include <vcl/vclptr.hxx>
48 
49 class SdrPageWindow;
50 
51 class SdrObject;
52 class FmFormObj;
53 class FmFormModel;
54 class FmFormView;
55 class FmFormShell;
56 namespace vcl { class Window; }
57 class OutputDevice;
58 class SdrUnoObj;
59 struct ImplSVEvent;
60 enum class SdrInventor : sal_uInt32;
61 
62 namespace 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 
75 class FmXFormView;
76 
77 namespace svx {
78  class ODataAccessDescriptor;
79  struct OXFormsDescriptor;
80 }
81 
82 
83 // FormViewPageWindowAdapter
84 
85 typedef ::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 
99 public:
100  FormViewPageWindowAdapter( const css::uno::Reference<css::uno::XComponentContext>& _rContext,
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 
117 private:
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 
130 class SdrModel;
131 
132 class 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;
142  friend class ObjectRemoveListener;
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 );
180  void stopMarkListWatching();
181  void startMarkListWatching();
182 
183  void notifyViewDying( );
184  // notifies this impl class that the anti-impl instance (m_pView) is going to die
185 
186 public:
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; }
213  void setHasBeenActivated( ) { m_bFirstActivation = false; }
214 
215  void onFirstViewActivation( const FmFormModel* _pDocModel );
216 
221  void suspendTabOrderUpdate();
222 
226  void resumeTabOrderUpdate();
227 
228  void onCreatedFormObject( FmFormObj const & _rFormObject );
229 
230  void breakCreateFormObject();
231 
232  static bool
233  isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl );
234 
235 private:
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 
245  static bool createControlLabelPair(
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 
260  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
261  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _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,
272  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
273  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _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 
295 private:
297 };
298 
299 
300 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
301 
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
void stopMarkListWatching()
Definition: fmvwimp.cxx:1725
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:152
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
void saveMarkList()
Definition: fmvwimp.cxx:1753
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:149
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
Definition: fmvwimp.hxx:94
void removeWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC)
Definition: fmvwimp.cxx:549
::std::set< css::uno::Reference< css::form::XForm > > SetOfForms
Definition: fmvwimp.hxx:159
void cancelEvents()
Definition: fmvwimp.cxx:399
virtual ~FormViewPageWindowAdapter() override
Definition: fmvwimp.cxx:181
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::awt::XWindow > m_xWindow
Definition: fmvwimp.hxx:144
void resumeTabOrderUpdate()
resumes calls to activateTabOrder, and also does all pending calls which were collected since the las...
Definition: fmvwimp.cxx:596
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1902
void startMarkListWatching()
Definition: fmvwimp.cxx:1735
void onFirstViewActivation(const FmFormModel *_pDocModel)
Definition: fmvwimp.cxx:584
exports com.sun.star. awt
void notifyViewDying()
Definition: fmvwimp.cxx:427
::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList
Definition: fmvwimp.hxx:93
SdrInventor
Definition: svdobj.hxx:98
void setController(const css::uno::Reference< css::form::XForm > &xForm, const css::uno::Reference< css::form::runtime::XFormController > &_rxParentController)
Definition: fmvwimp.cxx:298
FmFormView * getView() const
Definition: fmvwimp.hxx:205
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1702
SdrObjKind
Definition: svdobjkind.hxx:24
SdrObjectUniquePtr implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1115
FmFormObj * m_pMarkedGrid
Definition: fmvwimp.hxx:147
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1807
DECL_LINK(OnActivate, void *, void)
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:435
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:151
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:777
virtual void SAL_CALL formActivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:463
void AutoFocus()
the auto focus to the first (in terms of the tab order) control
Definition: fmvwimp.cxx:768
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:155
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmvwimp.cxx:228
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:968
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmvwimp.cxx:233
::cppu::WeakImplHelper< css::container::XIndexAccess, css::form::runtime::XFormControllerContext > FormViewPageWindowAdapter_Base
Definition: fmvwimp.hxx:87
css::uno::Reference< css::awt::XWindow > GetParentWindow() const
Definition: fmvwimp.cxx:1014
virtual void SAL_CALL makeVisible(const css::uno::Reference< css::awt::XControl > &Control) override
Definition: fmvwimp.cxx:244
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:28
css::uno::Reference< css::form::runtime::XFormController > getFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const OutputDevice &_rDevice) const
Definition: fmvwimp.cxx:875
void suspendTabOrderUpdate()
suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of th...
Definition: fmvwimp.cxx:590
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fmvwimp.cxx:222
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmvwimp.cxx:448
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: fmvwimp.hxx:95
unsigned char sal_Bool
void addWindow(const SdrPageWindow &)
Definition: fmvwimp.cxx:527
FmFormShell * GetFormShell() const
Definition: fmvwimp.cxx:763
std::vector< rtl::Reference< FormViewPageWindowAdapter > > m_aPageWindowAdapters
Definition: fmvwimp.hxx:158
::svxform::DocumentType impl_getDocumentType() const
Definition: fmvwimp.cxx:1912
Abstract DrawObject.
Definition: svdobj.hxx:258
const css::uno::Reference< css::awt::XControlContainer > & getControlContainer() const
Definition: fmvwimp.hxx:124
void breakCreateFormObject()
Definition: fmvwimp.cxx:1004
void Activate(bool bSync=false)
Definition: fmvwimp.cxx:732
exports com.sun.star. beans
bool m_isTabOrderUpdateSuspended
Definition: fmvwimp.hxx:169
class encapsulating the css::sdb::DataAccessDescriptor service.
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:478
css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel
Definition: fmvwimp.hxx:145
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1894
std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > m_aNeedTabOrderUpdate
Definition: fmvwimp.hxx:161
const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > & GetList() const
Definition: fmvwimp.hxx:115
void setHasBeenActivated()
Definition: fmvwimp.hxx:213
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
Definition: fmvwimp.cxx:352
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmvwimp.cxx:217
bool hasEverBeenActivated() const
Definition: fmvwimp.hxx:212
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:150
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:512
virtual void SAL_CALL formDeactivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:470
rtl::Reference< FormViewPageWindowAdapter > findWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC) const
Definition: fmvwimp.cxx:517
SdrMarkList m_aMark
Definition: fmvwimp.hxx:164
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:96
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:506
vcl::Window * getWindow() const
Definition: fmvwimp.hxx:127
VclPtr< vcl::Window > m_pWindow
Definition: fmvwimp.hxx:97
FormViewPageWindowAdapter(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const SdrPageWindow &, FmXFormView *pView)
Definition: fmvwimp.cxx:151
FmFormView * m_pView
Definition: fmvwimp.hxx:148
SdrObjectUniquePtr implCreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
Definition: fmvwimp.cxx:1347
bool m_bFirstActivation
Definition: fmvwimp.hxx:168
struct _ADOIndex Index
FmXFormView(FmFormView *_pView)
Definition: fmvwimp.cxx:386
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:96
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:749
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, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpLabel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpControl)
std::unique_ptr< ObjectRemoveListener > m_pWatchStoredList
Definition: fmvwimp.hxx:166