update credits
[LibreOffice.git] / sc / inc / cellvalue.hxx
blob674fc722a16baa1a082c3c7db2dea9399f1d3167
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef __SC_CELLVALUE_HXX__
11 #define __SC_CELLVALUE_HXX__
13 #include "global.hxx"
15 class ScDocument;
16 class ScColumn;
17 class ScFormulaCell;
18 class EditTextObject;
19 class ScBaseCell;
21 /**
22 * Store arbitrary cell value of any kind. It only stores cell value and
23 * nothing else. It creates a copy of the original cell value, and manages
24 * the life cycle of the copied value.
26 struct SC_DLLPUBLIC ScCellValue
28 CellType meType;
29 union {
30 double mfValue;
31 OUString* mpString;
32 EditTextObject* mpEditText;
33 ScFormulaCell* mpFormula;
36 ScCellValue();
37 ScCellValue( double fValue );
38 ScCellValue( const OUString& rString );
39 ScCellValue( const EditTextObject& rEditText );
40 ScCellValue( const ScFormulaCell& rFormula );
41 ScCellValue( const ScCellValue& r );
42 ~ScCellValue();
44 void clear();
46 void set( double fValue );
47 void set( const OUString& rStr );
48 void set( const EditTextObject& rEditText );
49 void set( const ScFormulaCell& rFormula );
50 void set( ScFormulaCell* pFormula );
52 /**
53 * Take cell value from specified position in specified document.
55 void assign( const ScDocument& rDoc, const ScAddress& rPos );
57 void assign( const ScCellValue& rOther, ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT );
59 /**
60 * TODO: Remove this later.
62 void assign( const ScBaseCell& rCell );
64 /**
65 * Set cell value at specified position in specified document.
67 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
69 /**
70 * Set cell value at specified position in specified document. But unlike
71 * commit(), this method sets the original value to the document without
72 * copying. After this call, the value gets cleared.
74 void release( ScDocument& rDoc, const ScAddress& rPos );
76 void release( ScColumn& rColumn, SCROW nRow );
78 bool hasString() const;
80 bool hasNumeric() const;
82 bool isEmpty() const;
84 bool equalsWithoutFormat( const ScCellValue& r ) const;
86 ScCellValue& operator= ( const ScCellValue& r );
88 void swap( ScCellValue& r );
91 /**
92 * This is very similar to ScCellValue, except that it references the
93 * original value instead of copying it. As such, don't hold an instance of
94 * this class any longer than necessary, and absolutely not after the
95 * original cell has been destroyed.
97 struct SC_DLLPUBLIC ScRefCellValue
99 CellType meType;
100 union {
101 double mfValue;
102 const OUString* mpString;
103 const EditTextObject* mpEditText;
104 ScFormulaCell* mpFormula;
107 ScRefCellValue();
108 ScRefCellValue( double fValue );
109 ScRefCellValue( const OUString* pString );
110 ScRefCellValue( const EditTextObject* pEditText );
111 ScRefCellValue( ScFormulaCell* pFormula );
112 ScRefCellValue( const ScRefCellValue& r );
113 ~ScRefCellValue();
115 void clear();
118 * Take cell value from specified position in specified document.
120 void assign( ScDocument& rDoc, const ScAddress& rPos );
123 * TODO: Remove this later.
125 void assign( ScBaseCell& rCell );
128 * Set cell value at specified position in specified document.
130 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
132 bool hasString() const;
134 bool hasNumeric() const;
136 double getValue();
138 /** Retrieve string value.
140 @param pDoc
141 Needed to resolve EditCells' field contents, obtain a
142 ScFieldEditEngine from that document. May be NULL if there is
143 no ScDocument in the calling context but then the document
144 specific fields can not be resolved. See
145 ScEditUtil::GetString().
147 OUString getString( const ScDocument* pDoc );
149 bool isEmpty() const;
151 bool hasEmptyValue();
153 bool equalsWithoutFormat( const ScRefCellValue& r ) const;
155 ScRefCellValue& operator= ( const ScRefCellValue& r );
157 void swap( ScRefCellValue& r );
160 #endif
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */