filters

oowriter/ExportFilter.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20/*
21 This file is based on the old file:
22 /home/kde/koffice/filters/kword/ascii/asciiexport.cpp
23
24 The old file was copyrighted by
25 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
26 Copyright (c) 2000 ID-PRO Deutschland GmbH. All rights reserved.
27 Contact: Wolf-Michael Bolle <Bolle@ID-PRO.de>
28
29 The old file was licensed under the terms of the GNU Library General Public
30 License version 2.
31*/
32
33#ifndef _EXPORTFILTER_H
34#define _EXPORTFILTER_H
35
36#include <KWEFStructures.h>
37#include <KWEFUtil.h>
38#include <KWEFBaseWorker.h>
39#include <KWEFKWordLeader.h>
40
41#define STRICT_OOWRITER_VERSION_1
42
43class KZip;
44
45class StyleMap : public TQMap<TQString,LayoutData>
46{
47public:
48 StyleMap(void) {}
49 ~StyleMap(void) {}
50};
51
52class OOWriterWorker : public KWEFBaseWorker
53{
54public:
55 OOWriterWorker(void);
56 virtual ~OOWriterWorker(void) { delete m_streamOut; }
57public:
59 enum AnchorType
60 {
61 AnchorUnknown = 0, // ### TODO: is this really needed?
62 AnchorInlined,
63 AnchorNonInlined,
64 AnchorTextImage
65 };
66public:
67 virtual bool doOpenFile(const TQString& filenameOut, const TQString& to);
68 virtual bool doCloseFile(void);
69 virtual bool doOpenDocument(void);
70 virtual bool doCloseDocument(void);
71 virtual bool doFullParagraph(const TQString& paraText, const LayoutData& layout,
72 const ValueListFormatData& paraFormatDataList);
73 virtual bool doFullPaperFormat(const int format,
74 const double width, const double height, const int orientation);
75 virtual bool doFullPaperBorders (const double top, const double left,
76 const double bottom, const double right);
81 virtual bool doFullPaperFormatOther ( const int columns, const double columnspacing, const int numPages );
82 virtual bool doOpenStyles(void);
83 virtual bool doCloseStyles(void);
84 virtual bool doFullDefineStyle(LayoutData& layout);
85 virtual bool doFullDocumentInfo(const KWEFDocumentInfo& docInfo);
86 virtual bool doVariableSettings(const VariableSettingsData& vs);
87 virtual bool doOpenBody (void);
88 virtual bool doDeclareNonInlinedFramesets( TQValueList<FrameAnchor>& pictureAnchors, TQValueList<FrameAnchor>& tableAnchors );
89private:
90 void processParagraphData (const TQString& paraText,
91 const TextFormatting& formatLayout,
92 const ValueListFormatData& paraFormatDataList);
93 void processNormalText ( const TQString& paraText,
94 const TextFormatting& formatLayout,
95 const FormatData& formatData);
96 void processFootnote( const VariableData& variable );
97 void processNote( const VariableData& variable );
98 void processVariable ( const TQString& paraText,
99 const TextFormatting& formatLayout,
100 const FormatData& formatData);
101 void processAnchor ( const TQString& paraText,
102 const TextFormatting& formatLayout,
103 const FormatData& formatData);
104 void processTextImage ( const TQString&,
105 const TextFormatting& formatLayout,
106 const FormatData& formatData);
107 TQString textFormatToStyle(const TextFormatting& formatOrigin,
108 const TextFormatting& formatData, const bool force, TQString& key);
109 TQString layoutToParagraphStyle(const LayoutData& layoutOrigin,
110 const LayoutData& layout, const bool force, TQString& styleKey);
111 TQString escapeOOText(const TQString& strText) const;
112 TQString escapeOOSpan(const TQString& strText) const;
113 TQString cellToProperties( const TableCell& cell, TQString& key) const;
114 bool makeTableRows( const TQString& tableName, const Table& table, int firstRowNumber );
115 bool makeTable( const FrameAnchor& anchor, const AnchorType anchorType );
116 bool makePicture( const FrameAnchor& anchor, const AnchorType anchorType );
117 bool convertUnknownPicture(const TQString& name, const TQString& extension, TQByteArray& image);
118 void declareFont(const TQString& fontName);
119 void writeFontDeclaration(void);
120 void writeContentXml(void);
121 void writeStylesXml(void);
122 void writeMetaXml(void);
123 void writeStartOfFile(const TQString& type);
128 TQString makeAutomaticStyleName(const TQString& prefix, ulong& counter) const;
129private: // ZIP methods
130 bool zipPrepareWriting(const TQString& name);
131 bool zipDoneWriting(void);
132 bool zipWriteData(const char* str);
133 bool zipWriteData(const TQByteArray& array);
134 bool zipWriteData(const TQCString& cstr);
135 bool zipWriteData(const TQString& str);
136private:
137 TQTextStream* m_streamOut;
138 TQString m_pagesize;
139 StyleMap m_styleMap;
140 double m_paperBorderTop,m_paperBorderLeft,m_paperBorderBottom,m_paperBorderRight;
141 KWEFDocumentInfo m_docInfo;
142 TQByteArray m_contentBody;
143 KZip* m_zip;
144 TQMap<TQString,TQString> m_fontNames;
145
146 ulong m_pictureNumber;
147 ulong m_automaticParagraphStyleNumber;
148 ulong m_automaticTextStyleNumber;
149 ulong m_footnoteNumber;
150 ulong m_tableNumber;
151 ulong m_textBoxNumber;
152
153
154 TQString m_styles;
155 TQString m_contentAutomaticStyles;
156
157 uint m_size;
158 int m_paperFormat;
159 double m_paperWidth;
160 double m_paperHeight;
161 int m_paperOrientation;
162
163 TQMap<TQString,TQString> m_mapTextStyleKeys;
164 TQMap<TQString,TQString> m_mapParaStyleKeys;
165 VariableSettingsData m_varSet;
166 int m_numPages;
167 double m_columnspacing;
168 int m_columns;
169private: // Variable that would need a link/glue from libexport
170 TQValueList<FrameAnchor> m_nonInlinedPictureAnchors;
171 TQValueList<FrameAnchor> m_nonInlinedTableAnchors;
172
173};
174#endif // _EXPORTFILTER_H
Base worker of the libexport system.
virtual bool doOpenStyles(void)
Like HTML's <style>.
virtual bool doCloseStyles(void)
Like HTML's </style>.
virtual bool doOpenBody(void)
Like HTML's <BODY>.