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
);
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
);
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
);
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
);
81 OUString
getString( const ScDocument
* pDoc
);
85 bool equalsWithoutFormat( const ScCellValue
& r
) const;
87 ScCellValue
& operator= ( const ScCellValue
& r
);
88 ScCellValue
& operator= ( const ScRefCellValue
& r
);
90 void swap( ScCellValue
& r
);
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
104 const svl::SharedString
* mpString
;
105 const EditTextObject
* mpEditText
;
106 ScFormulaCell
* mpFormula
;
110 ScRefCellValue( double fValue
);
111 ScRefCellValue( const svl::SharedString
* pString
);
112 ScRefCellValue( const EditTextObject
* pEditText
);
113 ScRefCellValue( ScFormulaCell
* pFormula
);
114 ScRefCellValue( const ScRefCellValue
& r
);
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;
135 /** Retrieve string value.
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
);
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */