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 typedef ::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter;
131 typedef ::std::set< css::uno::Reference< css::form::XForm > > SetOfForms;
132 typedef ::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms;
133 class SdrModel;
134 
135 class FmXFormView : public ::cppu::WeakImplHelper<
136  css::form::XFormControllerListener,
137  css::awt::XFocusListener,
138  css::container::XContainerListener>
139 {
140  friend class FmFormView;
141  friend class FmFormShell;
142  friend class FmXFormShell;
145  friend class ObjectRemoveListener;
146 
147  css::uno::Reference< css::awt::XWindow> m_xWindow;
148  css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel;
149 
150  FmFormObj* m_pMarkedGrid;
153  ImplSVEvent * m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
154  ImplSVEvent * m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
155  ImplSVEvent * m_nControlWizardEvent; // event for asynchronously setting the focus to a control
156 
157  css::sdb::SQLErrorEvent
158  m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
159 
160  std::vector< PFormViewPageWindowAdapter >
161  m_aPageWindowAdapters; // to be filled in alive mode only
164 
165  // list of selected objects, used for restoration when switching from Alive to DesignMode
167  std::unique_ptr<ObjectRemoveListener>
169 
172 
173  FmFormShell* GetFormShell() const;
174 
175 protected:
176  FmXFormView( FmFormView* _pView );
177  virtual ~FmXFormView() override;
178 
179  void saveMarkList();
180  void restoreMarkList( SdrMarkList& _rRestoredMarkList );
181  void stopMarkListWatching();
182  void startMarkListWatching();
183 
184  void notifyViewDying( );
185  // notifies this impl class that the anti-impl instance (m_pView) is going to die
186 
187 public:
188  // UNO binding
189 
190 // css::lang::XEventListener
191  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
192 
193 // css::container::XContainerListener
194  virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
195  virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
196  virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
197 
198 // css::form::XFormControllerListener
199  virtual void SAL_CALL formActivated(const css::lang::EventObject& rEvent) override;
200  virtual void SAL_CALL formDeactivated(const css::lang::EventObject& rEvent) override;
201 
202  // XFocusListener
203  virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override;
204  virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override;
205 
206  FmFormView* getView() const {return m_pView;}
207  PFormViewPageWindowAdapter findWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ) const;
208 
209  css::uno::Reference< css::form::runtime::XFormController >
210  getFormController( const css::uno::Reference< css::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
211 
212  // activation handling
213  bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
214  void setHasBeenActivated( ) { m_bFirstActivation = false; }
215 
216  void onFirstViewActivation( const FmFormModel* _pDocModel );
217 
222  void suspendTabOrderUpdate();
223 
227  void resumeTabOrderUpdate();
228 
229  void onCreatedFormObject( FmFormObj const & _rFormObject );
230 
231  void breakCreateFormObject();
232 
233  static bool
234  isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl );
235 
236 private:
237  //void addWindow(const SdrPageViewWinRec*);
238  void addWindow(const SdrPageWindow&);
239  void removeWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC );
240  void Activate(bool bSync = false);
241  void Deactivate(bool bDeactivateController = true);
242 
245 
246  static bool createControlLabelPair(
247  OutputDevice const & _rOutDev,
248  sal_Int32 _nXOffsetMM,
249  sal_Int32 _nYOffsetMM,
250  const css::uno::Reference< css::beans::XPropertySet >& _rxField,
251  const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
252  SdrObjKind _nControlObjectID,
253  std::u16string_view _rFieldPostfix,
254  SdrInventor _nInventor,
255  SdrObjKind _nLabelObjectID,
256 
257  // tdf#118963 Need a SdrModel for SdrObject creation. To make the
258  // demand clear, hand over a SdrMldel&
259  SdrModel& _rModel,
260 
261  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
262  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl
263  );
264 
266  OutputDevice const & _rOutDev,
267  sal_Int32 _nXOffsetMM,
268  sal_Int32 _nYOffsetMM,
269  const css::uno::Reference< css::beans::XPropertySet >& _rxField,
270  const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
271  SdrObjKind _nControlObjectID,
272  std::u16string_view _rFieldPostfix,
273  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
274  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
275  const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource,
276  const OUString& _rDataSourceName,
277  const OUString& _rCommand,
278  const sal_Int32 _nCommandType
279  );
280 
281  void ObjectRemovedInAliveMode(const SdrObject* pObject);
282 
283  // asynchronously displays an error message. See also OnDelayedErrorMessage.
284  void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent& _rEvent );
285 
286  // cancels all pending async events
287  void cancelEvents();
288 
290  void AutoFocus();
291  DECL_LINK( OnActivate, void*, void );
292  DECL_LINK( OnAutoFocus, void*, void );
293  DECL_LINK( OnDelayedErrorMessage, void*, void );
294  DECL_LINK( OnStartControlWizard, void*, void );
295 
296 private:
298 };
299 
300 
301 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
302 
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
void stopMarkListWatching()
Definition: fmvwimp.cxx:1722
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:155
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
void saveMarkList()
Definition: fmvwimp.cxx:1750
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:152
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:548
void cancelEvents()
Definition: fmvwimp.cxx:398
virtual ~FormViewPageWindowAdapter() override
Definition: fmvwimp.cxx:180
css::uno::Reference< css::form::runtime::XFormController > getController(const css::uno::Reference< css::form::XForm > &xForm) const
Definition: fmvwimp.cxx:280
css::uno::Reference< css::awt::XWindow > m_xWindow
Definition: fmvwimp.hxx:147
void resumeTabOrderUpdate()
resumes calls to activateTabOrder, and also does all pending calls which were collected since the las...
Definition: fmvwimp.cxx:600
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1899
void startMarkListWatching()
Definition: fmvwimp.cxx:1732
void onFirstViewActivation(const FmFormModel *_pDocModel)
Definition: fmvwimp.cxx:586
exports com.sun.star. awt
void notifyViewDying()
Definition: fmvwimp.cxx:426
::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList
Definition: fmvwimp.hxx:93
SdrInventor
Definition: svdobj.hxx:101
void setController(const css::uno::Reference< css::form::XForm > &xForm, const css::uno::Reference< css::form::runtime::XFormController > &_rxParentController)
Definition: fmvwimp.cxx:297
FmFormView * getView() const
Definition: fmvwimp.hxx:206
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1699
SdrObjKind
Definition: svdobjkind.hxx:24
SdrObjectUniquePtr implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1112
FmFormObj * m_pMarkedGrid
Definition: fmvwimp.hxx:150
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1804
DECL_LINK(OnActivate, void *, void)
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:434
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:154
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:781
virtual void SAL_CALL formActivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:462
void AutoFocus()
the auto focus to the first (in terms of the tab order) control
Definition: fmvwimp.cxx:772
::std::set< css::uno::Reference< css::form::XForm > > SetOfForms
Definition: fmvwimp.hxx:131
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:158
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmvwimp.cxx:227
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:971
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmvwimp.cxx:232
::cppu::WeakImplHelper< css::container::XIndexAccess, css::form::runtime::XFormControllerContext > FormViewPageWindowAdapter_Base
Definition: fmvwimp.hxx:87
::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter
Definition: fmvwimp.hxx:130
virtual void SAL_CALL makeVisible(const css::uno::Reference< css::awt::XControl > &Control) override
Definition: fmvwimp.cxx:243
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:879
MapControlContainerToSetOfForms m_aNeedTabOrderUpdate
Definition: fmvwimp.hxx:163
void suspendTabOrderUpdate()
suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of th...
Definition: fmvwimp.cxx:593
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fmvwimp.cxx:221
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: fmvwimp.cxx:447
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: fmvwimp.hxx:95
unsigned char sal_Bool
void addWindow(const SdrPageWindow &)
Definition: fmvwimp.cxx:526
FmFormShell * GetFormShell() const
Definition: fmvwimp.cxx:767
::svxform::DocumentType impl_getDocumentType() const
Definition: fmvwimp.cxx:1909
Abstract DrawObject.
Definition: svdobj.hxx:261
const css::uno::Reference< css::awt::XControlContainer > & getControlContainer() const
Definition: fmvwimp.hxx:124
void breakCreateFormObject()
Definition: fmvwimp.cxx:1007
void Activate(bool bSync=false)
Definition: fmvwimp.cxx:736
exports com.sun.star. beans
::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms
Definition: fmvwimp.hxx:132
std::vector< PFormViewPageWindowAdapter > m_aPageWindowAdapters
Definition: fmvwimp.hxx:161
bool m_isTabOrderUpdateSuspended
Definition: fmvwimp.hxx:171
class encapsulating the css::sdb::DataAccessDescriptor service.
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:477
css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel
Definition: fmvwimp.hxx:148
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1891
const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > & GetList() const
Definition: fmvwimp.hxx:115
void setHasBeenActivated()
Definition: fmvwimp.hxx:214
void updateTabOrder(const css::uno::Reference< css::form::XForm > &_rxForm)
Definition: fmvwimp.cxx:351
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmvwimp.cxx:216
bool hasEverBeenActivated() const
Definition: fmvwimp.hxx:213
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:153
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:511
virtual void SAL_CALL formDeactivated(const css::lang::EventObject &rEvent) override
Definition: fmvwimp.cxx:469
SdrMarkList m_aMark
Definition: fmvwimp.hxx:166
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:99
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:505
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:150
FmFormView * m_pView
Definition: fmvwimp.hxx:151
PFormViewPageWindowAdapter findWindow(const css::uno::Reference< css::awt::XControlContainer > &_rxCC) const
Definition: fmvwimp.cxx:516
SdrObjectUniquePtr implCreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
Definition: fmvwimp.cxx:1344
bool m_bFirstActivation
Definition: fmvwimp.hxx:170
struct _ADOIndex Index
FmXFormView(FmFormView *_pView)
Definition: fmvwimp.cxx:385
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:96
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:753
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:168