LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / cellvalue.hxx
blob3cd1bb8710cfccea291bf3b0dc2ab1d5ccf4ff1a
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 #pragma once
12 #include "global.hxx"
14 class ScDocument;
15 class ScFormulaCell;
16 class EditTextObject;
17 class ScColumn;
18 struct ScRefCellValue;
20 namespace sc {
21 struct ColumnBlockPosition;
24 namespace svl {
26 class SharedString;
30 /**
31 * Store arbitrary cell value of any kind. It only stores cell value and
32 * nothing else. It creates a copy of the original cell value, and manages
33 * the life cycle of the copied value.
35 struct SC_DLLPUBLIC ScCellValue
37 CellType meType;
38 union {
39 double mfValue;
40 svl::SharedString* mpString;
41 EditTextObject* mpEditText;
42 ScFormulaCell* mpFormula;
45 ScCellValue();
46 ScCellValue( const ScRefCellValue& rCell );
47 ScCellValue( double fValue );
48 ScCellValue( const svl::SharedString& rString );
49 ScCellValue( const ScCellValue& r );
50 ScCellValue(ScCellValue&& r) noexcept;
51 ~ScCellValue();
53 void clear() noexcept;
55 void set( double fValue );
56 void set( const svl::SharedString& rStr );
57 void set( const EditTextObject& rEditText );
58 void set( EditTextObject* pEditText );
59 void set( ScFormulaCell* pFormula );
61 /**
62 * Take cell value from specified position in specified document.
64 void assign( const ScDocument& rDoc, const ScAddress& rPos );
66 void assign(const ScCellValue& rOther, ScDocument& rDestDoc, ScCloneFlags nCloneFlags = ScCloneFlags::Default);
68 /**
69 * Set cell value at specified position in specified document.
71 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
73 void commit( ScColumn& rColumn, SCROW nRow ) const;
75 /**
76 * Set cell value at specified position in specified document. But unlike
77 * commit(), this method sets the original value to the document without
78 * copying. After this call, the value gets cleared.
80 void release( ScDocument& rDoc, const ScAddress& rPos );
82 void release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType eListenType = sc::SingleCellListening );
84 OUString getString( const ScDocument& rDoc ) const;
86 bool isEmpty() const;
88 bool equalsWithoutFormat( const ScCellValue& r ) const;
90 ScCellValue& operator= ( const ScCellValue& r );
91 ScCellValue& operator=(ScCellValue&& r) noexcept;
92 ScCellValue& operator= ( const ScRefCellValue& r );
94 void swap( ScCellValue& r );
97 /**
98 * This is very similar to ScCellValue, except that it references the
99 * original value instead of copying it. As such, don't hold an instance of
100 * this class any longer than necessary, and absolutely not after the
101 * original cell has been destroyed.
103 struct SC_DLLPUBLIC ScRefCellValue
105 CellType meType;
106 union {
107 double mfValue;
108 const svl::SharedString* mpString;
109 const EditTextObject* mpEditText;
110 ScFormulaCell* mpFormula;
113 ScRefCellValue();
114 ScRefCellValue( double fValue );
115 ScRefCellValue( const svl::SharedString* pString );
116 ScRefCellValue( const EditTextObject* pEditText );
117 ScRefCellValue( ScFormulaCell* pFormula );
120 * Take cell value from specified position in specified document.
122 ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos );
123 ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
125 void clear();
128 * Take cell value from specified position in specified document.
130 void assign( ScDocument& rDoc, const ScAddress& rPos );
131 void assign( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
134 * Set cell value at specified position in specified document.
136 void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
138 bool hasString() const;
140 bool hasNumeric() const;
142 bool hasError() const;
144 double getValue();
147 * Retrieve a numeric value without modifying the states of any objects in
148 * the referenced document store.
150 double getRawValue() const;
153 * Retrieve string value.
155 * Note that this method is NOT thread-safe.
157 * @param pDoc
158 * Needed to resolve EditCells' field contents, obtain a
159 * ScFieldEditEngine from that document. May be NULL if there is
160 * no ScDocument in the calling context but then the document
161 * specific fields can not be resolved. See
162 * ScEditUtil::GetString().
164 OUString getString( const ScDocument* pDoc ) const;
167 * Retrieve a string value without modifying the states of any objects in
168 * the referenced document store.
170 * This method is thread-safe.
172 OUString getRawString( const ScDocument& rDoc ) const;
174 bool isEmpty() const;
176 bool hasEmptyValue();
178 bool equalsWithoutFormat( const ScRefCellValue& r ) const;
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */