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

Generated by: LCOV version 1.10