STOFFCell.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3/* libstaroffice
4* Version: MPL 2.0 / LGPLv2+
5*
6* The contents of this file are subject to the Mozilla Public License Version
7* 2.0 (the "License"); you may not use this file except in compliance with
8* the License or as specified alternatively below. You may obtain a copy of
9* the License at http://www.mozilla.org/MPL/
10*
11* Software distributed under the License is distributed on an "AS IS" basis,
12* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13* for the specific language governing rights and limitations under the
14* License.
15*
16* Major Contributor(s):
17* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22*
23*
24* All Rights Reserved.
25*
26* For minor contributions see the git repository.
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30* in which case the provisions of the LGPLv2+ are applicable
31* instead of those above.
32*/
33
38#ifndef STOFF_CELL_H
39# define STOFF_CELL_H
40
41#include <string>
42#include <vector>
43
45
46#include "STOFFEntry.hxx"
47#include "STOFFFont.hxx"
48#include "STOFFCellStyle.hxx"
49
50class STOFFTable;
51
54{
55public:
61 struct Format {
69 virtual ~Format();
71 bool hasBasicFormat() const
72 {
74 }
76 std::string getValueType() const;
78 static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector);
80 friend std::ostream &operator<<(std::ostream &o, Format const &format);
81
86 };
89 : m_position(0,0)
90 , m_bdBox()
91 , m_bdSize()
92 , m_format()
93 , m_font()
94 , m_cellStyle()
95 , m_numberingStyle() { }
96
98 virtual ~STOFFCell() {}
99
101 void addTo(librevenge::RVNGPropertyList &propList) const;
102
104 friend std::ostream &operator<<(std::ostream &o, STOFFCell const &cell);
105
106 // interface with STOFFTable:
107
112 virtual bool send(STOFFListenerPtr listener, STOFFTable &table);
117 virtual bool sendContent(STOFFListenerPtr listener, STOFFTable &table);
118
119 // position
120
122 STOFFVec2i const &position() const
123 {
124 return m_position;
125 }
128 {
129 m_position = posi;
130 }
131
133 STOFFBox2f const &bdBox() const
134 {
135 return m_bdBox;
136 }
139 {
140 m_bdBox = box;
141 }
142
144 STOFFVec2f const &bdSize() const
145 {
146 return m_bdSize;
147 }
150 {
151 m_bdSize = sz;
152 }
153
155 static std::string getCellName(STOFFVec2i const &pos, STOFFVec2b const &absolute);
156
158 static std::string getColumnName(int col);
159
160 // format
161
163 Format const &getFormat() const
164 {
165 return m_format;
166 }
168 void setFormat(Format const &format)
169 {
170 m_format=format;
171 }
172
174 STOFFFont const &getFont() const
175 {
176 return m_font;
177 }
179 void setFont(STOFFFont const &font)
180 {
181 m_font=font;
182 }
183
186 {
187 return m_cellStyle;
188 }
191 {
192 return m_cellStyle;
193 }
195 void setCellStyle(STOFFCellStyle const &cellStyle)
196 {
197 m_cellStyle=cellStyle;
198 }
199
201 librevenge::RVNGPropertyList const &getNumberingStyle() const
202 {
203 return m_numberingStyle;
204 }
206 librevenge::RVNGPropertyList &getNumberingStyle()
207 {
208 return m_numberingStyle;
209 }
211 void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
212 {
213 m_numberingStyle=numberStyle;
214 }
215protected:
222
230 librevenge::RVNGPropertyList m_numberingStyle;
231};
232
235{
236public:
242 m_sheetId(-1), m_sheetIdRelative(false), m_extra("")
243 {
244 for (int i=0; i<2; ++i) {
245 m_position[i]=STOFFVec2i(0,0);
246 m_positionRelative[i]=STOFFVec2b(false,false);
247 }
248 }
250 librevenge::RVNGPropertyList getPropertyList() const;
252 friend std::ostream &operator<<(std::ostream &o, FormulaInstruction const &inst);
256 librevenge::RVNGString m_content;
266 librevenge::RVNGString m_sheet;
272 std::string m_extra;
273 };
274
282 friend std::ostream &operator<<(std::ostream &o, STOFFCellContent const &cell);
283
285 bool empty() const
286 {
287 if (m_contentType == C_NUMBER || m_contentType == C_TEXT) return false;
288 if (m_contentType == C_TEXT_BASIC && !m_text.empty()) return false;
289 if (m_contentType == C_FORMULA && (m_formula.size() || isValueSet())) return false;
290 return true;
291 }
293 void setValue(double value)
294 {
295 m_value = value;
296 m_valueSet = true;
297 }
299 bool isValueSet() const
300 {
301 return m_valueSet;
302 }
304 bool hasText() const
305 {
306 return m_contentType == C_TEXT || !m_text.empty();
307 }
310 static bool double2Date(double val, int &Y, int &M, int &D);
312 static bool double2Time(double val, int &H, int &M, int &S);
314 static bool date2Double(int Y, int M, int D, double &val);
318 double m_value;
322 std::vector<uint32_t> m_text;
324 std::vector<FormulaInstruction> m_formula;
325};
326
327#endif
328// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
small class use to define a sheet cell content
Definition STOFFCell.hxx:235
STOFFCellContent()
constructor
Definition STOFFCell.hxx:278
bool isValueSet() const
returns true if the value has been setted
Definition STOFFCell.hxx:299
Type
the different types of cell's field
Definition STOFFCell.hxx:276
@ C_NUMBER
Definition STOFFCell.hxx:276
@ C_NONE
Definition STOFFCell.hxx:276
@ C_TEXT
Definition STOFFCell.hxx:276
@ C_FORMULA
Definition STOFFCell.hxx:276
@ C_UNKNOWN
Definition STOFFCell.hxx:276
@ C_TEXT_BASIC
Definition STOFFCell.hxx:276
~STOFFCellContent()
destructor
Definition STOFFCell.hxx:280
static bool double2Date(double val, int &Y, int &M, int &D)
conversion beetween double days since 1900 and a date, ie val=0 corresponds to 1/1/1900,...
Definition STOFFCell.cxx:302
bool empty() const
returns true if the cell has no content
Definition STOFFCell.hxx:285
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition STOFFCell.hxx:324
Type m_contentType
the content type ( by default unknown )
Definition STOFFCell.hxx:316
static bool double2Time(double val, int &H, int &M, int &S)
conversion beetween double: second since 0:00 and time
Definition STOFFCell.cxx:382
bool m_valueSet
true if the value has been set
Definition STOFFCell.hxx:320
friend std::ostream & operator<<(std::ostream &o, STOFFCellContent const &cell)
operator<<
Definition STOFFCell.cxx:394
std::vector< uint32_t > m_text
the text value (for C_TEXT_BASIC)
Definition STOFFCell.hxx:322
bool hasText() const
returns true if the text is set
Definition STOFFCell.hxx:304
void setValue(double value)
sets the double value
Definition STOFFCell.hxx:293
static bool date2Double(int Y, int M, int D, double &val)
conversion beetween date and double days since 1900 date
Definition STOFFCell.cxx:352
double m_value
the cell value
Definition STOFFCell.hxx:318
Class to store a cell style.
Definition STOFFCellStyle.hxx:44
a structure used to define a cell and its format
Definition STOFFCell.hxx:54
friend std::ostream & operator<<(std::ostream &o, STOFFCell const &cell)
operator<<
Definition STOFFCell.cxx:272
Format const & getFormat() const
returns the cell format
Definition STOFFCell.hxx:163
librevenge::RVNGPropertyList const & getNumberingStyle() const
returns the numbering style
Definition STOFFCell.hxx:201
librevenge::RVNGPropertyList m_numberingStyle
the numbering style
Definition STOFFCell.hxx:230
STOFFCellStyle const & getCellStyle() const
returns the cell style
Definition STOFFCell.hxx:185
void setBdBox(STOFFBox2f box)
set the bdbox (unit point)
Definition STOFFCell.hxx:138
static std::string getCellName(STOFFVec2i const &pos, STOFFVec2b const &absolute)
return the name of a cell (given row and column) : 0,0 -> A1, 0,1 -> A2
Definition STOFFCell.cxx:265
librevenge::RVNGPropertyList & getNumberingStyle()
returns the numbering style
Definition STOFFCell.hxx:206
FormatType
the different format of a cell's content
Definition STOFFCell.hxx:57
@ F_UNKNOWN
Definition STOFFCell.hxx:57
@ F_TIME
Definition STOFFCell.hxx:57
@ F_DATETIME
Definition STOFFCell.hxx:57
@ F_NUMBER
Definition STOFFCell.hxx:57
@ F_TEXT
Definition STOFFCell.hxx:57
@ F_DATE
Definition STOFFCell.hxx:57
@ F_BOOLEAN
Definition STOFFCell.hxx:57
void setPosition(STOFFVec2i posi)
set the cell positions : 0,0 -> A1, 0,1 -> A2
Definition STOFFCell.hxx:127
STOFFVec2f const & bdSize() const
bdbox size accessor
Definition STOFFCell.hxx:144
static std::string getColumnName(int col)
return the column name
Definition STOFFCell.cxx:255
STOFFBox2f const & bdBox() const
bdbox accessor
Definition STOFFCell.hxx:133
void addTo(librevenge::RVNGPropertyList &propList) const
adds to the propList
Definition STOFFCell.cxx:246
NumberType
the different number format of a cell's content
Definition STOFFCell.hxx:59
@ F_NUMBER_PERCENT
Definition STOFFCell.hxx:59
@ F_NUMBER_DECIMAL
Definition STOFFCell.hxx:59
@ F_NUMBER_FRACTION
Definition STOFFCell.hxx:59
@ F_NUMBER_GENERIC
Definition STOFFCell.hxx:59
@ F_NUMBER_UNKNOWN
Definition STOFFCell.hxx:59
@ F_NUMBER_CURRENCY
Definition STOFFCell.hxx:59
@ F_NUMBER_SCIENTIFIC
Definition STOFFCell.hxx:59
virtual bool sendContent(STOFFListenerPtr listener, STOFFTable &table)
function called when the content of a cell must be send to the listener, ie.
Definition STOFFCell.cxx:293
void setFormat(Format const &format)
set the cell format
Definition STOFFCell.hxx:168
STOFFCellStyle & getCellStyle()
returns the cell style
Definition STOFFCell.hxx:190
void setCellStyle(STOFFCellStyle const &cellStyle)
set the cell style
Definition STOFFCell.hxx:195
STOFFFont m_font
the cell font
Definition STOFFCell.hxx:226
STOFFFont const & getFont() const
returns the font
Definition STOFFCell.hxx:174
STOFFCellStyle m_cellStyle
the cell cell style
Definition STOFFCell.hxx:228
virtual bool send(STOFFListenerPtr listener, STOFFTable &table)
function called when a cell is send by STOFFTable to send a cell to a listener.
Definition STOFFCell.cxx:284
STOFFBox2f m_bdBox
the cell bounding box (unit in point)
Definition STOFFCell.hxx:219
STOFFVec2f m_bdSize
the cell bounding size : unit point
Definition STOFFCell.hxx:221
void setFont(STOFFFont const &font)
set the font
Definition STOFFCell.hxx:179
virtual ~STOFFCell()
destructor
Definition STOFFCell.hxx:98
void setBdSize(STOFFVec2f sz)
set the bdbox size(unit point)
Definition STOFFCell.hxx:149
Format m_format
the cell format
Definition STOFFCell.hxx:224
STOFFCell()
constructor
Definition STOFFCell.hxx:88
STOFFVec2i m_position
the cell row and column : 0,0 -> A1, 0,1 -> A2
Definition STOFFCell.hxx:217
STOFFVec2i const & position() const
position accessor
Definition STOFFCell.hxx:122
void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
set the numbering style
Definition STOFFCell.hxx:211
Class to store font.
Definition STOFFFont.hxx:44
a class used to recreate the table structure using cell informations, ....
Definition STOFFTable.hxx:52
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition libstaroffice_internal.hxx:491
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition libstaroffice_internal.hxx:767
STOFFVec2< bool > STOFFVec2b
STOFFVec2 of bool.
Definition libstaroffice_internal.hxx:765
small class use to define a formula instruction
Definition STOFFCell.hxx:238
bool m_sheetIdRelative
the sheet id relative flag
Definition STOFFCell.hxx:270
STOFFVec2b m_positionRelative[2]
relative cell position ( if type==F_Cell or F_CellList )
Definition STOFFCell.hxx:264
double m_doubleValue
value ( if type==F_Double )
Definition STOFFCell.hxx:260
Type m_type
the type
Definition STOFFCell.hxx:254
Type
Definition STOFFCell.hxx:239
@ F_Text
Definition STOFFCell.hxx:239
@ F_Long
Definition STOFFCell.hxx:239
@ F_Function
Definition STOFFCell.hxx:239
@ F_Cell
Definition STOFFCell.hxx:239
@ F_Double
Definition STOFFCell.hxx:239
@ F_None
Definition STOFFCell.hxx:239
@ F_Index
Definition STOFFCell.hxx:239
@ F_CellList
Definition STOFFCell.hxx:239
@ F_Operator
Definition STOFFCell.hxx:239
librevenge::RVNGString m_sheet
the sheet name (if not empty)
Definition STOFFCell.hxx:266
friend std::ostream & operator<<(std::ostream &o, FormulaInstruction const &inst)
operator<<
Definition STOFFCell.cxx:486
std::string m_extra
extra data
Definition STOFFCell.hxx:272
librevenge::RVNGString m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition STOFFCell.hxx:256
FormulaInstruction()
constructor
Definition STOFFCell.hxx:241
STOFFVec2i m_position[2]
cell position ( if type==F_Cell or F_CellList )
Definition STOFFCell.hxx:262
long m_longValue
value ( if type==F_Long )
Definition STOFFCell.hxx:258
librevenge::RVNGPropertyList getPropertyList() const
returns a proplist corresponding to a instruction
Definition STOFFCell.cxx:424
int m_sheetId
the sheet id (if set)
Definition STOFFCell.hxx:268
a structure uses to define the format of a cell content
Definition STOFFCell.hxx:61
NumberType m_numberFormat
the numeric format
Definition STOFFCell.hxx:85
std::string getValueType() const
returns a value type
Definition STOFFCell.cxx:58
virtual ~Format()
destructor
Definition STOFFCell.cxx:54
Format()
constructor
Definition STOFFCell.hxx:63
friend std::ostream & operator<<(std::ostream &o, Format const &format)
operator<<
Definition STOFFCell.cxx:189
bool hasBasicFormat() const
returns true if this is a basic format style
Definition STOFFCell.hxx:71
static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector)
convert a DTFormat in a propertyList
Definition STOFFCell.cxx:81
FormatType m_format
the cell format : by default unknown
Definition STOFFCell.hxx:83

Generated on Mon Apr 22 2024 12:48:55 for libstaroffice by doxygen 1.10.0