LCOV - code coverage report
Current view: top level - include/basic - sbxvar.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 31 0.0 %
Date: 2014-04-14 Functions: 0 29 0.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_SBXVAR_HXX
      21             : #define INCLUDED_BASIC_SBXVAR_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
      25             : #include <basic/sbxcore.hxx>
      26             : #include <basic/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           0 :     SbxValues(): pData( NULL ), eType(SbxEMPTY) {}
      72           0 :     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( 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 bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     103             :     virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
     104             : public:
     105           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VALUE,1);
     106             :     TYPEINFO_OVERRIDE();
     107             :     SbxValue();
     108             :     SbxValue( SbxDataType, void* = NULL );
     109             :     SbxValue( const SbxValue& );
     110             :     SbxValue& operator=( const SbxValue& );
     111             :     virtual void Clear() SAL_OVERRIDE;
     112             :     virtual bool IsFixed() const SAL_OVERRIDE;
     113             : 
     114           0 :     bool IsInteger()    const { return GetType() == SbxINTEGER   ; }
     115             :     bool IsLong()       const { return GetType() == SbxLONG      ; }
     116             :     bool IsSingle()     const { return GetType() == SbxSINGLE    ; }
     117           0 :     bool IsDouble()     const { return GetType() == SbxDOUBLE    ; }
     118           0 :     bool IsString()     const { return GetType() == SbxSTRING    ; }
     119             :     bool IsDate()       const { return GetType() == SbxDATE      ; }
     120             :     bool IsCurrency()   const { return GetType() == SbxCURRENCY  ; }
     121           0 :     bool IsObject()     const { return GetType() == SbxOBJECT    ; }
     122             :     bool IsDataObject() const { return GetType() == SbxDATAOBJECT; }
     123           0 :     bool IsBool()       const { return GetType() == SbxBOOL      ; }
     124           0 :     bool IsErr()        const { return GetType() == SbxERROR     ; }
     125           0 :     bool IsEmpty()      const { return GetType() == SbxEMPTY     ; }
     126           0 :     bool IsNull()       const { return GetType() == SbxNULL      ; }
     127             :     bool IsChar()       const { return GetType() == SbxCHAR      ; }
     128             :     bool IsByte()       const { return GetType() == SbxBYTE      ; }
     129             :     bool IsUShort()     const { return GetType() == SbxUSHORT    ; }
     130             :     bool IsULong()      const { return GetType() == SbxULONG     ; }
     131             :     bool IsInt()        const { return GetType() == SbxINT       ; }
     132             :     bool IsUInt()       const { return GetType() == SbxUINT      ; }
     133             :     bool IspChar()      const { return GetType() == SbxLPSTR     ; }
     134             :     bool IsNumeric() const;
     135             :     bool IsNumericRTL() const;  // #41692 Interface for Basic
     136             :     bool ImpIsNumeric( bool bOnlyIntntl ) const;    // Implementation
     137             : 
     138             :     virtual SbxClassType GetClass() const SAL_OVERRIDE;
     139             :     virtual SbxDataType GetType() const SAL_OVERRIDE;
     140             :     SbxDataType GetFullType() const;
     141             :     bool SetType( SbxDataType );
     142             : 
     143             :     virtual bool Get( SbxValues& ) const;
     144           0 :     const SbxValues& GetValues_Impl() const { return aData; }
     145             :     virtual 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             :     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             :     bool PutInteger( sal_Int16 );
     172             :     bool PutLong( sal_Int32 );
     173             :     bool PutSingle( float );
     174             :     bool PutDouble( double );
     175             :     bool PutDate( double );
     176             :     bool PutBool( bool );
     177             :     bool PutErr( sal_uInt16 );
     178             :     bool PutStringExt( const OUString& );     // with extended analysis (International, "sal_True"/"sal_False")
     179             :     bool PutInt64( sal_Int64 );
     180             :     bool PutUInt64( sal_uInt64 );
     181             :     bool PutString( const OUString& );
     182             :     bool PutChar( sal_Unicode );
     183             :     bool PutByte( sal_uInt8 );
     184             :     bool PutUShort( sal_uInt16 );
     185             :     bool PutULong( sal_uInt32 );
     186             :     bool PutEmpty();
     187             :     bool PutNull();
     188             : 
     189             :             // Special methods
     190             :     bool PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
     191             :     bool PutDecimal( SbxDecimal* pDecimal ); // This function is needed for Windows build, don't remove
     192             :     bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) const;
     193             :     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             :     bool PutObject( SbxBase* );
     198             : 
     199             :     virtual bool Convert( SbxDataType );
     200             :     virtual bool Compute( SbxOperator, const SbxValue& );
     201             :     virtual bool Compare( SbxOperator, const SbxValue& ) const;
     202             :     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 bool operator ==( const SbxValue& ) const;
     210             :     inline bool operator !=( const SbxValue& ) const;
     211             :     inline bool operator <( const SbxValue& ) const;
     212             :     inline bool operator >( const SbxValue& ) const;
     213             :     inline bool operator <=( const SbxValue& ) const;
     214             :     inline bool 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 bool SbxValue::operator==( const SbxValue& r ) const
     227             : { return Compare( SbxEQ, r ); }
     228             : 
     229             : inline bool SbxValue::operator!=( const SbxValue& r ) const
     230             : { return Compare( SbxNE, r ); }
     231             : 
     232             : inline bool SbxValue::operator<( const SbxValue& r ) const
     233             : { return Compare( SbxLT, r ); }
     234             : 
     235             : inline bool SbxValue::operator>( const SbxValue& r ) const
     236             : { return Compare( SbxGT, r ); }
     237             : 
     238           0 : inline bool SbxValue::operator<=( const SbxValue& r ) const
     239           0 : { return Compare( SbxLE, r ); }
     240             : 
     241           0 : inline bool 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             : typedef tools::SvRef<SbxArray> SbxArrayRef;
     274             : #endif
     275             : 
     276             : #ifndef SBX_INFO_DECL_DEFINED
     277             : #define SBX_INFO_DECL_DEFINED
     278             : typedef tools::SvRef<SbxInfo> SbxInfoRef;
     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 bool LoadData( SvStream&, sal_uInt16 ) SAL_OVERRIDE;
     304             :     virtual bool StoreData( SvStream& ) const SAL_OVERRIDE;
     305             : public:
     306           0 :     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_VARIABLE,2);
     307             :     TYPEINFO_OVERRIDE();
     308             :     SbxVariable();
     309             :     SbxVariable( SbxDataType, void* = NULL );
     310             :     SbxVariable( const SbxVariable& );
     311             :     SbxVariable& operator=( const SbxVariable& );
     312             : 
     313             :     void Dump( SvStream&, bool bDumpAll=false );
     314             : 
     315             :     virtual void SetName( const OUString& );
     316             :     virtual const OUString& GetName( SbxNameType = SbxNAME_NONE ) const;
     317           0 :     sal_uInt16 GetHashCode() const          { return nHash; }
     318             : 
     319             :     virtual void SetModified( bool ) SAL_OVERRIDE;
     320             : 
     321           0 :     sal_uIntPtr GetUserData() const        { return nUserData; }
     322           0 :     void SetUserData( sal_uIntPtr n ) { nUserData = n;    }
     323             : 
     324             :     virtual SbxDataType  GetType()  const SAL_OVERRIDE;
     325             :     virtual SbxClassType GetClass() const SAL_OVERRIDE;
     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           0 :     bool IsBroadcaster() const { return pCst != NULL; }
     337             :     virtual void Broadcast( sal_uIntPtr nHintId ) SAL_OVERRIDE;
     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             : typedef tools::SvRef<SbxVariable> SbxVariableRef;
     353             : 
     354             : #endif // INCLUDED_BASIC_SBXVAR_HXX
     355             : 
     356             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10