office-gobmx/sc/inc/scmatrix.hxx
Jens-Heiner Rechtien 87307aba9e CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj  r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj  r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj  r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj  r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj  r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj  r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj  r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj  r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj  r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj  r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj  r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj  r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj  r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj  r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj  r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj  r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj  r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj  r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc  r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc  r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc  r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc  r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc  r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc  r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj  r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj  r264980 : some small changes
2008-12-05 12:57:57 +0100 oj  r264902 : eof changed
2008-12-05 12:56:46 +0100 oj  r264901 : eof changed
2008-12-05 12:28:47 +0100 oj  r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj  r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc  r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc  r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc  r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc  r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc  r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj  r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj  r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj  r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj  r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj  r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj  r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj  r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj  r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj  r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj  r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj  r264604 : use temp var
2008-12-01 14:18:31 +0100 oj  r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj  r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj  r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj  r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj  r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj  r264532 : add help ids
2008-11-28 10:16:56 +0100 oj  r264529 : set help id
2008-11-28 10:16:43 +0100 oj  r264528 : set help id
2008-11-26 13:55:04 +0100 oj  r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj  r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj  r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj  r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj  r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj  r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj  r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj  r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj  r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj  r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj  r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj  r263967 : deleted
2008-11-19 10:58:24 +0100 oj  r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj  r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj  r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj  r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj  r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj  r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj  r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj  r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj  r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj  r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj  r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj  r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj  r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj  r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj  r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj  r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj  r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj  r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj  r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj  r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj  r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj  r262077 : copy
2008-10-07 09:45:31 +0200 oj  r262076 : #i94535# 
2008-10-07 09:44:26 +0200 oj  r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj  r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj  r262073 : new images
2008-10-07 09:03:01 +0200 oj  r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj  r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj  r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj  r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj  r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj  r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj  r262013 : new module formula
2008-10-01 17:04:55 +0200 oj  r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj  r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj  r262009 : #i94535#
2009-01-08 10:47:13 +00:00

