1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_SC_INC_CELLVALUE_HXX
11 #define INCLUDED_SC_INC_CELLVALUE_HXX
19 struct ScRefCellValue
;
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
37 svl::SharedString
* mpString
;
38 EditTextObject
* mpEditText
;
39 ScFormulaCell
* mpFormula
;
43 ScCellValue( const ScRefCellValue
& rCell
);
44 ScCellValue( double fValue
);
45 ScCellValue( const svl::SharedString
& rString
);
46 ScCellValue( const ScCellValue
& r
);
47 ScCellValue( ScCellValue
&& r
);
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
);
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
, ScCloneFlags nCloneFlags
= ScCloneFlags::Default
);
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;
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
, sc::StartListeningType eListenType
= sc::SingleCellListening
);
81 OUString
getString( const ScDocument
* pDoc
);
85 bool equalsWithoutFormat( const ScCellValue
& r
) const;
87 ScCellValue
& operator= ( const ScCellValue
& r
);
88 ScCellValue
& operator= ( ScCellValue
&& r
);
89 ScCellValue
& operator= ( const ScRefCellValue
& r
);
91 void swap( ScCellValue
& r
);
95 * This is very similar to ScCellValue, except that it references the
96 * original value instead of copying it. As such, don't hold an instance of
97 * this class any longer than necessary, and absolutely not after the
98 * original cell has been destroyed.
100 struct SC_DLLPUBLIC ScRefCellValue
105 const svl::SharedString
* mpString
;
106 const EditTextObject
* mpEditText
;
107 ScFormulaCell
* mpFormula
;
111 ScRefCellValue( double fValue
);
112 ScRefCellValue( const svl::SharedString
* pString
);
113 ScRefCellValue( const EditTextObject
* pEditText
);
114 ScRefCellValue( ScFormulaCell
* pFormula
);
117 * Take cell value from specified position in specified document.
119 ScRefCellValue( ScDocument
& rDoc
, const ScAddress
& rPos
);
124 * Take cell value from specified position in specified document.
126 void assign( ScDocument
& rDoc
, const ScAddress
& rPos
);
129 * Set cell value at specified position in specified document.
131 void commit( ScDocument
& rDoc
, const ScAddress
& rPos
) const;
133 bool hasString() const;
135 bool hasNumeric() const;
137 bool hasError() const;
142 * Retrieve a numeric value without modifying the states of any objects in
143 * the referenced document store.
145 double getRawValue() const;
148 * Retrieve string value.
150 * Note that this method is NOT thread-safe.
153 * Needed to resolve EditCells' field contents, obtain a
154 * ScFieldEditEngine from that document. May be NULL if there is
155 * no ScDocument in the calling context but then the document
156 * specific fields can not be resolved. See
157 * ScEditUtil::GetString().
159 OUString
getString( const ScDocument
* pDoc
);
162 * Retrieve a string value without modifying the states of any objects in
163 * the referenced document store.
165 * This method is thread-safe.
167 OUString
getRawString( const ScDocument
* pDoc
) const;
169 bool isEmpty() const;
171 bool hasEmptyValue();
173 bool equalsWithoutFormat( const ScRefCellValue
& r
) const;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */