MWAWCell.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 /* libmwaw
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 MWAW_CELL_H
39 # define MWAW_CELL_H
40 
41 #include <string>
42 #include <vector>
43 
44 #include "libmwaw_internal.hxx"
45 
46 #include "MWAWEntry.hxx"
47 #include "MWAWFont.hxx"
48 
49 class MWAWTable;
50 
52 class MWAWCell
53 {
54 public:
60  struct Format {
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  bool getNumberingProperties(librevenge::RVNGPropertyList &propList) const;
78  static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector);
80  friend std::ostream &operator<<(std::ostream &o, Format const &format);
82  int compare(Format const &format) const;
83 
89  int m_digits;
101  std::string m_currencySymbol;
103  std::string m_DTFormat;
104  };
106  struct CompareFormat {
110  bool operator()(Format const &c1, Format const &c2) const
111  {
112  return c1.compare(c2) < 0;
113  }
114  };
120  };
121 
125 
128 
132  m_backgroundColor(MWAWColor::white()), m_protected(false),
134 
136  virtual ~MWAWCell() {}
137 
139  void addTo(librevenge::RVNGPropertyList &propList, shared_ptr<MWAWFontConverter> fontConverter) const;
140 
142  friend std::ostream &operator<<(std::ostream &o, MWAWCell const &cell);
143 
144  // interface with MWAWTable:
145 
150  virtual bool send(MWAWListenerPtr listener, MWAWTable &table);
155  virtual bool sendContent(MWAWListenerPtr listener, MWAWTable &table);
156 
157  // position
158 
160  MWAWVec2i const &position() const
161  {
162  return m_position;
163  }
166  {
167  m_position = posi;
168  }
169 
171  MWAWVec2i const &numSpannedCells() const
172  {
173  return m_numberCellSpanned;
174  }
176  void setNumSpannedCells(MWAWVec2i numSpanned)
177  {
178  m_numberCellSpanned=numSpanned;
179  }
180 
182  MWAWBox2f const &bdBox() const
183  {
184  return m_bdBox;
185  }
187  void setBdBox(MWAWBox2f box)
188  {
189  m_bdBox = box;
190  }
191 
193  MWAWVec2f const &bdSize() const
194  {
195  return m_bdSize;
196  }
199  {
200  m_bdSize = sz;
201  }
203  static std::string getBasicCellName(MWAWVec2i const &pos);
205  static std::string getCellName(MWAWVec2i const &pos, MWAWVec2b const &absolute);
206 
208  static std::string getColumnName(int col);
209 
210  // format
211 
213  Format const &getFormat() const
214  {
215  return m_format;
216  }
218  void setFormat(Format const &format)
219  {
220  m_format=format;
221  }
222 
224  bool isFontSet() const
225  {
226  return m_fontSet;
227  }
230  {
231  return m_font;
232  }
234  void setFont(MWAWFont const &font, bool isDefault=false)
235  {
236  m_font=font;
237  m_fontSet=!isDefault;
238  }
239 
241  bool isProtected() const
242  {
243  return m_protected;
244  }
246  void setProtected(bool fl)
247  {
248  m_protected = fl;
249  }
250 
253  {
254  return m_hAlign;
255  }
258  {
259  m_hAlign = align;
260  }
261 
264  {
265  return m_vAlign;
266  }
269  {
270  m_vAlign = align;
271  }
272 
274  bool hasBorders() const
275  {
276  return m_bordersList.size() != 0;
277  }
279  std::vector<MWAWBorder> const &borders() const
280  {
281  return m_bordersList;
282  }
283 
286  {
287  m_bordersList.resize(0);
288  }
290  void setBorders(int wh, MWAWBorder const &border);
291 
294  {
295  return m_backgroundColor;
296  }
299  {
300  m_backgroundColor = color;
301  }
303  bool hasExtraLine() const
304  {
306  }
309  {
310  return m_extraLine;
311  }
313  MWAWBorder const &extraLineType() const
314  {
315  return m_extraLineType;
316  }
318  void setExtraLine(ExtraLine extrLine, MWAWBorder const &type=MWAWBorder())
319  {
320  m_extraLine = extrLine;
321  m_extraLineType=type;
322  }
323 protected:
332 
338  bool m_fontSet;
347 
349  std::vector<MWAWBorder> m_bordersList;
354 };
355 
358 {
359 public:
365  {
366  for (int i=0; i<2; ++i) {
367  m_position[i]=MWAWVec2i(0,0);
368  m_positionRelative[i]=MWAWVec2b(false,false);
369  }
370  }
372  librevenge::RVNGPropertyList getPropertyList(MWAWFontConverter &fontConverter, int fontId) const;
374  friend std::ostream &operator<<(std::ostream &o, FormulaInstruction const &inst);
378  std::string m_content;
380  double m_longValue;
388  std::string m_sheet;
389  };
390 
398  friend std::ostream &operator<<(std::ostream &o, MWAWCellContent const &cell);
399 
401  bool empty() const
402  {
403  if (m_contentType == C_NUMBER) return false;
404  if (m_contentType == C_TEXT && m_textEntry.valid()) return false;
405  if (m_contentType == C_FORMULA && (m_formula.size() || isValueSet())) return false;
406  return true;
407  }
409  void setValue(double value)
410  {
411  m_value = value;
412  m_valueSet = true;
413  }
415  bool isValueSet() const
416  {
417  return m_valueSet;
418  }
420  bool hasText() const
421  {
422  return m_textEntry.valid();
423  }
426  static bool double2Date(double val, int &Y, int &M, int &D);
428  static bool double2Time(double val, int &H, int &M, int &S);
430  static bool double2String(double val, MWAWCell::Format const &format, std::string &str);
432  static bool date2Double(int Y, int M, int D, double &val);
436  double m_value;
442  std::vector<FormulaInstruction> m_formula;
443 };
444 
445 #endif
446 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue Mar 1 2016 23:42:50 for libmwaw by doxygen 1.8.4