diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-04-18 14:27:59 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-04-19 14:19:25 +0200 |
commit | a2bebd5dc696de301e4e35321108cd23a42d5fcb (patch) | |
tree | c99eef321a721a7b93f9ddc2da725ae92a4db32b | |
parent | 6ccd6981635845e9fd9ba2aef2a3ce3e46171f9b (diff) |
implement w:evenAndOddHeaders (and settings.xml too)
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 16 |
2 files changed, 55 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 1ee405155e..074a128826 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -215,6 +215,9 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST ) WriteHeaderFooter( rFirstPageFmt, false, "first" ); + if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN )) + settings.evenAndOddHeaders = true; + #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "DocxExport::WriteHeadersFooters() - nBreakCode introduced, but ignored\n" ); #endif @@ -339,6 +342,8 @@ void DocxExport::ExportDocument_Impl() WriteFonts(); + WriteSettings(); + delete pStyles, pStyles = NULL; delete m_pSections, m_pSections = NULL; } @@ -642,6 +647,28 @@ void DocxExport::WriteProperties( ) m_pFilter->exportDocumentProperties( xDocProps ); } +void DocxExport::WriteSettings() +{ + if( !settings.hasData()) + return; + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" ), + S( "settings.xml" ) ); + + ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openFragmentStreamWithSerializer( + S( "word/settings.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" ) ); + + pFS->startElementNS( XML_w, XML_settings, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + + if( settings.evenAndOddHeaders ) + pFS->singleElementNS( XML_w, XML_evenAndOddHeaders, FSEND ); + + pFS->endElementNS( XML_w, XML_settings ); +} + VMLExport& DocxExport::VMLExporter() { return *m_pVMLExport; @@ -726,4 +753,16 @@ DocxExport::~DocxExport() delete m_pDrawingML, m_pDrawingML = NULL; } +DocxSettingsData::DocxSettingsData() +: evenAndOddHeaders( false ) +{ +} + +bool DocxSettingsData::hasData() const +{ + if( evenAndOddHeaders ) + return true; + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 4838d55868..ee84dcd33b 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -58,6 +58,14 @@ namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } } +/// Data to be written in the document settings part of the document +struct DocxSettingsData +{ + DocxSettingsData(); + bool hasData() const; /// returns true if there are any non-default settings (i.e. something to write) + bool evenAndOddHeaders; +}; + /// The class that does all the actual DOCX export-related work. class DocxExport : public MSWordExportBase { @@ -85,6 +93,8 @@ class DocxExport : public MSWordExportBase /// Exporter of the VML shapes. oox::vml::VMLExport *m_pVMLExport; + DocxSettingsData settings; + public: DocxExportFilter& GetFilter() { return *m_pFilter; }; @@ -192,6 +202,9 @@ private: /// Write docProps/core.xml void WriteProperties(); + /// Write word/settings.xml + void WriteSettings(); + /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...) sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer ); @@ -210,6 +223,9 @@ public: /// Reference to the VMLExport instance for the main document. oox::vml::VMLExport& VMLExporter(); + /// Data to be exported in the settings part of the document + DocxSettingsData& settingsData(); + private: /// No copying. DocxExport( const DocxExport& ); |