filters

ExportFilter.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 /*
00021    This file is based on the old file:
00022     /home/kde/koffice/filters/kword/ascii/asciiexport.cc
00023 
00024    The old file was copyrighted by
00025     Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00026     Copyright (c) 2000 ID-PRO Deutschland GmbH. All rights reserved.
00027                        Contact: Wolf-Michael Bolle <Bolle@ID-PRO.de>
00028 
00029    The old file was licensed under the terms of the GNU Library General Public
00030    License version 2.
00031 */
00032 
00033 #ifndef _EXPORTFILTER_H
00034 #define _EXPORTFILTER_H
00035 
00036 #include <KWEFStructures.h>
00037 #include <KWEFUtil.h>
00038 #include <KWEFBaseWorker.h>
00039 #include <KWEFKWordLeader.h>
00040 
00041 #define STRICT_OOWRITER_VERSION_1
00042 
00043 class KZip;
00044 
00045 class StyleMap : public QMap<QString,LayoutData>
00046 {
00047 public:
00048     StyleMap(void) {}
00049     ~StyleMap(void) {}
00050 };
00051 
00052 class OOWriterWorker : public KWEFBaseWorker
00053 {
00054 public:
00055     OOWriterWorker(void);
00056     virtual ~OOWriterWorker(void) { delete m_streamOut; }
00057 public:
00059     enum AnchorType
00060     {
00061         AnchorUnknown = 0, // ### TODO: is this really needed?
00062         AnchorInlined, 
00063         AnchorNonInlined, 
00064         AnchorTextImage 
00065     };
00066 public:
00067     virtual bool doOpenFile(const QString& filenameOut, const QString& to);
00068     virtual bool doCloseFile(void); 
00069     virtual bool doOpenDocument(void);
00070     virtual bool doCloseDocument(void);
00071     virtual bool doFullParagraph(const QString& paraText, const LayoutData& layout,
00072         const ValueListFormatData& paraFormatDataList);
00073     virtual bool doFullPaperFormat(const int format,
00074         const double width, const double height, const int orientation);
00075     virtual bool doFullPaperBorders (const double top, const double left,
00076         const double bottom, const double right);
00081     virtual bool doFullPaperFormatOther ( const int columns, const double columnspacing, const int numPages );        
00082     virtual bool doOpenStyles(void);
00083     virtual bool doCloseStyles(void);
00084     virtual bool doFullDefineStyle(LayoutData& layout);
00085     virtual bool doFullDocumentInfo(const KWEFDocumentInfo& docInfo);
00086     virtual bool doVariableSettings(const VariableSettingsData& vs);
00087     virtual bool doOpenBody (void);
00088     virtual bool doDeclareNonInlinedFramesets( QValueList<FrameAnchor>& pictureAnchors, QValueList<FrameAnchor>& tableAnchors ); 
00089 private:
00090     void processParagraphData (const QString& paraText,
00091         const TextFormatting& formatLayout,
00092         const ValueListFormatData& paraFormatDataList);
00093     void processNormalText ( const QString& paraText,
00094         const TextFormatting& formatLayout,
00095         const FormatData& formatData);
00096     void processFootnote( const VariableData& variable );
00097     void processNote( const VariableData& variable );
00098     void processVariable ( const QString& paraText,
00099         const TextFormatting& formatLayout,
00100         const FormatData& formatData);
00101     void processAnchor ( const QString& paraText,
00102         const TextFormatting& formatLayout,
00103         const FormatData& formatData);
00104     void processTextImage ( const QString&,
00105         const TextFormatting& formatLayout,
00106         const FormatData& formatData);
00107     QString textFormatToStyle(const TextFormatting& formatOrigin,
00108         const TextFormatting& formatData, const bool force, QString& key);
00109     QString layoutToParagraphStyle(const LayoutData& layoutOrigin,
00110         const LayoutData& layout, const bool force, QString& styleKey);
00111     QString escapeOOText(const QString& strText) const;
00112     QString escapeOOSpan(const QString& strText) const;
00113     QString cellToProperties( const TableCell& cell, QString& key) const;
00114     bool makeTableRows( const QString& tableName, const Table& table, int firstRowNumber );
00115     bool makeTable( const FrameAnchor& anchor, const AnchorType anchorType );
00116     bool makePicture( const FrameAnchor& anchor, const AnchorType anchorType );
00117     bool convertUnknownPicture(const QString& name, const QString& extension, QByteArray& image);
00118     void declareFont(const QString& fontName);
00119     void writeFontDeclaration(void);
00120     void writeContentXml(void);
00121     void writeStylesXml(void);
00122     void writeMetaXml(void);
00123     void writeStartOfFile(const QString& type);
00128     QString makeAutomaticStyleName(const QString& prefix, ulong& counter) const;
00129 private: // ZIP methods
00130     bool zipPrepareWriting(const QString& name);
00131     bool zipDoneWriting(void);
00132     bool zipWriteData(const char* str);
00133     bool zipWriteData(const QByteArray& array);
00134     bool zipWriteData(const QCString& cstr);
00135     bool zipWriteData(const QString& str); 
00136 private:
00137     QTextStream* m_streamOut;
00138     QString m_pagesize;
00139     StyleMap m_styleMap;
00140     double m_paperBorderTop,m_paperBorderLeft,m_paperBorderBottom,m_paperBorderRight;
00141     KWEFDocumentInfo m_docInfo; 
00142     QByteArray m_contentBody; 
00143     KZip* m_zip; 
00144     QMap<QString,QString> m_fontNames; 
00145 
00146     ulong m_pictureNumber; 
00147     ulong m_automaticParagraphStyleNumber; 
00148     ulong m_automaticTextStyleNumber; 
00149     ulong m_footnoteNumber; 
00150     ulong m_tableNumber; 
00151     ulong m_textBoxNumber; 
00152     
00153 
00154     QString m_styles; 
00155     QString m_contentAutomaticStyles; 
00156 
00157     uint m_size; 
00158     int m_paperFormat;
00159     double m_paperWidth;
00160     double m_paperHeight;
00161     int m_paperOrientation;
00162 
00163     QMap<QString,QString> m_mapTextStyleKeys; 
00164     QMap<QString,QString> m_mapParaStyleKeys; 
00165     VariableSettingsData m_varSet; 
00166     int m_numPages; 
00167     double m_columnspacing; 
00168     int m_columns; 
00169 private: // Variable that would need a link/glue from libexport
00170     QValueList<FrameAnchor> m_nonInlinedPictureAnchors; 
00171     QValueList<FrameAnchor> m_nonInlinedTableAnchors; 
00172 
00173 };
00174 #endif // _EXPORTFILTER_H
KDE Home | KDE Accessibility Home | Description of Access Keys