LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/inc - formcontrolling.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 7 71.4 %
Date: 2013-07-09 Functions: 4 6 66.7 %
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             : 
      20             : #ifndef SVX_FORMCONTROLLING_HXX
      21             : #define SVX_FORMCONTROLLING_HXX
      22             : 
      23             : #include <com/sun/star/form/runtime/XFormController.hpp>
      24             : #include <com/sun/star/form/XForm.hpp>
      25             : #include <com/sun/star/form/runtime/FeatureState.hpp>
      26             : #include <com/sun/star/form/runtime/XFormOperations.hpp>
      27             : #include <com/sun/star/sdb/XSQLErrorListener.hpp>
      28             : 
      29             : #include <cppuhelper/implbase2.hxx>
      30             : 
      31             : #include <vector>
      32             : 
      33             : //........................................................................
      34             : namespace svx
      35             : {
      36             : //........................................................................
      37             : 
      38             :     //====================================================================
      39             :     //= FeatureSlotTranslation
      40             :     //====================================================================
      41             :     class FeatureSlotTranslation
      42             :     {
      43             :     public:
      44             :         /// retrieves the feature id for a given feature URL
      45             :         static  sal_Int32       getControllerFeatureSlotIdForURL( const OUString& _rMainURL );
      46             : 
      47             :         /// retrieves the css.form.runtime.FormFeature ID for a given slot ID
      48             :         static  sal_Int16       getFormFeatureForSlotId( sal_Int32 _nSlotId );
      49             : 
      50             :         /// retrieves the slot id for a given css.form.runtime.FormFeature ID
      51             :         static  sal_Int32       getSlotIdForFormFeature( sal_Int16 _nFormFeature );
      52             :     };
      53             : 
      54             :     //====================================================================
      55             :     //= IControllerFeatureInvalidation
      56             :     //====================================================================
      57        1055 :     class IControllerFeatureInvalidation
      58             :     {
      59             :     public:
      60             :         /** invalidates the given features
      61             : 
      62             :             Invalidation means that any user interface representation (such as toolbox buttons), or
      63             :             any dispatches associated with the features in question are potentially out-of-date, and
      64             :             need to be updated
      65             : 
      66             :             @param _rFeatures
      67             :                 Ids of the features to be invalidated.
      68             :         */
      69             :         virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) = 0;
      70             : 
      71             :     protected:
      72        1052 :         ~IControllerFeatureInvalidation() {}
      73             :     };
      74             : 
      75             :     //====================================================================
      76             :     //= ControllerFeatures
      77             :     //====================================================================
      78             :     class FormControllerHelper;
      79             :     /** easier access to an FormControllerHelper instance
      80             :     */
      81             :     class ControllerFeatures
      82             :     {
      83             :     protected:
      84             :         IControllerFeatureInvalidation* m_pInvalidationCallback;    // necessary as long as m_pImpl is not yet constructed
      85             :         FormControllerHelper*           m_pImpl;
      86             : 
      87             :     public:
      88             :         /** standard ctor
      89             : 
      90             :             The instance is not functional until <method>assign</method> is used.
      91             : 
      92             :             @param _pInvalidationCallback
      93             :                 the callback for invalidating feature states
      94             :         */
      95             :         ControllerFeatures(
      96             :             IControllerFeatureInvalidation* _pInvalidationCallback
      97             :         );
      98             : 
      99             :         /** constructs the instance from a <type scope="com::sun::star::form::runtime">XFormController<type> instance
     100             : 
     101             :             @param _rxController
     102             :                 The form controller which the helper should be responsible for. Must not
     103             :                 be <NULL/>, and must have a valid model (form).
     104             : 
     105             :             @param _pInvalidationCallback
     106             :                 the callback for invalidating feature states
     107             :         */
     108             :         ControllerFeatures(
     109             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController,
     110             :             IControllerFeatureInvalidation* _pInvalidationCallback
     111             :         );
     112             : 
     113             :         /// dtor
     114             :         ~ControllerFeatures();
     115             : 
     116             :         /// checks whether the instance is properly assigned to a form and/or controller
     117           0 :         inline bool isAssigned( ) const { return m_pImpl != NULL; }
     118             : 
     119             :         /** assign to a controller
     120             :         */
     121             :         void assign(
     122             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController
     123             :         );
     124             : 
     125             :         /// clears the instance so that it cannot be used afterwards
     126             :         void dispose();
     127             : 
     128             :         // access to the instance which implements the functionality. Not to be used when not assigned
     129           6 :         inline const FormControllerHelper* operator->() const { return m_pImpl; }
     130           0 :         inline       FormControllerHelper* operator->()       { return m_pImpl; }
     131             :         inline const FormControllerHelper& operator*() const  { return *m_pImpl; }
     132             :         inline       FormControllerHelper& operator*()        { return *m_pImpl; }
     133             :     };
     134             : 
     135             :     //====================================================================
     136             :     //= FormControllerHelper
     137             :     //====================================================================
     138             :     typedef ::cppu::WeakImplHelper2 <   ::com::sun::star::form::runtime::XFeatureInvalidation
     139             :                                     ,   ::com::sun::star::sdb::XSQLErrorListener
     140             :                                     >   FormControllerHelper_Base;
     141             :     /** is a helper class which manages form controller functionality (such as moveNext etc.).
     142             : 
     143             :         <p>The class helps implementing form controller functionality, by providing
     144             :         methods to determine the state of, and execute, various common form features.<br/>
     145             :         A <em>feature</em> is for instance moving the form associated with the controller
     146             :         to a certain position, or reloading the form, and so on.</p>
     147             :     */
     148             :     class FormControllerHelper : public FormControllerHelper_Base
     149             :     {
     150             :     protected:
     151             :         IControllerFeatureInvalidation* m_pInvalidationCallback;
     152             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >
     153             :                                         m_xFormOperations;
     154             : 
     155             :         ::com::sun::star::uno::Any      m_aOperationError;
     156             : 
     157             :     public:
     158             :         /** constructs the helper from a <type scope="com::sun::star::form::runtime">XFormController<type> instance
     159             : 
     160             :             @param _rxController
     161             :                 The form controller which the helper should be responsible for. Must not
     162             :                 be <NULL/>, and must have a valid model (form).
     163             :             @param _pInvalidationCallback
     164             :                 the callback for invalidating feature states
     165             :         */
     166             :         FormControllerHelper(
     167             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController,
     168             :             IControllerFeatureInvalidation* _pInvalidationCallback
     169             :         );
     170             : 
     171             :         // forwards to the XFormOperations implementation
     172             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
     173             :                     getCursor() const;
     174             :         void        getState(
     175             :                         sal_Int32 _nSlotId,
     176             :                         ::com::sun::star::form::runtime::FeatureState& _out_rState
     177             :                     ) const;
     178             :         sal_Bool    isEnabled( sal_Int32 _nSlotId ) const;
     179             :         void        execute( sal_Int32 _nSlotId ) const;
     180             :         void        execute( sal_Int32 _nSlotId, const OUString& _rParamName, const ::com::sun::star::uno::Any& _rParamValue ) const;
     181             :         sal_Bool    commitCurrentRecord() const;
     182             :         sal_Bool    commitCurrentControl( ) const;
     183             :         sal_Bool    isInsertionRow() const;
     184             :         sal_Bool    isModifiedRow() const;
     185             : 
     186             :         bool        canDoFormFilter() const;
     187             : 
     188             :         /** disposes this instance.
     189             : 
     190             :             After this method has been called, the instance is not functional anymore
     191             :         */
     192             :         void        dispose();
     193             : 
     194             :         const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >&
     195             :                     getFormOperations() const { return m_xFormOperations; }
     196             :     protected:
     197             :         /// dtor
     198             :         ~FormControllerHelper();
     199             : 
     200             :         // XFeatureInvalidation
     201             :         virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException);
     202             :         virtual void SAL_CALL invalidateAllFeatures() throw (::com::sun::star::uno::RuntimeException);
     203             : 
     204             :         // XSQLErrorListener
     205             :         virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _Event ) throw (::com::sun::star::uno::RuntimeException);
     206             : 
     207             :         // XEventListener
     208             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     209             : 
     210             :     private:
     211             :         enum FormOperation { EXECUTE, EXECUTE_ARGS, COMMIT_CONTROL, COMMIT_RECORD };
     212             : 
     213             :         bool    impl_operateForm_nothrow(
     214             :                     const FormOperation _eWhat,
     215             :                     const sal_Int16 _nFeature,  /* ignore for COMMIT_* */
     216             :                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rArguments /* ignore except for EXECUTE_ARGS */
     217             :                 ) const;
     218           3 :         bool    impl_operateForm_nothrow( const FormOperation _eWhat ) const
     219             :         {
     220           3 :             return impl_operateForm_nothrow( _eWhat, 0, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() );
     221             :         }
     222             :         bool    impl_operateForm_nothrow( const sal_Int16 _nFeature ) const
     223             :         {
     224             :             return impl_operateForm_nothrow( EXECUTE, _nFeature, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() );
     225             :         }
     226             : 
     227             :     private:
     228             :         FormControllerHelper();                                         // never implemented
     229             :         FormControllerHelper( const FormControllerHelper& );            // never implemented
     230             :         FormControllerHelper& operator=( const FormControllerHelper& ); // never implemented
     231             :     };
     232             : 
     233             : //........................................................................
     234             : }   // namespace svx
     235             : //........................................................................
     236             : 
     237             : #endif // SVX_FORMCONTROLLING_HXX
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10