LibreOffice Module basic (master) 1
sbxdec.hxx
Go to the documentation of this file.
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#pragma once
21
22#ifdef _WIN32
23#include <prewin.h>
24#include <postwin.h>
25#include <comutil.h>
26#include <oleauto.h>
27#endif
28
29#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
30
31
32// Decimal support
33// Implementation only for windows
34
36{
37 friend void releaseDecimalPtr( SbxDecimal*& rpDecimal );
38
39#ifdef _WIN32
40 DECIMAL maDec;
41#endif
42 sal_Int32 mnRefCount;
43
44public:
45 SbxDecimal();
46 SbxDecimal( const SbxDecimal& rDec );
47 explicit SbxDecimal( const css::bridge::oleautomation::Decimal& rAutomationDec );
48
49 void addRef()
50 { mnRefCount++; }
51
52 void fillAutomationDecimal( css::bridge::oleautomation::Decimal& rAutomationDec );
53
54 void setChar( sal_Unicode val );
55 void setByte( sal_uInt8 val );
56 void setShort( sal_Int16 val );
57 void setLong( sal_Int32 val );
58 void setUShort( sal_uInt16 val );
59 void setULong( sal_uInt32 val );
60 bool setSingle( float val );
61 bool setDouble( double val );
62 void setInt( int val );
63 void setUInt( unsigned int val );
64 bool setString( OUString* pOUString );
65 void setDecimal( SbxDecimal const * pDecimal )
66 {
67#ifdef _WIN32
68 if( pDecimal )
69 maDec = pDecimal->maDec;
70#else
71 (void)pDecimal;
72#endif
73 }
74
75 bool getChar( sal_Unicode& rVal );
76 bool getShort( sal_Int16& rVal );
77 bool getLong( sal_Int32& rVal );
78 bool getUShort( sal_uInt16& rVal );
79 bool getULong( sal_uInt32& rVal );
80 bool getSingle( float& rVal );
81 bool getDouble( double& rVal );
82 void getString( OUString& rString );
83
84 bool operator -= ( const SbxDecimal &r );
85 bool operator += ( const SbxDecimal &r );
86 bool operator /= ( const SbxDecimal &r );
87 bool operator *= ( const SbxDecimal &r );
88 bool neg();
89
90 bool isZero() const;
91
92 // must match the return values of the Microsoft VarDecCmp Automation function
93 enum class CmpResult { LT, EQ, GT };
94 friend CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight );
95};
96
97/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator-=(const SbxDecimal &r)
Definition: sbxdec.cxx:283
bool getChar(sal_Unicode &rVal)
Definition: sbxdec.cxx:330
void setInt(int val)
Definition: sbxdec.cxx:326
bool getULong(sal_uInt32 &rVal)
Definition: sbxdec.cxx:334
void setByte(sal_uInt8 val)
Definition: sbxdec.cxx:319
void setLong(sal_Int32 val)
Definition: sbxdec.cxx:321
bool getShort(sal_Int16 &rVal)
Definition: sbxdec.cxx:331
void setDecimal(SbxDecimal const *pDecimal)
Definition: sbxdec.hxx:65
bool getLong(sal_Int32 &rVal)
Definition: sbxdec.cxx:332
void setUShort(sal_uInt16 val)
Definition: sbxdec.cxx:322
void setULong(sal_uInt32 val)
Definition: sbxdec.cxx:323
void addRef()
Definition: sbxdec.hxx:49
bool operator/=(const SbxDecimal &r)
Definition: sbxdec.cxx:293
void getString(OUString &rString)
Definition: sbxdec.cxx:340
bool getDouble(double &rVal)
Definition: sbxdec.cxx:336
bool operator*=(const SbxDecimal &r)
Definition: sbxdec.cxx:298
friend CmpResult compare(const SbxDecimal &rLeft, const SbxDecimal &rRight)
bool operator+=(const SbxDecimal &r)
Definition: sbxdec.cxx:288
bool setString(OUString *pOUString)
Definition: sbxdec.cxx:328
sal_Int32 mnRefCount
Definition: sbxdec.hxx:42
bool neg()
Definition: sbxdec.cxx:303
bool getSingle(float &rVal)
Definition: sbxdec.cxx:335
void setChar(sal_Unicode val)
Definition: sbxdec.cxx:318
bool isZero() const
Definition: sbxdec.cxx:308
void fillAutomationDecimal(css::bridge::oleautomation::Decimal &rAutomationDec)
Definition: sbxdec.cxx:64
friend void releaseDecimalPtr(SbxDecimal *&rpDecimal)
Definition: sbxdec.cxx:77
bool setSingle(float val)
Definition: sbxdec.cxx:324
bool setDouble(double val)
Definition: sbxdec.cxx:325
bool getUShort(sal_uInt16 &rVal)
Definition: sbxdec.cxx:333
SbxDecimal()
Definition: sbxdec.cxx:32
void setUInt(unsigned int val)
Definition: sbxdec.cxx:327
void setShort(sal_Int16 val)
Definition: sbxdec.cxx:320
@ GT
Definition: token.hxx:73
@ LT
Definition: token.hxx:73
@ EQ
Definition: token.hxx:73
unsigned char sal_uInt8
sal_uInt16 sal_Unicode