138d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
338d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
438d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file
538d50f7bSAndrew Rist * distributed with this work for additional information
638d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file
738d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the
838d50f7bSAndrew Rist * "License"); you may not use this file except in compliance
938d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1138d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1338d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing,
1438d50f7bSAndrew Rist * software distributed under the License is distributed on an
1538d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1638d50f7bSAndrew Rist * KIND, either express or implied. See the License for the
1738d50f7bSAndrew Rist * specific language governing permissions and limitations
1838d50f7bSAndrew Rist * under the License.
19cdf0e10cSrcweir *
2038d50f7bSAndrew Rist *************************************************************/
2138d50f7bSAndrew Rist
22cdf0e10cSrcweir #ifndef SC_CELL_HXX
23cdf0e10cSrcweir #define SC_CELL_HXX
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <stddef.h>
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <set>
28cdf0e10cSrcweir #include <tools/mempool.hxx>
29cdf0e10cSrcweir #include <svl/listener.hxx>
30cdf0e10cSrcweir #include "global.hxx"
31cdf0e10cSrcweir #include "rangenam.hxx"
32cdf0e10cSrcweir #include "formula/grammar.hxx"
33cdf0e10cSrcweir #include "tokenarray.hxx"
34cdf0e10cSrcweir #include "formularesult.hxx"
35cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
36cdf0e10cSrcweir #include <unotools/fontcvt.hxx>
37cdf0e10cSrcweir #include "scdllapi.h"
38cdf0e10cSrcweir
39b4df81e3SWang Lei #include <cellform.hxx>
40b4df81e3SWang Lei
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
GetCellType() const102cdf0e10cSrcweir 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
GetTextWidth() const109cdf0e10cSrcweir inline sal_uInt16 GetTextWidth() const { return nTextWidth; }
SetTextWidth(sal_uInt16 nNew)110cdf0e10cSrcweir inline void SetTextWidth( sal_uInt16 nNew ) { nTextWidth = nNew; }
111cdf0e10cSrcweir
GetScriptType() const112cdf0e10cSrcweir inline sal_uInt8 GetScriptType() const { return nScriptType; }
SetScriptType(sal_uInt8 nNew)113cdf0e10cSrcweir inline void SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; }
114cdf0e10cSrcweir
115cdf0e10cSrcweir /** Returns true, if the cell contains a note. */
HasNote() const116cdf0e10cSrcweir inline bool HasNote() const { return mpNote != 0; }
117cdf0e10cSrcweir /** Returns the pointer to a cell note object (read-only). */
GetNote() const118cdf0e10cSrcweir inline const ScPostIt* GetNote() const { return mpNote; }
119cdf0e10cSrcweir /** Returns the pointer to a cell note object. */
GetNote()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. */
HasBroadcaster() const129cdf0e10cSrcweir inline bool HasBroadcaster() const { return mpBroadcaster != 0; }
130cdf0e10cSrcweir /** Returns the pointer to the cell broadcaster. */
GetBroadcaster() const131cdf0e10cSrcweir 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
SetValue(double fValue)209cdf0e10cSrcweir inline void SetValue( double fValue ) { mfValue = fValue; }
GetValue() const210cdf0e10cSrcweir 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
SetString(const String & rString)232cdf0e10cSrcweir inline void SetString( const String& rString ) { maString = rString; }
GetString(String & rString) const233cdf0e10cSrcweir inline void GetString( String& rString ) const { rString = maString; }
GetString() const234cdf0e10cSrcweir 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
GetData() const274cdf0e10cSrcweir 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
310*61e64f4aSWang Lei ScToken* pValidRefToken; // i120962, get the valid reference token if the cell was applied a reference formula
311cdf0e10cSrcweir
312cdf0e10cSrcweir enum ScInterpretTailParameter
313cdf0e10cSrcweir {
314cdf0e10cSrcweir SCITP_NORMAL,
315cdf0e10cSrcweir SCITP_FROM_ITERATION,
316cdf0e10cSrcweir SCITP_CLOSE_ITERATION_CIRCLE
317cdf0e10cSrcweir };
318cdf0e10cSrcweir void InterpretTail( ScInterpretTailParameter );
319cdf0e10cSrcweir
320cdf0e10cSrcweir ScFormulaCell( const ScFormulaCell& );
321cdf0e10cSrcweir
322cdf0e10cSrcweir public:
323cdf0e10cSrcweir
324cdf0e10cSrcweir #ifdef USE_MEMPOOL
325cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell )
326cdf0e10cSrcweir #endif
327cdf0e10cSrcweir
328cdf0e10cSrcweir ScAddress aPos;
329cdf0e10cSrcweir
330cdf0e10cSrcweir ~ScFormulaCell();
331cdf0e10cSrcweir ScFormulaCell();
332cdf0e10cSrcweir
333cdf0e10cSrcweir /** Empty formula cell, or with a preconstructed token array. */
334cdf0e10cSrcweir ScFormulaCell( ScDocument*, const ScAddress&, const ScTokenArray* = NULL,
335cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
336cdf0e10cSrcweir sal_uInt8 = MM_NONE );
337cdf0e10cSrcweir
338cdf0e10cSrcweir /** With formula string and grammar to compile with.
339cdf0e10cSrcweir formula::FormulaGrammar::GRAM_DEFAULT effectively isformula::FormulaGrammar::GRAM_NATIVE_UI that
340cdf0e10cSrcweir also includes formula::FormulaGrammar::CONV_UNSPECIFIED, therefor uses the address
341cdf0e10cSrcweir convention associated with rPos::nTab by default. */
342cdf0e10cSrcweir ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
343cdf0e10cSrcweir const String& rFormula,
344cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
345cdf0e10cSrcweir sal_uInt8 cMatInd = MM_NONE );
346cdf0e10cSrcweir
347cdf0e10cSrcweir ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, int nCloneFlags = SC_CLONECELL_DEFAULT );
348cdf0e10cSrcweir
349cdf0e10cSrcweir void GetFormula( String& rFormula,
350cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
351cdf0e10cSrcweir void GetFormula( rtl::OUStringBuffer& rBuffer,
352cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
353cdf0e10cSrcweir
354cdf0e10cSrcweir void SetDirty();
SetDirtyVar()355cdf0e10cSrcweir inline void SetDirtyVar() { bDirty = sal_True; }
356cdf0e10cSrcweir // If setting entire document dirty after load, no broadcasts but still append to FormulaTree.
357cdf0e10cSrcweir void SetDirtyAfterLoad();
ResetTableOpDirtyVar()358cdf0e10cSrcweir inline void ResetTableOpDirtyVar() { bTableOpDirty = sal_False; }
359cdf0e10cSrcweir void SetTableOpDirty();
360cdf0e10cSrcweir sal_Bool IsDirtyOrInTableOpDirty() const;
GetDirty() const361cdf0e10cSrcweir sal_Bool GetDirty() const { return bDirty; }
NeedsListening() const362cdf0e10cSrcweir sal_Bool NeedsListening() const { return bNeedListening; }
SetNeedsListening(sal_Bool bVar)363cdf0e10cSrcweir void SetNeedsListening( sal_Bool bVar ) { bNeedListening = bVar; }
364cdf0e10cSrcweir void Compile(const String& rFormula,
365cdf0e10cSrcweir sal_Bool bNoListening = sal_False,
366cdf0e10cSrcweir const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
367cdf0e10cSrcweir void CompileTokenArray( sal_Bool bNoListening = sal_False );
368cdf0e10cSrcweir void CompileXML( ScProgress& rProgress ); // compile temporary string tokens
369cdf0e10cSrcweir void CalcAfterLoad();
370cdf0e10cSrcweir bool MarkUsedExternalReferences();
371cdf0e10cSrcweir void Interpret();
IsIterCell() const372cdf0e10cSrcweir inline sal_Bool IsIterCell() const { return bIsIterCell; }
GetSeenInIteration() const373cdf0e10cSrcweir inline sal_uInt16 GetSeenInIteration() const { return nSeenInIteration; }
374cdf0e10cSrcweir
375cdf0e10cSrcweir sal_Bool HasOneReference( ScRange& r ) const;
376cdf0e10cSrcweir /* Checks if the formula contains reference list that can be
377cdf0e10cSrcweir expressed by one reference (like A1;A2;A3:A5 -> A1:A5). The
378cdf0e10cSrcweir reference list is not required to be sorted (i.e. A3;A1;A2 is
379cdf0e10cSrcweir still recognized as A1:A3), but no overlapping is allowed.
380cdf0e10cSrcweir If one reference is recognized, the rRange is filled.
381cdf0e10cSrcweir
382cdf0e10cSrcweir It is similar to HasOneReference(), but more general.
383cdf0e10cSrcweir */
384cdf0e10cSrcweir bool HasRefListExpressibleAsOneReference(ScRange& rRange) const;
385cdf0e10cSrcweir sal_Bool HasRelNameReference() const;
386cdf0e10cSrcweir sal_Bool HasColRowName() const;
387cdf0e10cSrcweir
388cdf0e10cSrcweir void UpdateReference(UpdateRefMode eUpdateRefMode,
389cdf0e10cSrcweir const ScRange& r,
390cdf0e10cSrcweir SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
391cdf0e10cSrcweir ScDocument* pUndoDoc = NULL,
392cdf0e10cSrcweir const ScAddress* pUndoCellPos = NULL );
393cdf0e10cSrcweir
394cdf0e10cSrcweir void TransposeReference();
395cdf0e10cSrcweir void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
396cdf0e10cSrcweir ScDocument* pUndoDoc );
397cdf0e10cSrcweir
398cdf0e10cSrcweir void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
399cdf0e10cSrcweir
400cdf0e10cSrcweir void UpdateInsertTab(SCTAB nTable);
401cdf0e10cSrcweir void UpdateInsertTabAbs(SCTAB nTable);
402cdf0e10cSrcweir sal_Bool UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove = sal_False);
403cdf0e10cSrcweir void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
404cdf0e10cSrcweir void UpdateRenameTab(SCTAB nTable, const String& rName);
405cdf0e10cSrcweir sal_Bool TestTabRefAbs(SCTAB nTable);
406cdf0e10cSrcweir void UpdateCompile( sal_Bool bForceIfNameInUse = sal_False );
407cdf0e10cSrcweir sal_Bool IsRangeNameInUse(sal_uInt16 nIndex) const;
408cdf0e10cSrcweir void FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes) const;
409cdf0e10cSrcweir void ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap );
IsSubTotal() const410cdf0e10cSrcweir sal_Bool IsSubTotal() const { return bSubTotal; }
IsChanged() const411cdf0e10cSrcweir sal_Bool IsChanged() const { return bChanged; }
ResetChanged()412cdf0e10cSrcweir void ResetChanged() { bChanged = sal_False; }
413cdf0e10cSrcweir sal_Bool IsEmpty(); // formula::svEmptyCell result
414cdf0e10cSrcweir // display as empty string if formula::svEmptyCell result
415cdf0e10cSrcweir sal_Bool IsEmptyDisplayedAsString();
416cdf0e10cSrcweir sal_Bool IsValue(); // also sal_True if formula::svEmptyCell
417cdf0e10cSrcweir double GetValue();
418cdf0e10cSrcweir double GetValueAlways(); // ignore errors
419cdf0e10cSrcweir void GetString( String& rString );
420cdf0e10cSrcweir const ScMatrix* GetMatrix();
421cdf0e10cSrcweir sal_Bool GetMatrixOrigin( ScAddress& rPos ) const;
422cdf0e10cSrcweir void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows );
423cdf0e10cSrcweir sal_uInt16 GetMatrixEdge( ScAddress& rOrgPos );
424cdf0e10cSrcweir sal_uInt16 GetErrCode(); // interpret first if necessary
425cdf0e10cSrcweir sal_uInt16 GetRawError(); // don't interpret, just return code or result error
GetFormatType() const426cdf0e10cSrcweir short GetFormatType() const { return nFormatType; }
GetFormatIndex() const427cdf0e10cSrcweir sal_uLong GetFormatIndex() const { return nFormatIndex; }
GetFormatInfo(short & nType,sal_uLong & nIndex) const428cdf0e10cSrcweir void GetFormatInfo( short& nType, sal_uLong& nIndex ) const
429cdf0e10cSrcweir { nType = nFormatType; nIndex = nFormatIndex; }
GetMatrixFlag() const430cdf0e10cSrcweir sal_uInt8 GetMatrixFlag() const { return cMatrixFlag; }
GetCode() const431cdf0e10cSrcweir ScTokenArray* GetCode() const { return pCode; }
432cdf0e10cSrcweir
IsRunning() const433cdf0e10cSrcweir sal_Bool IsRunning() const { return bRunning; }
SetRunning(sal_Bool bVal)434cdf0e10cSrcweir void SetRunning( sal_Bool bVal ) { bRunning = bVal; }
435cdf0e10cSrcweir void CompileDBFormula();
436cdf0e10cSrcweir void CompileDBFormula( sal_Bool bCreateFormulaString );
437cdf0e10cSrcweir void CompileNameFormula( sal_Bool bCreateFormulaString );
438cdf0e10cSrcweir void CompileColRowNameFormula();
GetPrevious() const439cdf0e10cSrcweir ScFormulaCell* GetPrevious() const { return pPrevious; }
GetNext() const440cdf0e10cSrcweir ScFormulaCell* GetNext() const { return pNext; }
SetPrevious(ScFormulaCell * pF)441cdf0e10cSrcweir void SetPrevious( ScFormulaCell* pF ) { pPrevious = pF; }
SetNext(ScFormulaCell * pF)442cdf0e10cSrcweir void SetNext( ScFormulaCell* pF ) { pNext = pF; }
GetPreviousTrack() const443cdf0e10cSrcweir ScFormulaCell* GetPreviousTrack() const { return pPreviousTrack; }
GetNextTrack() const444cdf0e10cSrcweir ScFormulaCell* GetNextTrack() const { return pNextTrack; }
SetPreviousTrack(ScFormulaCell * pF)445cdf0e10cSrcweir void SetPreviousTrack( ScFormulaCell* pF ) { pPreviousTrack = pF; }
SetNextTrack(ScFormulaCell * pF)446cdf0e10cSrcweir void SetNextTrack( ScFormulaCell* pF ) { pNextTrack = pF; }
447cdf0e10cSrcweir
448cdf0e10cSrcweir virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint);
SetCompile(sal_Bool bVal)449cdf0e10cSrcweir void SetCompile( sal_Bool bVal ) { bCompile = bVal; }
GetDocument() const450cdf0e10cSrcweir ScDocument* GetDocument() const { return pDocument; }
451cdf0e10cSrcweir void SetMatColsRows( SCCOL nCols, SCROW nRows );
452cdf0e10cSrcweir void GetMatColsRows( SCCOL& nCols, SCROW& nRows ) const;
453cdf0e10cSrcweir
454cdf0e10cSrcweir // ob Zelle im ChangeTrack und nicht im echten Dokument ist
SetInChangeTrack(sal_Bool bVal)455cdf0e10cSrcweir void SetInChangeTrack( sal_Bool bVal ) { bInChangeTrack = bVal; }
IsInChangeTrack() const456cdf0e10cSrcweir sal_Bool IsInChangeTrack() const { return bInChangeTrack; }
457cdf0e10cSrcweir
458cdf0e10cSrcweir // Zu Typ und Format das entsprechende Standardformat.
459cdf0e10cSrcweir // Bei Format "Standard" evtl. das in die Formelzelle
460cdf0e10cSrcweir // uebernommene Format.
461cdf0e10cSrcweir sal_uLong GetStandardFormat( SvNumberFormatter& rFormatter, sal_uLong nFormat ) const;
462cdf0e10cSrcweir
463cdf0e10cSrcweir // For import filters!
464cdf0e10cSrcweir void AddRecalcMode( formula::ScRecalcMode );
465cdf0e10cSrcweir /** For import only: set a double result. */
SetHybridDouble(double n)466cdf0e10cSrcweir void SetHybridDouble( double n ) { aResult.SetHybridDouble( n); }
467cdf0e10cSrcweir /** For import only: set a string result.
468cdf0e10cSrcweir If for whatever reason you have to use both, SetHybridDouble() and
469cdf0e10cSrcweir SetHybridString() or SetHybridFormula(), use SetHybridDouble() first
470cdf0e10cSrcweir for performance reasons.*/
SetHybridString(const String & r)471cdf0e10cSrcweir void SetHybridString( const String& r )
472cdf0e10cSrcweir { aResult.SetHybridString( r); }
473cdf0e10cSrcweir /** For import only: set a temporary formula string to be compiled later.
474cdf0e10cSrcweir If for whatever reason you have to use both, SetHybridDouble() and
475cdf0e10cSrcweir SetHybridString() or SetHybridFormula(), use SetHybridDouble() first
476cdf0e10cSrcweir for performance reasons.*/
SetHybridFormula(const String & r,const formula::FormulaGrammar::Grammar eGrammar)477cdf0e10cSrcweir void SetHybridFormula( const String& r,
478cdf0e10cSrcweir const formula::FormulaGrammar::Grammar eGrammar )
479cdf0e10cSrcweir { aResult.SetHybridFormula( r); eTempGrammar = eGrammar; }
480cdf0e10cSrcweir void SetErrCode( sal_uInt16 n );
IsHyperLinkCell() const481cdf0e10cSrcweir inline sal_Bool IsHyperLinkCell() const { return pCode && pCode->IsHyperLink(); }
482cdf0e10cSrcweir EditTextObject* CreateURLObject() ;
483cdf0e10cSrcweir void GetURLResult( String& rURL, String& rCellText );
484cdf0e10cSrcweir
485cdf0e10cSrcweir /** Determines whether or not the result string contains more than one paragraph */
486cdf0e10cSrcweir bool IsMultilineResult();
GetValidRefToken()487*61e64f4aSWang Lei ScToken* GetValidRefToken() { return pValidRefToken; } // i120962
488cdf0e10cSrcweir };
489cdf0e10cSrcweir
490cdf0e10cSrcweir // Iterator fuer Referenzen in einer Formelzelle
491cdf0e10cSrcweir class ScDetectiveRefIter
492cdf0e10cSrcweir {
493cdf0e10cSrcweir private:
494cdf0e10cSrcweir ScTokenArray* pCode;
495cdf0e10cSrcweir ScAddress aPos;
496cdf0e10cSrcweir public:
497cdf0e10cSrcweir ScDetectiveRefIter( ScFormulaCell* pCell );
498cdf0e10cSrcweir sal_Bool GetNextRef( ScRange& rRange );
499cdf0e10cSrcweir };
500cdf0e10cSrcweir
501cdf0e10cSrcweir // ============================================================================
GetValueFromCell(const ScBaseCell * pCell)502b4df81e3SWang Lei inline double GetValueFromCell( const ScBaseCell * pCell )
503b4df81e3SWang Lei {
504b4df81e3SWang Lei switch (pCell->GetCellType())
505b4df81e3SWang Lei {
506b4df81e3SWang Lei case CELLTYPE_VALUE:
507b4df81e3SWang Lei return ((ScValueCell*)pCell)->GetValue();
508b4df81e3SWang Lei case CELLTYPE_FORMULA:
509b4df81e3SWang Lei {
510b4df81e3SWang Lei if (((ScFormulaCell*)pCell)->IsValue())
511b4df81e3SWang Lei return ((ScFormulaCell*)pCell)->GetValue();
512b4df81e3SWang Lei else
513b4df81e3SWang Lei return 0.0;
514b4df81e3SWang Lei }
515b4df81e3SWang Lei default:
516b4df81e3SWang Lei return 0.0;
517b4df81e3SWang Lei }
518b4df81e3SWang Lei }
519b4df81e3SWang Lei // ============================================================================
520b4df81e3SWang Lei
521b4df81e3SWang Lei
GetStringFromCell(const ScBaseCell * pCell,sal_uLong nFormat,SvNumberFormatter * pFormatter)522b4df81e3SWang Lei inline String GetStringFromCell( const ScBaseCell * pCell, sal_uLong nFormat, SvNumberFormatter* pFormatter )
523b4df81e3SWang Lei {
524b4df81e3SWang Lei if (pCell->GetCellType() != CELLTYPE_NOTE)
525b4df81e3SWang Lei {
526b4df81e3SWang Lei String strResult;
527b4df81e3SWang Lei Color* pColor = NULL;
528b4df81e3SWang Lei ScCellFormat::GetString( const_cast<ScBaseCell*>(pCell), nFormat, strResult, &pColor, *(pFormatter) );
529b4df81e3SWang Lei return strResult;
530b4df81e3SWang Lei }
531b4df81e3SWang Lei else
532b4df81e3SWang Lei return String();
533b4df81e3SWang Lei }
534cdf0e10cSrcweir
535cdf0e10cSrcweir #endif
536cdf0e10cSrcweir
537