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

           Branch data     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 OOX_OLE_VBACONTROL_HXX
      21                 :            : #define OOX_OLE_VBACONTROL_HXX
      22                 :            : 
      23                 :            : #include "oox/ole/axcontrol.hxx"
      24                 :            : #include <com/sun/star/frame/XModel.hpp>
      25                 :            : 
      26                 :            : namespace com { namespace sun { namespace star {
      27                 :            :     namespace container { class XNameContainer; }
      28                 :            :     namespace uno { class XComponentContext; }
      29                 :            : } } }
      30                 :            : 
      31                 :            : namespace oox { class StorageBase; }
      32                 :            : 
      33                 :            : namespace oox {
      34                 :            : namespace ole {
      35                 :            : 
      36                 :            : // ============================================================================
      37                 :            : 
      38                 :            : /** Common properties for all controls that are part of a VBA user form or of
      39                 :            :     another container control in a VBA user form. */
      40                 :            : class VbaSiteModel
      41                 :            : {
      42                 :            : public:
      43                 :            :     explicit            VbaSiteModel();
      44                 :            :     virtual             ~VbaSiteModel();
      45                 :            : 
      46                 :            :     /** Allows to set single properties specified by XML token identifier. */
      47                 :            :     void                importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
      48                 :            :     /** Imports the site model data from the passed input stream. */
      49                 :            :     bool                importBinaryModel( BinaryInputStream& rInStrm );
      50                 :            :     /** Moves the control relative to its current position by the passed distance. */
      51                 :            :     void                moveRelative( const AxPairData& rDistance );
      52                 :            : 
      53                 :            :     /** Returns the programmatical name of the control. */
      54                 :          0 :     inline const ::rtl::OUString& getName() const { return maName; }
      55                 :            :     /** Returns the position of the control in its parent. */
      56                 :            :     inline const AxPairData& getPosition() const { return maPos; }
      57                 :            :     /** Returns the unique identifier of this control. */
      58                 :          0 :     inline sal_Int32    getId() const { return mnId; }
      59                 :            :     /** Returns true, if this control is a container control. */
      60                 :            :     bool                isContainer() const;
      61                 :            :     /** Returns the length of the stream data for stream based controls. */
      62                 :            :     sal_uInt32          getStreamLength() const;
      63                 :            :     /** Returns the name of the substorage for the container control data. */
      64                 :            :     ::rtl::OUString     getSubStorageName() const;
      65                 :            :     /** Returns the tab index of the control. */
      66                 :          0 :     inline sal_Int16    getTabIndex() const { return mnTabIndex; }
      67                 :            : 
      68                 :            :     /** Tries to create the control model according to the site model. */
      69                 :            :     ControlModelRef     createControlModel( const AxClassTable& rClassTable ) const;
      70                 :            :     /** Converts all form site properties. */
      71                 :            :     void                convertProperties(
      72                 :            :                             PropertyMap& rPropMap,
      73                 :            :                             const ControlConverter& rConv,
      74                 :            :                             ApiControlType eCtrlType,
      75                 :            :                             sal_Int32 nCtrlIndex ) const;
      76                 :            : 
      77                 :            :     /** Binds the passed control model to the data sources. The implementation
      78                 :            :         will check which source types are supported. */
      79                 :            :     void                bindToSources(
      80                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
      81                 :            :                             const ControlConverter& rConv ) const;
      82                 :            : 
      83                 :            : protected:
      84                 :            :     ::rtl::OUString     maName;             ///< Name of the control.
      85                 :            :     ::rtl::OUString     maTag;              ///< User defined tag.
      86                 :            :     ::rtl::OUString     maToolTip;          ///< Tool tip for the control.
      87                 :            :     ::rtl::OUString     maControlSource;    ///< Linked cell for the control value in a spreadsheet.
      88                 :            :     ::rtl::OUString     maRowSource;        ///< Source data for the control in a spreadsheet.
      89                 :            : 
      90                 :            :     AxPairData          maPos;              ///< Position in parent container.
      91                 :            :     sal_Int32           mnId;               ///< Control identifier.
      92                 :            :     sal_Int32           mnHelpContextId;    ///< Help context identifier.
      93                 :            :     sal_uInt32          mnFlags;            ///< Various flags.
      94                 :            :     sal_uInt32          mnStreamLen;        ///< Size of control stream data.
      95                 :            :     sal_Int16           mnTabIndex;         ///< Tab order index.
      96                 :            :     sal_uInt16          mnClassIdOrCache;   ///< Class name identifier or GUID cache index.
      97                 :            :     sal_uInt16          mnGroupId;          ///< Group identifier for grouped controls.
      98                 :            : };
      99                 :            : 
     100                 :            : typedef ::boost::shared_ptr< VbaSiteModel > VbaSiteModelRef;
     101                 :            : 
     102                 :            : // ============================================================================
     103                 :            : 
     104                 :            : /** A control that is embedded in a VBA user form or in another container
     105                 :            :     control in a VBA user form.
     106                 :            : 
     107                 :            :     The control may be a 'simple' control with its data stored in the 'o'
     108                 :            :     stream, or it may be a container control with its data stored in an own
     109                 :            :     substorage.
     110                 :            :  */
     111                 :            : class VbaFormControl
     112                 :            : {
     113                 :            : public:
     114                 :            :     explicit            VbaFormControl();
     115                 :            :     virtual             ~VbaFormControl();
     116                 :            : 
     117                 :            :     /** Imports the model from the passed stream or storage, depending on the
     118                 :            :         control's type. Imports all embedded controls, if this is a container. */
     119                 :            :     void                importModelOrStorage(
     120                 :            :                             BinaryInputStream& rInStrm,
     121                 :            :                             StorageBase& rStrg,
     122                 :            :                             const AxClassTable& rClassTable );
     123                 :            : 
     124                 :            :     /** Returns the programmatical name of the control. */
     125                 :            :     ::rtl::OUString     getControlName() const;
     126                 :            :     /** Returns the unique identifier of this control. */
     127                 :            :     sal_Int32           getControlId() const;
     128                 :            : 
     129                 :            :     /** Creates the UNO control model, inserts it into the passed container,
     130                 :            :         and converts all control properties. */
     131                 :            :     void                createAndConvert(
     132                 :            :                             sal_Int32 nCtrlIndex,
     133                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC,
     134                 :            :                             const ControlConverter& rConv ) const;
     135                 :            : 
     136                 :            : protected:
     137                 :            :     /** Creates and imports the control model containing properties of the control. */
     138                 :            :     void                importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable );
     139                 :            :     /** Creates and imports the control model, and imports all embedded
     140                 :            :         controls from the passed substorage. */
     141                 :            :     void                importStorage( StorageBase& rStrg, const AxClassTable& rClassTable );
     142                 :            : 
     143                 :            :     /** Converts all control properties, and inserts and converts embedded controls. */
     144                 :            :     bool                convertProperties(
     145                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
     146                 :            :                             const ControlConverter& rConv,
     147                 :            :                             sal_Int32 nCtrlIndex ) const;
     148                 :            : 
     149                 :            : private:
     150                 :            :     typedef RefVector< VbaFormControl >         VbaFormControlVector;
     151                 :            :     typedef VbaFormControlVector::value_type    VbaFormControlRef;
     152                 :            : 
     153                 :            :     /** Creates the control model according to the current site model. */
     154                 :            :     void                createControlModel( const AxClassTable& rClassTable );
     155                 :            :     /** Imports the site model data containing common properties of the control. */
     156                 :            :     bool                importSiteModel( BinaryInputStream& rInStrm );
     157                 :            : 
     158                 :            :     /** Imports the site models of all embedded controls from the 'f' stream. */
     159                 :            :     bool                importEmbeddedSiteModels( BinaryInputStream& rInStrm );
     160                 :            :     /*  Final processing of all embedded controls after import. */
     161                 :            :     void                finalizeEmbeddedControls( StorageBase& rStrg );
     162                 :            : 
     163                 :            :     /** Functor for comparing controls by their tab index. */
     164                 :            :     static bool         compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight );
     165                 :            : 
     166                 :            : protected:
     167                 :            :     VbaSiteModelRef     mxSiteModel;        ///< Common control properties.
     168                 :            :     ControlModelRef     mxCtrlModel;        ///< Specific control properties.
     169                 :            : 
     170                 :            : private:
     171                 :            :     VbaFormControlVector maControls;        ///< All embedded form controls.
     172                 :            :     AxClassTable         maClassTable;      ///< Class identifiers for exotic embedded controls.
     173                 :            : };
     174                 :            : 
     175                 :            : // ============================================================================
     176                 :            : 
     177 [ #  # ][ #  # ]:          0 : class VbaUserForm : public VbaFormControl
     178                 :            : {
     179                 :            : public:
     180                 :            :     explicit            VbaUserForm(
     181                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     182                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
     183                 :            :                             const GraphicHelper& rGraphicHelper,
     184                 :            :                             bool bDefaultColorBgr = true );
     185                 :            : 
     186                 :            :     /** Imports the form and its embedded controls, and inserts the form with
     187                 :            :         all its controls into the passed dialog library. */
     188                 :            :     void                importForm(
     189                 :            :                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
     190                 :            :                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib,
     191                 :            :                            StorageBase& rVbaFormStrg,
     192                 :            :                            const ::rtl::OUString& rModuleName,
     193                 :            :                            rtl_TextEncoding eTextEnc );
     194                 :            : 
     195                 :            : private:
     196                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     197                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
     198                 :            :     ControlConverter    maConverter;
     199                 :            : };
     200                 :            : 
     201                 :            : // ============================================================================
     202                 :            : 
     203                 :            : } // namespace ole
     204                 :            : } // namespace oox
     205                 :            : 
     206                 :            : #endif
     207                 :            : 
     208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10