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 
27 #include <svx/svdmark.hxx>
28 #include <svx/svdobj.hxx>
30 
31 #include <com/sun/star/form/XForm.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/form/runtime/XFormController.hpp>
34 #include <com/sun/star/form/runtime/XFormControllerContext.hpp>
35 #include <com/sun/star/container/XContainerListener.hpp>
36 #include <com/sun/star/container/ContainerEvent.hpp>
37 #include <com/sun/star/awt/XFocusListener.hpp>
38 #include <com/sun/star/sdb/SQLErrorEvent.hpp>
39 #include <com/sun/star/sdbc/XDataSource.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 
42 #include <tools/link.hxx>
43 #include <cppuhelper/implbase.hxx>
44 #include <rtl/ref.hxx>
45 #include <vcl/vclptr.hxx>
46 
47 class SdrPageWindow;
48 
49 class SdrObject;
50 class FmFormObj;
51 class FmFormModel;
52 class FmFormView;
53 class FmFormShell;
54 namespace vcl { class Window; }
55 class OutputDevice;
56 class SdrUnoObj;
57 struct ImplSVEvent;
58 enum class SdrInventor : sal_uInt32;
59 
60 namespace com::sun::star {
61  namespace awt {
62  class XControl;
63  class XWindow;
64  }
65  namespace beans {
66  class XPropertySet;
67  }
68  namespace util {
69  class XNumberFormats;
70  }
71 }
72 
73 class FmXFormView;
74 
75 namespace svx {
76  class ODataAccessDescriptor;
77  struct OXFormsDescriptor;
78 }
79 
80 
81 // FormViewPageWindowAdapter
82 
83 typedef ::cppu::WeakImplHelper < css::container::XIndexAccess
84  , css::form::runtime::XFormControllerContext
86 
88 {
89  friend class FmXFormView;
90 
91  ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > m_aControllerList;
92  css::uno::Reference< css::awt::XControlContainer > m_xControlContainer;
93  css::uno::Reference<css::uno::XComponentContext> m_xContext;
96 
97 public:
98  FormViewPageWindowAdapter( const css::uno::Reference<css::uno::XComponentContext>& _rContext,
99  const SdrPageWindow&, FmXFormView* pView);
100  //const SdrPageViewWinRec*, FmXFormView* pView);
101 
102  // XElementAccess
103  virtual css::uno::Type SAL_CALL getElementType() override;
104  virtual sal_Bool SAL_CALL hasElements() override;
105 
106  // XIndexAccess
107  virtual sal_Int32 SAL_CALL getCount() override;
108  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override;
109 
110  // XFormControllerContext
111  virtual void SAL_CALL makeVisible( const css::uno::Reference< css::awt::XControl >& Control ) override;
112 
113  const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > >& GetList() const {return m_aControllerList;}
114 
115 private:
116  virtual ~FormViewPageWindowAdapter() override;
117 
118  css::uno::Reference< css::form::runtime::XFormController > getController( const css::uno::Reference< css::form::XForm >& xForm ) const;
119  void setController(
120  const css::uno::Reference< css::form::XForm >& xForm,
121  const css::uno::Reference< css::form::runtime::XFormController >& _rxParentController );
122  const css::uno::Reference< css::awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
123  void updateTabOrder( const css::uno::Reference< css::form::XForm >& _rxForm );
124  void dispose();
125  vcl::Window* getWindow() const {return m_pWindow;}
126 };
127 
128 typedef ::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter;
129 typedef ::std::set< css::uno::Reference< css::form::XForm > > SetOfForms;
130 typedef ::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms;
131 class SdrModel;
132 
133 class FmXFormView : public ::cppu::WeakImplHelper<
134  css::form::XFormControllerListener,
135  css::awt::XFocusListener,
136  css::container::XContainerListener>
137 {
138  friend class FmFormView;
139  friend class FmFormShell;
140  friend class FmXFormShell;
143  friend class ObjectRemoveListener;
144 
145  css::uno::Reference< css::awt::XWindow> m_xWindow;
146  css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel;
147 
148  FmFormObj* m_pMarkedGrid;
151  ImplSVEvent * m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
152  ImplSVEvent * m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
153  ImplSVEvent * m_nControlWizardEvent; // event for asynchronously setting the focus to a control
154 
155  css::sdb::SQLErrorEvent
156  m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
157 
158  std::vector< PFormViewPageWindowAdapter >
159  m_aPageWindowAdapters; // to be filled in alive mode only
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 protected:
174  FmXFormView( FmFormView* _pView );
175  virtual ~FmXFormView() override;
176 
177  void saveMarkList();
178  void restoreMarkList( SdrMarkList& _rRestoredMarkList );
179  void stopMarkListWatching();
180  void startMarkListWatching();
181 
182  void notifyViewDying( );
183  // notifies this impl class that the anti-impl instance (m_pView) is going to die
184 
185 public:
186  // UNO binding
187 
188 // css::lang::XEventListener
189  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
190 
191 // css::container::XContainerListener
192  virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override;
193  virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override;
194  virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override;
195 
196 // css::form::XFormControllerListener
197  virtual void SAL_CALL formActivated(const css::lang::EventObject& rEvent) override;
198  virtual void SAL_CALL formDeactivated(const css::lang::EventObject& rEvent) override;
199 
200  // XFocusListener
201  virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override;
202  virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override;
203 
204  FmFormView* getView() const {return m_pView;}
205  PFormViewPageWindowAdapter findWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ) const;
206 
207  css::uno::Reference< css::form::runtime::XFormController >
208  getFormController( const css::uno::Reference< css::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
209 
210  // activation handling
211  bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
212  void setHasBeenActivated( ) { m_bFirstActivation = false; }
213 
214  void onFirstViewActivation( const FmFormModel* _pDocModel );
215 
220  void suspendTabOrderUpdate();
221 
225  void resumeTabOrderUpdate();
226 
227  void onCreatedFormObject( FmFormObj const & _rFormObject );
228 
229  void breakCreateFormObject();
230 
231  static bool
232  isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl );
233 
234 private:
235  //void addWindow(const SdrPageViewWinRec*);
236  void addWindow(const SdrPageWindow&);
237  void removeWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC );
238  void Activate(bool bSync = false);
239  void Deactivate(bool bDeactivateController = true);
240 
243 
244  static bool createControlLabelPair(
245  OutputDevice const & _rOutDev,
246  sal_Int32 _nXOffsetMM,
247  sal_Int32 _nYOffsetMM,
248  const css::uno::Reference< css::beans::XPropertySet >& _rxField,
249  const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
250  sal_uInt16 _nControlObjectID,
251  const OUString& _rFieldPostfix,
252  SdrInventor _nInventor,
253  sal_uInt16 _nLabelObjectID,
254 
255  // tdf#118963 Need a SdrModel for SdrObject creation. To make the
256  // demand clear, hand over a SdrMldel&
257  SdrModel& _rModel,
258 
259  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
260  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl
261  );
262 
264  OutputDevice const & _rOutDev,
265  sal_Int32 _nXOffsetMM,
266  sal_Int32 _nYOffsetMM,
267  const css::uno::Reference< css::beans::XPropertySet >& _rxField,
268  const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
269  sal_uInt16 _nControlObjectID,
270  const OUString& _rFieldPostfix,
271  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
272  std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
273  const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource,
274  const OUString& _rDataSourceName,
275  const OUString& _rCommand,
276  const sal_Int32 _nCommandType
277  );
278 
279  void ObjectRemovedInAliveMode(const SdrObject* pObject);
280 
281  // asynchronously displays an error message. See also OnDelayedErrorMessage.
282  void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent& _rEvent );
283 
284  // cancels all pending async events
285  void cancelEvents();
286 
288  void AutoFocus();
289  DECL_LINK( OnActivate, void*, void );
290  DECL_LINK( OnAutoFocus, void*, void );
291  DECL_LINK( OnDelayedErrorMessage, void*, void );
292  DECL_LINK( OnStartControlWizard, void*, void );
293 
294 private:
296 };
297 
298 
299 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
void stopMarkListWatching()
Definition: fmvwimp.cxx:1723
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:153
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
void saveMarkList()
Definition: fmvwimp.cxx:1751
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:150
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer
Definition: fmvwimp.hxx:92
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:145
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:1900
void startMarkListWatching()
Definition: fmvwimp.cxx:1733
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:91
SdrInventor
Definition: svdobj.hxx:152
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:204
void ObjectRemovedInAliveMode(const SdrObject *pObject)
Definition: fmvwimp.cxx:1700
SdrObjectUniquePtr implCreateFieldControl(const svx::ODataAccessDescriptor &_rColumnDescriptor)
Definition: fmvwimp.cxx:1112
FmFormObj * m_pMarkedGrid
Definition: fmvwimp.hxx:148
void restoreMarkList(SdrMarkList &_rRestoredMarkList)
Definition: fmvwimp.cxx:1805
DECL_LINK(OnActivate, void *, void)
virtual ~FmXFormView() override
Definition: fmvwimp.cxx:434
ImplSVEvent * m_nAutoFocusEvent
Definition: fmvwimp.hxx:152
static bool isFocusable(const css::uno::Reference< css::awt::XControl > &i_rControl)
Definition: fmvwimp.cxx:781
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, sal_uInt16 _nControlObjectID, const OUString &_rFieldPostfix, SdrInventor _nInventor, sal_uInt16 _nLabelObjectID, SdrModel &_rModel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpLabel, std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > &_rpControl)
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:129
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:156
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:85
::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter
Definition: fmvwimp.hxx:128
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:31
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:161
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:93
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:1910
Abstract DrawObject.
Definition: svdobj.hxx:312
const css::uno::Reference< css::awt::XControlContainer > & getControlContainer() const
Definition: fmvwimp.hxx:122
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:130
std::vector< PFormViewPageWindowAdapter > m_aPageWindowAdapters
Definition: fmvwimp.hxx:159
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:477
css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel
Definition: fmvwimp.hxx:146
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: fmvwimp.cxx:1892
const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > > & GetList() const
Definition: fmvwimp.hxx:113
void setHasBeenActivated()
Definition: fmvwimp.hxx:212
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:211
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:151
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:164
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &rEvent) override
Definition: fmvwimp.cxx:505
vcl::Window * getWindow() const
Definition: fmvwimp.hxx:125
VclPtr< vcl::Window > m_pWindow
Definition: fmvwimp.hxx:95
FormViewPageWindowAdapter(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const SdrPageWindow &, FmXFormView *pView)
Definition: fmvwimp.cxx:150
FmFormView * m_pView
Definition: fmvwimp.hxx:149
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:168
struct _ADOIndex Index
FmXFormView(FmFormView *_pView)
Definition: fmvwimp.cxx:385
FmXFormView * m_pViewImpl
Definition: fmvwimp.hxx:94
void Deactivate(bool bDeactivateController=true)
Definition: fmvwimp.cxx:753
std::unique_ptr< ObjectRemoveListener > m_pWatchStoredList
Definition: fmvwimp.hxx:166