LCOV - code coverage report
Current view: top level - include/oox/ole - vbacontrol.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 7 71.4 %
Date: 2014-11-03 Functions: 5 8 62.5 %
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 INCLUDED_OOX_OLE_VBACONTROL_HXX
      21             : #define INCLUDED_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 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          40 :     const OUString& getName() const { return maName; }
      55             :     /** Returns the position of the control in its parent. */
      56           0 :     const AxPairData& getPosition() const { return maPos; }
      57             :     /** Returns the unique identifier of this control. */
      58           0 :     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             :     OUString     getSubStorageName() const;
      65             :     /** Returns the tab index of the control. */
      66          36 :     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          16 :     ::rtl::OUString getControlSource() { return  maControlSource; }
      77          16 :     ::rtl::OUString getRowSource() { return  maRowSource; }
      78             : protected:
      79             :     OUString     maName;             ///< Name of the control.
      80             :     OUString     maTag;              ///< User defined tag.
      81             :     OUString     maToolTip;          ///< Tool tip for the control.
      82             :     OUString     maControlSource;    ///< Linked cell for the control value in a spreadsheet.
      83             :     OUString     maRowSource;        ///< Source data for the control in a spreadsheet.
      84             : 
      85             :     AxPairData          maPos;              ///< Position in parent container.
      86             :     sal_Int32           mnId;               ///< Control identifier.
      87             :     sal_Int32           mnHelpContextId;    ///< Help context identifier.
      88             :     sal_uInt32          mnFlags;            ///< Various flags.
      89             :     sal_uInt32          mnStreamLen;        ///< Size of control stream data.
      90             :     sal_Int16           mnTabIndex;         ///< Tab order index.
      91             :     sal_uInt16          mnClassIdOrCache;   ///< Class name identifier or GUID cache index.
      92             :     sal_uInt16          mnGroupId;          ///< Group identifier for grouped controls.
      93             : };
      94             : 
      95             : typedef ::boost::shared_ptr< VbaSiteModel > VbaSiteModelRef;
      96             : 
      97             : 
      98             : 
      99             : /** A control that is embedded in a VBA user form or in another container
     100             :     control in a VBA user form.
     101             : 
     102             :     The control may be a 'simple' control with its data stored in the 'o'
     103             :     stream, or it may be a container control with its data stored in an own
     104             :     substorage.
     105             :  */
     106             : class VbaFormControl
     107             : {
     108             : public:
     109             :     explicit            VbaFormControl();
     110             :     virtual             ~VbaFormControl();
     111             : 
     112             :     /** Imports the model from the passed stream or storage, depending on the
     113             :         control's type. Imports all embedded controls, if this is a container. */
     114             :     void                importModelOrStorage(
     115             :                             BinaryInputStream& rInStrm,
     116             :                             StorageBase& rStrg,
     117             :                             const AxClassTable& rClassTable );
     118             : 
     119             :     /** Returns the programmatical name of the control. */
     120             :     OUString     getControlName() const;
     121             : 
     122             :     /** Creates the UNO control model, inserts it into the passed container,
     123             :         and converts all control properties. */
     124             :     void                createAndConvert(
     125             :                             sal_Int32 nCtrlIndex,
     126             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC,
     127             :                             const ControlConverter& rConv ) const;
     128             : 
     129             : protected:
     130             :     /** Creates and imports the control model containing properties of the control. */
     131             :     void                importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable );
     132             :     /** Creates and imports the control model, and imports all embedded
     133             :         controls from the passed substorage. */
     134             :     void                importStorage( StorageBase& rStrg, const AxClassTable& rClassTable );
     135             : 
     136             :     /** Converts all control properties, and inserts and converts embedded controls. */
     137             :     bool                convertProperties(
     138             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
     139             :                             const ControlConverter& rConv,
     140             :                             sal_Int32 nCtrlIndex ) const;
     141             : 
     142             : private:
     143             :     typedef RefVector< VbaFormControl >         VbaFormControlVector;
     144             :     typedef VbaFormControlVector::value_type    VbaFormControlRef;
     145             : 
     146             :     /** Creates the control model according to the current site model. */
     147             :     void                createControlModel( const AxClassTable& rClassTable );
     148             :     /** Imports the site model data containing common properties of the control. */
     149             :     bool                importSiteModel( BinaryInputStream& rInStrm );
     150             : 
     151             :     /** Imports the site models of all embedded controls from the 'f' stream. */
     152             :     bool                importEmbeddedSiteModels( BinaryInputStream& rInStrm );
     153             :     /*  Final processing of all embedded controls after import. */
     154             :     void                finalizeEmbeddedControls();
     155             : 
     156             :     /** Moves the control relative to its current position by the passed distance. */
     157             :     void                moveRelative( const AxPairData& rDistance );
     158             :     /** Moves all embedded controls from their relative position in this
     159             :         control to an absolute position in the parent of this control. */
     160             :     void                moveEmbeddedToAbsoluteParent();
     161             : 
     162             :     /** Functor for comparing controls by their tab index. */
     163             :     static bool         compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight );
     164             : 
     165             : protected:
     166             :     VbaSiteModelRef     mxSiteModel;        ///< Common control properties.
     167             :     ControlModelRef     mxCtrlModel;        ///< Specific control properties.
     168             : 
     169             : private:
     170             :     VbaFormControlVector maControls;        ///< All embedded form controls.
     171             :     AxClassTable         maClassTable;      ///< Class identifiers for exotic embedded controls.
     172             : };
     173             : 
     174             : 
     175             : 
     176           4 : class VbaUserForm : public VbaFormControl
     177             : {
     178             : public:
     179             :     explicit            VbaUserForm(
     180             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     181             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
     182             :                             const GraphicHelper& rGraphicHelper,
     183             :                             bool bDefaultColorBgr = true );
     184             : 
     185             :     /** Imports the form and its embedded controls, and inserts the form with
     186             :         all its controls into the passed dialog library. */
     187             :     void                importForm(
     188             :                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib,
     189             :                            StorageBase& rVbaFormStrg,
     190             :                            const OUString& rModuleName,
     191             :                            rtl_TextEncoding eTextEnc );
     192             : 
     193             : private:
     194             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     195             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
     196             :     ControlConverter    maConverter;
     197             : };
     198             : 
     199             : 
     200             : 
     201             : } // namespace ole
     202             : } // namespace oox
     203             : 
     204             : #endif
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10