LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/basic - sbxvar.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 34 41.2 %
Date: 2013-07-09 Functions: 24 45 53.3 %
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 SBXVAR_HXX
      21             : #define SBXVAR_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
      25             : #include <basic/sbxcore.hxx>
      26             : #include "basicdllapi.h"
      27             : 
      28             : 
      29             : class SbxDecimal;
      30             : 
      31             : struct SbxValues
      32             : {
      33             :     union {
      34             :         sal_uInt8       nByte;
      35             :         sal_uInt16      nUShort;
      36             :         sal_Unicode     nChar;
      37             :         sal_Int16       nInteger;
      38             :         sal_uInt32      nULong;
      39             :         sal_Int32       nLong;
      40             :         unsigned int    nUInt;
      41             :         int             nInt;
      42             :         sal_uInt64      uInt64;
      43             :         sal_Int64       nInt64;
      44             : 
      45             :         float           nSingle;
      46             :         double          nDouble;
      47             : 
      48             :         OUString*       pOUString;
      49             :         SbxDecimal*     pDecimal;
      50             : 
      51             :         SbxBase*        pObj;
      52             : 
      53             :         sal_uInt8*      pByte;
      54             :         sal_uInt16*     pUShort;
      55             :         sal_Unicode*    pChar;
      56             :         sal_Int16*      pInteger;
      57             :         sal_uInt32*     pULong;
      58             :         sal_Int32*      pLong;
      59             :         unsigned int*   pUInt;
      60             :         int*            pInt;
      61             :         sal_uInt64*     puInt64;
      62             :         sal_Int64*      pnInt64;
      63             : 
      64             :         float*          pSingle;
      65             :         double*         pDouble;
      66             : 
      67             :         void*           pData;
      68             :     };
      69             :     SbxDataType  eType;
      70             : 
      71      141233 :     SbxValues(): pData( NULL ), eType(SbxEMPTY) {}
      72       37915 :     SbxValues( SbxDataType e ): eType(e) {}
      73             :     SbxValues( char _nChar ): nChar( _nChar ), eType(SbxCHAR) {}
      74             :     SbxValues( sal_uInt8 _nByte ): nByte( _nByte ), eType(SbxBYTE) {}
      75             :     SbxValues( short _nInteger ): nInteger( _nInteger ), eType(SbxINTEGER ) {}
      76             :     SbxValues( long _nLong ): nLong( _nLong ), eType(SbxLONG) {}
      77             :     SbxValues( sal_uInt16 _nUShort ): nUShort( _nUShort ), eType(SbxUSHORT) {}
      78             :     SbxValues( sal_uIntPtr _nULong ): nULong( _nULong ), eType(SbxULONG) {}
      79             :     SbxValues( int _nInt ): nInt( _nInt ), eType(SbxINT) {}
      80             :     SbxValues( unsigned int _nUInt ): nUInt( _nUInt ), eType(SbxUINT) {}
      81             :     SbxValues( float _nSingle ): nSingle( _nSingle ), eType(SbxSINGLE) {}
      82           0 :     SbxValues( double _nDouble ): nDouble( _nDouble ), eType(SbxDOUBLE) {}
      83             :     SbxValues( const OUString* _pString ): pOUString( (OUString*)_pString ), eType(SbxSTRING) {}
      84             :     SbxValues( SbxBase* _pObj ): pObj( _pObj ), eType(SbxOBJECT) {}
      85             :     SbxValues( sal_Unicode* _pChar ): pChar( _pChar ), eType(SbxLPSTR) {}
      86             :     SbxValues( void* _pData ): pData( _pData ), eType(SbxPOINTER) {}
      87             : 
      88             : };
      89             : 
      90             : class BASIC_DLLPUBLIC SbxValue : public SbxBase
      91             : {
      92             :     // #55226 Transport additional infos
      93             :     BASIC_DLLPRIVATE SbxValue* TheRealValue( sal_Bool bObjInObjError ) const;
      94             :     BASIC_DLLPRIVATE SbxValue* TheRealValue() const;
      95             : protected:
      96             :     SbxValues aData; // Data
      97             :     OUString aPic;  // Picture-String
      98             :     OUString aToolString;  // tool string copy
      99             : 
     100             :     virtual void Broadcast( sal_uIntPtr );      // Broadcast-Call
     101             :     virtual ~SbxValue();
     102             :     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
     103             :     virtual sal_Bool StoreData( SvStream& ) const;
     104             : public:
     105           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VALUE,1);
     106             :     TYPEINFO();
     107             :     SbxValue();
     108             :     SbxValue( SbxDataType, void* = NULL );
     109             :     SbxValue( const SbxValue& );
     110             :     SbxValue& operator=( const SbxValue& );
     111             :     virtual void Clear();
     112             :     virtual sal_Bool IsFixed() const;
     113             : 
     114           0 :     sal_Bool IsInteger() const { return sal_Bool( GetType() == SbxINTEGER  ); }
     115             :     sal_Bool IsLong()    const { return sal_Bool( GetType() == SbxLONG     ); }
     116             :     sal_Bool IsSingle()  const { return sal_Bool( GetType() == SbxSINGLE   ); }
     117           0 :     sal_Bool IsDouble()  const { return sal_Bool( GetType() == SbxDOUBLE   ); }
     118           0 :     sal_Bool IsString()  const { return sal_Bool( GetType() == SbxSTRING   ); }
     119             :     sal_Bool IsDate()    const { return sal_Bool( GetType() == SbxDATE     ); }
     120             :     sal_Bool IsCurrency()const { return sal_Bool( GetType() == SbxCURRENCY ); }
     121           0 :     sal_Bool IsObject()  const { return sal_Bool( GetType() == SbxOBJECT   ); }
     122             :     sal_Bool IsDataObject()const{return sal_Bool( GetType() == SbxDATAOBJECT);}
     123           4 :     sal_Bool IsBool()    const { return sal_Bool( GetType() == SbxBOOL     ); }
     124          22 :     sal_Bool IsErr()     const { return sal_Bool( GetType() == SbxERROR    ); }
     125           1 :     sal_Bool IsEmpty()   const { return sal_Bool( GetType() == SbxEMPTY    ); }
     126        7858 :     sal_Bool IsNull()    const { return sal_Bool( GetType() == SbxNULL     ); }
     127             :     sal_Bool IsChar()    const { return sal_Bool( GetType() == SbxCHAR     ); }
     128             :     sal_Bool IsByte()    const { return sal_Bool( GetType() == SbxBYTE     ); }
     129             :     sal_Bool IsUShort()  const { return sal_Bool( GetType() == SbxUSHORT   ); }
     130             :     sal_Bool IsULong()   const { return sal_Bool( GetType() == SbxULONG    ); }
     131             :     sal_Bool IsInt()     const { return sal_Bool( GetType() == SbxINT      ); }
     132             :     sal_Bool IsUInt()    const { return sal_Bool( GetType() == SbxUINT     ); }
     133             :     sal_Bool IspChar()   const { return sal_Bool( GetType() == SbxLPSTR    ); }
     134             :     sal_Bool IsNumeric() const;
     135             :     sal_Bool IsNumericRTL() const;  // #41692 Interface for Basic
     136             :     sal_Bool ImpIsNumeric( bool bOnlyIntntl ) const;    // Implementation
     137             : 
     138             :     virtual SbxClassType GetClass() const;
     139             :     virtual SbxDataType GetType() const;
     140             :     SbxDataType GetFullType() const;
     141             :     sal_Bool SetType( SbxDataType );
     142             : 
     143             :     virtual sal_Bool Get( SbxValues& ) const;
     144        1390 :     const SbxValues& GetValues_Impl() const { return aData; }
     145             :     virtual sal_Bool Put( const SbxValues& );
     146             : 
     147             :     inline SbxValues * data() { return &aData; }
     148             : 
     149             :     sal_Unicode GetChar() const;
     150             :     sal_Int16   GetInteger() const;
     151             :     sal_Int32   GetLong() const;
     152             :     sal_Int64   GetInt64() const;
     153             :     sal_uInt64  GetUInt64() const;
     154             : 
     155             :     sal_Int64   GetCurrency() const;
     156             :     SbxDecimal* GetDecimal() const;
     157             : 
     158             :     float       GetSingle() const;
     159             :     double      GetDouble() const;
     160             :     double      GetDate() const;
     161             : 
     162             :     sal_Bool    GetBool() const;
     163             :     const OUString&   GetCoreString() const;
     164             :     OUString    GetOUString() const;
     165             : 
     166             :     SbxBase*    GetObject() const;
     167             :     sal_uInt8   GetByte() const;
     168             :     sal_uInt16  GetUShort() const;
     169             :     sal_uInt32  GetULong() const;
     170             : 
     171             :     sal_Bool PutInteger( sal_Int16 );
     172             :     sal_Bool PutLong( sal_Int32 );
     173             :     sal_Bool PutSingle( float );
     174             :     sal_Bool PutDouble( double );
     175             :     sal_Bool PutDate( double );
     176             :     sal_Bool PutBool( sal_Bool );
     177             :     sal_Bool PutErr( sal_uInt16 );
     178             :     sal_Bool PutStringExt( const OUString& );     // with extended analysis (International, "sal_True"/"sal_False")
     179             :     sal_Bool PutInt64( sal_Int64 );
     180             :     sal_Bool PutUInt64( sal_uInt64 );
     181             :     sal_Bool PutString( const OUString& );
     182             :     sal_Bool PutChar( sal_Unicode );
     183             :     sal_Bool PutByte( sal_uInt8 );
     184             :     sal_Bool PutUShort( sal_uInt16 );
     185             :     sal_Bool PutULong( sal_uInt32 );
     186             :     sal_Bool PutEmpty();
     187             :     sal_Bool PutNull();
     188             : 
     189             :             // Special methods
     190             :     sal_Bool PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
     191             :     sal_Bool PutDecimal( SbxDecimal* pDecimal ); // This function is needed for Windows build, don't remove
     192             :     sal_Bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
     193             :     sal_Bool PutCurrency( const sal_Int64& );
     194             :             // Interface for CDbl in Basic
     195             :     static SbxError ScanNumIntnl( const OUString& rSrc, double& nVal, bool bSingle = false );
     196             : 
     197             :     sal_Bool PutObject( SbxBase* );
     198             : 
     199             :     virtual sal_Bool Convert( SbxDataType );
     200             :     virtual sal_Bool Compute( SbxOperator, const SbxValue& );
     201             :     virtual sal_Bool Compare( SbxOperator, const SbxValue& ) const;
     202             :     sal_Bool Scan( const OUString&, sal_uInt16* = NULL );
     203             :     void Format( OUString&, const OUString* = NULL ) const;
     204             : 
     205             :     // The following operators are definied for easier handling.
     206             :     // TODO: Ensure error conditions (overflow, conversions)
     207             :     // are taken into consideration in Compute and Compare
     208             : 
     209             :     inline int operator ==( const SbxValue& ) const;
     210             :     inline int operator !=( const SbxValue& ) const;
     211             :     inline int operator <( const SbxValue& ) const;
     212             :     inline int operator >( const SbxValue& ) const;
     213             :     inline int operator <=( const SbxValue& ) const;
     214             :     inline int operator >=( const SbxValue& ) const;
     215             : 
     216             :     inline SbxValue& operator *=( const SbxValue& );
     217             :     inline SbxValue& operator /=( const SbxValue& );
     218             :     inline SbxValue& operator %=( const SbxValue& );
     219             :     inline SbxValue& operator +=( const SbxValue& );
     220             :     inline SbxValue& operator -=( const SbxValue& );
     221             :     inline SbxValue& operator &=( const SbxValue& );
     222             :     inline SbxValue& operator |=( const SbxValue& );
     223             :     inline SbxValue& operator ^=( const SbxValue& );
     224             : };
     225             : 
     226             : inline int SbxValue::operator==( const SbxValue& r ) const
     227             : { return Compare( SbxEQ, r ); }
     228             : 
     229             : inline int SbxValue::operator!=( const SbxValue& r ) const
     230             : { return Compare( SbxNE, r ); }
     231             : 
     232             : inline int SbxValue::operator<( const SbxValue& r ) const
     233             : { return Compare( SbxLT, r ); }
     234             : 
     235             : inline int SbxValue::operator>( const SbxValue& r ) const
     236             : { return Compare( SbxGT, r ); }
     237             : 
     238           0 : inline int SbxValue::operator<=( const SbxValue& r ) const
     239           0 : { return Compare( SbxLE, r ); }
     240             : 
     241           0 : inline int SbxValue::operator>=( const SbxValue& r ) const
     242           0 : { return Compare( SbxGE, r ); }
     243             : 
     244           0 : inline SbxValue& SbxValue::operator*=( const SbxValue& r )
     245           0 : { Compute( SbxMUL, r ); return *this; }
     246             : 
     247           0 : inline SbxValue& SbxValue::operator/=( const SbxValue& r )
     248           0 : { Compute( SbxDIV, r ); return *this; }
     249             : 
     250             : inline SbxValue& SbxValue::operator%=( const SbxValue& r )
     251             : { Compute( SbxMOD, r ); return *this; }
     252             : 
     253           0 : inline SbxValue& SbxValue::operator+=( const SbxValue& r )
     254           0 : { Compute( SbxPLUS, r ); return *this; }
     255             : 
     256           0 : inline SbxValue& SbxValue::operator-=( const SbxValue& r )
     257           0 : { Compute( SbxMINUS, r ); return *this; }
     258             : 
     259             : inline SbxValue& SbxValue::operator&=( const SbxValue& r )
     260             : { Compute( SbxAND, r ); return *this; }
     261             : 
     262             : inline SbxValue& SbxValue::operator|=( const SbxValue& r )
     263             : { Compute( SbxOR, r ); return *this; }
     264             : 
     265             : inline SbxValue& SbxValue::operator^=( const SbxValue& r )
     266             : { Compute( SbxXOR, r ); return *this; }
     267             : 
     268             : class SbxArray;
     269             : class SbxInfo;
     270             : 
     271             : #ifndef SBX_ARRAY_DECL_DEFINED
     272             : #define SBX_ARRAY_DECL_DEFINED
     273      798301 : SV_DECL_REF(SbxArray)
     274             : #endif
     275             : 
     276             : #ifndef SBX_INFO_DECL_DEFINED
     277             : #define SBX_INFO_DECL_DEFINED
     278       51509 : SV_DECL_REF(SbxInfo)
     279             : #endif
     280             : 
     281             : class SfxBroadcaster;
     282             : 
     283             : class SbxVariableImpl;
     284             : class StarBASIC;
     285             : 
     286             : class BASIC_DLLPUBLIC SbxVariable : public SbxValue
     287             : {
     288             :     friend class SbMethod;
     289             : 
     290             :     SbxVariableImpl* mpSbxVariableImpl; // Impl data
     291             :     SfxBroadcaster*  pCst;              // Broadcaster, if needed
     292             :     OUString         maName;            // Name, if available
     293             :     SbxArrayRef      mpPar;             // Parameter-Array, if set
     294             :     sal_uInt16       nHash;             // Hash-ID for search
     295             : 
     296             :     BASIC_DLLPRIVATE SbxVariableImpl* getImpl( void );
     297             : 
     298             : protected:
     299             :     SbxInfoRef  pInfo;              // Probably called information
     300             :     sal_uIntPtr nUserData;          // User data for Call()
     301             :     SbxObject* pParent;             // Currently attached object
     302             :     virtual ~SbxVariable();
     303             :     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
     304             :     virtual sal_Bool StoreData( SvStream& ) const;
     305             : public:
     306           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VARIABLE,2);
     307             :     TYPEINFO();
     308             :     SbxVariable();
     309             :     SbxVariable( SbxDataType, void* = NULL );
     310             :     SbxVariable( const SbxVariable& );
     311             :     SbxVariable& operator=( const SbxVariable& );
     312             : 
     313             :     void Dump( SvStream&, sal_Bool bDumpAll=sal_False );
     314             : 
     315             :     virtual void SetName( const OUString& );
     316             :     virtual const OUString& GetName( SbxNameType = SbxNAME_NONE ) const;
     317      828554 :     sal_uInt16 GetHashCode() const          { return nHash; }
     318             : 
     319             :     virtual void SetModified( sal_Bool );
     320             : 
     321        6014 :     sal_uIntPtr GetUserData() const        { return nUserData; }
     322        5882 :     void SetUserData( sal_uIntPtr n ) { nUserData = n;    }
     323             : 
     324             :     virtual SbxDataType  GetType()  const;
     325             :     virtual SbxClassType GetClass() const;
     326             : 
     327             :     // Parameter-Interface
     328             :     virtual SbxInfo* GetInfo();
     329             :     void SetInfo( SbxInfo* p );
     330             :     void SetParameters( SbxArray* p );
     331             :     SbxArray* GetParameters() const;
     332             : 
     333             :     // Sfx-Broadcasting-Support:
     334             :     // Due to data reduction and better DLL-hierarchie currently via casting
     335             :     SfxBroadcaster& GetBroadcaster();
     336       21441 :     sal_Bool IsBroadcaster() const { return sal_Bool( pCst != NULL ); }
     337             :     virtual void Broadcast( sal_uIntPtr nHintId );
     338             : 
     339           0 :     inline const SbxObject* GetParent() const { return pParent; }
     340             :     SbxObject* GetParent();
     341             :     virtual void SetParent( SbxObject* );
     342             : 
     343             :     const OUString& GetDeclareClassName( void );
     344             :     void SetDeclareClassName( const OUString& );
     345             :     void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener,
     346             :                          StarBASIC* pParentBasic );
     347             :     void ClearComListener( void );
     348             : 
     349             :     static sal_uInt16 MakeHashCode( const OUString& rName );
     350             : };
     351             : 
     352     1451858 : SV_DECL_REF(SbxVariable)
     353             : 
     354             : #endif  // SBXVAR_HXX
     355             : 
     356             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10