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
;
22 struct ColumnBlockPosition
;
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
41 svl::SharedString
* mpString
;
42 EditTextObject
* mpEditText
;
43 ScFormulaCell
* mpFormula
;
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
;
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
);
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
);
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;
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;
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
);
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
109 const svl::SharedString
* mpString
;
110 const EditTextObject
* mpEditText
;
111 ScFormulaCell
* mpFormula
;
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
);
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;
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.
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;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */