LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - docxexport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 721 0.0 %
Date: 2014-04-14 Functions: 0 58 0.0 %
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             : #include "docxexport.hxx"
      21             : #include "docxexportfilter.hxx"
      22             : #include "docxattributeoutput.hxx"
      23             : #include "docxsdrexport.hxx"
      24             : 
      25             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      26             : #include <com/sun/star/document/XDocumentProperties.hpp>
      27             : #include <com/sun/star/drawing/XShape.hpp>
      28             : #include <com/sun/star/i18n/ScriptType.hpp>
      29             : #include <com/sun/star/frame/XModel.hpp>
      30             : #include <com/sun/star/xml/dom/XDocument.hpp>
      31             : #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
      32             : #include <com/sun/star/xml/sax/Writer.hpp>
      33             : 
      34             : #include <oox/token/tokens.hxx>
      35             : #include <oox/export/drawingml.hxx>
      36             : #include <oox/export/vmlexport.hxx>
      37             : #include <oox/export/chartexport.hxx>
      38             : #include <oox/export/shapes.hxx>
      39             : 
      40             : #include <map>
      41             : #include <algorithm>
      42             : 
      43             : #include <IMark.hxx>
      44             : #include <docsh.hxx>
      45             : #include <ndtxt.hxx>
      46             : #include <wrtww8.hxx>
      47             : #include <fltini.hxx>
      48             : #include <fmtline.hxx>
      49             : #include <fmtpdsc.hxx>
      50             : #include <frmfmt.hxx>
      51             : #include <section.hxx>
      52             : #include <ftninfo.hxx>
      53             : #include <pagedesc.hxx>
      54             : 
      55             : #include <editeng/unoprnms.hxx>
      56             : #include <editeng/editobj.hxx>
      57             : #include <editeng/outlobj.hxx>
      58             : #include <editeng/brushitem.hxx>
      59             : 
      60             : #include <docary.hxx>
      61             : #include <numrule.hxx>
      62             : #include <charfmt.hxx>
      63             : #include <viewsh.hxx>
      64             : #include <viewopt.hxx>
      65             : 
      66             : #include "ww8par.hxx"
      67             : #include "ww8scan.hxx"
      68             : #include <oox/token/properties.hxx>
      69             : #include <comphelper/embeddedobjectcontainer.hxx>
      70             : #include <comphelper/string.hxx>
      71             : #include <rtl/ustrbuf.hxx>
      72             : #include <vcl/font.hxx>
      73             : 
      74             : using namespace sax_fastparser;
      75             : using namespace ::comphelper;
      76             : using namespace ::com::sun::star;
      77             : using namespace ::oox;
      78             : 
      79             : using oox::vml::VMLExport;
      80             : 
      81             : using sw::mark::IMark;
      82             : 
      83           0 : AttributeOutputBase& DocxExport::AttrOutput() const
      84             : {
      85           0 :     return *m_pAttrOutput;
      86             : }
      87             : 
      88           0 : MSWordSections& DocxExport::Sections() const
      89             : {
      90           0 :     return *m_pSections;
      91             : }
      92             : 
      93           0 : bool DocxExport::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich )
      94             : {
      95             :     // TODO FIXME is this actually true for docx? - this is ~copied from WW8
      96           0 :     if ( nScript == i18n::ScriptType::ASIAN )
      97             :     {
      98             :         // for asian in ww8, there is only one fontsize
      99             :         // and one fontstyle (posture/weight)
     100           0 :         switch ( nWhich )
     101             :         {
     102             :             case RES_CHRATR_FONTSIZE:
     103             :             case RES_CHRATR_POSTURE:
     104             :             case RES_CHRATR_WEIGHT:
     105           0 :                 return false;
     106             :             default:
     107           0 :                 break;
     108             :         }
     109             :     }
     110           0 :     else if ( nScript != i18n::ScriptType::COMPLEX )
     111             :     {
     112             :         // for western in ww8, there is only one fontsize
     113             :         // and one fontstyle (posture/weight)
     114           0 :         switch ( nWhich )
     115             :         {
     116             :             case RES_CHRATR_CJK_FONTSIZE:
     117             :             case RES_CHRATR_CJK_POSTURE:
     118             :             case RES_CHRATR_CJK_WEIGHT:
     119           0 :                 return false;
     120             :             default:
     121           0 :                 break;
     122             :         }
     123             :     }
     124           0 :     return true;
     125             : }
     126             : 
     127           0 : void DocxExport::AppendBookmarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen )
     128             : {
     129           0 :     std::vector< OUString > aStarts;
     130           0 :     std::vector< OUString > aEnds;
     131             : 
     132           0 :     IMarkVector aMarks;
     133           0 :     if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarks ) )
     134             :     {
     135           0 :         for ( IMarkVector::const_iterator it = aMarks.begin(), end = aMarks.end();
     136             :               it != end; ++it )
     137             :         {
     138           0 :             IMark* pMark = (*it);
     139             : 
     140           0 :             const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
     141           0 :             const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
     142             : 
     143           0 :             if ( nStart == nAktPos )
     144           0 :                 aStarts.push_back( pMark->GetName() );
     145             : 
     146           0 :             if ( nEnd == nAktPos )
     147           0 :                 aEnds.push_back( pMark->GetName() );
     148             :         }
     149             :     }
     150             : 
     151           0 :     m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
     152           0 : }
     153             : 
     154           0 : void DocxExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ )
     155             : {
     156           0 :     std::vector< OUString > aStarts;
     157           0 :     std::vector< OUString > aEnds;
     158             : 
     159           0 :     aStarts.push_back( rName );
     160           0 :     aEnds.push_back( rName );
     161             : 
     162           0 :     m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
     163           0 : }
     164             : 
     165           0 : void DocxExport::AppendAnnotationMarks( const SwTxtNode& rNode, sal_Int32 nAktPos, sal_Int32 nLen )
     166             : {
     167           0 :     std::vector< OUString > aStarts;
     168           0 :     std::vector< OUString > aEnds;
     169             : 
     170           0 :     IMarkVector aMarks;
     171           0 :     if ( GetAnnotationMarks( rNode, nAktPos, nAktPos + nLen, aMarks ) )
     172             :     {
     173           0 :         for ( IMarkVector::const_iterator it = aMarks.begin(), end = aMarks.end();
     174             :               it != end; ++it )
     175             :         {
     176           0 :             IMark* pMark = (*it);
     177             : 
     178           0 :             const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
     179           0 :             const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
     180             : 
     181           0 :             if ( nStart == nAktPos )
     182           0 :                 aStarts.push_back( pMark->GetName() );
     183             : 
     184           0 :             if ( nEnd == nAktPos )
     185           0 :                 aEnds.push_back( pMark->GetName() );
     186             :         }
     187             :     }
     188             : 
     189           0 :     m_pAttrOutput->WriteAnnotationMarks_Impl( aStarts, aEnds );
     190           0 : }
     191             : 
     192           0 : void DocxExport::ExportGrfBullet(const SwTxtNode&)
     193             : {
     194             :     // Just collect the bullets for now, numbering.xml is not yet started.
     195           0 :     CollectGrfsOfBullets();
     196           0 : }
     197             : 
     198           0 : OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget )
     199             : {
     200             :     OUString sId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     201           0 :            rType, rTarget, true );
     202             : 
     203           0 :     return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
     204             : }
     205             : 
     206           0 : bool DocxExport::DisallowInheritingOutlineNumbering( const SwFmt& rFmt )
     207             : {
     208           0 :     bool bRet( false );
     209             : 
     210           0 :     if (SFX_ITEM_SET != rFmt.GetItemState(RES_PARATR_NUMRULE, false))
     211             :     {
     212           0 :         if (const SwFmt *pParent = rFmt.DerivedFrom())
     213             :         {
     214           0 :             if (((const SwTxtFmtColl*)pParent)->IsAssignedToListLevelOfOutlineStyle())
     215             :             {
     216           0 :                 ::sax_fastparser::FSHelperPtr pSerializer = m_pAttrOutput->GetSerializer( );
     217             :                 // Level 9 disables the outline
     218             :                 pSerializer->singleElementNS( XML_w, XML_outlineLvl,
     219             :                         FSNS( XML_w, XML_val ), "9" ,
     220           0 :                         FSEND );
     221             : 
     222           0 :                 bRet = true;
     223             :             }
     224             :         }
     225             :     }
     226             : 
     227           0 :     return bRet;
     228             : }
     229             : 
     230           0 : void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
     231             :         const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 /*nBreakCode*/ )
     232             : {
     233           0 :     m_nHeadersFootersInSection = 1;
     234             :     // Turn ON flag for 'Writing Headers \ Footers'
     235           0 :     m_pAttrOutput->SetWritingHeaderFooter( true );
     236             : 
     237             :     // headers
     238           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN )
     239           0 :         WriteHeaderFooter( rLeftFmt, true, "even" );
     240             : 
     241           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
     242           0 :         WriteHeaderFooter( rFmt, true, "default" );
     243             : 
     244           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST )
     245           0 :         WriteHeaderFooter( rFirstPageFmt, true, "first" );
     246             : 
     247             :     // footers
     248           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN )
     249           0 :         WriteHeaderFooter( rLeftFmt, false, "even" );
     250             : 
     251           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
     252           0 :         WriteHeaderFooter( rFmt, false, "default" );
     253             : 
     254           0 :     if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST )
     255           0 :         WriteHeaderFooter( rFirstPageFmt, false, "first" );
     256             : 
     257           0 :     if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN ))
     258           0 :         m_aSettings.evenAndOddHeaders = true;
     259             : 
     260             :     // Turn OFF flag for 'Writing Headers \ Footers'
     261           0 :     m_pAttrOutput->SetWritingHeaderFooter( false );
     262           0 :     m_pAttrOutput->switchHeaderFooter(false, -1);
     263             : #if OSL_DEBUG_LEVEL > 1
     264             :     fprintf( stderr, "DocxExport::WriteHeadersFooters() - nBreakCode introduced, but ignored\n" );
     265             : #endif
     266           0 : }
     267             : 
     268           0 : void DocxExport::OutputField( const SwField* pFld, ww::eField eFldType, const OUString& rFldCmd, sal_uInt8 nMode )
     269             : {
     270           0 :     m_pAttrOutput->WriteField_Impl( pFld, eFldType, rFldCmd, nMode );
     271           0 : }
     272             : 
     273           0 : void DocxExport::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
     274             : {
     275           0 :     m_pAttrOutput->WriteFormData_Impl( rFieldmark );
     276           0 : }
     277             : 
     278           0 : void DocxExport::WriteHyperlinkData( const ::sw::mark::IFieldmark& /*rFieldmark*/ )
     279             : {
     280             : #if OSL_DEBUG_LEVEL > 1
     281             :     fprintf( stderr, "TODO DocxExport::WriteHyperlinkData()\n" );
     282             : #endif
     283           0 : }
     284             : 
     285           0 : void DocxExport::DoComboBox(const OUString& rName,
     286             :                              const OUString& rHelp,
     287             :                              const OUString& rToolTip,
     288             :                              const OUString& rSelected,
     289             :                              uno::Sequence<OUString>& rListItems)
     290             : {
     291           0 :     m_pDocumentFS->startElementNS( XML_w, XML_ffData, FSEND );
     292             : 
     293             :     m_pDocumentFS->singleElementNS( XML_w, XML_name,
     294             :             FSNS( XML_w, XML_val ), OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(),
     295           0 :             FSEND );
     296             : 
     297           0 :     m_pDocumentFS->singleElementNS( XML_w, XML_enabled, FSEND );
     298             : 
     299           0 :     if ( !rHelp.isEmpty() )
     300             :         m_pDocumentFS->singleElementNS( XML_w, XML_helpText,
     301             :             FSNS( XML_w, XML_val ), OUStringToOString( rHelp, RTL_TEXTENCODING_UTF8 ).getStr(),
     302           0 :             FSEND );
     303             : 
     304           0 :     if ( !rToolTip.isEmpty() )
     305             :         m_pDocumentFS->singleElementNS( XML_w, XML_statusText,
     306             :             FSNS( XML_w, XML_val ), OUStringToOString( rToolTip, RTL_TEXTENCODING_UTF8 ).getStr(),
     307           0 :             FSEND );
     308             : 
     309           0 :     m_pDocumentFS->startElementNS( XML_w, XML_ddList, FSEND );
     310             : 
     311             :     // Output the 0-based index of the selected value
     312           0 :     sal_uInt32 nListItems = rListItems.getLength();
     313           0 :     sal_Int32 nId = 0;
     314           0 :     sal_uInt32 nI = 0;
     315           0 :     while ( ( nI < nListItems ) && ( nId == 0 ) )
     316             :     {
     317           0 :         if ( rListItems[nI] == rSelected )
     318           0 :             nId = nI;
     319           0 :         nI++;
     320             :     }
     321             : 
     322             :     m_pDocumentFS->singleElementNS( XML_w, XML_result,
     323             :             FSNS( XML_w, XML_val ), OString::number( nId ).getStr( ),
     324           0 :             FSEND );
     325             : 
     326             :     // Loop over the entries
     327             : 
     328           0 :     for (sal_uInt32 i = 0; i < nListItems; i++)
     329             :     {
     330             :         m_pDocumentFS->singleElementNS( XML_w, XML_listEntry,
     331           0 :                 FSNS( XML_w, XML_val ), OUStringToOString( rListItems[i], RTL_TEXTENCODING_UTF8 ).getStr(),
     332           0 :                FSEND );
     333             :     }
     334             : 
     335           0 :     m_pDocumentFS->endElementNS( XML_w, XML_ddList );
     336             : 
     337           0 :     m_pDocumentFS->endElementNS( XML_w, XML_ffData );
     338           0 : }
     339             : 
     340           0 : void DocxExport::DoFormText(const SwInputField* /*pFld*/)
     341             : {
     342             :     OSL_TRACE( "TODO DocxExport::ForFormText()" );
     343           0 : }
     344             : 
     345           0 : OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer )
     346             : {
     347           0 :     OUString aFileName = "charts/chart" + OUString::number(nCount) + ".xml";
     348             :     OUString sId = m_pFilter->addRelation( m_pSerializer->getOutputStream(),
     349             :                     "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
     350           0 :                     aFileName );
     351           0 :     aFileName = "word/charts/chart" + OUString::number(nCount) + ".xml";
     352             :     ::sax_fastparser::FSHelperPtr pChartFS =
     353             :         m_pFilter->openFragmentStreamWithSerializer( aFileName,
     354           0 :             "application/vnd.openxmlformats-officedocument.drawingml.chart+xml" );
     355             : 
     356           0 :     oox::drawingml::ChartExport aChartExport( XML_w, pChartFS, xModel, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX );
     357           0 :     aChartExport.ExportContent();
     358           0 :     return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
     359             : }
     360             : 
     361           0 : OString DocxExport::WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType )
     362             : {
     363           0 :     uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
     364           0 :     comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer();
     365           0 :     uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj, NULL );
     366             : 
     367           0 :     OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + ".bin";
     368           0 :     uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer()
     369           0 :                                                                       .appendAscii( "word/" )
     370           0 :                                                                       .append( sFileName )
     371             :                                                                       .makeStringAndClear(),
     372           0 :                                                                       sMediaType );
     373           0 :     OUString sId;
     374           0 :     if( lcl_CopyStream( xInStream, xOutStream ) )
     375             : 
     376           0 :         sId = m_pFilter->addRelation( GetFS()->getOutputStream(),
     377           0 :                 sRelationType, sFileName, false );
     378             : 
     379           0 :     return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
     380             : }
     381             : 
     382             : // function copied from embeddedobj/source/msole/oleembed.cxx
     383           0 : bool DocxExport::lcl_CopyStream( uno::Reference<io::XInputStream> xIn, uno::Reference<io::XOutputStream> xOut )
     384             : {
     385           0 :     if( !xIn.is() || !xOut.is() )
     386           0 :         return false;
     387             : 
     388           0 :     const sal_Int32 nChunkSize = 4096;
     389           0 :     uno::Sequence< sal_Int8 > aData(nChunkSize);
     390           0 :     sal_Int32 nTotalRead = 0;
     391           0 :     sal_Int32 nRead = 0;
     392           0 :     do
     393             :     {
     394           0 :         nRead = xIn->readBytes(aData, nChunkSize);
     395           0 :         nTotalRead += nRead;
     396           0 :         xOut->writeBytes(aData);
     397             :     } while (nRead == nChunkSize);
     398           0 :     return nTotalRead != 0;
     399             : }
     400             : 
     401           0 : void DocxExport::OutputDML(uno::Reference<drawing::XShape>& xShape)
     402             : {
     403           0 :     uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
     404           0 :     sal_Int32 nNamespace = XML_wps;
     405           0 :     if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
     406           0 :         nNamespace = XML_wpg;
     407           0 :     else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
     408           0 :         nNamespace = XML_pic;
     409           0 :     oox::drawingml::ShapeExport aExport(nNamespace, m_pAttrOutput->GetSerializer(), 0, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX, m_pAttrOutput);
     410           0 :     aExport.WriteShape(xShape);
     411           0 : }
     412             : 
     413           0 : void DocxExport::ExportDocument_Impl()
     414             : {
     415             :     // Set the 'Track Revisions' flag in the settings structure
     416           0 :     m_aSettings.trackRevisions = 0 != ( nsRedlineMode_t::REDLINE_ON & mnRedlineMode );
     417             : 
     418           0 :     InitStyles();
     419             : 
     420             :     // init sections
     421           0 :     m_pSections = new MSWordSections( *this );
     422             : 
     423             :     // Make sure images are counted from one, even when exporting multiple documents.
     424           0 :     oox::drawingml::DrawingML::ResetCounters();
     425             : 
     426           0 :     WriteMainText();
     427             : 
     428           0 :     WriteFootnotesEndnotes();
     429             : 
     430           0 :     WritePostitFields();
     431             : 
     432           0 :     WriteNumbering();
     433             : 
     434           0 :     WriteFonts();
     435             : 
     436           0 :     WriteSettings();
     437             : 
     438           0 :     WriteTheme();
     439             : 
     440           0 :     WriteGlossary();
     441             : 
     442           0 :     WriteCustomXml();
     443             : 
     444           0 :     WriteActiveX();
     445             : 
     446           0 :     WriteEmbeddings();
     447             : 
     448           0 :     delete pStyles, pStyles = NULL;
     449           0 :     delete m_pSections, m_pSections = NULL;
     450           0 : }
     451             : 
     452           0 : void DocxExport::OutputPageSectionBreaks( const SwTxtNode& )
     453             : {
     454             :     OSL_TRACE( "TODO DocxExport::OutputPageSectionBreaks( const SwTxtNode& )" );
     455           0 : }
     456             : 
     457           0 : void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum )
     458             : {
     459           0 :     AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
     460           0 :     m_pSections->AppendSection( pPageDesc, pFmt, nLnNum );
     461           0 : }
     462             : 
     463           0 : void DocxExport::OutputEndNode( const SwEndNode& rEndNode )
     464             : {
     465           0 :     MSWordExportBase::OutputEndNode( rEndNode );
     466             : 
     467           0 :     if ( TXT_MAINTEXT == nTxtTyp && rEndNode.StartOfSectionNode()->IsSectionNode() )
     468             :     {
     469             :         // this originally comes from WW8Export::WriteText(), and looks like it
     470             :         // could have some code common with SectionNode()...
     471             : 
     472           0 :         const SwSection& rSect = rEndNode.StartOfSectionNode()->GetSectionNode()->GetSection();
     473           0 :         if ( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() )
     474           0 :             bStartTOX = false;
     475             : 
     476           0 :         SwNodeIndex aIdx( rEndNode, 1 );
     477           0 :         const SwNode& rNd = aIdx.GetNode();
     478           0 :         if ( rNd.IsEndNode() && rNd.StartOfSectionNode()->IsSectionNode() )
     479           0 :             return;
     480             : 
     481           0 :         bool isInTable = IsInTable();
     482           0 :         if ( !rNd.IsSectionNode() && isInTable ) // No sections in table
     483             :         {
     484           0 :             const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent();
     485           0 :             if( !pParentFmt )
     486           0 :                 pParentFmt = (SwSectionFmt*)0xFFFFFFFF;
     487             : 
     488             :             sal_uLong nRstLnNum;
     489           0 :             if( rNd.IsCntntNode() )
     490           0 :                 nRstLnNum = const_cast< SwCntntNode* >( rNd.GetCntntNode() )->GetSwAttrSet().GetLineNumber().GetStartValue();
     491             :             else
     492           0 :                 nRstLnNum = 0;
     493             : 
     494           0 :             AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo( ) );
     495           0 :             m_pSections->AppendSection( pAktPageDesc, pParentFmt, nRstLnNum );
     496           0 :         }
     497             :     }
     498             : }
     499             : 
     500           0 : void DocxExport::OutputTableNode( const SwTableNode& )
     501             : {
     502             :     OSL_TRACE( "TODO DocxExport::OutputTableNode( const SwTableNode& )" );
     503           0 : }
     504             : 
     505           0 : void DocxExport::OutputGrfNode( const SwGrfNode& )
     506             : {
     507             :     OSL_TRACE( "TODO DocxExport::OutputGrfNode( const SwGrfNode& )" );
     508           0 : }
     509             : 
     510           0 : void DocxExport::OutputOLENode( const SwOLENode& )
     511             : {
     512             :     OSL_TRACE( "TODO DocxExport::OutputOLENode( const SwOLENode& )" );
     513           0 : }
     514             : 
     515           0 : void DocxExport::OutputLinkedOLE( const OUString& )
     516             : {
     517             :     // Nothing to implement here: WW8 only
     518           0 : }
     519             : 
     520           0 : sal_uLong DocxExport::ReplaceCr( sal_uInt8 )
     521             : {
     522             :     // Completely unused for Docx export... only here for code sharing
     523             :     // purpose with binary export
     524           0 :     return 0;
     525             : }
     526             : 
     527           0 : void DocxExport::PrepareNewPageDesc( const SfxItemSet* pSet,
     528             :         const SwNode& rNd, const SwFmtPageDesc* pNewPgDescFmt,
     529             :         const SwPageDesc* pNewPgDesc )
     530             : {
     531             :     // tell the attribute output that we are ready to write the section
     532             :     // break [has to be output inside paragraph properties]
     533           0 :     AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
     534             : 
     535           0 :     const SwSectionFmt* pFmt = GetSectionFormat( rNd );
     536           0 :     const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd );
     537             : 
     538             :     OSL_ENSURE( pNewPgDescFmt || pNewPgDesc, "Neither page desc format nor page desc provided." );
     539             : 
     540           0 :     if ( pNewPgDescFmt )
     541             :     {
     542           0 :         m_pSections->AppendSection( *pNewPgDescFmt, rNd, pFmt, nLnNm );
     543             :     }
     544           0 :     else if ( pNewPgDesc )
     545             :     {
     546           0 :         m_pSections->AppendSection( pNewPgDesc, rNd, pFmt, nLnNm );
     547             :     }
     548             : 
     549           0 : }
     550             : 
     551           0 : void DocxExport::InitStyles()
     552             : {
     553           0 :     pStyles = new MSWordStyles( *this, /*bListStyles =*/ true );
     554             : 
     555             :     // setup word/styles.xml and the relations + content type
     556             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     557             :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
     558           0 :             "styles.xml" );
     559             : 
     560             :     ::sax_fastparser::FSHelperPtr pStylesFS =
     561             :         m_pFilter->openFragmentStreamWithSerializer( "word/styles.xml",
     562           0 :             "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" );
     563             : 
     564             :     // switch the serializer to redirect the output to word/styles.xml
     565           0 :     m_pAttrOutput->SetSerializer( pStylesFS );
     566             : 
     567             :     // do the work
     568           0 :     pStyles->OutputStylesTable();
     569             : 
     570             :     // switch the serializer back
     571           0 :     m_pAttrOutput->SetSerializer( m_pDocumentFS );
     572           0 : }
     573             : 
     574           0 : void DocxExport::WriteFootnotesEndnotes()
     575             : {
     576           0 :     if ( m_pAttrOutput->HasFootnotes() )
     577             :     {
     578             :         // setup word/styles.xml and the relations + content type
     579             :         m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     580             :                 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
     581           0 :                 "footnotes.xml" );
     582             : 
     583             :         ::sax_fastparser::FSHelperPtr pFootnotesFS =
     584             :             m_pFilter->openFragmentStreamWithSerializer( "word/footnotes.xml",
     585           0 :                     "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" );
     586             : 
     587             :         // switch the serializer to redirect the output to word/footnotes.xml
     588           0 :         m_pAttrOutput->SetSerializer( pFootnotesFS );
     589             : 
     590             :         // do the work
     591           0 :         m_pAttrOutput->FootnotesEndnotes( true );
     592             : 
     593             :         // switch the serializer back
     594           0 :         m_pAttrOutput->SetSerializer( m_pDocumentFS );
     595             :     }
     596             : 
     597           0 :     if ( m_pAttrOutput->HasEndnotes() )
     598             :     {
     599             :         // setup word/styles.xml and the relations + content type
     600             :         m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     601             :                 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
     602           0 :                 "endnotes.xml" );
     603             : 
     604             :         ::sax_fastparser::FSHelperPtr pEndnotesFS =
     605             :             m_pFilter->openFragmentStreamWithSerializer( "word/endnotes.xml",
     606           0 :                     "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" );
     607             : 
     608             :         // switch the serializer to redirect the output to word/endnotes.xml
     609           0 :         m_pAttrOutput->SetSerializer( pEndnotesFS );
     610             : 
     611             :         // do the work
     612           0 :         m_pAttrOutput->FootnotesEndnotes( false );
     613             : 
     614             :         // switch the serializer back
     615           0 :         m_pAttrOutput->SetSerializer( m_pDocumentFS );
     616             :     }
     617           0 : }
     618             : 
     619           0 : void DocxExport::WritePostitFields()
     620             : {
     621           0 :     if ( m_pAttrOutput->HasPostitFields() )
     622             :     {
     623             :         m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     624             :                 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
     625           0 :                 "comments.xml" );
     626             : 
     627             :         ::sax_fastparser::FSHelperPtr pPostitFS =
     628             :             m_pFilter->openFragmentStreamWithSerializer( "word/comments.xml",
     629           0 :                     "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" );
     630             : 
     631           0 :         pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces( pPostitFS ));
     632           0 :         m_pAttrOutput->SetSerializer( pPostitFS );
     633           0 :         m_pAttrOutput->WritePostitFields();
     634           0 :         m_pAttrOutput->SetSerializer( m_pDocumentFS );
     635           0 :         pPostitFS->endElementNS( XML_w, XML_comments );
     636             :     }
     637           0 : }
     638             : 
     639           0 : void DocxExport::WriteNumbering()
     640             : {
     641           0 :     if ( !pUsedNumTbl )
     642           0 :         return; // no numbering is used
     643             : 
     644             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     645             :         "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
     646           0 :         "numbering.xml" );
     647             : 
     648             :     ::sax_fastparser::FSHelperPtr pNumberingFS = m_pFilter->openFragmentStreamWithSerializer( "word/numbering.xml",
     649           0 :         "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" );
     650             : 
     651             :     // switch the serializer to redirect the output to word/nubering.xml
     652           0 :     m_pAttrOutput->SetSerializer( pNumberingFS );
     653             : 
     654             :     pNumberingFS->startElementNS( XML_w, XML_numbering,
     655             :             FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
     656             :             FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office",
     657             :             FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
     658             :             FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml",
     659           0 :             FSEND );
     660             : 
     661           0 :     BulletDefinitions();
     662             : 
     663           0 :     AbstractNumberingDefinitions();
     664             : 
     665           0 :     NumberingDefinitions();
     666             : 
     667           0 :     pNumberingFS->endElementNS( XML_w, XML_numbering );
     668             : 
     669             :     // switch the serializer back
     670           0 :     m_pAttrOutput->SetSerializer( m_pDocumentFS );
     671             : }
     672             : 
     673           0 : void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType )
     674             : {
     675             :     // setup the xml stream
     676           0 :     OUString aRelId;
     677           0 :     ::sax_fastparser::FSHelperPtr pFS;
     678           0 :     if ( bHeader )
     679             :     {
     680           0 :         OUString aName( OUStringBuffer().append("header").append( ++m_nHeaders ).append(".xml").makeStringAndClear() );
     681             : 
     682           0 :         aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     683             :                 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
     684           0 :                 aName );
     685             : 
     686           0 :         pFS = m_pFilter->openFragmentStreamWithSerializer( OUStringBuffer().append("word/").append( aName ).makeStringAndClear(),
     687           0 :                     "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" );
     688             : 
     689           0 :         pFS->startElementNS( XML_w, XML_hdr, MainXmlNamespaces( pFS ));
     690             :     }
     691             :     else
     692             :     {
     693           0 :         OUString aName( OUStringBuffer().append("footer").append( ++m_nFooters ).append(".xml").makeStringAndClear() );
     694             : 
     695           0 :         aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     696             :                 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
     697           0 :                 aName );
     698             : 
     699           0 :         pFS = m_pFilter->openFragmentStreamWithSerializer( OUStringBuffer().append("word/").append( aName ).makeStringAndClear(),
     700           0 :                     "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" );
     701             : 
     702           0 :         pFS->startElementNS( XML_w, XML_ftr, MainXmlNamespaces( pFS ));
     703             :     }
     704             : 
     705             :     // switch the serializer to redirect the output to word/styles.xml
     706           0 :     m_pAttrOutput->SetSerializer( pFS );
     707           0 :     m_pVMLExport->SetFS( pFS );
     708           0 :     m_pSdrExport->setSerializer(pFS);
     709           0 :     SetFS( pFS );
     710           0 :     m_pAttrOutput->switchHeaderFooter(true, m_nHeadersFootersInSection++);
     711             :     // do the work
     712           0 :     WriteHeaderFooterText( rFmt, bHeader );
     713             : 
     714             :     // switch the serializer back
     715           0 :     m_pAttrOutput->SetSerializer( m_pDocumentFS );
     716           0 :     m_pVMLExport->SetFS( m_pDocumentFS );
     717           0 :     m_pSdrExport->setSerializer(m_pDocumentFS);
     718           0 :     SetFS( m_pDocumentFS );
     719             : 
     720             :     // close the tag
     721             :     sal_Int32 nReference;
     722           0 :     if ( bHeader )
     723             :     {
     724           0 :         pFS->endElementNS( XML_w, XML_hdr );
     725           0 :         nReference = XML_headerReference;
     726             :     }
     727             :     else
     728             :     {
     729           0 :         pFS->endElementNS( XML_w, XML_ftr );
     730           0 :         nReference = XML_footerReference;
     731             :     }
     732             : 
     733             :     // and write the reference
     734             :     m_pDocumentFS->singleElementNS( XML_w, nReference,
     735             :             FSNS( XML_w, XML_type ), pType,
     736             :             FSNS( XML_r, XML_id ), OUStringToOString( aRelId, RTL_TEXTENCODING_UTF8 ).getStr(),
     737           0 :             FSEND );
     738           0 : }
     739             : 
     740           0 : void DocxExport::WriteFonts()
     741             : {
     742             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     743             :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
     744           0 :             "fontTable.xml" );
     745             : 
     746             :     ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openFragmentStreamWithSerializer(
     747             :             "word/fontTable.xml",
     748           0 :             "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" );
     749             : 
     750             :     pFS->startElementNS( XML_w, XML_fonts,
     751             :             FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
     752             :             FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
     753           0 :             FSEND );
     754             : 
     755             :     // switch the serializer to redirect the output to word/styles.xml
     756           0 :     m_pAttrOutput->SetSerializer( pFS );
     757             : 
     758             :     // do the work
     759           0 :     maFontHelper.WriteFontTable( *m_pAttrOutput );
     760             : 
     761             :     // switch the serializer back
     762           0 :     m_pAttrOutput->SetSerializer( m_pDocumentFS );
     763             : 
     764           0 :     pFS->endElementNS( XML_w, XML_fonts );
     765           0 : }
     766             : 
     767           0 : void DocxExport::WriteProperties( )
     768             : {
     769             :     // Write the core properties
     770           0 :     SwDocShell* pDocShell( pDoc->GetDocShell( ) );
     771           0 :     uno::Reference<document::XDocumentProperties> xDocProps;
     772           0 :     if ( pDocShell )
     773             :     {
     774             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     775           0 :                pDocShell->GetModel( ), uno::UNO_QUERY );
     776           0 :         xDocProps = xDPS->getDocumentProperties();
     777             :     }
     778             : 
     779           0 :     m_pFilter->exportDocumentProperties( xDocProps );
     780           0 : }
     781             : 
     782           0 : void DocxExport::WriteSettings()
     783             : {
     784           0 :     SwViewShell *pViewShell(pDoc->GetCurrentViewShell());
     785           0 :     if( !pViewShell && !m_aSettings.hasData() && !m_pAttrOutput->HasFootnotes() && !m_pAttrOutput->HasEndnotes())
     786           0 :         return;
     787             : 
     788             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     789             :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
     790           0 :             "settings.xml" );
     791             : 
     792             :     ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openFragmentStreamWithSerializer(
     793             :             "word/settings.xml",
     794           0 :             "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" );
     795             : 
     796             :     pFS->startElementNS( XML_w, XML_settings,
     797             :             FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
     798           0 :             FSEND );
     799             : 
     800             :     // Zoom
     801           0 :     if (pViewShell)
     802             :     {
     803           0 :         OString aZoom(OString::number(pViewShell->GetViewOptions()->GetZoom()));
     804           0 :         pFS->singleElementNS(XML_w, XML_zoom, FSNS(XML_w, XML_percent), aZoom.getStr(), FSEND);
     805             :     }
     806             : 
     807             :     // Display Background Shape
     808           0 :     if (boost::optional<const SvxBrushItem*> oBrush = getBackground())
     809             :     {
     810             :         // Turn on the 'displayBackgroundShape'
     811           0 :         pFS->singleElementNS( XML_w, XML_displayBackgroundShape, FSEND );
     812           0 :     }
     813             : 
     814             :     // Track Changes
     815           0 :     if ( m_aSettings.trackRevisions )
     816           0 :         pFS->singleElementNS( XML_w, XML_trackRevisions, FSEND );
     817             : 
     818             :     // Mirror Margins
     819           0 :     if(isMirroredMargin())
     820           0 :         pFS->singleElementNS( XML_w, XML_mirrorMargins, FSEND );
     821             : 
     822             :     // Embed Fonts
     823           0 :     if( pDoc->get( IDocumentSettingAccess::EMBED_FONTS ))
     824           0 :         pFS->singleElementNS( XML_w, XML_embedTrueTypeFonts, FSEND );
     825             : 
     826             :     // Embed System Fonts
     827           0 :     if( pDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS ))
     828           0 :         pFS->singleElementNS( XML_w, XML_embedSystemFonts, FSEND );
     829             : 
     830             :     // Default Tab Stop
     831           0 :     if( m_aSettings.defaultTabStop != 0 )
     832             :         pFS->singleElementNS( XML_w, XML_defaultTabStop, FSNS( XML_w, XML_val ),
     833           0 :             OString::number( m_aSettings.defaultTabStop).getStr(), FSEND );
     834             : 
     835             :     // Even and Odd Headers
     836           0 :     if( m_aSettings.evenAndOddHeaders )
     837           0 :         pFS->singleElementNS( XML_w, XML_evenAndOddHeaders, FSEND );
     838             : 
     839             :     // Has Footnotes
     840           0 :     if( m_pAttrOutput->HasFootnotes())
     841           0 :         m_pAttrOutput->WriteFootnoteEndnotePr( pFS, XML_footnotePr, pDoc->GetFtnInfo(), XML_footnote );
     842             : 
     843             :     // Has Endnotes
     844           0 :     if( m_pAttrOutput->HasEndnotes())
     845           0 :         m_pAttrOutput->WriteFootnoteEndnotePr( pFS, XML_endnotePr, pDoc->GetEndNoteInfo(), XML_endnote );
     846             : 
     847             :     // Has themeFontLang information
     848           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
     849             : 
     850           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     851           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
     852           0 :     if ( xPropSetInfo->hasPropertyByName( pName ) )
     853             :     {
     854           0 :         uno::Sequence< beans::PropertyValue > propList;
     855           0 :         xPropSet->getPropertyValue( pName ) >>= propList;
     856           0 :         for( sal_Int32 i=0; i < propList.getLength(); ++i )
     857             :         {
     858           0 :             if ( propList[i].Name == "ThemeFontLangProps" )
     859             :             {
     860           0 :                 uno::Sequence< beans::PropertyValue > themeFontLangProps;
     861           0 :                 propList[i].Value >>= themeFontLangProps;
     862           0 :                 OUString aValues[3];
     863           0 :                 for( sal_Int32 j=0; j < themeFontLangProps.getLength(); ++j )
     864             :                 {
     865           0 :                     if( themeFontLangProps[j].Name == "val" )
     866           0 :                         themeFontLangProps[j].Value >>= aValues[0];
     867           0 :                     else if( themeFontLangProps[j].Name == "eastAsia" )
     868           0 :                         themeFontLangProps[j].Value >>= aValues[1];
     869           0 :                     else if( themeFontLangProps[j].Name == "bidi" )
     870           0 :                         themeFontLangProps[j].Value >>= aValues[2];
     871             :                 }
     872             :                 pFS->singleElementNS( XML_w, XML_themeFontLang,
     873             :                                       FSNS( XML_w, XML_val ), OUStringToOString( aValues[0], RTL_TEXTENCODING_UTF8 ).getStr(),
     874             :                                       FSNS( XML_w, XML_eastAsia ), OUStringToOString( aValues[1], RTL_TEXTENCODING_UTF8 ).getStr(),
     875             :                                       FSNS( XML_w, XML_bidi ), OUStringToOString( aValues[2], RTL_TEXTENCODING_UTF8 ).getStr(),
     876           0 :                                       FSEND );
     877             :             }
     878           0 :             else if ( propList[i].Name == "CompatSettings" )
     879             :             {
     880           0 :                 pFS->startElementNS( XML_w, XML_compat, FSEND );
     881             : 
     882           0 :                 uno::Sequence< beans::PropertyValue > aCompatSettingsSequence;
     883           0 :                 propList[i].Value >>= aCompatSettingsSequence;
     884           0 :                 for(sal_Int32 j=0; j < aCompatSettingsSequence.getLength(); ++j)
     885             :                 {
     886           0 :                     uno::Sequence< beans::PropertyValue > aCompatSetting;
     887           0 :                     aCompatSettingsSequence[j].Value >>= aCompatSetting;
     888           0 :                     OUString aName;
     889           0 :                     OUString aUri;
     890           0 :                     OUString aValue;
     891             : 
     892           0 :                     for(sal_Int32 k=0; k < aCompatSetting.getLength(); ++k)
     893             :                     {
     894           0 :                         if( aCompatSetting[k].Name == "name" )
     895           0 :                             aCompatSetting[k].Value >>= aName;
     896           0 :                         else if( aCompatSetting[k].Name == "uri" )
     897           0 :                             aCompatSetting[k].Value >>= aUri;
     898           0 :                         else if( aCompatSetting[k].Name == "val" )
     899           0 :                             aCompatSetting[k].Value >>= aValue;
     900             :                     }
     901             :                     pFS->singleElementNS( XML_w, XML_compatSetting,
     902             :                         FSNS( XML_w, XML_name ), OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr(),
     903             :                         FSNS( XML_w, XML_uri ),  OUStringToOString(aUri, RTL_TEXTENCODING_UTF8).getStr(),
     904             :                         FSNS( XML_w, XML_val ),  OUStringToOString(aValue, RTL_TEXTENCODING_UTF8).getStr(),
     905           0 :                         FSEND);
     906           0 :                 }
     907             : 
     908           0 :                 pFS->endElementNS( XML_w, XML_compat );
     909             :             }
     910           0 :         }
     911             :     }
     912             : 
     913           0 :     pFS->endElementNS( XML_w, XML_settings );
     914             : }
     915             : 
     916           0 : void DocxExport::WriteTheme()
     917             : {
     918           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
     919             : 
     920           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     921           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
     922           0 :     if ( !xPropSetInfo->hasPropertyByName( pName ) )
     923           0 :         return;
     924             : 
     925           0 :     uno::Reference<xml::dom::XDocument> themeDom;
     926           0 :     uno::Sequence< beans::PropertyValue > propList;
     927           0 :     xPropSet->getPropertyValue( pName ) >>= propList;
     928           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
     929             :     {
     930           0 :         OUString propName = propList[nProp].Name;
     931           0 :         if ( propName == "OOXTheme" )
     932             :         {
     933           0 :              propList[nProp].Value >>= themeDom;
     934           0 :              break;
     935             :         }
     936           0 :     }
     937             : 
     938             :     // no theme dom to write
     939           0 :     if ( !themeDom.is() )
     940           0 :         return;
     941             : 
     942             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     943             :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
     944           0 :             "theme/theme1.xml" );
     945             : 
     946           0 :     uno::Reference< xml::sax::XSAXSerializable > serializer( themeDom, uno::UNO_QUERY );
     947           0 :     uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
     948           0 :     writer->setOutputStream( GetFilter().openFragmentStream( "word/theme/theme1.xml",
     949           0 :         "application/vnd.openxmlformats-officedocument.theme+xml" ) );
     950           0 :     serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
     951           0 :         uno::Sequence< beans::StringPair >() );
     952             : }
     953             : 
     954           0 : void DocxExport::WriteGlossary()
     955             : {
     956           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
     957             : 
     958           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     959           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
     960           0 :     if ( !xPropSetInfo->hasPropertyByName( pName ) )
     961           0 :         return;
     962             : 
     963           0 :     uno::Reference<xml::dom::XDocument> glossaryDocDom;
     964           0 :     uno::Sequence< uno::Sequence< uno::Any> > glossaryDomList;
     965           0 :     uno::Sequence< beans::PropertyValue > propList;
     966           0 :     xPropSet->getPropertyValue( pName ) >>= propList;
     967           0 :     sal_Int32 collectedProperties = 0;
     968           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
     969             :     {
     970           0 :         OUString propName = propList[nProp].Name;
     971           0 :         if ( propName == "OOXGlossary" )
     972             :         {
     973           0 :              propList[nProp].Value >>= glossaryDocDom;
     974           0 :              collectedProperties++;
     975             :         }
     976           0 :         if (propName == "OOXGlossaryDom")
     977             :         {
     978           0 :             propList[nProp].Value >>= glossaryDomList;
     979           0 :             collectedProperties++;
     980             :         }
     981           0 :         if (collectedProperties == 2)
     982           0 :             break;
     983           0 :     }
     984             : 
     985             :     // no glossary dom to write
     986           0 :     if ( !glossaryDocDom.is() )
     987           0 :         return;
     988             : 
     989             :     m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
     990             :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument",
     991           0 :             "glossary/document.xml" );
     992             : 
     993           0 :     uno::Reference< io::XOutputStream > xOutputStream = GetFilter().openFragmentStream( "word/glossary/document.xml",
     994           0 :             "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml" );
     995             : 
     996           0 :     uno::Reference< xml::sax::XSAXSerializable > serializer( glossaryDocDom, uno::UNO_QUERY );
     997           0 :     uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
     998           0 :     writer->setOutputStream( xOutputStream );
     999           0 :     serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
    1000           0 :         uno::Sequence< beans::StringPair >() );
    1001             : 
    1002           0 :     sal_Int32 length = glossaryDomList.getLength();
    1003           0 :     for ( int i =0; i < length; i++)
    1004             :     {
    1005           0 :         uno::Sequence< uno::Any> glossaryElement = glossaryDomList[i];
    1006           0 :         OUString gTarget, gType, gId, contentType;
    1007           0 :         uno::Reference<xml::dom::XDocument> xDom;
    1008           0 :         glossaryElement[0] >>= xDom;
    1009           0 :         glossaryElement[1] >>= gId;
    1010           0 :         glossaryElement[2] >>= gType;
    1011           0 :         glossaryElement[3] >>= gTarget;
    1012           0 :         glossaryElement[4] >>= contentType;
    1013           0 :         gId = gId.copy(3); //"rId" only save the numeric value
    1014             : 
    1015           0 :         PropertySet aProps(xOutputStream);
    1016           0 :         aProps.setAnyProperty( PROP_RelId, uno::makeAny( sal_Int32( gId.toInt32() )));
    1017           0 :         m_pFilter->addRelation( xOutputStream, gType, gTarget);
    1018           0 :         uno::Reference< xml::sax::XSAXSerializable > gserializer( xDom, uno::UNO_QUERY );
    1019           0 :         writer->setOutputStream(GetFilter().openFragmentStream( "word/glossary/" + gTarget, contentType ) );
    1020           0 :         gserializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
    1021           0 :                uno::Sequence< beans::StringPair >() );
    1022           0 :     }
    1023             : }
    1024             : 
    1025           0 : void DocxExport::WriteCustomXml()
    1026             : {
    1027           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
    1028             : 
    1029           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
    1030           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
    1031           0 :     if ( !xPropSetInfo->hasPropertyByName( pName ) )
    1032           0 :         return;
    1033             : 
    1034           0 :     uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomlist;
    1035           0 :     uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomPropslist;
    1036           0 :     uno::Sequence< beans::PropertyValue > propList;
    1037           0 :     xPropSet->getPropertyValue( pName ) >>= propList;
    1038           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
    1039             :     {
    1040           0 :         OUString propName = propList[nProp].Name;
    1041           0 :         if ( propName == "OOXCustomXml" )
    1042             :         {
    1043           0 :              propList[nProp].Value >>= customXmlDomlist;
    1044           0 :              break;
    1045             :         }
    1046           0 :     }
    1047             : 
    1048           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
    1049             :     {
    1050           0 :         OUString propName = propList[nProp].Name;
    1051           0 :         if ( propName == "OOXCustomXmlProps" )
    1052             :         {
    1053           0 :              propList[nProp].Value >>= customXmlDomPropslist;
    1054           0 :              break;
    1055             :         }
    1056           0 :     }
    1057             : 
    1058           0 :     for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++) {
    1059             : 
    1060           0 :         uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j];
    1061           0 :         uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j];
    1062           0 :         if ( customXmlDom.is() )
    1063             :         {
    1064             :             m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
    1065             :                     "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
    1066           0 :                     "../customXml/item"+OUString::number((j+1))+".xml" );
    1067             : 
    1068           0 :             uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY );
    1069           0 :             uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
    1070           0 :             writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml",
    1071           0 :                 "application/xml" ) );
    1072           0 :             serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
    1073           0 :                 uno::Sequence< beans::StringPair >() );
    1074             :         }
    1075             : 
    1076           0 :         if ( customXmlDomProps.is() )
    1077             :         {
    1078             : 
    1079           0 :             uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY );
    1080           0 :             uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
    1081           0 :             writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml",
    1082           0 :                 "application/vnd.openxmlformats-officedocument.customXmlProperties+xml" ) );
    1083           0 :             serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
    1084           0 :                 uno::Sequence< beans::StringPair >() );
    1085             : 
    1086             :             // Adding itemprops's relationship entry to item.xml.rels file
    1087           0 :             m_pFilter->addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml",
    1088             :                     "application/xml" ) ,
    1089             :                     "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps",
    1090           0 :                     "itemProps"+OUString::number((j+1))+".xml" );
    1091             : 
    1092             :         }
    1093           0 :     }
    1094             : }
    1095             : 
    1096           0 : void DocxExport::WriteActiveX()
    1097             : {
    1098           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
    1099             : 
    1100           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
    1101           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
    1102           0 :     if ( !xPropSetInfo->hasPropertyByName( pName ) )
    1103           0 :         return;
    1104             : 
    1105           0 :     uno::Sequence<uno::Reference<xml::dom::XDocument> > activeXDomlist;
    1106           0 :     uno::Sequence<uno::Reference<io::XInputStream> > activeXBinList;
    1107           0 :     uno::Sequence< beans::PropertyValue > propList;
    1108           0 :     xPropSet->getPropertyValue( pName ) >>= propList;
    1109           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
    1110             :     {
    1111           0 :         OUString propName = propList[nProp].Name;
    1112           0 :         if ( propName == "OOXActiveX" )
    1113             :         {
    1114           0 :              propList[nProp].Value >>= activeXDomlist;
    1115           0 :              break;
    1116             :         }
    1117           0 :     }
    1118             : 
    1119           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
    1120             :     {
    1121           0 :         OUString propName = propList[nProp].Name;
    1122           0 :         if ( propName == "OOXActiveXBin" )
    1123             :         {
    1124           0 :             propList[nProp].Value >>= activeXBinList;
    1125           0 :             break;
    1126             :         }
    1127           0 :     }
    1128             : 
    1129           0 :     for (sal_Int32 j = 0; j < activeXDomlist.getLength(); j++)
    1130             :     {
    1131           0 :         uno::Reference<xml::dom::XDocument> activeXDom = activeXDomlist[j];
    1132           0 :         uno::Reference<io::XInputStream> activeXBin = activeXBinList[j];
    1133             : 
    1134           0 :         if ( activeXDom.is() )
    1135             :         {
    1136             :             m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
    1137             :                     "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control",
    1138           0 :                     "activeX/activeX"+OUString::number((j+1))+".xml" );
    1139             : 
    1140           0 :             uno::Reference< xml::sax::XSAXSerializable > serializer( activeXDom, uno::UNO_QUERY );
    1141           0 :             uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
    1142           0 :             writer->setOutputStream( GetFilter().openFragmentStream( "word/activeX/activeX"+OUString::number((j+1))+".xml",
    1143           0 :                 "application/vnd.ms-office.activeX+xml" ) );
    1144           0 :             serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
    1145           0 :                 uno::Sequence< beans::StringPair >() );
    1146             :         }
    1147             : 
    1148           0 :         if ( activeXBin.is() )
    1149             :         {
    1150           0 :             uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream("word/activeX/activeX"+OUString::number((j+1))+".bin",
    1151           0 :                     "application/vnd.ms-office.activeX");
    1152             : 
    1153             :             try
    1154             :             {
    1155           0 :                 sal_Int32 nBufferSize = 512;
    1156           0 :                 uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize);
    1157             :                 sal_Int32 nRead;
    1158           0 :                 do
    1159             :                 {
    1160           0 :                     nRead = activeXBin->readBytes( aDataBuffer, nBufferSize );
    1161           0 :                     if( nRead )
    1162             :                     {
    1163           0 :                         if( nRead < nBufferSize )
    1164             :                         {
    1165           0 :                             nBufferSize = nRead;
    1166           0 :                             aDataBuffer.realloc(nRead);
    1167             :                         }
    1168           0 :                         xOutStream->writeBytes( aDataBuffer );
    1169             :                     }
    1170             :                 }
    1171             :                 while( nRead );
    1172           0 :                 xOutStream->flush();
    1173             :             }
    1174           0 :             catch(const uno::Exception&)
    1175             :             {
    1176             :                 SAL_WARN("sw.ww8", "WriteActiveX() ::Failed to copy Inputstream to outputstream exception catched!");
    1177             :             }
    1178             : 
    1179           0 :             xOutStream->closeOutput();
    1180             :             // Adding itemprops's relationship entry to item.xml.rels file
    1181           0 :             m_pFilter->addRelation( GetFilter().openFragmentStream( "/word/activeX/activeX"+OUString::number((j+1))+".xml",
    1182             :                     "application/vnd.ms-office.activeX+xml" ) ,
    1183             :                     "http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary",
    1184           0 :                     "activeX"+OUString::number((j+1))+".bin" );
    1185             : 
    1186             :         }
    1187           0 :      }
    1188             : }
    1189             : 
    1190           0 : void DocxExport::WriteEmbeddings()
    1191             : {
    1192           0 :     uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
    1193             : 
    1194           0 :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
    1195           0 :     OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
    1196           0 :     if ( !xPropSetInfo->hasPropertyByName( pName ) )
    1197           0 :         return;
    1198             : 
    1199           0 :     uno::Sequence< beans::PropertyValue > embeddingsList;
    1200           0 :     uno::Sequence< beans::PropertyValue > propList;
    1201           0 :     xPropSet->getPropertyValue( pName ) >>= propList;
    1202           0 :     for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
    1203             :     {
    1204           0 :         OUString propName = propList[nProp].Name;
    1205           0 :         if ( propName == "OOXEmbeddings" )
    1206             :         {
    1207           0 :              propList[nProp].Value >>= embeddingsList;
    1208           0 :              break;
    1209             :         }
    1210           0 :     }
    1211           0 :     for (sal_Int32 j = 0; j < embeddingsList.getLength(); j++)
    1212             :     {
    1213           0 :         OUString embeddingPath = embeddingsList[j].Name;
    1214           0 :         uno::Reference<io::XInputStream> embeddingsStream;
    1215           0 :         embeddingsList[j].Value >>= embeddingsStream;
    1216             : 
    1217           0 :         OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    1218           0 :         if (embeddingPath.endsWith(OUString(".xlsm")))
    1219           0 :             contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
    1220           0 :         else if (embeddingPath.endsWith(OUString(".bin")))
    1221           0 :             contentType = "application/vnd.openxmlformats-officedocument.oleObject";
    1222             : 
    1223           0 :         if ( embeddingsStream.is() )
    1224             :         {
    1225           0 :             uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream(embeddingPath,
    1226           0 :                                     contentType);
    1227             :             try
    1228             :             {
    1229           0 :                 sal_Int32 nBufferSize = 512;
    1230           0 :                 uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize);
    1231             :                 sal_Int32 nRead;
    1232           0 :                 do
    1233             :                 {
    1234           0 :                     nRead = embeddingsStream->readBytes( aDataBuffer, nBufferSize );
    1235           0 :                     if( nRead )
    1236             :                     {
    1237           0 :                         if( nRead < nBufferSize )
    1238             :                         {
    1239           0 :                             nBufferSize = nRead;
    1240           0 :                             aDataBuffer.realloc(nRead);
    1241             :                         }
    1242           0 :                         xOutStream->writeBytes( aDataBuffer );
    1243             :                     }
    1244             :                 }
    1245             :                 while( nRead );
    1246           0 :                 xOutStream->flush();
    1247             :             }
    1248           0 :             catch(const uno::Exception&)
    1249             :             {
    1250             :                 SAL_WARN("sw.ww8", "WriteEmbeddings() ::Failed to copy Inputstream to outputstream exception catched!");
    1251             :             }
    1252           0 :             xOutStream->closeOutput();
    1253             :         }
    1254           0 :     }
    1255             : }
    1256             : 
    1257           0 : VMLExport& DocxExport::VMLExporter()
    1258             : {
    1259           0 :     return *m_pVMLExport;
    1260             : }
    1261             : 
    1262           0 : DocxSdrExport& DocxExport::SdrExporter()
    1263             : {
    1264           0 :     return *m_pSdrExport;
    1265             : }
    1266             : 
    1267           0 : bool DocxExport::isMirroredMargin()
    1268             : {
    1269           0 :     bool bMirroredMargins = false;
    1270           0 :     if ( nsUseOnPage::PD_MIRROR == (nsUseOnPage::PD_MIRROR & pDoc->GetPageDesc(0).ReadUseOn()) )
    1271             :     {
    1272           0 :         bMirroredMargins = true;
    1273             :     }
    1274           0 :     return bMirroredMargins;
    1275             : }
    1276             : 
    1277           0 : boost::optional<const SvxBrushItem*> DocxExport::getBackground()
    1278             : {
    1279           0 :     boost::optional<const SvxBrushItem*> oRet;
    1280           0 :     const SwFrmFmt &rFmt = pDoc->GetPageDesc(0).GetMaster();
    1281           0 :     const SfxPoolItem* pItem = 0;
    1282           0 :     SfxItemState eState = rFmt.GetItemState(RES_BACKGROUND, true, &pItem);
    1283             : 
    1284           0 :     if (SFX_ITEM_SET == eState && pItem)
    1285             :     {
    1286             :         // The 'color' is set for the first page style - take it and use it as the background color of the entire DOCX
    1287           0 :         const SvxBrushItem* pBrush = (const SvxBrushItem*)pItem;
    1288           0 :         if (pBrush->GetColor().GetColor() != COL_AUTO)
    1289           0 :             oRet.reset(pBrush);
    1290             :     }
    1291           0 :     return oRet;
    1292             : }
    1293             : 
    1294           0 : void DocxExport::WriteMainText()
    1295             : {
    1296             :     // setup the namespaces
    1297           0 :     m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS ));
    1298             : 
    1299             :     // Write background page color
    1300           0 :     if (boost::optional<const SvxBrushItem*> oBrush = getBackground())
    1301             :     {
    1302           0 :         Color backgroundColor = (*oBrush)->GetColor();
    1303           0 :         OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor);
    1304             : 
    1305           0 :         m_pDocumentFS->singleElementNS( XML_w, XML_background, FSNS( XML_w, XML_color ), aBackgroundColorStr, FSEND );
    1306           0 :     }
    1307             : 
    1308             :     // body
    1309           0 :     m_pDocumentFS->startElementNS( XML_w, XML_body, FSEND );
    1310             : 
    1311           0 :     pCurPam->GetPoint()->nNode = pDoc->GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
    1312             : 
    1313             :     // the text
    1314           0 :     WriteText();
    1315             : 
    1316             :     // the last section info
    1317           0 :     const WW8_SepInfo *pSectionInfo = m_pSections? m_pSections->CurrentSectionInfo(): NULL;
    1318           0 :     if ( pSectionInfo )
    1319           0 :         SectionProperties( *pSectionInfo );
    1320             : 
    1321             :     // finish body and document
    1322           0 :     m_pDocumentFS->endElementNS( XML_w, XML_body );
    1323           0 :     m_pDocumentFS->endElementNS( XML_w, XML_document );
    1324           0 : }
    1325             : 
    1326           0 : XFastAttributeListRef DocxExport::MainXmlNamespaces( FSHelperPtr serializer )
    1327             : {
    1328           0 :     FastAttributeList* pAttr = serializer->createAttrList();
    1329           0 :     pAttr->add( FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office" );
    1330           0 :     pAttr->add( FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships" );
    1331           0 :     pAttr->add( FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml" );
    1332           0 :     pAttr->add( FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main" );
    1333           0 :     pAttr->add( FSNS( XML_xmlns, XML_w10 ), "urn:schemas-microsoft-com:office:word" );
    1334           0 :     pAttr->add( FSNS( XML_xmlns, XML_wp ), "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" );
    1335           0 :     pAttr->add( FSNS( XML_xmlns, XML_wps ), "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
    1336           0 :     pAttr->add( FSNS( XML_xmlns, XML_wpg ), "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
    1337           0 :     pAttr->add( FSNS( XML_xmlns, XML_mc ), "http://schemas.openxmlformats.org/markup-compatibility/2006" );
    1338           0 :     pAttr->add( FSNS( XML_xmlns, XML_wp14 ), "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" );
    1339           0 :     pAttr->add( FSNS( XML_xmlns, XML_w14 ), "http://schemas.microsoft.com/office/word/2010/wordml" );
    1340           0 :     pAttr->add( FSNS( XML_mc, XML_Ignorable ), "w14 wp14" );
    1341           0 :     return XFastAttributeListRef( pAttr );
    1342             : }
    1343             : 
    1344           0 : bool DocxExport::ignoreAttributeForStyles( sal_uInt16 nWhich ) const
    1345             : {
    1346           0 :     if( nWhich == RES_TEXTGRID )
    1347           0 :         return true; // w:docGrid is written only to document.xml, not to styles.xml
    1348           0 :     return MSWordExportBase::ignoreAttributeForStyles( nWhich );
    1349             : }
    1350             : 
    1351           0 : void DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp)
    1352             : {
    1353           0 :     const EditTextObject& rEditObj = rParaObj.GetTextObject();
    1354           0 :     MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
    1355             : 
    1356           0 :     sal_Int32 nPara = rEditObj.GetParagraphCount();
    1357           0 :     for( sal_Int32 n = 0; n < nPara; ++n )
    1358             :     {
    1359           0 :         if( n )
    1360           0 :             aAttrIter.NextPara( n );
    1361             : 
    1362           0 :         AttrOutput().StartParagraph( ww8::WW8TableNodeInfo::Pointer_t());
    1363           0 :         rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
    1364           0 :         OUString aStr( rEditObj.GetText( n ));
    1365           0 :         sal_Int32 nAktPos = 0;
    1366           0 :         const sal_Int32 nEnd = aStr.getLength();
    1367           0 :         do {
    1368           0 :             AttrOutput().StartRun( NULL );
    1369           0 :             const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
    1370           0 :             rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
    1371             : 
    1372           0 :             bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
    1373           0 :             if( !bTxtAtr )
    1374             :             {
    1375           0 :                 if( nAktPos == 0 && nNextAttr - nAktPos == aStr.getLength())
    1376           0 :                     AttrOutput().RunText( aStr, eChrSet );
    1377             :                 else
    1378             :                 {
    1379           0 :                     OUString tmp( aStr.copy( nAktPos, nNextAttr - nAktPos ));
    1380           0 :                     AttrOutput().RunText( tmp, eChrSet );
    1381             :                 }
    1382             :             }
    1383           0 :             AttrOutput().StartRunProperties();
    1384           0 :             aAttrIter.OutAttr( nAktPos );
    1385           0 :             AttrOutput().EndRunProperties( NULL );
    1386             : 
    1387           0 :             nAktPos = nNextAttr;
    1388           0 :             eChrSet = eNextChrSet;
    1389           0 :             aAttrIter.NextPos();
    1390           0 :             AttrOutput().EndRun();
    1391           0 :         } while( nAktPos < nEnd );
    1392             : //        aAttrIter.OutParaAttr(false);
    1393           0 :         AttrOutput().EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t());
    1394           0 :     }
    1395           0 : }
    1396             : 
    1397           0 : void DocxExport::SetFS( ::sax_fastparser::FSHelperPtr pFS )
    1398             : {
    1399           0 :     mpFS = pFS;
    1400           0 : }
    1401             : 
    1402           0 : DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
    1403             :     : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
    1404             :       m_pFilter( pFilter ),
    1405             :       m_pAttrOutput( NULL ),
    1406             :       m_pSections( NULL ),
    1407             :       m_nHeaders( 0 ),
    1408             :       m_nFooters( 0 ),
    1409             :       m_nOLEObjects( 0 ),
    1410             :       m_nHeadersFootersInSection(0),
    1411             :       m_pVMLExport( NULL ),
    1412           0 :       m_pSdrExport( NULL )
    1413             : {
    1414             :     // Write the document properies
    1415           0 :     WriteProperties( );
    1416             : 
    1417             :     // relations for the document
    1418             :     m_pFilter->addRelation( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
    1419           0 :             "word/document.xml" );
    1420             : 
    1421             :     // the actual document
    1422           0 :     m_pDocumentFS = m_pFilter->openFragmentStreamWithSerializer( "word/document.xml",
    1423           0 :             "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" );
    1424             : 
    1425           0 :     SetFS(m_pDocumentFS);
    1426             : 
    1427             :     // the DrawingML access
    1428           0 :     m_pDrawingML = new oox::drawingml::DrawingML( m_pDocumentFS, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX );
    1429             : 
    1430             :     // the attribute output for the document
    1431           0 :     m_pAttrOutput = new DocxAttributeOutput( *this, m_pDocumentFS, m_pDrawingML );
    1432             : 
    1433             :     // the related VMLExport
    1434           0 :     m_pVMLExport = new VMLExport( m_pDocumentFS, m_pAttrOutput );
    1435             : 
    1436             :     // the related drawing export
    1437           0 :     m_pSdrExport = new DocxSdrExport( *this, m_pDocumentFS, m_pDrawingML );
    1438           0 : }
    1439             : 
    1440           0 : DocxExport::~DocxExport()
    1441             : {
    1442           0 :     delete m_pSdrExport, m_pSdrExport = NULL;
    1443           0 :     delete m_pVMLExport, m_pVMLExport = NULL;
    1444           0 :     delete m_pAttrOutput, m_pAttrOutput = NULL;
    1445           0 :     delete m_pDrawingML, m_pDrawingML = NULL;
    1446           0 : }
    1447             : 
    1448           0 : DocxSettingsData::DocxSettingsData()
    1449             : : evenAndOddHeaders( false )
    1450             : , defaultTabStop( 0 )
    1451           0 : , trackRevisions( false )
    1452             : {
    1453           0 : }
    1454             : 
    1455           0 : bool DocxSettingsData::hasData() const
    1456             : {
    1457           0 :     if( evenAndOddHeaders )
    1458           0 :         return true;
    1459           0 :     if( defaultTabStop != 0 )
    1460           0 :         return true;
    1461           0 :     if ( trackRevisions )
    1462           0 :         return true;
    1463             : 
    1464           0 :     return false;
    1465           0 : }
    1466             : 
    1467             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10