| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef QUATTRO_9_H |
| 23 |
#define QUATTRO_9_H |
| 24 |
|
| 25 |
#include <map> |
| 26 |
#include <vector> |
| 27 |
|
| 28 |
#include <librevenge-stream/librevenge-stream.h> |
| 29 |
#include "libwps/libwps.h" |
| 30 |
|
| 31 |
#include "libwps_internal.h" |
| 32 |
#include "libwps_tools_win.h" |
| 33 |
|
| 34 |
#include "WPSEntry.h" |
| 35 |
#include "WKSParser.h" |
| 36 |
#include "WPSGraphicStyle.h" |
| 37 |
|
| 38 |
namespace Quattro9ParserInternal |
| 39 |
{ |
| 40 |
class SubDocument; |
| 41 |
struct State; |
| 42 |
|
| 43 |
struct TextEntry |
| 44 |
{ |
| 45 |
|
| 46 |
TextEntry() |
| 47 |
: m_entry() |
| 48 |
, m_fontsList() |
| 49 |
, m_posFontIdMap() |
| 50 |
, m_flag(0) |
| 51 |
, m_extra() |
| 52 |
{ |
| 53 |
} |
| 54 |
|
| 55 |
bool empty() const |
| 56 |
{ |
| 57 |
return !m_entry.valid(); |
| 58 |
} |
| 59 |
|
| 60 |
librevenge::RVNGString getString(std::shared_ptr<WPSStream> const &stream, libwps_tools_win::Font::Type type=libwps_tools_win::Font::WIN3_WEUROPE) const; |
| 61 |
|
| 62 |
void send(std::shared_ptr<WPSStream> const &stream, WPSFont const &font, libwps_tools_win::Font::Type type, WKSContentListenerPtr &listener); |
| 63 |
|
| 64 |
std::string getDebugString(std::shared_ptr<WPSStream> const &stream) const; |
| 65 |
|
| 66 |
WPSEntry m_entry; |
| 67 |
|
| 68 |
std::vector<WPSFont> m_fontsList; |
| 69 |
|
| 70 |
std::map<int, int> m_posFontIdMap; |
| 71 |
|
| 72 |
int m_flag; |
| 73 |
|
| 74 |
std::string m_extra; |
| 75 |
}; |
| 76 |
} |
| 77 |
|
| 78 |
class Quattro9Graph; |
| 79 |
class Quattro9Spreadsheet; |
| 80 |
|
| 81 |
namespace QuattroFormulaInternal |
| 82 |
{ |
| 83 |
class CellReference; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
class Quattro9Parser final : public WKSParser |
| 91 |
{ |
| 92 |
friend class Quattro9ParserInternal::SubDocument; |
| 93 |
friend class Quattro9Graph; |
| 94 |
friend class Quattro9Spreadsheet; |
| 95 |
|
| 96 |
public: |
| 97 |
|
| 98 |
Quattro9Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, |
| 99 |
libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN, |
| 100 |
char const *password=nullptr); |
| 101 |
|
| 102 |
~Quattro9Parser() final; |
| 103 |
|
| 104 |
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final; |
| 105 |
|
| 106 |
bool checkHeader(WPSHeader *header, bool strict=false); |
| 107 |
|
| 108 |
protected: |
| 109 |
|
| 110 |
int version() const; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
libwps_tools_win::Font::Type getDefaultFontType() const; |
| 115 |
|
| 116 |
bool getExternalFileName(int fId, librevenge::RVNGString &fName) const; |
| 117 |
|
| 118 |
bool getField(int fId, librevenge::RVNGString &text, |
| 119 |
QuattroFormulaInternal::CellReference &ref, |
| 120 |
librevenge::RVNGString const &fileName) const; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
bool getFont(int id, WPSFont &font) const; |
| 128 |
|
| 129 |
Vec2f getCellPosition(int sheetId, Vec2i const &cell) const; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
bool getColor(int id, WPSColor &color) const; |
| 137 |
|
| 138 |
bool getPattern(int id, WPSGraphicStyle::Pattern &pattern) const; |
| 139 |
|
| 140 |
bool sendPageGraphics(int sheetId) const; |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface); |
| 148 |
|
| 149 |
|
| 150 |
void sendHeaderFooter(bool header); |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
bool checkHeader(std::shared_ptr<WPSStream> stream, bool strict); |
| 158 |
|
| 159 |
bool readZones(); |
| 160 |
|
| 161 |
bool readZone(std::shared_ptr<WPSStream> &stream); |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
bool readPString(std::shared_ptr<WPSStream> const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry); |
| 167 |
|
| 168 |
bool readFontNames(std::shared_ptr<WPSStream> const &stream); |
| 169 |
|
| 170 |
bool readFontStyles(std::shared_ptr<WPSStream> const &stream); |
| 171 |
|
| 172 |
static bool readFilePositions(std::shared_ptr<WPSStream> const &stream, long (&filePos)[2]); |
| 173 |
|
| 174 |
bool readDocumentFields(std::shared_ptr<WPSStream> const &stream); |
| 175 |
|
| 176 |
bool readDocumentStrings(std::shared_ptr<WPSStream> const &stream); |
| 177 |
|
| 178 |
|
| 179 |
bool readTextStyles(std::shared_ptr<WPSStream> const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry); |
| 180 |
|
| 181 |
bool readTextFontStyles(std::shared_ptr<WPSStream> const &stream, int dataSz, WPSFont &font); |
| 182 |
|
| 183 |
|
| 184 |
void addDocumentStrings(); |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
bool parseOLEStream(RVNGInputStreamPtr input, std::string const &avoid=""); |
| 193 |
|
| 194 |
static bool readOleLinkInfo(std::shared_ptr<WPSStream> stream); |
| 195 |
|
| 196 |
static bool readOleBOlePart(std::shared_ptr<WPSStream> stream); |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, std::vector<uint8_t> const &key); |
| 202 |
|
| 203 |
std::shared_ptr<WKSContentListener> m_listener; |
| 204 |
|
| 205 |
std::shared_ptr<Quattro9ParserInternal::State> m_state; |
| 206 |
|
| 207 |
std::shared_ptr<Quattro9Graph> m_graphParser; |
| 208 |
|
| 209 |
std::shared_ptr<Quattro9Spreadsheet> m_spreadsheetParser; |
| 210 |
}; |
| 211 |
|
| 212 |
#endif |
| 213 |
|