- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

STOFFSection.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
34 #ifndef STOFF_SECTION_H
35 #define STOFF_SECTION_H
36
37 #include <iostream>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "libstaroffice_internal.hxx"
43
45 class STOFFSection
46 {
47 public:
48 struct Column;
50 STOFFSection() : m_columns(), m_width(0), m_balanceText(false), m_backgroundColor(STOFFColor::white())
51 {
52 }
54 virtual ~STOFFSection()
55 {
56 }
61 void setColumns(int num, double width, librevenge::RVNGUnit widthUnit, double colSep=0);
63 int numColumns() const
64 {
65 return m_columns.size() <= 1 ? 1 : int(m_columns.size());
66 }
68 bool hasSingleColumns() const
69 {
70 return m_columns.size() <= 1;
71 }
73 void addTo(librevenge::RVNGPropertyList &propList) const;
75 void addColumnsTo(librevenge::RVNGPropertyListVector &propList) const;
77 friend std::ostream &operator<<(std::ostream &o, STOFFSection const &sec);
79 bool operator!=(STOFFSection const &sec) const
80 {
81 if (m_columns.size()!=sec.m_columns.size())
82 return true;
83 for (size_t c=0; c < m_columns.size(); c++) {
84 if (m_columns[c] != sec.m_columns[c])
85 return true;
86 }
87 if (m_balanceText!=sec.m_balanceText || m_backgroundColor!=sec.m_backgroundColor)
88 return true;
89 return false;
90 }
92 bool operator==(STOFFSection const &sec) const
93 {
94 return !operator!=(sec);
95 }
96
98 std::vector<Column> m_columns;
100 double m_width;
102 bool m_balanceText;
104 STOFFColor m_backgroundColor;
105
106 public:
108 struct Column {
110 Column() : m_width(0), m_widthUnit(librevenge::RVNG_INCH)
111 {
112 for (int i = 0; i < 4; i++)
113 m_margins[i]=0;
114 }
116 bool addTo(librevenge::RVNGPropertyList &propList) const;
118 friend std::ostream &operator<<(std::ostream &o, Column const &column);
120 bool operator!=(Column const &col) const
121 {
122 if (m_width<col.m_width || m_width>col.m_width || m_widthUnit!=col.m_widthUnit)
123 return true;
124 for (int i = 0; i < 4; i++) {
125 if (m_margins[i]<col.m_margins[i] || m_margins[i]>col.m_margins[i])
126 return true;
127 }
128 return false;
129 }
131 bool operator==(Column const &col) const
132 {
133 return !operator!=(col);
134 }
135
137 double m_width;
139 librevenge::RVNGUnit m_widthUnit;
141 double m_margins[4];
142 };
143 };
144 #endif
145 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFSection::addColumnsTo
void addColumnsTo(librevenge::RVNGPropertyListVector &propList) const
add tabs to the propList
Definition: STOFFSection.cxx:130
librevenge
Definition: STOFFDocument.hxx:42
STOFFSection::Column
struct to store the columns properties
Definition: STOFFSection.hxx:108
STOFFSection::Column::operator<<
friend std::ostream & operator<<(std::ostream &o, Column const &column)
operator <<
Definition: STOFFSection.cxx:44
STOFFSection::m_columns
std::vector< Column > m_columns
the different column
Definition: STOFFSection.hxx:98
STOFFSection::Column::m_widthUnit
librevenge::RVNGUnit m_widthUnit
the width unit (default inches)
Definition: STOFFSection.hxx:139
STOFFSection::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition: STOFFSection.cxx:120
STOFFSection::hasSingleColumns
bool hasSingleColumns() const
returns the true if the section has only one columns
Definition: STOFFSection.hxx:68
STOFFSection::STOFFSection
STOFFSection()
constructor
Definition: STOFFSection.hxx:50
STOFFSection::setColumns
void setColumns(int num, double width, librevenge::RVNGUnit widthUnit, double colSep=0)
a function which sets n uniform columns
Definition: STOFFSection.cxx:99
STOFFSection::m_balanceText
bool m_balanceText
true if the text is balanced between different columns
Definition: STOFFSection.hxx:102
STOFFSection::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFSection const &sec)
operator <<
Definition: STOFFSection.cxx:86
STOFFSection::Column::addTo
bool addTo(librevenge::RVNGPropertyList &propList) const
add a column to the propList
Definition: STOFFSection.cxx:55
STOFFSection::Column::m_margins
double m_margins[4]
the margins in inches using libstoff::Position orders
Definition: STOFFSection.hxx:141
STOFFSection::Column::operator==
bool operator==(Column const &col) const
operator==
Definition: STOFFSection.hxx:131
STOFFSection::operator!=
bool operator!=(STOFFSection const &sec) const
operator!=
Definition: STOFFSection.hxx:79
STOFFSection::Column::operator!=
bool operator!=(Column const &col) const
operator!=
Definition: STOFFSection.hxx:120
STOFFSection::numColumns
int numColumns() const
returns the number of columns
Definition: STOFFSection.hxx:63
STOFFSection
a class which stores section properties
Definition: STOFFSection.hxx:45
STOFFSection::m_width
double m_width
the total section width ( if set )
Definition: STOFFSection.hxx:100
STOFFSection::~STOFFSection
virtual ~STOFFSection()
destructor
Definition: STOFFSection.hxx:54
libstaroffice_internal.hxx
STOFFColor
the class to store a color
Definition: libstaroffice_internal.hxx:179
STOFFSection::operator==
bool operator==(STOFFSection const &sec) const
operator==
Definition: STOFFSection.hxx:92
STOFFSection::m_backgroundColor
STOFFColor m_backgroundColor
the background color
Definition: STOFFSection.hxx:104
STOFFSection::Column::m_width
double m_width
the columns width
Definition: STOFFSection.hxx:137
STOFFSection::Column::Column
Column()
constructor
Definition: STOFFSection.hxx:110