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  * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
4  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
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 "libwpd_types.h"
40 
41 typedef struct _WPXTableCell WPXTableCell;
42 
44 {
45  _WPXTableCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits);
46  uint8_t m_colSpan;
47  uint8_t m_rowSpan;
48  uint8_t m_borderBits;
49 };
50 
51 class WPXTable
52 {
53 public:
55  ~WPXTable();
56  void insertRow();
57  void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits);
58  const WPXTableCell *getCell(int i, int 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.size() == 0;
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: */

Generated for libwpd by doxygen 1.8.3