/* This file is part of the KDE project Copyright (C) 2001, 2002, 2003, 2004 Nicolas GOUTTE This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ /* This file is based on the old file: /home/kde/koffice/filters/kword/ascii/asciiexport.cc The old file was copyrighted by Copyright (C) 1998, 1999 Reginald Stadlbauer Copyright (c) 2000 ID-PRO Deutschland GmbH. All rights reserved. Contact: Wolf-Michael Bolle The old file was licensed under the terms of the GNU Library General Public License version 2. */ #ifndef _EXPORTFILTER_H #define _EXPORTFILTER_H #include #include #include #include #define STRICT_OOWRITER_VERSION_1 class KZip; class StyleMap : public TQMap { public: StyleMap(void) {} ~StyleMap(void) {} }; class OOWriterWorker : public KWEFBaseWorker { public: OOWriterWorker(void); virtual ~OOWriterWorker(void) { delete m_streamOut; } public: /// What is the type of the frameset anchor enum AnchorType { AnchorUnknown = 0, // ### TODO: is this really needed? AnchorInlined, ///< The frameset is inlined AnchorNonInlined, ///< the frameset is not inlined AnchorTextImage ///< This is a text image (KWord 0.8; inlined; only for pictures) }; public: virtual bool doOpenFile(const TQString& filenameOut, const TQString& to); virtual bool doCloseFile(void); ///< Close file in normal conditions virtual bool doOpenDocument(void); virtual bool doCloseDocument(void); virtual bool doFullParagraph(const TQString& paraText, const LayoutData& tqlayout, const ValueListFormatData& paraFormatDataList); virtual bool doFullPaperFormat(const int format, const double width, const double height, const int orientation); virtual bool doFullPaperBorders (const double top, const double left, const double bottom, const double right); /** * Other data of KWord's \ which are not in @see doFullPaperFormat * @since 1.4 */ virtual bool doFullPaperFormatOther ( const int columns, const double columnspacing, const int numPages ); virtual bool doOpenStyles(void); virtual bool doCloseStyles(void); virtual bool doFullDefineStyle(LayoutData& tqlayout); virtual bool doFullDocumentInfo(const KWEFDocumentInfo& docInfo); virtual bool doVariableSettings(const VariableSettingsData& vs); virtual bool doOpenBody (void); virtual bool doDeclareNonInlinedFramesets( TQValueList& pictureAnchors, TQValueList& tableAnchors ); ///< @since 1.4 private: void processParagraphData (const TQString& paraText, const TextFormatting& formatLayout, const ValueListFormatData& paraFormatDataList); void processNormalText ( const TQString& paraText, const TextFormatting& formatLayout, const FormatData& formatData); void processFootnote( const VariableData& variable ); void processNote( const VariableData& variable ); void processVariable ( const TQString& paraText, const TextFormatting& formatLayout, const FormatData& formatData); void processAnchor ( const TQString& paraText, const TextFormatting& formatLayout, const FormatData& formatData); void processTextImage ( const TQString&, const TextFormatting& formatLayout, const FormatData& formatData); TQString textFormatToStyle(const TextFormatting& formatOrigin, const TextFormatting& formatData, const bool force, TQString& key); TQString layoutToParagraphStyle(const LayoutData& layoutOrigin, const LayoutData& tqlayout, const bool force, TQString& styleKey); TQString escapeOOText(const TQString& strText) const; TQString escapeOOSpan(const TQString& strText) const; TQString cellToProperties( const TableCell& cell, TQString& key) const; bool makeTableRows( const TQString& tableName, const Table& table, int firstRowNumber ); bool makeTable( const FrameAnchor& anchor, const AnchorType anchorType ); bool makePicture( const FrameAnchor& anchor, const AnchorType anchorType ); bool convertUnknownPicture(const TQString& name, const TQString& extension, TQByteArray& image); void declareFont(const TQString& fontName); void writeFontDeclaration(void); void writeContentXml(void); void writeStylesXml(void); void writeMetaXml(void); void writeStartOfFile(const TQString& type); /** * For automatic styles: create the name from @p prefix and from the increased @p counter * (Yes, the counter is increased by the method.) */ TQString makeAutomaticStyleName(const TQString& prefix, ulong& counter) const; private: // ZIP methods bool zipPrepareWriting(const TQString& name); bool zipDoneWriting(void); bool zipWriteData(const char* str); bool zipWriteData(const TQByteArray& array); bool zipWriteData(const TQCString& cstr); bool zipWriteData(const TQString& str); ///< Assumes UTF-8 private: TQTextStream* m_streamOut; TQString m_pagesize; StyleMap m_styleMap; double m_paperBorderTop,m_paperBorderLeft,m_paperBorderBottom,m_paperBorderRight; KWEFDocumentInfo m_docInfo; ///< document information TQByteArray m_contentBody; ///< office:body element of content.xml KZip* m_zip; ///< Output OOWriter file TQMap m_fontNames; ///< List of used font names (the data() are extra attributes for font declaration time.) ulong m_pictureNumber; ///< Number of picture (increment *before* use) ulong m_automaticParagraphStyleNumber; ///< Number of paragraph-based automatic styles (increment *before* use) ulong m_automaticTextStyleNumber; ///< Number of text-based automatic styles (increment *before* use) ulong m_footnoteNumber; ///< Number of footnote (for text:id) (increment *before* use) ulong m_tableNumber; ///< Number of table (for table:name) (increment *before* use) ulong m_textBoxNumber; ///< Number of a textbox (for draw:text-box) (increment *before* use) TQString m_styles; ///< Normal paragraph styles (in OO format) TQString m_contentAutomaticStyles; ///< Automatic styles for content.xml (in OO format) uint m_size; ///< Size of ZIP entry int m_paperFormat; double m_paperWidth; double m_paperHeight; int m_paperOrientation; TQMap m_mapTextStyleKeys; ///< Map of keys to automatic text styles TQMap m_mapParaStyleKeys; ///< Map of keys to automatic paragraph styles VariableSettingsData m_varSet; ///< KWord's \ int m_numPages; ///< Number of pages @note if the input file comes from a filter, this data is often missing. double m_columnspacing; ///< Spacing between columns int m_columns; ///< Number of columns private: // Variable that would need a link/glue from libexport TQValueList m_nonInlinedPictureAnchors; ///< Pseudo-anchors for non-inlined anchors \todo: connection to libexport TQValueList m_nonInlinedTableAnchors; ///< Pseudo-anchors for non-inlined tables \todo: connection to libexport }; #endif // _EXPORTFILTER_H