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 
50 class STOFFTable;
51 
53 class STOFFCell
54 {
55 public:
61  struct Format {
63  Format() : m_format(F_UNKNOWN), m_numberFormat(F_NUMBER_UNKNOWN)
64  {
65  }
67  virtual ~Format();
69  bool hasBasicFormat() const
70  {
71  return m_format==F_TEXT || m_format==F_UNKNOWN;
72  }
74  std::string getValueType() const;
76  static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector);
78  friend std::ostream &operator<<(std::ostream &o, Format const &format);
79 
84  };
88 
90  virtual ~STOFFCell() {}
91 
93  void addTo(librevenge::RVNGPropertyList &propList) const;
94 
96  friend std::ostream &operator<<(std::ostream &o, STOFFCell const &cell);
97 
98  // interface with STOFFTable:
99 
104  virtual bool send(STOFFListenerPtr listener, STOFFTable &table);
109  virtual bool sendContent(STOFFListenerPtr listener, STOFFTable &table);
110 
111  // position
112 
114  STOFFVec2i const &position() const
115  {
116  return m_position;
117  }
120  {
121  m_position = posi;
122  }
123 
125  STOFFBox2f const &bdBox() const
126  {
127  return m_bdBox;
128  }
131  {
132  m_bdBox = box;
133  }
134 
136  STOFFVec2f const &bdSize() const
137  {
138  return m_bdSize;
139  }
142  {
143  m_bdSize = sz;
144  }
145 
147  static std::string getCellName(STOFFVec2i const &pos, STOFFVec2b const &absolute);
148 
150  static std::string getColumnName(int col);
151 
152  // format
153 
155  Format const &getFormat() const
156  {
157  return m_format;
158  }
160  void setFormat(Format const &format)
161  {
162  m_format=format;
163  }
164 
166  STOFFFont const &getFont() const
167  {
168  return m_font;
169  }
171  void setFont(STOFFFont const &font)
172  {
173  m_font=font;
174  }
175 
178  {
179  return m_cellStyle;
180  }
183  {
184  return m_cellStyle;
185  }
187  void setCellStyle(STOFFCellStyle const &cellStyle)
188  {
189  m_cellStyle=cellStyle;
190  }
191 
193  librevenge::RVNGPropertyList const &getNumberingStyle() const
194  {
195  return m_numberingStyle;
196  }
198  librevenge::RVNGPropertyList &getNumberingStyle()
199  {
200  return m_numberingStyle;
201  }
203  void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
204  {
205  m_numberingStyle=numberStyle;
206  }
207 protected:
214 
222  librevenge::RVNGPropertyList m_numberingStyle;
223 };
224 
227 {
228 public:
231  enum Type { F_None, F_Operator, F_Function, F_Cell, F_CellList, F_Index, F_Long, F_Double, F_Text };
233  FormulaInstruction() : m_type(F_None), m_content(""), m_longValue(0), m_doubleValue(0), m_sheet(""),
234  m_sheetId(-1), m_sheetIdRelative(false), m_extra("")
235  {
236  for (int i=0; i<2; ++i) {
237  m_position[i]=STOFFVec2i(0,0);
238  m_positionRelative[i]=STOFFVec2b(false,false);
239  }
240  }
242  librevenge::RVNGPropertyList getPropertyList() const;
244  friend std::ostream &operator<<(std::ostream &o, FormulaInstruction const &inst);
248  librevenge::RVNGString m_content;
256  STOFFVec2b m_positionRelative[2];
258  librevenge::RVNGString m_sheet;
264  std::string m_extra;
265  };
266 
268  enum Type { C_NONE, C_TEXT, C_TEXT_BASIC, C_NUMBER, C_FORMULA, C_UNKNOWN };
270  STOFFCellContent() : m_contentType(C_UNKNOWN), m_value(0.0), m_valueSet(false), m_text(), m_formula() { }
274  friend std::ostream &operator<<(std::ostream &o, STOFFCellContent const &cell);
275 
277  bool empty() const
278  {
279  if (m_contentType == C_NUMBER || m_contentType == C_TEXT) return false;
280  if (m_contentType == C_TEXT_BASIC && !m_text.empty()) return false;
281  if (m_contentType == C_FORMULA && (m_formula.size() || isValueSet())) return false;
282  return true;
283  }
285  void setValue(double value)
286  {
287  m_value = value;
288  m_valueSet = true;
289  }
291  bool isValueSet() const
292  {
293  return m_valueSet;
294  }
296  bool hasText() const
297  {
298  return m_contentType == C_TEXT || !m_text.empty();
299  }
302  static bool double2Date(double val, int &Y, int &M, int &D);
304  static bool double2Time(double val, int &H, int &M, int &S);
306  static bool date2Double(int Y, int M, int D, double &val);
310  double m_value;
314  std::vector<uint32_t> m_text;
316  std::vector<FormulaInstruction> m_formula;
317 };
318 
319 #endif
320 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void setCellStyle(STOFFCellStyle const &cellStyle)
set the cell style
Definition: STOFFCell.hxx:187
static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector)
convert a DTFormat in a propertyList
Definition: STOFFCell.cxx:81
Definition: STOFFCell.hxx:59
librevenge::RVNGString m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition: STOFFCell.hxx:248
Format const & getFormat() const
returns the cell format
Definition: STOFFCell.hxx:155
STOFFCellContent()
constructor
Definition: STOFFCell.hxx:270
Definition: STOFFCell.hxx:57
virtual ~STOFFCell()
destructor
Definition: STOFFCell.hxx:90
std::string getValueType() const
returns a value type
Definition: STOFFCell.cxx:58
Definition: STOFFCell.hxx:59
void setValue(double value)
sets the double value
Definition: STOFFCell.hxx:285
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
FormatType
the different format of a cell&#39;s content
Definition: STOFFCell.hxx:57
FormatType m_format
the cell format : by default unknown
Definition: STOFFCell.hxx:81
Definition: STOFFCell.hxx:57
bool hasBasicFormat() const
returns true if this is a basic format style
Definition: STOFFCell.hxx:69
bool hasText() const
returns true if the text is set
Definition: STOFFCell.hxx:296
Definition: STOFFCell.hxx:57
void addTo(librevenge::RVNGPropertyList &propList) const
adds to the propList
Definition: STOFFCell.cxx:243
Type
Definition: STOFFCell.hxx:231
small class use to define a sheet cell content
Definition: STOFFCell.hxx:226
void setFormat(Format const &format)
set the cell format
Definition: STOFFCell.hxx:160
virtual ~Format()
destructor
Definition: STOFFCell.cxx:54
friend std::ostream & operator<<(std::ostream &o, Format const &format)
operator<<
Definition: STOFFCell.cxx:186
int m_sheetId
the sheet id (if set)
Definition: STOFFCell.hxx:260
Definition: STOFFCell.hxx:59
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
Definition: STOFFCell.hxx:59
bool m_valueSet
true if the value has been set
Definition: STOFFCell.hxx:312
STOFFVec2i const & position() const
position accessor
Definition: STOFFCell.hxx:114
double m_value
the cell value
Definition: STOFFCell.hxx:310
STOFFFont m_font
the cell font
Definition: STOFFCell.hxx:218
std::string m_extra
extra data
Definition: STOFFCell.hxx:264
shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition: libstaroffice_internal.hxx:476
STOFFVec2i m_position
the cell row and column : 0,0 -> A1, 0,1 -> A2
Definition: STOFFCell.hxx:209
STOFFCellStyle const & getCellStyle() const
returns the cell style
Definition: STOFFCell.hxx:177
Format()
constructor
Definition: STOFFCell.hxx:63
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition: STOFFCell.hxx:316
void setBdBox(STOFFBox2f box)
set the bdbox (unit point)
Definition: STOFFCell.hxx:130
STOFFVec2f m_bdSize
the cell bounding size : unit point
Definition: STOFFCell.hxx:213
long m_longValue
value ( if type==F_Long )
Definition: STOFFCell.hxx:250
NumberType m_numberFormat
the numeric format
Definition: STOFFCell.hxx:83
STOFFVec2< bool > STOFFVec2b
STOFFVec2 of bool.
Definition: libstaroffice_internal.hxx:746
STOFFCellStyle m_cellStyle
the cell cell style
Definition: STOFFCell.hxx:220
bool isValueSet() const
returns true if the value has been setted
Definition: STOFFCell.hxx:291
~STOFFCellContent()
destructor
Definition: STOFFCell.hxx:272
std::vector< uint32_t > m_text
the text value (for C_TEXT_BASIC)
Definition: STOFFCell.hxx:314
Definition: STOFFCell.hxx:59
NumberType
the different number format of a cell&#39;s content
Definition: STOFFCell.hxx:59
void setBdSize(STOFFVec2f sz)
set the bdbox size(unit point)
Definition: STOFFCell.hxx:141
librevenge::RVNGPropertyList m_numberingStyle
the numbering style
Definition: STOFFCell.hxx:222
Type m_contentType
the content type ( by default unknown )
Definition: STOFFCell.hxx:308
Definition: STOFFCell.hxx:57
librevenge::RVNGPropertyList const & getNumberingStyle() const
returns the numbering style
Definition: STOFFCell.hxx:193
double m_doubleValue
value ( if type==F_Double )
Definition: STOFFCell.hxx:252
bool m_sheetIdRelative
the sheet id relative flag
Definition: STOFFCell.hxx:262
static std::string getColumnName(int col)
return the column name
Definition: STOFFCell.cxx:252
Definition: STOFFCell.hxx:59
Definition: STOFFCell.hxx:57
Definition: STOFFCell.hxx:59
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:748
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:287
STOFFCellStyle & getCellStyle()
returns the cell style
Definition: STOFFCell.hxx:182
Class to store font.
Definition: STOFFFont.hxx:43
Type
the different types of cell&#39;s field
Definition: STOFFCell.hxx:268
a structure uses to define the format of a cell content
Definition: STOFFCell.hxx:61
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:262
Definition: STOFFCell.hxx:57
STOFFBox2f const & bdBox() const
bdbox accessor
Definition: STOFFCell.hxx:125
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:296
STOFFVec2f const & bdSize() const
bdbox size accessor
Definition: STOFFCell.hxx:136
Format m_format
the cell format
Definition: STOFFCell.hxx:216
bool empty() const
returns true if the cell has no content
Definition: STOFFCell.hxx:277
STOFFFont const & getFont() const
returns the font
Definition: STOFFCell.hxx:166
void setPosition(STOFFVec2i posi)
set the cell positions : 0,0 -> A1, 0,1 -> A2
Definition: STOFFCell.hxx:119
STOFFCell()
constructor
Definition: STOFFCell.hxx:86
small class use to define a formula instruction
Definition: STOFFCell.hxx:230
STOFFBox2f m_bdBox
the cell bounding box (unit in point)
Definition: STOFFCell.hxx:211
void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
set the numbering style
Definition: STOFFCell.hxx:203
Class to store a cell style.
Definition: STOFFCellStyle.hxx:43
librevenge::RVNGPropertyList & getNumberingStyle()
returns the numbering style
Definition: STOFFCell.hxx:198
Definition: STOFFCell.hxx:57
FormulaInstruction()
constructor
Definition: STOFFCell.hxx:233
Type m_type
the type
Definition: STOFFCell.hxx:246
void setFont(STOFFFont const &font)
set the font
Definition: STOFFCell.hxx:171
librevenge::RVNGString m_sheet
the sheet name (if not empty)
Definition: STOFFCell.hxx:258

Generated on Thu Aug 11 2016 17:51:54 for libstaroffice by doxygen 1.8.11