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, bool list);
00080 UT_Error finishText(int target);
00081 UT_Error startMath();
00082 UT_Error writeMath(const char* omml);
00083 UT_Error finishMath();
00084 UT_Error startRun(int target);
00085 UT_Error finishRun(int target);
00086 UT_Error startRunProperties(int target);
00087 UT_Error finishRunProperties(int target);
00088 UT_Error startParagraphProperties(int target);
00089 UT_Error finishParagraphProperties(int target);
00090 UT_Error startCellProperties(int target);
00091 UT_Error finishCellProperties(int target);
00092 UT_Error startStyle(const std::string& name, const std::string& basedon, const std::string& followedby, const std::string& type);
00093 UT_Error finishStyle();
00094 UT_Error startDocumentDefaultProperties();
00095 UT_Error finishDocumentDefaultProperties();
00096 UT_Error startRunDefaultProperties();
00097 UT_Error finishRunDefaultProperties();
00098 UT_Error startParagraphDefaultProperties();
00099 UT_Error finishParagraphDefaultProperties();
00100 UT_Error startTable();
00101 UT_Error finishTable();
00102 UT_Error startTableProperties(int target);
00103 UT_Error finishTableProperties(int target);
00104 UT_Error startTableBorderProperties(int target);
00105 UT_Error finishTableBorderProperties(int target);
00106 UT_Error startCellBorderProperties(int target);
00107 UT_Error finishCellBorderProperties(int target);
00108 UT_Error startListProperties(int target);
00109 UT_Error finishListProperties(int target);
00110 UT_Error startAbstractNumbering(int target, UT_uint32 id);
00111 UT_Error finishAbstractNumbering(int target);
00112 UT_Error startTextBox(int target, const gchar* id);
00113 UT_Error finishTextBox(int target);
00114 UT_Error startTextBoxProperties(int target);
00115 UT_Error finishTextBoxProperties(int target);
00116 UT_Error startTextBoxContent(int target);
00117 UT_Error finishTextBoxContent(int target);
00118 UT_Error startNumbering(int target, UT_uint32 id);
00119 UT_Error finishNumbering(int target);
00120 UT_Error startNumberingLevel(int target, UT_uint32 level);
00121 UT_Error finishNumberingLevel(int target);
00122 UT_Error startRow();
00123 UT_Error finishRow();
00124 UT_Error startRowProperties(int target);
00125 UT_Error finishRowProperties(int target);
00126 UT_Error startCell();
00127 UT_Error finishCell();
00128 UT_Error startTableGrid(int target);
00129 UT_Error finishTableGrid(int target);
00130 UT_Error startExternalHyperlink(const gchar* id);
00131 UT_Error startInternalHyperlink(const gchar* anchor);
00132 UT_Error setHeaderRelation(const char* relId, const char* headerId);
00133 UT_Error setFooterRelation(const char* relId, const char* footerId);
00134 UT_Error finishHyperlink();
00135 UT_Error startBookmark(const gchar* id, const gchar* name);
00136 UT_Error finishBookmark(const gchar* id);
00137 UT_Error startFootnote(const gchar* id);
00138 UT_Error finishFootnote();
00139 UT_Error startEndnote(const gchar* id);
00140 UT_Error finishEndnote();
00141 UT_Error setBold(int target);
00142 UT_Error setItalic(int target);
00143 UT_Error setUnderline(int target);
00144 UT_Error setOverline();
00145 UT_Error setLineThrough(int target);
00146 UT_Error setSuperscript(int target);
00147 UT_Error setSubscript(int target);
00148 UT_Error setTextColor(int target, const gchar* color);
00149 UT_Error setBackgroundColor(int target, const gchar* color);
00150 UT_Error setTextAlignment(int target, const gchar* alignment);
00151 UT_Error setTextIndentation(int target, const gchar* indentation);
00152 UT_Error setParagraphStyle(int target, const gchar* style);
00153 UT_Error setParagraphLeftMargin(int target, const gchar* margin);
00154 UT_Error setParagraphRightMargin(int target, const gchar* margin);
00155 UT_Error setParagraphTopMargin(int target, const gchar* margin);
00156 UT_Error setParagraphBottomMargin(int target, const gchar* margin);
00157 UT_Error setLineHeight(int target, const gchar* height);
00158 UT_Error setTabstops(int target, const gchar* tabstops);
00159 UT_Error setFontSize(int target, const gchar* size);
00160 UT_Error setFontFamily(int target, const gchar* family);
00161 UT_Error setTextDirection(int target, const gchar* direction);
00162 UT_Error setWidows(int target, const gchar* widows);
00163 UT_Error setGridSpan(int target, UT_sint32 hspan);
00164 UT_Error setVerticalMerge(int target, const char* vmerge);
00165 UT_Error setTableBorder(int target, const char* border, const char* type, const char* color, const char* size);
00166 UT_Error setGridCol(int target, const char* column);
00167 UT_Error setColumnWidth(int target, const char* width);
00168 UT_Error setRowHeight(int target, const char* height);
00169 UT_Error setListLevel(int target, const char* level);
00170 UT_Error setListFormat(int target, const char* format);
00171 UT_Error setListStartValue(int target, UT_uint32 startValue);
00172 UT_Error setListLevelText(int target, const char* text);
00173 UT_Error setListType(int target, const char* type);
00174 UT_Error setAbstractNumberingId(int target, UT_uint32 id);
00175 UT_Error setNumberingFormat(int target, const char* format);
00176 UT_Error setMultilevelType(int target, const char* type);
00177 UT_Error setHyperlinkRelation(int target, const char* id, const char* addr, const char* mode);
00178 UT_Error setImage(const char* id, const char* relId, const char* filename, const char* width, const char* height);
00179 UT_Error setPositionedImage(const char* id, const char* relId, const char* filename, const char* width, const char* height, const char* xpos, const char* ypos, const char* wrapMode);
00180 UT_Error setImageRelation(const char* filename, const char* id);
00181 UT_Error writeImage(const char* filename, const UT_ConstByteBufPtr & data);
00182 UT_Error setSimpleField(int target, const char* instr, const char* value);
00183 UT_Error setHeaderReference(const char* id, const char* type);
00184 UT_Error setFooterReference(const char* id, const char* type);
00185 UT_Error setFootnoteReference(const char* id);
00186 UT_Error setFootnoteRef();
00187 UT_Error setEndnoteReference(const char* id);
00188 UT_Error setEndnoteRef();
00189 UT_Error startHeaderStream(const char* id);
00190 UT_Error finishHeaderStream();
00191 UT_Error startFooterStream(const char* id);
00192 UT_Error finishFooterStream();
00193 UT_Error setTitlePage();
00194 UT_Error setEvenAndOddHeaders();
00195 UT_Error setColumns(int target, const gchar* num, const gchar* sep);
00196 UT_Error setContinuousSection(int target);
00197 UT_Error setPageBreak(int target);
00198 UT_Error setPageSize(int target, const char* width, const char* height, const char* orientation);
00199 UT_Error setPageMargins(int target, const char* top, const char* left, const char* right, const char* bottom);
00200 UT_Error setLanguage(int target, const gchar* lang);
00201 UT_Error setNoProof(int target);
00202 UT_Error setTextBoxWidth(int target, const gchar* width);
00203 UT_Error setTextBoxHeight(int target, const gchar* height);
00204 PD_Document* getDoc() {return m_pDoc;};
00205
00206 protected:
00207 virtual UT_Error _writeDocument(void);
00208
00209 private:
00210 PD_Document* m_pDoc;
00211 GsfOutfile* root;
00212 GsfOutfile* relsDir;
00213 GsfOutfile* wordDir;
00214 GsfOutfile* wordRelsDir;
00215 GsfOutfile* wordMediaDir;
00216 GsfOutput* contentTypesStream;
00217 GsfOutput* relStream;
00218 GsfOutput* wordRelStream;
00219 GsfOutput* documentStream;
00220 GsfOutput* settingsStream;
00221 GsfOutput* stylesStream;
00222 GsfOutput* numberingStream;
00223 GsfOutput* headerStream;
00224 GsfOutput* footerStream;
00225 GsfOutput* footnoteStream;
00226 GsfOutput* endnoteStream;
00227 std::map<std::string, GsfOutput*> mediaStreams;
00228 std::map<std::string, GsfOutput*> headerStreams;
00229 std::map<std::string, GsfOutput*> footerStreams;
00230
00231 bool isOverline;
00232
00233 UT_Error startNumbering();
00234 UT_Error startStyles();
00235 UT_Error startContentTypes();
00236 UT_Error startRelations();
00237 UT_Error startWordRelations();
00238 UT_Error startWordMedia();
00239 UT_Error startMainPart();
00240 UT_Error startHeaders();
00241 UT_Error startFooters();
00242 UT_Error startSettings();
00243 UT_Error startFootnotes();
00244 UT_Error startEndnotes();
00245 UT_Error finishNumbering();
00246 UT_Error finishStyles();
00247 UT_Error finishContentTypes();
00248 UT_Error finishRelations();
00249 UT_Error finishWordRelations();
00250 UT_Error finishWordMedia();
00251 UT_Error finishMainPart();
00252 UT_Error finishHeaders();
00253 UT_Error finishFooters();
00254 UT_Error finishSettings();
00255 UT_Error finishFootnotes();
00256 UT_Error finishEndnotes();
00257 UT_Error writeXmlHeader(GsfOutput* file);
00258
00259 const gchar* convertToPoints(const gchar* str);
00260 const gchar* convertToTwips(const gchar* str);
00261 const gchar* convertToPositiveTwips(const gchar* str);
00262 const gchar* convertToPositiveEmus(const gchar* str);
00263 bool isNegativeQuantity(const gchar* quantity);
00264 const gchar* convertToLines(const gchar* str);
00265 const gchar* computeFontSize(const gchar* str);
00266 const gchar* computeBorderWidth(const gchar* str);
00267
00268 GsfOutput* getTargetStream(int target);
00269 UT_Error writeTargetStream(int target, const char* str);
00270
00271 bool isListBullet(const char* str);
00272
00273 void _cleanup();
00274 };
00275
00276 #endif //_IE_EXP_OPENXML_H_
00277