LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - docxexport.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 10 11 90.9 %
Date: 2014-04-11 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
      21             : #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
      22             : 
      23             : #include "wrtww8.hxx"
      24             : 
      25             : #include <sax/fshelper.hxx>
      26             : #include <sax/fastattribs.hxx>
      27             : #include <rtl/ustring.hxx>
      28             : 
      29             : #include <cstdio>
      30             : #include <vector>
      31             : #include <boost/optional.hpp>
      32             : #include <ndole.hxx>
      33             : 
      34             : class DocxAttributeOutput;
      35             : class DocxExportFilter;
      36             : class SwNode;
      37             : class SwEndNode;
      38             : class SwTableNode;
      39             : class SwTxtNode;
      40             : class SwGrfNode;
      41             : class SwOLENode;
      42             : class DocxSdrExport;
      43             : 
      44             : namespace oox {
      45             :     namespace drawingml { class DrawingML; }
      46             :     namespace vml { class VMLExport; }
      47             : }
      48             : 
      49             : namespace com { namespace sun { namespace star {
      50             :     namespace frame { class XModel; }
      51             :     namespace drawing { class XShape; }
      52             : } } }
      53             : 
      54             : /// Data to be written in the document settings part of the document
      55             : struct DocxSettingsData
      56             : {
      57             :     DocxSettingsData();
      58             :     bool hasData() const; /// returns true if there are any non-default settings (i.e. something to write)
      59             :     bool evenAndOddHeaders;
      60             :     int defaultTabStop;
      61             :     bool trackRevisions;    // Should 'Track Revisions' be set
      62             : };
      63             : 
      64             : /// The class that does all the actual DOCX export-related work.
      65             : class DocxExport : public MSWordExportBase
      66             : {
      67             :     /// Pointer to the filter that owns us.
      68             :     DocxExportFilter *m_pFilter;
      69             : 
      70             :     /// Fast serializer for the document output.
      71             :     ::sax_fastparser::FSHelperPtr m_pDocumentFS;
      72             : 
      73             :     /// Fast serializer to output the data.
      74             :     ::sax_fastparser::FSHelperPtr mpFS;
      75             : 
      76             :     /// Access to the DrawingML writer.
      77             :     oox::drawingml::DrawingML *m_pDrawingML;
      78             : 
      79             :     /// Attribute output for document.
      80             :     DocxAttributeOutput *m_pAttrOutput;
      81             : 
      82             :     /// Sections/headers/footers
      83             :     MSWordSections *m_pSections;
      84             : 
      85             :     /// Header counter.
      86             :     sal_Int32 m_nHeaders;
      87             : 
      88             :     /// Footer counter.
      89             :     sal_Int32 m_nFooters;
      90             : 
      91             :     /// OLE objects counter.
      92             :     sal_Int32 m_nOLEObjects;
      93             : 
      94             :     ///Footer and Header counter in Section properties
      95             :     sal_Int32 m_nHeadersFootersInSection;
      96             : 
      97             :     /// Exporter of the VML shapes.
      98             :     oox::vml::VMLExport *m_pVMLExport;
      99             : 
     100             :     /// Exporter of drawings.
     101             :     DocxSdrExport* m_pSdrExport;
     102             : 
     103             :     DocxSettingsData m_aSettings;
     104             : 
     105             : public:
     106             : 
     107        9199 :     DocxExportFilter& GetFilter() { return *m_pFilter; };
     108        2026 :     const DocxExportFilter& GetFilter() const { return *m_pFilter; };
     109             : 
     110             :     /// Access to the attribute output class.
     111             :     virtual AttributeOutputBase& AttrOutput() const SAL_OVERRIDE;
     112             : 
     113             :     /// Access to the sections/headers/footres.
     114             :     virtual MSWordSections& Sections() const SAL_OVERRIDE;
     115             : 
     116             :     /// Determines if the format is expected to support unicode.
     117       27820 :     virtual bool SupportsUnicode() const SAL_OVERRIDE { return true; }
     118             : 
     119           2 :     virtual bool SupportsOneColumnBreak() const SAL_OVERRIDE { return true; }
     120             : 
     121           9 :     virtual bool FieldsQuoted() const SAL_OVERRIDE { return true; }
     122             : 
     123           9 :     virtual bool AddSectionBreaksForTOX() const SAL_OVERRIDE { return true; }
     124             : 
     125             :     virtual bool ignoreAttributeForStyles( sal_uInt16 nWhich ) const SAL_OVERRIDE;
     126             : 
     127             :     /// Guess the script (asian/western).
     128             :     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) SAL_OVERRIDE;
     129             : 
     130             :     virtual void AppendBookmarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
     131             : 
     132             :     virtual void AppendBookmark( const OUString& rName, bool bSkip = false ) SAL_OVERRIDE;
     133             : 
     134             :     virtual void AppendAnnotationMarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
     135             : 
     136             :     virtual void ExportGrfBullet(const SwTxtNode&) SAL_OVERRIDE;
     137             : 
     138             :     /// Returns the relationd id
     139             :     OString AddRelation( const OUString& rType, const OUString& rTarget );
     140             : 
     141        5189 :     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) SAL_OVERRIDE { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ }
     142           0 :     virtual void WriteChar( sal_Unicode ) SAL_OVERRIDE { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); }
     143             : 
     144             :     /// Return value indicates if an inherited outline numbering is suppressed.
     145             :     virtual bool DisallowInheritingOutlineNumbering( const SwFmt &rFmt ) SAL_OVERRIDE;
     146             : 
     147             :     /// Output the actual headers and footers.
     148             :     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
     149             :             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode ) SAL_OVERRIDE;
     150             : 
     151             :     /// Write the field
     152             :     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
     153             :             const OUString& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) SAL_OVERRIDE;
     154             : 
     155             :     /// Write the data of the form field
     156             :     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
     157             :     virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
     158             : 
     159             :     virtual void DoComboBox(const OUString &rName,
     160             :                     const OUString &rHelp,
     161             :                     const OUString &ToolTip,
     162             :                     const OUString &rSelected,
     163             :                     com::sun::star::uno::Sequence<OUString> &rListItems) SAL_OVERRIDE;
     164             : 
     165             :     virtual void DoFormText(const SwInputField * pFld) SAL_OVERRIDE;
     166             : 
     167             :     virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) SAL_OVERRIDE;
     168             : 
     169             :     /// Returns the relationd id
     170             :     OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer );
     171             :     OString WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType );
     172             :     bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut );
     173             : 
     174             :     /// Writes the shape using drawingML syntax.
     175             :     void OutputDML( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
     176             : 
     177             :     void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
     178             : 
     179             : protected:
     180             :     /// Format-dependent part of the actual export.
     181             :     virtual void ExportDocument_Impl() SAL_OVERRIDE;
     182             : 
     183             :     /// Output page/section breaks
     184             :     virtual void OutputPageSectionBreaks( const SwTxtNode& );
     185             : 
     186             :     /// Output SwEndNode
     187             :     virtual void OutputEndNode( const SwEndNode& ) SAL_OVERRIDE;
     188             : 
     189             :     /// Output SwTableNode
     190             :     virtual void OutputTableNode( const SwTableNode& );
     191             : 
     192             :     /// Output SwGrfNode
     193             :     virtual void OutputGrfNode( const SwGrfNode& ) SAL_OVERRIDE;
     194             : 
     195             :     /// Output SwOLENode
     196             :     virtual void OutputOLENode( const SwOLENode& ) SAL_OVERRIDE;
     197             : 
     198             :     virtual void OutputLinkedOLE( const OUString& ) SAL_OVERRIDE;
     199             : 
     200             :     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) SAL_OVERRIDE;
     201             : 
     202        5191 :     virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) SAL_OVERRIDE {}
     203             : 
     204             :     /// Get ready for a new section.
     205             :     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
     206             :                                      const SwNode& rNd,
     207             :                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
     208             :                                      const SwPageDesc* pNewPgDesc = 0 ) SAL_OVERRIDE;
     209             : 
     210             : private:
     211             :     /// Setup pStyles and write styles.xml
     212             :     void InitStyles();
     213             : 
     214             :     /// Write footnotes.xml and endnotes.xml.
     215             :     void WriteFootnotesEndnotes();
     216             : 
     217             :     /// Write comments.xml
     218             :     void WritePostitFields();
     219             : 
     220             :     /// Write the numbering table.
     221             :     virtual void WriteNumbering() SAL_OVERRIDE;
     222             : 
     223             :     /// Write reference to a header/foorter + the actual xml containing the text.
     224             :     void WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType );
     225             : 
     226             :     /// Write word/fontTable.xml.
     227             :     void WriteFonts();
     228             : 
     229             :     /// Write docProps/core.xml
     230             :     void WriteProperties();
     231             : 
     232             :     /// Write word/settings.xml
     233             :     void WriteSettings();
     234             : 
     235             :     /// Write word/theme/theme1.xml
     236             :     void WriteTheme();
     237             : 
     238             :     void WriteGlossary();
     239             : 
     240             :     /// Write customXml/item[n].xml and customXml/itemProps[n].xml
     241             :     void WriteCustomXml();
     242             : 
     243             :     /// Write word/activeX/activeX[n].xml
     244             :     void WriteActiveX();
     245             : 
     246             :     /// Write word/embeddings/Worksheet[n].xlsx
     247             :     void WriteEmbeddings();
     248             : 
     249             :     /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
     250             :     sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer );
     251             : 
     252             :     /// Get background color of the document, if there is one.
     253             :     boost::optional<const SvxBrushItem*> getBackground();
     254             : 
     255             :     /// return true if Page Layout is set as Mirrored
     256             :     bool isMirroredMargin();
     257             : 
     258             : public:
     259             :     /// FIXME this is temporary, remotely reminding the method of the same
     260             :     /// name in WW8Export.
     261             :     void WriteMainText();
     262             : 
     263             :     /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
     264             :     DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument,
     265             :             SwPaM *pCurrentPam, SwPaM *pOriginalPam );
     266             : 
     267             :     /// Destructor.
     268             :     virtual ~DocxExport();
     269             : 
     270             :     /// Reference to the VMLExport instance for the main document.
     271             :     oox::vml::VMLExport& VMLExporter();
     272             : 
     273             :     /// Reference to the DocxSdrExport instance for the main document.
     274             :     DocxSdrExport& SdrExporter();
     275             : 
     276             :     /// Set the document default tab stop.
     277         668 :     void setDefaultTabStop( int stop ) { m_aSettings.defaultTabStop = stop; }
     278             : 
     279           6 :     ::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
     280             : 
     281             :     void SetFS(::sax_fastparser::FSHelperPtr mpFS);
     282             : 
     283             : private:
     284             :     /// No copying.
     285             :     DocxExport( const DocxExport& );
     286             : 
     287             :     /// No copying.
     288             :     DocxExport& operator=( const DocxExport& );
     289             : };
     290             : 
     291             : #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
     292             : 
     293             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10