1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DOCXEXPORT_HXX_ 25 #define _DOCXEXPORT_HXX_ 26 27 #include "docxattributeoutput.hxx" 28 #include "wrtww8.hxx" 29 30 #include <sax/fshelper.hxx> 31 #include <rtl/ustring.hxx> 32 33 #include <cstdio> 34 #include <vector> 35 36 class DocxExportFilter; 37 class SwNode; 38 class SwEndNode; 39 class SwTableNode; 40 class SwTxtNode; 41 class SwGrfNode; 42 class SwOLENode; 43 class SwSectionNode; 44 class SwNumRuleTbl; 45 46 namespace oox { 47 namespace drawingml { class DrawingML; } 48 namespace vml { class VMLExport; } 49 } 50 51 // The class that does all the actual DOCX export-related work. 52 class DocxExport : public MSWordExportBase 53 { 54 // Pointer to the filter that owns us. 55 DocxExportFilter *m_pFilter; 56 57 // Fast serializer for the document output. 58 ::sax_fastparser::FSHelperPtr m_pDocumentFS; 59 60 // Access to the DrawingML writer. 61 oox::drawingml::DrawingML *m_pDrawingML; 62 63 // Attribute output for document. 64 DocxAttributeOutput *m_pAttrOutput; 65 66 // Sections/headers/footers 67 MSWordSections *m_pSections; 68 69 // Header counter. 70 sal_Int32 m_nHeaders; 71 72 // Footer counter. 73 sal_Int32 m_nFooters; 74 75 // Exporter of the VML shapes. 76 oox::vml::VMLExport *m_pVMLExport; 77 78 public: 79 // Access to the attribute output class. 80 virtual AttributeOutputBase& AttrOutput() const; 81 82 // Access to the sections/headers/footres. 83 virtual MSWordSections& Sections() const; 84 85 // Hack, unfortunately necessary at some places for now. 86 // FIXME remove it when possible. HackIsWW8OrHigher() const87 virtual bool HackIsWW8OrHigher() const { return true; } 88 89 // Guess the script (asian/western). 90 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ); 91 92 virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen ); 93 94 virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ); 95 96 // Returns the relationd id 97 rtl::OString AddRelation( const rtl::OUString& rType, const rtl::OUString& rTarget, const rtl::OUString& rMode ); 98 WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t)99 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ } WriteChar(sal_Unicode)100 virtual void WriteChar( sal_Unicode ) { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); } 101 102 // Return value indicates if an inherited outline numbering is suppressed. 103 virtual bool DisallowInheritingOutlineNumbering( const SwFmt &rFmt ); 104 105 // Output the actual headers and footers. 106 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags, 107 const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt ); 108 109 // Write the field 110 virtual void OutputField( const SwField* pFld, ww::eField eFldType, 111 const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ); 112 113 // Write the data of the form field 114 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ); 115 116 virtual void DoComboBox(const rtl::OUString &rName, 117 const rtl::OUString &rHelp, 118 const rtl::OUString &ToolTip, 119 const rtl::OUString &rSelected, 120 com::sun::star::uno::Sequence<rtl::OUString> &rListItems); 121 122 virtual void DoFormText(const SwInputField * pFld); 123 124 virtual sal_uLong ReplaceCr( sal_uInt8 nChar ); 125 126 protected: 127 // Format-dependent part of the actual export. 128 virtual void ExportDocument_Impl(); 129 130 // Output page/section breaks 131 virtual void OutputPageSectionBreaks( const SwTxtNode& ); 132 133 // Output SwEndNode 134 virtual void OutputEndNode( const SwEndNode& ); 135 136 // Output SwTableNode 137 virtual void OutputTableNode( const SwTableNode& ); 138 139 // Output SwGrfNode 140 virtual void OutputGrfNode( const SwGrfNode& ); 141 142 // Output SwOLENode 143 virtual void OutputOLENode( const SwOLENode& ); 144 145 146 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ); 147 SectionBreaksAndFrames(const SwTxtNode & rNode)148 virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) {} 149 150 // Get ready for a new section. 151 virtual void PrepareNewPageDesc( const SfxItemSet* pSet, 152 const SwNode& rNd, 153 const SwFmtPageDesc* pNewPgDescFmt = 0, 154 const SwPageDesc* pNewPgDesc = 0 ); 155 156 private: 157 // Setup pStyles and write styles.xml 158 void InitStyles(); 159 160 // Write footnotes.xml and endnotes.xml. 161 void WriteFootnotesEndnotes(); 162 163 // Write the numbering table. 164 virtual void WriteNumbering(); 165 166 // Write reference to a header/foorter + the actual xml containing the text. 167 void WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType ); 168 169 // Write word/fontTable.xml. 170 void WriteFonts(); 171 172 // Write docProps/core.xml 173 void WriteProperties(); 174 175 public: 176 // FIXME this is temporary, remotely reminding the method of the same 177 // name in WW8Export. 178 void WriteMainText(); 179 180 // Pass the pDocument, pCurrentPam and pOriginalPam to the base class. 181 DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, 182 SwPaM *pCurrentPam, SwPaM *pOriginalPam ); 183 184 // Destructor. 185 virtual ~DocxExport(); 186 187 // Reference to the VMLExport instance for the main document. 188 oox::vml::VMLExport& VMLExporter(); 189 190 private: 191 // No copying. 192 DocxExport( const DocxExport& ); 193 194 // No copying. 195 DocxExport& operator=( const DocxExport& ); 196 }; 197 198 #endif // _DOCXEXPORT_HXX_ 199 200 /* vim: set noet sw=4 ts=4: */ 201