Bump version to 4.3-4
[LibreOffice.git] / sc / inc / cellvalue.hxx
blob9154e30ddacd0d4a6861e8a63eae3ea078f3fa46
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 INCLUDED_SC_INC_CELLVALUE_HXX
11 #define INCLUDED_SC_INC_CELLVALUE_HXX
13 #include "global.hxx"
15 class ScDocument;
16 class ScFormulaCell;
17 class EditTextObject;
18 class ScColumn;
19 struct ScRefCellValue;
21 namespace svl {
23 class SharedString;
27 /**
28 * Store arbitrary cell value of any kind. It only stores cell value and
29 * nothing else. It creates a copy of the original cell value, and manages
30 * the life cycle of the copied value.
32 struct SC_DLLPUBLIC ScCellValue
34 CellType meType;
35 union {
36 double mfValue;
37 svl::SharedString* mpString;
38 EditTextObject* mpEditText;
39 ScFormulaCell* mpFormula;
42 ScCellValue();
43 ScCellValue( const ScRefCellValue& rCell );
44 ScCellValue( double fValue );
45 ScCellValue( const svl::SharedString& rString );
46 ScCellValue( const ScCellValue& r );
47 ~ScCellValue();
49 void clear();
51 void set( const ScRefCellValue& rCell );
52 void set( double fValue );
53 void set( const svl::SharedString& rStr );
54 void set( const EditTextObject& rEditText );
55 void set( EditTextObject* pEditText );
56 void set( ScFormulaCell* pFormula );
58 /**
59 * Take cell value from specified position in specified document.
61 void assign( const ScDocument& rDoc, const ScAddress& rPos );
63 void assign( const ScCellValue& rOther, ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT );
65 /**
66 * Set cell value at specified position in specified document.
68 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
70 void commit( ScColumn& rColumn, SCROW nRow ) const;
72 /**
73 * Set cell value at specified position in specified document. But unlike
74 * commit(), this method sets the original value to the document without
75 * copying. After this call, the value gets cleared.
77 void release( ScDocument& rDoc, const ScAddress& rPos );
79 void release( ScColumn& rColumn, SCROW nRow );
81 OUString getString( const ScDocument* pDoc );
83 bool isEmpty() const;
85 bool equalsWithoutFormat( const ScCellValue& r ) const;
87 ScCellValue& operator= ( const ScCellValue& r );
88 ScCellValue& operator= ( const ScRefCellValue& r );
90 void swap( ScCellValue& r );
93 /**
94 * This is very similar to ScCellValue, except that it references the
95 * original value instead of copying it. As such, don't hold an instance of
96 * this class any longer than necessary, and absolutely not after the
97 * original cell has been destroyed.
99 struct SC_DLLPUBLIC ScRefCellValue
101 CellType meType;
102 union {
103 double mfValue;
104 const svl::SharedString* mpString;
105 const EditTextObject* mpEditText;
106 ScFormulaCell* mpFormula;
109 ScRefCellValue();
110 ScRefCellValue( double fValue );
111 ScRefCellValue( const svl::SharedString* pString );
112 ScRefCellValue( const EditTextObject* pEditText );
113 ScRefCellValue( ScFormulaCell* pFormula );
114 ScRefCellValue( const ScRefCellValue& r );
115 ~ScRefCellValue();
117 void clear();
120 * Take cell value from specified position in specified document.
122 void assign( ScDocument& rDoc, const ScAddress& rPos );
125 * Set cell value at specified position in specified document.
127 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
129 bool hasString() const;
131 bool hasNumeric() const;
133 double getValue();
135 /** Retrieve string value.
137 @param pDoc
138 Needed to resolve EditCells' field contents, obtain a
139 ScFieldEditEngine from that document. May be NULL if there is
140 no ScDocument in the calling context but then the document
141 specific fields can not be resolved. See
142 ScEditUtil::GetString().
144 OUString getString( const ScDocument* pDoc );
146 bool isEmpty() const;
148 bool hasEmptyValue();
150 bool equalsWithoutFormat( const ScRefCellValue& r ) const;
152 ScRefCellValue& operator= ( const ScRefCellValue& r );
154 void swap( ScRefCellValue& r );
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */