1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_CELL_HXX 25cdf0e10cSrcweir #define SC_CELL_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <stddef.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <set> 30cdf0e10cSrcweir #include <tools/mempool.hxx> 31cdf0e10cSrcweir #include <svl/listener.hxx> 32cdf0e10cSrcweir #include "global.hxx" 33cdf0e10cSrcweir #include "rangenam.hxx" 34cdf0e10cSrcweir #include "formula/grammar.hxx" 35cdf0e10cSrcweir #include "tokenarray.hxx" 36cdf0e10cSrcweir #include "formularesult.hxx" 37cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 38cdf0e10cSrcweir #include <unotools/fontcvt.hxx> 39cdf0e10cSrcweir #include "scdllapi.h" 40cdf0e10cSrcweir 41cdf0e10cSrcweir #define USE_MEMPOOL 42cdf0e10cSrcweir #define TEXTWIDTH_DIRTY 0xffff 43cdf0e10cSrcweir 44cdf0e10cSrcweir // in addition to SCRIPTTYPE_... flags from scripttypeitem.hxx: 45cdf0e10cSrcweir // set (in nScriptType) if type has not been determined yet 46cdf0e10cSrcweir #define SC_SCRIPTTYPE_UNKNOWN 0x08 47cdf0e10cSrcweir 48cdf0e10cSrcweir class ScDocument; 49cdf0e10cSrcweir class EditTextObject; 50cdf0e10cSrcweir class ScMatrix; 51cdf0e10cSrcweir class SvtBroadcaster; 52cdf0e10cSrcweir class ScCodeArray; 53cdf0e10cSrcweir class ScProgress; 54cdf0e10cSrcweir class ScPostIt; 55cdf0e10cSrcweir 56cdf0e10cSrcweir // ============================================================================ 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** Default cell clone flags: do not start listening, do not adjust 3D refs to 59cdf0e10cSrcweir old position, clone note captions of cell notes. */ 60cdf0e10cSrcweir const int SC_CLONECELL_DEFAULT = 0x0000; 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** If set, cloned formula cells will start to listen to the document. */ 63cdf0e10cSrcweir const int SC_CLONECELL_STARTLISTENING = 0x0001; 64cdf0e10cSrcweir 65cdf0e10cSrcweir /** If set, relative 3D references of cloned formula cells will be adjusted to 66cdf0e10cSrcweir old position (used while swapping cells for sorting a cell range). */ 67cdf0e10cSrcweir const int SC_CLONECELL_ADJUST3DREL = 0x0002; 68cdf0e10cSrcweir 69cdf0e10cSrcweir /** If set, the caption object of a cell note will not be cloned (used while 70cdf0e10cSrcweir copying cells to undo document, where captions are handled in drawing undo). */ 71cdf0e10cSrcweir const int SC_CLONECELL_NOCAPTION = 0x0004; 72cdf0e10cSrcweir 73cdf0e10cSrcweir // ============================================================================ 74cdf0e10cSrcweir 75cdf0e10cSrcweir class SC_DLLPUBLIC ScBaseCell 76cdf0e10cSrcweir { 77cdf0e10cSrcweir protected: 78cdf0e10cSrcweir ~ScBaseCell(); // nicht virtuell -> darf nicht direkt aufgerufen werden 79cdf0e10cSrcweir 80cdf0e10cSrcweir public: 81cdf0e10cSrcweir explicit ScBaseCell( CellType eNewType ); 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Base copy constructor. Does NOT clone cell note or broadcaster! */ 84cdf0e10cSrcweir ScBaseCell( const ScBaseCell& rCell ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir /** Returns a clone of this cell at the same position, cell note and 87cdf0e10cSrcweir broadcaster will not be cloned. */ 88cdf0e10cSrcweir ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** Returns a clone of this cell for the passed document position, cell 91cdf0e10cSrcweir note and broadcaster will not be cloned. */ 92cdf0e10cSrcweir ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; 93cdf0e10cSrcweir 94cdf0e10cSrcweir /** Returns a clone of this cell, clones cell note and caption object too 95cdf0e10cSrcweir (unless SC_CLONECELL_NOCAPTION flag is set). Broadcaster will not be cloned. */ 96cdf0e10cSrcweir ScBaseCell* CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; 97cdf0e10cSrcweir 98cdf0e10cSrcweir /** Due to the fact that ScBaseCell does not have a vtable, this function 99cdf0e10cSrcweir deletes the cell by calling the appropriate d'tor of the derived class. */ 100cdf0e10cSrcweir void Delete(); 101cdf0e10cSrcweir 102cdf0e10cSrcweir inline CellType GetCellType() const { return (CellType)eCellType; } 103cdf0e10cSrcweir 104cdf0e10cSrcweir /** Returns true, if the cell is empty (neither value nor formula nor cell note). 105cdf0e10cSrcweir Returns false for formula cells returning nothing, use HasEmptyData() for that. */ 106cdf0e10cSrcweir bool IsBlank( bool bIgnoreNotes = false ) const; 107cdf0e10cSrcweir 108cdf0e10cSrcweir // fuer Idle-Berechnung 109cdf0e10cSrcweir inline sal_uInt16 GetTextWidth() const { return nTextWidth; } 110cdf0e10cSrcweir inline void SetTextWidth( sal_uInt16 nNew ) { nTextWidth = nNew; } 111cdf0e10cSrcweir 112cdf0e10cSrcweir inline sal_uInt8 GetScriptType() const { return nScriptType; } 113cdf0e10cSrcweir inline void SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; } 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** Returns true, if the cell contains a note. */ 116cdf0e10cSrcweir inline bool HasNote() const { return mpNote != 0; } 117cdf0e10cSrcweir /** Returns the pointer to a cell note object (read-only). */ 118cdf0e10cSrcweir inline const ScPostIt* GetNote() const { return mpNote; } 119cdf0e10cSrcweir /** Returns the pointer to a cell note object. */ 120cdf0e10cSrcweir inline ScPostIt* GetNote() { return mpNote; } 121cdf0e10cSrcweir /** Takes ownership of the passed cell note object. */ 122cdf0e10cSrcweir void TakeNote( ScPostIt* pNote ); 123cdf0e10cSrcweir /** Returns and forgets the own cell note object. Caller takes ownership! */ 124cdf0e10cSrcweir ScPostIt* ReleaseNote(); 125cdf0e10cSrcweir /** Deletes the own cell note object. */ 126cdf0e10cSrcweir void DeleteNote(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir /** Returns true, if the cell contains a broadcaster. */ 129cdf0e10cSrcweir inline bool HasBroadcaster() const { return mpBroadcaster != 0; } 130cdf0e10cSrcweir /** Returns the pointer to the cell broadcaster. */ 131cdf0e10cSrcweir inline SvtBroadcaster* GetBroadcaster() const { return mpBroadcaster; } 132cdf0e10cSrcweir /** Takes ownership of the passed cell broadcaster. */ 133cdf0e10cSrcweir void TakeBroadcaster( SvtBroadcaster* pBroadcaster ); 134cdf0e10cSrcweir /** Returns and forgets the own cell broadcaster. Caller takes ownership! */ 135cdf0e10cSrcweir SvtBroadcaster* ReleaseBroadcaster(); 136cdf0e10cSrcweir /** Deletes the own cell broadcaster. */ 137cdf0e10cSrcweir void DeleteBroadcaster(); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // String- oder EditCell 140cdf0e10cSrcweir static ScBaseCell* CreateTextCell( const String& rString, ScDocument* ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // nOnlyNames may be one or more of SC_LISTENING_NAMES_* 143cdf0e10cSrcweir void StartListeningTo( ScDocument* pDoc ); 144cdf0e10cSrcweir void EndListeningTo( ScDocument* pDoc, 145cdf0e10cSrcweir ScTokenArray* pArr = NULL, 146cdf0e10cSrcweir ScAddress aPos = ScAddress() ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir /** Error code if ScFormulaCell, else 0. */ 149cdf0e10cSrcweir sal_uInt16 GetErrorCode() const; 150cdf0e10cSrcweir /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been 151cdf0e10cSrcweir created due to reference to empty cell). */ 152cdf0e10cSrcweir sal_Bool HasEmptyData() const; 153cdf0e10cSrcweir sal_Bool HasValueData() const; 154cdf0e10cSrcweir sal_Bool HasStringData() const; 155cdf0e10cSrcweir String GetStringData() const; // nur echte Strings 156cdf0e10cSrcweir 157cdf0e10cSrcweir static sal_Bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ); 158cdf0e10cSrcweir 159cdf0e10cSrcweir private: 160cdf0e10cSrcweir ScBaseCell& operator=( const ScBaseCell& ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir private: 163cdf0e10cSrcweir ScPostIt* mpNote; /// The cell note. Cell takes ownership! 164cdf0e10cSrcweir SvtBroadcaster* mpBroadcaster; /// Broadcaster for changed values. Cell takes ownership! 165cdf0e10cSrcweir 166cdf0e10cSrcweir protected: 167cdf0e10cSrcweir sal_uInt16 nTextWidth; 168cdf0e10cSrcweir sal_uInt8 eCellType; // enum CellType - sal_uInt8 spart Speicher 169cdf0e10cSrcweir sal_uInt8 nScriptType; 170cdf0e10cSrcweir }; 171cdf0e10cSrcweir 172cdf0e10cSrcweir // ============================================================================ 173cdf0e10cSrcweir 174cdf0e10cSrcweir class SC_DLLPUBLIC ScNoteCell : public ScBaseCell 175cdf0e10cSrcweir { 176cdf0e10cSrcweir public: 177cdf0e10cSrcweir #ifdef USE_MEMPOOL 178cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) 179cdf0e10cSrcweir #endif 180cdf0e10cSrcweir 181cdf0e10cSrcweir /** Cell takes ownership of the passed broadcaster. */ 182cdf0e10cSrcweir explicit ScNoteCell( SvtBroadcaster* pBC = 0 ); 183cdf0e10cSrcweir /** Cell takes ownership of the passed note and broadcaster. */ 184cdf0e10cSrcweir explicit ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC = 0 ); 185cdf0e10cSrcweir 186cdf0e10cSrcweir #ifdef DBG_UTIL 187cdf0e10cSrcweir ~ScNoteCell(); 188cdf0e10cSrcweir #endif 189cdf0e10cSrcweir 190cdf0e10cSrcweir private: 191cdf0e10cSrcweir ScNoteCell( const ScNoteCell& ); 192cdf0e10cSrcweir }; 193cdf0e10cSrcweir 194cdf0e10cSrcweir // ============================================================================ 195cdf0e10cSrcweir 196cdf0e10cSrcweir class SC_DLLPUBLIC ScValueCell : public ScBaseCell 197cdf0e10cSrcweir { 198cdf0e10cSrcweir public: 199cdf0e10cSrcweir #ifdef USE_MEMPOOL 200cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScValueCell ) 201cdf0e10cSrcweir #endif 202cdf0e10cSrcweir ScValueCell(); 203cdf0e10cSrcweir explicit ScValueCell( double fValue ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir #ifdef DBG_UTIL 206cdf0e10cSrcweir ~ScValueCell(); 207cdf0e10cSrcweir #endif 208cdf0e10cSrcweir 209cdf0e10cSrcweir inline void SetValue( double fValue ) { mfValue = fValue; } 210cdf0e10cSrcweir inline double GetValue() const { return mfValue; } 211cdf0e10cSrcweir 212cdf0e10cSrcweir private: 213cdf0e10cSrcweir double mfValue; 214cdf0e10cSrcweir }; 215cdf0e10cSrcweir 216cdf0e10cSrcweir // ============================================================================ 217cdf0e10cSrcweir 218cdf0e10cSrcweir class SC_DLLPUBLIC ScStringCell : public ScBaseCell 219cdf0e10cSrcweir { 220cdf0e10cSrcweir public: 221cdf0e10cSrcweir #ifdef USE_MEMPOOL 222cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScStringCell ) 223cdf0e10cSrcweir #endif 224cdf0e10cSrcweir 225cdf0e10cSrcweir ScStringCell(); 226cdf0e10cSrcweir explicit ScStringCell( const String& rString ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir #ifdef DBG_UTIL 229cdf0e10cSrcweir ~ScStringCell(); 230cdf0e10cSrcweir #endif 231cdf0e10cSrcweir 232cdf0e10cSrcweir inline void SetString( const String& rString ) { maString = rString; } 233cdf0e10cSrcweir inline void GetString( String& rString ) const { rString = maString; } 234cdf0e10cSrcweir inline const String& GetString() const { return maString; } 235cdf0e10cSrcweir 236cdf0e10cSrcweir private: 237cdf0e10cSrcweir String maString; 238cdf0e10cSrcweir }; 239cdf0e10cSrcweir 240cdf0e10cSrcweir // ============================================================================ 241cdf0e10cSrcweir 242cdf0e10cSrcweir class SC_DLLPUBLIC ScEditCell : public ScBaseCell 243cdf0e10cSrcweir { 244cdf0e10cSrcweir private: 245cdf0e10cSrcweir EditTextObject* pData; 246cdf0e10cSrcweir String* pString; // fuer schnelleren Zugriff von Formeln 247cdf0e10cSrcweir ScDocument* pDoc; // fuer EditEngine Zugriff mit Pool 248cdf0e10cSrcweir 249cdf0e10cSrcweir void SetTextObject( const EditTextObject* pObject, 250cdf0e10cSrcweir const SfxItemPool* pFromPool ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir // not implemented 253cdf0e10cSrcweir ScEditCell( const ScEditCell& ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir public: 256cdf0e10cSrcweir 257cdf0e10cSrcweir #ifdef USE_MEMPOOL 258cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScEditCell ) 259cdf0e10cSrcweir #endif 260cdf0e10cSrcweir 261cdf0e10cSrcweir ~ScEditCell(); // wegen pData immer! 262cdf0e10cSrcweir 263cdf0e10cSrcweir ScEditCell( const EditTextObject* pObject, ScDocument*, 264cdf0e10cSrcweir const SfxItemPool* pFromPool /* = NULL */ ); 265cdf0e10cSrcweir ScEditCell( const ScEditCell& rCell, ScDocument& rDoc ); 266cdf0e10cSrcweir // fuer Zeilenumbrueche 267cdf0e10cSrcweir ScEditCell( const String& rString, ScDocument* ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir void SetData( const EditTextObject* pObject, 270cdf0e10cSrcweir const SfxItemPool* pFromPool /* = NULL */ ); 271cdf0e10cSrcweir void GetData( const EditTextObject*& rpObject ) const; 272cdf0e10cSrcweir void GetString( String& rString ) const; 273cdf0e10cSrcweir 274cdf0e10cSrcweir const EditTextObject* GetData() const { return pData; } 275cdf0e10cSrcweir }; 276cdf0e10cSrcweir 277cdf0e10cSrcweir // ============================================================================ 278cdf0e10cSrcweir 279cdf0e10cSrcweir enum ScMatrixMode { 280cdf0e10cSrcweir MM_NONE = 0, // No matrix formula 281cdf0e10cSrcweir MM_FORMULA = 1, // Upper left matrix formula cell 282cdf0e10cSrcweir MM_REFERENCE = 2, // Remaining cells, via ocMatRef reference token 283cdf0e10cSrcweir MM_FAKE = 3 // Interpret "as-if" matrix formula (legacy) 284cdf0e10cSrcweir }; 285cdf0e10cSrcweir 286cdf0e10cSrcweir class SC_DLLPUBLIC ScFormulaCell : public ScBaseCell, public SvtListener 287cdf0e10cSrcweir { 288cdf0e10cSrcweir private: 289cdf0e10cSrcweir ScFormulaResult aResult; 290cdf0e10cSrcweir formula::FormulaGrammar::Grammar eTempGrammar; // used between string (creation) and (re)compilation 291cdf0e10cSrcweir ScTokenArray* pCode; // The (new) token array 292cdf0e10cSrcweir ScDocument* pDocument; 293cdf0e10cSrcweir ScFormulaCell* pPrevious; 294cdf0e10cSrcweir ScFormulaCell* pNext; 295cdf0e10cSrcweir ScFormulaCell* pPreviousTrack; 296cdf0e10cSrcweir ScFormulaCell* pNextTrack; 297cdf0e10cSrcweir sal_uLong nFormatIndex; // Number format set by calculation 298cdf0e10cSrcweir short nFormatType; // Number format type set by calculation 299cdf0e10cSrcweir sal_uInt16 nSeenInIteration; // Iteration cycle in which the cell was last encountered 300cdf0e10cSrcweir sal_uInt8 cMatrixFlag; // One of ScMatrixMode 301cdf0e10cSrcweir sal_Bool bDirty : 1; // Must be (re)calculated 302cdf0e10cSrcweir sal_Bool bChanged : 1; // Whether something changed regarding display/representation 303cdf0e10cSrcweir sal_Bool bRunning : 1; // Already interpreting right now 304cdf0e10cSrcweir sal_Bool bCompile : 1; // Must be (re)compiled 305cdf0e10cSrcweir sal_Bool bSubTotal : 1; // Cell is part of or contains a SubTotal 306cdf0e10cSrcweir sal_Bool bIsIterCell : 1; // Cell is part of a circular reference 307cdf0e10cSrcweir sal_Bool bInChangeTrack : 1; // Cell is in ChangeTrack 308cdf0e10cSrcweir sal_Bool bTableOpDirty : 1; // Dirty flag for TableOp 309cdf0e10cSrcweir sal_Bool bNeedListening : 1; // Listeners need to be re-established after UpdateReference 310cdf0e10cSrcweir 311cdf0e10cSrcweir enum ScInterpretTailParameter 312cdf0e10cSrcweir { 313cdf0e10cSrcweir SCITP_NORMAL, 314cdf0e10cSrcweir SCITP_FROM_ITERATION, 315cdf0e10cSrcweir SCITP_CLOSE_ITERATION_CIRCLE 316cdf0e10cSrcweir }; 317cdf0e10cSrcweir void InterpretTail( ScInterpretTailParameter ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir ScFormulaCell( const ScFormulaCell& ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir public: 322cdf0e10cSrcweir 323cdf0e10cSrcweir #ifdef USE_MEMPOOL 324cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell ) 325cdf0e10cSrcweir #endif 326cdf0e10cSrcweir 327cdf0e10cSrcweir ScAddress aPos; 328cdf0e10cSrcweir 329cdf0e10cSrcweir ~ScFormulaCell(); 330cdf0e10cSrcweir ScFormulaCell(); 331cdf0e10cSrcweir 332cdf0e10cSrcweir /** Empty formula cell, or with a preconstructed token array. */ 333cdf0e10cSrcweir ScFormulaCell( ScDocument*, const ScAddress&, const ScTokenArray* = NULL, 334cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, 335cdf0e10cSrcweir sal_uInt8 = MM_NONE ); 336cdf0e10cSrcweir 337cdf0e10cSrcweir /** With formula string and grammar to compile with. 338cdf0e10cSrcweir formula::FormulaGrammar::GRAM_DEFAULT effectively isformula::FormulaGrammar::GRAM_NATIVE_UI that 339cdf0e10cSrcweir also includes formula::FormulaGrammar::CONV_UNSPECIFIED, therefor uses the address 340cdf0e10cSrcweir convention associated with rPos::nTab by default. */ 341cdf0e10cSrcweir ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, 342cdf0e10cSrcweir const String& rFormula, 343cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, 344cdf0e10cSrcweir sal_uInt8 cMatInd = MM_NONE ); 345cdf0e10cSrcweir 346cdf0e10cSrcweir ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, int nCloneFlags = SC_CLONECELL_DEFAULT ); 347cdf0e10cSrcweir 348cdf0e10cSrcweir void GetFormula( String& rFormula, 349cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; 350cdf0e10cSrcweir void GetFormula( rtl::OUStringBuffer& rBuffer, 351cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; 352cdf0e10cSrcweir 353cdf0e10cSrcweir void SetDirty(); 354cdf0e10cSrcweir inline void SetDirtyVar() { bDirty = sal_True; } 355cdf0e10cSrcweir // If setting entire document dirty after load, no broadcasts but still append to FormulaTree. 356cdf0e10cSrcweir void SetDirtyAfterLoad(); 357cdf0e10cSrcweir inline void ResetTableOpDirtyVar() { bTableOpDirty = sal_False; } 358cdf0e10cSrcweir void SetTableOpDirty(); 359cdf0e10cSrcweir sal_Bool IsDirtyOrInTableOpDirty() const; 360cdf0e10cSrcweir sal_Bool GetDirty() const { return bDirty; } 361cdf0e10cSrcweir sal_Bool NeedsListening() const { return bNeedListening; } 362cdf0e10cSrcweir void SetNeedsListening( sal_Bool bVar ) { bNeedListening = bVar; } 363cdf0e10cSrcweir void Compile(const String& rFormula, 364cdf0e10cSrcweir sal_Bool bNoListening = sal_False, 365cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ); 366cdf0e10cSrcweir void CompileTokenArray( sal_Bool bNoListening = sal_False ); 367cdf0e10cSrcweir void CompileXML( ScProgress& rProgress ); // compile temporary string tokens 368cdf0e10cSrcweir void CalcAfterLoad(); 369cdf0e10cSrcweir bool MarkUsedExternalReferences(); 370cdf0e10cSrcweir void Interpret(); 371cdf0e10cSrcweir inline sal_Bool IsIterCell() const { return bIsIterCell; } 372cdf0e10cSrcweir inline sal_uInt16 GetSeenInIteration() const { return nSeenInIteration; } 373cdf0e10cSrcweir 374cdf0e10cSrcweir sal_Bool HasOneReference( ScRange& r ) const; 375cdf0e10cSrcweir /* Checks if the formula contains reference list that can be 376cdf0e10cSrcweir expressed by one reference (like A1;A2;A3:A5 -> A1:A5). The 377cdf0e10cSrcweir reference list is not required to be sorted (i.e. A3;A1;A2 is 378cdf0e10cSrcweir still recognized as A1:A3), but no overlapping is allowed. 379cdf0e10cSrcweir If one reference is recognized, the rRange is filled. 380cdf0e10cSrcweir 381cdf0e10cSrcweir It is similar to HasOneReference(), but more general. 382cdf0e10cSrcweir */ 383cdf0e10cSrcweir bool HasRefListExpressibleAsOneReference(ScRange& rRange) const; 384cdf0e10cSrcweir sal_Bool HasRelNameReference() const; 385cdf0e10cSrcweir sal_Bool HasColRowName() const; 386cdf0e10cSrcweir 387cdf0e10cSrcweir void UpdateReference(UpdateRefMode eUpdateRefMode, 388cdf0e10cSrcweir const ScRange& r, 389cdf0e10cSrcweir SCsCOL nDx, SCsROW nDy, SCsTAB nDz, 390cdf0e10cSrcweir ScDocument* pUndoDoc = NULL, 391cdf0e10cSrcweir const ScAddress* pUndoCellPos = NULL ); 392cdf0e10cSrcweir 393cdf0e10cSrcweir void TransposeReference(); 394cdf0e10cSrcweir void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, 395cdf0e10cSrcweir ScDocument* pUndoDoc ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); 398cdf0e10cSrcweir 399cdf0e10cSrcweir void UpdateInsertTab(SCTAB nTable); 400cdf0e10cSrcweir void UpdateInsertTabAbs(SCTAB nTable); 401cdf0e10cSrcweir sal_Bool UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove = sal_False); 402cdf0e10cSrcweir void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo); 403cdf0e10cSrcweir void UpdateRenameTab(SCTAB nTable, const String& rName); 404cdf0e10cSrcweir sal_Bool TestTabRefAbs(SCTAB nTable); 405cdf0e10cSrcweir void UpdateCompile( sal_Bool bForceIfNameInUse = sal_False ); 406cdf0e10cSrcweir sal_Bool IsRangeNameInUse(sal_uInt16 nIndex) const; 407cdf0e10cSrcweir void FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes) const; 408cdf0e10cSrcweir void ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap ); 409cdf0e10cSrcweir sal_Bool IsSubTotal() const { return bSubTotal; } 410cdf0e10cSrcweir sal_Bool IsChanged() const { return bChanged; } 411cdf0e10cSrcweir void ResetChanged() { bChanged = sal_False; } 412cdf0e10cSrcweir sal_Bool IsEmpty(); // formula::svEmptyCell result 413cdf0e10cSrcweir // display as empty string if formula::svEmptyCell result 414cdf0e10cSrcweir sal_Bool IsEmptyDisplayedAsString(); 415cdf0e10cSrcweir sal_Bool IsValue(); // also sal_True if formula::svEmptyCell 416cdf0e10cSrcweir double GetValue(); 417cdf0e10cSrcweir double GetValueAlways(); // ignore errors 418cdf0e10cSrcweir void GetString( String& rString ); 419cdf0e10cSrcweir const ScMatrix* GetMatrix(); 420cdf0e10cSrcweir sal_Bool GetMatrixOrigin( ScAddress& rPos ) const; 421cdf0e10cSrcweir void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ); 422cdf0e10cSrcweir sal_uInt16 GetMatrixEdge( ScAddress& rOrgPos ); 423cdf0e10cSrcweir sal_uInt16 GetErrCode(); // interpret first if necessary 424cdf0e10cSrcweir sal_uInt16 GetRawError(); // don't interpret, just return code or result error 425cdf0e10cSrcweir short GetFormatType() const { return nFormatType; } 426cdf0e10cSrcweir sal_uLong GetFormatIndex() const { return nFormatIndex; } 427cdf0e10cSrcweir void GetFormatInfo( short& nType, sal_uLong& nIndex ) const 428cdf0e10cSrcweir { nType = nFormatType; nIndex = nFormatIndex; } 429cdf0e10cSrcweir sal_uInt8 GetMatrixFlag() const { return cMatrixFlag; } 430cdf0e10cSrcweir ScTokenArray* GetCode() const { return pCode; } 431cdf0e10cSrcweir 432cdf0e10cSrcweir sal_Bool IsRunning() const { return bRunning; } 433cdf0e10cSrcweir void SetRunning( sal_Bool bVal ) { bRunning = bVal; } 434cdf0e10cSrcweir void CompileDBFormula(); 435cdf0e10cSrcweir void CompileDBFormula( sal_Bool bCreateFormulaString ); 436cdf0e10cSrcweir void CompileNameFormula( sal_Bool bCreateFormulaString ); 437cdf0e10cSrcweir void CompileColRowNameFormula(); 438cdf0e10cSrcweir ScFormulaCell* GetPrevious() const { return pPrevious; } 439cdf0e10cSrcweir ScFormulaCell* GetNext() const { return pNext; } 440cdf0e10cSrcweir void SetPrevious( ScFormulaCell* pF ) { pPrevious = pF; } 441cdf0e10cSrcweir void SetNext( ScFormulaCell* pF ) { pNext = pF; } 442cdf0e10cSrcweir ScFormulaCell* GetPreviousTrack() const { return pPreviousTrack; } 443cdf0e10cSrcweir ScFormulaCell* GetNextTrack() const { return pNextTrack; } 444cdf0e10cSrcweir void SetPreviousTrack( ScFormulaCell* pF ) { pPreviousTrack = pF; } 445cdf0e10cSrcweir void SetNextTrack( ScFormulaCell* pF ) { pNextTrack = pF; } 446cdf0e10cSrcweir 447cdf0e10cSrcweir virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint); 448cdf0e10cSrcweir void SetCompile( sal_Bool bVal ) { bCompile = bVal; } 449cdf0e10cSrcweir ScDocument* GetDocument() const { return pDocument; } 450cdf0e10cSrcweir void SetMatColsRows( SCCOL nCols, SCROW nRows ); 451cdf0e10cSrcweir void GetMatColsRows( SCCOL& nCols, SCROW& nRows ) const; 452cdf0e10cSrcweir 453cdf0e10cSrcweir // ob Zelle im ChangeTrack und nicht im echten Dokument ist 454cdf0e10cSrcweir void SetInChangeTrack( sal_Bool bVal ) { bInChangeTrack = bVal; } 455cdf0e10cSrcweir sal_Bool IsInChangeTrack() const { return bInChangeTrack; } 456cdf0e10cSrcweir 457cdf0e10cSrcweir // Zu Typ und Format das entsprechende Standardformat. 458cdf0e10cSrcweir // Bei Format "Standard" evtl. das in die Formelzelle 459cdf0e10cSrcweir // uebernommene Format. 460cdf0e10cSrcweir sal_uLong GetStandardFormat( SvNumberFormatter& rFormatter, sal_uLong nFormat ) const; 461cdf0e10cSrcweir 462cdf0e10cSrcweir // For import filters! 463cdf0e10cSrcweir void AddRecalcMode( formula::ScRecalcMode ); 464cdf0e10cSrcweir /** For import only: set a double result. */ 465cdf0e10cSrcweir void SetHybridDouble( double n ) { aResult.SetHybridDouble( n); } 466cdf0e10cSrcweir /** For import only: set a string result. 467cdf0e10cSrcweir If for whatever reason you have to use both, SetHybridDouble() and 468cdf0e10cSrcweir SetHybridString() or SetHybridFormula(), use SetHybridDouble() first 469cdf0e10cSrcweir for performance reasons.*/ 470cdf0e10cSrcweir void SetHybridString( const String& r ) 471cdf0e10cSrcweir { aResult.SetHybridString( r); } 472cdf0e10cSrcweir /** For import only: set a temporary formula string to be compiled later. 473cdf0e10cSrcweir If for whatever reason you have to use both, SetHybridDouble() and 474cdf0e10cSrcweir SetHybridString() or SetHybridFormula(), use SetHybridDouble() first 475cdf0e10cSrcweir for performance reasons.*/ 476cdf0e10cSrcweir void SetHybridFormula( const String& r, 477cdf0e10cSrcweir const formula::FormulaGrammar::Grammar eGrammar ) 478cdf0e10cSrcweir { aResult.SetHybridFormula( r); eTempGrammar = eGrammar; } 479cdf0e10cSrcweir void SetErrCode( sal_uInt16 n ); 480cdf0e10cSrcweir inline sal_Bool IsHyperLinkCell() const { return pCode && pCode->IsHyperLink(); } 481cdf0e10cSrcweir EditTextObject* CreateURLObject() ; 482cdf0e10cSrcweir void GetURLResult( String& rURL, String& rCellText ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir /** Determines whether or not the result string contains more than one paragraph */ 485cdf0e10cSrcweir bool IsMultilineResult(); 486cdf0e10cSrcweir }; 487cdf0e10cSrcweir 488cdf0e10cSrcweir // Iterator fuer Referenzen in einer Formelzelle 489cdf0e10cSrcweir class ScDetectiveRefIter 490cdf0e10cSrcweir { 491cdf0e10cSrcweir private: 492cdf0e10cSrcweir ScTokenArray* pCode; 493cdf0e10cSrcweir ScAddress aPos; 494cdf0e10cSrcweir public: 495cdf0e10cSrcweir ScDetectiveRefIter( ScFormulaCell* pCell ); 496cdf0e10cSrcweir sal_Bool GetNextRef( ScRange& rRange ); 497cdf0e10cSrcweir }; 498cdf0e10cSrcweir 499cdf0e10cSrcweir // ============================================================================ 500cdf0e10cSrcweir 501cdf0e10cSrcweir #endif 502cdf0e10cSrcweir 503