LCOV - code coverage report
Current view: top level - svx/source/inc - fmvwimp.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 6 100.0 %
Date: 2014-11-03 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10