MWAWCell.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 -*- */
/* libmwaw
* 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.
*/
/* Define some classes used to store a Cell
*/
#ifndef MWAW_CELL_H
# define MWAW_CELL_H
#include <string>
#include <vector>
#include "libmwaw_internal.hxx"
class WPXPropertyList;
class MWAWTable;
class MWAWCell
{
public:
enum HorizontalAlignment { HALIGN_LEFT, HALIGN_RIGHT, HALIGN_CENTER,
HALIGN_FULL, HALIGN_DEFAULT
};
enum VerticalAlignment { VALIGN_TOP, VALIGN_CENTER, VALIGN_BOTTOM, VALIGN_DEFAULT };
enum ExtraLine { E_None, E_Line1, E_Line2, E_Cross };
MWAWCell() : m_position(0,0), m_numberCellSpanned(1,1), m_bdBox(), m_bdSize(),
m_hAlign(HALIGN_DEFAULT), m_vAlign(VALIGN_DEFAULT), m_bordersList(),
m_backgroundColor(MWAWColor::white()), m_protected(false),
m_extraLine(E_None), m_extraLineType() { }
virtual ~MWAWCell() {}
void addTo(WPXPropertyList &propList) const;
friend std::ostream &operator<<(std::ostream &o, MWAWCell const &cell);
// interface with MWAWTable:
virtual bool send(MWAWContentListenerPtr listener, MWAWTable &table);
virtual bool sendContent(MWAWContentListenerPtr listener, MWAWTable &table);
// position
Vec2i const &position() const {
return m_position;
}
void setPosition(Vec2i posi) {
m_position = posi;
}
Vec2i const &numSpannedCells() const {
return m_numberCellSpanned;
}
void setNumSpannedCells(Vec2i numSpanned) {
m_numberCellSpanned=numSpanned;
}
Box2f const &bdBox() const {
return m_bdBox;
}
void setBdBox(Box2f box) {
m_bdBox = box;
}
Vec2f const &bdSize() const {
return m_bdSize;
}
void setBdSize(Vec2f sz) {
m_bdSize = sz;
}
static std::string getCellName(Vec2i const &pos, Vec2b const &absolute);
static std::string getColumnName(int col);
// format
bool isProtected() const {
return m_protected;
}
void setProtected(bool fl) {
m_protected = fl;
}
HorizontalAlignment hAlignement() const {
return m_hAlign;
}
void setHAlignement(HorizontalAlignment align) {
m_hAlign = align;
}
VerticalAlignment vAlignement() const {
return m_vAlign;
}
void setVAlignement(VerticalAlignment align) {
m_vAlign = align;
}
bool hasBorders() const {
return m_bordersList.size() != 0;
}
std::vector<MWAWBorder> const &borders() const {
return m_bordersList;
}
void resetBorders() {
m_bordersList.resize(0);
}
void setBorders(int wh, MWAWBorder const &border);
MWAWColor backgroundColor() const {
return m_backgroundColor;
}
void setBackgroundColor(MWAWColor color) {
m_backgroundColor = color;
}
bool hasExtraLine() const {
return m_extraLine!=E_None && !m_extraLineType.isEmpty();
}
ExtraLine extraLine() const {
return m_extraLine;
}
MWAWBorder const& extraLineType() const {
return m_extraLineType;
}
void setExtraLine(ExtraLine extrLine, MWAWBorder const &type=MWAWBorder()) {
m_extraLine = extrLine;
m_extraLineType=type;
}
protected:
Vec2i m_position;
Vec2i m_numberCellSpanned;
Box2f m_bdBox;
Vec2f m_bdSize;
HorizontalAlignment m_hAlign;
VerticalAlignment m_vAlign;
std::vector<MWAWBorder> m_bordersList;
MWAWColor m_backgroundColor;
bool m_protected;
ExtraLine m_extraLine;
MWAWBorder m_extraLineType;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWCell::setPosition
void setPosition(Vec2i posi)
set the cell positions : 0,0 -> A1, 0,1 -> A2
Definition: MWAWCell.hxx:102
MWAWCell::m_bdBox
Box2f m_bdBox
the cell bounding box (unit in point)
Definition: MWAWCell.hxx:216
MWAWCell::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWCell const &cell)
operator<<
Definition: MWAWCell.cxx:162
MWAWCell::m_extraLineType
MWAWBorder m_extraLineType
extra line type
Definition: MWAWCell.hxx:234
MWAWCell::setBdBox
void setBdBox(Box2f box)
set the bdbox (unit point)
Definition: MWAWCell.hxx:120
MWAWCell::m_numberCellSpanned
Vec2i m_numberCellSpanned
the cell spanned : by default (1,1)
Definition: MWAWCell.hxx:213
MWAWCell::setBackgroundColor
void setBackgroundColor(MWAWColor color)
sets the background color
Definition: MWAWCell.hxx:189
MWAWCell::MWAWCell
MWAWCell()
constructor
Definition: MWAWCell.hxx:68
MWAWCell::setHAlignement
void setHAlignement(HorizontalAlignment align)
sets the horizontal alignement
Definition: MWAWCell.hxx:155
libmwaw_internal.hxx
MWAWCell::hAlignement
HorizontalAlignment hAlignement() const
returns the horizontal alignement
Definition: MWAWCell.hxx:151
Box2< float >
MWAWCell::hasBorders
bool hasBorders() const
return true if the cell has some border
Definition: MWAWCell.hxx:169
MWAWCell::setProtected
void setProtected(bool fl)
returns true if the cell is protected
Definition: MWAWCell.hxx:146
MWAWCell::bdSize
Vec2f const & bdSize() const
bdbox size accessor
Definition: MWAWCell.hxx:125
MWAWCell::VALIGN_TOP
Definition: MWAWCell.hxx:62
MWAWCell::m_bordersList
std::vector< MWAWBorder > m_bordersList
the cell border MWAWBorder::Pos
Definition: MWAWCell.hxx:226
MWAWCell::m_vAlign
VerticalAlignment m_vAlign
the vertical cell alignement : by default nothing
Definition: MWAWCell.hxx:224
MWAWCell::getCellName
static std::string getCellName(Vec2i const &pos, Vec2b const &absolute)
return the name of a cell (given row and column) : 0,0 -> A1, 0,1 -> A2
Definition: MWAWCell.cxx:126
MWAWCell::bdBox
Box2f const & bdBox() const
bdbox accessor
Definition: MWAWCell.hxx:116
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:53
MWAWCell::m_protected
bool m_protected
cell protected
Definition: MWAWCell.hxx:230
MWAWCell::getColumnName
static std::string getColumnName(int col)
return the column name
Definition: MWAWCell.cxx:116
MWAWCell::setVAlignement
void setVAlignement(VerticalAlignment align)
sets the vertical alignement
Definition: MWAWCell.hxx:164
MWAWCell::extraLine
ExtraLine extraLine() const
returns the extra lines
Definition: MWAWCell.hxx:197
MWAWCell::HorizontalAlignment
HorizontalAlignment
the default horizontal alignement.
Definition: MWAWCell.hxx:56
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:50
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
MWAWCell::backgroundColor
MWAWColor backgroundColor() const
returns the background color
Definition: MWAWCell.hxx:185
MWAWCell::E_None
Definition: MWAWCell.hxx:65
MWAWCell::addTo
void addTo(WPXPropertyList &propList) const
adds to the propList
Definition: MWAWCell.cxx:45
MWAWCell::~MWAWCell
virtual ~MWAWCell()
destructor
Definition: MWAWCell.hxx:74
MWAWBorder
a border
Definition: libmwaw_internal.hxx:232
MWAWCell::setBdSize
void setBdSize(Vec2f sz)
set the bdbox size(unit point)
Definition: MWAWCell.hxx:129
MWAWCell::setNumSpannedCells
void setNumSpannedCells(Vec2i numSpanned)
sets the number of spanned cells : Vec2i(1,1) means 1 cellule
Definition: MWAWCell.hxx:111
MWAWCell::sendContent
virtual bool sendContent(MWAWContentListenerPtr listener, MWAWTable &table)
function called when the content of a cell must be send to the listener, ie.
Definition: MWAWCell.cxx:248
MWAWCell::m_hAlign
HorizontalAlignment m_hAlign
the cell alignement : by default nothing
Definition: MWAWCell.hxx:222
MWAWCell::ExtraLine
ExtraLine
an enum to defined potential internal line: E_Line1=TL to RB, E_Line2=BL to RT
Definition: MWAWCell.hxx:65
MWAWCell::VALIGN_BOTTOM
Definition: MWAWCell.hxx:62
MWAWCell::HALIGN_FULL
Definition: MWAWCell.hxx:57
MWAWCell::m_bdSize
Vec2f m_bdSize
the cell bounding size : unit point
Definition: MWAWCell.hxx:219
MWAWCell::setExtraLine
void setExtraLine(ExtraLine extrLine, MWAWBorder const &type=MWAWBorder())
sets the extraline
Definition: MWAWCell.hxx:205
MWAWCell::m_extraLine
ExtraLine m_extraLine
extra line
Definition: MWAWCell.hxx:232
MWAWCell::resetBorders
void resetBorders()
reset the border
Definition: MWAWCell.hxx:178
MWAWCell::E_Cross
Definition: MWAWCell.hxx:65
MWAWCell::position
Vec2i const & position() const
position accessor
Definition: MWAWCell.hxx:98
MWAWCell::VALIGN_CENTER
Definition: MWAWCell.hxx:62
MWAWCell::vAlignement
VerticalAlignment vAlignement() const
returns the vertical alignement
Definition: MWAWCell.hxx:160
MWAWCell::HALIGN_DEFAULT
Definition: MWAWCell.hxx:57
MWAWContentListenerPtr
shared_ptr< MWAWContentListener > MWAWContentListenerPtr
a smart pointer of MWAWContentListener
Definition: libmwaw_internal.hxx:330
MWAWCell::m_backgroundColor
MWAWColor m_backgroundColor
the backgroung color
Definition: MWAWCell.hxx:228
MWAWCell::hasExtraLine
bool hasExtraLine() const
returns true if we have some extra lines
Definition: MWAWCell.hxx:193
MWAWCell::send
virtual bool send(MWAWContentListenerPtr listener, MWAWTable &table)
function called when a cell is send by MWAWTable to send a cell to a listener.
Definition: MWAWCell.cxx:239
MWAWCell::E_Line1
Definition: MWAWCell.hxx:65
MWAWCell::borders
std::vector< MWAWBorder > const & borders() const
return the cell border: libmwaw::Left | ...
Definition: MWAWCell.hxx:173
MWAWCell::extraLineType
MWAWBorder const & extraLineType() const
returns the extra line border
Definition: MWAWCell.hxx:201
Vec2< int >
MWAWCell::VerticalAlignment
VerticalAlignment
the default vertical alignement.
Definition: MWAWCell.hxx:62
MWAWCell::numSpannedCells
Vec2i const & numSpannedCells() const
returns the number of spanned cells
Definition: MWAWCell.hxx:107
MWAWCell::HALIGN_RIGHT
Definition: MWAWCell.hxx:56
MWAWCell::VALIGN_DEFAULT
Definition: MWAWCell.hxx:62
MWAWCell::E_Line2
Definition: MWAWCell.hxx:65
MWAWCell::HALIGN_LEFT
Definition: MWAWCell.hxx:56
MWAWCell::isProtected
bool isProtected() const
returns true if the cell is protected
Definition: MWAWCell.hxx:142
MWAWCell::HALIGN_CENTER
Definition: MWAWCell.hxx:56
MWAWCell::m_position
Vec2i m_position
the cell row and column : 0,0 -> A1, 0,1 -> A2
Definition: MWAWCell.hxx:211
MWAWCell::setBorders
void setBorders(int wh, MWAWBorder const &border)
sets the cell border: wh=libmwaw::Left|...
Definition: MWAWCell.cxx:139
MWAWBorder::isEmpty
bool isEmpty() const
returns true if the border is empty
Definition: libmwaw_internal.hxx:245