diff options
Diffstat (limited to 'sc/source/core/inc')
-rw-r--r-- | sc/source/core/inc/addinhelpid.hxx | 60 | ||||
-rw-r--r-- | sc/source/core/inc/addinlis.hxx | 98 | ||||
-rw-r--r-- | sc/source/core/inc/adiasync.hxx | 92 | ||||
-rw-r--r-- | sc/source/core/inc/bcaslot.hxx | 309 | ||||
-rw-r--r-- | sc/source/core/inc/cellkeytranslator.hxx | 91 | ||||
-rw-r--r-- | sc/source/core/inc/core_pch.hxx | 248 | ||||
-rw-r--r-- | sc/source/core/inc/ddelink.hxx | 99 | ||||
-rw-r--r-- | sc/source/core/inc/doubleref.hxx | 194 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 918 | ||||
-rw-r--r-- | sc/source/core/inc/jumpmatrix.hxx | 222 | ||||
-rw-r--r-- | sc/source/core/inc/makefile.mk | 26 | ||||
-rw-r--r-- | sc/source/core/inc/parclass.hxx | 180 | ||||
-rw-r--r-- | sc/source/core/inc/poolhelp.hxx | 74 | ||||
-rw-r--r-- | sc/source/core/inc/refupdat.hxx | 100 | ||||
-rw-r--r-- | sc/source/core/inc/scrdata.hxx | 49 | ||||
-rw-r--r-- | sc/source/core/inc/sctictac.hxx | 131 |
16 files changed, 2891 insertions, 0 deletions
diff --git a/sc/source/core/inc/addinhelpid.hxx b/sc/source/core/inc/addinhelpid.hxx new file mode 100644 index 000000000000..b2f085ed64e5 --- /dev/null +++ b/sc/source/core/inc/addinhelpid.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_ADDINHELPID_HXX +#define SC_ADDINHELPID_HXX + +#include <rtl/ustring.hxx> + + +// ============================================================================ + +struct ScUnoAddInHelpId; + +/** Generates help IDs for standard Calc AddIns. */ +class ScUnoAddInHelpIdGenerator +{ +private: + const ScUnoAddInHelpId* pCurrHelpIds; /// Array of function names and help IDs. + sal_uInt32 nArrayCount; /// Count of array entries. + + ScUnoAddInHelpIdGenerator(); // disabled +public: + ScUnoAddInHelpIdGenerator( const ::rtl::OUString& rServiceName ); + + /** Sets service name of the AddIn. Has to be done before requesting help IDs. */ + void SetServiceName( const ::rtl::OUString& rServiceName ); + + /** @return The help ID of the function with given built-in name or 0 if not found. */ + sal_uInt16 GetHelpId( const ::rtl::OUString& rFuncName ) const; +}; + + +// ============================================================================ + +#endif + diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx new file mode 100644 index 000000000000..6c0f98386920 --- /dev/null +++ b/sc/source/core/inc/addinlis.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_ADDINLIS_HXX +#define SC_ADDINLIS_HXX + +#include "adiasync.hxx" // for ScAddInDocs PtrArr +#include <tools/list.hxx> +#include <com/sun/star/sheet/XResultListener.hpp> +#include <com/sun/star/sheet/XVolatileResult.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase2.hxx> + + + +class ScDocument; + + +class ScAddInListener : public cppu::WeakImplHelper2< + com::sun::star::sheet::XResultListener, + com::sun::star::lang::XServiceInfo >, + public SvtBroadcaster +{ +private: + com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVolRes; + com::sun::star::uno::Any aResult; + ScAddInDocs* pDocs; // documents where this is used + + static List aAllListeners; + + // always allocated via CreateListener + ScAddInListener( + com::sun::star::uno::Reference< + com::sun::star::sheet::XVolatileResult> xVR, + ScDocument* pD ); + +public: + virtual ~ScAddInListener(); + + // create Listener and put it into global list + static ScAddInListener* CreateListener( + com::sun::star::uno::Reference< + com::sun::star::sheet::XVolatileResult> xVR, + ScDocument* pDoc ); + + static ScAddInListener* Get( com::sun::star::uno::Reference< + com::sun::star::sheet::XVolatileResult> xVR ); + static void RemoveDocument( ScDocument* pDocument ); + + BOOL HasDocument( ScDocument* pDoc ) const { return pDocs->Seek_Entry( pDoc ); } + void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } + const com::sun::star::uno::Any& GetResult() const { return aResult; } + + + // XResultListener + virtual void SAL_CALL modified( const ::com::sun::star::sheet::ResultEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw(::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); +}; + + +#endif + diff --git a/sc/source/core/inc/adiasync.hxx b/sc/source/core/inc/adiasync.hxx new file mode 100644 index 000000000000..4d0997fce63d --- /dev/null +++ b/sc/source/core/inc/adiasync.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_ADIASYNC_HXX +#define SC_ADIASYNC_HXX + +#include <svl/broadcast.hxx> +#include <svl/svarray.hxx> + +#include "callform.hxx" + +extern "C" { +void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData ); +} + + +class ScAddInAsync; +typedef ScAddInAsync* ScAddInAsyncPtr; +SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4, 4 ) +extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx + +class ScDocument; +typedef ScDocument* ScAddInDocPtr; +SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1, 1 ) + +class String; + +class ScAddInAsync : public SvtBroadcaster +{ +private: + union + { + double nVal; // aktueller Wert + String* pStr; + }; + ScAddInDocs* pDocs; // Liste der benutzenden Dokumente + FuncData* pFuncData; // Zeiger auf die Daten in der Collection + ULONG nHandle; // wird von double auf ULONG gecasted + ParamType eType; // PTR_DOUBLE oder PTR_STRING Ergebnis + BOOL bValid; // ob Wert gueltig + +public: + // cTor nur wenn ScAddInAsync::Get fehlschlaegt! + // nIndex: Index aus der FunctionCollection + ScAddInAsync( ULONG nHandle, USHORT nIndex, + ScDocument* pDoc ); + // default-cTor nur fuer das eine globale aSeekObj !!! + ScAddInAsync(); + virtual ~ScAddInAsync(); + static ScAddInAsync* Get( ULONG nHandle ); + static void CallBack( ULONG nHandle, void* pData ); + static void RemoveDocument( ScDocument* pDocument ); + BOOL IsValid() const { return bValid; } + ParamType GetType() const { return eType; } + double GetValue() const { return nVal; } + const String& GetString() const { return *pStr; } + BOOL HasDocument( ScDocument* pDoc ) const + { return pDocs->Seek_Entry( pDoc ); } + void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } + + // Vergleichsoperatoren fuer PtrArrSort + BOOL operator < ( const ScAddInAsync& r ) { return nHandle < r.nHandle; } + BOOL operator ==( const ScAddInAsync& r ) { return nHandle == r.nHandle; } +}; + + + +#endif diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx new file mode 100644 index 000000000000..1ecbefe4a9b1 --- /dev/null +++ b/sc/source/core/inc/bcaslot.hxx @@ -0,0 +1,309 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_BCASLOT_HXX +#define SC_BCASLOT_HXX + +#include <set> +#include <hash_set> +#include <functional> +#include <svl/broadcast.hxx> +#include <svl/svarray.hxx> + +#include "global.hxx" +#include "brdcst.hxx" + +/** + Used in a Unique Associative Container. + */ + +class ScBroadcastArea +{ +private: + ScBroadcastArea* pUpdateChainNext; + SvtBroadcaster aBroadcaster; + ScRange aRange; + ULONG nRefCount; + BOOL bInUpdateChain; + +public: + ScBroadcastArea( const ScRange& rRange ) + : pUpdateChainNext( NULL ), aRange( rRange ), + nRefCount( 0 ), bInUpdateChain( FALSE ) {} + inline SvtBroadcaster& GetBroadcaster() { return aBroadcaster; } + inline const SvtBroadcaster& GetBroadcaster() const { return aBroadcaster; } + inline void UpdateRange( const ScRange& rNewRange ) + { aRange = rNewRange; } + inline const ScRange& GetRange() const { return aRange; } + inline const ScAddress& GetStart() const { return aRange.aStart; } + inline const ScAddress& GetEnd() const { return aRange.aEnd; } + inline void IncRef() { ++nRefCount; } + inline ULONG DecRef() { return nRefCount ? --nRefCount : 0; } + inline ULONG GetRef() { return nRefCount; } + inline ScBroadcastArea* GetUpdateChainNext() const { return pUpdateChainNext; } + inline void SetUpdateChainNext( ScBroadcastArea* p ) { pUpdateChainNext = p; } + inline BOOL IsInUpdateChain() const { return bInUpdateChain; } + inline void SetInUpdateChain( BOOL b ) { bInUpdateChain = b; } + + /** Equalness of this or range. */ + inline bool operator==( const ScBroadcastArea & rArea ) const; +}; + +inline bool ScBroadcastArea::operator==( const ScBroadcastArea & rArea ) const +{ + return aRange == rArea.aRange; +} + +//============================================================================= + +struct ScBroadcastAreaHash +{ + size_t operator()( const ScBroadcastArea* p ) const + { + return p->GetRange().hashArea(); + } +}; + +struct ScBroadcastAreaEqual +{ + bool operator()( const ScBroadcastArea* p1, const ScBroadcastArea* p2) const + { + return *p1 == *p2; + } +}; + +typedef ::std::hash_set< ScBroadcastArea*, ScBroadcastAreaHash, ScBroadcastAreaEqual > ScBroadcastAreas; + +//============================================================================= + +struct ScBroadcastAreaBulkHash +{ + size_t operator()( const ScBroadcastArea* p ) const + { + return reinterpret_cast<size_t>(p); + } +}; + +struct ScBroadcastAreaBulkEqual +{ + bool operator()( const ScBroadcastArea* p1, const ScBroadcastArea* p2) const + { + return p1 == p2; + } +}; + +typedef ::std::hash_set< const ScBroadcastArea*, ScBroadcastAreaBulkHash, + ScBroadcastAreaBulkEqual > ScBroadcastAreasBulk; + +//============================================================================= + +class ScBroadcastAreaSlotMachine; + +/// Collection of BroadcastAreas +class ScBroadcastAreaSlot +{ +private: + ScBroadcastAreas aBroadcastAreaTbl; + mutable ScBroadcastArea aTmpSeekBroadcastArea; // for FindBroadcastArea() + ScDocument* pDoc; + ScBroadcastAreaSlotMachine* pBASM; + + ScBroadcastAreas::iterator FindBroadcastArea( const ScRange& rRange ) const; + + /** + More hypothetical (memory would probably be doomed anyway) check + whether there would be an overflow when adding an area, setting the + proper state if so. + + @return TRUE if a HardRecalcState is effective and area is not to be + added. + */ + bool CheckHardRecalcStateCondition() const; + +public: + ScBroadcastAreaSlot( ScDocument* pDoc, + ScBroadcastAreaSlotMachine* pBASM ); + ~ScBroadcastAreaSlot(); + const ScBroadcastAreas& GetBroadcastAreas() const + { return aBroadcastAreaTbl; } + + /** + Only here new ScBroadcastArea objects are created, prevention of dupes. + + @param rpArea + If NULL, a new ScBroadcastArea is created and assigned ton the + reference if a matching area wasn't found. If a matching area was + found, that is assigned. In any case, the SvtListener is added to + the broadcaster. + + If not NULL then no listeners are startet, only the area is + inserted and the reference count incremented. Effectively the same + as InsertListeningArea(), so use that instead. + + @return + TRUE if rpArea passed was NULL and ScBroadcastArea is newly + created. + */ + bool StartListeningArea( const ScRange& rRange, + SvtListener* pListener, + ScBroadcastArea*& rpArea ); + + /** + Insert a ScBroadcastArea obtained via StartListeningArea() to + subsequent slots. + */ + void InsertListeningArea( ScBroadcastArea* pArea ); + + void EndListeningArea( const ScRange& rRange, + SvtListener* pListener, + ScBroadcastArea*& rpArea ); + BOOL AreaBroadcast( const ScHint& rHint ) const; + /// @return TRUE if at least one broadcast occurred. + BOOL AreaBroadcastInRange( const ScRange& rRange, + const ScHint& rHint ) const; + void DelBroadcastAreasInRange( const ScRange& rRange ); + void UpdateRemove( UpdateRefMode eUpdateRefMode, + const ScRange& rRange, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); + void UpdateRemoveArea( ScBroadcastArea* pArea ); + void UpdateInsert( ScBroadcastArea* pArea ); +}; + + +/** + BroadcastAreaSlots and their management, once per document. + */ + +class ScBroadcastAreaSlotMachine +{ +private: + + /** + Slot offset arrangement of columns and rows, once per sheet. + + +---+---+ + | 0 | 3 | + +---+---+ + | 1 | 4 | + +---+---+ + | 2 | 5 | + +---+---+ + */ + + /* TODO: When going for 1M rows this will definitely need some change, or + * with lots of referred sheets even the reservation of NULL pointers would + * be a memory hog. */ + + class TableSlots + { + public: + TableSlots(); + ~TableSlots(); + inline ScBroadcastAreaSlot** getSlots() { return ppSlots; } + + /** + Obtain slot pointer, no check on validity! It is assumed that + all calls are made with the result of ComputeSlotOfsset() + */ + inline ScBroadcastAreaSlot* getAreaSlot( SCSIZE nOff ) { return *(ppSlots + nOff); } + + private: + ScBroadcastAreaSlot** ppSlots; + + // prevent usage + TableSlots( const TableSlots& ); + TableSlots& operator=( const TableSlots& ); + }; + + typedef ::std::map< SCTAB, TableSlots* > TableSlotsMap; + +private: + ScBroadcastAreasBulk aBulkBroadcastAreas; + TableSlotsMap aTableSlotsMap; + SvtBroadcaster *pBCAlways; // for the RC_ALWAYS special range + ScDocument *pDoc; + ScBroadcastArea *pUpdateChain; + ScBroadcastArea *pEOUpdateChain; + ULONG nInBulkBroadcast; + + inline SCSIZE ComputeSlotOffset( const ScAddress& rAddress ) const; + void ComputeAreaPoints( const ScRange& rRange, + SCSIZE& nStart, SCSIZE& nEnd, + SCSIZE& nRowBreak ) const; + +public: + ScBroadcastAreaSlotMachine( ScDocument* pDoc ); + ~ScBroadcastAreaSlotMachine(); + void StartListeningArea( const ScRange& rRange, + SvtListener* pListener ); + void EndListeningArea( const ScRange& rRange, + SvtListener* pListener ); + BOOL AreaBroadcast( const ScHint& rHint ) const; + // return: at least one broadcast occurred + BOOL AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHint ) const; + void DelBroadcastAreasInRange( const ScRange& rRange ); + void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode, + const ScRange& rRange, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); + void EnterBulkBroadcast(); + void LeaveBulkBroadcast(); + bool InsertBulkArea( const ScBroadcastArea* p ); + /// @return: how many removed + size_t RemoveBulkArea( const ScBroadcastArea* p ); + inline ScBroadcastArea* GetUpdateChain() const { return pUpdateChain; } + inline void SetUpdateChain( ScBroadcastArea* p ) { pUpdateChain = p; } + inline ScBroadcastArea* GetEOUpdateChain() const { return pEOUpdateChain; } + inline void SetEOUpdateChain( ScBroadcastArea* p ) { pEOUpdateChain = p; } + inline bool IsInBulkBroadcast() const { return nInBulkBroadcast > 0; } +}; + + +class ScBulkBroadcast +{ + ScBroadcastAreaSlotMachine* pBASM; +public: + explicit ScBulkBroadcast( ScBroadcastAreaSlotMachine* p ) : pBASM(p) + { + if (pBASM) + pBASM->EnterBulkBroadcast(); + } + ~ScBulkBroadcast() + { + if (pBASM) + pBASM->LeaveBulkBroadcast(); + } + void LeaveBulkBroadcast() + { + if (pBASM) + { + pBASM->LeaveBulkBroadcast(); + pBASM = NULL; + } + } +}; + +#endif diff --git a/sc/source/core/inc/cellkeytranslator.hxx b/sc/source/core/inc/cellkeytranslator.hxx new file mode 100644 index 000000000000..536e521a78da --- /dev/null +++ b/sc/source/core/inc/cellkeytranslator.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_CELLKEY_TRANSLATOR_HXX +#define SC_CELLKEY_TRANSLATOR_HXX + +#include "global.hxx" +#include "formula/opcode.hxx" +#include "unotools/transliterationwrapper.hxx" +#include <hash_map> +#include <list> +#include <memory> + +#include <com/sun/star/lang/Locale.hpp> + +struct TransItem; + +struct ScCellKeyword +{ + const sal_Char* mpName; + OpCode meOpCode; + const ::com::sun::star::lang::Locale& mrLocale; + + ScCellKeyword(const sal_Char* pName, OpCode eOpCode, const ::com::sun::star::lang::Locale& rLocale); +}; + +typedef ::std::hash_map< String, ::std::list<ScCellKeyword>, ScStringHashCode, ::std::equal_to<String> > ScCellKeywordHashMap; + +/** Translate cell function keywords. + + This class provides a convenient way to translate a string keyword used as + a cell function argument. Since Calc's built-in cell functions don't + localize string keywords, this class is used mainly to deal with an Excel + document where string names may be localized. + + To use, simply call the + + ScCellKeywordTranslator::transKeyword(...) + + function. + + Note that when the locale and/or the opcode is specified, the function + tries to find a string with matching locale and/or opcode. But when it + fails to find one that satisfies the specified locale and/or opcode, it + returns a translated string with non-matching locale and/or opcode if + available. */ +class ScCellKeywordTranslator +{ +public: + static void transKeyword(String& rName, const ::com::sun::star::lang::Locale* pLocale = NULL, OpCode eOpCode = ocNone); + ~ScCellKeywordTranslator(); + +private: + ScCellKeywordTranslator(); + + void init(); + void addToMap(const String& rKey, const sal_Char* pName, + const ::com::sun::star::lang::Locale& rLocale, + OpCode eOpCode = ocNone); + void addToMap(const TransItem* pItems, const ::com::sun::star::lang::Locale& rLocale); + + static ::std::auto_ptr<ScCellKeywordTranslator> spInstance; + ScCellKeywordHashMap maStringNameMap; + ::utl::TransliterationWrapper maTransWrapper; +}; + +#endif diff --git a/sc/source/core/inc/core_pch.hxx b/sc/source/core/inc/core_pch.hxx new file mode 100644 index 000000000000..899169154d8d --- /dev/null +++ b/sc/source/core/inc/core_pch.hxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +// ItemID-Defines etc. muessen immer ganz vorne stehen + +#include "scitems.hxx" + + +#define _ZFORLIST_DECLARE_TABLE + +#define SC_PROGRESS_CXX + +// ab hier automatisch per makepch generiert +// folgende duerfen nicht aufgenommen werden: +// setjmp.h + +#include <tools/solar.h> +#include <string.h> +#include <tools/string.hxx> +#include <tools/rtti.hxx> +#include <limits.h> +#include <tools/ref.hxx> +#include <tools/list.hxx> +#include <tools/contnr.hxx> +#include <tools/link.hxx> +#include <tools/stream.hxx> +#include <tools/errinf.hxx> +#include <tools/errcode.hxx> +#include <vcl/sv.h> +#include <global.hxx> +#include <tools/color.hxx> +#include <i18npool/lang.h> +#include <tools/debug.hxx> +#include <tools/gen.hxx> +#include <svl/svarray.hxx> +#include <markarr.hxx> +#include <vcl/timer.hxx> +#include <rangelst.hxx> +#include <document.hxx> +#include <vcl/prntypes.hxx> +#include <table.hxx> +#include <column.hxx> +#include <svl/hint.hxx> +#include <svl/lstner.hxx> +#include <svl/poolitem.hxx> +#include <tools/time.hxx> +#include <svl/solar.hrc> +#include <tools/date.hxx> +#include <svl/brdcst.hxx> +#include <svx/svxids.hrc> +#include <svl/memberid.hrc> +#include <sfx2/sfx.hrc> +#include <sfx2/sfxsids.hrc> +#include <svl/cntwids.hrc> +#include <tools/resid.hxx> +#include <tools/table.hxx> +#include <stdarg.h> +#include <tools/rc.hxx> +#include <tools/resmgr.hxx> +#include <tools/unqidx.hxx> +#include <rsc/rscsfx.hxx> +#include <basic/sbxdef.hxx> +#include <svl/itemset.hxx> +#include <stddef.h> +#include <collect.hxx> +#include <scitems.hxx> +#include <tools/globname.hxx> +#include <tools/fract.hxx> +#include <sfx2/shell.hxx> +#include <cell.hxx> +#include <tools/mempool.hxx> +#include <vcl/color.hxx> +#include <vcl/region.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/bitmap.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <sot/object.hxx> +#include <sot/factory.hxx> +#include <sot/sotdata.hxx> +#include <vcl/keycod.hxx> +#include <vcl/keycodes.hxx> +#include <sot/sotref.hxx> +#include <rechead.hxx> +#include <tools/unqid.hxx> +#include <vcl/apptypes.hxx> +#include <vcl/vclenum.hxx> +#include <globstr.hrc> +#include <formula/compiler.hrc> +#include <tools/shl.hxx> +#include <compiler.hxx> +#include <vcl/font.hxx> +#include <svl/smplhint.hxx> +#include <vcl/wall.hxx> +#include <vcl/settings.hxx> +#include <vcl/accel.hxx> +#include <patattr.hxx> +#include <svl/zforlist.hxx> +#include <tools/pstm.hxx> +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> +#include <vcl/pointr.hxx> +#include <vcl/ptrstyle.hxx> +#include <vcl/wintypes.hxx> +#include <vcl/event.hxx> +#include <tools/ownlist.hxx> +#include <svl/itempool.hxx> +#include <tools/datetime.hxx> +#include <attrib.hxx> +#include <docpool.hxx> +#include <sot/storage.hxx> +#include <sfx2/objsh.hxx> +#include <vcl/window.hxx> +#include <svtools/confitem.hxx> +#include <vcl/syswin.hxx> +#include <sc.hrc> +#include <svx/dialogs.hrc> +#include <math.h> +#include <svl/style.hxx> +#include <svl/style.hrc> +#include <stdlib.h> +#include <vcl/prntypes.hxx> +#include <vcl/jobset.hxx> +#include <vcl/gdimtf.hxx> +//#include <setjmp.h> +#include <tools/urlobj.hxx> +#include <vcl/print.hxx> +#include <docoptio.hxx> +#include <markdata.hxx> +#include <vcl/wrkwin.hxx> +#include <stlpool.hxx> +#include <sfx2/app.hxx> +#include <svl/inetmsg.hxx> +#include <svtools/compat.hxx> +#include <svl/inetdef.hxx> +#include <svl/inethist.hxx> +#include <vcl/accel.hxx> +#include <sfx2/sfxdefs.hxx> +#include <sfx2/module.hxx> +#include <sfx2/imgdef.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/field.hxx> +#include <vcl/spinfld.hxx> +#include <vcl/edit.hxx> +#include <vcl/timer.hxx> +#include <vcl/combobox.hxx> +#include <vcl/combobox.h> +#include <refupdat.hxx> +#include <editeng/boxitem.hxx> +#include <conditio.hxx> +#include <brdcst.hxx> +#include <editeng/svxenum.hxx> +#include <dociter.hxx> +#include <scdll.hxx> +#include <stdio.h> +#include <stlsheet.hxx> +#include <vcl/gdiobj.hxx> +#include <vcl/mapmod.hxx> +#include <progress.hxx> +#include <sfx2/progress.hxx> +#include <vcl/event.hxx> +#include <vcl/window.hxx> +#include <svx/algitem.hxx> +#include <vcl/field.hxx> +#include <svx/svdtypes.hxx> +#include <vcl/graph.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/animate.hxx> +#include <vcl/graph.h> +#include <drwlayer.hxx> +#include <svx/svdmodel.hxx> +#include <scresid.hxx> +#include <vcl/print.hxx> +#include <attarray.hxx> +#include <svl/ownlist.hxx> +#include <interpre.hxx> +#include <subtotal.hxx> +#include <rangenam.hxx> +#include <scmatrix.hxx> +#include <svx/pageitem.hxx> +#include <dbcolect.hxx> +#include <userlist.hxx> +#include <editeng/editdata.hxx> +#include <basic/sbxvar.hxx> +#include <basic/sbxcore.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdsob.hxx> +#include <svx/svdglue.hxx> +#include <editeng/langitem.hxx> +#include <editeng/eeitem.hxx> +#include <callform.hxx> +#include <validat.hxx> +#include <editeng/brshitem.hxx> +#include <sot/exchange.hxx> +#include <editeng/editeng.hxx> +#include <vcl/fonttype.hxx> +#include <editeng/editobj.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <svl/stritem.hxx> +#include <pivot.hxx> +#include <vcl/gdimtf.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdlayer.hxx> +#include <sfx2/linkmgr.hxx> +#include <ctype.h> +#include <vcl/font.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/postitem.hxx> +#include <svx/svditer.hxx> +#include <editeng/udlnitem.hxx> +#include <adiasync.hxx> +#include <sfx2/bindings.hxx> +#include <ddelink.hxx> +#include <chartlis.hxx> +#include <sfx2/minarray.hxx> +#include <svtools/txtcmp.hxx> +#include <olinetab.hxx> +#include <basic/sbxobj.hxx> +#include <cfgids.hxx> + + + + diff --git a/sc/source/core/inc/ddelink.hxx b/sc/source/core/inc/ddelink.hxx new file mode 100644 index 000000000000..4f0652753e65 --- /dev/null +++ b/sc/source/core/inc/ddelink.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_DDELINK_HXX +#define SC_DDELINK_HXX + +#include "address.hxx" +#include <sfx2/lnkbase.hxx> +#include <svl/broadcast.hxx> +#include "scmatrix.hxx" + +class ScDocument; +class ScMultipleReadHeader; +class ScMultipleWriteHeader; +class SvStream; + +class ScDdeLink : public ::sfx2::SvBaseLink, public SvtBroadcaster +{ +private: +static BOOL bIsInUpdate; + + ScDocument* pDoc; + + String aAppl; // Verbindungsdaten + String aTopic; + String aItem; + BYTE nMode; // Zahlformat-Modus + + BOOL bNeedUpdate; // wird gesetzt, wenn Update nicht moeglich war + + ScMatrixRef pResult; // Ergebnis + +public: + TYPEINFO(); + + ScDdeLink( ScDocument* pD, + const String& rA, const String& rT, const String& rI, + BYTE nM ); + ScDdeLink( ScDocument* pD, SvStream& rStream, ScMultipleReadHeader& rHdr ); + ScDdeLink( ScDocument* pD, const ScDdeLink& rOther ); + virtual ~ScDdeLink(); + + void Store( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const; + + // von SvBaseLink ueberladen: + virtual void DataChanged( const String& rMimeType, + const ::com::sun::star::uno::Any & rValue ); + + // von SvtBroadcaster ueberladen: + virtual void ListenersGone(); + + // fuer Interpreter: + + const ScMatrix* GetResult() const { return pResult; } + void SetResult( ScMatrix* pRes ) { pResult = pRes; } + + // XML and Excel import after NewData() + ScMatrixRef GetModifiableResult() { return pResult; } + + const String& GetAppl() const { return aAppl; } + const String& GetTopic() const { return aTopic; } + const String& GetItem() const { return aItem; } + BYTE GetMode() const { return nMode; } + + void ResetValue(); // Wert zuruecksetzen + void TryUpdate(); + + BOOL NeedsUpdate() const { return bNeedUpdate; } + + static BOOL IsInUpdate() { return bIsInUpdate; } +}; + + +#endif + diff --git a/sc/source/core/inc/doubleref.hxx b/sc/source/core/inc/doubleref.hxx new file mode 100644 index 000000000000..e7bd2dfa6ae1 --- /dev/null +++ b/sc/source/core/inc/doubleref.hxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * 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: interpre.hxx,v $ + * $Revision: 1.35.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_DOUBLEREF_HXX +#define SC_DOUBLEREF_HXX + +#include "address.hxx" +#include "scmatrix.hxx" + +class ScDocument; +class ScBaseCell; +struct ScDBQueryParamBase; +struct ScQueryParamBase; + +// ============================================================================ + +/** + * Base class for abstracting range data backends for database functions. + */ +class ScDBRangeBase +{ +public: + enum RefType { INTERNAL, EXTERNAL }; + + virtual ~ScDBRangeBase() = 0; + + RefType getType() const; + bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const; + + virtual SCCOL getColSize() const = 0; + virtual SCROW getRowSize() const = 0; + virtual SCSIZE getVisibleDataCellCount() const = 0; + + /** + * Get a string value of a specified cell position. Note that the + * position of the upper left cell of the range is always (0, 0) even if + * the reference type is of internal range. + * + * @param nCol column position (0 to column size-1) + * @param nRow row position (0 to row size-1) + */ + virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const = 0; + + virtual SCCOL getFirstFieldColumn() const = 0; + + /** + * Get a <i>0-based</i> column index that corresponds with the passed field + * index. Note that the field index passed as the 1st parameter is + * <i>1-based.</i> + * + * @param nIndex 1-based field index. + * + * @return 0-based column index + */ + virtual SCCOL findFieldColumn(SCCOL nIndex) const = 0; + virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const = 0; + virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const = 0; + virtual bool isRangeEqual(const ScRange& rRange) const = 0; + +protected: + ScDBRangeBase(ScDocument* pDoc, RefType eType); + ScDocument* getDoc() const; + + /** + * Populate query options that are always the same for all database + * queries. + */ + static void fillQueryOptions(ScQueryParamBase* pParam); + +private: + ScDBRangeBase(); // disabled + + ScDocument* mpDoc; + RefType meType; +}; + +// ============================================================================ + +class ScDBInternalRange : public ScDBRangeBase +{ +public: + explicit ScDBInternalRange(ScDocument* pDoc, const ScRange& rRange); + virtual ~ScDBInternalRange(); + + const ScRange& getRange() const; + + virtual SCCOL getColSize() const; + virtual SCROW getRowSize() const; + virtual SCSIZE getVisibleDataCellCount() const; + + /** + * Get a string value of a specified cell position. Note that the + * position of the upper left cell of the range is always (0, 0) even if + * the reference type is of internal range. + * + * @param nCol column position (0 to column size-1) + * @param nRow row position (0 to row size-1) + */ + virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const; + + virtual SCCOL getFirstFieldColumn() const; + /** + * Get a <i>0-based</i> column index that corresponds with the passed field + * index. Note that the field index passed as the 1st parameter is + * <i>1-based.</i> + * + * @param nIndex 1-based field index. + * + * @return 0-based column index + */ + virtual SCCOL findFieldColumn(SCCOL nIndex) const; + virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const; + virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const; + virtual bool isRangeEqual(const ScRange& rRange) const; + +private: + sal_uInt16 getCellString(::rtl::OUString& rStr, ScBaseCell* pCell) const; + +private: + ScRange maRange; +}; + +// ============================================================================ + +class ScDBExternalRange : public ScDBRangeBase +{ +public: + explicit ScDBExternalRange(ScDocument* pDoc, const ScMatrixRef& pMat); + virtual ~ScDBExternalRange(); + + virtual SCCOL getColSize() const; + virtual SCROW getRowSize() const; + virtual SCSIZE getVisibleDataCellCount() const; + + /** + * Get a string value of a specified cell position. Note that the + * position of the upper left cell of the range is always (0, 0) even if + * the reference type is of internal range. + * + * @param nCol column position (0 to column size-1) + * @param nRow row position (0 to row size-1) + */ + virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const; + + virtual SCCOL getFirstFieldColumn() const; + + /** + * Get a <i>0-based</i> column index that corresponds with the passed field + * index. Note that the field index passed as the 1st parameter is + * <i>1-based.</i> + * + * @param nIndex 1-based field index. + * + * @return 0-based column index + */ + virtual SCCOL findFieldColumn(SCCOL nIndex) const; + virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const; + virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const; + virtual bool isRangeEqual(const ScRange& rRange) const; + +private: + const ScMatrixRef mpMatrix; + SCCOL mnCols; + SCROW mnRows; +}; + +#endif diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx new file mode 100644 index 000000000000..2075129e4f6e --- /dev/null +++ b/sc/source/core/inc/interpre.hxx @@ -0,0 +1,918 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_INTERPRE_HXX +#define SC_INTERPRE_HXX + +#define SC_SPEW_ENABLED 0 + +#include <math.h> +#include <rtl/math.hxx> +#include "formula/errorcodes.hxx" +#include "cell.hxx" +#include "scdll.hxx" +#include "document.hxx" +#include "scmatrix.hxx" + +#if SC_SPEW_ENABLED +#include "scspew.hxx" +#endif + +#include <math.h> +#include <map> + +class ScDocument; +class SbxVariable; +class ScBaseCell; +class ScFormulaCell; +class SvNumberFormatter; +class ScDBRangeBase; +struct MatrixDoubleOp; +struct ScQueryParam; +struct ScDBQueryParamBase; + +struct ScCompare +{ + double nVal[2]; + String* pVal[2]; + BOOL bVal[2]; + BOOL bEmpty[2]; + ScCompare( String* p1, String* p2 ) + { + pVal[ 0 ] = p1; + pVal[ 1 ] = p2; + bEmpty[0] = FALSE; + bEmpty[1] = FALSE; + } +}; + +struct ScCompareOptions +{ + ScQueryEntry aQueryEntry; + bool bRegEx; + bool bMatchWholeCell; + bool bIgnoreCase; + + ScCompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ); +private: + // Not implemented, prevent usage. + ScCompareOptions(); + ScCompareOptions( const ScCompareOptions & ); + ScCompareOptions& operator=( const ScCompareOptions & ); +}; + +class ScToken; + +#define MAXSTACK (4096 / sizeof(formula::FormulaToken*)) + +class ScTokenStack +{ +public: + DECL_FIXEDMEMPOOL_NEWDEL( ScTokenStack ) + formula::FormulaToken* pPointer[ MAXSTACK ]; +}; + +enum ScIterFunc { + ifSUM, // Aufsummieren + ifSUMSQ, // Quadratsummen + ifPRODUCT, // Multiplizieren + ifAVERAGE, // Durchschnitt + ifCOUNT, // Anzahl Werte + ifCOUNT2, // Anzahl Werte (nichtleer) + ifMIN, // Minimum + ifMAX // Maximum +}; + +struct FormulaTokenRef_less +{ + bool operator () ( const formula::FormulaConstTokenRef& r1, const formula::FormulaConstTokenRef& r2 ) const + { return &r1 < &r2; } +}; +typedef ::std::map< const formula::FormulaConstTokenRef, formula::FormulaTokenRef, FormulaTokenRef_less> ScTokenMatrixMap; + +class ScInterpreter +{ + // distibution function objects need the GetxxxDist methods + friend class ScGammaDistFunction; + friend class ScBetaDistFunction; + friend class ScTDistFunction; + friend class ScFDistFunction; + friend class ScChiDistFunction; + friend class ScChiSqDistFunction; + +public: + DECL_FIXEDMEMPOOL_NEWDEL( ScInterpreter ) +#if SC_SPEW_ENABLED + static ScSpew theSpew; +#endif + + static void GlobalExit(); // aus ScGlobal::Clear() gerufen + + /// Could string be a regular expression? + /// If pDoc!=NULL the document options are taken into account and if + /// RegularExpressions are disabled the function returns FALSE regardless + /// of the string content. + static BOOL MayBeRegExp( const String& rStr, const ScDocument* pDoc ); + + /// Fail safe division, returning an errDivisionByZero coded into a double + /// if denominator is 0.0 + static inline double div( const double& fNumerator, const double& fDenominator ); + + ScMatrixRef GetNewMat(SCSIZE nC, SCSIZE nR); +private: + static ScTokenStack* pGlobalStack; + static BOOL bGlobalStackInUse; + + formula::FormulaTokenIterator aCode; + ScAddress aPos; + ScTokenArray& rArr; + ScDocument* pDok; + formula::FormulaTokenRef xResult; + ScJumpMatrix* pJumpMatrix; // currently active array condition, if any + ScTokenMatrixMap* pTokenMatrixMap; // map ScToken* to formula::FormulaTokenRef if in array condition + ScFormulaCell* pMyFormulaCell; // the cell of this formula expression + SvNumberFormatter* pFormatter; + + const formula::FormulaToken* + pCur; // current token + String aTempStr; // for GetString() + ScTokenStack* pStackObj; // contains the stacks + formula::FormulaToken** pStack; // the current stack + USHORT nGlobalError; // global (local to this formula expression) error + USHORT sp; // stack pointer + USHORT maxsp; // the maximal used stack pointer + ULONG nFuncFmtIndex; // NumberFormatIndex of a function + ULONG nCurFmtIndex; // current NumberFormatIndex + ULONG nRetFmtIndex; // NumberFormatIndex of an expression, if any + short nFuncFmtType; // NumberFormatType of a function + short nCurFmtType; // current NumberFormatType + short nRetFmtType; // NumberFormatType of an expression + USHORT mnStringNoValueError; // the error set in ConvertStringToValue() if no value + BOOL glSubTotal; // flag for subtotal functions + BYTE cPar; // current count of parameters + BOOL bCalcAsShown; // precision as shown + BOOL bMatrixFormula; // formula cell is a matrix formula + +//---------------------------------Funktionen in interpre.cxx--------- +// nMust <= nAct <= nMax ? ok : PushError +inline BOOL MustHaveParamCount( short nAct, short nMust ); +inline BOOL MustHaveParamCount( short nAct, short nMust, short nMax ); +inline BOOL MustHaveParamCountMin( short nAct, short nMin ); +void PushParameterExpected(); +void PushIllegalParameter(); +void PushIllegalArgument(); +void PushNoValue(); +void PushNA(); +//------------------------------------------------------------------------- +// Funktionen fuer den Zugriff auf das Document +//------------------------------------------------------------------------- +void ReplaceCell( ScAddress& ); // for TableOp +void ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab ); // for TableOp +BOOL IsTableOpInRange( const ScRange& ); +ULONG GetCellNumberFormat( const ScAddress&, const ScBaseCell* ); +double ConvertStringToValue( const String& ); +double GetCellValue( const ScAddress&, const ScBaseCell* ); +double GetCellValueOrZero( const ScAddress&, const ScBaseCell* ); +double GetValueCellValue( const ScAddress&, const ScValueCell* ); +ScBaseCell* GetCell( const ScAddress& rPos ) + { return pDok->GetCell( rPos ); } +void GetCellString( String& rStr, const ScBaseCell* pCell ); +inline USHORT GetCellErrCode( const ScBaseCell* pCell ) + { return pCell ? pCell->GetErrorCode() : 0; } +inline CellType GetCellType( const ScBaseCell* pCell ) + { return pCell ? pCell->GetCellType() : CELLTYPE_NONE; } +/// Really empty or inherited emptiness. +inline BOOL HasCellEmptyData( const ScBaseCell* pCell ) + { return pCell ? pCell->HasEmptyData() : TRUE; } +/// This includes inherited emptiness, which usually is regarded as value! +inline BOOL HasCellValueData( const ScBaseCell* pCell ) + { return pCell ? pCell->HasValueData() : FALSE; } +/// Not empty and not value. +inline BOOL HasCellStringData( const ScBaseCell* pCell ) + { return pCell ? pCell->HasStringData() : FALSE; } + +BOOL CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr); +BOOL CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr); +BOOL CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr); + +//----------------------------------------------------------------------------- +// Stack operations +//----------------------------------------------------------------------------- + +/** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token + passed is not formula::FormulaErrorToken. + Increments RefCount of the original token if not substituted. */ +void Push( formula::FormulaToken& r ); + +/** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set. + Used to push RPN tokens or from within Push() or tokens that are already + explicit formula::FormulaErrorToken. Increments RefCount. */ +void PushWithoutError( formula::FormulaToken& r ); + +/** Clones the token to be pushed or substitutes with formula::FormulaErrorToken if + nGlobalError is set and the token passed is not formula::FormulaErrorToken. */ +void PushTempToken( const formula::FormulaToken& ); + +/** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token + passed is not formula::FormulaErrorToken. + Increments RefCount of the original token if not substituted. + ATTENTION! The token had to be allocated with `new' and must not be used + after this call if no RefCount was set because possibly it gets immediately + deleted in case of an errStackOverflow or if substituted with formula::FormulaErrorToken! */ +void PushTempToken( formula::FormulaToken* ); + +/** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set. + Used to push tokens from within PushTempToken() or tokens that are already + explicit formula::FormulaErrorToken. Increments RefCount. + ATTENTION! The token had to be allocated with `new' and must not be used + after this call if no RefCount was set because possibly it gets immediately + decremented again and thus deleted in case of an errStackOverflow! */ +void PushTempTokenWithoutError( formula::FormulaToken* ); + +/** If nGlobalError is set push formula::FormulaErrorToken. + If nGlobalError is not set do nothing. + Used in PushTempToken() and alike to simplify handling. + @return: <TRUE/> if nGlobalError. */ +inline bool IfErrorPushError() +{ + if (nGlobalError) + { + PushTempTokenWithoutError( new formula::FormulaErrorToken( nGlobalError)); + return true; + } + return false; +} + +/** Obtain cell result / content from address and push as temp token. + bDisplayEmptyAsString is passed to ScEmptyCell in case of an empty cell + result. Also obtain number format and type if _both_, type and index + pointer, are not NULL. */ +void PushCellResultToken( bool bDisplayEmptyAsString, const ScAddress & rAddress, + short * pRetTypeExpr, ULONG * pRetIndexExpr ); + +formula::FormulaTokenRef PopToken(); +void Pop(); +void PopError(); +double PopDouble(); +const String& PopString(); +void ValidateRef( const ScSingleRefData & rRef ); +void ValidateRef( const ScComplexRefData & rRef ); +void ValidateRef( const ScRefList & rRefList ); +void SingleRefToVars( const ScSingleRefData & rRef, SCCOL & rCol, SCROW & rRow, SCTAB & rTab ); +void PopSingleRef( ScAddress& ); +void PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab); +void DoubleRefToRange( const ScComplexRefData&, ScRange&, BOOL bDontCheckForTableOp = FALSE ); +/** If formula::StackVar formula::svDoubleRef pop ScDoubleRefToken and return values of + ScComplexRefData. + Else if StackVar svRefList return values of the ScComplexRefData where + rRefInList is pointing to. rRefInList is incremented. If rRefInList was the + last element in list pop ScRefListToken and set rRefInList to 0, else + rParam is incremented (!) to allow usage as in + while(nParamCount--) PopDoubleRef(aRange,nParamCount,nRefInList); + */ +void PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRefInList ); +void PopDoubleRef( ScRange&, BOOL bDontCheckForTableOp = FALSE ); +void DoubleRefToVars( const ScToken* p, + SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, + SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, + BOOL bDontCheckForTableOp = FALSE ); +ScDBRangeBase* PopDoubleRef(); +void PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, + SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, + BOOL bDontCheckForTableOp = FALSE ); +BOOL PopDoubleRefOrSingleRef( ScAddress& rAdr ); +void PopDoubleRefPushMatrix(); +// If MatrixFormula: convert formula::svDoubleRef to svMatrix, create JumpMatrix. +// Else convert area reference parameters marked as ForceArray to array. +// Returns TRUE if JumpMatrix created. +bool ConvertMatrixParameters(); +inline void MatrixDoubleRefToMatrix(); // if MatrixFormula: PopDoubleRefPushMatrix +// If MatrixFormula or ForceArray: ConvertMatrixParameters() +inline bool MatrixParameterConversion(); +ScMatrixRef PopMatrix(); +//void PushByte(BYTE nVal); +void PushDouble(double nVal); +void PushInt( int nVal ); +void PushStringBuffer( const sal_Unicode* pString ); +void PushString( const String& rString ); +void PushSingleRef(SCCOL nCol, SCROW nRow, SCTAB nTab); +void PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2); +void PushMatrix(ScMatrix* pMat); +void PushError( USHORT nError ); +/// Raw stack type without default replacements. +formula::StackVar GetRawStackType(); +/// Stack type with replacement of defaults, e.g. svMissing and formula::svEmptyCell will result in formula::svDouble. +formula::StackVar GetStackType(); +// peek StackType of Parameter, Parameter 1 == TOS, 2 == TOS-1, ... +formula::StackVar GetStackType( BYTE nParam ); +BYTE GetByte() { return cPar; } +// generiert aus DoubleRef positionsabhaengige SingleRef +BOOL DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& rAdr ); +double GetDouble(); +double GetDoubleWithDefault(double nDefault); +BOOL IsMissing(); +BOOL GetBool() { return GetDouble() != 0.0; } +const String& GetString(); +// pop matrix and obtain one element, upper left or according to jump matrix +ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, String& rString ); +ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ); +inline ScTokenMatrixMap& GetTokenMatrixMap(); +ScTokenMatrixMap* CreateTokenMatrixMap(); +ScMatrixRef GetMatrix(); +void ScTableOp(); // Mehrfachoperationen +void ScErrCell(); // Sonderbehandlung + // Fehlerzelle +//-----------------------------allgemeine Hilfsfunktionen +void SetMaxIterationCount(USHORT n); +inline void CurFmtToFuncFmt() + { nFuncFmtType = nCurFmtType; nFuncFmtIndex = nCurFmtIndex; } +// Check for String overflow of rResult+rAdd and set error and erase rResult +// if so. Return TRUE if ok, FALSE if overflow +inline BOOL CheckStringResultLen( String& rResult, const String& rAdd ); +// Set error according to rVal, and set rVal to 0.0 if there was an error. +inline void TreatDoubleError( double& rVal ); +// Lookup using ScLookupCache, @returns TRUE if found and result address +bool LookupQueryWithCache( ScAddress & o_rResultPos, + const ScQueryParam & rParam ) const; + +//---------------------------------Funktionen in interpr1.cxx--------- +void ScIfJump(); +void ScChoseJump(); + +// Be sure to only call this if pStack[sp-nStackLevel] really contains a +// ScJumpMatrixToken, no further checks are applied! +// Returns true if last jump was executed and result matrix pushed. +bool JumpMatrix( short nStackLevel ); + +/** @param pOptions + NULL means case sensitivity document option is to be used! + */ +double CompareFunc( const ScCompare& rComp, ScCompareOptions* pOptions = NULL ); +double Compare(); +/** @param pOptions + NULL means case sensitivity document option is to be used! + */ +ScMatrixRef CompareMat( ScCompareOptions* pOptions = NULL ); +ScMatrixRef QueryMat( ScMatrix* pMat, ScCompareOptions& rOptions ); +void ScEqual(); +void ScNotEqual(); +void ScLess(); +void ScGreater(); +void ScLessEqual(); +void ScGreaterEqual(); +void ScAnd(); +void ScOr(); +void ScNot(); +void ScNeg(); +void ScPercentSign(); +void ScIntersect(); +void ScRangeFunc(); +void ScUnionFunc(); +void ScPi(); +void ScRandom(); +void ScTrue(); +void ScFalse(); +void ScDeg(); +void ScRad(); +void ScSin(); +void ScCos(); +void ScTan(); +void ScCot(); +void ScArcSin(); +void ScArcCos(); +void ScArcTan(); +void ScArcCot(); +void ScSinHyp(); +void ScCosHyp(); +void ScTanHyp(); +void ScCotHyp(); +void ScArcSinHyp(); +void ScArcCosHyp(); +void ScArcTanHyp(); +void ScArcCotHyp(); +void ScExp(); +void ScLn(); +void ScLog10(); +void ScSqrt(); +void ScIsEmpty(); +short IsString(); +void ScIsString(); +void ScIsNonString(); +void ScIsLogical(); +void ScType(); +void ScCell(); +void ScIsRef(); +void ScIsValue(); +void ScIsFormula(); +void ScFormula(); +void ScRoman(); +void ScArabic(); +void ScIsNV(); +void ScIsErr(); +void ScIsError(); +short IsEven(); +void ScIsEven(); +void ScIsOdd(); +void ScN(); +void ScCode(); +void ScTrim(); +void ScUpper(); +void ScPropper(); +void ScLower(); +void ScLen(); +void ScT(); +void ScValue(); +void ScClean(); +void ScChar(); +void ScJis(); +void ScAsc(); +void ScUnicode(); +void ScUnichar(); +void ScMin( BOOL bTextAsZero = FALSE ); +void ScMax( BOOL bTextAsZero = FALSE ); +double IterateParameters( ScIterFunc, BOOL bTextAsZero = FALSE ); +void ScSumSQ(); +void ScSum(); +void ScProduct(); +void ScAverage( BOOL bTextAsZero = FALSE ); +void ScCount(); +void ScCount2(); +void GetStVarParams( double& rVal, double& rValCount, BOOL bTextAsZero = FALSE ); +void ScVar( BOOL bTextAsZero = FALSE ); +void ScVarP( BOOL bTextAsZero = FALSE ); +void ScStDev( BOOL bTextAsZero = FALSE ); +void ScStDevP( BOOL bTextAsZero = FALSE ); +void ScColumns(); +void ScRows(); +void ScTables(); +void ScColumn(); +void ScRow(); +void ScTable(); +void ScMatch(); +void ScCountIf(); +void ScSumIf(); +void ScCountEmptyCells(); +void ScLookup(); +void ScHLookup(); +void ScVLookup(); +void ScSubTotal(); + +// If upon call rMissingField==TRUE then the database field parameter may be +// missing (Xcl DCOUNT() syntax), or may be faked as missing by having the +// value 0.0 or being exactly the entire database range reference (old SO +// compatibility). If this was the case then rMissingField is set to TRUE upon +// return. If rMissingField==FALSE upon call all "missing cases" are considered +// to be an error. +ScDBQueryParamBase* GetDBParams( BOOL& rMissingField ); + +void DBIterator( ScIterFunc ); +void ScDBSum(); +void ScDBCount(); +void ScDBCount2(); +void ScDBAverage(); +void ScDBGet(); +void ScDBMax(); +void ScDBMin(); +void ScDBProduct(); +void GetDBStVarParams( double& rVal, double& rValCount ); +void ScDBStdDev(); +void ScDBStdDevP(); +void ScDBVar(); +void ScDBVarP(); +void ScIndirect(); +void ScAddressFunc(); +void ScOffset(); +void ScIndex(); +void ScMultiArea(); +void ScAreas(); +void ScCurrency(); +void ScReplace(); +void ScFixed(); +void ScFind(); +void ScExact(); +void ScLeft(); +void ScRight(); +void ScSearch(); +void ScMid(); +void ScText(); +void ScSubstitute(); +void ScRept(); +void ScConcat(); +void ScExternal(); +void ScMissing(); +void ScMacro(); +BOOL SetSbxVariable( SbxVariable* pVar, const ScAddress& ); +BOOL SetSbxVariable( SbxVariable* pVar, SCCOL nCol, SCROW nRow, SCTAB nTab ); +void ScErrorType(); +void ScDBArea(); +void ScColRowNameAuto(); +void ScExternalRef(); +void ScGetPivotData(); +void ScHyperLink(); +void ScBahtText(); +void ScCalcTeam(); +void ScAnswer(); +void ScTTT(); +void ScSpewFunc(); +void ScGame(); + +//----------------Funktionen in interpr2.cxx--------------- + +/** Obtain the date serial number for a given date. + @param bStrict + If FALSE, nYear < 100 takes the two-digit year setting into account, + and rollover of invalid calendar dates takes place, e.g. 1999-02-31 => + 1999-03-03. + If TRUE, the date passed must be a valid Gregorian calendar date. No + two-digit expanding or rollover is done. + */ +double GetDateSerial( INT16 nYear, INT16 nMonth, INT16 nDay, bool bStrict ); + +void ScGetActDate(); +void ScGetActTime(); +void ScGetYear(); +void ScGetMonth(); +void ScGetDay(); +void ScGetDayOfWeek(); +void ScGetWeekOfYear(); +void ScEasterSunday(); +void ScGetHour(); +void ScGetMin(); +void ScGetSec(); +void ScPlusMinus(); +void ScAbs(); +void ScInt(); +void ScEven(); +void ScOdd(); +void ScCeil(); +void ScFloor(); +void RoundNumber( rtl_math_RoundingMode eMode ); +void ScRound(); +void ScRoundUp(); +void ScRoundDown(); +void ScGetDateValue(); +void ScGetTimeValue(); +void ScArcTan2(); +void ScLog(); +void ScGetDate(); +void ScGetTime(); +void ScGetDiffDate(); +void ScGetDiffDate360(); +void ScPower(); +void ScAmpersand(); +void ScAdd(); +void ScSub(); +void ScMul(); +void ScDiv(); +void ScPow(); +void ScCurrent(); +void ScStyle(); +void ScDde(); +void ScBase(); +void ScDecimal(); +void ScConvert(); +void ScEuroConvert(); + +//----------------------- Finanzfunktionen ------------------------------------ +void ScNPV(); +void ScIRR(); +void ScMIRR(); +void ScISPMT(); + +double ScGetBw(double fZins, double fZzr, double fRmz, + double fZw, double fF); +void ScBW(); +void ScDIA(); +double ScGetGDA(double fWert, double fRest, double fDauer, + double fPeriode, double fFaktor); +void ScGDA(); +void ScGDA2(); +double ScInterVDB(double fWert,double fRest,double fDauer,double fDauer1, + double fPeriode,double fFaktor); +void ScVDB(); +void ScLaufz(); +void ScLIA(); +double ScGetRmz(double fZins, double fZzr, double fBw, + double fZw, double fF); +void ScRMZ(); +void ScZGZ(); +double ScGetZw(double fZins, double fZzr, double fRmz, + double fBw, double fF); +void ScZW(); +void ScZZR(); +bool RateIteration(double fNper, double fPayment, double fPv, + double fFv, double fPayType, double& fGuess); +void ScZins(); +double ScGetZinsZ(double fZins, double fZr, double fZzr, double fBw, + double fZw, double fF, double& fRmz); +void ScZinsZ(); +void ScKapz(); +void ScKumZinsZ(); +void ScKumKapZ(); +void ScEffektiv(); +void ScNominal(); +void ScMod(); +void ScBackSolver(); +void ScIntercept(); +//-------------------------Funktionen in interpr5.cxx-------------------------- +double ScGetGCD(double fx, double fy); +void ScGCD(); +void ScLCM(); +//-------------------------- Matrixfunktionen --------------------------------- + +void ScMatValue(); +void MEMat(ScMatrix* mM, SCSIZE n); +void MFastMult(ScMatrix* pA, ScMatrix* pB, ScMatrix* pR, SCSIZE n, SCSIZE m, SCSIZE l); +void ScMatDet(); +void ScMatInv(); +void ScMatMult(); +void ScMatTrans(); +void ScEMat(); +void ScMatRef(); +ScMatrixRef MatConcat(ScMatrix* pMat1, ScMatrix* pMat2); +void ScSumProduct(); +void ScSumX2MY2(); +void ScSumX2DY2(); +void ScSumXMY2(); +void ScGrowth(); +// multiple Regression: Varianzen der Koeffizienten +BOOL RGetVariances( ScMatrix* pV, ScMatrix* pX, SCSIZE nC, SCSIZE nR, + BOOL bSwapColRow, BOOL bZeroConstant ); +void Calculate(ScMatrixRef& pResMat,ScMatrixRef& pE,ScMatrixRef& pQ,ScMatrixRef& pV,ScMatrixRef& pMatX,BOOL bConstant,SCSIZE N,SCSIZE M,BYTE nCase); +ScMatrixRef Calculate2(const BOOL bConstant,const SCSIZE M ,const SCSIZE N,ScMatrixRef& pMatX,ScMatrixRef& pMatY,BYTE nCase); +bool Calculate3(const SCSIZE M ,ScMatrixRef& pQ); +bool Calculate4(BOOL _bExp,ScMatrixRef& pResMat,ScMatrixRef& pQ,BOOL bConstant,SCSIZE N,SCSIZE M); +bool CalculateSkew(double& fSum,double& fCount,double& vSum,std::vector<double>& values); +void CalculateSlopeIntercept(BOOL bSlope); +void CalculateSmallLarge(BOOL bSmall); +void CalculatePearsonCovar(BOOL _bPearson,BOOL _bStexy); +bool CalculateTest( BOOL _bTemplin + ,const SCSIZE nC1, const SCSIZE nC2,const SCSIZE nR1,const SCSIZE nR2 + ,const ScMatrixRef& pMat1,const ScMatrixRef& pMat2 + ,double& fT,double& fF); +void CalculateLookup(BOOL HLookup); +bool FillEntry(ScQueryEntry& rEntry); +void CalculateAddSub(BOOL _bSub); +void CalculateTrendGrowth(BOOL _bGrowth); +void CalulateRGPRKP(BOOL _bRKP); +void CalculateSumX2MY2SumX2DY2(BOOL _bSumX2DY2); +void CalculateMatrixValue(const ScMatrix* pMat,SCSIZE nC,SCSIZE nR); +bool CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE& nCX,SCSIZE& nCY,SCSIZE& nRX,SCSIZE& nRY,SCSIZE& M,SCSIZE& N,ScMatrixRef& pMatX,ScMatrixRef& pMatY); + +void ScRGP(); +void ScRKP(); +void ScForecast(); +//------------------------- Functions in interpr3.cxx ------------------------- +void ScNoName(); +void ScBadName(); +// Statistik: +double phi(double x); +double integralPhi(double x); +double taylor(double* pPolynom, USHORT nMax, double x); +double gauss(double x); +double gaussinv(double x); +double GetBetaDist(double x, double alpha, double beta); //cumulative distribution function +double GetBetaDistPDF(double fX, double fA, double fB); //probability density function) +double GetChiDist(double fChi, double fDF); // for LEGACY.CHIDIST, returns right tail +double GetChiSqDistCDF(double fX, double fDF); // for CHISQDIST, returns left tail +double GetChiSqDistPDF(double fX, double fDF); // probability density function +double GetFDist(double x, double fF1, double fF2); +double GetTDist(double T, double fDF); +double Fakultaet(double x); +double BinomKoeff(double n, double k); +double GetGamma(double x); +double GetLogGamma(double x); +double GetBeta(double fAlpha, double fBeta); +double GetLogBeta(double fAlpha, double fBeta); +void ScLogGamma(); +void ScGamma(); +void ScPhi(); +void ScGauss(); +void ScStdNormDist(); +void ScFisher(); +void ScFisherInv(); +void ScFact(); +void ScNormDist(); +void ScGammaDist(); +void ScGammaInv(); +void ScExpDist(); +void ScBinomDist(); +void ScPoissonDist(); +void ScKombin(); +void ScKombin2(); +void ScVariationen(); +void ScVariationen2(); +void ScB(); +void ScHypGeomDist(); +void ScLogNormDist(); +void ScLogNormInv(); +void ScTDist(); +void ScFDist(); +void ScChiDist(); // for LEGACY.CHIDIST, returns right tail +void ScChiSqDist(); // returns left tail or density +void ScChiSqInv(); //invers to CHISQDIST +void ScWeibull(); +void ScBetaDist(); +void ScFInv(); +void ScTInv(); +void ScChiInv(); +void ScBetaInv(); +void ScCritBinom(); +void ScNegBinomDist(); +void ScKurt(); +void ScHarMean(); +void ScGeoMean(); +void ScStandard(); +void ScSkew(); +void ScMedian(); +double GetMedian( ::std::vector<double> & rArray ); +double GetPercentile( ::std::vector<double> & rArray, double fPercentile ); +void GetNumberSequenceArray( BYTE nParamCount, ::std::vector<double>& rArray ); +void GetSortArray(BYTE nParamCount, ::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder = NULL); +void QuickSort(::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder = NULL); +void ScModalValue(); +void ScAveDev(); +void ScDevSq(); +void ScZTest(); +void ScTTest(); +void ScFTest(); +void ScChiTest(); +void ScRank(); +void ScPercentile(); +void ScPercentrank(); +void ScLarge(); +void ScSmall(); +void ScFrequency(); +void ScQuartile(); +void ScNormInv(); +void ScSNormInv(); +void ScConfidence(); +void ScTrimMean(); +void ScProbability(); +void ScCorrel(); +void ScCovar(); +void ScPearson(); +void ScRSQ(); +void ScSTEXY(); +void ScSlope(); +void ScTrend(); +void ScInfo(); + +//------------------------ Functions in interpr6.cxx ------------------------- + +static const double fMaxGammaArgument; // defined in interpr3.cxx + +double GetGammaContFraction(double fA,double fX); +double GetGammaSeries(double fA,double fX); +double GetLowRegIGamma(double fA,double fX); // lower regularized incomplete gamma function, GAMMAQ +double GetUpRegIGamma(double fA,double fX); // upper regularized incomplete gamma function, GAMMAP +// probability density function; fLambda is "scale" parameter +double GetGammaDistPDF(double fX, double fAlpha, double fLambda); +// cumulative distribution function; fLambda is "scale" parameter +double GetGammaDist(double fX, double fAlpha, double fLambda); + +//---------------------------------------------------------------------------- +public: + ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, + const ScAddress&, ScTokenArray& ); + ~ScInterpreter(); + + formula::StackVar Interpret(); + + void SetError(USHORT nError) + { if (nError && !nGlobalError) nGlobalError = nError; } + + USHORT GetError() const { return nGlobalError; } + formula::StackVar GetResultType() const { return xResult->GetType(); } + const String& GetStringResult() const { return xResult->GetString(); } + double GetNumResult() const { return xResult->GetDouble(); } + formula::FormulaTokenRef + GetResultToken() const { return xResult; } + short GetRetFormatType() const { return nRetFmtType; } + ULONG GetRetFormatIndex() const { return nRetFmtIndex; } +}; + + +inline void ScInterpreter::MatrixDoubleRefToMatrix() +{ + if ( bMatrixFormula && GetStackType() == formula::svDoubleRef ) + { + GetTokenMatrixMap(); // make sure it exists, create if not. + PopDoubleRefPushMatrix(); + } +} + + +inline bool ScInterpreter::MatrixParameterConversion() +{ + if ( (bMatrixFormula || pCur->HasForceArray()) && !pJumpMatrix && sp > 0 ) + return ConvertMatrixParameters(); + return false; +} + + +inline ScTokenMatrixMap& ScInterpreter::GetTokenMatrixMap() +{ + if (!pTokenMatrixMap) + pTokenMatrixMap = CreateTokenMatrixMap(); + return *pTokenMatrixMap; +} + + +inline BOOL ScInterpreter::MustHaveParamCount( short nAct, short nMust ) +{ + if ( nAct == nMust ) + return TRUE; + if ( nAct < nMust ) + PushParameterExpected(); + else + PushIllegalParameter(); + return FALSE; +} + + +inline BOOL ScInterpreter::MustHaveParamCount( short nAct, short nMust, short nMax ) +{ + if ( nMust <= nAct && nAct <= nMax ) + return TRUE; + if ( nAct < nMust ) + PushParameterExpected(); + else + PushIllegalParameter(); + return FALSE; +} + + +inline BOOL ScInterpreter::MustHaveParamCountMin( short nAct, short nMin ) +{ + if ( nAct >= nMin ) + return TRUE; + PushParameterExpected(); + return FALSE; +} + + +inline BOOL ScInterpreter::CheckStringResultLen( String& rResult, const String& rAdd ) +{ + if ( (ULONG) rResult.Len() + rAdd.Len() > STRING_MAXLEN ) + { + SetError( errStringOverflow ); + rResult.Erase(); + return FALSE; + } + return TRUE; +} + + +inline void ScInterpreter::TreatDoubleError( double& rVal ) +{ + if ( !::rtl::math::isFinite( rVal ) ) + { + USHORT nErr = GetDoubleErrorValue( rVal ); + if ( nErr ) + SetError( nErr ); + else + SetError( errNoValue ); + rVal = 0.0; + } +} + + +// static +inline double ScInterpreter::div( const double& fNumerator, const double& fDenominator ) +{ + return (fDenominator != 0.0) ? (fNumerator / fDenominator) : + CreateDoubleError( errDivisionByZero); +} + +#endif diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx new file mode 100644 index 000000000000..8089d6653730 --- /dev/null +++ b/sc/source/core/inc/jumpmatrix.hxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_JUMPMATRIX_HXX +#define SC_JUMPMATRIX_HXX + +#include "formula/token.hxx" +#include "formula/errorcodes.hxx" +#include <tools/solar.h> +#include <vector> +#include "scmatrix.hxx" + +typedef ::std::vector< formula::FormulaToken*> ScTokenVec; + +struct ScJumpMatrixEntry +{ + double fBool; // 0:= false 1:= true also if no-path + // other values may contain error conditions like NAN and INF + short nStart; // start of path (actually start-1, see formula::FormulaTokenIterator) + short nNext; // next after path + // jump path exists if nStart != nNext, else no path + short nStop; // optional stop of path (nPC < nStop) + + void SetJump( double fBoolP, short nStartP, short nNextP, short nStopP ) + { + fBool = fBoolP; + nStart = nStartP; + nNext = nNextP; + nStop = nStopP; + } + void GetJump( double& rBool, short& rStart, short& rNext, short& rStop ) + { + rBool = fBool; + rStart = nStart; + rNext = nNext; + rStop = nStop; + } +}; + +class ScJumpMatrix +{ + ScJumpMatrixEntry* pJump; // the jumps + ScMatrixRef pMat; // the results + ScTokenVec* pParams; // parameter stack + SCSIZE nCols; + SCSIZE nRows; + SCSIZE nCurCol; + SCSIZE nCurRow; + SCSIZE nResMatCols; + SCSIZE nResMatRows; + bool bStarted; + + // not implemented, prevent usage + ScJumpMatrix( const ScJumpMatrix& ); + ScJumpMatrix& operator=( const ScJumpMatrix& ); + +public: + ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP ) + : pJump( new ScJumpMatrixEntry[ nColsP * nRowsP ] ) + , pMat( new ScMatrix( nColsP, nRowsP) ) + , pParams( NULL ) + , nCols( nColsP ) + , nRows( nRowsP ) + , nCurCol( 0 ) + , nCurRow( 0 ) + , nResMatCols( nColsP ) + , nResMatRows( nRowsP ) + , bStarted( false ) + { + // Initialize result matrix in case of + // a premature end of the interpreter + // due to errors. + pMat->FillDouble( CreateDoubleError( + NOTAVAILABLE), 0, 0, nCols-1, + nRows-1); + /*! pJump not initialized */ + } + ~ScJumpMatrix() + { + if ( pParams ) + { + for ( ScTokenVec::iterator i = + pParams->begin(); i != + pParams->end(); ++i ) + { + (*i)->DecRef(); + } + delete pParams; + } + delete [] pJump; + } + void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const + { + rCols = nCols; + rRows = nRows; + } + void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, + short nStart, short nNext, + short nStop = SHRT_MAX ) + { + pJump[ (ULONG)nCol * nRows + nRow ]. + SetJump( fBool, nStart, nNext, nStop); + } + void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, + short& rStart, short& rNext, + short& rStop ) const + { + if (nCols == 1 && nRows == 1) + { + nCol = 0; + nRow = 0; + } + else if (nCols == 1 && nRow < nRows) + nCol = 0; + else if (nRows == 1 && nCol < nCols) + nRow = 0; + else if (nCols <= nCol || nRows <= nRow) + { + DBG_ERROR("ScJumpMatrix::GetJump: dimension error"); + nCol = 0; + nRow = 0; + } + pJump[ (ULONG)nCol * nRows + nRow ]. + GetJump( rBool, rStart, rNext, rStop); + } + void SetAllJumps( double fBool, + short nStart, short nNext, + short nStop = SHRT_MAX ) + { + ULONG n = (ULONG)nCols * nRows; + for ( ULONG j=0; j<n; ++j ) + { + pJump[ j ].SetJump( fBool, nStart, + nNext, nStop); + } + } + void SetJumpParameters( ScTokenVec* p ) + { pParams = p; } + const ScTokenVec* GetJumpParameters() const { return pParams; } + ScMatrix* GetResultMatrix() const { return pMat; } + void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const + { + rCol = nCurCol; + rRow = nCurRow; + } + bool Next( SCSIZE& rCol, SCSIZE& rRow ) + { + if ( !bStarted ) + { + bStarted = true; + nCurCol = nCurRow = 0; + } + else + { + if ( ++nCurRow >= nResMatRows ) + { + nCurRow = 0; + ++nCurCol; + } + } + GetPos( rCol, rRow ); + return nCurCol < nResMatCols; + } + void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows ) + { + rCols = nResMatCols; + rRows = nResMatRows; + } + void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows ) + { + if ( nNewCols > nResMatCols || nNewRows > nResMatRows ) + { + pMat = pMat->CloneAndExtend( nNewCols, nNewRows ); + if ( nResMatCols < nNewCols ) + { + pMat->FillDouble( CreateDoubleError( + NOTAVAILABLE), nResMatCols, 0, nNewCols-1, + nResMatRows-1); + } + if ( nResMatRows < nNewRows ) + { + pMat->FillDouble( CreateDoubleError( + NOTAVAILABLE), 0, nResMatRows, nNewCols-1, + nNewRows-1); + } + if ( nRows == 1 && nCurCol != 0 ) + { + nCurCol = 0; + nCurRow = nResMatRows - 1; + } + nResMatCols = nNewCols; + nResMatRows = nNewRows; + } + } +}; + +#endif // SC_JUMPMATRIX_HXX + diff --git a/sc/source/core/inc/makefile.mk b/sc/source/core/inc/makefile.mk new file mode 100644 index 000000000000..1b35ca49549d --- /dev/null +++ b/sc/source/core/inc/makefile.mk @@ -0,0 +1,26 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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. +# +#************************************************************************* diff --git a/sc/source/core/inc/parclass.hxx b/sc/source/core/inc/parclass.hxx new file mode 100644 index 000000000000..39844de7ae22 --- /dev/null +++ b/sc/source/core/inc/parclass.hxx @@ -0,0 +1,180 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_PARCLASS_HXX +#define SC_PARCLASS_HXX + +#include "formula/opcode.hxx" +#include <sys/types.h> // size_t + +namespace formula +{ + class FormulaToken; +} + +class ScParameterClassification +{ +public: + + enum Type + { + Unknown = 0, // MUST be zero for initialization mechanism! + + /** Out of bounds, function doesn't expect that many parameters. + However, not necessarily returned. */ + Bounds, + + /** In array formula: single value to be passed. Results in JumpMatrix + being created and multiple calls to function. Functions handling a + formula::svDoubleRef by means of DoubleRefToPosSingleRef() or + PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have + this. */ + Value, + + /** In array formula: area reference must stay reference. Otherwise + don't care. Functions handling a formula::svDoubleRef by means of + PopDoubleRefOrSingleRef() should not have this. */ + Reference, + + /** In array formula: convert area reference to array. Function will be + called only once if no Value type is involved. Functions able to + handle a svMatrix parameter but not a formula::svDoubleRef parameter as area + should have this. */ + Array, + + /** Area reference must be converted to array in any case, and must + also be propagated to subsequent operators and functions being part + of a parameter of this function. */ + ForceArray, + + /** Area reference is not converted to array, but ForceArray must be + propagated to subsequent operators and functions being part of a + parameter of this function. Used with functions that treat + references separately from arrays, but need the forced array + calculation of parameters that are not references.*/ + ReferenceOrForceArray + }; + + /// MUST be called once before any other method. + static void Init(); + + static void Exit(); + + /** Get one parameter type for function eOp. + @param nParameter + Which parameter, 0-based */ + static Type GetParameterType( const formula::FormulaToken* pToken, + USHORT nParameter); + + /** Whether OpCode has a parameter of type + ForceArray or ReferenceOrForceArray. */ + static inline bool HasForceArray( OpCode eOp) + { + return 0 <= (short)eOp && + eOp <= SC_OPCODE_LAST_OPCODE_ID && + pData[eOp].bHasForceArray; + } + +private: + + struct CommonData + { + const static size_t nMaxParams = 7; + + Type nParam[nMaxParams]; + bool bRepeatLast; + }; + + // SUNWS7 needs a forward declared friend, otherwise members of the outer + // class are not accessible (in this case CommonData). + struct RawData; + friend struct ScParameterClassification::RawData; + struct RawData + { + OpCode eOp; + CommonData aData; + }; + + struct RunData; + friend struct ScParameterClassification::RunData; + struct RunData + { + CommonData aData; + BYTE nMinParams; // fix or minimum, or repeat start + bool bHasForceArray; + }; + + static const RawData pRawData[]; + static RunData* pData; + + // ocExternal AddIns + static Type GetExternalParameterType( + const formula::FormulaToken* pToken, USHORT nParameter); + +#if OSL_DEBUG_LEVEL > 1 + // Generate documentation to stdout if environment variable + // OOO_CALC_GENPARCLASSDOC is set. + static void GenerateDocumentation(); + + /* OpCodes not specified in the implementation are taken from the global + * function list and all parameters, if any, are assumed to be of type + * Value. This could also be done in the product version if needed, but we + * don't want to spoil startup time. However, doing so could propagate the + * minimum parameter count to the formula compiler, which, together with + * additional information about optional parameters, could react on missing + * parameters then. */ + static void MergeArgumentsFromFunctionResource(); + + /** Minimum number of parameters, or fix number + of parameters if HasRepeatParameters() + returns FALSE. For opcodes not specified in + the implementation a parameter count of 1 + is assumed, for opcodes out of range 0 is + assumed. If HasRepeatParameters() returns + TRUE, information is NOT related to whether + any parameters are optional, only the type + of parameters is significant. */ + static inline BYTE GetMinimumParameters( OpCode eOp) + { + if ( eOp <= SC_OPCODE_LAST_OPCODE_ID ) + return pData[eOp].aData.nParam[0] + == Unknown ? 1 : + pData[eOp].nMinParams; + return 0; + } + + /** Whether last parameter type is repeated. */ + static inline bool HasRepeatParameters( OpCode eOp) + { + return eOp <= SC_OPCODE_LAST_OPCODE_ID + && pData[eOp].aData.bRepeatLast; + } +#endif // OSL_DEBUG_LEVEL +}; + +#endif // SC_PARCLASS_HXX + diff --git a/sc/source/core/inc/poolhelp.hxx b/sc/source/core/inc/poolhelp.hxx new file mode 100644 index 000000000000..f98963513c59 --- /dev/null +++ b/sc/source/core/inc/poolhelp.hxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_POOLHELP_HXX +#define SC_POOLHELP_HXX + +#include <rtl/ref.hxx> +#include <vos/refernce.hxx> +#include <tools/link.hxx> +#include "docoptio.hxx" + +class ScDocument; +class ScDocumentPool; +class ScStyleSheetPool; +class SvNumberFormatter; +class SfxItemPool; + + +class ScPoolHelper : public vos::OReference +{ +private: + ScDocOptions aOpt; + ScDocumentPool* pDocPool; + rtl::Reference< ScStyleSheetPool > mxStylePool; + mutable SvNumberFormatter* pFormTable; + mutable SfxItemPool* pEditPool; // EditTextObjectPool + mutable SfxItemPool* pEnginePool; // EditEnginePool + ScDocument* m_pSourceDoc; + + void UseDocOptions() const; + +public: + ScPoolHelper( ScDocument* pSourceDoc ); + virtual ~ScPoolHelper(); + + // called in dtor of main document + void SourceDocumentGone(); + + // access to pointers (are never 0): + ScDocumentPool* GetDocPool() const { return pDocPool; } + ScStyleSheetPool* GetStylePool() const { return mxStylePool.get(); } + SvNumberFormatter* GetFormTable() const; + SfxItemPool* GetEditPool() const; + SfxItemPool* GetEnginePool() const; + + void SetFormTableOpt(const ScDocOptions& rOpt); +}; + +#endif + diff --git a/sc/source/core/inc/refupdat.hxx b/sc/source/core/inc/refupdat.hxx new file mode 100644 index 000000000000..17da3bf5e635 --- /dev/null +++ b/sc/source/core/inc/refupdat.hxx @@ -0,0 +1,100 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_REFUPDAT_HXX +#define SC_REFUPDAT_HXX + +#include "global.hxx" + +class ScDocument; +class ScBigRange; +struct ScComplexRefData; +class ScAddress; +class ScRange; + +enum ScRefUpdateRes { + UR_NOTHING = 0, // keine Anpassungen + UR_UPDATED = 1, // Anpassungen erfolgt + UR_INVALID = 2 // Referenz wurde ungueltig +}; + +class ScRefUpdate +{ +public: + + /// What type of reference is to be updated. + enum WhatType + { + ALL, /// all references + ABSOLUTE /// only absolute references + }; + + static ScRefUpdateRes Update + ( ScDocument* pDoc, UpdateRefMode eUpdateRefMode, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz, + SCCOL& theCol1, SCROW& theRow1, SCTAB& theTab1, + SCCOL& theCol2, SCROW& theRow2, SCTAB& theTab2 ); + + static ScRefUpdateRes Update( UpdateRefMode eUpdateRefMode, + const ScBigRange& rWhere, + INT32 nDx, INT32 nDy, INT32 nDz, + ScBigRange& rWhat ); + + /// Before calling, the absolute references must be up-to-date! + static ScRefUpdateRes Update( ScDocument* pDoc, + UpdateRefMode eUpdateRefMode, + const ScAddress& rPos, const ScRange& rRange, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz, + ScComplexRefData& rRef, WhatType eWhat = ALL ); + + /// Before calling, the absolute references must be up-to-date! + static ScRefUpdateRes Move( ScDocument* pDoc, const ScAddress& rPos, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz, + ScComplexRefData& rRef, BOOL bWrap, BOOL bAbsolute ); + + static void MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos, + SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef ); + + /// Before calling, the absolute references must be up-to-date! + static ScRefUpdateRes UpdateTranspose( ScDocument* pDoc, + const ScRange& rSource, const ScAddress& rDest, + ScComplexRefData& rRef ); + + static void DoTranspose( SCsCOL& rCol, SCsROW& rRow, SCsTAB& rTab, ScDocument* pDoc, + const ScRange& rSource, const ScAddress& rDest ); + + /// Before calling, the absolute references must be up-to-date! + static ScRefUpdateRes UpdateGrow( + const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY, + ScComplexRefData& rRef ); +}; + + +#endif + diff --git a/sc/source/core/inc/scrdata.hxx b/sc/source/core/inc/scrdata.hxx new file mode 100644 index 000000000000..b569bddddd6b --- /dev/null +++ b/sc/source/core/inc/scrdata.hxx @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_SCRDATA_HXX +#define SC_SCRDATA_HXX + +#include <com/sun/star/uno/Reference.hxx> + +namespace com { namespace sun { namespace star { namespace i18n { + class XBreakIterator; +} } } } + + +class ScScriptTypeData +{ +public: + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIter; + + ScScriptTypeData() {} + ~ScScriptTypeData() {} +}; + +#endif + + diff --git a/sc/source/core/inc/sctictac.hxx b/sc/source/core/inc/sctictac.hxx new file mode 100644 index 000000000000..1c8242150369 --- /dev/null +++ b/sc/source/core/inc/sctictac.hxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_SCTICTAC_HXX +#define SC_SCTICTAC_HXX + +//#define TICTACTOE_MAIN +#ifdef TICTACTOE_MAIN +#define TICTACTOE_STDOUT +#else +//#define TICTACTOE_STDOUT +#endif +#ifndef TICTACTOE_STDOUT +#define TICTACTOE_SC +#endif + +#ifdef TICTACTOE_SC +class ScDocument; +#include "global.hxx" +#include "address.hxx" +#else +#include <tools/string.hxx> +#endif + +static const int ScTicTacToe_Squares = 9; +static const int ScTicTacToe_Possible_Wins = 8; +typedef sal_Unicode Square_Type; +typedef Square_Type Board_Type[ScTicTacToe_Squares]; + +class ScTicTacToe +{ +private: + /* Structure to hold a move and its heuristic */ + typedef struct { + int Square; + int Heuristic; + } Move_Heuristic_Type; + + static const Square_Type Empty; + static const Square_Type Human; + static const Square_Type Compi; + static const int Infinity; /* Higher value than any score */ + static const int Maximum_Moves; /* Maximum moves in a game */ + + Board_Type Board; +#ifdef TICTACTOE_SC + ScAddress aPos; // linke obere Ecke des Boards + ScDocument* pDoc; +#endif + ByteString aStdOut; + int Total_Nodes; /* Nodes searched with minimax */ + int nMove; + Square_Type aPlayer; + BOOL bInitialized; + + /* Array describing the eight combinations of three squares in a row */ + static const int Three_in_a_Row[ScTicTacToe_Possible_Wins][3]; + + /* Array used in heuristic formula for each move. */ + static const int Heuristic_Array[4][4]; + + + Square_Type Winner(); + inline Square_Type Other( Square_Type Player ); + inline void Play( int Square, Square_Type Player ); + int Evaluate( Square_Type Player ); + int BestMove( Square_Type Player, int *Square, + int Move_Nbr, int Alpha, int Beta ); + void Describe( int Score ); + void Move( int& Square ); + Square_Type TryMove( int& Square ); // return Winner() + void PromptHuman(); +#ifdef TICTACTOE_SC + // -1 == Fehler/Redraw, 0 == keine Aenderung, >0 == UserMoveSquare+1 + int GetStatus(); + void DrawBoard(); + void DrawPos( int nSquare, const String& rStr ); +#endif +#ifdef TICTACTOE_STDOUT + void Print(); +#endif + + ScTicTacToe( const ScTicTacToe& ); + ScTicTacToe& operator=( const ScTicTacToe& ); + +public: +#ifdef TICTACTOE_SC + ScTicTacToe( ScDocument* pDoc, const ScAddress& ); +#else + ScTicTacToe(); +#endif + ~ScTicTacToe() {} + void Initialize( BOOL bHumanFirst ); + Square_Type GetEmpty() { return Empty; } +#ifdef TICTACTOE_SC + Square_Type CalcMove(); // return Winner() +#endif +#ifdef TICTACTOE_STDOUT + void Game(); + void GetOutput( ByteString& rStr ); +#else + void GetOutput( String& rStr ); +#endif +}; + +#endif + |