LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - docxexportfilter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 35 40 87.5 %
Date: 2014-04-11 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "docxexportfilter.hxx"
      21             : #include "rtfexportfilter.hxx"
      22             : #include "docxexport.hxx"
      23             : 
      24             : #include <docsh.hxx>
      25             : #include <editsh.hxx>
      26             : #include <pam.hxx>
      27             : #include <unotxdoc.hxx>
      28             : 
      29             : #include <cppuhelper/implementationentry.hxx>
      30             : 
      31             : using namespace ::comphelper;
      32             : using namespace ::com::sun::star;
      33             : 
      34         272 : DocxExportFilter::DocxExportFilter( const uno::Reference< uno::XComponentContext >& xContext )
      35         272 :     : oox::core::XmlFilterBase( xContext )
      36             : {
      37         272 : }
      38             : 
      39         272 : bool DocxExportFilter::exportDocument()
      40             : {
      41             :     OSL_TRACE( "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me
      42             : 
      43             :     // get SwDoc*
      44         272 :     uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY );
      45         272 :     SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
      46         272 :     if ( !pTxtDoc )
      47           0 :         return false;
      48             : 
      49         272 :     SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
      50         272 :     if ( !pDoc )
      51           0 :         return false;
      52             : 
      53             :     // update layout (if present), for SwWriteTable
      54         272 :     SwViewShell* pViewShell = NULL;
      55         272 :     pDoc->GetEditShell(&pViewShell);
      56         272 :     if (pViewShell != NULL)
      57         272 :         pViewShell->CalcLayout();
      58             : 
      59             :     // get SwPaM*
      60             :     // FIXME so far we get SwPaM for the entire document; probably we should
      61             :     // be able to output just the selection as well - though no idea how to
      62             :     // get the correct SwPaM* then...
      63         544 :     SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
      64         272 :     aPam.SetMark();
      65         272 :     aPam.Move( fnMoveBackward, fnGoDoc );
      66             : 
      67         272 :     SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
      68             : 
      69             :     // export the document
      70             :     // (in a separate block so that it's destructed before the commit)
      71             :     {
      72         272 :         DocxExport aExport( this, pDoc, pCurPam, &aPam );
      73         272 :         aExport.ExportDocument( true ); // FIXME support exporting selection only
      74             :     }
      75             : 
      76         272 :     commitStorage();
      77             : 
      78             :     // delete the pCurPam
      79         272 :     if ( pCurPam )
      80             :     {
      81         544 :         while ( pCurPam->GetNext() != pCurPam )
      82           0 :             delete pCurPam->GetNext();
      83         272 :         delete pCurPam;
      84             :     }
      85             : 
      86         544 :     return true;
      87             : }
      88             : 
      89             : // UNO stuff so that the filter is registered
      90             : #define IMPL_NAME "com.sun.star.comp.Writer.DocxExport"
      91             : 
      92           6 : OUString DocxExport_getImplementationName()
      93             : {
      94           6 :     return OUString( IMPL_NAME );
      95             : }
      96             : 
      97           0 : OUString DocxExportFilter::implGetImplementationName() const
      98             : {
      99           0 :     return DocxExport_getImplementationName();
     100             : }
     101             : 
     102           4 : uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw()
     103             : {
     104           4 :     const OUString aServiceName( "com.sun.star.document.ExportFilter" );
     105           4 :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
     106           4 :     return aSeq;
     107             : }
     108             : 
     109         272 : uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< uno::XComponentContext > & xCtx ) throw( uno::Exception )
     110             : {
     111         272 :     return (cppu::OWeakObject*) new DocxExportFilter( xCtx );
     112             : }
     113             : 
     114             : extern "C"
     115             : {
     116             : 
     117             : ::cppu::ImplementationEntry entries [] =
     118             : {
     119             :     {
     120             :         DocxExport_createInstance, DocxExport_getImplementationName,
     121             :         DocxExport_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     122             :         0, 0
     123             :     },
     124             :     {
     125             :         RtfExport_createInstance, RtfExport_getImplementationName,
     126             :         RtfExport_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     127             :         0, 0
     128             :     },
     129             :     { 0, 0, 0, 0, 0, 0 }
     130             : };
     131             : 
     132           6 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL msword_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
     133             : {
     134           6 :     return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, entries );
     135             : }
     136             : 
     137          33 : } // extern "C"
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10