430 lines
16 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: scmatrix.hxx,v $
* $Revision: 1.11.148.2 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SC_MATRIX_HXX
#define SC_MATRIX_HXX
#include "global.hxx"
#include "formula/intruref.hxx"
#include "formula/errorcodes.hxx"
#include <tools/string.hxx>
#include "scdllapi.h"
class SvStream;
class ScInterpreter;
class SvNumberFormatter;
typedef BYTE ScMatValType;
const ScMatValType SC_MATVAL_VALUE = 0x00;
const ScMatValType SC_MATVAL_BOOLEAN = 0x01;
const ScMatValType SC_MATVAL_STRING = 0x02;
const ScMatValType SC_MATVAL_EMPTY = SC_MATVAL_STRING | 0x04; // STRING plus flag
const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08; // EMPTY plus flag
const ScMatValType SC_MATVAL_NONVALUE = SC_MATVAL_EMPTYPATH; // mask of all non-value bits
union ScMatrixValue
{
double fVal;
String* pS;
/// Only valid if ScMatrix methods indicate so!
const String& GetString() const { return pS ? *pS : EMPTY_STRING; }
/// Only valid if ScMatrix methods indicate that this is no string!
USHORT GetError() const { return GetDoubleErrorValue( fVal); }
/// Only valid if ScMatrix methods indicate that this is a boolean
bool GetBoolean() const { return fVal != 0.; }
};
/** Matrix representation of double values and strings.
@ATTENTION: optimized for speed and double values.
<p> Matrix elements are NOT initialized after construction!
<p> All methods using an SCSIZE nIndex parameter and all Is...() methods do
NOT check the range for validity! However, the Put...() and Get...()
methods using nCol/nRow parameters do check the range.
<p> Methods using nCol/nRow parameters do replicate a single row vector if
nRow &gt; 0 and nCol &lt; nColCount, respectively a column vector if nCol
&gt; 0 and nRow &lt; nRowCount.
<p> GetString( SCSIZE nIndex ) does not check if there really is a string,
do this with IsString() first. GetString( SCSIZE nC, SCSIZE nR ) does check
it and returns and empty string if there is no string. Both GetDouble()
methods don't check for a string, do this with IsNumeric() or IsString() or
IsValue() first.
<p> The GetString( SvNumberFormatter&, ...) methods return the matrix
element's string if one is present, otherwise the numerical value is
formatted as a string, or in case of an error the error string is returned.
<p> PutDouble() does not reset an eventual string! Use
PutDoubleAndResetString() if that is wanted. Also the FillDouble...()
methods don't reset strings. As a consequence memory leaks may occur if
used wrong.
*/
class SC_DLLPUBLIC ScMatrix
{
ScMatrixValue* pMat;
ScMatValType* mnValType;
ULONG mnNonValue; // how many strings and empties
ScInterpreter* pErrorInterpreter;
mutable ULONG nRefCnt; // reference count
SCSIZE nColCount;
SCSIZE nRowCount;
void ResetIsString();
void DeleteIsString();
void CreateMatrix( SCSIZE nC, SCSIZE nR);
// pStr may be NULL, bFlag MUST NOT be 0
void PutStringEntry( const String* pStr, BYTE bFlag, SCSIZE nIndex );
// only delete via Delete()
~ScMatrix();
// not implemented, prevent usage
ScMatrix( const ScMatrix& );
ScMatrix& operator=( const ScMatrix&);
void SetErrorAtInterpreter( USHORT nError) const;
public:
/// The maximum number of elements a matrix may have at runtime.
inline static size_t GetElementsMax()
{
// Roughly 125MB in total, divided by 8+1 per element => 14M elements.
const size_t nMemMax = 0x08000000 / (sizeof(ScMatrixValue) + sizeof(ScMatValType));
// With MAXROWCOUNT==65536 and 128 columns => 8M elements ~72MB.
const size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128;
// Stuffed with a million rows would limit this to 14 columns.
return nMemMax < nArbitraryLimit ? nMemMax : nArbitraryLimit;
}
/// Value or boolean.
inline static bool IsValueType( ScMatValType nType )
{
return nType <= SC_MATVAL_BOOLEAN;
}
/// Boolean.
inline static bool IsBooleanType( ScMatValType nType )
{
return nType == SC_MATVAL_BOOLEAN;
}
/// String, empty or empty path, but not value nor boolean.
inline static bool IsNonValueType( ScMatValType nType )
{
return (nType & SC_MATVAL_NONVALUE) != 0;
}
/** String, but not empty or empty path or any other type.
Not named IsStringType to prevent confusion because previously
IsNonValueType was named IsStringType. */
inline static bool IsRealStringType( ScMatValType nType )
{
return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_STRING;
}
/// Empty, but not empty path or any other type.
inline static bool IsEmptyType( ScMatValType nType )
{
return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_EMPTY;
}
/// Empty path, but not empty or any other type.
inline static bool IsEmptyPathType( ScMatValType nType )
{
return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_EMPTYPATH;
}
/** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is
created instead and a double error value (errStackOverflow) is set.
Compare nC and nR with a GetDimensions() call to check. */
ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0) { CreateMatrix( nC, nR); }
/** Clone the matrix. */
ScMatrix* Clone() const;
/** Clone the matrix and extend it to the new size. nNewCols and nNewRows
MUST be at least of the size of the original matrix. */
ScMatrix* CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows ) const;
/// Disable refcounting forever, may only be deleted via Delete() afterwards.
inline void SetEternalRef() { nRefCnt = ULONG_MAX; }
inline bool IsEternalRef() const { return nRefCnt == ULONG_MAX; }
inline void IncRef() const
{
if ( !IsEternalRef() )
++nRefCnt;
}
inline void DecRef() const
{
if ( nRefCnt > 0 && !IsEternalRef() )
if ( --nRefCnt == 0 )
delete this;
}
inline void Delete()
{
if ( nRefCnt == 0 || IsEternalRef() )
delete this;
else
--nRefCnt;
}
void SetErrorInterpreter( ScInterpreter* p)
{ pErrorInterpreter = p; }
ScMatrix( SvStream& rStream);
void Store( SvStream& rStream) const;
void GetDimensions( SCSIZE& rC, SCSIZE& rR) const
{ rC = nColCount; rR = nRowCount; };
SCSIZE GetElementCount() const
{ return nColCount * nRowCount; }
inline bool ValidColRow( SCSIZE nC, SCSIZE nR) const
{ return nC < nColCount && nR < nRowCount; }
inline SCSIZE CalcOffset( SCSIZE nC, SCSIZE nR) const
{ return nC * nRowCount + nR; }
/** For a row vector or column vector, if the position does not point into
the vector but is a valid column or row offset it is adapted such that
it points to an element to be replicated, same column row 0 for a row
vector, same row column 0 for a column vector. Else, for a 2D matrix,
returns false.
*/
inline bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const
{
if (nColCount == 1 && nRowCount == 1)
{
rC = 0;
rR = 0;
return true;
}
else if (nColCount == 1 && rR < nRowCount)
{
rC = 0;
return true;
}
else if (nRowCount == 1 && rC < nColCount)
{
rR = 0;
return true;
}
return false;
}
/** Checks if the matrix position is within the matrix. If it is not, for a
row vector or column vector the position is adapted such that it points
to an element to be replicated, same column row 0 for a row vector,
same row column 0 for a column vector. Else, for a 2D matrix and
position not within matrix, returns false.
*/
inline bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const
{
return ValidColRow( rC, rR) || ValidColRowReplicated( rC, rR);
}
void PutDouble( double fVal, SCSIZE nC, SCSIZE nR);
void PutDouble( double fVal, SCSIZE nIndex)
{ pMat[nIndex].fVal = fVal; }
void PutString( const String& rStr, SCSIZE nC, SCSIZE nR);
void PutString( const String& rStr, SCSIZE nIndex);
void PutEmpty( SCSIZE nC, SCSIZE nR);
void PutEmpty( SCSIZE nIndex);
/// Jump FALSE without path
void PutEmptyPath( SCSIZE nC, SCSIZE nR);
void PutEmptyPath( SCSIZE nIndex);
void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR )
{ PutDouble( CreateDoubleError( nErrorCode ), nC, nR ); }
void PutError( USHORT nErrorCode, SCSIZE nIndex )
{ PutDouble( CreateDoubleError( nErrorCode ), nIndex ); }
void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR);
void PutBoolean( bool bVal, SCSIZE nIndex);
void FillDouble( double fVal,
SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 );
/** May be used before obtaining the double value of an element to avoid
passing its NAN around.
@ATTENTION: MUST NOT be used if the element is a string!
Use GetErrorIfNotString() instead if not sure.
@returns 0 if no error, else one of err... constants */
USHORT GetError( SCSIZE nC, SCSIZE nR) const;
USHORT GetError( SCSIZE nIndex) const
{ return pMat[nIndex].GetError(); }
/** Use in ScInterpreter to obtain the error code, if any.
@returns 0 if no error or string element, else one of err... constants */
USHORT GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const
{ return IsValue( nC, nR) ? GetError( nC, nR) : 0; }
USHORT GetErrorIfNotString( SCSIZE nIndex) const
{ return IsValue( nIndex) ? GetError( nIndex) : 0; }
/// @return 0.0 if empty or empty path, else value or DoubleError.
double GetDouble( SCSIZE nC, SCSIZE nR) const;
/// @return 0.0 if empty or empty path, else value or DoubleError.
double GetDouble( SCSIZE nIndex) const
{
if ( pErrorInterpreter )
{
USHORT nError = GetDoubleErrorValue( pMat[nIndex].fVal);
if ( nError )
SetErrorAtInterpreter( nError);
}
return pMat[nIndex].fVal;
}
/// @return empty string if empty or empty path, else string content.
const String& GetString( SCSIZE nC, SCSIZE nR) const;
/// @return empty string if empty or empty path, else string content.
const String& GetString( SCSIZE nIndex) const
{ return pMat[nIndex].GetString(); }
/** @returns the matrix element's string if one is present, otherwise the
numerical value formatted as string, or in case of an error the error
string is returned; an empty string for empty, a "FALSE" string for
empty path. */
String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const;
String GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const;
/// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate
/// an empty string!
const ScMatrixValue* Get( SCSIZE nC, SCSIZE nR, ScMatValType& nType) const;
/// @return <TRUE/> if string or empty or empty path, in fact non-value.
BOOL IsString( SCSIZE nIndex ) const
{ return mnValType && IsNonValueType( mnValType[nIndex]); }
/// @return <TRUE/> if string or empty or empty path, in fact non-value.
BOOL IsString( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return mnValType && IsNonValueType( mnValType[ nC * nRowCount + nR ]);
}
/// @return <TRUE/> if empty or empty path.
BOOL IsEmpty( SCSIZE nIndex ) const
{ return mnValType && ((mnValType[nIndex] & SC_MATVAL_EMPTY) == SC_MATVAL_EMPTY); }
/// @return <TRUE/> if empty or empty path.
BOOL IsEmpty( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return mnValType && ((mnValType[ nC * nRowCount + nR ] & SC_MATVAL_EMPTY) == SC_MATVAL_EMPTY);
}
/// @return <TRUE/> if empty path.
BOOL IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return mnValType && ((mnValType[ nC * nRowCount + nR ] & SC_MATVAL_EMPTYPATH) == SC_MATVAL_EMPTYPATH);
}
/// @return <TRUE/> if empty path.
BOOL IsEmptyPath( SCSIZE nIndex ) const
{ return mnValType && ((mnValType[nIndex] & SC_MATVAL_EMPTYPATH) == SC_MATVAL_EMPTYPATH); }
/// @return <TRUE/> if value or boolean.
BOOL IsValue( SCSIZE nIndex ) const
{ return !mnValType || IsValueType( mnValType[nIndex]); }
/// @return <TRUE/> if value or boolean.
BOOL IsValue( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return !mnValType || IsValueType( mnValType[ nC * nRowCount + nR ]);
}
/// @return <TRUE/> if value or boolean or empty or empty path.
BOOL IsValueOrEmpty( SCSIZE nIndex ) const
{ return !mnValType || IsValueType( mnValType[nIndex] ) ||
((mnValType[nIndex] & SC_MATVAL_EMPTY) == SC_MATVAL_EMPTY); }
/// @return <TRUE/> if value or boolean or empty or empty path.
BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return !mnValType || IsValueType( mnValType[ nC * nRowCount + nR ]) ||
((mnValType[ nC * nRowCount + nR ] & SC_MATVAL_EMPTY) ==
SC_MATVAL_EMPTY);
}
/// @return <TRUE/> if boolean.
BOOL IsBoolean( SCSIZE nIndex ) const
{ return mnValType && IsBooleanType( mnValType[nIndex]); }
/// @return <TRUE/> if boolean.
BOOL IsBoolean( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated( nC, nR );
return mnValType && IsBooleanType( mnValType[ nC * nRowCount + nR ]);
}
/// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties
BOOL IsNumeric() const
{ return 0 == mnNonValue; }
void MatTrans( ScMatrix& mRes) const;
void MatCopy ( ScMatrix& mRes) const;
/** Copy upper left of this matrix to mRes matrix.
This matrix's dimensions must be greater or equal to the mRes matrix
dimensions.
*/
void MatCopyUpperLeft( ScMatrix& mRes) const;
// Convert ScInterpreter::CompareMat values (-1,0,1) to boolean values
void CompareEqual();
void CompareNotEqual();
void CompareLess();
void CompareGreater();
void CompareLessEqual();
void CompareGreaterEqual();
double And(); // logical AND of all matrix values, or NAN
double Or(); // logical OR of all matrix values, or NAN
// All other matrix functions MatMult, MInv, ... are in ScInterpreter
// to be numerically safe.
};
typedef formula::SimpleIntrusiveReference< class ScMatrix > ScMatrixRef;
typedef formula::SimpleIntrusiveReference< const class ScMatrix > ScConstMatrixRef;
#endif // SC_MATRIX_HXX