MSPUBParser2k.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libmspub
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
17  *
18  * All Rights Reserved.
19  *
20  * For minor contributions see the git repository.
21  *
22  * Alternatively, the contents of this file may be used under the terms of
23  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26  * instead of those above.
27  */
28 
29 #ifndef __MSPUBPARSER2K_H__
30 #define __MSPUBPARSER2K_H__
31 
32 #include <vector>
33 #include <map>
34 
35 #include "MSPUBParser.h"
36 #include "ShapeType.h"
37 
38 namespace libmspub
39 {
40 
41 class MSPUBParser2k : public MSPUBParser
42 {
43  static ShapeType getShapeType(unsigned char shapeSpecifier);
44  std::vector<unsigned> m_imageDataChunkIndices;
45  std::vector<unsigned> m_quillColorEntries;
46  std::map<unsigned, std::vector<unsigned> > m_chunkChildIndicesById;
47 
48 protected:
49  // helper functions
50  bool parse2kShapeChunk(const ContentChunkReference &chunk, WPXInputStream *input,
51  boost::optional<unsigned> pageSeqNum = boost::optional<unsigned>(),
52  bool topLevelCall = true);
53  void parseShapeLine(WPXInputStream *input, bool isRectangle, unsigned offset, unsigned seqNum);
54  void parseShapeType(WPXInputStream *input,
55  unsigned seqNum, unsigned chunkOffset,
56  bool &isGroup, bool &isLine, bool &isImage, bool &isRectangle,
57  unsigned &flagsOffset);
58  void parseShapeRotation(WPXInputStream *input, bool isGroup, bool isLine, unsigned seqNum,
59  unsigned chunkOffset);
60  void parseShapeFlips(WPXInputStream *input, unsigned flagsOffset, unsigned seqNum,
61  unsigned chunkOffset);
62  void parseShapeCoordinates(WPXInputStream *input, unsigned seqNum, unsigned chunkOffset);
63  bool parseGroup(WPXInputStream *input, unsigned seqNum, unsigned page);
64  void assignShapeImgIndex(unsigned seqNum);
65  void parseShapeFill(WPXInputStream *input, unsigned seqNum, unsigned chunkOffset);
66  bool parseContents(WPXInputStream *input);
67  virtual bool parseDocument(WPXInputStream *input);
68  virtual unsigned getColorIndexByQuillEntry(unsigned entry);
69  virtual int translateCoordinateIfNecessary(int coordinate) const;
70  virtual unsigned getFirstLineOffset() const;
71  virtual unsigned getSecondLineOffset() const;
72  virtual unsigned getShapeFillTypeOffset() const;
73  virtual unsigned getShapeFillColorOffset() const;
74  virtual unsigned short getTextMarker() const;
75  virtual unsigned getTextIdOffset() const;
76  static Color getColorBy2kIndex(unsigned char index);
77  static Color getColorBy2kHex(unsigned hex);
78  static unsigned translate2kColorReference(unsigned ref2k);
79  static PageType getPageTypeBySeqNum(unsigned seqNum);
80  virtual void parseContentsTextIfNecessary(WPXInputStream *input);
81 public:
82  explicit MSPUBParser2k(WPXInputStream *input, MSPUBCollector *collector);
83  virtual bool parse();
84  virtual ~MSPUBParser2k();
85 };
86 
87 } // namespace libmspub
88 
89 #endif // __MSPUBPARSER2K_H__
90 
91 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
static Color getColorBy2kHex(unsigned hex)
Definition: MSPUBParser2k.cpp:84
std::vector< unsigned > m_imageDataChunkIndices
Definition: MSPUBParser2k.h:44
Definition: MSPUBTypes.h:185
virtual ~MSPUBParser2k()
Definition: MSPUBParser2k.cpp:63
void assignShapeImgIndex(unsigned seqNum)
Definition: MSPUBParser2k.cpp:596
Definition: MSPUBParser2k.h:41
virtual unsigned getSecondLineOffset() const
Definition: MSPUBParser2k.cpp:709
void parseShapeType(WPXInputStream *input, unsigned seqNum, unsigned chunkOffset, bool &isGroup, bool &isLine, bool &isImage, bool &isRectangle, unsigned &flagsOffset)
Definition: MSPUBParser2k.cpp:642
std::map< unsigned, std::vector< unsigned > > m_chunkChildIndicesById
Definition: MSPUBParser2k.h:46
static unsigned translate2kColorReference(unsigned ref2k)
Definition: MSPUBParser2k.cpp:221
virtual int translateCoordinateIfNecessary(int coordinate) const
Definition: MSPUBParser2k.cpp:624
virtual unsigned getColorIndexByQuillEntry(unsigned entry)
Definition: MSPUBParser2k.cpp:50
void parseShapeRotation(WPXInputStream *input, bool isGroup, bool isLine, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:480
virtual unsigned getTextIdOffset() const
Definition: MSPUBParser2k.cpp:694
virtual unsigned short getTextMarker() const
Definition: MSPUBParser2k.cpp:699
Definition: MSPUBTypes.h:86
std::vector< unsigned > m_quillColorEntries
Definition: MSPUBParser2k.h:45
virtual unsigned getFirstLineOffset() const
Definition: MSPUBParser2k.cpp:704
PageType
Definition: MSPUBTypes.h:192
virtual bool parse()
Definition: MSPUBParser2k.cpp:752
bool parseGroup(WPXInputStream *input, unsigned seqNum, unsigned page)
Definition: MSPUBParser2k.cpp:579
MSPUBParser2k(WPXInputStream *input, MSPUBCollector *collector)
Definition: MSPUBParser2k.cpp:42
static PageType getPageTypeBySeqNum(unsigned seqNum)
Definition: MSPUBParser2k.cpp:781
void parseShapeFill(WPXInputStream *input, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:566
static Color getColorBy2kIndex(unsigned char index)
Definition: MSPUBParser2k.cpp:99
void parseShapeCoordinates(WPXInputStream *input, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:613
virtual void parseContentsTextIfNecessary(WPXInputStream *input)
Definition: MSPUBParser2k.cpp:333
void parseShapeLine(WPXInputStream *input, bool isRectangle, unsigned offset, unsigned seqNum)
Definition: MSPUBParser2k.cpp:714
virtual unsigned getShapeFillTypeOffset() const
Definition: MSPUBParser2k.cpp:556
Definition: MSPUBCollector.h:66
Definition: MSPUBParser.h:85
void parseShapeFlips(WPXInputStream *input, unsigned flagsOffset, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:629
virtual unsigned getShapeFillColorOffset() const
Definition: MSPUBParser2k.cpp:561
static ShapeType getShapeType(unsigned char shapeSpecifier)
Definition: MSPUBParser2k.cpp:237
ShapeType
Definition: ShapeType.h:34
virtual bool parseDocument(WPXInputStream *input)
Definition: MSPUBParser2k.cpp:465
bool parseContents(WPXInputStream *input)
Definition: MSPUBParser2k.cpp:337
bool parse2kShapeChunk(const ContentChunkReference &chunk, WPXInputStream *input, boost::optional< unsigned > pageSeqNum=boost::optional< unsigned >(), bool topLevelCall=true)
Definition: MSPUBParser2k.cpp:496

Generated for libmspub by doxygen 1.8.5