LCOV - code coverage report
Current view: top level - include/basic - sbx.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 10 17 58.8 %
Date: 2014-11-03 Functions: 9 25 36.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             : 
      20             : #ifndef INCLUDED_BASIC_SBX_HXX
      21             : #define INCLUDED_BASIC_SBX_HXX
      22             : 
      23             : #include <tools/ref.hxx>
      24             : #include <svl/smplhint.hxx>
      25             : #include <svl/lstner.hxx>
      26             : 
      27             : #include <basic/sbxdef.hxx>
      28             : #include <basic/sbxform.hxx>
      29             : #include <basic/sbxobj.hxx>
      30             : #include <basic/sbxprop.hxx>
      31             : #include <basic/sbxmeth.hxx>
      32             : #include <basic/basicdllapi.h>
      33             : 
      34             : #include <boost/ptr_container/ptr_vector.hpp>
      35             : #include <vector>
      36             : 
      37             : class SvStream;
      38             : class SbxBase;
      39             : class SbxVariable;
      40             : class SbxProperty;
      41             : class SbxMethod;
      42             : class SbxObject;
      43             : class SbxArray;
      44             : class SbxDimArray;
      45             : class SbxFactory;
      46             : 
      47             : class SfxBroadcaster;
      48             : 
      49             : // Parameter information
      50             : struct SbxParamInfo
      51             : {
      52             :     const OUString aName;          // Name of the parameter
      53             :     SbxBaseRef     aTypeRef;       // Object, if object type
      54             :     SbxDataType    eType;          // Data type
      55             :     SbxFlagBits    nFlags;         // Flag-Bits
      56             :     sal_uInt32     nUserData;      // IDs etc.
      57         954 :     SbxParamInfo( const OUString& s, SbxDataType t, SbxFlagBits n, SbxBase* b = NULL )
      58         954 :         : aName( s ), aTypeRef( b ), eType( t ), nFlags( n ), nUserData( 0 ) {}
      59         954 :     ~SbxParamInfo() {}
      60             : };
      61             : 
      62             : typedef boost::ptr_vector<SbxParamInfo> SbxParams;
      63             : 
      64             : class BASIC_DLLPUBLIC SbxInfo : public SvRefBase
      65             : {
      66             :     friend class SbxVariable;
      67             :     friend class SbMethod;
      68             : 
      69             :     OUString        aComment;
      70             :     OUString        aHelpFile;
      71             :     sal_uInt32      nHelpId;
      72             :     SbxParams       aParams;
      73             : 
      74             : protected:
      75             :     bool LoadData( SvStream&, sal_uInt16 );
      76             :     bool StoreData( SvStream& ) const;
      77             :     virtual ~SbxInfo();
      78             : public:
      79             :     SbxInfo();
      80             :     SbxInfo( const OUString&, sal_uInt32 );
      81             : 
      82             :     void                AddParam( const OUString&, SbxDataType, SbxFlagBits=SBX_READ );
      83             :     const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
      84           0 :     const OUString&     GetComment() const              { return aComment; }
      85           0 :     const OUString&     GetHelpFile() const             { return aHelpFile; }
      86           0 :     sal_uInt32          GetHelpId() const               { return nHelpId;   }
      87             : 
      88         818 :     void                SetComment( const OUString& r )   { aComment = r; }
      89             :     void                SetHelpFile( const OUString& r )  { aHelpFile = r; }
      90             :     void                SetHelpId( sal_uInt32 nId )         { nHelpId = nId; }
      91             : };
      92             : 
      93      168436 : class BASIC_DLLPUBLIC SbxHint : public SfxSimpleHint
      94             : {
      95             :     SbxVariable* pVar;
      96             : public:
      97      168436 :     SbxHint( sal_uIntPtr n, SbxVariable* v ) : SfxSimpleHint( n ), pVar( v ) {}
      98      169198 :     SbxVariable* GetVar() const { return pVar; }
      99             : };
     100             : 
     101             : // SbxAlias is an alias for a var or object
     102             : class BASIC_DLLPUBLIC SbxAlias : public SbxVariable, public SfxListener
     103             : {
     104             :     SbxVariableRef xAlias;
     105             :     virtual ~SbxAlias();
     106             :     virtual void Broadcast( sal_uIntPtr ) SAL_OVERRIDE;
     107             :     virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
     108             :                              const SfxHint& rHint, const TypeId& rHintType ) SAL_OVERRIDE;
     109             : public:
     110             :     SbxAlias( const SbxAlias& );
     111             :     SbxAlias& operator=( const SbxAlias& );
     112             : };
     113             : 
     114             : // SbxArray is an unidimensional, dynamic Array
     115             : // The variables convert from SbxVariablen. Put()/Insert() into the
     116             : // declared datatype, if they are not SbxVARIANT.
     117             : 
     118             : struct SbxVarEntry;
     119             : 
     120             : class BASIC_DLLPUBLIC SbxArray : public SbxBase
     121             : {
     122             :     typedef std::vector<SbxVarEntry*> VarEntriesType;
     123             : 
     124             : // #100883 Method to set method directly to parameter array
     125             :     friend class SbMethod;
     126             :     friend class SbClassModuleObject;
     127             :     friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
     128             :     BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
     129             : 
     130             :     VarEntriesType* mpVarEntries;          // The variables
     131             : 
     132             : protected:
     133             :     SbxDataType eType;            // Data type of the array
     134             :     virtual ~SbxArray();
     135             :     virtual bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     136             :     virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
     137             : 
     138             : public:
     139           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_ARRAY,1);
     140             :     TYPEINFO_OVERRIDE();
     141             :     SbxArray( SbxDataType=SbxVARIANT );
     142             :     SbxArray( const SbxArray& );
     143             :     SbxArray& operator=( const SbxArray& );
     144             :     virtual void Clear() SAL_OVERRIDE;
     145             :     sal_uInt16           Count() const;
     146             :     virtual SbxDataType  GetType() const SAL_OVERRIDE;
     147             :     virtual SbxClassType GetClass() const SAL_OVERRIDE;
     148             :     SbxVariableRef&      GetRef( sal_uInt16 );
     149             :     SbxVariable*         Get( sal_uInt16 );
     150             :     void                 Put( SbxVariable*, sal_uInt16 );
     151             :     void                 Insert( SbxVariable*, sal_uInt16 );
     152             :     void                 Remove( sal_uInt16 );
     153             :     void                 Remove( SbxVariable* );
     154             :     void                 Merge( SbxArray* );
     155             :     OUString             GetAlias( sal_uInt16 );
     156             :     void                 PutAlias( const OUString&, sal_uInt16 );
     157             :     SbxVariable*         FindUserData( sal_uInt32 nUserData );
     158             :     virtual SbxVariable* Find( const OUString&, SbxClassType );
     159             : 
     160             :     // Additional methods for 32-bit indices
     161             :     sal_uInt32           Count32() const;
     162             :     SbxVariableRef&      GetRef32( sal_uInt32 );
     163             :     SbxVariable*         Get32( sal_uInt32 );
     164             :     void                 Put32( SbxVariable*, sal_uInt32 );
     165             :     void                 Insert32( SbxVariable*, sal_uInt32 );
     166             :     void                 Remove32( sal_uInt32 );
     167             : };
     168             : 
     169             : // SbxDimArray is an array that can dimensioned using BASIC conventions.
     170             : struct SbxDim {                 // an array-dimension:
     171             :     sal_Int32 nLbound, nUbound; // Limitations
     172             :     sal_Int32 nSize;            // Number of elements
     173             : };
     174             : 
     175             : class BASIC_DLLPUBLIC SbxDimArray : public SbxArray
     176             : {
     177             :     std::vector<SbxDim> m_vDimensions;     // Dimension table
     178             :     BASIC_DLLPRIVATE void AddDimImpl32( sal_Int32, sal_Int32, bool bAllowSize0 );
     179             :     bool mbHasFixedSize;
     180             : protected:
     181             :     sal_uInt16  Offset( const short* );
     182             :     sal_uInt32  Offset32( const sal_Int32* );
     183             :     sal_uInt32  Offset32( SbxArray* );
     184             :     virtual bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     185             :     virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
     186             :     virtual ~SbxDimArray();
     187             : public:
     188           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DIMARRAY,1);
     189             :     TYPEINFO_OVERRIDE();
     190             :     SbxDimArray( SbxDataType=SbxVARIANT );
     191             :     SbxDimArray( const SbxDimArray& );
     192             :     SbxDimArray& operator=( const SbxDimArray& );
     193             :     virtual void Clear() SAL_OVERRIDE;
     194             :     using SbxArray::GetRef;
     195             :     using SbxArray::Get;
     196             :     SbxVariable* Get( const short* );
     197             :     using SbxArray::Put;
     198             :     void Put( SbxVariable*, const short* );
     199             :     SbxVariable* Get( SbxArray* );
     200             : 
     201         110 :     short  GetDims() const { return m_vDimensions.size();}
     202             :     void   AddDim( short, short );
     203             :     void   unoAddDim( short, short );
     204             :     bool   GetDim( short, short&, short& ) const;
     205             : 
     206             :     using SbxArray::GetRef32;
     207             :     using SbxArray::Get32;
     208             :     SbxVariable* Get32( const sal_Int32* );
     209             :     using SbxArray::Put32;
     210             :     void Put32( SbxVariable*, const sal_Int32* );
     211             :     void   AddDim32( sal_Int32, sal_Int32 );
     212             :     void   unoAddDim32( sal_Int32, sal_Int32 );
     213             :     bool   GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
     214           8 :     bool hasFixedSize() { return mbHasFixedSize; };
     215          34 :     void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
     216             : };
     217             : 
     218             : class BASIC_DLLPUBLIC SbxCollection : public SbxObject
     219             : {
     220             :     BASIC_DLLPRIVATE void Initialize();
     221             : protected:
     222             :     virtual ~SbxCollection();
     223             :     virtual bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     224             :     virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
     225             :                              const SfxHint& rHint, const TypeId& rHintType ) SAL_OVERRIDE;
     226             :     // Overridable methods (why not pure virtual?):
     227             :     virtual void CollAdd( SbxArray* pPar );
     228             :     virtual void CollItem( SbxArray* pPar );
     229             :     virtual void CollRemove( SbxArray* pPar );
     230             : 
     231             : public:
     232           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_COLLECTION,1);
     233             :     TYPEINFO_OVERRIDE();
     234             :     SbxCollection( const OUString& rClassname );
     235             :     SbxCollection( const SbxCollection& );
     236             :     SbxCollection& operator=( const SbxCollection& );
     237             :     virtual SbxVariable* FindUserData( sal_uInt32 nUserData ) SAL_OVERRIDE;
     238             :     virtual SbxVariable* Find( const OUString&, SbxClassType ) SAL_OVERRIDE;
     239             :     virtual void Clear() SAL_OVERRIDE;
     240             : };
     241             : 
     242             : class BASIC_DLLPUBLIC SbxStdCollection : public SbxCollection
     243             : {
     244             : protected:
     245             :     OUString aElemClass;
     246             :     bool bAddRemoveOk;
     247             :     virtual ~SbxStdCollection();
     248             :     virtual bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     249             :     virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
     250             :     virtual void CollAdd( SbxArray* pPar ) SAL_OVERRIDE;
     251             :     virtual void CollRemove( SbxArray* pPar ) SAL_OVERRIDE;
     252             : public:
     253           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_FIXCOLLECTION,1);
     254             :     TYPEINFO_OVERRIDE();
     255             :     SbxStdCollection( const OUString& rClassname, const OUString& rElemClass, bool=true );
     256             :     SbxStdCollection( const SbxStdCollection& );
     257             :     SbxStdCollection& operator=( const SbxStdCollection& );
     258             :     virtual void Insert( SbxVariable* ) SAL_OVERRIDE;
     259             :     const OUString& GetElementClass() const { return aElemClass; }
     260             : };
     261             : 
     262             : #ifndef SBX_ARRAY_DECL_DEFINED
     263             : #define SBX_ARRAY_DECL_DEFINED
     264             : typedef tools::SvRef<SbxArray> SbxArrayRef;
     265             : #endif
     266             : 
     267             : #ifndef SBX_INFO_DECL_DEFINED
     268             : #define SBX_INFO_DECL_DEFINED
     269             : typedef tools::SvRef<SbxInfo> SbxInfoRef;
     270             : #endif
     271             : 
     272             : typedef tools::SvRef<SbxDimArray> SbxDimArrayRef;
     273             : 
     274             : #endif
     275             : 
     276             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10