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 { namespace sun { namespace 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::vector< PFormViewPageWindowAdapter > PageWindowAdapterList;
130 typedef ::std::set< css::uno::Reference< css::form::XForm > > SetOfForms;
131 typedef ::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms;
132 class SdrModel;
133 
134 class FmXFormView : public ::cppu::WeakImplHelper<
135  css::form::XFormControllerListener,
136  css::awt::XFocusListener,
137  css::container::XContainerListener>
138 {
139  friend class FmFormView;
140  friend class FmFormShell;
141  friend class FmXFormShell;
144  friend class ObjectRemoveListener;
145 
146  css::uno::Reference< css::awt::XWindow> m_xWindow;
147  css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel;
148 
149  FmFormObj* m_pMarkedGrid;
152  ImplSVEvent * m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
153  ImplSVEvent * m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
154  ImplSVEvent * m_nControlWizardEvent; // event for asynchronously setting the focus to a control
155 
156  css::sdb::SQLErrorEvent
157  m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
158 
160  m_aPageWindowAdapters; // to be filled in alive mode only
163 
164  // list of selected objects, used for restoration when switching from Alive to DesignMode
166  std::unique_ptr<ObjectRemoveListener>
168 
171 
172  FmFormShell* GetFormShell() const;
173 
174 protected:
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  PFormViewPageWindowAdapter 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  sal_uInt16 _nControlObjectID,
252  const OUString& _rFieldPostfix,
253  SdrInventor _nInventor,
254  sal_uInt16 _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  sal_uInt16 _nControlObjectID,
271  const OUString& _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: */
void stopMarkListWatching()
Definition: fmvwimp.cxx:1723
ImplSVEvent * m_nControlWizardEvent
Definition: fmvwimp.hxx:154
void displayAsyncErrorMessage(const css::sdb::SQLErrorEvent &_rEvent)
Definition: fmvwimp.cxx:569
void saveMarkList()
Definition: fmvwimp.cxx:1751
ImplSVEvent * m_nActivationEvent
Definition: fmvwimp.hxx:151
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
::std::vector< PFormViewPageWindowAdapter > PageWindowAdapterList
Definition: fmvwimp.hxx:129
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:146
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
PageWindowAdapterList m_aPageWindowAdapters
Definition: fmvwimp.hxx:160
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:205
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:149
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:153
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:130
css::sdb::SQLErrorEvent m_aAsyncError
Definition: fmvwimp.hxx:157
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:162
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
::std::map< css::uno::Reference< css::awt::XControlContainer >, SetOfForms > MapControlContainerToSetOfForms
Definition: fmvwimp.hxx:131
bool m_isTabOrderUpdateSuspended
Definition: fmvwimp.hxx:170
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:147
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:213
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:212
ImplSVEvent * m_nErrorMessageEvent
Definition: fmvwimp.hxx:152
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:165
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:150
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:169
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:167