tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / svx / source / inc / fmvwimp.hxx
blob16c156d9a672393fdd85ce719bda7d0280f1f028
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
20 #define INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
22 #include <sal/config.h>
24 #include <map>
25 #include <memory>
26 #include <set>
27 #include <string_view>
29 #include <svx/svdmark.hxx>
30 #include <svx/svdobj.hxx>
31 #include "fmdocumentclassification.hxx"
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>
44 #include <tools/link.hxx>
45 #include <cppuhelper/implbase.hxx>
46 #include <rtl/ref.hxx>
47 #include <vcl/vclptr.hxx>
49 class SdrPageWindow;
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;
62 namespace com::sun::star {
63 namespace awt {
64 class XControl;
65 class XWindow;
67 namespace beans {
68 class XPropertySet;
70 namespace util {
71 class XNumberFormats;
75 class FmXFormView;
77 namespace svx {
78 class ODataAccessDescriptor;
79 struct OXFormsDescriptor;
83 // FormViewPageWindowAdapter
85 typedef ::cppu::WeakImplHelper < css::container::XIndexAccess
86 , css::form::runtime::XFormControllerContext
87 > FormViewPageWindowAdapter_Base;
89 class FormViewPageWindowAdapter final : public FormViewPageWindowAdapter_Base
91 friend class FmXFormView;
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;
96 FmXFormView* m_pViewImpl;
97 VclPtr<vcl::Window> m_pWindow;
99 public:
100 FormViewPageWindowAdapter( css::uno::Reference<css::uno::XComponentContext> _xContext,
101 const SdrPageWindow&, FmXFormView* pView);
102 //const SdrPageViewWinRec*, FmXFormView* pView);
104 // XElementAccess
105 virtual css::uno::Type SAL_CALL getElementType() override;
106 virtual sal_Bool SAL_CALL hasElements() override;
108 // XIndexAccess
109 virtual sal_Int32 SAL_CALL getCount() override;
110 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override;
112 // XFormControllerContext
113 virtual void SAL_CALL makeVisible( const css::uno::Reference< css::awt::XControl >& Control ) override;
115 const ::std::vector< css::uno::Reference< css::form::runtime::XFormController > >& GetList() const {return m_aControllerList;}
117 private:
118 virtual ~FormViewPageWindowAdapter() override;
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;}
130 class SdrModel;
132 class FmXFormView final : public ::cppu::WeakImplHelper<
133 css::form::XFormControllerListener,
134 css::awt::XFocusListener,
135 css::container::XContainerListener>
137 friend class FmFormView;
138 friend class FmFormShell;
139 friend class FmXFormShell;
140 friend class FormViewPageWindowAdapter;
141 class ObjectRemoveListener;
142 friend class ObjectRemoveListener;
144 css::uno::Reference< css::awt::XWindow> m_xWindow;
145 css::uno::Reference< css::beans::XPropertySet > m_xLastCreatedControlModel;
147 FmFormObj* m_pMarkedGrid;
148 FmFormView* m_pView;
149 ImplSVEvent * m_nActivationEvent;
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
154 css::sdb::SQLErrorEvent
155 m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
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
163 // list of selected objects, used for restoration when switching from Alive to DesignMode
164 SdrMarkList m_aMark;
165 std::unique_ptr<ObjectRemoveListener>
166 m_pWatchStoredList;
168 bool m_bFirstActivation;
169 bool m_isTabOrderUpdateSuspended;
171 FmFormShell* GetFormShell() const;
173 css::uno::Reference<css::awt::XWindow> GetParentWindow() const;
175 FmXFormView( FmFormView* _pView );
176 virtual ~FmXFormView() override;
178 void saveMarkList();
179 void restoreMarkList( SdrMarkList& _rRestoredMarkList );
180 void stopMarkListWatching();
181 void startMarkListWatching();
183 void notifyViewDying( );
184 // notifies this impl class that the anti-impl instance (m_pView) is going to die
186 public:
187 // UNO binding
189 // css::lang::XEventListener
190 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
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;
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;
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;
205 FmFormView* getView() const {return m_pView;}
206 rtl::Reference< FormViewPageWindowAdapter > findWindow( const css::uno::Reference< css::awt::XControlContainer >& _rxCC ) const;
208 css::uno::Reference< css::form::runtime::XFormController >
209 getFormController( const css::uno::Reference< css::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
211 // activation handling
212 bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
213 void setHasBeenActivated( ) { m_bFirstActivation = false; }
215 void onFirstViewActivation( const FmFormModel* _pDocModel );
217 /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
218 new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
219 suspendTabOrderUpdate, again.
221 void suspendTabOrderUpdate();
223 /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
224 suspendTabOrderUpdate call.
226 void resumeTabOrderUpdate();
228 void onCreatedFormObject( FmFormObj const & _rFormObject );
230 void breakCreateFormObject();
232 static bool
233 isFocusable( const css::uno::Reference< css::awt::XControl >& i_rControl );
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);
242 rtl::Reference<SdrObject> implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
243 rtl::Reference<SdrObject> implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
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,
256 // tdf#118963 Need a SdrModel for SdrObject creation. To make the
257 // demand clear, hand over a SdrMldel&
258 SdrModel& _rModel,
260 rtl::Reference<SdrUnoObj>& _rpLabel,
261 rtl::Reference<SdrUnoObj>& _rpControl
264 bool createControlLabelPair(
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 rtl::Reference<SdrUnoObj>& _rpLabel,
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
280 void ObjectRemovedInAliveMode(const SdrObject* pObject);
282 // asynchronously displays an error message. See also OnDelayedErrorMessage.
283 void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent& _rEvent );
285 // cancels all pending async events
286 void cancelEvents();
288 /// the auto focus to the first (in terms of the tab order) control
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 );
295 private:
296 ::svxform::DocumentType impl_getDocumentType() const;
300 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */