Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / inc / fmvwimp.hxx
blobf76c69dc6278b359816c3b9734e77f66fa97bb77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _SVX_FMVWIMP_HXX
29 #define _SVX_FMVWIMP_HXX
31 #include "svx/svdmark.hxx"
32 #include "fmdocumentclassification.hxx"
34 /** === begin UNO includes === **/
35 #include <com/sun/star/form/XForm.hpp>
36 #include <com/sun/star/container/XIndexAccess.hpp>
37 #include <com/sun/star/container/XEnumeration.hpp>
38 #include <com/sun/star/form/runtime/XFormController.hpp>
39 #include <com/sun/star/form/runtime/XFormControllerContext.hpp>
40 #include <com/sun/star/container/XContainerListener.hpp>
41 #include <com/sun/star/container/ContainerEvent.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #include <com/sun/star/awt/XFocusListener.hpp>
44 #include <com/sun/star/sdb/SQLErrorEvent.hpp>
45 #include <com/sun/star/sdbc/XDataSource.hpp>
46 /** === end UNO includes === **/
48 #include <comphelper/stl_types.hxx>
49 #include <tools/link.hxx>
50 #include <cppuhelper/implbase2.hxx>
51 #include <cppuhelper/implbase3.hxx>
52 #include <comphelper/uno3.hxx>
53 #include <comphelper/componentcontext.hxx>
54 #include <rtl/ref.hxx>
56 //class SdrPageViewWinRec;
57 class SdrPageWindow;
59 class SdrPageView;
60 class SdrObject;
61 class FmFormObj;
62 class FmFormModel;
63 class FmFormView;
64 class FmFormShell;
65 class Window;
66 class OutputDevice;
67 class SdrUnoObj;
68 class SdrView;
70 namespace com { namespace sun { namespace star {
71 namespace awt {
72 class XControl;
73 class XWindow;
75 namespace beans {
76 class XPropertySet;
78 namespace util {
79 class XNumberFormats;
81 }}}
83 class FmXFormView;
85 namespace svx {
86 class ODataAccessDescriptor;
87 struct OXFormsDescriptor;
90 //==================================================================
91 // FormViewPageWindowAdapter
92 //==================================================================
93 typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XIndexAccess
94 , ::com::sun::star::form::runtime::XFormControllerContext
95 > FormViewPageWindowAdapter_Base;
97 class FormViewPageWindowAdapter : public FormViewPageWindowAdapter_Base
99 friend class FmXFormView;
101 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > m_aControllerList;
102 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer;
103 ::comphelper::ComponentContext m_aContext;
104 FmXFormView* m_pViewImpl;
105 Window* m_pWindow;
107 protected:
108 ~FormViewPageWindowAdapter();
110 public:
111 FormViewPageWindowAdapter( const ::comphelper::ComponentContext& _rContext,
112 const SdrPageWindow&, FmXFormView* pView);
113 //const SdrPageViewWinRec*, FmXFormView* pView);
115 // XElementAccess
116 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
117 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
119 // XEnumerationAccess
120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
122 // XIndexAccess
123 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
124 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);
126 // XFormControllerContext
127 virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException);
129 const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;}
131 protected:
132 ::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;
133 void setController(
134 const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm,
135 const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController );
136 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; }
137 void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm );
138 void dispose();
139 Window* getWindow() const {return m_pWindow;}
142 typedef ::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter;
143 typedef ::std::vector< PFormViewPageWindowAdapter > PageWindowAdapterList;
144 typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
145 , ::comphelper::OInterfaceCompare< ::com::sun::star::form::XForm >
146 > SetOfForms;
147 typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
148 , SetOfForms
149 , ::comphelper::OInterfaceCompare< ::com::sun::star::awt::XControlContainer >
150 > MapControlContainerToSetOfForms;
151 class SdrModel;
152 //==================================================================
153 // FmXFormView
154 //==================================================================
155 class FmXFormView : public ::cppu::WeakImplHelper3<
156 ::com::sun::star::form::XFormControllerListener,
157 ::com::sun::star::awt::XFocusListener,
158 ::com::sun::star::container::XContainerListener>
160 friend class FmFormView;
161 friend class FmFormShell;
162 friend class FmXFormShell;
163 friend class FormViewPageWindowAdapter;
164 class ObjectRemoveListener;
165 friend class ObjectRemoveListener;
167 ::comphelper::ComponentContext m_aContext;
168 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> m_xWindow;
169 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLastCreatedControlModel;
171 FmFormObj* m_pMarkedGrid;
172 FmFormView* m_pView;
173 sal_uIntPtr m_nActivationEvent;
174 sal_uIntPtr m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
175 sal_uIntPtr m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
176 sal_uIntPtr m_nControlWizardEvent; // event for asynchronously setting the focus to a control
178 ::com::sun::star::sdb::SQLErrorEvent
179 m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
181 PageWindowAdapterList
182 m_aPageWindowAdapters; // to be filled in alive mode only
183 MapControlContainerToSetOfForms
184 m_aNeedTabOrderUpdate;
186 // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode
187 SdrMarkList m_aMark;
188 ObjectRemoveListener* m_pWatchStoredList;
190 bool m_bFirstActivation;
191 bool m_isTabOrderUpdateSuspended;
193 FmFormShell* GetFormShell() const;
195 void removeGridWindowListening();
197 protected:
198 FmXFormView( const ::comphelper::ComponentContext& _rContext, FmFormView* _pView );
199 ~FmXFormView();
201 void saveMarkList( sal_Bool _bSmartUnmark = sal_True );
202 void restoreMarkList( SdrMarkList& _rRestoredMarkList );
203 void stopMarkListWatching();
204 void startMarkListWatching();
206 void notifyViewDying( );
207 // notifies this impl class that the anti-impl instance (m_pView) is going to die
209 public:
210 // UNO Anbindung
212 // ::com::sun::star::lang::XEventListener
213 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
215 // ::com::sun::star::container::XContainerListener
216 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
217 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
218 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
220 // ::com::sun::star::form::XFormControllerListener
221 virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
222 virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
224 // XFocusListener
225 virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
226 virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
228 FmFormView* getView() const {return m_pView;}
229 PFormViewPageWindowAdapter findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const;
231 ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >
232 getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
234 // activation handling
235 inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
236 inline void setHasBeenActivated( ) { m_bFirstActivation = false; }
238 void onFirstViewActivation( const FmFormModel* _pDocModel );
240 /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
241 new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
242 suspendTabOrderUpdate, again.
244 void suspendTabOrderUpdate();
246 /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
247 suspendTabOrderUpdate call.
249 void resumeTabOrderUpdate();
251 void onCreatedFormObject( FmFormObj& _rFormObject );
253 static bool
254 isFocusable(
255 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& i_rControl
258 private:
259 //void addWindow(const SdrPageViewWinRec*);
260 void addWindow(const SdrPageWindow&);
261 void removeWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
262 void Activate(sal_Bool bSync = sal_False);
263 void Deactivate(sal_Bool bDeactivateController = sal_True);
265 SdrObject* implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor );
266 SdrObject* implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc );
268 static bool createControlLabelPair(
269 const ::comphelper::ComponentContext& _rContext,
270 OutputDevice& _rOutDev,
271 sal_Int32 _nXOffsetMM,
272 sal_Int32 _nYOffsetMM,
273 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
274 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
275 sal_uInt16 _nControlObjectID,
276 const ::rtl::OUString& _rFieldPostfix,
277 sal_uInt32 _nInventor,
278 sal_uInt16 _nLabelObjectID,
279 SdrPage* _pLabelPage,
280 SdrPage* _pControlPage,
281 SdrModel* _pModel,
282 SdrUnoObj*& _rpLabel,
283 SdrUnoObj*& _rpControl
286 bool createControlLabelPair(
287 OutputDevice& _rOutDev,
288 sal_Int32 _nXOffsetMM,
289 sal_Int32 _nYOffsetMM,
290 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
291 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
292 sal_uInt16 _nControlObjectID,
293 const ::rtl::OUString& _rFieldPostfix,
294 SdrUnoObj*& _rpLabel,
295 SdrUnoObj*& _rpControl,
296 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxDataSource = NULL,
297 const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
298 const ::rtl::OUString& _rCommand= ::rtl::OUString(),
299 const sal_Int32 _nCommandType = -1
302 void ObjectRemovedInAliveMode(const SdrObject* pObject);
304 // asynchronously displays an error message. See also OnDelayedErrorMessage.
305 void displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent );
307 // cancels all pending async events
308 void cancelEvents();
310 /// the the auto focus to the first (in terms of the tab order) control
311 void AutoFocus( sal_Bool _bSync = sal_False );
312 DECL_LINK( OnActivate, void* );
313 DECL_LINK( OnAutoFocus, void* );
314 DECL_LINK( OnDelayedErrorMessage, void* );
315 DECL_LINK( OnStartControlWizard, void* );
317 private:
318 ::svxform::DocumentType impl_getDocumentType() const;
323 #endif // _SVX_FMVWIMP_HXX
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */