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 typedef struct _WPXTableCell WPXTableCell;
42 
44 {
45  _WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
46  unsigned char m_colSpan;
47  unsigned char m_rowSpan;
48  unsigned char m_borderBits;
49 };
50 
51 class WPXTable
52 {
53 public:
55  ~WPXTable();
56  void insertRow();
57  void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
58  const WPXTableCell *getCell(size_t i, size_t j)
59  {
60  return (m_tableRows[i])[j];
61  }
62  void makeBordersConsistent();
63  void _makeCellBordersConsistent(WPXTableCell *cell, std::vector<WPXTableCell *> &adjacentCells,
64  int adjacencyBitCell, int adjacencyBitBoundCells);
65  std::vector<WPXTableCell *> _getCellsBottomAdjacent(int i, int j);
66  std::vector<WPXTableCell *> _getCellsRightAdjacent(int i, int j);
67 
68  const std::vector< std::vector<WPXTableCell *> > &getRows() const
69  {
70  return m_tableRows;
71  }
72  bool isEmpty() const
73  {
74  return m_tableRows.empty();
75  }
76 
77 private:
78  std::vector< std::vector<WPXTableCell *> > m_tableRows;
79 };
80 
82 {
83 public:
84  WPXTableList();
85  WPXTableList(const WPXTableList &);
86  WPXTableList &operator=(const WPXTableList &tableList);
87  virtual ~WPXTableList();
88 
89  WPXTable *operator[](unsigned long i)
90  {
91  return (*m_tableList)[i];
92  }
93  void add(WPXTable *table)
94  {
95  m_tableList->push_back(table);
96  }
97 
98 private:
99  void release();
100  void acquire(int *refCount, std::vector<WPXTable *> *tableList);
101  int *getRef() const
102  {
103  return m_refCount;
104  }
105  std::vector<WPXTable *> *get() const
106  {
107  return m_tableList;
108  }
109 
110  std::vector<WPXTable *> *m_tableList;
112 };
113 #endif /* _WPXTABLE_H */
114 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
_WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:31
unsigned char m_colSpan
Definition: WPXTable.h:46
unsigned char m_rowSpan
Definition: WPXTable.h:47
const WPXTableCell * getCell(size_t i, size_t j)
Definition: WPXTable.h:58
int * getRef() const
Definition: WPXTable.h:101
Definition: WPXTable.h:51
bool isEmpty() const
Definition: WPXTable.h:72
WPXTableList()
Definition: WPXTable.cpp:158
WPXTableList & operator=(const WPXTableList &tableList)
Definition: WPXTable.cpp:173
void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:56
Definition: WPXTable.h:43
Definition: WPXTable.h:81
std::vector< std::vector< WPXTableCell * > > m_tableRows
Definition: WPXTable.h:78
std::vector< WPXTable * > * m_tableList
Definition: WPXTable.h:110
void acquire(int *refCount, std::vector< WPXTable * > *tableList)
Definition: WPXTable.cpp:184
const std::vector< std::vector< WPXTableCell * > > & getRows() const
Definition: WPXTable.h:68
std::vector< WPXTableCell * > _getCellsRightAdjacent(int i, int j)
Definition: WPXTable.cpp:134
void release()
Definition: WPXTable.cpp:192
void insertRow()
Definition: WPXTable.cpp:51
int * m_refCount
Definition: WPXTable.h:111
unsigned char m_borderBits
Definition: WPXTable.h:48
void makeBordersConsistent()
Definition: WPXTable.cpp:66
WPXTable()
Definition: WPXTable.h:54
virtual ~WPXTableList()
Definition: WPXTable.cpp:208
WPXTable * operator[](unsigned long i)
Definition: WPXTable.h:89
~WPXTable()
Definition: WPXTable.cpp:38
void add(WPXTable *table)
Definition: WPXTable.h:93
std::vector< WPXTableCell * > _getCellsBottomAdjacent(int i, int j)
Definition: WPXTable.cpp:114
void _makeCellBordersConsistent(WPXTableCell *cell, std::vector< WPXTableCell * > &adjacentCells, int adjacencyBitCell, int adjacencyBitBoundCells)
Definition: WPXTable.cpp:89

Generated for libwpd by doxygen 1.8.8