MWAWSection.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.
*/
#ifndef MWAW_SECTION_H
#define MWAW_SECTION_H
#include <iostream>
#include <vector>
#include <librevenge/librevenge.h>
#include "libmwaw_internal.hxx"
class MWAWSection
{
public:
struct Column;
MWAWSection()
: m_columns()
, m_width(0)
, m_columnSeparator()
, m_balanceText(false)
, m_backgroundColor(MWAWColor::white())
{
m_columnSeparator.m_style=MWAWBorder::None;
}
MWAWSection(MWAWSection const &)=default;
MWAWSection &operator=(MWAWSection const &)=default;
MWAWSection &operator=(MWAWSection &&)=default;
virtual ~MWAWSection();
void setColumns(int num, double width, librevenge::RVNGUnit widthUnit, double colSep=0);
int numColumns() const
{
return m_columns.empty() ? 1 : int(m_columns.size());
}
bool hasSingleColumns() const
{
return m_columns.size() <= 1;
}
void addTo(librevenge::RVNGPropertyList &propList) const;
void addColumnsTo(librevenge::RVNGPropertyListVector &propList) const;
friend std::ostream &operator<<(std::ostream &o, MWAWSection const &sec);
bool operator!=(MWAWSection const &sec) const
{
if (m_columns.size()!=sec.m_columns.size())
return true;
for (size_t c=0; c < m_columns.size(); c++) {
if (m_columns[c] != sec.m_columns[c])
return true;
}
if (m_columnSeparator != sec.m_columnSeparator)
return true;
if (m_balanceText!=sec.m_balanceText || m_backgroundColor!=sec.m_backgroundColor)
return true;
return false;
}
bool operator==(MWAWSection const &sec) const
{
return !operator!=(sec);
}
std::vector<Column> m_columns;
double m_width;
MWAWBorder m_columnSeparator;
bool m_balanceText;
MWAWColor m_backgroundColor;
public:
struct Column {
Column()
: m_width(0)
, m_widthUnit(librevenge::RVNG_INCH)
{
for (auto &margin : m_margins) margin=0;
}
bool addTo(librevenge::RVNGPropertyList &propList) const;
friend std::ostream &operator<<(std::ostream &o, Column const &column);
bool operator!=(Column const &col) const
{
if (m_width<col.m_width || m_width>col.m_width || m_widthUnit!=col.m_widthUnit)
return true;
for (int i = 0; i < 4; i++) {
if (m_margins[i]<col.m_margins[i] || m_margins[i]>col.m_margins[i])
return true;
}
return false;
}
bool operator==(Column const &col) const
{
return !operator!=(col);
}
double m_width;
librevenge::RVNGUnit m_widthUnit;
double m_margins[4];
};
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWSection
a class which stores section properties
Definition MWAWSection.hxx:46
MWAWSection::operator==
bool operator==(MWAWSection const &sec) const
operator==
Definition MWAWSection.hxx:102
MWAWSection::MWAWSection
MWAWSection(MWAWSection const &)=default
MWAWSection::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition MWAWSection.cxx:130
MWAWSection::operator=
MWAWSection & operator=(MWAWSection const &)=default
MWAWSection::hasSingleColumns
bool hasSingleColumns() const
returns the true if the section has only one columns
Definition MWAWSection.hxx:76
MWAWSection::m_columns
std::vector< Column > m_columns
the different column
Definition MWAWSection.hxx:108
MWAWSection::m_backgroundColor
MWAWColor m_backgroundColor
the background color
Definition MWAWSection.hxx:116
MWAWSection::~MWAWSection
virtual ~MWAWSection()
destructor
Definition MWAWSection.cxx:89
MWAWSection::m_balanceText
bool m_balanceText
true if the text is balanced between different columns
Definition MWAWSection.hxx:114
MWAWSection::addColumnsTo
void addColumnsTo(librevenge::RVNGPropertyListVector &propList) const
add tabs to the propList
Definition MWAWSection.cxx:147
MWAWSection::m_columnSeparator
MWAWBorder m_columnSeparator
the vertical separator between columns
Definition MWAWSection.hxx:112
MWAWSection::numColumns
int numColumns() const
returns the number of columns
Definition MWAWSection.hxx:71
MWAWSection::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWSection const &sec)
operator <<
Definition MWAWSection.cxx:93
MWAWSection::operator!=
bool operator!=(MWAWSection const &sec) const
operator!=
Definition MWAWSection.hxx:87
MWAWSection::m_width
double m_width
the total section width ( if set )
Definition MWAWSection.hxx:110
MWAWSection::MWAWSection
MWAWSection()
constructor
Definition MWAWSection.hxx:50
MWAWSection::operator=
MWAWSection & operator=(MWAWSection &&)=default
MWAWSection::setColumns
void setColumns(int num, double width, librevenge::RVNGUnit widthUnit, double colSep=0)
a function which sets n uniform columns
Definition MWAWSection.cxx:109
libmwaw_internal.hxx
librevenge
Definition MWAWDocument.hxx:57
MWAWBorder
a border
Definition libmwaw_internal.hxx:333
MWAWBorder::None
@ None
Definition libmwaw_internal.hxx:335
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MWAWSection::Column
struct to store the columns properties
Definition MWAWSection.hxx:120
MWAWSection::Column::m_width
double m_width
the columns width
Definition MWAWSection.hxx:150
MWAWSection::Column::m_widthUnit
librevenge::RVNGUnit m_widthUnit
the width unit (default inches)
Definition MWAWSection.hxx:152
MWAWSection::Column::addTo
bool addTo(librevenge::RVNGPropertyList &propList) const
add a column to the propList
Definition MWAWSection.cxx:55
MWAWSection::Column::operator!=
bool operator!=(Column const &col) const
operator!=
Definition MWAWSection.hxx:133
MWAWSection::Column::Column
Column()
constructor
Definition MWAWSection.hxx:122
MWAWSection::Column::operator<<
friend std::ostream & operator<<(std::ostream &o, Column const &column)
operator <<
Definition MWAWSection.cxx:44
MWAWSection::Column::m_margins
double m_margins[4]
the margins in inches using libmwaw::Position orders
Definition MWAWSection.hxx:154
MWAWSection::Column::operator==
bool operator==(Column const &col) const
operator==
Definition MWAWSection.hxx:144