diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
commit | 2cb4c646a81c92d7582c0db6eedeb09128ace1c5 (patch) | |
tree | 4a0a18f27da908aa4507a8fd6cde5d99eb97635d /formula/inc | |
parent | 0c14679312da5bc50a3be71d39a5032b24887155 (diff) |
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#
Diffstat (limited to 'formula/inc')
21 files changed, 3360 insertions, 0 deletions
diff --git a/formula/inc/AddressConvention.hxx b/formula/inc/AddressConvention.hxx new file mode 100644 index 000000000000..d65a3be79524 --- /dev/null +++ b/formula/inc/AddressConvention.hxx @@ -0,0 +1,42 @@ +/*************************************************************************
+ *
+ * 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: tokenuno.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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 FORMULA_ADDRESSCONVENTION_HXX_INCLUDED
+#define FORMULA_ADDRESSCONVENTION_HXX_INCLUDED
+
+#include "formula/formuladllapi.h"
+namespace formula
+{
+// =============================================================================
+// =============================================================================
+} // formula
+// =============================================================================
+
+#endif // FORMULA_ADDRESSCONVENTION_HXX_INCLUDED
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx new file mode 100644 index 000000000000..d2ea1c520165 --- /dev/null +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -0,0 +1,372 @@ +/************************************************************************* + * + * 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: tokenuno.hxx,v $ + * $Revision: 1.4 $ + * + * 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 FORMULA_COMPILER_HXX_INCLUDED +#define FORMULA_COMPILER_HXX_INCLUDED + +#include "formula/formuladllapi.h" +#include <tools/string.hxx> +#include <tools/debug.hxx> +#include <rtl/ustrbuf.hxx> + +#include <boost/shared_ptr.hpp> +#include <hash_map> + +#include <com/sun/star/uno/Sequence.hxx> + +#include "formula/opcode.hxx" +#include "formula/grammar.hxx" +#include "formula/token.hxx" + + +#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */ +#define MAXCODE 512 /* maximum number of tokens in formula */ + + +namespace com { namespace sun { namespace star { + namespace sheet { + struct FormulaOpCodeMapEntry; + struct FormulaToken; + } +}}} + + +namespace formula +{ + class FormulaTokenArray; + +struct FormulaArrayStack +{ + FormulaArrayStack* pNext; + FormulaTokenArray* pArr; + BOOL bTemp; +}; + + +struct FORMULA_DLLPUBLIC StringHashCode +{ + size_t operator()( const String& rStr ) const + { + return rtl_ustr_hashCode_WithLength( rStr.GetBuffer(), rStr.Len() ); + } +}; + +typedef ::std::hash_map< String, OpCode, StringHashCode, ::std::equal_to< String > > OpCodeHashMap; +typedef ::std::hash_map< String, String, StringHashCode, ::std::equal_to< String > > ExternalHashMap; + +class FORMULA_DLLPUBLIC FormulaCompiler +{ +public: + FormulaCompiler(); + FormulaCompiler(FormulaTokenArray& _rArr); + virtual ~FormulaCompiler(); + + /** Mappings from strings to OpCodes and vice versa. */ + class FORMULA_DLLPUBLIC OpCodeMap + { + OpCodeHashMap * mpHashMap; /// Hash map of symbols, String -> OpCode + String * mpTable; /// Array of symbols, OpCode -> String, offset==OpCode + ExternalHashMap * mpExternalHashMap; /// Hash map of ocExternal, Filter String -> AddIn String + ExternalHashMap * mpReverseExternalHashMap; /// Hash map of ocExternal, AddIn String -> Filter String + FormulaGrammar::Grammar meGrammar; /// Grammar, language and reference convention + USHORT mnSymbols; /// Count of OpCode symbols + bool mbCore : 1; /// If mapping was setup by core, not filters + bool mbEnglish : 1; /// If English symbols and external names + + OpCodeMap(); // prevent usage + OpCodeMap( const OpCodeMap& ); // prevent usage + OpCodeMap& operator=( const OpCodeMap& ); // prevent usage + + public: + + OpCodeMap(USHORT nSymbols, bool bCore, FormulaGrammar::Grammar eGrammar ) : + mpHashMap( new OpCodeHashMap( nSymbols)), + mpTable( new String[ nSymbols ]), + mpExternalHashMap( new ExternalHashMap), + mpReverseExternalHashMap( new ExternalHashMap), + meGrammar( eGrammar), + mnSymbols( nSymbols), + mbCore( bCore) + { + mbEnglish = FormulaGrammar::isEnglish( meGrammar); + } + virtual ~OpCodeMap(); + + + /// Get the symbol String -> OpCode hash map for finds. + inline const OpCodeHashMap* getHashMap() const { return mpHashMap; } + + /// Get the symbol String -> AddIn String hash map for finds. + inline const ExternalHashMap* getExternalHashMap() const { return mpExternalHashMap; } + + /// Get the AddIn String -> symbol String hash map for finds. + inline const ExternalHashMap* getReverseExternalHashMap() const { return mpReverseExternalHashMap; } + + /// Get the symbol string matching an OpCode. + inline const String& getSymbol( const OpCode eOp ) const + { + DBG_ASSERT( USHORT(eOp) < mnSymbols, "OpCodeMap::getSymbol: OpCode out of range"); + if (USHORT(eOp) < mnSymbols) + return mpTable[ eOp ]; + static String s_sEmpty; + return s_sEmpty; + } + + /// Get the grammar. + inline FormulaGrammar::Grammar getGrammar() const { return meGrammar; } + + /// Get the symbol count. + inline USHORT getSymbolCount() const { return mnSymbols; } + + /** Are these English symbols, as opposed to native language (which may + be English as well)? */ + inline bool isEnglish() const { return mbEnglish; } + + /// Is it an internal core mapping, or setup by filters? + inline bool isCore() const { return mbCore; } + + /// Is it an ODF 1.1 compatibility mapping? + inline bool isPODF() const { return FormulaGrammar::isPODF( meGrammar); } + + /// Is it an ODFF / ODF 1.2 mapping? + inline bool isODFF() const { return FormulaGrammar::isODFF( meGrammar); } + + /// Does it have external symbol/name mappings? + inline bool hasExternals() const { return !mpExternalHashMap->empty(); } + + /// Put entry of symbol String and OpCode pair. + void putOpCode( const String & rStr, const OpCode eOp ); + + /// Put entry of symbol String and AddIn international String pair. + void putExternal( const String & rSymbol, const String & rAddIn ); + + /** Put entry of symbol String and AddIn international String pair, + failing silently if rAddIn name already exists. */ + void putExternalSoftly( const String & rSymbol, const String & rAddIn ); + + /// Core implementation of XFormulaOpCodeMapper::getMappings() + ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > + createSequenceOfFormulaTokens(const FormulaCompiler& _rCompiler, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames ) const; + + /// Core implementation of XFormulaOpCodeMapper::getAvailableMappings() + ::com::sun::star::uno::Sequence< + ::com::sun::star::sheet::FormulaOpCodeMapEntry > + createSequenceOfAvailableMappings( const FormulaCompiler& _rCompiler,const sal_Int32 nGroup ) const; + + /** The value used in createSequenceOfAvailableMappings() and thus in + XFormulaOpCodeMapper::getMappings() for an unknown symbol. */ + static sal_Int32 getOpCodeUnknown(); + }; + +public: + typedef ::boost::shared_ptr< const OpCodeMap > OpCodeMapPtr; + typedef ::boost::shared_ptr< OpCodeMap > NonConstOpCodeMapPtr; + + /** Get OpCodeMap for formula language. + @param nLanguage + One of ::com::sun::star::sheet::FormulaLanguage constants. + @return Map for nLanguage. If nLanguage is unknown, a NULL map is returned. + */ + OpCodeMapPtr GetOpCodeMap( const sal_Int32 nLanguage ) const; + + /** Create an internal symbol map from API mapping. + @param bEnglish + Use English number parser / formatter instead of native. + */ + OpCodeMapPtr CreateOpCodeMap( + const ::com::sun::star::uno::Sequence< + const ::com::sun::star::sheet::FormulaOpCodeMapEntry > & rMapping, + bool bEnglish ); + + /** Get OpCode for English symbol. + Used in XFunctionAccess to create token array. + @param rName + Symbol to lookup. MUST be upper case. + */ + OpCode GetEnglishOpCode( const String& rName ) const; + + static BOOL DeQuote( String& rStr ); + + static const String& GetNativeSymbol( OpCode eOp ); + static BOOL IsMatrixFunction(OpCode _eOpCode); // if a function _always_ returns a Matrix + + short GetNumFormatType() const { return nNumFmt; } + BOOL CompileTokenArray(); + + void CreateStringFromTokenArray( String& rFormula ); + void CreateStringFromTokenArray( rtl::OUStringBuffer& rBuffer ); + FormulaToken* CreateStringFromToken( String& rFormula, FormulaToken* pToken, + BOOL bAllowArrAdvance = FALSE ); + FormulaToken* CreateStringFromToken( rtl::OUStringBuffer& rBuffer, FormulaToken* pToken, + BOOL bAllowArrAdvance = FALSE ); + + void AppendBoolean( rtl::OUStringBuffer& rBuffer, bool bVal ); + void AppendDouble( rtl::OUStringBuffer& rBuffer, double fVal ); + void AppendString( rtl::OUStringBuffer& rBuffer, const String & rStr ); + + /** Set symbol map corresponding to one of predefined formula::FormulaGrammar::Grammar, + including an address reference convention. */ + inline FormulaGrammar::Grammar GetGrammar() const { return meGrammar; } + +protected: + virtual String FindAddInFunction( const String& rUpperName, BOOL bLocalFirst ) const; + virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const; + virtual void fillFromAddInMap( NonConstOpCodeMapPtr xMap, FormulaGrammar::Grammar _eGrammar ) const; + virtual void fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) const; + virtual void fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& _rVec,bool _bIsEnglish) const; + + virtual void SetError(USHORT nError); + virtual FormulaTokenRef ExtendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2, bool bReuseDoubleRef ); + virtual BOOL HandleRange(); + virtual BOOL HandleSingleRef(); + virtual BOOL HandleDbData(); + + virtual void CreateStringFromSingleRef(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP); + virtual void CreateStringFromDoubleRef(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP); + virtual void CreateStringFromMatrix(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP); + virtual void CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP); + virtual void LocalizeString( String& rName ); // modify rName - input: exact name + virtual BOOL IsImportingXML() const; + + BOOL GetToken(); + OpCode NextToken(); + void PutCode( FormulaTokenRef& ); + void Factor(); + void RangeLine(); + void UnionLine(); + void IntersectionLine(); + void UnaryLine(); + void PostOpLine(); + void PowLine(); + void MulDivLine(); + void AddSubLine(); + void ConcatLine(); + void CompareLine(); + void NotLine(); + OpCode Expression(); + void PopTokenArray(); + void PushTokenArray( FormulaTokenArray*, BOOL = FALSE ); + + bool MergeRangeReference( FormulaToken * * const pCode1, FormulaToken * const * const pCode2 ); + + String aCorrectedFormula; // autocorrected Formula + String aCorrectedSymbol; // autocorrected Symbol + + OpCodeMapPtr mxSymbols; // which symbols are used + + FormulaTokenRef pToken; // current token + FormulaTokenRef pCurrentFactorToken; // current factor token (of Factor() method) + FormulaTokenArray* pArr; + + FormulaToken** pCode; + FormulaArrayStack* pStack; + + OpCode eLastOp; + short nRecursion; // GetToken() recursions + short nNumFmt; // set during CompileTokenArray() + USHORT pc; + + FormulaGrammar::Grammar + meGrammar; // The grammar used, language plus convention. + + 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 + BOOL glSubTotal; // if code contains one or more subtotal functions +private: + void InitSymbolsNative() const; /// only SymbolsNative, on first document creation + void InitSymbolsEnglish() const; /// only SymbolsEnglish, maybe later + void InitSymbolsPODF() const; /// only SymbolsPODF, on demand + void InitSymbolsODFF() const; /// only SymbolsODFF, on demand + + void loadSymbols(USHORT _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const; + + static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& 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 FormulaCompiler::CurrentFactor; + class CurrentFactor + { + FormulaTokenRef pPrevFac; + FormulaCompiler* pCompiler; + // not implemented + CurrentFactor( const CurrentFactor& ); + CurrentFactor& operator=( const CurrentFactor& ); + public: + explicit CurrentFactor( FormulaCompiler* pComp ) + : pPrevFac( pComp->pCurrentFactorToken ) + , pCompiler( pComp ) + {} + ~CurrentFactor() + { pCompiler->pCurrentFactorToken = pPrevFac; } + // yes, this operator= may modify the RValue + void operator=( FormulaTokenRef& r ) + { + ForceArrayOperator( r, pPrevFac); + pCompiler->pCurrentFactorToken = r; + } + void operator=( FormulaToken* p ) + { + FormulaTokenRef xTemp( p ); + *this = xTemp; + } + operator FormulaTokenRef&() + { return pCompiler->pCurrentFactorToken; } + FormulaToken* operator->() + { return pCompiler->pCurrentFactorToken.operator->(); } + operator FormulaToken*() + { return operator->(); } + }; + + + mutable NonConstOpCodeMapPtr mxSymbolsODFF; // ODFF symbols + mutable NonConstOpCodeMapPtr mxSymbolsPODF; // ODF 1.1 symbols + mutable NonConstOpCodeMapPtr mxSymbolsNative; // native symbols + mutable NonConstOpCodeMapPtr mxSymbolsEnglish; // English symbols +}; +// ============================================================================= +} // formula +// ============================================================================= + +#endif // FORMULA_COMPILER_HXX_INCLUDED + + diff --git a/formula/inc/formula/FormulaOpCodeMapperObj.hxx b/formula/inc/formula/FormulaOpCodeMapperObj.hxx new file mode 100644 index 000000000000..fa6761746f39 --- /dev/null +++ b/formula/inc/formula/FormulaOpCodeMapperObj.hxx @@ -0,0 +1,89 @@ +/*************************************************************************
+ *
+ * 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: tokenuno.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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 FORMULA_FORMULAOPCODEMAPPER_HXX_INCLUDED
+#define FORMULA_FORMULAOPCODEMAPPER_HXX_INCLUDED
+
+#include "formula/formuladllapi.h"
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <memory>
+#include "formula/FormulaCompiler.hxx"
+
+
+namespace formula
+{
+
+class FORMULA_DLLPUBLIC FormulaOpCodeMapperObj : public ::cppu::WeakImplHelper2<
+ ::com::sun::star::sheet::XFormulaOpCodeMapper,
+ ::com::sun::star::lang::XServiceInfo >
+{
+ ::std::auto_ptr<FormulaCompiler> m_pCompiler;
+public:
+ static ::rtl::OUString getImplementationName_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString> getSupportedServiceNames_Static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext);
+
+protected:
+ FormulaOpCodeMapperObj(::std::auto_ptr<FormulaCompiler> _pCompiler);
+ virtual ~FormulaOpCodeMapperObj();
+
+private:
+ // XFormulaOpCodeMapper
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getOpCodeExternal() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getOpCodeUnknown() throw (::com::sun::star::uno::RuntimeException);
+ // Methods
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL getMappings(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames,
+ sal_Int32 nLanguage )
+ throw ( ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > SAL_CALL getAvailableMappings(
+ sal_Int32 nLanguage, sal_Int32 nGroups )
+ throw ( ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+};
+// =============================================================================
+} // formula
+// =============================================================================
+
+#endif // FORMULA_FORMULAOPCODEMAPPER_HXX_INCLUDED
diff --git a/formula/inc/formula/IControlReferenceHandler.hxx b/formula/inc/formula/IControlReferenceHandler.hxx new file mode 100644 index 000000000000..3642258f8877 --- /dev/null +++ b/formula/inc/formula/IControlReferenceHandler.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * + * 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: formula.hxx,v $ + * $Revision: 1.5 $ + * + * 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 FORMULA_ICONTROL_REFERENCE_HANDLER_HXX_INCLUDED +#define FORMULA_ICONTROL_REFERENCE_HANDLER_HXX_INCLUDED + +#include "formula/formuladllapi.h" + +namespace formula +{ + class RefEdit; + class RefButton; + class FORMULA_DLLPUBLIC SAL_NO_VTABLE IControlReferenceHandler + { + public: + virtual void ShowReference(const String& _sRef) = 0; + virtual void HideReference( BOOL bDoneRefMode = TRUE ) = 0; + virtual void ReleaseFocus( RefEdit* pEdit, RefButton* pButton = NULL ) = 0; + virtual void ToggleCollapsed( RefEdit* pEdit, RefButton* pButton = NULL ) = 0; + }; +} // formula +#endif // FORMULA_ICONTROL_REFERENCE_HANDLER_HXX_INCLUDED diff --git a/formula/inc/formula/IFunctionDescription.hxx b/formula/inc/formula/IFunctionDescription.hxx new file mode 100644 index 000000000000..0ab5fd441add --- /dev/null +++ b/formula/inc/formula/IFunctionDescription.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * 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: funcpage.hxx,v $ + * $Revision: 1.4 $ + * + * 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 INCLUDE_FUNCTION_DESCRIPTION +#define INCLUDE_FUNCTION_DESCRIPTION + +#include <vector> +#include <memory> +#include "formula/formuladllapi.h" +#include <rtl/ustring.hxx> +#include <tools/string.hxx> +#include <com/sun/star/sheet/XFormulaParser.hpp> +#include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp> + +class SvLBoxEntry; + +namespace formula +{ + class IFunctionCategory; + class IFunctionDescription; + class FormEditData; + class FormulaTokenArray; + + // ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); + class SAL_NO_VTABLE IFunctionManager + { + public: + IFunctionManager(){} + enum EToken + { + eOk, + eClose, + eSep, + eArrayOpen, + eArrayClose + }; + virtual sal_uInt32 getCount() const = 0; + virtual const IFunctionCategory* getCategory(sal_uInt32 nPos) const = 0; + virtual void fillLastRecentlyUsedFunctions(::std::vector< const IFunctionDescription*>& _rLastRUFunctions) const = 0; + virtual const IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const = 0; + + virtual const sal_Unicode getSingleToken(const EToken _eToken) const = 0; + }; + + class SAL_NO_VTABLE IFunctionCategory + { + public: + IFunctionCategory(){} + virtual const IFunctionManager* getFunctionManager() const = 0; + virtual sal_uInt32 getCount() const = 0; + virtual const IFunctionDescription* getFunction(sal_uInt32 _nPos) const = 0; + virtual sal_uInt32 getNumber() const = 0; + virtual ::rtl::OUString getName() const = 0; + }; + + class SAL_NO_VTABLE IFunctionDescription + { + public: + IFunctionDescription(){} + virtual ::rtl::OUString getFunctionName() const = 0; + virtual const IFunctionCategory* getCategory() const = 0; + virtual ::rtl::OUString getDescription() const = 0; + // GetSuppressedArgCount + virtual xub_StrLen getSuppressedArgumentCount() const = 0; + // GetFormulaString + virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const = 0; + // GetVisibleArgMapping + virtual void fillVisibleArgumentMapping(::std::vector<USHORT>& _rArguments) const = 0; + virtual void initArgumentInfo() const = 0; + virtual ::rtl::OUString getSignature() const = 0; + virtual long getHelpId() const = 0; + + // parameter + virtual sal_uInt32 getParameterCount() const = 0; + virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const = 0; + virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const = 0; + virtual bool isParameterOptional(sal_uInt32 _nPos) const = 0; + }; + + class SAL_NO_VTABLE IFormulaToken + { + public: + virtual bool isFunction() const = 0; + /* + OpCode eOp = pToken->GetOpCode(); + if(!(pToken->IsFunction()|| ocArcTan2<=eOp)) + */ + virtual sal_uInt32 getArgumentCount() const = 0; + }; + + class SAL_NO_VTABLE IStructHelper + { + public: + IStructHelper(){} + virtual SvLBoxEntry* InsertEntry(const XubString& rText, SvLBoxEntry* pParent, + USHORT nFlag,ULONG nPos=0,IFormulaToken* pScToken=NULL) = 0; + + virtual String GetEntryText(SvLBoxEntry* pEntry) const = 0; + virtual SvLBoxEntry* GetParent(SvLBoxEntry* pEntry) const = 0; + }; + + class SAL_NO_VTABLE IFormulaEditorHelper + { + public: + IFormulaEditorHelper(){} + virtual void notifyChange() = 0; + virtual void fill() = 0; + + virtual String getCurrentFormula() const = 0; + virtual void setCurrentFormula(const String& _sReplacement) = 0; + + virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const = 0; + virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd) = 0; + + virtual FormEditData* getFormEditData() const = 0; + virtual bool calculateValue(const String& _sExpression,String& _rResult) = 0; + + virtual void switchBack() = 0; + + virtual void clear() = 0; + virtual void deleteFormData() = 0; + virtual void setReferenceInput(const FormEditData* _pData) = 0; + + virtual IFunctionManager* getFunctionManager() = 0; + virtual ::std::auto_ptr<FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList) = 0; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const = 0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const = 0; + + virtual void setDispatcherLock( BOOL bLock ) = 0; + virtual void dispatch(BOOL _bOK,BOOL _bMartixChecked) = 0; + virtual void doClose(BOOL _bOk) = 0; + virtual void insertEntryToLRUList(const IFunctionDescription* pDesc) = 0; + virtual void showReference(const String& _sFormula) = 0; + }; + +} +#endif //INCLUDE_FUNCTION_DESCRIPTION diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc new file mode 100644 index 000000000000..ecf8348bc83c --- /dev/null +++ b/formula/inc/formula/compiler.hrc @@ -0,0 +1,412 @@ +/************************************************************************* + * + * 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: compiler.hrc,v $ + * $Revision: 1.20 $ + * + * 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 FORMULA_COMPILER_HRC +#define FORMULA_COMPILER_HRC + +/* Central definition of OpCodes for spreadsheet functions */ + +/*** Special commands ***/ +#define SC_OPCODE_PUSH 0 /* internal commands */ +#define SC_OPCODE_CALL 1 +#define SC_OPCODE_STOP 2 +#define SC_OPCODE_EXTERNAL 3 +#define SC_OPCODE_NAME 4 +#define SC_OPCODE_IF 5 /* jump commands */ +#define SC_OPCODE_CHOSE 6 +#define SC_OPCODE_OPEN 7 /* parentheses and separators */ +#define SC_OPCODE_CLOSE 8 +#define SC_OPCODE_SEP 9 +#define SC_OPCODE_MISSING 10 /* special OpCodes */ +#define SC_OPCODE_BAD 11 +#define SC_OPCODE_SPACES 12 +#define SC_OPCODE_MAT_REF 13 +#define SC_OPCODE_DB_AREA 14 /* additional access operators */ +#define SC_OPCODE_MACRO 15 +#define SC_OPCODE_COL_ROW_NAME 16 +#define SC_OPCODE_COL_ROW_NAME_AUTO 17 +#define SC_OPCODE_PERCENT_SIGN 18 /* operator _follows_ value */ +#define SC_OPCODE_ARRAY_OPEN 19 +#define SC_OPCODE_ARRAY_CLOSE 20 +#define SC_OPCODE_ARRAY_ROW_SEP 21 +#define SC_OPCODE_ARRAY_COL_SEP 22 /* some convs use sep != col_sep */ +#define SC_OPCODE_STOP_DIV 23 + +/*** error constants #... ***/ +#define SC_OPCODE_START_ERRORS 30 +#define SC_OPCODE_ERROR_NULL 30 +#define SC_OPCODE_ERROR_DIVZERO 31 +#define SC_OPCODE_ERROR_VALUE 32 +#define SC_OPCODE_ERROR_REF 33 +#define SC_OPCODE_ERROR_NAME 34 +#define SC_OPCODE_ERROR_NUM 35 +#define SC_OPCODE_ERROR_NA 36 +#define SC_OPCODE_STOP_ERRORS 37 + +/*** Binary operators ***/ +#define SC_OPCODE_START_BIN_OP 40 +#define SC_OPCODE_ADD 40 +#define SC_OPCODE_SUB 41 +#define SC_OPCODE_MUL 42 +#define SC_OPCODE_DIV 43 +#define SC_OPCODE_AMPERSAND 44 +#define SC_OPCODE_POW 45 +#define SC_OPCODE_EQUAL 46 +#define SC_OPCODE_NOT_EQUAL 47 +#define SC_OPCODE_LESS 48 +#define SC_OPCODE_GREATER 49 +#define SC_OPCODE_LESS_EQUAL 50 +#define SC_OPCODE_GREATER_EQUAL 51 +#define SC_OPCODE_AND 52 +#define SC_OPCODE_OR 53 +#define SC_OPCODE_INTERSECT 54 +#define SC_OPCODE_UNION 55 +#define SC_OPCODE_RANGE 56 +#define SC_OPCODE_STOP_BIN_OP 57 + +/* NOTE: binary and unary operators must be in sequence for compiler! */ + +/*** Unary operators ***/ +#define SC_OPCODE_START_UN_OP 60 +#define SC_OPCODE_NOT 60 +#define SC_OPCODE_NEG 61 +#define SC_OPCODE_NEG_SUB 62 +#define SC_OPCODE_STOP_UN_OP 63 + +/*** Functions without parameters ***/ +#define SC_OPCODE_START_NO_PAR 65 +#define SC_OPCODE_PI 65 +#define SC_OPCODE_RANDOM 66 +#define SC_OPCODE_TRUE 67 +#define SC_OPCODE_FALSE 68 +#define SC_OPCODE_GET_ACT_DATE 69 +#define SC_OPCODE_GET_ACT_TIME 70 +#define SC_OPCODE_NO_VALUE 71 +#define SC_OPCODE_CURRENT 72 +#define SC_OPCODE_STOP_NO_PAR 73 + +/*** Functions with one parameter ***/ +#define SC_OPCODE_START_1_PAR 80 +#define SC_OPCODE_DEG 80 /* trigonometric */ +#define SC_OPCODE_RAD 81 +#define SC_OPCODE_SIN 82 +#define SC_OPCODE_COS 83 +#define SC_OPCODE_TAN 84 +#define SC_OPCODE_COT 85 +#define SC_OPCODE_ARC_SIN 86 +#define SC_OPCODE_ARC_COS 87 +#define SC_OPCODE_ARC_TAN 88 +#define SC_OPCODE_ARC_COT 89 +#define SC_OPCODE_SIN_HYP 90 +#define SC_OPCODE_COS_HYP 91 +#define SC_OPCODE_TAN_HYP 92 +#define SC_OPCODE_COT_HYP 93 +#define SC_OPCODE_ARC_SIN_HYP 94 /* transcendent */ +#define SC_OPCODE_ARC_COS_HYP 95 +#define SC_OPCODE_ARC_TAN_HYP 96 +#define SC_OPCODE_ARC_COT_HYP 97 +#define SC_OPCODE_EXP 98 +#define SC_OPCODE_LN 99 +#define SC_OPCODE_SQRT 100 +#define SC_OPCODE_FACT 101 +#define SC_OPCODE_GET_YEAR 102 /* date and time */ +#define SC_OPCODE_GET_MONTH 103 +#define SC_OPCODE_GET_DAY 104 +#define SC_OPCODE_GET_HOUR 105 +#define SC_OPCODE_GET_MIN 106 +#define SC_OPCODE_GET_SEC 107 +#define SC_OPCODE_PLUS_MINUS 108 /* miscellaneous */ +#define SC_OPCODE_ABS 109 +#define SC_OPCODE_INT 110 +#define SC_OPCODE_PHI 111 +#define SC_OPCODE_GAUSS 112 +#define SC_OPCODE_IS_EMPTY 113 /* obtain type */ +#define SC_OPCODE_IS_STRING 114 +#define SC_OPCODE_IS_NON_STRING 115 +#define SC_OPCODE_IS_LOGICAL 116 +#define SC_OPCODE_TYPE 117 +#define SC_OPCODE_IS_REF 118 +#define SC_OPCODE_IS_VALUE 119 +#define SC_OPCODE_IS_FORMULA 120 +#define SC_OPCODE_IS_NV 121 +#define SC_OPCODE_IS_ERR 122 +#define SC_OPCODE_IS_ERROR 123 +#define SC_OPCODE_IS_EVEN 124 +#define SC_OPCODE_IS_ODD 125 +#define SC_OPCODE_N 126 +#define SC_OPCODE_GET_DATE_VALUE 127 /* string functions */ +#define SC_OPCODE_GET_TIME_VALUE 128 +#define SC_OPCODE_CODE 129 +#define SC_OPCODE_TRIM 130 +#define SC_OPCODE_UPPER 131 +#define SC_OPCODE_PROPPER 132 +#define SC_OPCODE_LOWER 133 +#define SC_OPCODE_LEN 134 +#define SC_OPCODE_T 135 /* miscellaneous, part 21 */ +#define SC_OPCODE_VALUE 136 +#define SC_OPCODE_CLEAN 137 +#define SC_OPCODE_CHAR 138 +#define SC_OPCODE_LOG10 139 +#define SC_OPCODE_EVEN 140 +#define SC_OPCODE_ODD 141 +#define SC_OPCODE_STD_NORM_DIST 142 +#define SC_OPCODE_FISHER 143 +#define SC_OPCODE_FISHER_INV 144 +#define SC_OPCODE_S_NORM_INV 145 +#define SC_OPCODE_GAMMA_LN 146 +#define SC_OPCODE_ERROR_TYPE 147 +#define SC_OPCODE_ERR_CELL 148 +#define SC_OPCODE_FORMULA 149 +#define SC_OPCODE_ARABIC 150 +#define SC_OPCODE_INFO 151 +#define SC_OPCODE_BAHTTEXT 152 +#define SC_OPCODE_JIS 153 +#define SC_OPCODE_ASC 154 +#define SC_OPCODE_UNICODE 155 +#define SC_OPCODE_UNICHAR 156 +#define SC_OPCODE_GAMMA 157 +#define SC_OPCODE_STOP_1_PAR 158 + +/*** Functions with more than one parameters ***/ +#define SC_OPCODE_START_2_PAR 201 +#define SC_OPCODE_ARC_TAN_2 201 +#define SC_OPCODE_CEIL 202 +#define SC_OPCODE_FLOOR 203 +#define SC_OPCODE_ROUND 204 +#define SC_OPCODE_ROUND_UP 205 +#define SC_OPCODE_ROUND_DOWN 206 +#define SC_OPCODE_TRUNC 207 +#define SC_OPCODE_LOG 208 +#define SC_OPCODE_POWER 209 +#define SC_OPCODE_GGT 210 +#define SC_OPCODE_KGV 211 +#define SC_OPCODE_MOD 212 +#define SC_OPCODE_SUM_PRODUCT 213 +#define SC_OPCODE_SUM_SQ 214 +#define SC_OPCODE_SUM_X2MY2 215 +#define SC_OPCODE_SUM_X2DY2 216 +#define SC_OPCODE_SUM_XMY2 217 +#define SC_OPCODE_GET_DATE 218 +#define SC_OPCODE_GET_TIME 219 +#define SC_OPCODE_GET_DIFF_DATE 220 +#define SC_OPCODE_GET_DIFF_DATE_360 221 +#define SC_OPCODE_MIN 222 +#define SC_OPCODE_MAX 223 +#define SC_OPCODE_SUM 224 +#define SC_OPCODE_PRODUCT 225 +#define SC_OPCODE_AVERAGE 226 +#define SC_OPCODE_COUNT 227 +#define SC_OPCODE_COUNT_2 228 +#define SC_OPCODE_NBW 229 +#define SC_OPCODE_IKV 230 +#define SC_OPCODE_VAR 231 +#define SC_OPCODE_VAR_P 232 +#define SC_OPCODE_ST_DEV 233 +#define SC_OPCODE_ST_DEV_P 234 +#define SC_OPCODE_B 235 +#define SC_OPCODE_NORM_DIST 236 +#define SC_OPCODE_EXP_DIST 237 +#define SC_OPCODE_BINOM_DIST 238 +#define SC_OPCODE_POISSON_DIST 239 +#define SC_OPCODE_KOMBIN 240 +#define SC_OPCODE_KOMBIN_2 241 +#define SC_OPCODE_VARIATIONEN 242 +#define SC_OPCODE_VARIATIONEN_2 243 +#define SC_OPCODE_BW 244 +#define SC_OPCODE_DIA 245 +#define SC_OPCODE_GDA 246 +#define SC_OPCODE_GDA_2 247 +#define SC_OPCODE_VBD 248 +#define SC_OPCODE_LAUFZ 249 +#define SC_OPCODE_LIA 250 +#define SC_OPCODE_RMZ 251 +#define SC_OPCODE_COLUMNS 252 +#define SC_OPCODE_ROWS 253 +#define SC_OPCODE_COLUMN 254 +#define SC_OPCODE_ROW 255 +#define SC_OPCODE_ZGZ 256 +#define SC_OPCODE_ZW 257 +#define SC_OPCODE_ZZR 258 +#define SC_OPCODE_ZINS 259 +#define SC_OPCODE_ZINS_Z 260 +#define SC_OPCODE_KAPZ 261 +#define SC_OPCODE_KUM_ZINS_Z 262 +#define SC_OPCODE_KUM_KAP_Z 263 +#define SC_OPCODE_EFFEKTIV 264 +#define SC_OPCODE_NOMINAL 265 +#define SC_OPCODE_SUB_TOTAL 266 +#define SC_OPCODE_DB_SUM 267 /* database functions */ +#define SC_OPCODE_DB_COUNT 268 +#define SC_OPCODE_DB_COUNT_2 269 +#define SC_OPCODE_DB_AVERAGE 270 +#define SC_OPCODE_DB_GET 271 +#define SC_OPCODE_DB_MAX 272 +#define SC_OPCODE_DB_MIN 273 +#define SC_OPCODE_DB_PRODUCT 274 +#define SC_OPCODE_DB_STD_DEV 275 +#define SC_OPCODE_DB_STD_DEV_P 276 +#define SC_OPCODE_DB_VAR 277 +#define SC_OPCODE_DB_VAR_P 278 +#define SC_OPCODE_INDIRECT 279 /* management functions */ +#define SC_OPCODE_ADDRESS 280 +#define SC_OPCODE_MATCH 281 +#define SC_OPCODE_COUNT_EMPTY_CELLS 282 +#define SC_OPCODE_COUNT_IF 283 +#define SC_OPCODE_SUM_IF 284 +#define SC_OPCODE_LOOKUP 285 +#define SC_OPCODE_V_LOOKUP 286 +#define SC_OPCODE_H_LOOKUP 287 +#define SC_OPCODE_MULTI_AREA 288 +#define SC_OPCODE_OFFSET 289 +#define SC_OPCODE_INDEX 290 +#define SC_OPCODE_AREAS 291 +#define SC_OPCODE_CURRENCY 292 /* string functions */ +#define SC_OPCODE_REPLACE 293 +#define SC_OPCODE_FIXED 294 +#define SC_OPCODE_FIND 295 +#define SC_OPCODE_EXACT 296 +#define SC_OPCODE_LEFT 297 +#define SC_OPCODE_RIGHT 298 +#define SC_OPCODE_SEARCH 299 +#define SC_OPCODE_MID 300 +#define SC_OPCODE_TEXT 301 +#define SC_OPCODE_SUBSTITUTE 302 +#define SC_OPCODE_REPT 303 +#define SC_OPCODE_CONCAT 304 +#define SC_OPCODE_MAT_VALUE 305 /* matrix functions */ +#define SC_OPCODE_MAT_DET 306 +#define SC_OPCODE_MAT_INV 307 +#define SC_OPCODE_MAT_MULT 308 +#define SC_OPCODE_MAT_TRANS 309 +#define SC_OPCODE_MATRIX_UNIT 310 +#define SC_OPCODE_BACK_SOLVER 311 /* BackSolver */ +#define SC_OPCODE_HYP_GEOM_DIST 312 /* statistical functions */ +#define SC_OPCODE_LOG_NORM_DIST 313 +#define SC_OPCODE_T_DIST 314 +#define SC_OPCODE_F_DIST 315 +#define SC_OPCODE_CHI_DIST 316 +#define SC_OPCODE_WEIBULL 317 +#define SC_OPCODE_NEG_BINOM_VERT 318 +#define SC_OPCODE_KRIT_BINOM 319 +#define SC_OPCODE_KURT 320 +#define SC_OPCODE_HAR_MEAN 321 +#define SC_OPCODE_GEO_MEAN 322 +#define SC_OPCODE_STANDARD 323 +#define SC_OPCODE_AVE_DEV 324 +#define SC_OPCODE_SCHIEFE 325 +#define SC_OPCODE_DEV_SQ 326 +#define SC_OPCODE_MEDIAN 327 +#define SC_OPCODE_MODAL_VALUE 328 +#define SC_OPCODE_Z_TEST 329 +#define SC_OPCODE_T_TEST 330 +#define SC_OPCODE_RANK 331 +#define SC_OPCODE_PERCENTILE 332 +#define SC_OPCODE_PERCENT_RANK 333 +#define SC_OPCODE_LARGE 334 +#define SC_OPCODE_SMALL 335 +#define SC_OPCODE_FREQUENCY 336 +#define SC_OPCODE_QUARTILE 337 +#define SC_OPCODE_NORM_INV 338 +#define SC_OPCODE_CONFIDENCE 339 +#define SC_OPCODE_F_TEST 340 +#define SC_OPCODE_TRIM_MEAN 341 +#define SC_OPCODE_PROB 342 +#define SC_OPCODE_CORREL 343 +#define SC_OPCODE_COVAR 344 +#define SC_OPCODE_PEARSON 345 +#define SC_OPCODE_RSQ 346 +#define SC_OPCODE_STEYX 347 +#define SC_OPCODE_SLOPE 348 +#define SC_OPCODE_INTERCEPT 349 +#define SC_OPCODE_TREND 350 +#define SC_OPCODE_GROWTH 351 +#define SC_OPCODE_RGP 352 +#define SC_OPCODE_RKP 353 +#define SC_OPCODE_FORECAST 354 +#define SC_OPCODE_CHI_INV 355 +#define SC_OPCODE_GAMMA_DIST 356 +#define SC_OPCODE_GAMMA_INV 357 +#define SC_OPCODE_T_INV 358 +#define SC_OPCODE_F_INV 359 +#define SC_OPCODE_CHI_TEST 360 +#define SC_OPCODE_LOG_INV 361 +#define SC_OPCODE_TABLE_OP 362 +#define SC_OPCODE_BETA_DIST 363 +#define SC_OPCODE_BETA_INV 364 +#define SC_OPCODE_WEEK 365 /* miscellaneous */ +#define SC_OPCODE_GET_DAY_OF_WEEK 366 +#define SC_OPCODE_NO_NAME 367 +#define SC_OPCODE_STYLE 368 +#define SC_OPCODE_DDE 369 +#define SC_OPCODE_BASE 370 +#define SC_OPCODE_TABLE 371 +#define SC_OPCODE_TABLES 372 +#define SC_OPCODE_MIN_A 373 +#define SC_OPCODE_MAX_A 374 +#define SC_OPCODE_AVERAGE_A 375 +#define SC_OPCODE_ST_DEV_A 376 +#define SC_OPCODE_ST_DEV_P_A 377 +#define SC_OPCODE_VAR_A 378 +#define SC_OPCODE_VAR_P_A 379 +#define SC_OPCODE_EASTERSUNDAY 380 +#define SC_OPCODE_DECIMAL 381 +#define SC_OPCODE_CONVERT 382 +#define SC_OPCODE_ROMAN 383 +#define SC_OPCODE_MIRR 384 +#define SC_OPCODE_CELL 385 +#define SC_OPCODE_ISPMT 386 +#define SC_OPCODE_HYPERLINK 387 +#define SC_OPCODE_INDIRECT_XL 388 /* See also INDIRECT for OOO variant */ +#define SC_OPCODE_ADDRESS_XL 389 /* See also ADRESS for OOO variant */ +#define SC_OPCODE_GET_PIVOT_DATA 390 +#define SC_OPCODE_EUROCONVERT 391 +#define SC_OPCODE_NUMBERVALUE 392 +#define SC_OPCODE_CHISQ_DIST 393 +#define SC_OPCODE_CHISQ_INV 394 +#define SC_OPCODE_STOP_2_PAR 395 + +#define SC_OPCODE_LAST_OPCODE_ID 394 /* last OpCode */ + +/*** Interna ***/ +#define SC_OPCODE_INTERNAL_BEGIN 9995 +#define SC_OPCODE_GAME 9995 +#define SC_OPCODE_SPEW 9996 +#define SC_OPCODE_TTT 9997 +#define SC_OPCODE_TEAM 9998 +#define SC_OPCODE_ANSWER 9999 +#define SC_OPCODE_INTERNAL_END 9999 + +/*** from here on ExtraData contained ***/ +#define SC_OPCODE_DATA_TOKEN_1 10000 + +#define SC_OPCODE_NONE 0xFFFF + + +#endif /* FORMULA_COMPILER_HRC */ diff --git a/formula/inc/formula/errorcodes.hxx b/formula/inc/formula/errorcodes.hxx new file mode 100644 index 000000000000..077129eb046c --- /dev/null +++ b/formula/inc/formula/errorcodes.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * 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: errorcodes.hxx,v $ + * $Revision: 1.6 $ + * + * 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_ERRORCODES_HXX +#define SC_ERRORCODES_HXX + +#include <rtl/math.hxx> +#include <tools/solar.h> + +namespace ScErrorCodes +{ + +const USHORT errIllegalChar = 501; +const USHORT errIllegalArgument = 502; +const USHORT errIllegalFPOperation = 503; // #NUM! +const USHORT errIllegalParameter = 504; +const USHORT errIllegalJump = 505; +const USHORT errSeparator = 506; +const USHORT errPair = 507; +const USHORT errPairExpected = 508; +const USHORT errOperatorExpected = 509; +const USHORT errVariableExpected = 510; +const USHORT errParameterExpected = 511; +const USHORT errCodeOverflow = 512; +const USHORT errStringOverflow = 513; +const USHORT errStackOverflow = 514; +const USHORT errUnknownState = 515; +const USHORT errUnknownVariable = 516; +const USHORT errUnknownOpCode = 517; +const USHORT errUnknownStackVariable = 518; +const USHORT errNoValue = 519; // #VALUE! +const USHORT errUnknownToken = 520; +const USHORT errNoCode = 521; // #NULL! +const USHORT errCircularReference = 522; +const USHORT errNoConvergence = 523; +const USHORT errNoRef = 524; // #REF! +const USHORT errNoName = 525; // #NAME? +const USHORT errDoubleRef = 526; +const USHORT errInterpOverflow = 527; +// Not displayed, temporary for TrackFormulas, +// Cell depends on another cell that has errCircularReference +const USHORT errTrackFromCircRef = 528; +// Interpreter internal: existing cell has no value but value queried +const USHORT errCellNoValue = 529; +// Interpreter: needed AddIn not found +const USHORT errNoAddin = 530; +// Interpreter: needed Macro not found +const USHORT errNoMacro = 531; +// Interpreter: Division by zero +const USHORT errDivisionByZero = 532; // #DIV/0! +// Compiler: a non-simple (str,err,val) value was put in an array +const USHORT errNestedArray = 533; + +// Interpreter: NA() not available condition, not a real error +const USHORT NOTAVAILABLE = 0x7fff; + + +/** Unconditionally construct a double value of NAN where the lower bits + represent an interpreter error code. */ +inline double CreateDoubleError( USHORT nErr ) +{ + double fVal; + ::rtl::math::setNan( &fVal ); + reinterpret_cast< sal_math_Double * >(&fVal)->nan_parts.fraction_lo = nErr; + return fVal; +} + + +/** Recreate the error code of a coded double error, if any. */ +inline USHORT GetDoubleErrorValue( double fVal ) +{ + if ( ::rtl::math::isFinite( fVal ) ) + return 0; + if ( ::rtl::math::isInf( fVal ) ) + return errIllegalFPOperation; // normal INF + UINT32 nErr = reinterpret_cast< sal_math_Double * >( + &fVal)->nan_parts.fraction_lo; + if ( nErr & 0xffff0000 ) + return errNoValue; // just a normal NAN + return (USHORT)(nErr & 0x0000ffff); // any other error +} + +} // namespace ScErrorCodes + +// yes, exceptionally we put a "using namespace" in a header file.. +using namespace ScErrorCodes; + +#endif // SC_ERRORCODES_HXX diff --git a/formula/inc/formula/formdata.hxx b/formula/inc/formula/formdata.hxx new file mode 100644 index 000000000000..44975c5843ed --- /dev/null +++ b/formula/inc/formula/formdata.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * 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: formdata.hxx,v $ + * $Revision: 1.3 $ + * + * 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 FORMULA_FORMDATA_HXX +#define FORMULA_FORMDATA_HXX + +#include <tools/string.hxx> +#include <tools/gen.hxx> +#include "formula/formuladllapi.h" + +//============================================================================ +namespace formula +{ +class FORMULA_DLLPUBLIC FormEditData +{ +public: + FormEditData(); + virtual ~FormEditData(); + + virtual void SaveValues(); + void RestoreValues(); + BOOL HasParent() const { return pParent != NULL; } + + inline USHORT GetMode() const { return nMode; } + inline xub_StrLen GetFStart() const { return nFStart; } + inline USHORT GetCatSel() const { return nCatSel; } + inline USHORT GetFuncSel() const { return nFuncSel; } + inline USHORT GetOffset() const { return nOffset; } + inline USHORT GetEdFocus() const { return nEdFocus; } + inline const String& GetUndoStr() const { return aUndoStr; } + inline BOOL GetMatrixFlag()const{ return bMatrix;} + inline ULONG GetUniqueId()const { return nUniqueId;} + inline const Selection& GetSelection()const { return aSelection;} + + inline void SetMode( USHORT nNew ) { nMode = nNew; } + inline void SetFStart( xub_StrLen nNew ) { nFStart = nNew; } + inline void SetCatSel( USHORT nNew ) { nCatSel = nNew; } + inline void SetFuncSel( USHORT nNew ) { nFuncSel = nNew; } + inline void SetOffset( USHORT nNew ) { nOffset = nNew; } + inline void SetEdFocus( USHORT nNew ) { nEdFocus = nNew; } + inline void SetUndoStr( const String& rNew ) { aUndoStr = rNew; } + inline void SetMatrixFlag(BOOL bNew) { bMatrix=bNew;} + inline void SetUniqueId(ULONG nNew) { nUniqueId=nNew;} + inline void SetSelection(const Selection& aSel) { aSelection=aSel;} +protected: + void Reset(); + FormEditData( const FormEditData& ); + const FormEditData& operator=( const FormEditData& r ); + + FormEditData* pParent; // fuer Verschachtelung +private: + USHORT nMode; // enum ScFormulaDlgMode + xub_StrLen nFStart; + USHORT nCatSel; + USHORT nFuncSel; + USHORT nOffset; + USHORT nEdFocus; + String aUndoStr; + BOOL bMatrix; + ULONG nUniqueId; + Selection aSelection; +}; + + +} // formula +#endif // FORMULA_FORMDATA_HXX + diff --git a/formula/inc/formula/formula.hxx b/formula/inc/formula/formula.hxx new file mode 100644 index 000000000000..df72e4a4ee76 --- /dev/null +++ b/formula/inc/formula/formula.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * 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: formula.hxx,v $ + * $Revision: 1.5 $ + * + * 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 FORMULA_FORMULA_HXX +#define FORMULA_FORMULA_HXX + +#include <sfx2/basedlgs.hxx> +// #include "formula/funcutl.hxx" +#include <memory> +#include "formula/formuladllapi.h" + +namespace formula +{ +//============================================================================ +#define STRUCT_END 1 +#define STRUCT_FOLDER 2 +#define STRUCT_ERROR 3 + +#define STRUCT_ERR_C1 1 +#define STRUCT_ERR_C2 2 + +enum FormulaDlgMode { FORMULA_FORMDLG_FORMULA, FORMULA_FORMDLG_ARGS, FORMULA_FORMDLG_EDIT }; + +//============================================================================ + +class IFormulaEditorHelper; +class FormulaDlg_Impl; +class IControlReferenceHandler; +class IFunctionDescription; +class IFunctionManager; +class FormulaHelper; +class RefEdit; +class RefButton; +//============================================================================ +class FORMULA_DLLPUBLIC FormulaModalDialog : public ModalDialog +{ + friend class FormulaDlg_Impl; +public: + FormulaModalDialog( Window* pParent + , bool _bSupportFunctionResult + , bool _bSupportResult + , bool _bSupportMatrix + ,IFormulaEditorHelper* _pHelper + ,IFunctionManager* _pFunctionMgr + ,IControlReferenceHandler* _pDlg = NULL ); + virtual ~FormulaModalDialog(); +private: + ::std::auto_ptr<FormulaDlg_Impl> m_pImpl; + +protected: + void disableOk(); + +protected: + + virtual long PreNotify( NotifyEvent& rNEvt ); + ::std::pair<RefButton*,RefEdit*> RefInputStartBefore( RefEdit* pEdit, RefButton* pButton = NULL ); + void RefInputStartAfter( RefEdit* pEdit, RefButton* pButton = NULL ); + void RefInputDoneAfter( BOOL bForced = FALSE ); + ULONG FindFocusWin(Window *pWin); + void SetFocusWin(Window *pWin,ULONG nUniqueId); + void HighlightFunctionParas(const String& aFormula); + + void SetMeText(const String& _sText); + FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate); + void Update(); + BOOL CheckMatrix(String& aFormula /*IN/OUT*/); + String GetMeText() const; + void Update(const String& _sExp); + void CheckMatrix(); + void DoEnter(BOOL _bOk); + BOOL isUserMatrix() const; + const IFunctionDescription* getCurrentFunctionDescription() const; + BOOL UpdateParaWin(Selection& _rSelection); + void UpdateParaWin(const Selection& _rSelection,const String& _sRefStr); + RefEdit* GetActiveEdit(); + void SetEdSelection(); + + const FormulaHelper& GetFormulaHelper() const; +}; + +class FORMULA_DLLPUBLIC FormulaDlg : public SfxModelessDialog +{ + friend class FormulaDlg_Impl; +public: + FormulaDlg( SfxBindings* pB + , SfxChildWindow* pCW + , Window* pParent + , bool _bSupportFunctionResult + , bool _bSupportResult + , bool _bSupportMatrix + , IFormulaEditorHelper* _pHelper + , IFunctionManager* _pFunctionMgr + , IControlReferenceHandler* _pDlg = NULL ); + virtual ~FormulaDlg(); +private: + ::std::auto_ptr<FormulaDlg_Impl> m_pImpl; + + DECL_LINK( UpdateFocusHdl, Timer*); +protected: + void disableOk(); + +protected: + + virtual long PreNotify( NotifyEvent& rNEvt ); + ::std::pair<RefButton*,RefEdit*> RefInputStartBefore( RefEdit* pEdit, RefButton* pButton = NULL ); + void RefInputStartAfter( RefEdit* pEdit, RefButton* pButton = NULL ); + void RefInputDoneAfter( BOOL bForced = FALSE ); + ULONG FindFocusWin(Window *pWin); + void SetFocusWin(Window *pWin,ULONG nUniqueId); + void HighlightFunctionParas(const String& aFormula); + + void SetMeText(const String& _sText); + FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate); + void Update(); + BOOL CheckMatrix(String& aFormula /*IN/OUT*/); + String GetMeText() const; + void Update(const String& _sExp); + void CheckMatrix(); + void DoEnter(BOOL _bOk); + BOOL isUserMatrix() const; + const IFunctionDescription* getCurrentFunctionDescription() const; + BOOL UpdateParaWin(Selection& _rSelection); + void UpdateParaWin(const Selection& _rSelection,const String& _sRefStr); + RefEdit* GetActiveEdit(); + void SetEdSelection(); + + const FormulaHelper& GetFormulaHelper() const; +}; + +} // formula + +#endif // FORMULA_FORMULA_HXX + diff --git a/formula/inc/formula/formuladllapi.h b/formula/inc/formula/formuladllapi.h new file mode 100644 index 000000000000..1267756cf9ac --- /dev/null +++ b/formula/inc/formula/formuladllapi.h @@ -0,0 +1,44 @@ +/************************************************************************* + * + * 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: dllapi.h,v $ + * $Revision: 1.3 $ + * + * 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 INCLUDED_FORMULADLLAPI_H +#define INCLUDED_FORMULADLLAPI_H + +#include "sal/types.h" + +#if defined(FORMULA_DLLIMPLEMENTATION) +#define FORMULA_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define FORMULA_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define FORMULA_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_FORMULADLLAPI_H */ + diff --git a/formula/inc/formula/formulahelper.hxx b/formula/inc/formula/formulahelper.hxx new file mode 100644 index 000000000000..44bb72f2f930 --- /dev/null +++ b/formula/inc/formula/formulahelper.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * 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: formula.hxx,v $ + * $Revision: 1.5 $ + * + * 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 FORMULA_FORMULA_HELPER_HXX +#define FORMULA_FORMULA_HELPER_HXX + +#include "formula/IFunctionDescription.hxx" +#include <vector> +#include <tools/string.hxx> +#include <memory> +#include "formula/formuladllapi.h" + +class SvtSysLocale; +class CharClass; + +namespace formula +{ + class FORMULA_DLLPUBLIC FormulaHelper + { + ::std::auto_ptr<SvtSysLocale> m_pSysLocale; + const CharClass* m_pCharClass; + const IFunctionManager* m_pFunctionManager; + const sal_Unicode open; + const sal_Unicode close; + const sal_Unicode sep; + const sal_Unicode arrayOpen; + const sal_Unicode arrayClose; + public: + FormulaHelper(const IFunctionManager* _pFunctionManager); + + inline const CharClass* GetCharClass() const { return m_pCharClass; } + + BOOL GetNextFunc( const String& rFormula, + BOOL bBack, + xub_StrLen& rFStart, // Ein- und Ausgabe + xub_StrLen* pFEnd = NULL, + const IFunctionDescription** ppFDesc = NULL, + ::std::vector< ::rtl::OUString>* pArgs = NULL ) const; + + xub_StrLen GetFunctionStart( const String& rFormula, xub_StrLen nStart, + BOOL bBack, String* pFuncName = NULL ) const; + + xub_StrLen GetFunctionEnd ( const String& rFormula, xub_StrLen nStart ) const; + + xub_StrLen GetArgStart ( const String& rFormula, xub_StrLen nStart, + USHORT nArg ) const; + + void GetArgStrings ( ::std::vector< ::rtl::OUString >& _rArgs, + const String& rFormula, + xub_StrLen nFuncPos, + USHORT nArgs ) const; + + void FillArgStrings ( const String& rFormula, + xub_StrLen nFuncPos, + USHORT nArgs, + ::std::vector< ::rtl::OUString >& _rArgs ) const; + }; +// ============================================================================= +} // formula +// ============================================================================= + +#endif //FORMULA_FORMULA_HELPER_HXX diff --git a/formula/inc/formula/funcutl.hxx b/formula/inc/formula/funcutl.hxx new file mode 100644 index 000000000000..0a8beb539975 --- /dev/null +++ b/formula/inc/formula/funcutl.hxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * 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: funcutl.hxx,v $ + * $Revision: 1.5 $ + * + * 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 FORMULA_FUNCUTL_HXX +#define FORMULA_FUNCUTL_HXX + +// #include <vcl/scrbar.hxx> +#include <vcl/fixed.hxx> +#include <vcl/button.hxx> +#include <vcl/edit.hxx> +#include "formula/formuladllapi.h" + + +namespace formula +{ + class IControlReferenceHandler; + +class FORMULA_DLLPUBLIC RefEdit : public Edit +{ +private: + Timer aTimer; + IControlReferenceHandler* pAnyRefDlg; // parent dialog + BOOL bSilentFocus; // for SilentGrabFocus() + + DECL_LINK( UpdateHdl, Timer* ); + +protected: + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void GetFocus(); + virtual void LoseFocus(); + +public: + RefEdit( Window* _pParent,IControlReferenceHandler* pParent, const ResId& rResId ); + RefEdit( Window* pParent, const ResId& rResId ); + virtual ~RefEdit(); + + void SetRefString( const XubString& rStr ); + using Edit::SetText; + virtual void SetText( const XubString& rStr ); + virtual void Modify(); + + void StartUpdateData(); + + void SilentGrabFocus(); // does not update any references + + void SetRefDialog( IControlReferenceHandler* pDlg ); + inline IControlReferenceHandler* GetRefDialog() { return pAnyRefDlg; } +}; + + +//============================================================================ + +class FORMULA_DLLPUBLIC RefButton : public ImageButton +{ +private: + Image aImgRefStart; /// Start reference input + Image aImgRefStartHC; /// Start reference input (high contrast) + Image aImgRefDone; /// Stop reference input + Image aImgRefDoneHC; /// Stop reference input (high contrast) + IControlReferenceHandler* pAnyRefDlg; // parent dialog + RefEdit* pRefEdit; // zugeordnetes Edit-Control + +protected: + virtual void Click(); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void GetFocus(); + virtual void LoseFocus(); + +public: + RefButton( Window* _pParent, const ResId& rResId); + RefButton( Window* _pParent, const ResId& rResId, RefEdit* pEdit ,IControlReferenceHandler* pDlg); + + void SetReferences( IControlReferenceHandler* pDlg, RefEdit* pEdit ); + + void SetStartImage(); + void SetEndImage(); + inline void DoRef() { Click(); } +}; + +} // formula +#endif // FORMULA_FUNCUTL_HXX + diff --git a/formula/inc/formula/grammar.hxx b/formula/inc/formula/grammar.hxx new file mode 100644 index 000000000000..12c330d3181c --- /dev/null +++ b/formula/inc/formula/grammar.hxx @@ -0,0 +1,239 @@ +/************************************************************************* + * + * 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: grammar.hxx,v $ + * $Revision: 1.4 $ + * + * 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 FORMULA_GRAMMAR_HXX +#define FORMULA_GRAMMAR_HXX + +#include "com/sun/star/sheet/FormulaLanguage.hpp" +#include "formula/formuladllapi.h" +#include <tools/debug.hxx> + +namespace formula +{ + +/** Grammars digested by ScCompiler. + */ +class FORMULA_DLLPUBLIC FormulaGrammar +{ +public: + enum AddressConvention{ + CONV_UNSPECIFIED = -1, /* useful when we want method to chose, must be first */ + + /* elements must be sequential and changes should be reflected in ScCompiler::pCharTables */ + CONV_OOO = 0, /* 'doc'#sheet.A1:sheet2.B2 */ + CONV_ODF, /* ['doc'#sheet.A1:sheet2.B2] */ + CONV_XL_A1, /* [doc]sheet:sheet2!A1:B2 */ + CONV_XL_R1C1, /* [doc]sheet:sheet2!R1C1:R2C2 */ + CONV_XL_OOX, /* [#]sheet:sheet2!A1:B2 */ + + CONV_LOTUS_A1, /* external? 3d? A1.B2 <placeholder/> */ + + CONV_LAST /* for loops, must always be last */ + }; + + //! CONV_UNSPECIFIED is a negative value! + static const int kConventionOffset = - CONV_UNSPECIFIED + 1; + // Room for 32k hypothetical languages plus EXTERNAL. + static const int kConventionShift = 16; + // Room for 256 reference conventions. + static const int kEnglishBit = (1 << (kConventionShift + 8)); + // Mask off all non-language bits. + static const int kFlagMask = ~((~int(0)) << kConventionShift); + + /** Values encoding the formula language plus address reference convention + plus English parsing/formatting + */ + //! When adding new values adapt isSupported() below as well. + enum Grammar + { + /// Used only in ScCompiler ctor and in some XML import API context. + GRAM_UNSPECIFIED = -1, + /// ODFF with default ODF A1 bracketed references. + GRAM_ODFF = ::com::sun::star::sheet::FormulaLanguage::ODFF | + ((CONV_ODF + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// ODF 1.1 with default ODF A1 bracketed references. + GRAM_PODF = ::com::sun::star::sheet::FormulaLanguage::ODF_11 | + ((CONV_ODF + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// English with default A1 reference style. + GRAM_ENGLISH = ::com::sun::star::sheet::FormulaLanguage::ENGLISH | + ((CONV_OOO + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// Native with default A1 reference style. + GRAM_NATIVE = ::com::sun::star::sheet::FormulaLanguage::NATIVE | + ((CONV_OOO + + kConventionOffset) << kConventionShift), + /// ODFF with reference style as set in UI, may be A1 or R1C1. + GRAM_ODFF_UI = ::com::sun::star::sheet::FormulaLanguage::ODFF | + ((CONV_UNSPECIFIED + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// ODFF with A1 reference style, unbracketed. + GRAM_ODFF_A1 = ::com::sun::star::sheet::FormulaLanguage::ODFF | + ((CONV_OOO + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// ODF 1.1 with reference style as set in UI, may be A1 or R1C1. + GRAM_PODF_UI = ::com::sun::star::sheet::FormulaLanguage::ODF_11 | + ((CONV_UNSPECIFIED + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// ODF 1.1 with A1 reference style, unbracketed. + GRAM_PODF_A1 = ::com::sun::star::sheet::FormulaLanguage::ODF_11 | + ((CONV_OOO + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// Native with reference style as set in UI, may be A1 or R1C1. + GRAM_NATIVE_UI = ::com::sun::star::sheet::FormulaLanguage::NATIVE | + ((CONV_UNSPECIFIED + + kConventionOffset) << kConventionShift), + /// Native with ODF A1 bracketed references. Not very useful but supported. + GRAM_NATIVE_ODF = ::com::sun::star::sheet::FormulaLanguage::NATIVE | + ((CONV_ODF + + kConventionOffset) << kConventionShift), + /// Native with Excel A1 reference style. + GRAM_NATIVE_XL_A1 = ::com::sun::star::sheet::FormulaLanguage::NATIVE | + ((CONV_XL_A1 + + kConventionOffset) << kConventionShift), + /// Native with Excel R1C1 reference style. + GRAM_NATIVE_XL_R1C1 = ::com::sun::star::sheet::FormulaLanguage::NATIVE | + ((CONV_XL_R1C1 + + kConventionOffset) << kConventionShift), + /// Central definition of the default grammar to be used. + GRAM_DEFAULT = GRAM_NATIVE_UI, + + /// Central definition of the default storage grammar to be used. + GRAM_STORAGE_DEFAULT = GRAM_ODFF, + + /** OpCodeMap set by external filter and merged with reference + convention plus English bit on top. Plain value acts as + FormulaLanguage. */ + GRAM_EXTERNAL = (1 << (kConventionShift - 1)) + }; + + /// If English parsing/formatting is associated with a grammar. + static inline bool isEnglish( const Grammar eGrammar ) + { + return (eGrammar & kEnglishBit) != 0; + } + + /** Compatibility helper for old "bCompileEnglish, bCompileXML" API calls + to obtain the new grammar. */ + static Grammar mapAPItoGrammar( const bool bEnglish, const bool bXML ) + { + Grammar eGrammar; + if (bEnglish && bXML) + eGrammar = GRAM_PODF; + else if (bEnglish && !bXML) + eGrammar = GRAM_PODF_A1; + else if (!bEnglish && bXML) + eGrammar = GRAM_NATIVE_ODF; + else // (!bEnglish && !bXML) + eGrammar = GRAM_NATIVE; + return eGrammar; + } + + static bool isSupported( const Grammar eGrammar ) + { + switch (eGrammar) + { + case GRAM_ODFF : + case GRAM_PODF : + case GRAM_ENGLISH : + case GRAM_NATIVE : + case GRAM_ODFF_UI : + case GRAM_ODFF_A1 : + case GRAM_PODF_UI : + case GRAM_PODF_A1 : + case GRAM_NATIVE_UI : + case GRAM_NATIVE_ODF : + case GRAM_NATIVE_XL_A1 : + case GRAM_NATIVE_XL_R1C1 : + return true; + default: + return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL; + } + } + + static inline sal_Int32 extractFormulaLanguage( const Grammar eGrammar ) + { + return eGrammar & kFlagMask; + } + + static inline AddressConvention extractRefConvention( const Grammar eGrammar ) + { + return static_cast<AddressConvention>( + ((eGrammar & ~kEnglishBit) >> kConventionShift) - + kConventionOffset); + } + + static inline Grammar setEnglishBit( const Grammar eGrammar, const bool bEnglish ) + { + if (bEnglish) + return static_cast<Grammar>( eGrammar | kEnglishBit); + else + return static_cast<Grammar>( eGrammar & ~kEnglishBit); + } + + static inline Grammar mergeToGrammar( const Grammar eGrammar, const AddressConvention eConv ) + { + bool bEnglish = isEnglish( eGrammar); + Grammar eGram = static_cast<Grammar>( + extractFormulaLanguage( eGrammar) | + ((eConv + kConventionOffset) << kConventionShift)); + eGram = setEnglishBit( eGram, bEnglish); + DBG_ASSERT( isSupported( eGram), "CompilerGrammarMap::mergeToGrammar: unsupported grammar"); + return eGram; + } + + /// If grammar is of ODF 1.1 + static inline bool isPODF( const Grammar eGrammar ) + { + return extractFormulaLanguage( eGrammar) == + ::com::sun::star::sheet::FormulaLanguage::ODF_11; + } + + /// If grammar is of ODFF + static inline bool isODFF( const Grammar eGrammar ) + { + return extractFormulaLanguage( eGrammar) == + ::com::sun::star::sheet::FormulaLanguage::ODFF; + } + +}; +// ============================================================================= +} // formula +// ============================================================================= + +#endif // FORMULA_GRAMMAR_HXX diff --git a/formula/inc/formula/intruref.hxx b/formula/inc/formula/intruref.hxx new file mode 100644 index 000000000000..e51f37f424ce --- /dev/null +++ b/formula/inc/formula/intruref.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * 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: intruref.hxx,v $ + * $Revision: 1.5 $ + * + * 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 FORMULA_INTRUREF_HXX +#define FORMULA_INTRUREF_HXX + +namespace formula
+{
+ +/** A simple intrusive refcounting template, not thread safe, but therefore + also a bit faster than boost's smart_ptr or uno::Reference equivalents, and + the type to be refcounted has full control over its behavior. + + Mainly used in formula compiler and interpreter context, e.g. ScTokenRef, + ScMatrixRef. + + Type T must implement methods IncRef() and DecRef(), in case typename T is + const they must be const as well and the reference counter be mutable. + */ +template< typename T > class SimpleIntrusiveReference +{ + T* p; +public: + inline SimpleIntrusiveReference() : p(0) {} + inline SimpleIntrusiveReference( const SimpleIntrusiveReference& r ) + { + p = r.p; + if ( p ) + p->IncRef(); + } + inline SimpleIntrusiveReference( T *t ) + { + p = t; + if ( p ) + t->IncRef(); + } + inline void Clear() + { + if ( p ) + { + p->DecRef(); + p = 0; + } + } + inline ~SimpleIntrusiveReference() + { + if ( p ) + p->DecRef(); + } + inline SimpleIntrusiveReference& operator=( T* t ) + { + if ( t ) + t->IncRef(); + if ( p ) + p->DecRef(); + p = t; + return *this; + } + inline SimpleIntrusiveReference& operator=( const SimpleIntrusiveReference& r ) + { + *this = r.p; + return *this; + } + inline bool Is() const { return p != 0; } + inline bool operator ! () const { return p == 0; } + inline T* operator&() const { return p; } + inline T* operator->() const { return p; } + inline T& operator*() const { return *p; } + inline operator T*() const { return p; } + inline T* get() const { return p; } +}; +// =============================================================================
+} // formula
+// =============================================================================
+ +#endif // SC_INTRUREF_HXX + diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx new file mode 100644 index 000000000000..bed61ac462c8 --- /dev/null +++ b/formula/inc/formula/opcode.hxx @@ -0,0 +1,408 @@ +/************************************************************************* + * + * 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: opcode.hxx,v $ + * $Revision: 1.23 $ + * + * 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 FORMULA_OPCODE_HXX +#define FORMULA_OPCODE_HXX + +#include "formula/compiler.hrc" // OpCodes +#include <tools/solar.h> + +enum OpCodeEnum +{ + // Special commands + ocPush = SC_OPCODE_PUSH, + ocCall = SC_OPCODE_CALL, + ocStop = SC_OPCODE_STOP, + ocExternal = SC_OPCODE_EXTERNAL, + ocName = SC_OPCODE_NAME, + // Jump commands + ocIf = SC_OPCODE_IF, + ocChose = SC_OPCODE_CHOSE, + // Parentheses and separators + ocOpen = SC_OPCODE_OPEN, + ocClose = SC_OPCODE_CLOSE, + ocSep = SC_OPCODE_SEP, + ocArrayOpen = SC_OPCODE_ARRAY_OPEN, + ocArrayClose = SC_OPCODE_ARRAY_CLOSE, + ocArrayRowSep = SC_OPCODE_ARRAY_ROW_SEP, + ocArrayColSep = SC_OPCODE_ARRAY_COL_SEP, + // Special OpCodes + ocMissing = SC_OPCODE_MISSING, + ocBad = SC_OPCODE_BAD, + ocSpaces = SC_OPCODE_SPACES, + ocMatRef = SC_OPCODE_MAT_REF, + // Access commands + ocDBArea = SC_OPCODE_DB_AREA, + ocMacro = SC_OPCODE_MACRO, + ocColRowName = SC_OPCODE_COL_ROW_NAME, + ocColRowNameAuto = SC_OPCODE_COL_ROW_NAME_AUTO, + // Percent operator _follows_ value + ocPercentSign = SC_OPCODE_PERCENT_SIGN, + // Error constants + ocErrNull = SC_OPCODE_ERROR_NULL, + ocErrDivZero = SC_OPCODE_ERROR_DIVZERO, + ocErrValue = SC_OPCODE_ERROR_VALUE, + ocErrRef = SC_OPCODE_ERROR_REF, + ocErrName = SC_OPCODE_ERROR_NAME, + ocErrNum = SC_OPCODE_ERROR_NUM, + ocErrNA = SC_OPCODE_ERROR_NA, + // Binary operators + ocAdd = SC_OPCODE_ADD, + ocSub = SC_OPCODE_SUB, + ocMul = SC_OPCODE_MUL, + ocDiv = SC_OPCODE_DIV, + ocAmpersand = SC_OPCODE_AMPERSAND, + ocPow = SC_OPCODE_POW, + ocEqual = SC_OPCODE_EQUAL, + ocNotEqual = SC_OPCODE_NOT_EQUAL, + ocLess = SC_OPCODE_LESS, + ocGreater = SC_OPCODE_GREATER, + ocLessEqual = SC_OPCODE_LESS_EQUAL, + ocGreaterEqual = SC_OPCODE_GREATER_EQUAL, + ocAnd = SC_OPCODE_AND, + ocOr = SC_OPCODE_OR, + ocIntersect = SC_OPCODE_INTERSECT, + ocUnion = SC_OPCODE_UNION, + ocRange = SC_OPCODE_RANGE, + // Unary operators + ocNot = SC_OPCODE_NOT, + ocNeg = SC_OPCODE_NEG, + ocNegSub = SC_OPCODE_NEG_SUB, + // Functions with no parameters + ocPi = SC_OPCODE_PI, + ocRandom = SC_OPCODE_RANDOM, + ocTrue = SC_OPCODE_TRUE, + ocFalse = SC_OPCODE_FALSE, + ocGetActDate = SC_OPCODE_GET_ACT_DATE, + ocGetActTime = SC_OPCODE_GET_ACT_TIME, + ocNotAvail = SC_OPCODE_NO_VALUE, + ocCurrent = SC_OPCODE_CURRENT, + // Functions with one parameter + ocDeg = SC_OPCODE_DEG, + ocRad = SC_OPCODE_RAD, + ocSin = SC_OPCODE_SIN, + ocCos = SC_OPCODE_COS, + ocTan = SC_OPCODE_TAN, + ocCot = SC_OPCODE_COT, + ocArcSin = SC_OPCODE_ARC_SIN, + ocArcCos = SC_OPCODE_ARC_COS, + ocArcTan = SC_OPCODE_ARC_TAN, + ocArcCot = SC_OPCODE_ARC_COT, + ocSinHyp = SC_OPCODE_SIN_HYP, + ocCosHyp = SC_OPCODE_COS_HYP, + ocTanHyp = SC_OPCODE_TAN_HYP, + ocCotHyp = SC_OPCODE_COT_HYP, + ocArcSinHyp = SC_OPCODE_ARC_SIN_HYP, + ocArcCosHyp = SC_OPCODE_ARC_COS_HYP, + ocArcTanHyp = SC_OPCODE_ARC_TAN_HYP, + ocArcCotHyp = SC_OPCODE_ARC_COT_HYP, + ocExp = SC_OPCODE_EXP, + ocLn = SC_OPCODE_LN, + ocSqrt = SC_OPCODE_SQRT, + ocFact = SC_OPCODE_FACT, + ocGetYear = SC_OPCODE_GET_YEAR, + ocGetMonth = SC_OPCODE_GET_MONTH, + ocGetDay = SC_OPCODE_GET_DAY, + ocGetHour = SC_OPCODE_GET_HOUR, + ocGetMin = SC_OPCODE_GET_MIN, + ocGetSec = SC_OPCODE_GET_SEC, + ocPlusMinus = SC_OPCODE_PLUS_MINUS, + ocAbs = SC_OPCODE_ABS, + ocInt = SC_OPCODE_INT, + ocPhi = SC_OPCODE_PHI, + ocGauss = SC_OPCODE_GAUSS, + ocIsEmpty = SC_OPCODE_IS_EMPTY, + ocIsString = SC_OPCODE_IS_STRING, + ocIsNonString = SC_OPCODE_IS_NON_STRING, + ocIsLogical = SC_OPCODE_IS_LOGICAL, + ocType = SC_OPCODE_TYPE, + ocCell = SC_OPCODE_CELL, + ocIsRef = SC_OPCODE_IS_REF, + ocIsValue = SC_OPCODE_IS_VALUE, + ocIsFormula = SC_OPCODE_IS_FORMULA, + ocIsNA = SC_OPCODE_IS_NV, + ocIsErr = SC_OPCODE_IS_ERR, + ocIsError = SC_OPCODE_IS_ERROR, + ocIsEven = SC_OPCODE_IS_EVEN, + ocIsOdd = SC_OPCODE_IS_ODD, + ocN = SC_OPCODE_N, + // String functions + ocGetDateValue = SC_OPCODE_GET_DATE_VALUE, + ocGetTimeValue = SC_OPCODE_GET_TIME_VALUE, + ocCode = SC_OPCODE_CODE, + ocTrim = SC_OPCODE_TRIM, + ocUpper = SC_OPCODE_UPPER, + ocPropper = SC_OPCODE_PROPPER, + ocLower = SC_OPCODE_LOWER, + ocLen = SC_OPCODE_LEN, + ocT = SC_OPCODE_T, + ocValue = SC_OPCODE_VALUE, + ocClean = SC_OPCODE_CLEAN, + ocChar = SC_OPCODE_CHAR, + ocLog10 = SC_OPCODE_LOG10, + ocEven = SC_OPCODE_EVEN, + ocOdd = SC_OPCODE_ODD, + ocStdNormDist = SC_OPCODE_STD_NORM_DIST, + ocFisher = SC_OPCODE_FISHER, + ocFisherInv = SC_OPCODE_FISHER_INV, + ocSNormInv = SC_OPCODE_S_NORM_INV, + ocGammaLn = SC_OPCODE_GAMMA_LN, + ocErrorType = SC_OPCODE_ERROR_TYPE, + ocErrCell = SC_OPCODE_ERR_CELL, + ocFormula = SC_OPCODE_FORMULA, + ocArabic = SC_OPCODE_ARABIC, + ocInfo = SC_OPCODE_INFO, + ocBahtText = SC_OPCODE_BAHTTEXT, + ocJis = SC_OPCODE_JIS, + ocAsc = SC_OPCODE_ASC, + ocUnicode = SC_OPCODE_UNICODE, + ocUnichar = SC_OPCODE_UNICHAR, + // Functions with more than one parameters + ocArcTan2 = SC_OPCODE_ARC_TAN_2, + ocCeil = SC_OPCODE_CEIL, + ocFloor = SC_OPCODE_FLOOR, + ocRound = SC_OPCODE_ROUND, + ocRoundUp = SC_OPCODE_ROUND_UP, + ocRoundDown = SC_OPCODE_ROUND_DOWN, + ocTrunc = SC_OPCODE_TRUNC, + ocLog = SC_OPCODE_LOG, + ocPower = SC_OPCODE_POWER, + ocGCD = SC_OPCODE_GGT, + ocLCM = SC_OPCODE_KGV, + ocMod = SC_OPCODE_MOD, + ocSumProduct = SC_OPCODE_SUM_PRODUCT, + ocSumSQ = SC_OPCODE_SUM_SQ, + ocSumX2MY2 = SC_OPCODE_SUM_X2MY2, + ocSumX2DY2 = SC_OPCODE_SUM_X2DY2, + ocSumXMY2 = SC_OPCODE_SUM_XMY2, + ocGetDate = SC_OPCODE_GET_DATE, + ocGetTime = SC_OPCODE_GET_TIME, + ocGetDiffDate = SC_OPCODE_GET_DIFF_DATE, + ocGetDiffDate360 = SC_OPCODE_GET_DIFF_DATE_360, + ocMin = SC_OPCODE_MIN, + ocMax = SC_OPCODE_MAX, + ocSum = SC_OPCODE_SUM, + ocProduct = SC_OPCODE_PRODUCT, + ocAverage = SC_OPCODE_AVERAGE, + ocCount = SC_OPCODE_COUNT, + ocCount2 = SC_OPCODE_COUNT_2, + ocNPV = SC_OPCODE_NBW, + ocIRR = SC_OPCODE_IKV, + ocMIRR = SC_OPCODE_MIRR, + ocISPMT = SC_OPCODE_ISPMT, + ocVar = SC_OPCODE_VAR, + ocVarP = SC_OPCODE_VAR_P, + ocStDev = SC_OPCODE_ST_DEV, + ocStDevP = SC_OPCODE_ST_DEV_P, + ocB = SC_OPCODE_B, + ocNormDist = SC_OPCODE_NORM_DIST, + ocExpDist = SC_OPCODE_EXP_DIST, + ocBinomDist = SC_OPCODE_BINOM_DIST, + ocPoissonDist = SC_OPCODE_POISSON_DIST, + ocKombin = SC_OPCODE_KOMBIN, + ocKombin2 = SC_OPCODE_KOMBIN_2, + ocVariationen = SC_OPCODE_VARIATIONEN, + ocVariationen2 = SC_OPCODE_VARIATIONEN_2, + ocBW = SC_OPCODE_BW, + ocDIA = SC_OPCODE_DIA, + ocGDA = SC_OPCODE_GDA, + ocGDA2 = SC_OPCODE_GDA_2, + ocVBD = SC_OPCODE_VBD, + ocLaufz = SC_OPCODE_LAUFZ, + ocLIA = SC_OPCODE_LIA, + ocRMZ = SC_OPCODE_RMZ, + ocColumns = SC_OPCODE_COLUMNS, + ocRows = SC_OPCODE_ROWS, + ocColumn = SC_OPCODE_COLUMN, + ocRow = SC_OPCODE_ROW, + ocZGZ = SC_OPCODE_ZGZ, + ocZW = SC_OPCODE_ZW, + ocZZR = SC_OPCODE_ZZR, + ocZins = SC_OPCODE_ZINS, + ocZinsZ = SC_OPCODE_ZINS_Z, + ocKapz = SC_OPCODE_KAPZ, + ocKumZinsZ = SC_OPCODE_KUM_ZINS_Z, + ocKumKapZ = SC_OPCODE_KUM_KAP_Z, + ocEffektiv = SC_OPCODE_EFFEKTIV, + ocNominal = SC_OPCODE_NOMINAL, + ocSubTotal = SC_OPCODE_SUB_TOTAL, + // Database functions + ocDBSum = SC_OPCODE_DB_SUM, + ocDBCount = SC_OPCODE_DB_COUNT, + ocDBCount2 = SC_OPCODE_DB_COUNT_2, + ocDBAverage = SC_OPCODE_DB_AVERAGE, + ocDBGet = SC_OPCODE_DB_GET, + ocDBMax = SC_OPCODE_DB_MAX, + ocDBMin = SC_OPCODE_DB_MIN, + ocDBProduct = SC_OPCODE_DB_PRODUCT, + ocDBStdDev = SC_OPCODE_DB_STD_DEV, + ocDBStdDevP = SC_OPCODE_DB_STD_DEV_P, + ocDBVar = SC_OPCODE_DB_VAR, + ocDBVarP = SC_OPCODE_DB_VAR_P, + // Management functions + ocIndirect = SC_OPCODE_INDIRECT, + ocIndirectXL = SC_OPCODE_INDIRECT_XL, + ocAddress = SC_OPCODE_ADDRESS, + ocAddressXL = SC_OPCODE_ADDRESS_XL, + ocMatch = SC_OPCODE_MATCH, + ocCountEmptyCells = SC_OPCODE_COUNT_EMPTY_CELLS, + ocCountIf = SC_OPCODE_COUNT_IF, + ocSumIf = SC_OPCODE_SUM_IF, + ocLookup = SC_OPCODE_LOOKUP, + ocVLookup = SC_OPCODE_V_LOOKUP, + ocHLookup = SC_OPCODE_H_LOOKUP, + ocMultiArea = SC_OPCODE_MULTI_AREA, + ocOffset = SC_OPCODE_OFFSET, + ocIndex = SC_OPCODE_INDEX, + ocAreas = SC_OPCODE_AREAS, + // String functions + ocCurrency = SC_OPCODE_CURRENCY, + ocReplace = SC_OPCODE_REPLACE, + ocFixed = SC_OPCODE_FIXED, + ocFind = SC_OPCODE_FIND, + ocExact = SC_OPCODE_EXACT, + ocLeft = SC_OPCODE_LEFT, + ocRight = SC_OPCODE_RIGHT, + ocSearch = SC_OPCODE_SEARCH, + ocMid = SC_OPCODE_MID, + ocText = SC_OPCODE_TEXT, + ocSubstitute = SC_OPCODE_SUBSTITUTE, + ocRept = SC_OPCODE_REPT, + ocConcat = SC_OPCODE_CONCAT, + // Matrix functions + ocMatValue = SC_OPCODE_MAT_VALUE, + ocMatDet = SC_OPCODE_MAT_DET, + ocMatInv = SC_OPCODE_MAT_INV, + ocMatMult = SC_OPCODE_MAT_MULT, + ocMatTrans = SC_OPCODE_MAT_TRANS, + ocMatrixUnit = SC_OPCODE_MATRIX_UNIT, + // BackSolver + ocBackSolver = SC_OPCODE_BACK_SOLVER, + // Statistical functions + ocHypGeomDist = SC_OPCODE_HYP_GEOM_DIST, + ocLogNormDist = SC_OPCODE_LOG_NORM_DIST, + ocTDist = SC_OPCODE_T_DIST, + ocFDist = SC_OPCODE_F_DIST, + ocChiDist = SC_OPCODE_CHI_DIST, + ocWeibull = SC_OPCODE_WEIBULL, + ocNegBinomVert = SC_OPCODE_NEG_BINOM_VERT, + ocKritBinom = SC_OPCODE_KRIT_BINOM, + ocKurt = SC_OPCODE_KURT, + ocHarMean = SC_OPCODE_HAR_MEAN, + ocGeoMean = SC_OPCODE_GEO_MEAN, + ocStandard = SC_OPCODE_STANDARD, + ocAveDev = SC_OPCODE_AVE_DEV, + ocSchiefe = SC_OPCODE_SCHIEFE, + ocDevSq = SC_OPCODE_DEV_SQ, + ocMedian = SC_OPCODE_MEDIAN, + ocModalValue = SC_OPCODE_MODAL_VALUE, + ocZTest = SC_OPCODE_Z_TEST, + ocTTest = SC_OPCODE_T_TEST, + ocRank = SC_OPCODE_RANK, + ocPercentile = SC_OPCODE_PERCENTILE, + ocPercentrank = SC_OPCODE_PERCENT_RANK, + ocLarge = SC_OPCODE_LARGE, + ocSmall = SC_OPCODE_SMALL, + ocFrequency = SC_OPCODE_FREQUENCY, + ocQuartile = SC_OPCODE_QUARTILE, + ocNormInv = SC_OPCODE_NORM_INV, + ocConfidence = SC_OPCODE_CONFIDENCE, + ocFTest = SC_OPCODE_F_TEST, + ocTrimMean = SC_OPCODE_TRIM_MEAN, + ocProb = SC_OPCODE_PROB, + ocCorrel = SC_OPCODE_CORREL, + ocCovar = SC_OPCODE_COVAR, + ocPearson = SC_OPCODE_PEARSON, + ocRSQ = SC_OPCODE_RSQ, + ocSTEYX = SC_OPCODE_STEYX, + ocSlope = SC_OPCODE_SLOPE, + ocIntercept = SC_OPCODE_INTERCEPT, + ocTrend = SC_OPCODE_TREND, + ocGrowth = SC_OPCODE_GROWTH, + ocRGP = SC_OPCODE_RGP, + ocRKP = SC_OPCODE_RKP, + ocForecast = SC_OPCODE_FORECAST, + ocChiInv = SC_OPCODE_CHI_INV, + ocGammaDist = SC_OPCODE_GAMMA_DIST, + ocGammaInv = SC_OPCODE_GAMMA_INV, + ocTInv = SC_OPCODE_T_INV, + ocFInv = SC_OPCODE_F_INV, + ocChiTest = SC_OPCODE_CHI_TEST, + ocLogInv = SC_OPCODE_LOG_INV, + ocTableOp = SC_OPCODE_TABLE_OP, + ocBetaDist = SC_OPCODE_BETA_DIST, + ocBetaInv = SC_OPCODE_BETA_INV, + // miscellaneous + ocWeek = SC_OPCODE_WEEK, + ocGetDayOfWeek = SC_OPCODE_GET_DAY_OF_WEEK, + ocNoName = SC_OPCODE_NO_NAME, + ocStyle = SC_OPCODE_STYLE, + ocDde = SC_OPCODE_DDE, + ocBase = SC_OPCODE_BASE, + ocTable = SC_OPCODE_TABLE, + ocTables = SC_OPCODE_TABLES, + ocMinA = SC_OPCODE_MIN_A, + ocMaxA = SC_OPCODE_MAX_A, + ocAverageA = SC_OPCODE_AVERAGE_A, + ocStDevA = SC_OPCODE_ST_DEV_A, + ocStDevPA = SC_OPCODE_ST_DEV_P_A, + ocVarA = SC_OPCODE_VAR_A, + ocVarPA = SC_OPCODE_VAR_P_A, + ocEasterSunday = SC_OPCODE_EASTERSUNDAY, + ocDecimal = SC_OPCODE_DECIMAL, + ocConvert = SC_OPCODE_CONVERT, + ocRoman = SC_OPCODE_ROMAN, + ocHyperLink = SC_OPCODE_HYPERLINK, + ocGetPivotData = SC_OPCODE_GET_PIVOT_DATA, + ocEuroConvert = SC_OPCODE_EUROCONVERT, + ocNumberValue = SC_OPCODE_NUMBERVALUE, + // internal stuff + ocInternalBegin = SC_OPCODE_INTERNAL_BEGIN, + ocGame = SC_OPCODE_GAME, + ocSpew = SC_OPCODE_SPEW, + ocTTT = SC_OPCODE_TTT, + ocTeam = SC_OPCODE_TEAM, + ocAnswer = SC_OPCODE_ANSWER, + ocInternalEnd = SC_OPCODE_INTERNAL_END, + // from here on ExtraData + ocDataToken1 = SC_OPCODE_DATA_TOKEN_1, + // no OpCode + ocNone = SC_OPCODE_NONE +}; + +#ifdef PRODUCT +// save memory since compilers tend to int an enum +typedef USHORT OpCode; +#else +// have enum names in debugger +typedef OpCodeEnum OpCode; +#endif + +#endif diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx new file mode 100644 index 000000000000..0e738982ddc8 --- /dev/null +++ b/formula/inc/formula/token.hxx @@ -0,0 +1,398 @@ +/************************************************************************* + * + * 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: token.hxx,v $ + * $Revision: 1.16 $ + * + * 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 FORMULA_TOKEN_HXX +#define FORMULA_TOKEN_HXX + +#include <memory> +#include <vector> +#include "formula/opcode.hxx" +//#include "refdata.hxx" +//#include "scmatrix.hxx" +#include "formula/intruref.hxx" +#include <tools/mempool.hxx> +#include "formula/IFunctionDescription.hxx" +#include "formula/formuladllapi.h" + +namespace formula +{ + +enum StackVarEnum +{ + svByte, + svDouble, + svString, + svSingleRef, + svDoubleRef, + svMatrix, + svIndex, + svJump, + svExternal, // Byte + String + svFAP, // FormulaAutoPilot only, ever exported + svJumpMatrix, // 2003-07-02 + svRefList, // ocUnion result + svEmptyCell, // Result is an empty cell, e.g. in LOOKUP() + + svMatrixCell, // Result is a matrix with bells and + // whistles as needed for _the_ matrix + // formula result. + + svHybridCell, // A temporary condition of a formula + // cell during import, having a double + // and/or string result and a formula + // string to be compiled. + + svError, // error token + svMissing = 0x70, // 0 or "" + svSep, // separator, ocSep, ocOpen, ocClose + svUnknown // unknown StackType +}; + +#ifdef PRODUCT +// save memory since compilers tend to int an enum +typedef BYTE StackVar; +#else +// have enum names in debugger +typedef StackVarEnum StackVar; +#endif + + +class FormulaToken; +typedef SimpleIntrusiveReference< class FormulaToken > FormulaTokenRef; +typedef SimpleIntrusiveReference< const class FormulaToken > FormulaConstTokenRef; + + +class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken +{ + OpCode eOp; + // not implemented, prevent usage + FormulaToken(); + FormulaToken& operator=( const FormulaToken& ); +protected: + + const StackVar eType; // type of data + mutable USHORT nRefCnt; // reference count + +public: + FormulaToken( StackVar eTypeP,OpCode e = ocPush ) : + eOp(e), eType( eTypeP ), nRefCnt(0) {} + FormulaToken( const FormulaToken& r ) : IFormulaToken(), + eOp(r.eOp), eType( r.eType ), nRefCnt(0) {} + + virtual ~FormulaToken(); + + inline void Delete() { delete this; } + inline StackVar GetType() const { return eType; } + BOOL IsFunction() const; // pure functions, no operators + BOOL IsMatrixFunction() const; // if a function _always_ returns a Matrix + BYTE GetParamCount() const; + inline void IncRef() const { nRefCnt++; } + inline void DecRef() const + { + if (!--nRefCnt) + const_cast<FormulaToken*>(this)->Delete(); + } + inline USHORT GetRef() const { return nRefCnt; } + inline OpCode GetOpCode() const { return eOp; } + + /** + Dummy methods to avoid switches and casts where possible, + the real token classes have to overload the appropriate method[s]. + The only methods valid anytime if not overloaded are: + + - GetByte() since this represents the count of parameters to a function + which of course is 0 on non-functions. FormulaByteToken and ScExternal do + overload it. + + - HasForceArray() since also this is only used for operators and + functions and is 0 for other tokens. + + Any other non-overloaded method pops up an assertion. + */ + + virtual BYTE GetByte() const; + virtual void SetByte( BYTE n ); + virtual bool HasForceArray() const; + virtual void SetForceArray( bool b ); + virtual double GetDouble() const; + virtual double& GetDoubleAsReference(); + virtual const String& GetString() const; + virtual USHORT GetIndex() const; + virtual void SetIndex( USHORT n ); + virtual short* GetJump() const; + virtual const String& GetExternal() const; + virtual FormulaToken* GetFAPOrigToken() const; + virtual USHORT GetError() const; + virtual void SetError( USHORT ); + + virtual FormulaToken* Clone() const { return new FormulaToken(*this); } + + virtual BOOL Is3DRef() const; // reference with 3D flag set + virtual BOOL TextEqual( const formula::FormulaToken& rToken ) const; + virtual BOOL operator==( const FormulaToken& rToken ) const; + + virtual bool isFunction() const + { + return IsFunction(); + } + + virtual sal_uInt32 getArgumentCount() const + { + return GetParamCount(); + } + + /** This is dirty and only the compiler should use it! */ + struct PrivateAccess { friend class FormulaCompiler; private: PrivateAccess() { } }; + inline void NewOpCode( OpCode e, const PrivateAccess& ) { eOp = e; } + + static size_t GetStrLenBytes( xub_StrLen nLen ) + { return nLen * sizeof(sal_Unicode); } + static size_t GetStrLenBytes( const String& rStr ) + { return GetStrLenBytes( rStr.Len() ); } +}; + +class FORMULA_DLLPUBLIC FormulaByteToken : public FormulaToken +{ +private: + BYTE nByte; + bool bHasForceArray; +protected: + FormulaByteToken( OpCode e, BYTE n, StackVar v, bool b ) : + FormulaToken( v,e ), nByte( n ), + bHasForceArray( b ) {} +public: + FormulaByteToken( OpCode e, BYTE n, bool b ) : + FormulaToken( svByte,e ), nByte( n ), + bHasForceArray( b ) {} + FormulaByteToken( OpCode e, BYTE n ) : + FormulaToken( svByte,e ), nByte( n ), + bHasForceArray( false ) {} + FormulaByteToken( OpCode e ) : + FormulaToken( svByte,e ), nByte( 0 ), + bHasForceArray( false ) {} + FormulaByteToken( const FormulaByteToken& r ) : + FormulaToken( r ), nByte( r.nByte ), + bHasForceArray( r.bHasForceArray ) {} + + virtual FormulaToken* Clone() const { return new FormulaByteToken(*this); } + virtual BYTE GetByte() const; + virtual void SetByte( BYTE n ); + virtual bool HasForceArray() const; + virtual void SetForceArray( bool b ); + virtual BOOL operator==( const FormulaToken& rToken ) const; + + DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaByteToken ); +}; + + +// A special token for the FormulaAutoPilot only. Keeps a reference pointer of +// the token of which it was created for comparison. +class FORMULA_DLLPUBLIC FormulaFAPToken : public FormulaByteToken +{ +private: + FormulaTokenRef pOrigToken; +public: + FormulaFAPToken( OpCode e, BYTE n, FormulaToken* p ) : + FormulaByteToken( e, n, svFAP, false ), + pOrigToken( p ) {} + FormulaFAPToken( const FormulaFAPToken& r ) : + FormulaByteToken( r ), pOrigToken( r.pOrigToken ) {} + + virtual FormulaToken* Clone() const { return new FormulaFAPToken(*this); } + virtual FormulaToken* GetFAPOrigToken() const; + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + +class FORMULA_DLLPUBLIC FormulaDoubleToken : public FormulaToken +{ +private: + double fDouble; +public: + FormulaDoubleToken( double f ) : + FormulaToken( svDouble ), fDouble( f ) {} + FormulaDoubleToken( const FormulaDoubleToken& r ) : + FormulaToken( r ), fDouble( r.fDouble ) {} + + virtual FormulaToken* Clone() const { return new FormulaDoubleToken(*this); } + virtual double GetDouble() const; + virtual double& GetDoubleAsReference(); + virtual BOOL operator==( const FormulaToken& rToken ) const; + + DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaDoubleToken ); +}; + + +class FORMULA_DLLPUBLIC FormulaStringToken : public FormulaToken +{ +private: + String aString; +public: + FormulaStringToken( const String& r ) : + FormulaToken( svString ), aString( r ) {} + FormulaStringToken( const FormulaStringToken& r ) : + FormulaToken( r ), aString( r.aString ) {} + + virtual FormulaToken* Clone() const { return new FormulaStringToken(*this); } + virtual const String& GetString() const; + virtual BOOL operator==( const FormulaToken& rToken ) const; + + DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaStringToken ); +}; + + +/** Identical to FormulaStringToken, but with explicit OpCode instead of implicit + ocPush, and an optional BYTE for ocBad tokens. */ +class FORMULA_DLLPUBLIC FormulaStringOpToken : public FormulaByteToken +{ +private: + String aString; +public: + FormulaStringOpToken( OpCode e, const String& r ) : + FormulaByteToken( e, 0, svString, false ), aString( r ) {} + FormulaStringOpToken( const FormulaStringOpToken& r ) : + FormulaByteToken( r ), aString( r.aString ) {} + + virtual FormulaToken* Clone() const { return new FormulaStringOpToken(*this); } + virtual const String& GetString() const; + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + +class FORMULA_DLLPUBLIC FormulaIndexToken : public FormulaToken +{ +private: + USHORT nIndex; +public: + FormulaIndexToken( OpCode e, USHORT n ) : + FormulaToken( svIndex, e ), nIndex( n ) {} + FormulaIndexToken( const FormulaIndexToken& r ) : + FormulaToken( r ), nIndex( r.nIndex ) {} + + virtual FormulaToken* Clone() const { return new FormulaIndexToken(*this); } + virtual USHORT GetIndex() const; + virtual void SetIndex( USHORT n ); + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + + +class FORMULA_DLLPUBLIC FormulaExternalToken : public FormulaToken +{ +private: + String aExternal; + BYTE nByte; +public: + FormulaExternalToken( OpCode e, BYTE n, const String& r ) : + FormulaToken( svExternal, e ), aExternal( r ), + nByte( n ) {} + FormulaExternalToken( OpCode e, const String& r ) : + FormulaToken(svExternal, e ), aExternal( r ), + nByte( 0 ) {} + FormulaExternalToken( const FormulaExternalToken& r ) : + FormulaToken( r ), aExternal( r.aExternal ), + nByte( r.nByte ) {} + + virtual FormulaToken* Clone() const { return new FormulaExternalToken(*this); } + virtual const String& GetExternal() const; + virtual BYTE GetByte() const; + virtual void SetByte( BYTE n ); + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + + +class FORMULA_DLLPUBLIC FormulaMissingToken : public FormulaToken +{ +public: + FormulaMissingToken() : + FormulaToken( svMissing,ocMissing ) {} + FormulaMissingToken( const FormulaMissingToken& r ) : + FormulaToken( r ) {} + + virtual FormulaToken* Clone() const { return new FormulaMissingToken(*this); } + virtual double GetDouble() const; + virtual const String& GetString() const; + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + +class FORMULA_DLLPUBLIC FormulaJumpToken : public FormulaToken +{ +private: + short* pJump; +public: + FormulaJumpToken( OpCode e, short* p ) : + FormulaToken( formula::svJump , e) + { + pJump = new short[ p[0] + 1 ]; + memcpy( pJump, p, (p[0] + 1) * sizeof(short) ); + } + FormulaJumpToken( const FormulaJumpToken& r ) : + FormulaToken( r ) + { + pJump = new short[ r.pJump[0] + 1 ]; + memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) ); + } + virtual ~FormulaJumpToken(); + virtual short* GetJump() const; + virtual BOOL operator==( const formula::FormulaToken& rToken ) const; + virtual FormulaToken* Clone() const { return new FormulaJumpToken(*this); } +}; + + +class FORMULA_DLLPUBLIC FormulaUnknownToken : public FormulaToken +{ +public: + FormulaUnknownToken( OpCode e ) : + FormulaToken( svUnknown, e ) {} + FormulaUnknownToken( const FormulaUnknownToken& r ) : + FormulaToken( r ) {} + + virtual FormulaToken* Clone() const { return new FormulaUnknownToken(*this); } + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + + +class FORMULA_DLLPUBLIC FormulaErrorToken : public FormulaToken +{ + USHORT nError; +public: + FormulaErrorToken( USHORT nErr ) : + FormulaToken( svError ), nError( nErr) {} + FormulaErrorToken( const FormulaErrorToken& r ) : + FormulaToken( r ), nError( r.nError) {} + + virtual FormulaToken* Clone() const { return new FormulaErrorToken(*this); } + virtual USHORT GetError() const; + virtual void SetError( USHORT nErr ); + virtual BOOL operator==( const FormulaToken& rToken ) const; +}; + +// ============================================================================= +} // formula +// ============================================================================= + +#endif diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx new file mode 100644 index 000000000000..2b84fced2687 --- /dev/null +++ b/formula/inc/formula/tokenarray.hxx @@ -0,0 +1,285 @@ +/************************************************************************* + * + * 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: tokenarray.hxx,v $ + * $Revision: 1.12 $ + * + * 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 FORMULA_TOKENARRAY_HXX +#define FORMULA_TOKENARRAY_HXX + +#include "formula/token.hxx" +#include <tools/solar.h> +#include <com/sun/star/sheet/FormulaToken.hpp> + +namespace formula +{ + +// RecalcMode access only via TokenArray SetRecalcMode / IsRecalcMode... + +typedef BYTE ScRecalcMode; +// Only one of the exclusive bits can be set, +// handled by TokenArray SetRecalcMode... methods +#define RECALCMODE_NORMAL 0x01 // exclusive +#define RECALCMODE_ALWAYS 0x02 // exclusive, always +#define RECALCMODE_ONLOAD 0x04 // exclusive, always after load +#define RECALCMODE_ONLOAD_ONCE 0x08 // exclusive, once after load +#define RECALCMODE_FORCED 0x10 // combined, also if cell isn't visible +#define RECALCMODE_ONREFMOVE 0x20 // combined, if reference was moved +#define RECALCMODE_EMASK 0x0F // mask of exclusive bits +// If new bits are to be defined, AddRecalcMode has to be adjusted! + +class FormulaMissingContext; + +class FORMULA_DLLPUBLIC MissingConvention +{ + bool mbODFF; /// TRUE: ODFF, FALSE: PODF +public: + explicit MissingConvention( bool bODFF ) : mbODFF(bODFF) {} + // Implementation and usage only in token.cxx + inline bool isRewriteNeeded( OpCode eOp ) const; + inline bool isODFF() const { return mbODFF; } +}; + +class FORMULA_DLLPUBLIC FormulaTokenArray +{ + friend class FormulaCompiler; + friend class FormulaTokenIterator; + friend class FormulaMissingContext; + +protected: + FormulaToken** pCode; // Token code array + FormulaToken** pRPN; // RPN array + USHORT nLen; // Length of token array + USHORT nRPN; // Length of RPN array + USHORT nIndex; // Current step index + USHORT nError; // Error code + short nRefs; // Count of cell references + ScRecalcMode nMode; // Flags to indicate when to recalc this code + BOOL bHyperLink; // If HYPERLINK() occurs in the formula. + +protected: + void Assign( const FormulaTokenArray& ); + + /// Also used by the compiler. The token MUST had been allocated with new! + FormulaToken* Add( FormulaToken* ); + inline void SetCombinedBitsRecalcMode( ScRecalcMode nBits ) + { nMode |= (nBits & ~RECALCMODE_EMASK); } + inline ScRecalcMode GetCombinedBitsRecalcMode() const + { return nMode & ~RECALCMODE_EMASK; } + /** Exclusive bits already set in nMode are + zero'ed, nVal may contain combined bits, but + only one exclusive bit may be set! */ + inline void SetMaskedRecalcMode( ScRecalcMode nBits ) + { nMode = GetCombinedBitsRecalcMode() | nBits; } + +public: + FormulaTokenArray(); + /// Assignment with references to FormulaToken entries (not copied!) + FormulaTokenArray( const FormulaTokenArray& ); + virtual ~FormulaTokenArray(); + FormulaTokenArray* Clone() const; /// True copy! + void Clear(); + void DelRPN(); + FormulaToken* First() { nIndex = 0; return Next(); } + FormulaToken* Next(); + FormulaToken* FirstNoSpaces() { nIndex = 0; return NextNoSpaces(); } + FormulaToken* NextNoSpaces(); + FormulaToken* GetNextName(); + FormulaToken* GetNextDBArea(); + FormulaToken* GetNextReference(); + FormulaToken* GetNextReferenceRPN(); + FormulaToken* GetNextReferenceOrName(); + FormulaToken* GetNextColRowName(); + FormulaToken* GetNextOpCodeRPN( OpCode ); + /// Peek at nIdx-1 if not out of bounds, decrements nIdx if successful. Returns NULL if not. + FormulaToken* PeekPrev( USHORT & nIdx ); + FormulaToken* PeekNext(); + FormulaToken* PeekPrevNoSpaces(); /// Only after Reset/First/Next/Last/Prev! + FormulaToken* PeekNextNoSpaces(); /// Only after Reset/First/Next/Last/Prev! + FormulaToken* FirstRPN() { nIndex = 0; return NextRPN(); } + FormulaToken* NextRPN(); + FormulaToken* LastRPN() { nIndex = nRPN; return PrevRPN(); } + FormulaToken* PrevRPN(); + + BOOL HasOpCode( OpCode ) const; + BOOL HasOpCodeRPN( OpCode ) const; + /// Token of type svIndex or opcode ocColRowName + BOOL HasNameOrColRowName() const; + + FormulaToken** GetArray() const { return pCode; } + FormulaToken** GetCode() const { return pRPN; } + USHORT GetLen() const { return nLen; } + USHORT GetCodeLen() const { return nRPN; } + void Reset() { nIndex = 0; } + USHORT GetCodeError() const { return nError; } + void SetCodeError( USHORT n ) { nError = n; } + short GetRefs() const { return nRefs; } + void SetHyperLink( BOOL bVal ) { bHyperLink = bVal; } + BOOL IsHyperLink() const { return bHyperLink; } + + inline ScRecalcMode GetRecalcMode() const { return nMode; } + /** Bits aren't set directly but validated and + maybe handled according to priority if more + than one exclusive bit was set. */ + void AddRecalcMode( ScRecalcMode nBits ); + + inline void ClearRecalcMode() { nMode = RECALCMODE_NORMAL; } + inline void SetRecalcModeNormal() + { SetMaskedRecalcMode( RECALCMODE_NORMAL ); } + inline void SetRecalcModeAlways() + { SetMaskedRecalcMode( RECALCMODE_ALWAYS ); } + inline void SetRecalcModeOnLoad() + { SetMaskedRecalcMode( RECALCMODE_ONLOAD ); } + inline void SetRecalcModeOnLoadOnce() + { SetMaskedRecalcMode( RECALCMODE_ONLOAD_ONCE ); } + inline void SetRecalcModeForced() + { nMode |= RECALCMODE_FORCED; } + inline void ClearRecalcModeForced() + { nMode &= ~RECALCMODE_FORCED; } + inline void SetRecalcModeOnRefMove() + { nMode |= RECALCMODE_ONREFMOVE; } + inline void ClearRecalcModeOnRefMove() + { nMode &= ~RECALCMODE_ONREFMOVE; } + inline BOOL IsRecalcModeNormal() const + { return (nMode & RECALCMODE_NORMAL) != 0; } + inline BOOL IsRecalcModeAlways() const + { return (nMode & RECALCMODE_ALWAYS) != 0; } + inline BOOL IsRecalcModeOnLoad() const + { return (nMode & RECALCMODE_ONLOAD) != 0; } + inline BOOL IsRecalcModeOnLoadOnce() const + { return (nMode & RECALCMODE_ONLOAD_ONCE) != 0; } + inline BOOL IsRecalcModeForced() const + { return (nMode & RECALCMODE_FORCED) != 0; } + inline BOOL IsRecalcModeOnRefMove() const + { return (nMode & RECALCMODE_ONREFMOVE) != 0; } + + /** Get OpCode of the most outer function */ + inline OpCode GetOuterFuncOpCode(); + + /** Operators +,-,*,/,^,&,=,<>,<,>,<=,>= + with DoubleRef in Formula? */ + BOOL HasMatrixDoubleRefOps(); + + virtual FormulaToken* AddOpCode(OpCode e); + + /** Adds the single token to array. + Derived classes must overload it when they want to support derived classes from FormulaToken. + @return true when an error occurs + */ + virtual bool AddFormulaToken(const com::sun::star::sheet::FormulaToken& _aToken); + + /** fill the array with the tokens from the sequence. + It calls AddFormulaToken for each token in the list. + @param _aSequence the token to add + @return true when an error occurs + */ + bool Fill(const com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& _aSequence); + + FormulaToken* AddToken( const FormulaToken& ); + FormulaToken* AddString( const sal_Unicode* pStr ); + FormulaToken* AddString( const String& rStr ); + FormulaToken* AddDouble( double fVal ); + FormulaToken* AddName( USHORT n ); + FormulaToken* AddExternal( const sal_Unicode* pStr ); + /** Xcl import may play dirty tricks with OpCode!=ocExternal. + Others don't use! */ + FormulaToken* AddExternal( const String& rStr, OpCode eOp = ocExternal ); + FormulaToken* AddBad( const sal_Unicode* pStr ); /// ocBad with String + FormulaToken* AddBad( const String& rStr ); /// ocBad with String + + virtual FormulaToken* MergeArray( ); + + /// Assignment with references to FormulaToken entries (not copied!) + FormulaTokenArray& operator=( const FormulaTokenArray& ); + + /** Determines if this formula needs any changes to convert it to something + previous versions of OOo could consume (Plain Old Formula). */ + bool NeedsPofRewrite(const MissingConvention & rConv); + + /** Rewrites to Plain Old Formula, substituting missing parameters. The + FormulaTokenArray* returned is new'ed. */ + FormulaTokenArray* RewriteMissingToPof(const MissingConvention & rConv); + + /** Determines if this formula may be followed by a reference. */ + bool MayReferenceFollow(); +}; + +inline OpCode FormulaTokenArray::GetOuterFuncOpCode() +{ + if ( pRPN && nRPN ) + return pRPN[nRPN-1]->GetOpCode(); + return ocNone; +} + +struct ImpTokenIterator +{ + ImpTokenIterator* pNext; + const FormulaTokenArray* pArr; + short nPC; + short nStop; + + DECL_FIXEDMEMPOOL_NEWDEL( ImpTokenIterator ); +}; + +class FORMULA_DLLPUBLIC FormulaTokenIterator +{ + ImpTokenIterator* pCur; + +public: + FormulaTokenIterator( const FormulaTokenArray& ); + ~FormulaTokenIterator(); + void Reset(); + const FormulaToken* First(); + const FormulaToken* Next(); + bool IsEndOfPath() const; /// if a jump or subroutine path is done + bool HasStacked() const { return pCur->pNext != 0; } + short GetPC() const { return pCur->nPC; } + + /** Jump or subroutine call. + Program counter values will be incremented before code is executed => + positions are to be passed with -1 offset. + @param nStart + Start on code at position nStart+1 (yes, pass with offset -1) + @param nNext + After subroutine continue with instruction at position nNext+1 + @param nStop + Stop before reaching code at position nStop. If not specified the + default is to either run the entire code, or to stop if an ocSep or + ocClose is encountered, which are only present in ocIf or ocChose + jumps. + */ + void Jump( short nStart, short nNext, short nStop = SHRT_MAX ); + void Push( const FormulaTokenArray* ); + void Pop(); +}; +// ============================================================================= +} // formula +// ============================================================================= + + +#endif // FORMULA_TOKENARRAY_HXX + diff --git a/formula/inc/helpids.hrc b/formula/inc/helpids.hrc new file mode 100644 index 000000000000..e971f2054eaf --- /dev/null +++ b/formula/inc/helpids.hrc @@ -0,0 +1,65 @@ +/*************************************************************************
+ *
+ * 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: helpids.hrc,v $
+ * $Revision: 1.7 $
+ *
+ * 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 FORMULA_HELPID_HRC
+#define FORMULA_HELPID_HRC
+
+#ifndef _SOLAR_HRC
+#include <svtools/solar.hrc> // HID_FORMULA_START
+#endif
+
+#define HID_FORMULADLG_FORMULA (HID_FORMULA_START + 0)
+#define HID_FORMULA_FAP_FORMULA (HID_FORMULA_START + 1)
+#define HID_FORMULA_FAP_STRUCT (HID_FORMULA_START + 2)
+#define HID_FORMULA_FAP_PAGE (HID_FORMULA_START + 3)
+#define HID_FORMULA_FAP_EDIT1 (HID_FORMULA_START + 4)
+#define HID_FORMULA_FAP_EDIT2 (HID_FORMULA_START + 5)
+#define HID_FORMULA_FAP_EDIT3 (HID_FORMULA_START + 6)
+#define HID_FORMULA_FAP_EDIT4 (HID_FORMULA_START + 7)
+#define HID_FORMULA_FAP_BTN_FX1 (HID_FORMULA_START + 8)
+#define HID_FORMULA_FAP_BTN_FX2 (HID_FORMULA_START + 9)
+#define HID_FORMULA_FAP_BTN_FX3 (HID_FORMULA_START +10)
+#define HID_FORMULA_FAP_BTN_FX4 (HID_FORMULA_START +11)
+#define HID_FORMULA_FAP_BTN_REF1 (HID_FORMULA_START +12)
+#define HID_FORMULA_FAP_BTN_REF2 (HID_FORMULA_START +13)
+#define HID_FORMULA_FAP_BTN_REF3 (HID_FORMULA_START +14)
+#define HID_FORMULA_FAP_BTN_REF4 (HID_FORMULA_START +15)
+#define HID_FORMULA_LB_CATEGORY (HID_FORMULA_START +16)
+#define HID_FORMULA_LB_FUNCTION (HID_FORMULA_START +17)
+#define HID_FORMULATAB_FUNCTION (HID_FORMULA_START +18)
+#define HID_FORMULATAB_STRUCT (HID_FORMULA_START +19)
+
+
+#if HID_FORMULATAB_STRUCT > HID_FORMULA_END
+#error Help-Id Ueberlauf in #file, #line
+#endif
+// don't forget to update the file util/hidother.src
+
+#endif //FORMULA_HELPID_HRC
+
diff --git a/formula/inc/makefile.mk b/formula/inc/makefile.mk new file mode 100644 index 000000000000..4d06d357eec8 --- /dev/null +++ b/formula/inc/makefile.mk @@ -0,0 +1,51 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# 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. +# +#************************************************************************* +PRJ=.. + +PRJNAME=formula +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/formula/inc/pch/precompiled_formula.cxx b/formula/inc/pch/precompiled_formula.cxx new file mode 100644 index 000000000000..9b69b902b603 --- /dev/null +++ b/formula/inc/pch/precompiled_formula.cxx @@ -0,0 +1,32 @@ +/************************************************************************* + * + * 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: precompiled_reportdesign.cxx,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#include "precompiled_formula.hxx" + diff --git a/formula/inc/pch/precompiled_formula.hxx b/formula/inc/pch/precompiled_formula.hxx new file mode 100644 index 000000000000..8d33bbec97c6 --- /dev/null +++ b/formula/inc/pch/precompiled_formula.hxx @@ -0,0 +1,39 @@ +/************************************************************************* + * + * 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: precompiled_reportdesign.hxx,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:38.561560 + +#ifdef PRECOMPILED_HEADERS +#include "com/sun/star/sdb/CommandType.hpp" +#include "com/sun/star/sdb/CommandType.hpp" +#include "comphelper/sequence.hxx" +#include "comphelper/sequenceashashmap.hxx" +#include "comphelper/documentconstants.hxx" +#endif |