00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _IE_EXP_OPENXML_H_
00025 #define _IE_EXP_OPENXML_H_
00026
00027
00028 #include <ie_exp.h>
00029 #include <ut_debugmsg.h>
00030 #include <ut_types.h>
00031 #include <ut_misc.h>
00032 #include <ut_assert.h>
00033 #include <ut_string_class.h>
00034 #include <pp_Property.h>
00035
00036 #include <OXML_Document.h>
00037 #include <ie_exp_OpenXML_Listener.h>
00038
00039
00040 #include <gsf/gsf-outfile.h>
00041 #include <gsf/gsf-outfile-zip.h>
00042 #include <gsf/gsf-output-stdio.h>
00043 #include <gsf/gsf-output-memory.h>
00044 #include <string>
00045 #include <map>
00046
00047
00048 #define TARGET_DOCUMENT 0
00049 #define TARGET_STYLES 1
00050 #define TARGET_DOCUMENT_RELATION 2
00051 #define TARGET_RELATION 3
00052 #define TARGET_CONTENT 4
00053 #define TARGET_NUMBERING 5
00054 #define TARGET_HEADER 6
00055 #define TARGET_FOOTER 7
00056 #define TARGET_SETTINGS 8
00057 #define TARGET_FOOTNOTE 9
00058 #define TARGET_ENDNOTE 10
00059
00060 class OXML_Document;
00061
00065 class IE_Exp_OpenXML : public IE_Exp
00066 {
00067 public:
00068 IE_Exp_OpenXML (PD_Document * pDocument);
00069 virtual ~IE_Exp_OpenXML ();
00070 UT_Error startDocument();
00071 UT_Error finishDocument();
00072 UT_Error startSection();
00073 UT_Error finishSection();
00074 UT_Error startSectionProperties();
00075 UT_Error finishSectionProperties();
00076 UT_Error startParagraph(int target);
00077 UT_Error finishParagraph(int target);
00078 UT_Error startText(int target);
00079 UT_Error writeText(int target, const UT_UCS4Char* text);
00080 UT_Error finishText(int target);
00081 UT_Error startRun(int target);
00082 UT_Error finishRun(int target);
00083 UT_Error startRunProperties(int target);
00084 UT_Error finishRunProperties(int target);
00085 UT_Error startParagraphProperties(int target);
00086 UT_Error finishParagraphProperties(int target);
00087 UT_Error startCellProperties(int target);
00088 UT_Error finishCellProperties(int target);
00089 UT_Error startStyle(std::string name, std::string basedon, std::string followedby);
00090 UT_Error finishStyle();
00091 UT_Error startTable();
00092 UT_Error finishTable();
00093 UT_Error startTableProperties(int target);
00094 UT_Error finishTableProperties(int target);
00095 UT_Error startTableBorderProperties(int target);
00096 UT_Error finishTableBorderProperties(int target);
00097 UT_Error startCellBorderProperties(int target);
00098 UT_Error finishCellBorderProperties(int target);
00099 UT_Error startListProperties(int target);
00100 UT_Error finishListProperties(int target);
00101 UT_Error startAbstractNumbering(int target, UT_uint32 id);
00102 UT_Error finishAbstractNumbering(int target);
00103 UT_Error startTextBox(int target, const gchar* id);
00104 UT_Error finishTextBox(int target);
00105 UT_Error startTextBoxProperties(int target);
00106 UT_Error finishTextBoxProperties(int target);
00107 UT_Error startTextBoxContent(int target);
00108 UT_Error finishTextBoxContent(int target);
00109 UT_Error startNumbering(int target, UT_uint32 id);
00110 UT_Error finishNumbering(int target);
00111 UT_Error startNumberingLevel(int target, UT_uint32 level);
00112 UT_Error finishNumberingLevel(int target);
00113 UT_Error startRow();
00114 UT_Error finishRow();
00115 UT_Error startRowProperties(int target);
00116 UT_Error finishRowProperties(int target);
00117 UT_Error startCell();
00118 UT_Error finishCell();
00119 UT_Error startTableGrid(int target);
00120 UT_Error finishTableGrid(int target);
00121 UT_Error startExternalHyperlink(const gchar* id);
00122 UT_Error startInternalHyperlink(const gchar* anchor);
00123 UT_Error setHeaderRelation(const char* relId, const char* headerId);
00124 UT_Error setFooterRelation(const char* relId, const char* footerId);
00125 UT_Error finishHyperlink();
00126 UT_Error startBookmark(const gchar* id, const gchar* name);
00127 UT_Error finishBookmark(const gchar* id);
00128 UT_Error startFootnote(const gchar* id);
00129 UT_Error finishFootnote();
00130 UT_Error startEndnote(const gchar* id);
00131 UT_Error finishEndnote();
00132 UT_Error writeDefaultStyle();
00133 UT_Error setBold(int target);
00134 UT_Error setItalic(int target);
00135 UT_Error setUnderline(int target);
00136 UT_Error setOverline(int target);
00137 UT_Error setLineThrough(int target);
00138 UT_Error setSuperscript(int target);
00139 UT_Error setSubscript(int target);
00140 UT_Error setTextColor(int target, const gchar* color);
00141 UT_Error setBackgroundColor(int target, const gchar* color);
00142 UT_Error setTextAlignment(int target, const gchar* alignment);
00143 UT_Error setTextIndentation(int target, const gchar* indentation);
00144 UT_Error setParagraphStyle(int target, const gchar* style);
00145 UT_Error setParagraphLeftMargin(int target, const gchar* margin);
00146 UT_Error setParagraphRightMargin(int target, const gchar* margin);
00147 UT_Error setParagraphTopMargin(int target, const gchar* margin);
00148 UT_Error setParagraphBottomMargin(int target, const gchar* margin);
00149 UT_Error setLineHeight(int target, const gchar* height);
00150 UT_Error setTabstops(int target, const gchar* tabstops);
00151 UT_Error setFontSize(int target, const gchar* size);
00152 UT_Error setFontFamily(int target, const gchar* family);
00153 UT_Error setTextDirection(int target, const gchar* direction);
00154 UT_Error setWidows(int target, const gchar* widows);
00155 UT_Error setGridSpan(int target, UT_sint32 hspan);
00156 UT_Error setVerticalMerge(int target, const char* vmerge);
00157 UT_Error setTableBorder(int target, const char* border, const char* type, const char* color, const char* size);
00158 UT_Error setGridCol(int target, const char* column);
00159 UT_Error setColumnWidth(int target, const char* width);
00160 UT_Error setRowHeight(int target, const char* height);
00161 UT_Error setListLevel(int target, const char* level);
00162 UT_Error setListFormat(int target, const char* format);
00163 UT_Error setListStartValue(int target, UT_uint32 startValue);
00164 UT_Error setListLevelText(int target, const char* text);
00165 UT_Error setListType(int target, const char* type);
00166 UT_Error setAbstractNumberingId(int target, UT_uint32 id);
00167 UT_Error setNumberingFormat(int target, const char* format);
00168 UT_Error setMultilevelType(int target, const char* type);
00169 UT_Error setHyperlinkRelation(int target, const char* id, const char* addr, const char* mode);
00170 UT_Error setImage(const char* id, const char* relId, const char* filename, const char* width, const char* height);
00171 UT_Error setImageRelation(const char* filename, const char* id);
00172 UT_Error writeImage(const char* filename, const UT_ByteBuf* data);
00173 UT_Error setSimpleField(int target, const char* instr, const char* value);
00174 UT_Error setHeaderReference(const char* id, const char* type);
00175 UT_Error setFooterReference(const char* id, const char* type);
00176 UT_Error setFootnoteReference(const char* id);
00177 UT_Error setFootnoteRef();
00178 UT_Error setEndnoteReference(const char* id);
00179 UT_Error setEndnoteRef();
00180 UT_Error startHeaderStream(const char* id);
00181 UT_Error finishHeaderStream();
00182 UT_Error startFooterStream(const char* id);
00183 UT_Error finishFooterStream();
00184 UT_Error setTitlePage();
00185 UT_Error setEvenAndOddHeaders();
00186 UT_Error setColumns(int target, const gchar* num, const gchar* sep);
00187 UT_Error setPageBreak(int target);
00188 UT_Error setPageSize(int target, const char* width, const char* height, const char* orientation);
00189 UT_Error setPageMargins(int target, const char* top, const char* left, const char* right, const char* bottom);
00190 UT_Error setLanguage(int target, const gchar* lang);
00191 UT_Error setNoProof(int target);
00192 UT_Error setTextBoxWidth(int target, const gchar* width);
00193 UT_Error setTextBoxHeight(int target, const gchar* height);
00194 PD_Document* getDoc() {return m_pDoc;};
00195
00196 protected:
00197 virtual UT_Error _writeDocument(void);
00198
00199 private:
00200 PD_Document* m_pDoc;
00201 GsfOutfile* root;
00202 GsfOutfile* relsDir;
00203 GsfOutfile* wordDir;
00204 GsfOutfile* wordRelsDir;
00205 GsfOutfile* wordMediaDir;
00206 GsfOutput* contentTypesStream;
00207 GsfOutput* relStream;
00208 GsfOutput* wordRelStream;
00209 GsfOutput* documentStream;
00210 GsfOutput* settingsStream;
00211 GsfOutput* stylesStream;
00212 GsfOutput* numberingStream;
00213 GsfOutput* headerStream;
00214 GsfOutput* footerStream;
00215 GsfOutput* footnoteStream;
00216 GsfOutput* endnoteStream;
00217 std::map<std::string, GsfOutput*> mediaStreams;
00218 std::map<std::string, GsfOutput*> headerStreams;
00219 std::map<std::string, GsfOutput*> footerStreams;
00220
00221 UT_Error startNumbering();
00222 UT_Error startStyles();
00223 UT_Error startContentTypes();
00224 UT_Error startRelations();
00225 UT_Error startWordRelations();
00226 UT_Error startWordMedia();
00227 UT_Error startMainPart();
00228 UT_Error startHeaders();
00229 UT_Error startFooters();
00230 UT_Error startSettings();
00231 UT_Error startFootnotes();
00232 UT_Error startEndnotes();
00233 UT_Error finishNumbering();
00234 UT_Error finishStyles();
00235 UT_Error finishContentTypes();
00236 UT_Error finishRelations();
00237 UT_Error finishWordRelations();
00238 UT_Error finishWordMedia();
00239 UT_Error finishMainPart();
00240 UT_Error finishHeaders();
00241 UT_Error finishFooters();
00242 UT_Error finishSettings();
00243 UT_Error finishFootnotes();
00244 UT_Error finishEndnotes();
00245 UT_Error writeXmlHeader(GsfOutput* file);
00246
00247 const gchar* convertToPoints(const gchar* str);
00248 const gchar* convertToTwips(const gchar* str);
00249 const gchar* convertToPositiveTwips(const gchar* str);
00250 const gchar* convertToPositiveEmus(const gchar* str);
00251 bool isNegativeQuantity(const gchar* quantity);
00252 const gchar* convertToLines(const gchar* str);
00253 const gchar* computeFontSize(const gchar* str);
00254 const gchar* computeBorderWidth(const gchar* str);
00255
00256 GsfOutput* getTargetStream(int target);
00257 UT_Error writeTargetStream(int target, const char* str);
00258
00259 bool isListBullet(const char* str);
00260
00261 void _cleanup();
00262 };
00263
00264 #endif //_IE_EXP_OPENXML_H_
00265