LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - docxexportfilter.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 39 87.2 %
Date: 2014-11-03 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             : #include <IDocumentLayoutAccess.hxx>
      29             : 
      30             : #include <cppuhelper/implementationentry.hxx>
      31             : 
      32             : using namespace ::comphelper;
      33             : using namespace ::com::sun::star;
      34             : 
      35         860 : DocxExportFilter::DocxExportFilter( const uno::Reference< uno::XComponentContext >& xContext )
      36         860 :     : oox::core::XmlFilterBase( xContext )
      37             : {
      38         860 : }
      39             : 
      40         860 : bool DocxExportFilter::exportDocument()
      41             : {
      42             :     OSL_TRACE( "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me
      43             : 
      44             :     // get SwDoc*
      45         860 :     uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY );
      46         860 :     SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
      47         860 :     if ( !pTxtDoc )
      48           0 :         return false;
      49             : 
      50         860 :     SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
      51         860 :     if ( !pDoc )
      52           0 :         return false;
      53             : 
      54             :     // update layout (if present), for SwWriteTable
      55         860 :     SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
      56         860 :     if (pViewShell != NULL)
      57         848 :         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        1720 :     SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
      64         860 :     aPam.SetMark();
      65         860 :     aPam.Move( fnMoveBackward, fnGoDoc );
      66             : 
      67         860 :     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         860 :         DocxExport aExport( this, pDoc, pCurPam, &aPam );
      73         860 :         aExport.ExportDocument( true ); // FIXME support exporting selection only
      74             :     }
      75             : 
      76         860 :     commitStorage();
      77             : 
      78             :     // delete the pCurPam
      79         860 :     if ( pCurPam )
      80             :     {
      81        1720 :         while ( pCurPam->GetNext() != pCurPam )
      82           0 :             delete pCurPam->GetNext();
      83         860 :         delete pCurPam;
      84             :     }
      85             : 
      86        1720 :     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          24 : OUString DocxExport_getImplementationName()
      93             : {
      94          24 :     return OUString( IMPL_NAME );
      95             : }
      96             : 
      97           0 : OUString DocxExportFilter::implGetImplementationName() const
      98             : {
      99           0 :     return DocxExport_getImplementationName();
     100             : }
     101             : 
     102          20 : uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw()
     103             : {
     104          20 :     const OUString aServiceName( "com.sun.star.document.ExportFilter" );
     105          20 :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
     106          20 :     return aSeq;
     107             : }
     108             : 
     109         860 : uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< uno::XComponentContext > & xCtx ) throw( uno::Exception )
     110             : {
     111         860 :     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          24 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL msword_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
     133             : {
     134          24 :     return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, entries );
     135             : }
     136             : 
     137         102 : } // extern "C"
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10