STOFFCell.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libstaroffice
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef STOFF_CELL_H
# define STOFF_CELL_H
#include <string>
#include <vector>
#include "libstaroffice_internal.hxx"
#include "STOFFEntry.hxx"
#include "STOFFFont.hxx"
#include "STOFFCellStyle.hxx"
class STOFFTable;
class STOFFCell
{
public:
enum FormatType { F_TEXT, F_BOOLEAN, F_NUMBER, F_DATE, F_TIME, F_DATETIME, F_UNKNOWN };
enum NumberType { F_NUMBER_CURRENCY, F_NUMBER_DECIMAL, F_NUMBER_FRACTION, F_NUMBER_GENERIC, F_NUMBER_SCIENTIFIC, F_NUMBER_PERCENT, F_NUMBER_UNKNOWN };
struct Format {
Format()
: m_format(F_UNKNOWN)
, m_numberFormat(F_NUMBER_UNKNOWN)
{
}
virtual ~Format();
bool hasBasicFormat() const
{
return m_format==F_TEXT || m_format==F_UNKNOWN;
}
std::string getValueType() const;
static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector);
friend std::ostream &operator<<(std::ostream &o, Format const &format);
FormatType m_format;
NumberType m_numberFormat;
};
STOFFCell()
: m_position(0,0)
, m_bdBox()
, m_bdSize()
, m_format()
, m_font()
, m_cellStyle()
, m_numberingStyle() { }
virtual ~STOFFCell() {}
void addTo(librevenge::RVNGPropertyList &propList) const;
friend std::ostream &operator<<(std::ostream &o, STOFFCell const &cell);
// interface with STOFFTable:
virtual bool send(STOFFListenerPtr listener, STOFFTable &table);
virtual bool sendContent(STOFFListenerPtr listener, STOFFTable &table);
// position
STOFFVec2i const &position() const
{
return m_position;
}
void setPosition(STOFFVec2i posi)
{
m_position = posi;
}
STOFFBox2f const &bdBox() const
{
return m_bdBox;
}
void setBdBox(STOFFBox2f box)
{
m_bdBox = box;
}
STOFFVec2f const &bdSize() const
{
return m_bdSize;
}
void setBdSize(STOFFVec2f sz)
{
m_bdSize = sz;
}
static std::string getCellName(STOFFVec2i const &pos, STOFFVec2b const &absolute);
static std::string getColumnName(int col);
// format
Format const &getFormat() const
{
return m_format;
}
void setFormat(Format const &format)
{
m_format=format;
}
STOFFFont const &getFont() const
{
return m_font;
}
void setFont(STOFFFont const &font)
{
m_font=font;
}
STOFFCellStyle const &getCellStyle() const
{
return m_cellStyle;
}
STOFFCellStyle &getCellStyle()
{
return m_cellStyle;
}
void setCellStyle(STOFFCellStyle const &cellStyle)
{
m_cellStyle=cellStyle;
}
librevenge::RVNGPropertyList const &getNumberingStyle() const
{
return m_numberingStyle;
}
librevenge::RVNGPropertyList &getNumberingStyle()
{
return m_numberingStyle;
}
void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
{
m_numberingStyle=numberStyle;
}
protected:
STOFFVec2i m_position;
STOFFBox2f m_bdBox;
STOFFVec2f m_bdSize;
Format m_format;
STOFFFont m_font;
STOFFCellStyle m_cellStyle;
librevenge::RVNGPropertyList m_numberingStyle;
};
class STOFFCellContent
{
public:
struct FormulaInstruction {
enum Type { F_None, F_Operator, F_Function, F_Cell, F_CellList, F_Index, F_Long, F_Double, F_Text };
FormulaInstruction() : m_type(F_None), m_content(""), m_longValue(0), m_doubleValue(0), m_sheet(""),
m_sheetId(-1), m_sheetIdRelative(false), m_extra("")
{
for (int i=0; i<2; ++i) {
m_position[i]=STOFFVec2i(0,0);
m_positionRelative[i]=STOFFVec2b(false,false);
}
}
librevenge::RVNGPropertyList getPropertyList() const;
friend std::ostream &operator<<(std::ostream &o, FormulaInstruction const &inst);
Type m_type;
librevenge::RVNGString m_content;
long m_longValue;
double m_doubleValue;
STOFFVec2i m_position[2];
STOFFVec2b m_positionRelative[2];
librevenge::RVNGString m_sheet;
int m_sheetId;
bool m_sheetIdRelative;
std::string m_extra;
};
enum Type { C_NONE, C_TEXT, C_TEXT_BASIC, C_NUMBER, C_FORMULA, C_UNKNOWN };
STOFFCellContent() : m_contentType(C_UNKNOWN), m_value(0.0), m_valueSet(false), m_text(), m_formula() { }
~STOFFCellContent() {}
friend std::ostream &operator<<(std::ostream &o, STOFFCellContent const &cell);
bool empty() const
{
if (m_contentType == C_NUMBER || m_contentType == C_TEXT) return false;
if (m_contentType == C_TEXT_BASIC && !m_text.empty()) return false;
if (m_contentType == C_FORMULA && (m_formula.size() || isValueSet())) return false;
return true;
}
void setValue(double value)
{
m_value = value;
m_valueSet = true;
}
bool isValueSet() const
{
return m_valueSet;
}
bool hasText() const
{
return m_contentType == C_TEXT || !m_text.empty();
}
static bool double2Date(double val, int &Y, int &M, int &D);
static bool double2Time(double val, int &H, int &M, int &S);
static bool date2Double(int Y, int M, int D, double &val);
Type m_contentType;
double m_value;
bool m_valueSet;
std::vector<uint32_t> m_text;
std::vector<FormulaInstruction> m_formula;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFCellStyle.hxx
STOFFEntry.hxx
STOFFFont.hxx
STOFFCellContent
small class use to define a sheet cell content
Definition STOFFCell.hxx:235
STOFFCellContent::STOFFCellContent
STOFFCellContent()
constructor
Definition STOFFCell.hxx:278
STOFFCellContent::isValueSet
bool isValueSet() const
returns true if the value has been setted
Definition STOFFCell.hxx:299
STOFFCellContent::Type
Type
the different types of cell's field
Definition STOFFCell.hxx:276
STOFFCellContent::C_NUMBER
@ C_NUMBER
Definition STOFFCell.hxx:276
STOFFCellContent::C_NONE
@ C_NONE
Definition STOFFCell.hxx:276
STOFFCellContent::C_TEXT
@ C_TEXT
Definition STOFFCell.hxx:276
STOFFCellContent::C_FORMULA
@ C_FORMULA
Definition STOFFCell.hxx:276
STOFFCellContent::C_UNKNOWN
@ C_UNKNOWN
Definition STOFFCell.hxx:276
STOFFCellContent::C_TEXT_BASIC
@ C_TEXT_BASIC
Definition STOFFCell.hxx:276
STOFFCellContent::~STOFFCellContent
~STOFFCellContent()
destructor
Definition STOFFCell.hxx:280
STOFFCellContent::double2Date
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
STOFFCellContent::empty
bool empty() const
returns true if the cell has no content
Definition STOFFCell.hxx:285
STOFFCellContent::m_formula
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition STOFFCell.hxx:324
STOFFCellContent::m_contentType
Type m_contentType
the content type ( by default unknown )
Definition STOFFCell.hxx:316
STOFFCellContent::double2Time
static bool double2Time(double val, int &H, int &M, int &S)
conversion beetween double: second since 0:00 and time
Definition STOFFCell.cxx:382
STOFFCellContent::m_valueSet
bool m_valueSet
true if the value has been set
Definition STOFFCell.hxx:320
STOFFCellContent::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFCellContent const &cell)
operator<<
Definition STOFFCell.cxx:394
STOFFCellContent::m_text
std::vector< uint32_t > m_text
the text value (for C_TEXT_BASIC)
Definition STOFFCell.hxx:322
STOFFCellContent::hasText
bool hasText() const
returns true if the text is set
Definition STOFFCell.hxx:304
STOFFCellContent::setValue
void setValue(double value)
sets the double value
Definition STOFFCell.hxx:293
STOFFCellContent::date2Double
static bool date2Double(int Y, int M, int D, double &val)
conversion beetween date and double days since 1900 date
Definition STOFFCell.cxx:352
STOFFCellContent::m_value
double m_value
the cell value
Definition STOFFCell.hxx:318
STOFFCellStyle
Class to store a cell style.
Definition STOFFCellStyle.hxx:44
STOFFCell
a structure used to define a cell and its format
Definition STOFFCell.hxx:54
STOFFCell::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFCell const &cell)
operator<<
Definition STOFFCell.cxx:272
STOFFCell::getFormat
Format const & getFormat() const
returns the cell format
Definition STOFFCell.hxx:163
STOFFCell::getNumberingStyle
librevenge::RVNGPropertyList const & getNumberingStyle() const
returns the numbering style
Definition STOFFCell.hxx:201
STOFFCell::m_numberingStyle
librevenge::RVNGPropertyList m_numberingStyle
the numbering style
Definition STOFFCell.hxx:230
STOFFCell::getCellStyle
STOFFCellStyle const & getCellStyle() const
returns the cell style
Definition STOFFCell.hxx:185
STOFFCell::setBdBox
void setBdBox(STOFFBox2f box)
set the bdbox (unit point)
Definition STOFFCell.hxx:138
STOFFCell::getCellName
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
STOFFCell::getNumberingStyle
librevenge::RVNGPropertyList & getNumberingStyle()
returns the numbering style
Definition STOFFCell.hxx:206
STOFFCell::FormatType
FormatType
the different format of a cell's content
Definition STOFFCell.hxx:57
STOFFCell::F_UNKNOWN
@ F_UNKNOWN
Definition STOFFCell.hxx:57
STOFFCell::F_TIME
@ F_TIME
Definition STOFFCell.hxx:57
STOFFCell::F_DATETIME
@ F_DATETIME
Definition STOFFCell.hxx:57
STOFFCell::F_NUMBER
@ F_NUMBER
Definition STOFFCell.hxx:57
STOFFCell::F_TEXT
@ F_TEXT
Definition STOFFCell.hxx:57
STOFFCell::F_DATE
@ F_DATE
Definition STOFFCell.hxx:57
STOFFCell::F_BOOLEAN
@ F_BOOLEAN
Definition STOFFCell.hxx:57
STOFFCell::setPosition
void setPosition(STOFFVec2i posi)
set the cell positions : 0,0 -> A1, 0,1 -> A2
Definition STOFFCell.hxx:127
STOFFCell::bdSize
STOFFVec2f const & bdSize() const
bdbox size accessor
Definition STOFFCell.hxx:144
STOFFCell::getColumnName
static std::string getColumnName(int col)
return the column name
Definition STOFFCell.cxx:255
STOFFCell::bdBox
STOFFBox2f const & bdBox() const
bdbox accessor
Definition STOFFCell.hxx:133
STOFFCell::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
adds to the propList
Definition STOFFCell.cxx:246
STOFFCell::NumberType
NumberType
the different number format of a cell's content
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_PERCENT
@ F_NUMBER_PERCENT
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_DECIMAL
@ F_NUMBER_DECIMAL
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_FRACTION
@ F_NUMBER_FRACTION
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_GENERIC
@ F_NUMBER_GENERIC
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_UNKNOWN
@ F_NUMBER_UNKNOWN
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_CURRENCY
@ F_NUMBER_CURRENCY
Definition STOFFCell.hxx:59
STOFFCell::F_NUMBER_SCIENTIFIC
@ F_NUMBER_SCIENTIFIC
Definition STOFFCell.hxx:59
STOFFCell::sendContent
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
STOFFCell::setFormat
void setFormat(Format const &format)
set the cell format
Definition STOFFCell.hxx:168
STOFFCell::getCellStyle
STOFFCellStyle & getCellStyle()
returns the cell style
Definition STOFFCell.hxx:190
STOFFCell::setCellStyle
void setCellStyle(STOFFCellStyle const &cellStyle)
set the cell style
Definition STOFFCell.hxx:195
STOFFCell::m_font
STOFFFont m_font
the cell font
Definition STOFFCell.hxx:226
STOFFCell::getFont
STOFFFont const & getFont() const
returns the font
Definition STOFFCell.hxx:174
STOFFCell::m_cellStyle
STOFFCellStyle m_cellStyle
the cell cell style
Definition STOFFCell.hxx:228
STOFFCell::send
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
STOFFCell::m_bdBox
STOFFBox2f m_bdBox
the cell bounding box (unit in point)
Definition STOFFCell.hxx:219
STOFFCell::m_bdSize
STOFFVec2f m_bdSize
the cell bounding size : unit point
Definition STOFFCell.hxx:221
STOFFCell::setFont
void setFont(STOFFFont const &font)
set the font
Definition STOFFCell.hxx:179
STOFFCell::~STOFFCell
virtual ~STOFFCell()
destructor
Definition STOFFCell.hxx:98
STOFFCell::setBdSize
void setBdSize(STOFFVec2f sz)
set the bdbox size(unit point)
Definition STOFFCell.hxx:149
STOFFCell::m_format
Format m_format
the cell format
Definition STOFFCell.hxx:224
STOFFCell::STOFFCell
STOFFCell()
constructor
Definition STOFFCell.hxx:88
STOFFCell::m_position
STOFFVec2i m_position
the cell row and column : 0,0 -> A1, 0,1 -> A2
Definition STOFFCell.hxx:217
STOFFCell::position
STOFFVec2i const & position() const
position accessor
Definition STOFFCell.hxx:122
STOFFCell::setNumberingStyle
void setNumberingStyle(librevenge::RVNGPropertyList const &numberStyle)
set the numbering style
Definition STOFFCell.hxx:211
STOFFFont
Class to store font.
Definition STOFFFont.hxx:44
STOFFTable
a class used to recreate the table structure using cell informations, ....
Definition STOFFTable.hxx:52
libstaroffice_internal.hxx
STOFFListenerPtr
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition libstaroffice_internal.hxx:491
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition libstaroffice_internal.hxx:767
STOFFVec2b
STOFFVec2< bool > STOFFVec2b
STOFFVec2 of bool.
Definition libstaroffice_internal.hxx:765
STOFFVec2f
STOFFVec2< float > STOFFVec2f
STOFFVec2 of float.
Definition libstaroffice_internal.hxx:771
STOFFBox2f
STOFFBox2< float > STOFFBox2f
STOFFBox2 of float.
Definition libstaroffice_internal.hxx:1135
STOFFCellContent::FormulaInstruction
small class use to define a formula instruction
Definition STOFFCell.hxx:238
STOFFCellContent::FormulaInstruction::m_sheetIdRelative
bool m_sheetIdRelative
the sheet id relative flag
Definition STOFFCell.hxx:270
STOFFCellContent::FormulaInstruction::m_positionRelative
STOFFVec2b m_positionRelative[2]
relative cell position ( if type==F_Cell or F_CellList )
Definition STOFFCell.hxx:264
STOFFCellContent::FormulaInstruction::m_doubleValue
double m_doubleValue
value ( if type==F_Double )
Definition STOFFCell.hxx:260
STOFFCellContent::FormulaInstruction::m_type
Type m_type
the type
Definition STOFFCell.hxx:254
STOFFCellContent::FormulaInstruction::operator<<
friend std::ostream & operator<<(std::ostream &o, FormulaInstruction const &inst)
operator<<
Definition STOFFCell.cxx:486
STOFFCellContent::FormulaInstruction::Type
Type
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Text
@ F_Text
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Long
@ F_Long
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Function
@ F_Function
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Cell
@ F_Cell
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Double
@ F_Double
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_None
@ F_None
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Index
@ F_Index
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_CellList
@ F_CellList
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Operator
@ F_Operator
Definition STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::m_sheet
librevenge::RVNGString m_sheet
the sheet name (if not empty)
Definition STOFFCell.hxx:266
STOFFCellContent::FormulaInstruction::m_extra
std::string m_extra
extra data
Definition STOFFCell.hxx:272
STOFFCellContent::FormulaInstruction::m_content
librevenge::RVNGString m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition STOFFCell.hxx:256
STOFFCellContent::FormulaInstruction::FormulaInstruction
FormulaInstruction()
constructor
Definition STOFFCell.hxx:241
STOFFCellContent::FormulaInstruction::m_position
STOFFVec2i m_position[2]
cell position ( if type==F_Cell or F_CellList )
Definition STOFFCell.hxx:262
STOFFCellContent::FormulaInstruction::m_longValue
long m_longValue
value ( if type==F_Long )
Definition STOFFCell.hxx:258
STOFFCellContent::FormulaInstruction::getPropertyList
librevenge::RVNGPropertyList getPropertyList() const
returns a proplist corresponding to a instruction
Definition STOFFCell.cxx:424
STOFFCellContent::FormulaInstruction::m_sheetId
int m_sheetId
the sheet id (if set)
Definition STOFFCell.hxx:268
STOFFCell::Format
a structure uses to define the format of a cell content
Definition STOFFCell.hxx:61
STOFFCell::Format::m_numberFormat
NumberType m_numberFormat
the numeric format
Definition STOFFCell.hxx:85
STOFFCell::Format::getValueType
std::string getValueType() const
returns a value type
Definition STOFFCell.cxx:58
STOFFCell::Format::operator<<
friend std::ostream & operator<<(std::ostream &o, Format const &format)
operator<<
Definition STOFFCell.cxx:189
STOFFCell::Format::~Format
virtual ~Format()
destructor
Definition STOFFCell.cxx:54
STOFFCell::Format::Format
Format()
constructor
Definition STOFFCell.hxx:63
STOFFCell::Format::hasBasicFormat
bool hasBasicFormat() const
returns true if this is a basic format style
Definition STOFFCell.hxx:71
STOFFCell::Format::convertDTFormat
static bool convertDTFormat(std::string const &dtFormat, librevenge::RVNGPropertyListVector &propListVector)
convert a DTFormat in a propertyList
Definition STOFFCell.cxx:81
STOFFCell::Format::m_format
FormatType m_format
the cell format : by default unknown
Definition STOFFCell.hxx:83