1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 2 /* libodfgen 3 * Version: MPL 2.0 / LGPLv2.1+ 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * Major Contributor(s): 10 * Copyright (C) 2004 William Lachance (wlach@interlog.com) 11 * 12 * For minor contributions see the git repository. 13 * 14 * Alternatively, the contents of this file may be used under the terms 15 * of the GNU Lesser General Public License Version 2.1 or later 16 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are 17 * applicable instead of those above. 18 * 19 * For further information visit http://libwpd.sourceforge.net 20 */ 21 22 /* "This product is not manufactured, approved, or supported by 23 * Corel Corporation or Corel Corporation Limited." 24 */ 25 #ifndef _ODFDOCUMENTHANDLER_HXX_ 26 #define _ODFDOCUMENTHANDLER_HXX_ 27 #include <librevenge/librevenge.h> 28 29 #include "libodfgen-api.hxx" 30 31 /** Type of ODF content a generator should produce. 32 * 33 * @sa OdgGenerator, OdpGenerator, OdtGenerator 34 */ 35 enum OdfStreamType { ODF_FLAT_XML, ODF_CONTENT_XML, ODF_STYLES_XML, ODF_SETTINGS_XML, ODF_META_XML, ODF_MANIFEST_XML }; 36 37 class OdfDocumentHandler; 38 39 /** Handler for embedded objects. 40 * 41 * @param[in] data the object's data 42 * @param[in] pHandler the current OdfDocumentHandler 43 * @param[in] streamType type of the object 44 */ 45 typedef bool (*OdfEmbeddedObject)(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType); 46 47 /** Handler for embedded images. 48 * 49 * This is also (mis)used for embedded fonts, to avoid API change. In 50 * this case the output format must be TTF. 51 * 52 * @param[in] input the image's data 53 * @param[in] output the same image in format suitable for the used 54 * OdfDocumentHandler. 55 */ 56 typedef bool (*OdfEmbeddedImage)(const librevenge::RVNGBinaryData &input, librevenge::RVNGBinaryData &output); 57 58 /** XML writer. 59 * 60 * This interface is used by the document generators to create a valid 61 * XML document. It is up to the implementation if the document will be 62 * saved to a file, printed to the standard output, saved to a file 63 * inside a package, or whatever else. 64 */ 65 class ODFGENAPI OdfDocumentHandler 66 { 67 public: ~OdfDocumentHandler()68 virtual ~OdfDocumentHandler() {} 69 70 /** Start an XML document. 71 */ 72 virtual void startDocument() = 0; 73 74 /** End the XML document. 75 */ 76 virtual void endDocument() = 0; 77 78 /** Add a start tag to the XML document. 79 * 80 * @param[in] psName name of the element 81 * @param[in] xPropList list of attributes 82 */ 83 virtual void startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList) = 0; 84 85 /** Add a end tag to the XML document. 86 * 87 * @param[in] psName name of the element. It must match the 88 * name of the innermost currently opened element. 89 */ 90 virtual void endElement(const char *psName) = 0; 91 92 /** Insert a textual content into the currently opened element. 93 * 94 * @param[in] sCharacters the content 95 */ 96 virtual void characters(const librevenge::RVNGString &sCharacters) = 0; 97 }; 98 #endif 99 100 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ 101