summaryrefslogtreecommitdiff
path: root/src/lib/ABWStylesCollector.h
blob: dfcb684ee9e12c29c154e1436486998810f266cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * This file is part of the libabw project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef __ABWSTYLESCOLLECTOR_H__
#define __ABWSTYLESCOLLECTOR_H__

#include <stack>
#include <librevenge/librevenge.h>
#include "ABWCollector.h"

namespace libabw
{

struct ABWStylesTableState
{
  ABWStylesTableState();
  ABWStylesTableState(const ABWStylesTableState &ts);
  ~ABWStylesTableState();

  ABWPropertyMap m_currentCellProperties;

  int m_currentTableWidth;
  int m_currentTableRow;
  int m_currentTableId;
};

struct ABWStylesParsingState
{
  ABWStylesParsingState();
  ABWStylesParsingState(const ABWStylesParsingState &ps);
  ~ABWStylesParsingState();

  std::stack<ABWStylesTableState> m_tableStates;
};

class ABWStylesCollector : public ABWCollector
{
public:
  ABWStylesCollector(std::map<int, int> &tableSizes,
                     std::map<std::string, ABWData> &data,
                     std::map<int, ABWListElement *> &listElements);
  virtual ~ABWStylesCollector();

  // collector functions

  void collectTextStyle(const char *, const char *, const char *, const char *) {}
  void collectDocumentProperties(const char *) {}
  void collectParagraphProperties(const char *level, const char *listid, const char *parentid,
                                  const char *style, const char *props);
  void collectSectionProperties(const char *, const char *, const char *, const char *,
                                const char *, const char *, const char *, const char *,
                                const char *) {}
  void collectCharacterProperties(const char *, const char *) {}
  void collectPageSize(const char *, const char *, const char *, const char *) {}
  void closeParagraphOrListElement() {}
  void closeSpan() {}
  void openLink(const char *) {}
  void closeLink() {}
  void openFoot(const char *) {}
  void closeFoot() {}
  void openEndnote(const char *) {}
  void closeEndnote() {}
  void openField(const char *, const char *) {}
  void closeField() {}
  void endSection() {}
  void startDocument() {}
  void endDocument() {}
  void insertLineBreak() {}
  void insertColumnBreak() {}
  void insertPageBreak() {}
  void insertText(const char *) {}
  void insertImage(const char *, const char *) {}

  void collectData(const char *name, const char *mimeType, const librevenge::RVNGBinaryData &data);
  void collectHeaderFooter(const char *, const char *) {}
  void collectList(const char *id, const char *listDecimal, const char *listDelim,
                   const char *parentid, const char *startValue, const char *type);

  void openTable(const char *props);
  void closeTable();
  void openCell(const char *props);
  void closeCell();

  void openFrame(const char *, const char *, const char *, const char *) {}
  void closeFrame(ABWOutputElements *(&elements), bool &)
  {
    elements=0;
  }
  void addFrameElements(ABWOutputElements &, bool) {}

  void addMetadataEntry(const char *, const char *) {}

private:
  ABWStylesCollector(const ABWStylesCollector &);
  ABWStylesCollector &operator=(const ABWStylesCollector &);

  std::string _findCellProperty(const char *name);
  void _processList(int id, const char *listDelim, int parentid, int startValue, int type);

  ABWStylesParsingState *m_ps;
  std::map<int, int> &m_tableSizes;
  std::map<std::string, ABWData> &m_data;
  int m_tableCounter;
  std::map<int, ABWListElement *> &m_listElements;
};

} // namespace libabw

#endif /* __ABWSTYLESCOLLECTOR_H__ */
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */