nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / cellvalue.hxx
blob5dfe66ba276391e0efa2493765e2329d71efb261
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 sc {
22 struct ColumnBlockPosition;
25 namespace svl {
27 class SharedString;
31 /**
32 * Store arbitrary cell value of any kind. It only stores cell value and
33 * nothing else. It creates a copy of the original cell value, and manages
34 * the life cycle of the copied value.
36 struct SC_DLLPUBLIC ScCellValue
38 CellType meType;
39 union {
40 double mfValue;
41 svl::SharedString* mpString;
42 EditTextObject* mpEditText;
43 ScFormulaCell* mpFormula;
46 ScCellValue();
47 ScCellValue( const ScRefCellValue& rCell );
48 ScCellValue( double fValue );
49 ScCellValue( const svl::SharedString& rString );
50 ScCellValue( const ScCellValue& r );
51 ScCellValue(ScCellValue&& r) noexcept;
52 ~ScCellValue();
54 void clear() noexcept;
56 void set( double fValue );
57 void set( const svl::SharedString& rStr );
58 void set( const EditTextObject& rEditText );
59 void set( EditTextObject* pEditText );
60 void set( ScFormulaCell* pFormula );
62 /**
63 * Take cell value from specified position in specified document.
65 void assign( const ScDocument& rDoc, const ScAddress& rPos );
67 void assign(const ScCellValue& rOther, ScDocument& rDestDoc, ScCloneFlags nCloneFlags = ScCloneFlags::Default);
69 /**
70 * Set cell value at specified position in specified document.
72 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
74 void commit( ScColumn& rColumn, SCROW nRow ) const;
76 /**
77 * Set cell value at specified position in specified document. But unlike
78 * commit(), this method sets the original value to the document without
79 * copying. After this call, the value gets cleared.
81 void release( ScDocument& rDoc, const ScAddress& rPos );
83 void release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType eListenType = sc::SingleCellListening );
85 OUString getString( const ScDocument& rDoc ) const;
87 bool isEmpty() const;
89 bool equalsWithoutFormat( const ScCellValue& r ) const;
91 ScCellValue& operator= ( const ScCellValue& r );
92 ScCellValue& operator=(ScCellValue&& r) noexcept;
93 ScCellValue& operator= ( const ScRefCellValue& r );
95 void swap( ScCellValue& r );
98 /**
99 * This is very similar to ScCellValue, except that it references the
100 * original value instead of copying it. As such, don't hold an instance of
101 * this class any longer than necessary, and absolutely not after the
102 * original cell has been destroyed.
104 struct SC_DLLPUBLIC ScRefCellValue
106 CellType meType;
107 union {
108 double mfValue;
109 const svl::SharedString* mpString;
110 const EditTextObject* mpEditText;
111 ScFormulaCell* mpFormula;
114 ScRefCellValue();
115 ScRefCellValue( double fValue );
116 ScRefCellValue( const svl::SharedString* pString );
117 ScRefCellValue( const EditTextObject* pEditText );
118 ScRefCellValue( ScFormulaCell* pFormula );
121 * Take cell value from specified position in specified document.
123 ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos );
124 ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
126 void clear();
129 * Take cell value from specified position in specified document.
131 void assign( ScDocument& rDoc, const ScAddress& rPos );
132 void assign( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
135 * Set cell value at specified position in specified document.
137 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
139 bool hasString() const;
141 bool hasNumeric() const;
143 bool hasError() const;
145 double getValue();
148 * Retrieve a numeric value without modifying the states of any objects in
149 * the referenced document store.
151 double getRawValue() const;
154 * Retrieve string value.
156 * Note that this method is NOT thread-safe.
158 * @param pDoc
159 * Needed to resolve EditCells' field contents, obtain a
160 * ScFieldEditEngine from that document. May be NULL if there is
161 * no ScDocument in the calling context but then the document
162 * specific fields can not be resolved. See
163 * ScEditUtil::GetString().
165 OUString getString( const ScDocument* pDoc ) const;
168 * Retrieve a string value without modifying the states of any objects in
169 * the referenced document store.
171 * This method is thread-safe.
173 OUString getRawString( const ScDocument& rDoc ) const;
175 bool isEmpty() const;
177 bool hasEmptyValue();
179 bool equalsWithoutFormat( const ScRefCellValue& r ) const;
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */