update dev300-m58
[ooovba.git] / svx / source / inc / fmvwimp.hxx
blob64a8ef4849953a23c9face3b152788ad781068aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmvwimp.hxx,v $
10 * $Revision: 1.34.260.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVX_FMVWIMP_HXX
31 #define _SVX_FMVWIMP_HXX
33 #include "svx/svdmark.hxx"
34 #include "fmdocumentclassification.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/form/XForm.hpp>
38 #include <com/sun/star/container/XIndexAccess.hpp>
39 #include <com/sun/star/container/XEnumeration.hpp>
40 #include <com/sun/star/form/XFormController.hpp>
41 #include <com/sun/star/container/XContainerListener.hpp>
42 #include <com/sun/star/container/ContainerEvent.hpp>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/awt/XFocusListener.hpp>
45 #include <com/sun/star/sdb/SQLErrorEvent.hpp>
46 #include <com/sun/star/sdbc/XDataSource.hpp>
47 /** === end UNO includes === **/
49 #include <comphelper/stl_types.hxx>
50 #include <tools/link.hxx>
51 #include <tools/string.hxx>
52 #include <cppuhelper/implbase1.hxx>
53 #include <cppuhelper/implbase3.hxx>
54 #include <comphelper/uno3.hxx>
55 #include <comphelper/componentcontext.hxx>
57 //class SdrPageViewWinRec;
58 class SdrPageWindow;
60 class SdrPageView;
61 class SdrObject;
62 class FmFormObj;
63 class FmFormModel;
64 class FmFormView;
65 class FmFormShell;
66 class Window;
67 class OutputDevice;
68 class SdrUnoObj;
69 class SdrView;
71 FORWARD_DECLARE_INTERFACE(awt,XControl)
72 FORWARD_DECLARE_INTERFACE(awt,XWindow)
73 FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
74 FORWARD_DECLARE_INTERFACE(util,XNumberFormats)
76 class FmXFormController;
77 class FmXFormView;
79 namespace svx {
80 class ODataAccessDescriptor;
81 struct OXFormsDescriptor;
84 //==================================================================
85 // FmXPageViewWinRec
86 //==================================================================
87 class FmXPageViewWinRec : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess>
89 friend class FmXFormView;
91 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > > m_aControllerList;
92 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer;
93 ::comphelper::ComponentContext m_aContext;
94 FmXFormView* m_pViewImpl;
95 Window* m_pWindow;
97 public:
98 FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext,
99 const SdrPageWindow&, FmXFormView* pView);
100 //const SdrPageViewWinRec*, FmXFormView* pView);
101 ~FmXPageViewWinRec();
103 // UNO Anbindung
105 // ::com::sun::star::container::XElementAccess
106 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
107 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
109 // ::com::sun::star::container::XEnumerationAccess
110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
112 // ::com::sun::star::container::XIndexAccess
113 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
114 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);
116 const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > >& GetList() {return m_aControllerList;}
118 protected:
119 ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const;
120 void setController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm,
121 FmXFormController* pParent = NULL);
122 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; }
123 void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm );
124 void dispose();
125 Window* getWindow() const {return m_pWindow;}
128 typedef ::std::vector<FmXPageViewWinRec*> FmWinRecList;
129 typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
130 , ::comphelper::OInterfaceCompare< ::com::sun::star::form::XForm >
131 > SetOfForms;
132 typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
133 , SetOfForms
134 , ::comphelper::OInterfaceCompare< ::com::sun::star::awt::XControlContainer >
135 > MapControlContainerToSetOfForms;
136 class SdrModel;
137 //==================================================================
138 // FmXFormView
139 //==================================================================
140 class FmXFormView : public ::cppu::WeakImplHelper3<
141 ::com::sun::star::form::XFormControllerListener,
142 ::com::sun::star::awt::XFocusListener,
143 ::com::sun::star::container::XContainerListener>
145 friend class FmFormView;
146 friend class FmFormShell;
147 friend class FmXFormShell;
148 friend class FmXPageViewWinRec;
149 class ObjectRemoveListener;
150 friend class ObjectRemoveListener;
152 ::comphelper::ComponentContext m_aContext;
153 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> m_xWindow;
154 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLastCreatedControlModel;
156 FmFormObj* m_pMarkedGrid;
157 FmFormView* m_pView;
158 sal_uIntPtr m_nActivationEvent;
159 sal_uIntPtr m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
160 sal_uIntPtr m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
161 sal_uIntPtr m_nControlWizardEvent; // event for asynchronously setting the focus to a control
163 ::com::sun::star::sdb::SQLErrorEvent
164 m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
166 FmWinRecList m_aWinList; // to be filled in alive mode only
167 MapControlContainerToSetOfForms
168 m_aNeedTabOrderUpdate;
170 // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode
171 SdrMarkList m_aMark;
172 ObjectRemoveListener* m_pWatchStoredList;
174 bool m_bFirstActivation;
175 bool m_isTabOrderUpdateSuspended;
177 FmFormShell* GetFormShell() const;
179 void removeGridWindowListening();
181 protected:
182 FmXFormView( const ::comphelper::ComponentContext& _rContext, FmFormView* _pView );
183 ~FmXFormView();
185 void saveMarkList( sal_Bool _bSmartUnmark = sal_True );
186 void restoreMarkList( SdrMarkList& _rRestoredMarkList );
187 void stopMarkListWatching();
188 void startMarkListWatching();
190 void notifyViewDying( );
191 // notifies this impl class that the anti-impl instance (m_pView) is going to die
193 public:
194 // UNO Anbindung
196 // ::com::sun::star::lang::XEventListener
197 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
199 // ::com::sun::star::container::XContainerListener
200 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
201 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
202 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
204 // ::com::sun::star::form::XFormControllerListener
205 virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
206 virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
208 // XFocusListener
209 virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
210 virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
212 FmFormView* getView() const {return m_pView;}
213 FmWinRecList::const_iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const;
214 const FmWinRecList& getWindowList() const {return m_aWinList;}
216 ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >
217 getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
219 // activation handling
220 inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
221 inline void setHasBeenActivated( ) { m_bFirstActivation = false; }
223 void onFirstViewActivation( const FmFormModel* _pDocModel );
225 /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
226 new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
227 suspendTabOrderUpdate, again.
229 void suspendTabOrderUpdate();
231 /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
232 suspendTabOrderUpdate call.
234 void resumeTabOrderUpdate();
236 void onCreatedFormObject( FmFormObj& _rFormObject );
238 private:
239 FmWinRecList::iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
240 //void addWindow(const SdrPageViewWinRec*);
241 void addWindow(const SdrPageWindow&);
242 void removeWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
243 void Activate(sal_Bool bSync = sal_False);
244 void Deactivate(BOOL bDeactivateController = TRUE);
246 SdrObject* implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor );
247 SdrObject* implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc );
249 static bool createControlLabelPair(
250 const ::comphelper::ComponentContext& _rContext,
251 OutputDevice& _rOutDev,
252 sal_Int32 _nXOffsetMM,
253 sal_Int32 _nYOffsetMM,
254 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
255 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
256 sal_uInt16 _nControlObjectID,
257 const ::rtl::OUString& _rFieldPostfix,
258 UINT32 _nInventor,
259 UINT16 _nLabelObjectID,
260 SdrPage* _pLabelPage,
261 SdrPage* _pControlPage,
262 SdrModel* _pModel,
263 SdrUnoObj*& _rpLabel,
264 SdrUnoObj*& _rpControl
267 bool createControlLabelPair(
268 OutputDevice& _rOutDev,
269 sal_Int32 _nXOffsetMM,
270 sal_Int32 _nYOffsetMM,
271 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
272 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
273 sal_uInt16 _nControlObjectID,
274 const ::rtl::OUString& _rFieldPostfix,
275 SdrUnoObj*& _rpLabel,
276 SdrUnoObj*& _rpControl,
277 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxDataSource = NULL,
278 const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
279 const ::rtl::OUString& _rCommand= ::rtl::OUString(),
280 const sal_Int32 _nCommandType = -1
283 void ObjectRemovedInAliveMode(const SdrObject* pObject);
285 // asynchronously displays an error message. See also OnDelayedErrorMessage.
286 void displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent );
288 // cancels all pending async events
289 void cancelEvents();
291 /// the the auto focus to the first (in terms of the tab order) control
292 void AutoFocus( sal_Bool _bSync = sal_False );
293 DECL_LINK( OnActivate, void* );
294 DECL_LINK( OnAutoFocus, void* );
295 DECL_LINK( OnDelayedErrorMessage, void* );
296 DECL_LINK( OnStartControlWizard, void* );
298 private:
299 ::svxform::DocumentType impl_getDocumentType() const;
304 #endif // _SVX_FMVWIMP_HXX