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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
26 #include "tools/mempool.hxx"
28 #include <boost/shared_ptr.hpp>
42 ~ScBaseCell(); // not virtual - not to be called directly.
45 explicit ScBaseCell( CellType eNewType
);
47 /** Base copy constructor. Does NOT clone cell note or broadcaster! */
48 ScBaseCell( const ScBaseCell
& rCell
);
50 /** Returns a clone of this cell at the same position,
51 broadcaster will not be cloned. */
52 ScBaseCell
* Clone( ScDocument
& rDestDoc
, int nCloneFlags
= SC_CLONECELL_DEFAULT
) const;
54 /** Returns a clone of this cell for the passed document position,
55 broadcaster will not be cloned. */
56 ScBaseCell
* Clone( ScDocument
& rDestDoc
, const ScAddress
& rDestPos
, int nCloneFlags
= SC_CLONECELL_DEFAULT
) const;
58 /** Due to the fact that ScBaseCell does not have a vtable, this function
59 deletes the cell by calling the appropriate d'tor of the derived class. */
62 inline CellType
GetCellType() const { return (CellType
)eCellType
; }
64 /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been
65 created due to reference to empty cell). */
66 bool HasEmptyData() const;
67 bool HasValueData() const;
68 bool HasStringData() const;
69 OUString
GetStringData() const; // only real strings
72 ScBaseCell
& operator=( const ScBaseCell
& );
75 sal_uInt8 eCellType
; // enum CellType - sal_uInt8 spart Speicher
78 class ScValueCell
: public ScBaseCell
82 DECL_FIXEDMEMPOOL_NEWDEL( ScValueCell
)
85 explicit ScValueCell( double fValue
);
87 #if OSL_DEBUG_LEVEL > 0
91 inline void SetValue( double fValue
) { mfValue
= fValue
; }
92 inline double GetValue() const { return mfValue
; }
93 double* GetValuePtr() { return &mfValue
; }
99 class ScStringCell
: public ScBaseCell
103 DECL_FIXEDMEMPOOL_NEWDEL( ScStringCell
)
106 explicit ScStringCell(const OUString
& rString
);
108 #if OSL_DEBUG_LEVEL > 0
112 inline void SetString( const OUString
& rString
) { maString
= rString
; }
113 inline const OUString
& GetString() const { return maString
; }
114 const OUString
* GetStringPtr() const { return &maString
; }
120 class ScEditCell
: public ScBaseCell
122 EditTextObject
* mpData
;
123 mutable OUString
* mpString
; // for faster access to formulas
124 ScDocument
* mpDoc
; // for EditEngine access with Pool
126 void SetTextObject( const EditTextObject
* pObject
,
127 const SfxItemPool
* pFromPool
);
130 ScEditCell( const ScEditCell
& );
135 DECL_FIXEDMEMPOOL_NEWDEL( ScEditCell
)
138 ~ScEditCell(); // always because of pData!
141 * Constructor that takes ownership of the passed EditTextObject instance
142 * which the caller must not delete afterward!
144 * <p>Also ensure that the passed edit text object <i>uses the SfxItemPool
145 * instance returned from ScDocument::GetEditPool()</i>. This is
148 ScEditCell(EditTextObject
* pObject
, ScDocument
* pDoc
);
151 * Constructor. The caller is responsible for deleting the text object
152 * instance passed on to this constructor, since it creates a clone and
153 * stores it instead of the original.
155 * @param rObject text object to clone from.
156 * @param pDoc pointer to the document instance.
157 * @param pFromPool pointer to SfxItemPool instance that the new text
158 * object that is to be stored in the cell instance
159 * should use. If it's NULL, it uses the default pool
160 * for edit cells from the document instance (one
161 * returned from GetEditPool()).
163 ScEditCell(const EditTextObject
& rObject
, ScDocument
* pDoc
, const SfxItemPool
* pFromPool
);
164 ScEditCell(const ScEditCell
& rCell
, ScDocument
& rDoc
, const ScAddress
& rDestPos
);
167 ScEditCell(const OUString
& rString
, ScDocument
* pDoc
);
170 * Remove the text data as well as string cache.
175 * Set new text data. This method clones the passed text data and stores
176 * the clone; the caller is responsible for deleting the text data
177 * instance after the call.
179 * @param rObject text object to clone from.
180 * @param pFromPool pointer to SfxItemPool instance that the new text
181 * object that is to be stored in the cell instance
182 * should use. If it's NULL, it uses the default pool
183 * for edit cells from the document instance (one
184 * returned from GetEditPool()).
186 void SetData(const EditTextObject
& rObject
, const SfxItemPool
* pFromPool
);
189 * Set new text data. The passed text data instance will be owned by the
190 * cell. The caller must ensure that the text data uses the SfxItemPool
191 * instance returned from ScDocument::GetEditPool().
193 void SetData(EditTextObject
* pObject
);
195 OUString
GetString() const;
197 const EditTextObject
* GetData() const;
199 /** Removes character attribute based on new pattern attributes. */
200 void RemoveCharAttribs( const ScPatternAttr
& rAttr
);
202 /** Update field items if any. */
203 void UpdateFields(SCTAB nTab
);
206 class ScEditDataArray
212 explicit Item(SCTAB nTab
, SCCOL nCol
, SCROW nRow
,
213 EditTextObject
* pOldData
, EditTextObject
* pNewData
);
216 const EditTextObject
* GetOldData() const;
217 const EditTextObject
* GetNewData() const;
218 SCTAB
GetTab() const;
219 SCCOL
GetCol() const;
220 SCROW
GetRow() const;
226 ::boost::shared_ptr
<EditTextObject
> mpOldData
;
227 ::boost::shared_ptr
<EditTextObject
> mpNewData
;
237 void AddItem(SCTAB nTab
, SCCOL nCol
, SCROW nRow
,
238 EditTextObject
* pOldData
, EditTextObject
* pNewData
);
244 ::std::vector
<Item
>::const_iterator maIter
;
245 ::std::vector
<Item
> maArray
;
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */