LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/filter/xml - xmlexp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 273 329 83.0 %
Date: 2013-07-09 Functions: 42 50 84.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             : 
      21             : #include <com/sun/star/text/XTextDocument.hpp>
      22             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/container/XNameContainer.hpp>
      25             : #include <com/sun/star/container/XIndexContainer.hpp>
      26             : #include <com/sun/star/document/IndexedPropertyValues.hpp>
      27             : #include <com/sun/star/uno/RuntimeException.hpp>
      28             : #include <com/sun/star/xforms/XFormsSupplier.hpp>
      29             : 
      30             : #include <sax/tools/converter.hxx>
      31             : #include <svx/svdmodel.hxx>
      32             : #include <svx/svdpage.hxx>
      33             : #include <svx/xmleohlp.hxx>
      34             : #include <svx/xmlgrhlp.hxx>
      35             : #include <editeng/eeitem.hxx>
      36             : #include <svx/svddef.hxx>
      37             : #include <xmloff/nmspmap.hxx>
      38             : #include <xmloff/xmlnmspe.hxx>
      39             : #include <editeng/xmlcnitm.hxx>
      40             : #include <xmloff/ProgressBarHelper.hxx>
      41             : #include <xmloff/xmluconv.hxx>
      42             : #include <xmloff/xformsexport.hxx>
      43             : #include <pam.hxx>
      44             : #include <doc.hxx>
      45             : #include <swmodule.hxx>
      46             : #include <docsh.hxx>
      47             : #include <viewsh.hxx>
      48             : #include <docstat.hxx>
      49             : #include <swerror.h>
      50             : #include <unotext.hxx>
      51             : #include <xmltexte.hxx>
      52             : #include <xmlexp.hxx>
      53             : #include <sfx2/viewsh.hxx>
      54             : #include <comphelper/processfactory.hxx>
      55             : #include <docary.hxx>
      56             : #include <editeng/unolingu.hxx>
      57             : #include <editeng/forbiddencharacterstable.hxx>
      58             : #include <comphelper/servicehelper.hxx>
      59             : 
      60             : // for locking SolarMutex: svapp + mutex
      61             : #include <vcl/svapp.hxx>
      62             : #include <osl/mutex.hxx>
      63             : 
      64             : #include <pausethreadstarting.hxx> // #i73788#
      65             : 
      66             : 
      67             : using namespace ::com::sun::star;
      68             : using namespace ::com::sun::star::frame;
      69             : using namespace ::com::sun::star::lang;
      70             : using namespace ::com::sun::star::xml::sax;
      71             : using namespace ::com::sun::star::uno;
      72             : using namespace ::com::sun::star::text;
      73             : using namespace ::com::sun::star::container;
      74             : using namespace ::com::sun::star::document;
      75             : using namespace ::com::sun::star::drawing;
      76             : using namespace ::com::sun::star::beans;
      77             : using namespace ::com::sun::star::i18n;
      78             : using namespace ::com::sun::star::xforms;
      79             : using namespace ::xmloff::token;
      80             : 
      81          68 : SwXMLExport::SwXMLExport(
      82             :     const uno::Reference< uno::XComponentContext > xContext,
      83             :     sal_uInt16 nExportFlags)
      84             : :   SvXMLExport( util::MeasureUnit::INCH, xContext, XML_TEXT,
      85             :         nExportFlags ),
      86             :     pTableItemMapper( 0 ),
      87             :     pTableLines( 0 ),
      88             :     bBlock( sal_False ),
      89             :     bShowProgress( sal_True ),
      90             :     doc( NULL ),
      91             :     sNumberFormat("NumberFormat"),
      92             :     sIsProtected("IsProtected"),
      93          68 :     sCell("Cell")
      94             : {
      95          68 :     _InitItemExport();
      96          68 : }
      97             : 
      98           2 : void SwXMLExport::setBlockMode()
      99             : {
     100           2 :     bBlock = sal_True;
     101             : 
     102           2 : }
     103             : 
     104          62 : sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
     105             : {
     106          62 :     if( !GetModel().is() )
     107           0 :         return ERR_SWG_WRITE_ERROR;
     108             : 
     109          62 :     SwPauseThreadStarting aPauseThreadStarting; // #i73788#
     110             : 
     111             :     // from here, we use core interfaces -> lock Solar-Mutex
     112         124 :     SolarMutexGuard aGuard;
     113             : 
     114             :     {
     115          62 :         Reference<XPropertySet> rInfoSet = getExportInfo();
     116          62 :         if( rInfoSet.is() )
     117             :         {
     118          62 :             OUString sAutoTextMode("AutoTextMode");
     119         124 :             if( rInfoSet->getPropertySetInfo()->hasPropertyByName(
     120          62 :                         sAutoTextMode ) )
     121             :             {
     122          62 :                 Any aAny = rInfoSet->getPropertyValue(sAutoTextMode);
     123          64 :                 if( aAny.getValueType() == ::getBooleanCppuType() &&
     124           2 :                     *static_cast<const sal_Bool*>(aAny.getValue()) )
     125           2 :                     setBlockMode();
     126          62 :             }
     127          62 :         }
     128             :     }
     129             : 
     130          62 :     SwDoc *pDoc = getDoc();
     131             : 
     132          62 :     sal_Bool bExtended = sal_False;
     133          62 :     if( (getExportFlags() & (EXPORT_FONTDECLS|EXPORT_STYLES|
     134             :                              EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 )
     135             :     {
     136          32 :         if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
     137             :         {
     138          32 :             _GetNamespaceMap().Add(
     139          32 :                 GetXMLToken(XML_NP_OFFICE_EXT),
     140          32 :                 GetXMLToken(XML_N_OFFICE_EXT),
     141          32 :                 XML_NAMESPACE_OFFICE_EXT);
     142             :         }
     143             : 
     144          32 :         GetTextParagraphExport()->SetBlockMode( bBlock );
     145             : 
     146             :         const SfxPoolItem* pItem;
     147          32 :         const SfxItemPool& rPool = pDoc->GetAttrPool();
     148             :         sal_uInt16 aWhichIds[5] = { RES_UNKNOWNATR_CONTAINER,
     149             :                                     RES_TXTATR_UNKNOWN_CONTAINER,
     150             :                                     SDRATTR_XMLATTRIBUTES,
     151             :                                     EE_PARA_XMLATTRIBS,
     152          32 :                                     EE_CHAR_XMLATTRIBS };
     153             : 
     154          32 :         sal_uInt16 nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
     155         192 :         for( sal_uInt16 j=0; j < nWhichIds; j++ )
     156             :         {
     157         160 :             sal_uInt16 nWhichId = aWhichIds[j];
     158         160 :             sal_uInt32 i=0, nItems = rPool.GetItemCount2( nWhichId );
     159         168 :             for( i = 0; i < nItems; ++i )
     160             :             {
     161           8 :                 if( 0 != (pItem = rPool.GetItem2( nWhichId , i ) ) )
     162             :                 {
     163             :                     const SvXMLAttrContainerItem *pUnknown =
     164           8 :                                 PTR_CAST( SvXMLAttrContainerItem, pItem );
     165             :                     OSL_ENSURE( pUnknown, "illegal attribute container item" );
     166           8 :                     if( pUnknown && (pUnknown->GetAttrCount() > 0) )
     167             :                     {
     168           0 :                         sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex();
     169           0 :                         while( USHRT_MAX != nIdx )
     170             :                         {
     171             :                             const OUString& rPrefix =
     172           0 :                                 pUnknown->GetPrefix( nIdx );
     173           0 :                             _GetNamespaceMap().Add( rPrefix,
     174           0 :                                                 pUnknown->GetNamespace( nIdx ),
     175           0 :                                                 XML_NAMESPACE_UNKNOWN );
     176           0 :                             nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
     177             :                         }
     178           0 :                         bExtended = sal_True;
     179             :                     }
     180             :                 }
     181             :             }
     182             :         }
     183             :     }
     184             : 
     185             :     sal_uInt16 const eUnit = SvXMLUnitConverter::GetMeasureUnit(
     186          62 :             SW_MOD()->GetMetric(pDoc->get(IDocumentSettingAccess::HTML_MODE)));
     187          62 :     if (GetMM100UnitConverter().GetXMLMeasureUnit() != eUnit )
     188             :     {
     189           0 :         GetMM100UnitConverter().SetXMLMeasureUnit( eUnit );
     190           0 :         pTwipUnitConv->SetXMLMeasureUnit( eUnit );
     191             :     }
     192             : 
     193          62 :     SetExtended( bExtended );
     194             : 
     195          62 :     if( (getExportFlags() & EXPORT_META) != 0 )
     196             :     {
     197             :         // Update doc stat, so that correct values are exported and
     198             :         // the progress works correctly.
     199          15 :         pDoc->UpdateDocStat();
     200             : 
     201          15 :         SfxObjectShell* pObjSh = pDoc->GetDocShell();
     202          15 :         if( pObjSh )
     203          15 :             pObjSh->UpdateDocInfoForSave();     // update information
     204             :     }
     205          62 :     if( bShowProgress )
     206             :     {
     207          62 :         ProgressBarHelper *pProgress = GetProgressBarHelper();
     208          62 :         if( -1 == pProgress->GetReference() )
     209             :         {
     210             :             // progress isn't initialized:
     211             :             // We assume that the whole doc is exported, and the following
     212             :             // durations:
     213             :             // - meta information: 2
     214             :             // - settings: 4 (TODO: not now!)
     215             :             // - styles (except page styles): 2
     216             :             // - page styles: 2 (TODO: not now!) + 2 for each paragraph
     217             :             // - paragraph: 2 (1 for automatic styles and one for content)
     218             : 
     219             :             // count each item once, and then multiply by two to reach the
     220             :             // figures given above
     221             :             // The styles in pDoc also count the default style that never
     222             :             // gets exported -> subtract one.
     223          16 :             sal_Int32 nRef = 1; // meta.xml
     224          16 :             nRef += pDoc->GetCharFmts()->size() - 1;
     225          16 :             nRef += pDoc->GetFrmFmts()->size() - 1;
     226          16 :             nRef += pDoc->GetTxtFmtColls()->size() - 1;
     227          16 :             nRef *= 2; // for the above styles, xmloff will increment by 2!
     228             :             // #i93174#: count all paragraphs for the progress bar
     229          16 :             nRef += pDoc->GetUpdatedDocStat().nAllPara; // 1: only content, no autostyle
     230          16 :             pProgress->SetReference( nRef );
     231          16 :             pProgress->SetValue( 0 );
     232             :         }
     233             :     }
     234             : 
     235          62 :     if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 )
     236             :     {
     237             :         //Auf die Korrektheit der OrdNums sind wir schon angewiesen.
     238          32 :         SdrModel* pModel = pDoc->GetDrawModel();
     239          32 :         if( pModel )
     240          32 :             pModel->GetPage( 0 )->RecalcObjOrdNums();
     241             :     }
     242             : 
     243             :     // adjust document class (eClass)
     244          62 :     if (pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT))
     245             :     {
     246           0 :         eClass = XML_TEXT_GLOBAL;
     247             : 
     248             :         // additionally, we take care of the save-linked-sections-thingy
     249           0 :         mbSaveLinkedSections = pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
     250             :     }
     251             :     // MIB: 03/26/04: The Label information is saved in the settings, so
     252             :     // we don't need it here.
     253             :     // else: keep default pClass that we received
     254             : 
     255          62 :     SvXMLGraphicHelper *pGraphicResolver = 0;
     256          62 :     if( !GetGraphicResolver().is() )
     257             :     {
     258          30 :         pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE );
     259          30 :         Reference< XGraphicObjectResolver > xGraphicResolver( pGraphicResolver );
     260          30 :         SetGraphicResolver( xGraphicResolver );
     261             :     }
     262             : 
     263          62 :     SvXMLEmbeddedObjectHelper *pEmbeddedResolver = 0;
     264          62 :     if( !GetEmbeddedResolver().is() )
     265             :     {
     266          30 :         SfxObjectShell *pPersist = pDoc->GetPersist();
     267          30 :         if( pPersist )
     268             :         {
     269             :             pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
     270             :                                             *pPersist,
     271          30 :                                             EMBEDDEDOBJECTHELPER_MODE_WRITE );
     272          30 :             Reference< XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
     273          30 :             SetEmbeddedResolver( xEmbeddedResolver );
     274             :         }
     275             :     }
     276             : 
     277             :     // set redline mode if we export STYLES or CONTENT, unless redline
     278             :     // mode is taken care of outside (through info XPropertySet)
     279             :     sal_Bool bSaveRedline =
     280          62 :         ( (getExportFlags() & (EXPORT_CONTENT|EXPORT_STYLES)) != 0 );
     281          62 :     if( bSaveRedline )
     282             :     {
     283             :         // if the info property set has a ShowChanges property,
     284             :         // then change tracking is taken care of on the outside,
     285             :         // so we don't have to!
     286          32 :         Reference<XPropertySet> rInfoSet = getExportInfo();
     287          32 :         if( rInfoSet.is() )
     288             :         {
     289          32 :             OUString sShowChanges("ShowChanges");
     290          64 :             bSaveRedline = ! rInfoSet->getPropertySetInfo()->hasPropertyByName(
     291          64 :                                                                 sShowChanges );
     292          32 :         }
     293             :     }
     294          62 :     sal_uInt16 nRedlineMode = 0;
     295          62 :     bSavedShowChanges = IDocumentRedlineAccess::IsShowChanges( pDoc->GetRedlineMode() );
     296          62 :     if( bSaveRedline )
     297             :     {
     298             :         // now save and switch redline mode
     299           0 :         nRedlineMode = pDoc->GetRedlineMode();
     300             :         pDoc->SetRedlineMode(
     301           0 :                  (RedlineMode_t)(( nRedlineMode & nsRedlineMode_t::REDLINE_SHOW_MASK ) | nsRedlineType_t::REDLINE_INSERT ));
     302             :     }
     303             : 
     304          62 :      sal_uInt32 nRet = SvXMLExport::exportDoc( eClass );
     305             : 
     306             :     // now we can restore the redline mode (if we changed it previously)
     307          62 :     if( bSaveRedline )
     308             :     {
     309           0 :       pDoc->SetRedlineMode( (RedlineMode_t)(nRedlineMode ));
     310             :     }
     311             : 
     312             : 
     313          62 :     if( pGraphicResolver )
     314          30 :         SvXMLGraphicHelper::Destroy( pGraphicResolver );
     315          62 :     if( pEmbeddedResolver )
     316          30 :         SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
     317             : 
     318             :     OSL_ENSURE( !pTableLines, "there are table columns infos left" );
     319             : 
     320         124 :     return nRet;
     321             : }
     322             : 
     323          32 : XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport()
     324             : {
     325          32 :     return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
     326             : }
     327             : 
     328          32 : XMLShapeExport* SwXMLExport::CreateShapeExport()
     329             : {
     330          32 :     XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) );
     331          32 :     Reference < XDrawPageSupplier > xDPS( GetModel(), UNO_QUERY );
     332          32 :     if( xDPS.is() )
     333             :     {
     334          32 :          Reference < XShapes > xShapes( xDPS->getDrawPage(), UNO_QUERY );
     335          32 :         pShapeExport->seekShapes( xShapes );
     336             :     }
     337             : 
     338          32 :     return pShapeExport;
     339             : }
     340             : 
     341         204 : SwXMLExport::~SwXMLExport()
     342             : {
     343          68 :     DeleteTableLines();
     344          68 :     _FinitItemExport();
     345         136 : }
     346             : 
     347             : 
     348          32 : void SwXMLExport::_ExportFontDecls()
     349             : {
     350          32 :     GetFontAutoStylePool(); // make sure the pool is created
     351          32 :     SvXMLExport::_ExportFontDecls();
     352          32 : }
     353             : 
     354             : #define NUM_EXPORTED_VIEW_SETTINGS 11
     355          15 : void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
     356             : {
     357          15 :     aProps.realloc( NUM_EXPORTED_VIEW_SETTINGS );
     358             :      // Currently exporting 9 properties
     359          15 :     PropertyValue *pValue = aProps.getArray();
     360          15 :     sal_Int32 nIndex = 0;
     361             : 
     362          15 :     Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() );
     363          15 :     pValue[nIndex].Name = OUString( "Views");
     364          15 :     pValue[nIndex++].Value <<= xBox;
     365             : 
     366          15 :     SwDoc *pDoc = getDoc();
     367             :     const Rectangle rRect =
     368          15 :         pDoc->GetDocShell()->GetVisArea( ASPECT_CONTENT );
     369          15 :     sal_Bool bTwip = pDoc->GetDocShell()->GetMapUnit ( ) == MAP_TWIP;
     370             : 
     371             :    OSL_ENSURE( bTwip, "Map unit for visible area is not in TWIPS!" );
     372             : 
     373          15 :     pValue[nIndex].Name = OUString( "ViewAreaTop");
     374          15 :     pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.Top() ) : rRect.Top();
     375             : 
     376          15 :     pValue[nIndex].Name = OUString( "ViewAreaLeft");
     377          15 :     pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.Left() ) : rRect.Left();
     378             : 
     379          15 :     pValue[nIndex].Name = OUString( "ViewAreaWidth");
     380          15 :     pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.GetWidth() ) : rRect.GetWidth();
     381             : 
     382          15 :     pValue[nIndex].Name = OUString( "ViewAreaHeight");
     383          15 :     pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.GetHeight() ) : rRect.GetHeight();
     384             : 
     385             :     // "show redline mode" cannot simply be read from the document
     386             :     // since it gets changed during execution. If it's in the info
     387             :     // XPropertySet, we take it from there.
     388          15 :     sal_Bool bShowRedlineChanges = bSavedShowChanges;
     389          30 :     Reference<XPropertySet> xInfoSet( getExportInfo() );
     390          15 :     if ( xInfoSet.is() )
     391             :     {
     392          15 :         OUString sShowChanges( "ShowChanges" );
     393          15 :         if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) )
     394             :         {
     395          15 :             bShowRedlineChanges = *(sal_Bool*) xInfoSet->
     396          15 :                                    getPropertyValue( sShowChanges ).getValue();
     397          15 :         }
     398             :     }
     399             : 
     400          15 :     pValue[nIndex].Name = OUString( "ShowRedlineChanges");
     401          15 :     pValue[nIndex++].Value.setValue( &bShowRedlineChanges, ::getBooleanCppuType() );
     402             : 
     403          15 :     sal_Bool bInBrowse =  pDoc->get(IDocumentSettingAccess::BROWSE_MODE);
     404          15 :     pValue[nIndex].Name = OUString( "InBrowseMode");
     405          15 :     pValue[nIndex++].Value.setValue( &bInBrowse, ::getBooleanCppuType() );
     406             : 
     407          15 :     if ( nIndex < NUM_EXPORTED_VIEW_SETTINGS )
     408          30 :         aProps.realloc(nIndex);
     409          15 : }
     410             : #undef NUM_EXPORTED_VIEW_SETTINGS
     411             : 
     412          15 : void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
     413             : {
     414          15 :     Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
     415          15 :     if( xFac.is() )
     416             :     {
     417          15 :         Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
     418          15 :         if( xProps.is() )
     419          15 :             SvXMLUnitConverter::convertPropertySet( rProps, xProps );
     420          15 :     }
     421          15 : }
     422             : 
     423          15 : sal_Int32 SwXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
     424             : {
     425             :     // the only doc-specific settings group we know so far are the XForms settings
     426          15 :     uno::Sequence<beans::PropertyValue> aXFormsSettings;
     427          30 :     Reference< XFormsSupplier > xXFormsSupp( GetModel(), UNO_QUERY );
     428          30 :     Reference< XNameAccess > xXForms;
     429          15 :     if ( xXFormsSupp.is() )
     430          15 :         xXForms = xXFormsSupp->getXForms().get();
     431          15 :     if ( xXForms.is() )
     432             :     {
     433           0 :         getXFormsSettings( xXForms, aXFormsSettings );
     434           0 :         _out_rSettings.push_back( SettingsGroup( XML_XFORM_MODEL_SETTINGS, aXFormsSettings ) );
     435             :     }
     436             : 
     437          30 :     return aXFormsSettings.getLength() + SvXMLExport::GetDocumentSpecificSettings( _out_rSettings );
     438             : }
     439             : 
     440          16 : void SwXMLExport::SetBodyAttributes()
     441             : {
     442             :     // export use of soft page breaks
     443          16 :     SwDoc *pDoc = getDoc();
     444          31 :     if( pDoc->GetCurrentViewShell() &&
     445          15 :         pDoc->GetCurrentViewShell()->GetPageCount() > 1 )
     446             :     {
     447           3 :         sal_Bool bValue = sal_True;
     448           3 :         OUStringBuffer sBuffer;
     449           3 :         ::sax::Converter::convertBool(sBuffer, bValue);
     450             :         AddAttribute(XML_NAMESPACE_TEXT, XML_USE_SOFT_PAGE_BREAKS,
     451           3 :             sBuffer.makeStringAndClear());
     452             :     }
     453          16 : }
     454             : 
     455             : 
     456          16 : void SwXMLExport::_ExportContent()
     457             : {
     458             :     // export forms
     459          16 :     Reference<XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY);
     460          16 :     if (xDrawPageSupplier.is())
     461             :     {
     462             :         // export only if we actually have elements
     463          16 :         Reference<XDrawPage> xPage = xDrawPageSupplier->getDrawPage();
     464          16 :         if (xPage.is())
     465             :         {
     466             :             // prevent export of form controls which are embedded in mute sections
     467             :             GetTextParagraphExport()->PreventExportOfControlsInMuteSections(
     468          16 :                 xPage, GetFormExport() );
     469             : 
     470             :             // #i36597#
     471          16 :             if ( GetFormExport()->pageContainsForms( xPage ) || GetFormExport()->documentContainsXForms() )
     472             :             {
     473           0 :                 ::xmloff::OOfficeFormsExport aOfficeForms(*this);
     474             : 
     475           0 :                 GetFormExport()->exportXForms();
     476             : 
     477           0 :                 GetFormExport()->seekPage(xPage);
     478           0 :                 GetFormExport()->exportForms(xPage);
     479             :             }
     480          16 :         }
     481             :     }
     482             : 
     483          32 :     Reference<XPropertySet> xPropSet(GetModel(), UNO_QUERY);
     484          16 :     if (xPropSet.is())
     485             :     {
     486          16 :         OUString sTwoDigitYear("TwoDigitYear");
     487             : 
     488          32 :         Any aAny = xPropSet->getPropertyValue( sTwoDigitYear );
     489          16 :         aAny <<= (sal_Int16)1930;
     490             : 
     491          16 :         sal_Int16 nYear = 0;
     492          16 :         aAny >>= nYear;
     493          16 :         if (nYear != 1930 )
     494             :         {
     495           0 :             OUStringBuffer sBuffer;
     496           0 :             ::sax::Converter::convertNumber(sBuffer, nYear);
     497           0 :             AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear());
     498           0 :             SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True);
     499          16 :         }
     500             :     }
     501             : 
     502          16 :     GetTextParagraphExport()->exportTrackedChanges( sal_False );
     503          16 :     GetTextParagraphExport()->exportTextDeclarations();
     504          32 :     Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
     505          32 :     Reference < XText > xText = xTextDoc->getText();
     506             : 
     507          16 :     GetTextParagraphExport()->exportFramesBoundToPage( bShowProgress );
     508          32 :     GetTextParagraphExport()->exportText( xText, bShowProgress );
     509          16 : }
     510             : 
     511             : 
     512             : 
     513             : //
     514             : // uno component registration
     515             : // helper functions for export service(s)
     516             : //
     517             : 
     518             : // OOo
     519          73 : OUString SAL_CALL SwXMLExportOOO_getImplementationName() throw()
     520             : {
     521             :     return OUString(
     522          73 :         "com.sun.star.comp.Writer.XMLExporter" );
     523             : }
     524             : 
     525           0 : Sequence< OUString > SAL_CALL SwXMLExportOOO_getSupportedServiceNames()
     526             :     throw()
     527             : {
     528           0 :     const OUString aServiceName(SwXMLExportOOO_getImplementationName());
     529           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     530           0 :     return aSeq;
     531             : }
     532             : 
     533           0 : Reference< XInterface > SAL_CALL SwXMLExportOOO_createInstance(
     534             :         const Reference< XMultiServiceFactory > & rSMgr)
     535             :     throw( Exception )
     536             : {
     537           0 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_ALL);
     538             : }
     539             : 
     540          79 : OUString SAL_CALL SwXMLExportStylesOOO_getImplementationName() throw()
     541             : {
     542             :     return OUString(
     543          79 :         "com.sun.star.comp.Writer.XMLStylesExporter" );
     544             : }
     545             : 
     546           3 : Sequence< OUString > SAL_CALL SwXMLExportStylesOOO_getSupportedServiceNames()
     547             :     throw()
     548             : {
     549           3 :     const OUString aServiceName(SwXMLExportStylesOOO_getImplementationName());
     550           3 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     551           3 :     return aSeq;
     552             : }
     553             : 
     554           4 : Reference< XInterface > SAL_CALL SwXMLExportStylesOOO_createInstance(
     555             :         const Reference< XMultiServiceFactory > & rSMgr)
     556             :     throw( Exception )
     557             : {
     558             :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr),
     559             :         EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
     560           4 :         EXPORT_FONTDECLS );
     561             : }
     562             : 
     563          76 : OUString SAL_CALL SwXMLExportContentOOO_getImplementationName() throw()
     564             : {
     565             :     return OUString(
     566          76 :         "com.sun.star.comp.Writer.XMLContentExporter" );
     567             : }
     568             : 
     569           3 : Sequence< OUString > SAL_CALL SwXMLExportContentOOO_getSupportedServiceNames()
     570             :     throw()
     571             : {
     572           3 :     const OUString aServiceName(SwXMLExportContentOOO_getImplementationName());
     573           3 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     574           3 :     return aSeq;
     575             : }
     576             : 
     577           4 : Reference< XInterface > SAL_CALL SwXMLExportContentOOO_createInstance(
     578             :         const Reference< XMultiServiceFactory > & rSMgr)
     579             :     throw( Exception )
     580             : {
     581             :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr),
     582             :         EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
     583           4 :         EXPORT_FONTDECLS );
     584             : }
     585             : 
     586          71 : OUString SAL_CALL SwXMLExportMetaOOO_getImplementationName() throw()
     587             : {
     588             :     return OUString(
     589          71 :         "com.sun.star.comp.Writer.XMLMetaExporter" );
     590             : }
     591             : 
     592           2 : Sequence< OUString > SAL_CALL SwXMLExportMetaOOO_getSupportedServiceNames()
     593             :     throw()
     594             : {
     595           2 :     const OUString aServiceName(SwXMLExportMetaOOO_getImplementationName());
     596           2 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     597           2 :     return aSeq;
     598             : }
     599             : 
     600           2 : Reference< XInterface > SAL_CALL SwXMLExportMetaOOO_createInstance(
     601             :         const Reference< XMultiServiceFactory > & rSMgr)
     602             :     throw( Exception )
     603             : {
     604           2 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_META);
     605             : }
     606             : 
     607          71 : OUString SAL_CALL SwXMLExportSettingsOOO_getImplementationName() throw()
     608             : {
     609             :     return OUString(
     610          71 :         "com.sun.star.comp.Writer.XMLSettingsExporter" );
     611             : }
     612             : 
     613           3 : Sequence< OUString > SAL_CALL SwXMLExportSettingsOOO_getSupportedServiceNames()
     614             :     throw()
     615             : {
     616           3 :     const OUString aServiceName(SwXMLExportSettingsOOO_getImplementationName());
     617           3 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     618           3 :     return aSeq;
     619             : }
     620             : 
     621           4 : Reference< XInterface > SAL_CALL SwXMLExportSettingsOOO_createInstance(
     622             :         const Reference< XMultiServiceFactory > & rSMgr)
     623             :     throw( Exception )
     624             : {
     625           4 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_SETTINGS);
     626             : }
     627             : 
     628             : // OASIS
     629          62 : OUString SAL_CALL SwXMLExport_getImplementationName() throw()
     630             : {
     631             :     return OUString(
     632          62 :         "com.sun.star.comp.Writer.XMLOasisExporter" );
     633             : }
     634             : 
     635           0 : Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames()
     636             :     throw()
     637             : {
     638           0 :     const OUString aServiceName(SwXMLExport_getImplementationName());
     639           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     640           0 :     return aSeq;
     641             : }
     642             : 
     643           0 : Reference< XInterface > SAL_CALL SwXMLExport_createInstance(
     644             :         const Reference< XMultiServiceFactory > & rSMgr)
     645             :     throw( Exception )
     646             : {
     647           0 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_ALL|EXPORT_OASIS);
     648             : }
     649             : 
     650          76 : OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw()
     651             : {
     652             :     return OUString(
     653          76 :         "com.sun.star.comp.Writer.XMLOasisStylesExporter" );
     654             : }
     655             : 
     656           7 : Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames()
     657             :     throw()
     658             : {
     659           7 :     const OUString aServiceName(SwXMLExportStyles_getImplementationName());
     660           7 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     661           7 :     return aSeq;
     662             : }
     663             : 
     664          14 : Reference< XInterface > SAL_CALL SwXMLExportStyles_createInstance(
     665             :         const Reference< XMultiServiceFactory > & rSMgr)
     666             :     throw( Exception )
     667             : {
     668             :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr),
     669             :         EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
     670          14 :         EXPORT_FONTDECLS|EXPORT_OASIS );
     671             : }
     672             : 
     673          69 : OUString SAL_CALL SwXMLExportContent_getImplementationName() throw()
     674             : {
     675             :     return OUString(
     676          69 :         "com.sun.star.comp.Writer.XMLOasisContentExporter" );
     677             : }
     678             : 
     679           7 : Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames()
     680             :     throw()
     681             : {
     682           7 :     const OUString aServiceName(SwXMLExportContent_getImplementationName());
     683           7 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     684           7 :     return aSeq;
     685             : }
     686             : 
     687          14 : Reference< XInterface > SAL_CALL SwXMLExportContent_createInstance(
     688             :         const Reference< XMultiServiceFactory > & rSMgr)
     689             :     throw( Exception )
     690             : {
     691             :     return (cppu::OWeakObject*)new SwXMLExport(
     692             :         comphelper::getComponentContext(rSMgr),
     693             :         EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
     694          14 :         EXPORT_FONTDECLS|EXPORT_OASIS );
     695             : }
     696             : 
     697          60 : OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw()
     698             : {
     699             :     return OUString(
     700          60 :         "com.sun.star.comp.Writer.XMLOasisMetaExporter" );
     701             : }
     702             : 
     703           6 : Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames()
     704             :     throw()
     705             : {
     706           6 :     const OUString aServiceName(SwXMLExportMeta_getImplementationName());
     707           6 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     708           6 :     return aSeq;
     709             : }
     710             : 
     711          13 : Reference< XInterface > SAL_CALL SwXMLExportMeta_createInstance(
     712             :         const Reference< XMultiServiceFactory > & rSMgr)
     713             :     throw( Exception )
     714             : {
     715          13 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_META|EXPORT_OASIS);
     716             : }
     717             : 
     718          54 : OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw()
     719             : {
     720             :     return OUString(
     721          54 :         "com.sun.star.comp.Writer.XMLOasisSettingsExporter" );
     722             : }
     723             : 
     724           6 : Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames()
     725             :     throw()
     726             : {
     727           6 :     const OUString aServiceName(SwXMLExportSettings_getImplementationName());
     728           6 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
     729           6 :     return aSeq;
     730             : }
     731             : 
     732          13 : Reference< XInterface > SAL_CALL SwXMLExportSettings_createInstance(
     733             :         const Reference< XMultiServiceFactory > & rSMgr)
     734             :     throw( Exception )
     735             : {
     736          13 :     return (cppu::OWeakObject*)new SwXMLExport( comphelper::getComponentContext(rSMgr), EXPORT_SETTINGS|EXPORT_OASIS);
     737             : }
     738             : 
     739             : namespace
     740             : {
     741             :     class theSwXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXMLExportUnoTunnelId > {};
     742             : }
     743             : 
     744           0 : const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw()
     745             : {
     746           0 :     return theSwXMLExportUnoTunnelId::get().getSeq();
     747             : }
     748             : 
     749           0 : sal_Int64 SAL_CALL SwXMLExport::getSomething( const Sequence< sal_Int8 >& rId )
     750             :     throw(RuntimeException)
     751             : {
     752           0 :     if( rId.getLength() == 16
     753           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
     754           0 :                                         rId.getConstArray(), 16 ) )
     755             :     {
     756           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
     757             :     }
     758           0 :     return SvXMLExport::getSomething( rId );
     759             : }
     760             : 
     761             : 
     762             : // XServiceInfo
     763             : // override empty method from parent class
     764           0 : OUString SAL_CALL SwXMLExport::getImplementationName()
     765             :     throw(RuntimeException)
     766             : {
     767           0 :     switch( getExportFlags() )
     768             :     {
     769             :         case EXPORT_ALL:
     770           0 :             return SwXMLExport_getImplementationName();
     771             :         case (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS):
     772           0 :             return SwXMLExportStyles_getImplementationName();
     773             :         case (EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS):
     774           0 :             return SwXMLExportContent_getImplementationName();
     775             :         case EXPORT_META:
     776           0 :             return SwXMLExportMeta_getImplementationName();
     777             :         case EXPORT_SETTINGS:
     778           0 :             return SwXMLExportSettings_getImplementationName();
     779             :         default:
     780             :             // generic name for 'unknown' cases
     781             :             return OUString(
     782           0 :                 "com.sun.star.comp.Writer.SwXMLExport" );
     783             :     }
     784             : }
     785             : 
     786         157 : SwDoc* SwXMLExport::getDoc()
     787             : {
     788         157 :     if( doc != NULL )
     789          95 :         return doc;
     790          62 :     Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
     791         124 :     Reference < XText > xText = xTextDoc->getText();
     792         124 :     Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
     793             :     assert( xTextTunnel.is());
     794             :     SwXText *pText = reinterpret_cast< SwXText *>(
     795          62 :             sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
     796             :     assert( pText != NULL );
     797          62 :     doc = pText->GetDoc();
     798             :     assert( doc != NULL );
     799         124 :     return doc;
     800             : }
     801             : 
     802           0 : const SwDoc* SwXMLExport::getDoc() const
     803             : {
     804           0 :     return const_cast< SwXMLExport* >( this )->getDoc();
     805          99 : }
     806             : 
     807             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10