| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef POWER_POINT3_PARSER |
| 35 |
# define POWER_POINT3_PARSER |
| 36 |
|
| 37 |
#include <map> |
| 38 |
#include <set> |
| 39 |
#include <vector> |
| 40 |
|
| 41 |
#include "MWAWDebug.hxx" |
| 42 |
#include "MWAWInputStream.hxx" |
| 43 |
|
| 44 |
#include "MWAWParser.hxx" |
| 45 |
|
| 46 |
namespace PowerPoint3ParserInternal |
| 47 |
{ |
| 48 |
struct FieldParser; |
| 49 |
struct Frame; |
| 50 |
struct Polygon; |
| 51 |
struct Ruler; |
| 52 |
struct Slide; |
| 53 |
struct SlideContent; |
| 54 |
struct SlideFormat; |
| 55 |
struct State; |
| 56 |
struct TextZone; |
| 57 |
|
| 58 |
class SubDocument; |
| 59 |
} |
| 60 |
|
| 61 |
/** \brief the main class to read a Microsoft PowerPoint v3 or v4 files (MacOs and Windows) |
| 62 |
*/ |
| 63 |
class PowerPoint3Parser final : public MWAWPresentationParser |
| 64 |
{ |
| 65 |
friend class PowerPoint3ParserInternal::SubDocument; |
| 66 |
public: |
| 67 |
//! constructor |
| 68 |
PowerPoint3Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header); |
| 69 |
//! destructor |
| 70 |
~PowerPoint3Parser() final; |
| 71 |
|
| 72 |
//! checks if the document header is correct (or not) |
| 73 |
bool checkHeader(MWAWHeader *header, bool strict=false) final; |
| 74 |
|
| 75 |
// the main parse function |
| 76 |
void parse(librevenge::RVNGPresentationInterface *documentInterface) final; |
| 77 |
|
| 78 |
protected: |
| 79 |
//! creates the listener which will be associated to the document |
| 80 |
void createDocument(librevenge::RVNGPresentationInterface *documentInterface); |
| 81 |
|
| 82 |
//! finds the different zones |
| 83 |
bool createZones(); |
| 84 |
//! try to send all slides |
| 85 |
void sendSlides(); |
| 86 |
|
| 87 |
//! try to read the list of zones |
| 88 |
bool readListZones(int &docInfoId); |
| 89 |
//! try to read a list of structure |
| 90 |
bool readStructList(MWAWEntry const &entry, PowerPoint3ParserInternal::FieldParser &parser); |
| 91 |
|
| 92 |
// |
| 93 |
// internal level |
| 94 |
// |
| 95 |
|
| 96 |
//! try to read a color list |
| 97 |
bool readColors(MWAWEntry const &entry); |
| 98 |
//! try to read a color zone, probably used to define the menu, ...: the 8th zone |
| 99 |
bool readColorZone(MWAWEntry const &entry); |
| 100 |
//! try to read the document info zone |
| 101 |
bool readDocInfo(MWAWEntry const &entry); |
| 102 |
//! try to read the main child of doc info |
| 103 |
bool readDocRoot(MWAWEntry const &entry); |
| 104 |
//! try to read a font |
| 105 |
bool readFont(MWAWFont &font, int schemeId); |
| 106 |
//! try to read a font names list |
| 107 |
bool readFontNamesList(std::map<int,int> const &fIdtoZIdMap); |
| 108 |
//! try to read a font name : 11th zone |
| 109 |
bool readFontName(MWAWEntry const &entry, int id); |
| 110 |
//! try to read a frame zone in a page |
| 111 |
bool readFramesList(MWAWEntry const &entry, PowerPoint3ParserInternal::SlideContent &content); |
| 112 |
//! try to read a paragraph |
| 113 |
bool readParagraph(MWAWParagraph ¶, PowerPoint3ParserInternal::Ruler const &ruler, int schemeId); |
| 114 |
//! try to read the picture definition |
| 115 |
bool readPictureDefinition(MWAWEntry const &entry, int id); |
| 116 |
//! try to read the first child of the picture |
| 117 |
bool readPictureContent(MWAWEntry const &entry, MWAWEmbeddedObject &pict); |
| 118 |
//! try to read the 5th zone |
| 119 |
bool readPictureMain(MWAWEntry const &entry); |
| 120 |
//! try to read a picture list |
| 121 |
bool readPicturesList(std::map<int,int> const &pIdtoZIdMap); |
| 122 |
//! try to read a print info zone |
| 123 |
bool readPrintInfo(MWAWEntry const &entry); |
| 124 |
//! try to read some ruler |
| 125 |
bool readRuler(MWAWEntry const &entry, int id); |
| 126 |
//! try to read a scheme |
| 127 |
bool readScheme(MWAWEntry const &entry, int id); |
| 128 |
//! try to read a slide main zone |
| 129 |
bool readSlide(MWAWEntry const &entry, PowerPoint3ParserInternal::Slide &slide, int zId); |
| 130 |
//! try to read the second/third child of slideMain: main, master ? |
| 131 |
bool readSlideContent(MWAWEntry const &entry, PowerPoint3ParserInternal::SlideContent &slide); |
| 132 |
//! try to read the second child of slide content which contains some shadow offset... |
| 133 |
bool readSlideFormats(MWAWEntry const &entry, std::vector<PowerPoint3ParserInternal::SlideFormat> &formatList); |
| 134 |
//! try to read the third child of slide content |
| 135 |
bool readSlidePolygons(MWAWEntry const &entry, std::vector<PowerPoint3ParserInternal::Polygon> &polyList); |
| 136 |
//! try to read the first child of slideMain |
| 137 |
bool readSlideTransition(MWAWEntry const &entry); |
| 138 |
//! try to read the first child of docRoot |
| 139 |
bool readSlidesList(MWAWEntry const &entry); |
| 140 |
//! try to read a text zone |
| 141 |
bool readTextZone(MWAWEntry const &entry, PowerPoint3ParserInternal::SlideContent &content); |
| 142 |
|
| 143 |
|
| 144 |
// |
| 145 |
// send data |
| 146 |
// |
| 147 |
//! try to send a slide |
| 148 |
bool sendSlide(PowerPoint3ParserInternal::SlideContent const &slide, bool master); |
| 149 |
//! try to send a frame zone |
| 150 |
bool sendFrame(PowerPoint3ParserInternal::Frame const &frame, PowerPoint3ParserInternal::SlideContent const &content, bool master, std::set<int> &seen); |
| 151 |
//! try to send a text zone |
| 152 |
bool sendText(PowerPoint3ParserInternal::SlideContent const &slide, int tId, bool placeHolder, bool master); |
| 153 |
|
| 154 |
// |
| 155 |
// low level |
| 156 |
// |
| 157 |
//! try to read the 9th zone |
| 158 |
bool readZone9(MWAWEntry const &entry); |
| 159 |
//! try to read the 10th zone |
| 160 |
bool readZone10(MWAWEntry const &entry); |
| 161 |
|
| 162 |
|
| 163 |
//! try to return a color corresponding to a scheme and color |
| 164 |
bool getColor(int colorId, int schemeId, MWAWColor &color) const; |
| 165 |
//! check for unparsed zone |
| 166 |
void checkForUnparsedZones(); |
| 167 |
protected: |
| 168 |
// |
| 169 |
// data |
| 170 |
// |
| 171 |
//! the state |
| 172 |
std::shared_ptr<PowerPoint3ParserInternal::State> m_state; |
| 173 |
}; |
| 174 |
#endif |
| 175 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |