WPXTable.h Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

WPXTable.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwpd
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
11 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 *
20 * For further information visit http://libwpd.sourceforge.net
21 */
22
23 /* "This product is not manufactured, approved, or supported by
24 * Corel Corporation or Corel Corporation Limited."
25 */
26
27 // WPXTable: an intermediate representation of a table, designed to be created
28 // "ahead of time". unlike wordperfect's table definition messages, this representation
29 // is _consistent_: we can always count on the messages being sent using this representation
30 // (once it is created and finalized) to be reliable (assuming no bugs in this code!) :-)
31 //
32 // example situation where this might be useful: WordPerfect allows two cells,
33 // side by side, one with border, one without-- creating a false ambiguity (none
34 // actually exists: if one cell does not have a border, the other doesn't either)
35
36 #ifndef _WPXTABLE_H
37 #define _WPXTABLE_H
38 #include <vector>
39 #include <stdio.h>
40
41 struct WPXTableCell
42 {
43 WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
44 unsigned char m_colSpan;
45 unsigned char m_rowSpan;
46 unsigned char m_borderBits;
47 };
48
49 class WPXTable
50 {
51 public:
52 WPXTable() : m_tableRows() {}
53 ~WPXTable();
54 void insertRow();
55 void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
56 const WPXTableCell *getCell(size_t i, size_t j)
57 {
58 return (m_tableRows[i])[j];
59 }
60 void makeBordersConsistent();
61 void _makeCellBordersConsistent(WPXTableCell *cell, std::vector<WPXTableCell *> &adjacentCells,
62 int adjacencyBitCell, int adjacencyBitBoundCells);
63 std::vector<WPXTableCell *> _getCellsBottomAdjacent(int i, int j);
64 std::vector<WPXTableCell *> _getCellsRightAdjacent(int i, int j);
65
66 const std::vector< std::vector<WPXTableCell *> > &getRows() const
67 {
68 return m_tableRows;
69 }
70 bool isEmpty() const
71 {
72 return m_tableRows.empty();
73 }
74
75 private:
76 std::vector< std::vector<WPXTableCell *> > m_tableRows;
77 };
78
79 class WPXTableList
80 {
81 public:
82 WPXTableList();
83 WPXTableList(const WPXTableList &);
84 WPXTableList &operator=(const WPXTableList &tableList);
85 virtual ~WPXTableList();
86
87 WPXTable *operator[](unsigned long i)
88 {
89 return (*m_tableList)[i];
90 }
91 void add(WPXTable *table)
92 {
93 m_tableList->push_back(table);
94 }
95
96 private:
97 void release();
98 void acquire(int *refCount, std::vector<WPXTable *> *tableList);
99 int *getRef() const
100 {
101 return m_refCount;
102 }
103 std::vector<WPXTable *> *get() const
104 {
105 return m_tableList;
106 }
107
108 std::vector<WPXTable *> *m_tableList;
109 int *m_refCount;
110 };
111 #endif /* _WPXTABLE_H */
112 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXTableCell::m_rowSpan
unsigned char m_rowSpan
Definition: WPXTable.h:45
WPXTable::getCell
const WPXTableCell * getCell(size_t i, size_t j)
Definition: WPXTable.h:56
WPXTableList::getRef
int * getRef() const
Definition: WPXTable.h:99
WPXTable
Definition: WPXTable.h:49
WPXTable::isEmpty
bool isEmpty() const
Definition: WPXTable.h:70
WPXTableList::WPXTableList
WPXTableList()
Definition: WPXTable.cpp:158
WPXTableList::operator=
WPXTableList & operator=(const WPXTableList &tableList)
Definition: WPXTable.cpp:173
WPXTable::insertCell
void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:56
WPXTableList
Definition: WPXTable.h:79
WPXTable::m_tableRows
std::vector< std::vector< WPXTableCell * > > m_tableRows
Definition: WPXTable.h:76
WPXTableCell
Definition: WPXTable.h:41
WPXTableList::m_tableList
std::vector< WPXTable * > * m_tableList
Definition: WPXTable.h:108
WPXTableList::acquire
void acquire(int *refCount, std::vector< WPXTable * > *tableList)
Definition: WPXTable.cpp:184
WPXTable::getRows
const std::vector< std::vector< WPXTableCell * > > & getRows() const
Definition: WPXTable.h:66
WPXTable::_getCellsRightAdjacent
std::vector< WPXTableCell * > _getCellsRightAdjacent(int i, int j)
Definition: WPXTable.cpp:134
WPXTableCell::m_colSpan
unsigned char m_colSpan
Definition: WPXTable.h:44
WPXTableList::release
void release()
Definition: WPXTable.cpp:192
WPXTable::insertRow
void insertRow()
Definition: WPXTable.cpp:51
WPXTableList::m_refCount
int * m_refCount
Definition: WPXTable.h:109
WPXTable::makeBordersConsistent
void makeBordersConsistent()
Definition: WPXTable.cpp:66
WPXTable::WPXTable
WPXTable()
Definition: WPXTable.h:52
WPXTableList::~WPXTableList
virtual ~WPXTableList()
Definition: WPXTable.cpp:208
WPXTableList::operator[]
WPXTable * operator[](unsigned long i)
Definition: WPXTable.h:87
WPXTable::~WPXTable
~WPXTable()
Definition: WPXTable.cpp:38
WPXTableList::add
void add(WPXTable *table)
Definition: WPXTable.h:91
WPXTable::_getCellsBottomAdjacent
std::vector< WPXTableCell * > _getCellsBottomAdjacent(int i, int j)
Definition: WPXTable.cpp:114
WPXTable::_makeCellBordersConsistent
void _makeCellBordersConsistent(WPXTableCell *cell, std::vector< WPXTableCell * > &adjacentCells, int adjacencyBitCell, int adjacencyBitBoundCells)
Definition: WPXTable.cpp:89
WPXTableCell::WPXTableCell
WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:31
WPXTableCell::m_borderBits
unsigned char m_borderBits
Definition: WPXTable.h:46