13334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 33334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 43334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 53334a7e6SAndrew Rist * distributed with this work for additional information 63334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 73334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 83334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 93334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 103334a7e6SAndrew Rist * 113334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 123334a7e6SAndrew Rist * 133334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 143334a7e6SAndrew Rist * software distributed under the License is distributed on an 153334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 163334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 173334a7e6SAndrew Rist * specific language governing permissions and limitations 183334a7e6SAndrew Rist * under the License. 193334a7e6SAndrew Rist * 203334a7e6SAndrew Rist *************************************************************/ 213334a7e6SAndrew Rist 223334a7e6SAndrew Rist 23cdf0e10cSrcweir #ifndef _SVX_FMVWIMP_HXX 24cdf0e10cSrcweir #define _SVX_FMVWIMP_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "svx/svdmark.hxx" 27cdf0e10cSrcweir #include "fmdocumentclassification.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir /** === begin UNO includes === **/ 30cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp> 31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 32cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp> 33cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormController.hpp> 34cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormControllerContext.hpp> 35cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp> 36cdf0e10cSrcweir #include <com/sun/star/container/ContainerEvent.hpp> 37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 38cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp> 39cdf0e10cSrcweir #include <com/sun/star/sdb/SQLErrorEvent.hpp> 40cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 41cdf0e10cSrcweir /** === end UNO includes === **/ 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 44cdf0e10cSrcweir #include <tools/link.hxx> 45cdf0e10cSrcweir #include <tools/string.hxx> 46cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 47cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 48cdf0e10cSrcweir #include <comphelper/uno3.hxx> 49cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 50cdf0e10cSrcweir #include <rtl/ref.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir //class SdrPageViewWinRec; 53cdf0e10cSrcweir class SdrPageWindow; 54cdf0e10cSrcweir 55cdf0e10cSrcweir class SdrPageView; 56cdf0e10cSrcweir class SdrObject; 57cdf0e10cSrcweir class FmFormObj; 58cdf0e10cSrcweir class FmFormModel; 59cdf0e10cSrcweir class FmFormView; 60cdf0e10cSrcweir class FmFormShell; 61cdf0e10cSrcweir class Window; 62cdf0e10cSrcweir class OutputDevice; 63cdf0e10cSrcweir class SdrUnoObj; 64cdf0e10cSrcweir class SdrView; 65cdf0e10cSrcweir 66cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(awt,XControl) 67cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(awt,XWindow) 68cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(beans,XPropertySet) 69cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(util,XNumberFormats) 70cdf0e10cSrcweir 71cdf0e10cSrcweir class FmXFormView; 72cdf0e10cSrcweir 73cdf0e10cSrcweir namespace svx { 74cdf0e10cSrcweir class ODataAccessDescriptor; 75cdf0e10cSrcweir struct OXFormsDescriptor; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir //================================================================== 79cdf0e10cSrcweir // FormViewPageWindowAdapter 80cdf0e10cSrcweir //================================================================== 81cdf0e10cSrcweir typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XIndexAccess 82cdf0e10cSrcweir , ::com::sun::star::form::runtime::XFormControllerContext 83cdf0e10cSrcweir > FormViewPageWindowAdapter_Base; 84cdf0e10cSrcweir 85cdf0e10cSrcweir class FormViewPageWindowAdapter : public FormViewPageWindowAdapter_Base 86cdf0e10cSrcweir { 87cdf0e10cSrcweir friend class FmXFormView; 88cdf0e10cSrcweir 89cdf0e10cSrcweir ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > m_aControllerList; 90cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer; 91cdf0e10cSrcweir ::comphelper::ComponentContext m_aContext; 92cdf0e10cSrcweir FmXFormView* m_pViewImpl; 93cdf0e10cSrcweir Window* m_pWindow; 94cdf0e10cSrcweir 95cdf0e10cSrcweir protected: 96cdf0e10cSrcweir ~FormViewPageWindowAdapter(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir public: 99cdf0e10cSrcweir FormViewPageWindowAdapter( const ::comphelper::ComponentContext& _rContext, 100cdf0e10cSrcweir const SdrPageWindow&, FmXFormView* pView); 101cdf0e10cSrcweir //const SdrPageViewWinRec*, FmXFormView* pView); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // XElementAccess 104cdf0e10cSrcweir virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XEnumerationAccess 108cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir 110cdf0e10cSrcweir // XIndexAccess 111cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir 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); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // XFormControllerContext 115cdf0e10cSrcweir virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException); 116cdf0e10cSrcweir GetList()117cdf0e10cSrcweir const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;} 118cdf0e10cSrcweir 119cdf0e10cSrcweir protected: 120cdf0e10cSrcweir ::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; 121cdf0e10cSrcweir void setController( 122cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, 123cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController ); getControlContainer() const124cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; } 125cdf0e10cSrcweir void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); 126cdf0e10cSrcweir void dispose(); getWindow() const127cdf0e10cSrcweir Window* getWindow() const {return m_pWindow;} 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir typedef ::rtl::Reference< FormViewPageWindowAdapter > PFormViewPageWindowAdapter; 131cdf0e10cSrcweir typedef ::std::vector< PFormViewPageWindowAdapter > PageWindowAdapterList; 132cdf0e10cSrcweir typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > 133cdf0e10cSrcweir , ::comphelper::OInterfaceCompare< ::com::sun::star::form::XForm > 134cdf0e10cSrcweir > SetOfForms; 135cdf0e10cSrcweir typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > 136cdf0e10cSrcweir , SetOfForms 137cdf0e10cSrcweir , ::comphelper::OInterfaceCompare< ::com::sun::star::awt::XControlContainer > 138cdf0e10cSrcweir > MapControlContainerToSetOfForms; 139cdf0e10cSrcweir class SdrModel; 140cdf0e10cSrcweir //================================================================== 141cdf0e10cSrcweir // FmXFormView 142cdf0e10cSrcweir //================================================================== 143cdf0e10cSrcweir class FmXFormView : public ::cppu::WeakImplHelper3< 144cdf0e10cSrcweir ::com::sun::star::form::XFormControllerListener, 145cdf0e10cSrcweir ::com::sun::star::awt::XFocusListener, 146cdf0e10cSrcweir ::com::sun::star::container::XContainerListener> 147cdf0e10cSrcweir { 148cdf0e10cSrcweir friend class FmFormView; 149cdf0e10cSrcweir friend class FmFormShell; 150cdf0e10cSrcweir friend class FmXFormShell; 151cdf0e10cSrcweir friend class FormViewPageWindowAdapter; 152cdf0e10cSrcweir class ObjectRemoveListener; 153cdf0e10cSrcweir friend class ObjectRemoveListener; 154cdf0e10cSrcweir 155cdf0e10cSrcweir ::comphelper::ComponentContext m_aContext; 156cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> m_xWindow; 157cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLastCreatedControlModel; 158cdf0e10cSrcweir 159cdf0e10cSrcweir FmFormObj* m_pMarkedGrid; 160cdf0e10cSrcweir FmFormView* m_pView; 161cdf0e10cSrcweir sal_uIntPtr m_nActivationEvent; 162cdf0e10cSrcweir sal_uIntPtr m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError 163cdf0e10cSrcweir sal_uIntPtr m_nAutoFocusEvent; // event for asynchronously setting the focus to a control 164cdf0e10cSrcweir sal_uIntPtr m_nControlWizardEvent; // event for asynchronously setting the focus to a control 165cdf0e10cSrcweir 166cdf0e10cSrcweir ::com::sun::star::sdb::SQLErrorEvent 167cdf0e10cSrcweir m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent. 168cdf0e10cSrcweir 169cdf0e10cSrcweir PageWindowAdapterList 170cdf0e10cSrcweir m_aPageWindowAdapters; // to be filled in alive mode only 171cdf0e10cSrcweir MapControlContainerToSetOfForms 172cdf0e10cSrcweir m_aNeedTabOrderUpdate; 173cdf0e10cSrcweir 174cdf0e10cSrcweir // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode 175cdf0e10cSrcweir SdrMarkList m_aMark; 176cdf0e10cSrcweir ObjectRemoveListener* m_pWatchStoredList; 177cdf0e10cSrcweir 178cdf0e10cSrcweir bool m_bFirstActivation; 179cdf0e10cSrcweir bool m_isTabOrderUpdateSuspended; 180cdf0e10cSrcweir 181cdf0e10cSrcweir FmFormShell* GetFormShell() const; 182cdf0e10cSrcweir 183cdf0e10cSrcweir void removeGridWindowListening(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir protected: 186cdf0e10cSrcweir FmXFormView( const ::comphelper::ComponentContext& _rContext, FmFormView* _pView ); 187cdf0e10cSrcweir ~FmXFormView(); 188cdf0e10cSrcweir 189cdf0e10cSrcweir void saveMarkList( sal_Bool _bSmartUnmark = sal_True ); 190cdf0e10cSrcweir void restoreMarkList( SdrMarkList& _rRestoredMarkList ); 191cdf0e10cSrcweir void stopMarkListWatching(); 192cdf0e10cSrcweir void startMarkListWatching(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir void notifyViewDying( ); 195cdf0e10cSrcweir // notifies this impl class that the anti-impl instance (m_pView) is going to die 196cdf0e10cSrcweir 197cdf0e10cSrcweir public: 198cdf0e10cSrcweir // UNO Anbindung 199cdf0e10cSrcweir 200cdf0e10cSrcweir // ::com::sun::star::lang::XEventListener 201cdf0e10cSrcweir virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException); 202cdf0e10cSrcweir 203cdf0e10cSrcweir // ::com::sun::star::container::XContainerListener 204cdf0e10cSrcweir virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException); 205cdf0e10cSrcweir virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException); 206cdf0e10cSrcweir virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException); 207cdf0e10cSrcweir 208cdf0e10cSrcweir // ::com::sun::star::form::XFormControllerListener 209cdf0e10cSrcweir virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException); 210cdf0e10cSrcweir virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException); 211cdf0e10cSrcweir 212cdf0e10cSrcweir // XFocusListener 213cdf0e10cSrcweir virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); 214cdf0e10cSrcweir virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); 215cdf0e10cSrcweir getView() const216cdf0e10cSrcweir FmFormView* getView() const {return m_pView;} 217cdf0e10cSrcweir PFormViewPageWindowAdapter findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const; 218cdf0e10cSrcweir 219cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > 220cdf0e10cSrcweir getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; 221cdf0e10cSrcweir 222cdf0e10cSrcweir // activation handling hasEverBeenActivated() const223cdf0e10cSrcweir inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation; } setHasBeenActivated()224cdf0e10cSrcweir inline void setHasBeenActivated( ) { m_bFirstActivation = false; } 225cdf0e10cSrcweir 226cdf0e10cSrcweir void onFirstViewActivation( const FmFormModel* _pDocModel ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view, 229cdf0e10cSrcweir new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling 230cdf0e10cSrcweir suspendTabOrderUpdate, again. 231cdf0e10cSrcweir */ 232cdf0e10cSrcweir void suspendTabOrderUpdate(); 233cdf0e10cSrcweir 234cdf0e10cSrcweir /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last 235cdf0e10cSrcweir suspendTabOrderUpdate call. 236cdf0e10cSrcweir */ 237cdf0e10cSrcweir void resumeTabOrderUpdate(); 238cdf0e10cSrcweir 239cdf0e10cSrcweir void onCreatedFormObject( FmFormObj& _rFormObject ); 240cdf0e10cSrcweir 241cdf0e10cSrcweir static bool 242cdf0e10cSrcweir isFocusable( 243cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& i_rControl 244cdf0e10cSrcweir ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir private: 247cdf0e10cSrcweir //void addWindow(const SdrPageViewWinRec*); 248cdf0e10cSrcweir void addWindow(const SdrPageWindow&); 249cdf0e10cSrcweir void removeWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ); 250cdf0e10cSrcweir void Activate(sal_Bool bSync = sal_False); 251cdf0e10cSrcweir void Deactivate(sal_Bool bDeactivateController = sal_True); 252cdf0e10cSrcweir 253cdf0e10cSrcweir SdrObject* implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor ); 254cdf0e10cSrcweir SdrObject* implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc ); 255cdf0e10cSrcweir 256cdf0e10cSrcweir static bool createControlLabelPair( 257cdf0e10cSrcweir const ::comphelper::ComponentContext& _rContext, 258cdf0e10cSrcweir OutputDevice& _rOutDev, 259cdf0e10cSrcweir sal_Int32 _nXOffsetMM, 260cdf0e10cSrcweir sal_Int32 _nYOffsetMM, 261cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, 262cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats, 263cdf0e10cSrcweir sal_uInt16 _nControlObjectID, 264cdf0e10cSrcweir const ::rtl::OUString& _rFieldPostfix, 265cdf0e10cSrcweir sal_uInt32 _nInventor, 266cdf0e10cSrcweir sal_uInt16 _nLabelObjectID, 267cdf0e10cSrcweir SdrPage* _pLabelPage, 268cdf0e10cSrcweir SdrPage* _pControlPage, 269cdf0e10cSrcweir SdrModel* _pModel, 270cdf0e10cSrcweir SdrUnoObj*& _rpLabel, 271cdf0e10cSrcweir SdrUnoObj*& _rpControl 272cdf0e10cSrcweir ); 273cdf0e10cSrcweir 274cdf0e10cSrcweir bool createControlLabelPair( 275cdf0e10cSrcweir OutputDevice& _rOutDev, 276cdf0e10cSrcweir sal_Int32 _nXOffsetMM, 277cdf0e10cSrcweir sal_Int32 _nYOffsetMM, 278cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, 279cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats, 280cdf0e10cSrcweir sal_uInt16 _nControlObjectID, 281cdf0e10cSrcweir const ::rtl::OUString& _rFieldPostfix, 282cdf0e10cSrcweir SdrUnoObj*& _rpLabel, 283cdf0e10cSrcweir SdrUnoObj*& _rpControl, 284cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxDataSource = NULL, 285cdf0e10cSrcweir const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(), 286cdf0e10cSrcweir const ::rtl::OUString& _rCommand= ::rtl::OUString(), 287cdf0e10cSrcweir const sal_Int32 _nCommandType = -1 288cdf0e10cSrcweir ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir void ObjectRemovedInAliveMode(const SdrObject* pObject); 291cdf0e10cSrcweir 292cdf0e10cSrcweir // asynchronously displays an error message. See also OnDelayedErrorMessage. 293cdf0e10cSrcweir void displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ); 294cdf0e10cSrcweir 295cdf0e10cSrcweir // cancels all pending async events 296cdf0e10cSrcweir void cancelEvents(); 297cdf0e10cSrcweir 298*fb0b81f5Smseidel /// the auto focus to the first (in terms of the tab order) control 299cdf0e10cSrcweir void AutoFocus( sal_Bool _bSync = sal_False ); 300cdf0e10cSrcweir DECL_LINK( OnActivate, void* ); 301cdf0e10cSrcweir DECL_LINK( OnAutoFocus, void* ); 302cdf0e10cSrcweir DECL_LINK( OnDelayedErrorMessage, void* ); 303cdf0e10cSrcweir DECL_LINK( OnStartControlWizard, void* ); 304cdf0e10cSrcweir 305cdf0e10cSrcweir private: 306cdf0e10cSrcweir ::svxform::DocumentType impl_getDocumentType() const; 307cdf0e10cSrcweir }; 308cdf0e10cSrcweir 309cdf0e10cSrcweir 310cdf0e10cSrcweir 311cdf0e10cSrcweir #endif // _SVX_FMVWIMP_HXX 312cdf0e10cSrcweir 313