LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - docxexportfilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 40 87.5 %
Date: 2012-08-25 Functions: 8 9 88.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 64 46.9 %

           Branch data     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 "docxexportfilter.hxx"
      21                 :            : #include "rtfexportfilter.hxx"
      22                 :            : #include "rtfimportfilter.hxx"
      23                 :            : #include "docxexport.hxx"
      24                 :            : 
      25                 :            : #include <docsh.hxx>
      26                 :            : #include <editsh.hxx>
      27                 :            : #include <pam.hxx>
      28                 :            : #include <unotxdoc.hxx>
      29                 :            : 
      30                 :            : #include <cppuhelper/implementationentry.hxx>
      31                 :            : 
      32                 :            : using namespace ::comphelper;
      33                 :            : using namespace ::com::sun::star;
      34                 :            : 
      35                 :         57 : DocxExportFilter::DocxExportFilter( const uno::Reference< uno::XComponentContext >& xContext )
      36                 :         57 :     : oox::core::XmlFilterBase( xContext )
      37                 :            : {
      38                 :         57 : }
      39                 :            : 
      40                 :         57 : bool DocxExportFilter::exportDocument()
      41                 :            : {
      42                 :            :     OSL_TRACE( "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me
      43                 :            : 
      44                 :            :     // get SwDoc*
      45 [ +  - ][ +  - ]:         57 :     uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY );
      46 [ +  - ][ -  + ]:         57 :     SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
      47         [ -  + ]:         57 :     if ( !pTxtDoc )
      48                 :          0 :         return false;
      49                 :            : 
      50                 :         57 :     SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
      51         [ -  + ]:         57 :     if ( !pDoc )
      52                 :          0 :         return false;
      53                 :            : 
      54                 :            :     // update layout (if present), for SwWriteTable
      55                 :         57 :     ViewShell* pViewShell = NULL;
      56         [ +  - ]:         57 :     pDoc->GetEditShell(&pViewShell);
      57         [ +  - ]:         57 :     if (pViewShell != NULL)
      58         [ +  - ]:         57 :         pViewShell->CalcLayout();
      59                 :            : 
      60                 :            :     // get SwPaM*
      61                 :            :     // FIXME so far we get SwPaM for the entire document; probably we should
      62                 :            :     // be able to output just the selection as well - though no idea how to
      63                 :            :     // get the correct SwPaM* then...
      64 [ +  - ][ +  - ]:         57 :     SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
      65         [ +  - ]:         57 :     aPam.SetMark();
      66         [ +  - ]:         57 :     aPam.Move( fnMoveBackward, fnGoDoc );
      67                 :            : 
      68 [ +  - ][ +  - ]:         57 :     SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
         [ +  - ][ +  - ]
      69                 :            : 
      70                 :            :     // export the document
      71                 :            :     // (in a separate block so that it's destructed before the commit)
      72                 :            :     {
      73         [ +  - ]:         57 :         DocxExport aExport( this, pDoc, pCurPam, &aPam );
      74 [ +  - ][ +  - ]:         57 :         aExport.ExportDocument( true ); // FIXME support exporting selection only
      75                 :            :     }
      76                 :            : 
      77         [ +  - ]:         57 :     commitStorage();
      78                 :            : 
      79                 :            :     // delete the pCurPam
      80         [ +  - ]:         57 :     if ( pCurPam )
      81                 :            :     {
      82         [ -  + ]:         57 :         while ( pCurPam->GetNext() != pCurPam )
      83 [ #  # ][ #  # ]:          0 :             delete pCurPam->GetNext();
      84 [ +  - ][ +  - ]:         57 :         delete pCurPam;
      85                 :            :     }
      86                 :            : 
      87         [ +  - ]:         57 :     return true;
      88                 :            : }
      89                 :            : 
      90                 :            : //////////////////////////////////////////////////////////////////////////
      91                 :            : // UNO stuff so that the filter is registered
      92                 :            : //////////////////////////////////////////////////////////////////////////
      93                 :            : 
      94                 :            : #define IMPL_NAME "com.sun.star.comp.Writer.DocxExport"
      95                 :            : 
      96                 :          6 : OUString DocxExport_getImplementationName()
      97                 :            : {
      98                 :          6 :     return OUString( IMPL_NAME );
      99                 :            : }
     100                 :            : 
     101                 :          0 : OUString DocxExportFilter::implGetImplementationName() const
     102                 :            : {
     103                 :          0 :     return DocxExport_getImplementationName();
     104                 :            : }
     105                 :            : 
     106                 :          3 : uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw()
     107                 :            : {
     108                 :          3 :     const OUString aServiceName( "com.sun.star.document.ExportFilter" );
     109         [ +  - ]:          3 :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
     110                 :          3 :     return aSeq;
     111                 :            : }
     112                 :            : 
     113                 :         57 : uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< uno::XComponentContext > & xCtx ) throw( uno::Exception )
     114                 :            : {
     115         [ +  - ]:         57 :     return (cppu::OWeakObject*) new DocxExportFilter( xCtx );
     116                 :            : }
     117                 :            : 
     118                 :            : extern "C"
     119                 :            : {
     120                 :            : 
     121                 :            : ::cppu::ImplementationEntry entries [] =
     122                 :            : {
     123                 :            :     {
     124                 :            :         DocxExport_createInstance, DocxExport_getImplementationName,
     125                 :            :         DocxExport_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     126                 :            :         0, 0
     127                 :            :     },
     128                 :            :     {
     129                 :            :         RtfExport_createInstance, RtfExport_getImplementationName,
     130                 :            :         RtfExport_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     131                 :            :         0, 0
     132                 :            :     },
     133                 :            :     {
     134                 :            :         RtfImport_createInstance, RtfImport_getImplementationName,
     135                 :            :         RtfImport_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     136                 :            :         0, 0
     137                 :            :     },
     138                 :            :     { 0, 0, 0, 0, 0, 0 }
     139                 :            : };
     140                 :            : 
     141                 :          6 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL msword_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
     142                 :            : {
     143                 :          6 :     return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, entries );
     144                 :            : }
     145                 :            : 
     146 [ +  - ][ +  - ]:         54 : } // extern "C"
     147                 :            : 
     148                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10