2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* $RCSfile: compiler.hxx,v $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-10-02 14:20:55 +00:00
|
|
|
* $Revision: 1.33 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-10-02 14:20:55 +00:00
|
|
|
* last change: $Author: kz $ $Date: 2007-10-02 15:20:55 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* This library 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 for more details.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 16:28:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SC_COMPILER_HXX
|
|
|
|
#define SC_COMPILER_HXX
|
|
|
|
|
2004-08-23 08:23:12 +00:00
|
|
|
#ifndef INCLUDED_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#define INCLUDED_STRING_H
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
#ifndef _SVMEMPOOL_HXX
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/mempool.hxx>
|
|
|
|
#endif
|
|
|
|
|
2004-08-23 08:23:12 +00:00
|
|
|
#ifndef INCLUDED_SCDLLAPI_H
|
|
|
|
#include "scdllapi.h"
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef SC_SCGLOB_HXX
|
2001-02-21 17:23:49 +00:00
|
|
|
#include "global.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2001-02-21 17:23:49 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
#ifndef SC_TOKENARRAY_HXX
|
|
|
|
#include "tokenarray.hxx"
|
|
|
|
#endif
|
2001-02-21 17:23:49 +00:00
|
|
|
#ifndef SC_TOKEN_HXX
|
|
|
|
#include "token.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2004-03-08 10:40:25 +00:00
|
|
|
#ifndef SC_INTRUREF_HXX
|
|
|
|
#include "intruref.hxx"
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifndef _UNOTOOLS_CHARCLASS_HXX
|
|
|
|
#include <unotools/charclass.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-06-15 16:26:31 +00:00
|
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#endif
|
2004-08-23 08:23:12 +00:00
|
|
|
|
|
|
|
#ifndef INCLUDED_HASH_MAP
|
2002-11-19 21:08:22 +00:00
|
|
|
#include <hash_map>
|
2004-08-23 08:23:12 +00:00
|
|
|
#define INCLUDED_HASH_MAP
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
// constants and data types also for external modules (ScInterpreter et al)
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
#define MAXCODE 512 /* maximum number of tokens in formula */
|
|
|
|
#define MAXSTRLEN 256 /* maximum length of input string of one symbol */
|
|
|
|
#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// flag values of CharTable
|
2002-11-21 15:11:24 +00:00
|
|
|
#define SC_COMPILER_C_ILLEGAL 0x00000000
|
|
|
|
#define SC_COMPILER_C_CHAR 0x00000001
|
|
|
|
#define SC_COMPILER_C_CHAR_BOOL 0x00000002
|
|
|
|
#define SC_COMPILER_C_CHAR_WORD 0x00000004
|
|
|
|
#define SC_COMPILER_C_CHAR_VALUE 0x00000008
|
|
|
|
#define SC_COMPILER_C_CHAR_STRING 0x00000010
|
|
|
|
#define SC_COMPILER_C_CHAR_DONTCARE 0x00000020
|
|
|
|
#define SC_COMPILER_C_BOOL 0x00000040
|
2004-03-08 10:40:25 +00:00
|
|
|
#define SC_COMPILER_C_WORD 0x00000080
|
|
|
|
#define SC_COMPILER_C_WORD_SEP 0x00000100
|
2002-11-21 15:11:24 +00:00
|
|
|
#define SC_COMPILER_C_VALUE 0x00000200
|
|
|
|
#define SC_COMPILER_C_VALUE_SEP 0x00000400
|
|
|
|
#define SC_COMPILER_C_VALUE_EXP 0x00000800
|
|
|
|
#define SC_COMPILER_C_VALUE_SIGN 0x00001000
|
|
|
|
#define SC_COMPILER_C_VALUE_VALUE 0x00002000
|
|
|
|
#define SC_COMPILER_C_STRING_SEP 0x00004000
|
2004-03-08 10:40:25 +00:00
|
|
|
#define SC_COMPILER_C_NAME_SEP 0x00008000 // there can be only one! '\''
|
2002-11-21 15:11:24 +00:00
|
|
|
#define SC_COMPILER_C_CHAR_IDENT 0x00010000 // identifier (built-in function) start
|
|
|
|
#define SC_COMPILER_C_IDENT 0x00020000 // identifier continuation
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
#define SC_COMPILER_FILE_TAB_SEP '#' // 'Doc'#Tab
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ScDocument;
|
|
|
|
class ScMatrix;
|
|
|
|
class ScRangeData;
|
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
// constants and data types internal to compiler
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*
|
2001-02-21 17:23:49 +00:00
|
|
|
OpCode eOp; // OpCode
|
|
|
|
StackVar eType; // type of data
|
|
|
|
USHORT nRefCnt; // reference count
|
2004-03-08 10:40:25 +00:00
|
|
|
BOOL bRaw; // not cloned yet and trimmed to real size
|
2000-09-18 16:07:07 +00:00
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SC_TOKEN_FIX_MEMBERS \
|
|
|
|
OpCode eOp; \
|
|
|
|
StackVar eType; \
|
|
|
|
USHORT nRefCnt; \
|
|
|
|
BOOL bRaw;
|
|
|
|
|
2001-02-21 17:23:49 +00:00
|
|
|
struct ScDoubleRawToken
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
SC_TOKEN_FIX_MEMBERS
|
|
|
|
public:
|
|
|
|
union
|
2004-03-08 10:40:25 +00:00
|
|
|
{ // union only to assure alignment identical to ScRawToken
|
2000-09-18 16:07:07 +00:00
|
|
|
double nValue;
|
2004-03-08 10:40:25 +00:00
|
|
|
struct {
|
|
|
|
BYTE cByte;
|
|
|
|
bool bHasForceArray;
|
|
|
|
} sbyte;
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
2001-02-21 17:23:49 +00:00
|
|
|
DECL_FIXEDMEMPOOL_NEWDEL( ScDoubleRawToken );
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2001-02-21 17:23:49 +00:00
|
|
|
struct ScRawToken
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
friend class ScCompiler;
|
2004-03-08 10:40:25 +00:00
|
|
|
// Friends that use a temporary ScRawToken on the stack (and therefor need
|
|
|
|
// the private dtor) and know what they're doing..
|
2000-09-18 16:07:07 +00:00
|
|
|
friend class ScTokenArray;
|
2007-02-27 10:53:56 +00:00
|
|
|
friend USHORT lcl_ScRawTokenOffset();
|
2000-09-18 16:07:07 +00:00
|
|
|
private:
|
|
|
|
SC_TOKEN_FIX_MEMBERS
|
|
|
|
public:
|
|
|
|
union {
|
|
|
|
double nValue;
|
2004-03-08 10:40:25 +00:00
|
|
|
struct {
|
|
|
|
BYTE cByte;
|
|
|
|
bool bHasForceArray;
|
|
|
|
} sbyte;
|
2000-09-18 16:07:07 +00:00
|
|
|
ComplRefData aRef;
|
|
|
|
ScMatrix* pMat;
|
2004-03-08 10:40:25 +00:00
|
|
|
USHORT nIndex; // index into name collection
|
|
|
|
sal_Unicode cStr[ MAXSTRLEN+1 ]; // string (up to 255 characters + 0)
|
|
|
|
short nJump[MAXJUMPCOUNT+1]; // If/Chose token
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
//! other members not initialized
|
2001-02-21 17:23:49 +00:00
|
|
|
ScRawToken() : bRaw( TRUE ) {}
|
2000-09-18 16:07:07 +00:00
|
|
|
private:
|
2004-03-08 10:40:25 +00:00
|
|
|
~ScRawToken() {} //! only delete via Delete()
|
2000-09-18 16:07:07 +00:00
|
|
|
public:
|
2001-02-21 17:23:49 +00:00
|
|
|
DECL_FIXEDMEMPOOL_NEWDEL( ScRawToken );
|
2000-09-18 16:07:07 +00:00
|
|
|
StackVar GetType() const { return (StackVar) eType; }
|
|
|
|
OpCode GetOpCode() const { return (OpCode) eOp; }
|
|
|
|
void NewOpCode( OpCode e ) { eOp = e; }
|
|
|
|
void IncRef() { nRefCnt++; }
|
|
|
|
void DecRef() { if( !--nRefCnt ) Delete(); }
|
|
|
|
USHORT GetRef() const { return nRefCnt; }
|
2007-04-25 14:56:13 +00:00
|
|
|
SC_DLLPUBLIC void Delete();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
// Use these methods only on tokens that are not part of a token array,
|
|
|
|
// since the reference count is cleared!
|
2000-09-18 16:07:07 +00:00
|
|
|
void SetOpCode( OpCode eCode );
|
|
|
|
void SetString( const sal_Unicode* pStr );
|
|
|
|
void SetSingleReference( const SingleRefData& rRef );
|
|
|
|
void SetDoubleReference( const ComplRefData& rRef );
|
|
|
|
void SetDouble( double fVal );
|
|
|
|
void SetInt( int nVal );
|
|
|
|
void SetName( USHORT n );
|
|
|
|
void SetMatrix( ScMatrix* p );
|
|
|
|
void SetExternal(const sal_Unicode* pStr);
|
2004-03-08 10:40:25 +00:00
|
|
|
// These methods are ok to use, reference count not cleared.
|
2000-09-18 16:07:07 +00:00
|
|
|
ComplRefData& GetReference();
|
|
|
|
void SetReference( ComplRefData& rRef );
|
|
|
|
|
2001-02-21 17:23:49 +00:00
|
|
|
ScRawToken* Clone() const; // real copy!
|
|
|
|
ScToken* CreateToken() const; // create typified token
|
2000-09-18 16:07:07 +00:00
|
|
|
void Load30( SvStream& );
|
|
|
|
void Load( SvStream&, USHORT nVer );
|
|
|
|
|
|
|
|
static xub_StrLen GetStrLen( const sal_Unicode* pStr ); // as long as a "string" is an array
|
|
|
|
static size_t GetStrLenBytes( xub_StrLen nLen )
|
|
|
|
{ return nLen * sizeof(sal_Unicode); }
|
|
|
|
static size_t GetStrLenBytes( const sal_Unicode* pStr )
|
|
|
|
{ return GetStrLenBytes( GetStrLen( pStr ) ); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
typedef ScSimpleIntrusiveReference< struct ScRawToken > ScRawTokenRef;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct ScArrayStack;
|
|
|
|
|
2002-11-19 21:08:22 +00:00
|
|
|
typedef ::std::hash_map< String, OpCode, ScStringHashCode, ::std::equal_to< String > > ScOpCodeHashMap;
|
|
|
|
|
2006-10-18 11:16:39 +00:00
|
|
|
using namespace ::com::sun::star::i18n;
|
2007-04-25 14:56:13 +00:00
|
|
|
class SC_DLLPUBLIC ScCompiler
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-10-18 11:16:39 +00:00
|
|
|
struct Convention
|
|
|
|
{
|
|
|
|
const ScAddress::Convention meConv;
|
|
|
|
const ULONG* mpCharTable;
|
|
|
|
|
|
|
|
|
|
|
|
Convention( ScAddress::Convention eConvP );
|
2007-02-27 10:53:56 +00:00
|
|
|
virtual ~Convention();
|
2006-10-18 11:16:39 +00:00
|
|
|
|
|
|
|
virtual void MakeRefStr( rtl::OUStringBuffer& rBuffer,
|
|
|
|
const ScCompiler& rCompiler,
|
|
|
|
const ComplRefData& rRef,
|
|
|
|
BOOL bSingleRef ) const = 0;
|
|
|
|
virtual ::com::sun::star::i18n::ParseResult
|
|
|
|
parseAnyToken( const String& rFormula,
|
|
|
|
xub_StrLen nSrcPos,
|
|
|
|
const CharClass* pCharClass) const = 0;
|
|
|
|
};
|
|
|
|
|
2002-11-19 21:08:22 +00:00
|
|
|
static String* pSymbolTableNative; // array of native symbols, offset==OpCode
|
|
|
|
static String* pSymbolTableEnglish; // array of English symbols, offset==OpCode
|
|
|
|
static USHORT nAnzStrings; // count of symbols
|
|
|
|
static ScOpCodeHashMap* pSymbolHashMapNative; // hash map of native symbols
|
|
|
|
static ScOpCodeHashMap* pSymbolHashMapEnglish; // hash map of English symbols
|
2005-11-07 13:40:47 +00:00
|
|
|
static CharClass* pCharClassEnglish; // character classification for en_US locale
|
2006-10-18 11:16:39 +00:00
|
|
|
static const Convention *pConventions[ ScAddress::CONV_LAST ];
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocument* pDoc;
|
|
|
|
ScAddress aPos;
|
2006-10-18 11:16:39 +00:00
|
|
|
|
|
|
|
private:
|
2000-09-18 16:07:07 +00:00
|
|
|
String aCorrectedFormula; // autocorrected Formula
|
|
|
|
String aCorrectedSymbol; // autocorrected Symbol
|
|
|
|
sal_Unicode cSymbol[MAXSTRLEN]; // current Symbol
|
|
|
|
String aFormula; // formula source code
|
|
|
|
xub_StrLen nSrcPos; // tokenizer position (source code)
|
|
|
|
ScTokenArray* pArr;
|
2001-02-21 17:23:49 +00:00
|
|
|
ScRawTokenRef pRawToken;
|
2004-03-08 10:40:25 +00:00
|
|
|
ScTokenRef pToken; // current token
|
|
|
|
ScTokenRef pCurrentFactorToken; // current factor token (of Factor() method)
|
2000-09-18 16:07:07 +00:00
|
|
|
OpCode eLastOp;
|
|
|
|
ScToken** pCode;
|
|
|
|
ScArrayStack* pStack;
|
2002-11-19 21:08:22 +00:00
|
|
|
String* pSymbolTable; // which symbol table is used
|
|
|
|
ScOpCodeHashMap* pSymbolHashMap; // which symbol hash map is used
|
2005-11-07 13:40:47 +00:00
|
|
|
const CharClass* pCharClass; // which character classification is used for parseAnyToken
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT pc;
|
2004-03-08 10:40:25 +00:00
|
|
|
short nNumFmt; // set during CompileTokenArray()
|
2004-06-04 12:21:35 +00:00
|
|
|
SCsTAB nMaxTab; // last sheet in document
|
2004-03-08 10:40:25 +00:00
|
|
|
short nRecursion; // GetToken() recursions
|
|
|
|
BOOL glSubTotal; // if code contains one or more subtotal functions
|
|
|
|
BOOL bAutoCorrect; // whether to apply AutoCorrection
|
|
|
|
BOOL bCorrected; // AutoCorrection was applied
|
|
|
|
BOOL bCompileForFAP; //! not real RPN but names, for FunctionAutoPilot,
|
|
|
|
// will not be resolved
|
|
|
|
BOOL bIgnoreErrors; // on AutoCorrect and CompileForFAP
|
|
|
|
// ignore errors and create RPN nevertheless
|
2006-10-18 11:16:39 +00:00
|
|
|
const Convention *pConv;
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bImportXML;
|
2007-10-02 14:20:55 +00:00
|
|
|
bool mbCloseBrackets; // whether to close open brackets automatically, default TRUE
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL GetToken();
|
2007-06-13 08:04:48 +00:00
|
|
|
BOOL NextNewToken(bool bAllowBooleans = false);
|
2000-09-18 16:07:07 +00:00
|
|
|
OpCode NextToken();
|
2004-03-08 10:40:25 +00:00
|
|
|
void PutCode( ScTokenRef& );
|
2000-09-18 16:07:07 +00:00
|
|
|
void Factor();
|
|
|
|
void UnionCutLine();
|
2004-10-22 06:56:48 +00:00
|
|
|
void UnaryLine();
|
|
|
|
void PostOpLine();
|
2000-09-18 16:07:07 +00:00
|
|
|
void PowLine();
|
|
|
|
void MulDivLine();
|
|
|
|
void AddSubLine();
|
2001-10-09 10:45:53 +00:00
|
|
|
void ConcatLine();
|
2000-09-18 16:07:07 +00:00
|
|
|
void CompareLine();
|
|
|
|
void NotLine();
|
|
|
|
OpCode Expression();
|
|
|
|
|
|
|
|
void SetError(USHORT nError);
|
|
|
|
xub_StrLen NextSymbol();
|
|
|
|
BOOL IsValue( const String& );
|
|
|
|
BOOL IsOpCode( const String& );
|
|
|
|
BOOL IsOpCode2( const String& );
|
|
|
|
BOOL IsString();
|
|
|
|
BOOL IsReference( const String& );
|
|
|
|
BOOL IsMacro( const String& );
|
|
|
|
BOOL IsNamedRange( const String& );
|
|
|
|
BOOL IsDBRange( const String& );
|
|
|
|
BOOL IsColRowName( const String& );
|
2007-06-13 08:04:48 +00:00
|
|
|
BOOL IsBoolean( const String& );
|
2000-09-18 16:07:07 +00:00
|
|
|
void AutoCorrectParsedSymbol();
|
|
|
|
void AdjustReference( SingleRefData& r );
|
|
|
|
void PushTokenArray( ScTokenArray*, BOOL = FALSE );
|
|
|
|
void PopTokenArray();
|
|
|
|
void SetRelNameReference();
|
2007-06-13 08:04:48 +00:00
|
|
|
void CreateStringFromScMatrix( rtl::OUStringBuffer& rBuffer, const ScMatrix* pMatrix );
|
|
|
|
|
|
|
|
void AppendBoolean( rtl::OUStringBuffer& rBuffer, bool bVal );
|
|
|
|
void AppendDouble( rtl::OUStringBuffer& rBuffer, double fVal );
|
|
|
|
void AppendString( rtl::OUStringBuffer& rBuffer, const String & rStr );
|
2004-03-08 10:40:25 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
public:
|
|
|
|
ScCompiler(ScDocument* pDocument, const ScAddress& );
|
|
|
|
|
|
|
|
ScCompiler( ScDocument* pDocument, const ScAddress&,
|
|
|
|
const ScTokenArray& rArr );
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
static void DeInit();
|
|
|
|
|
2006-10-18 11:16:39 +00:00
|
|
|
// for ScAddress::Format()
|
|
|
|
static void CheckTabQuotes( String& aTabName,
|
|
|
|
const ScAddress::Convention eConv = ScAddress::CONV_OOO );
|
|
|
|
|
|
|
|
static BOOL EnQuote( String& rStr );
|
|
|
|
static BOOL DeQuote( String& rStr );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
//! _either_ CompileForFAP _or_ AutoCorrection, _not_ both
|
2000-09-18 16:07:07 +00:00
|
|
|
void SetCompileForFAP( BOOL bVal )
|
|
|
|
{ bCompileForFAP = bVal; bIgnoreErrors = bVal; }
|
|
|
|
void SetAutoCorrection( BOOL bVal )
|
|
|
|
{ bAutoCorrect = bVal; bIgnoreErrors = bVal; }
|
2007-10-02 14:20:55 +00:00
|
|
|
void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; }
|
2000-09-18 16:07:07 +00:00
|
|
|
void SetCompileEnglish( BOOL bVal ); // use English SymbolTable
|
2006-10-18 11:16:39 +00:00
|
|
|
void SetRefConvention( const Convention *pConvP );
|
|
|
|
void SetRefConvention( const ScAddress::Convention eConv );
|
|
|
|
|
|
|
|
void SetCompileXML( BOOL bVal ); // Deprecate and move to an address conv
|
2000-09-18 16:07:07 +00:00
|
|
|
void SetImportXML( BOOL bVal )
|
|
|
|
{ bImportXML = bVal; }
|
|
|
|
BOOL IsCorrected() { return bCorrected; }
|
|
|
|
const String& GetCorrectedFormula() { return aCorrectedFormula; }
|
2006-10-18 11:16:39 +00:00
|
|
|
|
|
|
|
// Use convention from this->aPos by default
|
|
|
|
ScTokenArray* CompileString( const String& rFormula,
|
|
|
|
ScAddress::Convention eConv = ScAddress::CONV_UNSPECIFIED );
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL CompileTokenArray();
|
|
|
|
short GetNumFormatType() { return nNumFmt; }
|
|
|
|
|
2004-11-09 13:58:16 +00:00
|
|
|
static const String& GetStringFromOpCode( OpCode eOpCode, bool bEnglish = false );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ScToken* CreateStringFromToken( String& rFormula, ScToken* pToken,
|
|
|
|
BOOL bAllowArrAdvance = FALSE );
|
2001-06-15 16:26:31 +00:00
|
|
|
ScToken* CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToken* pToken,
|
|
|
|
BOOL bAllowArrAdvance = FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
void CreateStringFromTokenArray( String& rFormula );
|
2001-06-15 16:26:31 +00:00
|
|
|
void CreateStringFromTokenArray( rtl::OUStringBuffer& rBuffer );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void MoveRelWrap();
|
|
|
|
static void MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc,
|
|
|
|
const ScAddress& rPos );
|
|
|
|
|
|
|
|
BOOL UpdateNameReference( UpdateRefMode eUpdateRefMode,
|
|
|
|
const ScRange&,
|
2004-06-04 12:21:35 +00:00
|
|
|
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
|
2004-06-28 16:33:51 +00:00
|
|
|
BOOL& rChanged, BOOL bSharedFormula = FALSE);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ScRangeData* UpdateReference( UpdateRefMode eUpdateRefMode,
|
|
|
|
const ScAddress& rOldPos, const ScRange&,
|
2004-06-04 12:21:35 +00:00
|
|
|
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
|
2006-08-04 10:33:00 +00:00
|
|
|
BOOL& rChanged, BOOL& rRefSizeChanged );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
/// Only once for converted shared formulas,
|
|
|
|
/// token array has to be compiled afterwards.
|
|
|
|
void UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode,
|
|
|
|
const ScAddress& rOldPos, const ScRange&,
|
2004-06-04 12:21:35 +00:00
|
|
|
SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 12:21:35 +00:00
|
|
|
ScRangeData* UpdateInsertTab(SCTAB nTable, BOOL bIsName );
|
|
|
|
ScRangeData* UpdateDeleteTab(SCTAB nTable, BOOL bIsMove, BOOL bIsName, BOOL& bCompile);
|
|
|
|
ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, BOOL bIsName );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL HasModifiedRange();
|
|
|
|
|
|
|
|
/// If the character is allowed as first character in sheet names or references
|
2007-01-22 10:57:34 +00:00
|
|
|
static inline BOOL IsCharWordChar( String const & rStr,
|
|
|
|
xub_StrLen nPos,
|
2006-10-18 11:16:39 +00:00
|
|
|
const ScAddress::Convention eConv = ScAddress::CONV_OOO )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-01-22 10:57:34 +00:00
|
|
|
sal_Unicode c = rStr.GetChar( nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
return c < 128 ?
|
2007-02-27 10:53:56 +00:00
|
|
|
static_cast<BOOL>(
|
|
|
|
(pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
|
2007-01-22 10:57:34 +00:00
|
|
|
ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// If the character is allowed in sheet names or references
|
2007-01-22 10:57:34 +00:00
|
|
|
static inline BOOL IsWordChar( String const & rStr,
|
|
|
|
xub_StrLen nPos,
|
2006-10-18 11:16:39 +00:00
|
|
|
const ScAddress::Convention eConv = ScAddress::CONV_OOO )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-01-22 10:57:34 +00:00
|
|
|
sal_Unicode c = rStr.GetChar( nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
return c < 128 ?
|
2007-02-27 10:53:56 +00:00
|
|
|
static_cast<BOOL>(
|
|
|
|
(pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
|
2007-01-22 10:57:34 +00:00
|
|
|
ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-03-08 10:40:25 +00:00
|
|
|
|
|
|
|
private:
|
2006-10-18 11:16:39 +00:00
|
|
|
/// Access the CharTable flags
|
|
|
|
inline ULONG GetCharTableFlags( sal_Unicode c )
|
|
|
|
{ return c < 128 ? pConv->mpCharTable[ UINT8(c) ] : 0; }
|
|
|
|
|
2004-03-08 10:40:25 +00:00
|
|
|
static inline void ForceArrayOperator( ScTokenRef& rCurr, const ScTokenRef& rPrev )
|
|
|
|
{
|
|
|
|
if ( rPrev.Is() && rPrev->HasForceArray() &&
|
|
|
|
rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush
|
|
|
|
&& !rCurr->HasForceArray() )
|
|
|
|
rCurr->SetForceArray( true);
|
|
|
|
}
|
|
|
|
// SUNWS7 needs a forward declared friend, otherwise members of the outer
|
|
|
|
// class are not accessible.
|
|
|
|
class CurrentFactor;
|
|
|
|
friend class ScCompiler::CurrentFactor;
|
|
|
|
class CurrentFactor
|
|
|
|
{
|
|
|
|
ScTokenRef pPrevFac;
|
|
|
|
ScCompiler* pCompiler;
|
|
|
|
// not implemented
|
|
|
|
CurrentFactor( const CurrentFactor& );
|
|
|
|
CurrentFactor& operator=( const CurrentFactor& );
|
|
|
|
public:
|
|
|
|
explicit CurrentFactor( ScCompiler* pComp )
|
|
|
|
: pPrevFac( pComp->pCurrentFactorToken )
|
|
|
|
, pCompiler( pComp )
|
|
|
|
{}
|
|
|
|
~CurrentFactor()
|
|
|
|
{ pCompiler->pCurrentFactorToken = pPrevFac; }
|
|
|
|
// yes, this operator= may modify the RValue
|
|
|
|
void operator=( ScTokenRef& r )
|
|
|
|
{
|
|
|
|
ForceArrayOperator( r, pPrevFac);
|
|
|
|
pCompiler->pCurrentFactorToken = r;
|
|
|
|
}
|
|
|
|
void operator=( ScToken* p )
|
|
|
|
{
|
|
|
|
ScTokenRef xTemp( p );
|
|
|
|
*this = xTemp;
|
|
|
|
}
|
|
|
|
operator ScTokenRef&()
|
|
|
|
{ return pCompiler->pCurrentFactorToken; }
|
|
|
|
ScToken* operator->()
|
|
|
|
{ return pCompiler->pCurrentFactorToken.operator->(); }
|
|
|
|
operator ScToken*()
|
|
|
|
{ return operator->(); }
|
|
|
|
};
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
2004-06-04 12:21:35 +00:00
|
|
|
|
2004-08-23 08:23:12 +00:00
|
|
|
SC_DLLPUBLIC String* GetScCompilerpSymbolTableNative(); //CHINA001
|
2004-03-08 10:40:25 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|