1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 #include <svx/svdmark.hxx>
28 #include <svx/svdobj.hxx>
29 #include "fmdocumentclassification.hxx"
31 #include <com/sun/star/form/XForm.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/container/XEnumeration.hpp>
34 #include <com/sun/star/form/runtime/XFormController.hpp>
35 #include <com/sun/star/form/runtime/XFormControllerContext.hpp>
36 #include <com/sun/star/container/XContainerListener.hpp>
37 #include <com/sun/star/container/ContainerEvent.hpp>
38 #include <com/sun/star/lang/XMultiServiceFactory.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>
56 namespace vcl
{ class Window
; }
60 enum class SdrInventor
: sal_uInt32
;
62 namespace com
{ namespace sun
{ namespace star
{
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
;
100 FormViewPageWindowAdapter( const css::uno::Reference
<css::uno::XComponentContext
>& _rContext
,
101 const SdrPageWindow
&, FmXFormView
* pView
);
102 //const SdrPageViewWinRec*, FmXFormView* pView);
105 virtual css::uno::Type SAL_CALL
getElementType() override
;
106 virtual sal_Bool SAL_CALL
hasElements() override
;
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
;}
118 virtual ~FormViewPageWindowAdapter() override
;
120 css::uno::Reference
< css::form::runtime::XFormController
> getController( const css::uno::Reference
< css::form::XForm
>& xForm
) const;
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
);
127 vcl::Window
* getWindow() const {return m_pWindow
;}
130 typedef ::rtl::Reference
< FormViewPageWindowAdapter
> PFormViewPageWindowAdapter
;
131 typedef ::std::vector
< PFormViewPageWindowAdapter
> PageWindowAdapterList
;
132 typedef ::std::set
< css::uno::Reference
< css::form::XForm
> > SetOfForms
;
133 typedef ::std::map
< css::uno::Reference
< css::awt::XControlContainer
>, SetOfForms
> MapControlContainerToSetOfForms
;
136 class FmXFormView
: public ::cppu::WeakImplHelper
<
137 css::form::XFormControllerListener
,
138 css::awt::XFocusListener
,
139 css::container::XContainerListener
>
141 friend class FmFormView
;
142 friend class FmFormShell
;
143 friend class FmXFormShell
;
144 friend class FormViewPageWindowAdapter
;
145 class ObjectRemoveListener
;
146 friend class ObjectRemoveListener
;
148 css::uno::Reference
< css::awt::XWindow
> m_xWindow
;
149 css::uno::Reference
< css::beans::XPropertySet
> m_xLastCreatedControlModel
;
151 FmFormObj
* m_pMarkedGrid
;
153 ImplSVEvent
* m_nActivationEvent
;
154 ImplSVEvent
* m_nErrorMessageEvent
; // event for an asynchronous error message. See also m_aAsyncError
155 ImplSVEvent
* m_nAutoFocusEvent
; // event for asynchronously setting the focus to a control
156 ImplSVEvent
* m_nControlWizardEvent
; // event for asynchronously setting the focus to a control
158 css::sdb::SQLErrorEvent
159 m_aAsyncError
; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
161 PageWindowAdapterList
162 m_aPageWindowAdapters
; // to be filled in alive mode only
163 MapControlContainerToSetOfForms
164 m_aNeedTabOrderUpdate
;
166 // list of selected objects, used for restoration when switching from Alive to DesignMode
168 std::unique_ptr
<ObjectRemoveListener
>
171 bool m_bFirstActivation
;
172 bool m_isTabOrderUpdateSuspended
;
174 FmFormShell
* GetFormShell() const;
177 FmXFormView( FmFormView
* _pView
);
178 virtual ~FmXFormView() override
;
181 void restoreMarkList( SdrMarkList
& _rRestoredMarkList
);
182 void stopMarkListWatching();
183 void startMarkListWatching();
185 void notifyViewDying( );
186 // notifies this impl class that the anti-impl instance (m_pView) is going to die
191 // css::lang::XEventListener
192 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
194 // css::container::XContainerListener
195 virtual void SAL_CALL
elementInserted(const css::container::ContainerEvent
& rEvent
) override
;
196 virtual void SAL_CALL
elementReplaced(const css::container::ContainerEvent
& rEvent
) override
;
197 virtual void SAL_CALL
elementRemoved(const css::container::ContainerEvent
& rEvent
) override
;
199 // css::form::XFormControllerListener
200 virtual void SAL_CALL
formActivated(const css::lang::EventObject
& rEvent
) override
;
201 virtual void SAL_CALL
formDeactivated(const css::lang::EventObject
& rEvent
) override
;
204 virtual void SAL_CALL
focusGained( const css::awt::FocusEvent
& e
) override
;
205 virtual void SAL_CALL
focusLost( const css::awt::FocusEvent
& e
) override
;
207 FmFormView
* getView() const {return m_pView
;}
208 PFormViewPageWindowAdapter
findWindow( const css::uno::Reference
< css::awt::XControlContainer
>& _rxCC
) const;
210 css::uno::Reference
< css::form::runtime::XFormController
>
211 getFormController( const css::uno::Reference
< css::form::XForm
>& _rxForm
, const OutputDevice
& _rDevice
) const;
213 // activation handling
214 bool hasEverBeenActivated( ) const { return !m_bFirstActivation
; }
215 void setHasBeenActivated( ) { m_bFirstActivation
= false; }
217 void onFirstViewActivation( const FmFormModel
* _pDocModel
);
219 /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
220 new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
221 suspendTabOrderUpdate, again.
223 void suspendTabOrderUpdate();
225 /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
226 suspendTabOrderUpdate call.
228 void resumeTabOrderUpdate();
230 void onCreatedFormObject( FmFormObj
const & _rFormObject
);
232 void breakCreateFormObject();
235 isFocusable( const css::uno::Reference
< css::awt::XControl
>& i_rControl
);
238 //void addWindow(const SdrPageViewWinRec*);
239 void addWindow(const SdrPageWindow
&);
240 void removeWindow( const css::uno::Reference
< css::awt::XControlContainer
>& _rxCC
);
241 void Activate(bool bSync
= false);
242 void Deactivate(bool bDeactivateController
= true);
244 SdrObjectUniquePtr
implCreateFieldControl( const svx::ODataAccessDescriptor
& _rColumnDescriptor
);
245 SdrObjectUniquePtr
implCreateXFormsControl( const svx::OXFormsDescriptor
&_rDesc
);
247 static bool createControlLabelPair(
248 OutputDevice
const & _rOutDev
,
249 sal_Int32 _nXOffsetMM
,
250 sal_Int32 _nYOffsetMM
,
251 const css::uno::Reference
< css::beans::XPropertySet
>& _rxField
,
252 const css::uno::Reference
< css::util::XNumberFormats
>& _rxNumberFormats
,
253 sal_uInt16 _nControlObjectID
,
254 const OUString
& _rFieldPostfix
,
255 SdrInventor _nInventor
,
256 sal_uInt16 _nLabelObjectID
,
258 // tdf#118963 Need a SdrModel for SdrObject creation. To make the
259 // demand clear, hand over a SdrMldel&
262 std::unique_ptr
<SdrUnoObj
, SdrObjectFreeOp
>& _rpLabel
,
263 std::unique_ptr
<SdrUnoObj
, SdrObjectFreeOp
>& _rpControl
266 bool createControlLabelPair(
267 OutputDevice
const & _rOutDev
,
268 sal_Int32 _nXOffsetMM
,
269 sal_Int32 _nYOffsetMM
,
270 const css::uno::Reference
< css::beans::XPropertySet
>& _rxField
,
271 const css::uno::Reference
< css::util::XNumberFormats
>& _rxNumberFormats
,
272 sal_uInt16 _nControlObjectID
,
273 const OUString
& _rFieldPostfix
,
274 std::unique_ptr
<SdrUnoObj
, SdrObjectFreeOp
>& _rpLabel
,
275 std::unique_ptr
<SdrUnoObj
, SdrObjectFreeOp
>& _rpControl
,
276 const css::uno::Reference
< css::sdbc::XDataSource
>& _rxDataSource
,
277 const OUString
& _rDataSourceName
,
278 const OUString
& _rCommand
,
279 const sal_Int32 _nCommandType
282 void ObjectRemovedInAliveMode(const SdrObject
* pObject
);
284 // asynchronously displays an error message. See also OnDelayedErrorMessage.
285 void displayAsyncErrorMessage( const css::sdb::SQLErrorEvent
& _rEvent
);
287 // cancels all pending async events
290 /// the auto focus to the first (in terms of the tab order) control
292 DECL_LINK( OnActivate
, void*, void );
293 DECL_LINK( OnAutoFocus
, void*, void );
294 DECL_LINK( OnDelayedErrorMessage
, void*, void );
295 DECL_LINK( OnStartControlWizard
, void*, void );
298 ::svxform::DocumentType
impl_getDocumentType() const;
302 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */