LCOV - code coverage report
Current view: top level - svx/source/inc - fmvwimp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 6 100.0 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      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.
      15                 :            :  *
      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).
      21                 :            :  *
      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.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _SVX_FMVWIMP_HXX
      29                 :            : #define _SVX_FMVWIMP_HXX
      30                 :            : 
      31                 :            : #include "svx/svdmark.hxx"
      32                 :            : #include "fmdocumentclassification.hxx"
      33                 :            : 
      34                 :            : #include <com/sun/star/form/XForm.hpp>
      35                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      36                 :            : #include <com/sun/star/container/XEnumeration.hpp>
      37                 :            : #include <com/sun/star/form/runtime/XFormController.hpp>
      38                 :            : #include <com/sun/star/form/runtime/XFormControllerContext.hpp>
      39                 :            : #include <com/sun/star/container/XContainerListener.hpp>
      40                 :            : #include <com/sun/star/container/ContainerEvent.hpp>
      41                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      42                 :            : #include <com/sun/star/awt/XFocusListener.hpp>
      43                 :            : #include <com/sun/star/sdb/SQLErrorEvent.hpp>
      44                 :            : #include <com/sun/star/sdbc/XDataSource.hpp>
      45                 :            : 
      46                 :            : #include <comphelper/stl_types.hxx>
      47                 :            : #include <tools/link.hxx>
      48                 :            : #include <cppuhelper/implbase2.hxx>
      49                 :            : #include <cppuhelper/implbase3.hxx>
      50                 :            : #include <comphelper/uno3.hxx>
      51                 :            : #include <comphelper/componentcontext.hxx>
      52                 :            : #include <rtl/ref.hxx>
      53                 :            : 
      54                 :            : class SdrPageWindow;
      55                 :            : 
      56                 :            : class SdrObject;
      57                 :            : class FmFormObj;
      58                 :            : class FmFormModel;
      59                 :            : class FmFormView;
      60                 :            : class FmFormShell;
      61                 :            : class Window;
      62                 :            : class OutputDevice;
      63                 :            : class SdrUnoObj;
      64                 :            : 
      65                 :            : namespace com { namespace sun { namespace star {
      66                 :            :     namespace awt {
      67                 :            :         class XControl;
      68                 :            :         class XWindow;
      69                 :            :     }
      70                 :            :     namespace beans {
      71                 :            :         class XPropertySet;
      72                 :            :     }
      73                 :            :     namespace util {
      74                 :            :         class XNumberFormats;
      75                 :            :     }
      76                 :            : }}}
      77                 :            : 
      78                 :            : class FmXFormView;
      79                 :            : 
      80                 :            : namespace svx {
      81                 :            :     class ODataAccessDescriptor;
      82                 :            :     struct OXFormsDescriptor;
      83                 :            : }
      84                 :            : 
      85                 :            : //==================================================================
      86                 :            : // FormViewPageWindowAdapter
      87                 :            : //==================================================================
      88                 :            : typedef ::cppu::WeakImplHelper2 <   ::com::sun::star::container::XIndexAccess
      89                 :            :                                 ,   ::com::sun::star::form::runtime::XFormControllerContext
      90                 :            :                                 >   FormViewPageWindowAdapter_Base;
      91                 :            : 
      92                 :            : class FormViewPageWindowAdapter : public FormViewPageWindowAdapter_Base
      93                 :            : {
      94                 :            :     friend class FmXFormView;
      95                 :            : 
      96                 :            :     ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >   m_aControllerList;
      97                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >                            m_xControlContainer;
      98                 :            :     ::comphelper::ComponentContext                                                                          m_aContext;
      99                 :            :     FmXFormView*                m_pViewImpl;
     100                 :            :     Window*                     m_pWindow;
     101                 :            : 
     102                 :            : protected:
     103                 :            :     ~FormViewPageWindowAdapter();
     104                 :            : 
     105                 :            : public:
     106                 :            :     FormViewPageWindowAdapter(  const ::comphelper::ComponentContext& _rContext,
     107                 :            :         const SdrPageWindow&, FmXFormView* pView);
     108                 :            :         //const SdrPageViewWinRec*, FmXFormView* pView);
     109                 :            : 
     110                 :            :     // XElementAccess
     111                 :            :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
     112                 :            :     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
     113                 :            : 
     114                 :            :     // XEnumerationAccess
     115                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >  SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
     116                 :            : 
     117                 :            :     // XIndexAccess
     118                 :            :     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
     119                 :            :     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);
     120                 :            : 
     121                 :            :     // XFormControllerContext
     122                 :            :     virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException);
     123                 :            : 
     124                 :         77 :     const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;}
     125                 :            : 
     126                 :            : protected:
     127                 :            :     ::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;
     128                 :            :     void setController(
     129                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm,
     130                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController );
     131                 :        180 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >  getControlContainer() const { return m_xControlContainer; }
     132                 :            :     void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm );
     133                 :            :     void dispose();
     134                 :         31 :     Window* getWindow() const {return m_pWindow;}
     135                 :            : };
     136                 :            : 
     137                 :            : typedef ::rtl::Reference< FormViewPageWindowAdapter >   PFormViewPageWindowAdapter;
     138                 :            : typedef ::std::vector< PFormViewPageWindowAdapter >     PageWindowAdapterList;
     139                 :            : typedef ::std::set  <   ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
     140                 :            :                     ,   ::comphelper::OInterfaceCompare< ::com::sun::star::form::XForm >
     141                 :            :                     >   SetOfForms;
     142                 :            : typedef ::std::map  <   ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
     143                 :            :                     ,   SetOfForms
     144                 :            :                     ,   ::comphelper::OInterfaceCompare< ::com::sun::star::awt::XControlContainer >
     145                 :            :                     >   MapControlContainerToSetOfForms;
     146                 :            : class SdrModel;
     147                 :            : //==================================================================
     148                 :            : // FmXFormView
     149                 :            : //==================================================================
     150                 :            : class FmXFormView : public ::cppu::WeakImplHelper3<
     151                 :            :                             ::com::sun::star::form::XFormControllerListener,
     152                 :            :                             ::com::sun::star::awt::XFocusListener,
     153                 :            :                             ::com::sun::star::container::XContainerListener>
     154                 :            : {
     155                 :            :     friend class FmFormView;
     156                 :            :     friend class FmFormShell;
     157                 :            :     friend class FmXFormShell;
     158                 :            :     friend class FormViewPageWindowAdapter;
     159                 :            :     class ObjectRemoveListener;
     160                 :            :     friend class ObjectRemoveListener;
     161                 :            : 
     162                 :            :     ::comphelper::ComponentContext                                                      m_aContext;
     163                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>                   m_xWindow;
     164                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >           m_xLastCreatedControlModel;
     165                 :            : 
     166                 :            :     FmFormObj*      m_pMarkedGrid;
     167                 :            :     FmFormView*     m_pView;
     168                 :            :     sal_uIntPtr     m_nActivationEvent;
     169                 :            :     sal_uIntPtr     m_nErrorMessageEvent;   // event for an asynchronous error message. See also m_aAsyncError
     170                 :            :     sal_uIntPtr     m_nAutoFocusEvent;      // event for asynchronously setting the focus to a control
     171                 :            :     sal_uIntPtr     m_nControlWizardEvent;  // event for asynchronously setting the focus to a control
     172                 :            : 
     173                 :            :     ::com::sun::star::sdb::SQLErrorEvent
     174                 :            :                     m_aAsyncError;          // error event which is to be displayed asyn. See m_nErrorMessageEvent.
     175                 :            : 
     176                 :            :     PageWindowAdapterList
     177                 :            :                     m_aPageWindowAdapters;  // to be filled in alive mode only
     178                 :            :     MapControlContainerToSetOfForms
     179                 :            :                     m_aNeedTabOrderUpdate;
     180                 :            : 
     181                 :            :     // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode
     182                 :            :     SdrMarkList             m_aMark;
     183                 :            :     ObjectRemoveListener*   m_pWatchStoredList;
     184                 :            : 
     185                 :            :     bool            m_bFirstActivation;
     186                 :            :     bool            m_isTabOrderUpdateSuspended;
     187                 :            : 
     188                 :            :     FmFormShell* GetFormShell() const;
     189                 :            : 
     190                 :            :     void removeGridWindowListening();
     191                 :            : 
     192                 :            : protected:
     193                 :            :     FmXFormView( const ::comphelper::ComponentContext& _rContext, FmFormView* _pView );
     194                 :            :     ~FmXFormView();
     195                 :            : 
     196                 :            :     void    saveMarkList( sal_Bool _bSmartUnmark = sal_True );
     197                 :            :     void    restoreMarkList( SdrMarkList& _rRestoredMarkList );
     198                 :            :     void    stopMarkListWatching();
     199                 :            :     void    startMarkListWatching();
     200                 :            : 
     201                 :            :     void    notifyViewDying( );
     202                 :            :         // notifies this impl class that the anti-impl instance (m_pView) is going to die
     203                 :            : 
     204                 :            : public:
     205                 :            :     // UNO Anbindung
     206                 :            : 
     207                 :            : // ::com::sun::star::lang::XEventListener
     208                 :            :     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
     209                 :            : 
     210                 :            : // ::com::sun::star::container::XContainerListener
     211                 :            :     virtual void SAL_CALL elementInserted(const  ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     212                 :            :     virtual void SAL_CALL elementReplaced(const  ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     213                 :            :     virtual void SAL_CALL elementRemoved(const  ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
     214                 :            : 
     215                 :            : // ::com::sun::star::form::XFormControllerListener
     216                 :            :     virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
     217                 :            :     virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
     218                 :            : 
     219                 :            :     // XFocusListener
     220                 :            :     virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
     221                 :            :     virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
     222                 :            : 
     223                 :         12 :     FmFormView* getView() const {return m_pView;}
     224                 :            :     PFormViewPageWindowAdapter  findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const;
     225                 :            : 
     226                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >
     227                 :            :             getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
     228                 :            : 
     229                 :            :     // activation handling
     230                 :         97 :     inline  bool        hasEverBeenActivated( ) const { return !m_bFirstActivation; }
     231                 :         69 :     inline  void        setHasBeenActivated( ) { m_bFirstActivation = false; }
     232                 :            : 
     233                 :            :             void        onFirstViewActivation( const FmFormModel* _pDocModel );
     234                 :            : 
     235                 :            :     /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
     236                 :            :         new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
     237                 :            :         suspendTabOrderUpdate, again.
     238                 :            :     */
     239                 :            :     void    suspendTabOrderUpdate();
     240                 :            : 
     241                 :            :     /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
     242                 :            :         suspendTabOrderUpdate call.
     243                 :            :     */
     244                 :            :     void    resumeTabOrderUpdate();
     245                 :            : 
     246                 :            :     void    onCreatedFormObject( FmFormObj& _rFormObject );
     247                 :            : 
     248                 :            :     static bool
     249                 :            :             isFocusable(
     250                 :            :                 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& i_rControl
     251                 :            :             );
     252                 :            : 
     253                 :            : private:
     254                 :            :     //void addWindow(const SdrPageViewWinRec*);
     255                 :            :     void addWindow(const SdrPageWindow&);
     256                 :            :     void removeWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
     257                 :            :     void Activate(sal_Bool bSync = sal_False);
     258                 :            :     void Deactivate(sal_Bool bDeactivateController = sal_True);
     259                 :            : 
     260                 :            :     SdrObject*  implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor );
     261                 :            :     SdrObject*  implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc );
     262                 :            : 
     263                 :            :     static bool createControlLabelPair(
     264                 :            :         const ::comphelper::ComponentContext& _rContext,
     265                 :            :         OutputDevice& _rOutDev,
     266                 :            :         sal_Int32 _nXOffsetMM,
     267                 :            :         sal_Int32 _nYOffsetMM,
     268                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
     269                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
     270                 :            :         sal_uInt16 _nControlObjectID,
     271                 :            :         const ::rtl::OUString& _rFieldPostfix,
     272                 :            :         sal_uInt32 _nInventor,
     273                 :            :         sal_uInt16 _nLabelObjectID,
     274                 :            :         SdrPage* _pLabelPage,
     275                 :            :         SdrPage* _pControlPage,
     276                 :            :         SdrModel* _pModel,
     277                 :            :         SdrUnoObj*& _rpLabel,
     278                 :            :         SdrUnoObj*& _rpControl
     279                 :            :     );
     280                 :            : 
     281                 :            :     bool    createControlLabelPair(
     282                 :            :         OutputDevice& _rOutDev,
     283                 :            :         sal_Int32 _nXOffsetMM,
     284                 :            :         sal_Int32 _nYOffsetMM,
     285                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
     286                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
     287                 :            :         sal_uInt16 _nControlObjectID,
     288                 :            :         const ::rtl::OUString& _rFieldPostfix,
     289                 :            :         SdrUnoObj*& _rpLabel,
     290                 :            :         SdrUnoObj*& _rpControl,
     291                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxDataSource = NULL,
     292                 :            :         const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
     293                 :            :         const ::rtl::OUString& _rCommand= ::rtl::OUString(),
     294                 :            :         const sal_Int32 _nCommandType = -1
     295                 :            :     );
     296                 :            : 
     297                 :            :     void ObjectRemovedInAliveMode(const SdrObject* pObject);
     298                 :            : 
     299                 :            :     // asynchronously displays an error message. See also OnDelayedErrorMessage.
     300                 :            :     void    displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent );
     301                 :            : 
     302                 :            :     // cancels all pending async events
     303                 :            :     void cancelEvents();
     304                 :            : 
     305                 :            :     /// the the auto focus to the first (in terms of the tab order) control
     306                 :            :     void AutoFocus( sal_Bool _bSync = sal_False );
     307                 :            :     DECL_LINK( OnActivate, void* );
     308                 :            :     DECL_LINK( OnAutoFocus, void* );
     309                 :            :     DECL_LINK( OnDelayedErrorMessage, void* );
     310                 :            :     DECL_LINK( OnStartControlWizard, void* );
     311                 :            : 
     312                 :            : private:
     313                 :            :     ::svxform::DocumentType impl_getDocumentType() const;
     314                 :            : };
     315                 :            : 
     316                 :            : 
     317                 :            : 
     318                 :            : #endif // _SVX_FMVWIMP_HXX
     319                 :            : 
     320                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10