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 (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
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 /** \file MWAWDocument.hxx
35  * libmwaw API: main interface functions of the libmwaw
36  *
37  * \see libmwaw.hxx
38  */
39 #ifndef MWAWDOCUMENT_HXX
40 #define MWAWDOCUMENT_HXX
41 
42 #ifdef _WINDLL
43 #  ifdef BUILD_MWAW
44 #    define MWAWLIB _declspec(dllexport)
45 #  else
46 #    define MWAWLIB _declspec(dllimport)
47 #  endif
48 #else // !DLL_EXPORT
49 #  ifdef LIBMWAW_VISIBILITY
50 #    define MWAWLIB __attribute__((visibility("default")))
51 #  else
52 #    define MWAWLIB
53 #  endif
54 #endif
55 
56 namespace librevenge
57 {
58 class RVNGBinaryData;
59 class RVNGDrawingInterface;
60 class RVNGPresentationInterface;
61 class RVNGSpreadsheetInterface;
62 class RVNGTextInterface;
63 class RVNGInputStream;
64 }
65 
66 /**
67 This class provides all the functions needed by applications to parse many pre-MacOSX documents.
68 */
69 class MWAWDocument
70 {
71 public:
72   /** an enum which defines if we have confidence that a file is supported */
73   enum Confidence {
74     MWAW_C_NONE=0/**< not supported */,
75     MWAW_C_UNSUPPORTED_ENCRYPTION /** encryption not supported*/,
76     MWAW_C_SUPPORTED_ENCRYPTION /** encryption supported */,
77     MWAW_C_EXCELLENT /** supported */
78   };
79   /** an enum to define the kind of document */
80   enum Kind {
81     MWAW_K_UNKNOWN=0 /**< unknown*/,
82     MWAW_K_TEXT /** word processing file*/,
83     MWAW_K_DRAW /** vectorized grphic*/,
84     MWAW_K_PAINT /** bitmap graphic*/,
85     MWAW_K_PRESENTATION /** presentation graphic*/,
86     MWAW_K_SPREADSHEET /** spreadsheet */,
87     MWAW_K_DATABASE /** database */
88   };
89   /** an enum which defines the result of the file parsing */
90   enum Result {
91     MWAW_R_OK=0 /**< conversion ok*/,
92     MWAW_R_FILE_ACCESS_ERROR /** problem when accessing file*/,
93     MWAW_R_OLE_ERROR /** problem when reading the OLE structure*/,
94     MWAW_R_PARSE_ERROR /** problem when parsing the file*/,
95     MWAW_R_PASSWORD_MISSMATCH_ERROR /** problem when using the given password*/,
96     MWAW_R_UNKNOWN_ERROR /** unknown error*/
97   };
98   /** an enum to define the different type of document */
99   enum Type {
100     MWAW_T_UNKNOWN=0 /**< Unrecognised file type*/,
101     MWAW_T_ACTA /**Acta (v2 and Classic v1)*/,
102     MWAW_T_ADOBEILLUSTRATOR /** Adobe Illustrator: TODO */,
103     MWAW_T_BEAGLEWORKS /**BeagleWorks (v1.0)/WordPerfect Works (v1.2): export database(as spreadsheet), draw, paint, spreadsheet and text files.*/,
104     MWAW_T_CLARISRESOLVE /**Claris Resolve (v1.1)*/,
105     MWAW_T_CLARISWORKS /**ClarisWorks/AppleWorks: all versions, export database (as spreadsheet), draw(as text), paint, presentation, spreadsheet, text document*/,
106     MWAW_T_DBASE /** DBase: TODO*/,
107     MWAW_T_DOCMAKER /** DocMaker (v4)*/,
108     MWAW_T_EDOC /** eDOC (v2)*/,
109     MWAW_T_FAMILYTREEMAKER /** Family Tree Maker: TODO*/,
110     MWAW_T_FILEMAKER /** FileMaker: TODO*/,
111     MWAW_T_FOXBASE /** FoxBase: TODO*/,
112     MWAW_T_FRAMEMAKER /** FrameMaker: TODO*/,
113     MWAW_T_FULLIMPACT /** FullImpact: TODO*/,
114     MWAW_T_FULLPAINT /** FullPaint: v1 ( same format as MacPaint file)*/,
115     MWAW_T_FULLWRITE /** FullWrite Professional: basic*/,
116     MWAW_T_GREATWORKS /** GreatWorks (v1-v2): export text, drawing, paint and spreadsheet document.*/,
117     MWAW_T_HANMACWORDJ /** HanMac Word-J (v2.0.4) */,
118     MWAW_T_HANMACWORDK /** HanMac Word-K (v2.0.5-2.0.6) */,
119     MWAW_T_INFOGENIE /** InfoGenie: TODO*/,
120     MWAW_T_KALEIDAGRAPH /** Kaleida Graph: TODO*/,
121     MWAW_T_LIGHTWAYTEXT /** LightWayText (only v4 Mac format)*/,
122     MWAW_T_MACDOC /** MacDoc (v1.3)*/,
123     MWAW_T_MACDRAFT /** MacDraft: v1, v4-v5*/,
124     MWAW_T_MACDRAW /** MacDraw: v0-v1 */,
125     MWAW_T_MACDRAWPRO /** MacDraw II: v1.0-v1.1, MacDraw Pro: v1*/,
126     MWAW_T_MACPAINT /** MacPaint: v1-v2 */,
127     MWAW_T_MARINERWRITE /** Mariner Write (only v1.6-v3.5 Mac Classic) */,
128     MWAW_T_MINDWRITE /** MindWrite */,
129     MWAW_T_MORE /** More (v2-3): retrieve the organization part but not the slide/tree parts*/,
130     MWAW_T_MICROSOFTFILE /** Microsoft File(data base): TODO*/,
131     MWAW_T_MICROSOFTMULTIPLAN /** Microsoft Multiplan: v1.11 */,
132     MWAW_T_MICROSOFTWORD /** Microsoft Word  (v1-v5)*/,
133     MWAW_T_MICROSOFTWORKS /** Microsoft Works Mac: export database(as spreadsheet), graphic, spreadsheet and text files.*/,
134     MWAW_T_MACWRITE /** MacWrite */,
135     MWAW_T_MACWRITEPRO /** MacWrite II/Pro*/,
136     MWAW_T_NISUSWRITER /** Nisus Writer (v3.4-v6.5)*/,
137     MWAW_T_OVERVUE /** OverVUE: TODO*/,
138     MWAW_T_PAGEMAKER /** PageMaker: TODO*/,
139     MWAW_T_PIXELPAINT /** PixelPaint: v1-v2.1 */,
140     /** RagTime:
141         -Mac v2.1-v3.2: done,
142         -all v5.0-v6.5: incomplete, only try to retrieve the picture/shape/textboxes
143      */
144     MWAW_T_RAGTIME,
145     MWAW_T_READYSETGO /** Ready,Set,Go!: TODO*/,
146     /** SuperPaint: export drawing and paint v1 document
147 
148      \note the other documents v2-v3 seems to be basic MacPaint/Pict
149      files */
150     MWAW_T_SUPERPAINT,
151     MWAW_T_SYMPOSIUM /** Symposium: TODO*/,
152     MWAW_T_TEACHTEXT /** TeachText/SimpleText*/,
153     MWAW_T_TEXEDIT /** Tex-Edit (v2)*/,
154     MWAW_T_TRAPEZE /** Trapeze spreadsheet: TODO*/,
155     MWAW_T_WINGZ /** Wingz (v1.1)*/,
156     MWAW_T_WRITENOW /** WriteNow*/,
157     MWAW_T_WRITERPLUS /** WriterPlus*/,
158     MWAW_T_XPRESS /** XPress: TODO*/,
159     MWAW_T_ZWRITE /** Z-Write (v1.3)*/,
160     MWAW_T_4DIMENSION /** 4th Dimension: TODO*/,
161 
162     MWAW_T_RESERVED1 /** Used for ClarisDraw v1 file: see below */,
163     MWAW_T_RESERVED2 /** Used for Apple's Pict file: see below */,
164     MWAW_T_RESERVED3 /** Used for Style v1.6: see below */,
165     MWAW_T_RESERVED4 /** Used for FreeHand: see below */,
166     MWAW_T_RESERVED5 /** Used for Cricket Draw: see below */,
167     MWAW_T_RESERVED6 /** Used for MaxWrite: see below */,
168     MWAW_T_RESERVED7 /** Used for MouseWrite: see below */,
169     MWAW_T_RESERVED8 /** Used for PowerPoint: see below */,
170     MWAW_T_RESERVED9 /** Used for Corel Painter: see below*/,
171 
172     //
173     // the reserved 10-29 were added in libmwaw 0.3.17
174     //
175     MWAW_T_RESERVED10 /** Used for Deneba Canvas: see below */,
176     MWAW_T_RESERVED11 /** Used for Drawing Table: see below */,
177     MWAW_T_RESERVED12 /** Used for Jazz Lotus: see below */,
178     MWAW_T_RESERVED13 /** Used for WordMaker: see below */,
179     MWAW_T_RESERVED14 /** Used for Student Writing Center: see below */,
180     MWAW_T_RESERVED15 /** Reserved for future used */,
181     MWAW_T_RESERVED16 /** Reserved for future used */,
182     MWAW_T_RESERVED17 /** Reserved for future used */,
183     MWAW_T_RESERVED18 /** Reserved for future used */,
184     MWAW_T_RESERVED19 /** Reserved for future used */,
185     MWAW_T_RESERVED20 /** Reserved for future used */,
186     MWAW_T_RESERVED21 /** Reserved for future used */,
187     MWAW_T_RESERVED22 /** Reserved for future used */,
188     MWAW_T_RESERVED23 /** Reserved for future used */,
189     MWAW_T_RESERVED24 /** Reserved for future used */,
190     MWAW_T_RESERVED25 /** Reserved for future used */,
191     MWAW_T_RESERVED26 /** Reserved for future used */,
192     MWAW_T_RESERVED27 /** Reserved for future used */,
193     MWAW_T_RESERVED28 /** Reserved for future used */,
194     MWAW_T_RESERVED29 /** Reserved for future used */,
195 
196     /**Claris Draw: v1.0.1-v1.0.3.
197        \note same enum as \a MWAW_T_RESERVED1 */
198     MWAW_T_CLARISDRAW=MWAW_T_RESERVED1,
199     /**Apple Pict: v1 or v2.
200        \note same enum as \a MWAW_T_RESERVED2*/
201     MWAW_T_APPLEPICT=MWAW_T_RESERVED2,
202     /**Style: v1.6, v1.9
203        \note same enum as \a MWAW_T_RESERVED3*/
204     MWAW_T_STYLE=MWAW_T_RESERVED3,
205     /**FreeHand: v1
206        \note same enum as \a MWAW_T_RESERVED4*/
207     MWAW_T_FREEHAND=MWAW_T_RESERVED4,
208     /**Cricket Draw: v1.0.1 and v1.1.1
209        \note same enum as \a MWAW_T_RESERVED5*/
210     MWAW_T_CRICKETDRAW=MWAW_T_RESERVED5,
211     /**MaxWrite: v1
212        \note same enum as \a MWAW_T_RESERVED6*/
213     MWAW_T_MAXWRITE=MWAW_T_RESERVED6,
214     /** MouseWrite: v1
215      \note same enum as \a MWAW_T_RESERVED7*/
216     MWAW_T_MOUSEWRITE=MWAW_T_RESERVED7,
217     /** PowerPoint: v1-v4 and pc v2-v4,95
218      \note same enum as \a MWAW_T_RESERVED8*/
219     MWAW_T_POWERPOINT=MWAW_T_RESERVED8,
220     /** Corel Painter: Fractal Design Painter Mac v1-v4, MetaCreations Mac v5-v6, Corel Painter Mac v7-v10
221         and Fractal Design Painter Windows v3
222      \note same enum as \a MWAW_T_RESERVED9
223      */
224     MWAW_T_CORELPAINTER=MWAW_T_RESERVED9,
225     /** Deneba Canvas mac: v2-v3 and v5-v8, windows: v3 and v5-v6 and probably v7-v8
226         ADC Canvas mac: v9-v10, windows: probably v9-v11
227      \note same enum as \a MWAW_T_RESERVED10
228     */
229     MWAW_T_CANVAS=MWAW_T_RESERVED10,
230     /** Drawing Table: v1
231      \note same enum as \a MWAW_T_RESERVED11
232     */
233     MWAW_T_DRAWINGTABLE=MWAW_T_RESERVED11,
234     /** Jazz (Lotus): v1 ; retrieve the spreadsheet and if the resource fork is available, the writer document
235         \note same enum as \a MWAW_T_RESERVED12
236     */
237     MWAW_T_JAZZLOTUS=MWAW_T_RESERVED12,
238     /** WordMaker: v1
239         \note same enum as \a MWAW_T_RESERVED13
240      */
241     MWAW_T_WORDMAKER=MWAW_T_RESERVED13,
242     /** Student Writing Center: v1
243         \note same enum as \a MWAW_T_RESERVED14
244      */
245     MWAW_T_STUDENTWRITING=MWAW_T_RESERVED14,
246 
247     /* FORMAT TO ADD:
248        PublishIt, tools to create SlideShow, complexity probably medium-hard
249     */
250   };
251 
252   /** Analyzes the content of an input stream to see if it can be parsed
253       \param input The input stream
254       \param type The document type ( filled if the file is supported )
255       \param kind The document kind ( filled if the file is supported )
256       \return A confidence value which represents the likelyhood that the content from
257       the input stream can be parsed
258 
259       \note encryption enum appears with MWAW_TEXT_VERSION==2 */
260   static MWAWLIB Confidence isFileFormatSupported(librevenge::RVNGInputStream *input, Type &type, Kind &kind);
261 
262   // ------------------------------------------------------------
263   // the different main parsers
264   // ------------------------------------------------------------
265 
266   /** Parses the input stream content. It will make callbacks to the functions provided by a
267      librevenge::RVNGTextInterface class implementation when needed. This is often commonly called the
268      'main parsing routine'.
269      \param input The input stream
270      \param documentInterface A RVNGTextInterface implementation
271      \param password The file password
272 
273    \note password appears with MWAW_TEXT_VERSION==2 */
274   static MWAWLIB Result parse(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *documentInterface, char const *password=nullptr);
275 
276   /** Parses the input stream content. It will make callbacks to the functions provided by a
277      librevenge::RVNGDrawingInterface class implementation when needed. This is often commonly called the
278      'main parsing routine'.
279      \param input The input stream
280      \param documentInterface A RVNGDrawingInterface implementation
281      \param password The file password
282 
283      \note this function appears with MWAW_GRAPHIC_VERSION==2 in libmwaw-0.3
284   */
285   static MWAWLIB Result parse(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *documentInterface, char const *password=nullptr);
286 
287   /** Parses the input stream content. It will make callbacks to the functions provided by a
288      librevenge::RVNGPresentationInterface class implementation when needed. This is often commonly called the
289      'main parsing routine'.
290      \param input The input stream
291      \param documentInterface A RVNGPresentationInterface implementation
292      \param password The file password
293 
294      \note this function appeared in libmwaw-0.3.0 ( and returns MWAW_R_UNKNOWN_ERROR ). It was implemented in libmwaw-0.3.3 ( MWAW_PRESENTATION_VERSION==1 )
295   */
296   static MWAWLIB Result parse(librevenge::RVNGInputStream *input, librevenge::RVNGPresentationInterface *documentInterface, char const *password=nullptr);
297 
298   /** Parses the input stream content. It will make callbacks to the functions provided by a
299      librevenge::RVNGSpreadsheetInterface class implementation when needed. This is often commonly called the
300      'main parsing routine'.
301      \param input The input stream
302      \param documentInterface A RVNGSpreadsheetInterface implementation
303      \param password The file password
304 
305      \note this function appears with MWAW_SPREADSHEET_VERSION==1 in libmwaw-0.3
306   */
307   static MWAWLIB Result parse(librevenge::RVNGInputStream *input, librevenge::RVNGSpreadsheetInterface *documentInterface, char const *password=nullptr);
308 
309   // ------------------------------------------------------------
310   // decoders of the embedded zones created by libmwaw
311   // ------------------------------------------------------------
312 
313   /** Parses the graphic contained in the binary data and called documentInterface to reconstruct
314     a graphic. The input is normally send to a librevenge::RVNGXXXInterface with mimeType="image/mwaw-odg",
315     ie. it must correspond to a picture created by the MWAWGraphicEncoder class via
316     a MWAWPropertyEncoder.
317 
318    \param binary a list of librevenge::RVNGDrawingInterface stored in a documentInterface,
319    \param documentInterface the RVNGDrawingInterface which will convert the graphic is some specific format.
320 
321    \note this function appears with MWAW_GRAPHIC_VERSION==1 in libmwaw-0.2 */
322   static MWAWLIB bool decodeGraphic(librevenge::RVNGBinaryData const &binary, librevenge::RVNGDrawingInterface *documentInterface);
323 
324   /** Parses the spreadsheet contained in the binary data and called documentInterface to reconstruct
325     a spreadsheet. The input is normally send to a librevenge::RVNGXXXInterface with mimeType="image/mwaw-ods",
326     ie. it must correspond to a spreadsheet created by the MWAWSpreadsheetInterface class via
327     a MWAWPropertyEncoder.
328 
329    \param binary a list of librevenge::RVNGSpreadsheetInterface stored in a documentInterface,
330    \param documentInterface the RVNGSpreadsheetInterface which will convert the spreadsheet is some specific format.
331 
332    \note this function appears in libmwaw-0.3.0 (and returns always false).
333    It was only implemented with MWAW_SPREADSHEET_VERSION==2 in libmwaw-0.3.1 */
334   static MWAWLIB bool decodeSpreadsheet(librevenge::RVNGBinaryData const &binary, librevenge::RVNGSpreadsheetInterface *documentInterface);
335 
336   /** Parses the text contained in the binary data and called documentInterface to reconstruct
337     a text. The input is normally send to a librevenge::RVNGXXXInterface with mimeType="image/mwaw-odt",
338     ie. it must correspond to a text created by the MWAWTextInterface class via
339     a MWAWPropertyEncoder.
340 
341    \param binary a list of librevenge::RVNGTextInterface stored in a documentInterface,
342    \param documentInterface the RVNGTextInterface which will convert the text is some specific format.
343 
344    \note Reserved for future use. Actually, it only returns false. */
345   static MWAWLIB bool decodeText(librevenge::RVNGBinaryData const &binary, librevenge::RVNGTextInterface *documentInterface);
346 };
347 
348 #endif /* MWAWDOCUMENT_HXX */
349 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
350