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>
26 #include "svx/svdmark.hxx"
27 #include "fmdocumentclassification.hxx"
29 #include <com/sun/star/form/XForm.hpp>
30 #include <com/sun/star/container/XIndexAccess.hpp>
31 #include <com/sun/star/container/XEnumeration.hpp>
32 #include <com/sun/star/form/runtime/XFormController.hpp>
33 #include <com/sun/star/form/runtime/XFormControllerContext.hpp>
34 #include <com/sun/star/container/XContainerListener.hpp>
35 #include <com/sun/star/container/ContainerEvent.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.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>
42 #include <comphelper/stl_types.hxx>
43 #include <tools/link.hxx>
44 #include <cppuhelper/implbase2.hxx>
45 #include <cppuhelper/implbase3.hxx>
46 #include <comphelper/uno3.hxx>
47 #include <rtl/ref.hxx>
48 #include <vcl/vclptr.hxx>
57 namespace vcl
{ class Window
; }
62 namespace com
{ namespace sun
{ namespace star
{
78 class ODataAccessDescriptor
;
79 struct OXFormsDescriptor
;
83 // FormViewPageWindowAdapter
85 typedef ::cppu::WeakImplHelper2
< ::com::sun::star::container::XIndexAccess
86 , ::com::sun::star::form::runtime::XFormControllerContext
87 > FormViewPageWindowAdapter_Base
;
89 class FormViewPageWindowAdapter
: public FormViewPageWindowAdapter_Base
91 friend class FmXFormView
;
93 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> > m_aControllerList
;
94 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
> m_xControlContainer
;
95 css::uno::Reference
<css::uno::XComponentContext
> m_xContext
;
96 FmXFormView
* m_pViewImpl
;
97 VclPtr
<vcl::Window
> m_pWindow
;
100 virtual ~FormViewPageWindowAdapter();
103 FormViewPageWindowAdapter( const css::uno::Reference
<css::uno::XComponentContext
>& _rContext
,
104 const SdrPageWindow
&, FmXFormView
* pView
);
105 //const SdrPageViewWinRec*, FmXFormView* pView);
108 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
109 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
112 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex(sal_Int32 _Index
) throw(::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 // XFormControllerContext
116 virtual void SAL_CALL
makeVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& _Control
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 const ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> >& GetList() {return m_aControllerList
;}
121 ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> getController( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& xForm
) const;
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& xForm
,
124 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
>& _rxParentController
);
125 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
> getControlContainer() const { return m_xControlContainer
; }
126 void updateTabOrder( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& _rxForm
);
128 vcl::Window
* getWindow() const {return m_pWindow
;}
131 typedef ::rtl::Reference
< FormViewPageWindowAdapter
> PFormViewPageWindowAdapter
;
132 typedef ::std::vector
< PFormViewPageWindowAdapter
> PageWindowAdapterList
;
133 typedef ::std::set
< ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>
134 , ::comphelper::OInterfaceCompare
< ::com::sun::star::form::XForm
>
136 typedef ::std::map
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
>
138 , ::comphelper::OInterfaceCompare
< ::com::sun::star::awt::XControlContainer
>
139 > MapControlContainerToSetOfForms
;
142 class FmXFormView
: public ::cppu::WeakImplHelper3
<
143 ::com::sun::star::form::XFormControllerListener
,
144 ::com::sun::star::awt::XFocusListener
,
145 ::com::sun::star::container::XContainerListener
>
147 friend class FmFormView
;
148 friend class FmFormShell
;
149 friend class FmXFormShell
;
150 friend class FormViewPageWindowAdapter
;
151 class ObjectRemoveListener
;
152 friend class ObjectRemoveListener
;
154 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xWindow
;
155 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xLastCreatedControlModel
;
157 FmFormObj
* m_pMarkedGrid
;
159 ImplSVEvent
* m_nActivationEvent
;
160 ImplSVEvent
* m_nErrorMessageEvent
; // event for an asynchronous error message. See also m_aAsyncError
161 ImplSVEvent
* m_nAutoFocusEvent
; // event for asynchronously setting the focus to a control
162 ImplSVEvent
* m_nControlWizardEvent
; // event for asynchronously setting the focus to a control
164 ::com::sun::star::sdb::SQLErrorEvent
165 m_aAsyncError
; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
167 PageWindowAdapterList
168 m_aPageWindowAdapters
; // to be filled in alive mode only
169 MapControlContainerToSetOfForms
170 m_aNeedTabOrderUpdate
;
172 // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode
174 ObjectRemoveListener
* m_pWatchStoredList
;
176 bool m_bFirstActivation
;
177 bool m_isTabOrderUpdateSuspended
;
179 FmFormShell
* GetFormShell() const;
181 void removeGridWindowListening();
184 FmXFormView( FmFormView
* _pView
);
185 virtual ~FmXFormView();
187 void saveMarkList( bool _bSmartUnmark
= true );
188 void restoreMarkList( SdrMarkList
& _rRestoredMarkList
);
189 void stopMarkListWatching();
190 void startMarkListWatching();
192 void notifyViewDying( );
193 // notifies this impl class that the anti-impl instance (m_pView) is going to die
198 // ::com::sun::star::lang::XEventListener
199 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
201 // ::com::sun::star::container::XContainerListener
202 virtual void SAL_CALL
elementInserted(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
203 virtual void SAL_CALL
elementReplaced(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
204 virtual void SAL_CALL
elementRemoved(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
206 // ::com::sun::star::form::XFormControllerListener
207 virtual void SAL_CALL
formActivated(const ::com::sun::star::lang::EventObject
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
208 virtual void SAL_CALL
formDeactivated(const ::com::sun::star::lang::EventObject
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
211 virtual void SAL_CALL
focusGained( const ::com::sun::star::awt::FocusEvent
& e
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
212 virtual void SAL_CALL
focusLost( const ::com::sun::star::awt::FocusEvent
& e
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
214 FmFormView
* getView() const {return m_pView
;}
215 PFormViewPageWindowAdapter
findWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
>& _rxCC
) const;
217 ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
>
218 getFormController( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& _rxForm
, const OutputDevice
& _rDevice
) const;
220 // activation handling
221 inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation
; }
222 inline void setHasBeenActivated( ) { m_bFirstActivation
= false; }
224 void onFirstViewActivation( const FmFormModel
* _pDocModel
);
226 /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
227 new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
228 suspendTabOrderUpdate, again.
230 void suspendTabOrderUpdate();
232 /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
233 suspendTabOrderUpdate call.
235 void resumeTabOrderUpdate();
237 void onCreatedFormObject( FmFormObj
& _rFormObject
);
239 void breakCreateFormObject();
243 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& i_rControl
247 //void addWindow(const SdrPageViewWinRec*);
248 void addWindow(const SdrPageWindow
&);
249 void removeWindow( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
>& _rxCC
);
250 void Activate(bool bSync
= false);
251 void Deactivate(bool bDeactivateController
= true);
253 SdrObject
* implCreateFieldControl( const svx::ODataAccessDescriptor
& _rColumnDescriptor
);
254 SdrObject
* implCreateXFormsControl( const svx::OXFormsDescriptor
&_rDesc
);
256 static bool createControlLabelPair(
257 OutputDevice
& _rOutDev
,
258 sal_Int32 _nXOffsetMM
,
259 sal_Int32 _nYOffsetMM
,
260 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxField
,
261 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormats
>& _rxNumberFormats
,
262 sal_uInt16 _nControlObjectID
,
263 const OUString
& _rFieldPostfix
,
264 sal_uInt32 _nInventor
,
265 sal_uInt16 _nLabelObjectID
,
266 SdrPage
* _pLabelPage
,
267 SdrPage
* _pControlPage
,
269 SdrUnoObj
*& _rpLabel
,
270 SdrUnoObj
*& _rpControl
273 bool createControlLabelPair(
274 OutputDevice
& _rOutDev
,
275 sal_Int32 _nXOffsetMM
,
276 sal_Int32 _nYOffsetMM
,
277 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxField
,
278 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormats
>& _rxNumberFormats
,
279 sal_uInt16 _nControlObjectID
,
280 const OUString
& _rFieldPostfix
,
281 SdrUnoObj
*& _rpLabel
,
282 SdrUnoObj
*& _rpControl
,
283 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
>& _rxDataSource
= NULL
,
284 const OUString
& _rDataSourceName
= OUString(),
285 const OUString
& _rCommand
= OUString(),
286 const sal_Int32 _nCommandType
= -1
289 void ObjectRemovedInAliveMode(const SdrObject
* pObject
);
291 // asynchronously displays an error message. See also OnDelayedErrorMessage.
292 void displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent
& _rEvent
);
294 // cancels all pending async events
297 /// the auto focus to the first (in terms of the tab order) control
298 void AutoFocus( bool _bSync
= false );
299 DECL_LINK( OnActivate
, void* );
300 DECL_LINK( OnAutoFocus
, void* );
301 DECL_LINK( OnDelayedErrorMessage
, void* );
302 DECL_LINK( OnStartControlWizard
, void* );
305 ::svxform::DocumentType
impl_getDocumentType() const;
310 #endif // INCLUDED_SVX_SOURCE_INC_FMVWIMP_HXX
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */