LCOV - code coverage report
Current view: top level - writerperfect/source/calc - MWAWCalcImportFilter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 52 78.8 %
Date: 2015-06-13 12:38:46 Functions: 8 11 72.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* MWAWCalcImportFilter: Sets up the filter, and calls DocumentCollector
       3             :  * to do the actual filtering
       4             :  *
       5             :  * This file is part of the LibreOffice project.
       6             :  *
       7             :  * This Source Code Form is subject to the terms of the Mozilla Public
       8             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       9             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      10             :  */
      11             : 
      12             : #include <com/sun/star/uno/Reference.h>
      13             : #include <cppuhelper/supportsservice.hxx>
      14             : 
      15             : #include <libmwaw/libmwaw.hxx>
      16             : #include <libodfgen/libodfgen.hxx>
      17             : 
      18             : #include "MWAWCalcImportFilter.hxx"
      19             : 
      20             : using com::sun::star::uno::Sequence;
      21             : using com::sun::star::uno::Reference;
      22             : using com::sun::star::uno::Any;
      23             : using com::sun::star::uno::XInterface;
      24             : using com::sun::star::uno::Exception;
      25             : using com::sun::star::uno::RuntimeException;
      26             : using com::sun::star::uno::XComponentContext;
      27             : 
      28           0 : static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler,  const OdfStreamType streamType)
      29             : {
      30           0 :     OdgGenerator exporter;
      31           0 :     exporter.addDocumentHandler(pHandler, streamType);
      32           0 :     return MWAWDocument::decodeGraphic(data, &exporter);
      33             : }
      34             : 
      35           0 : static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler,  const OdfStreamType streamType)
      36             : {
      37           0 :     OdsGenerator exporter;
      38           0 :     exporter.addDocumentHandler(pHandler, streamType);
      39           0 :     return MWAWDocument::decodeSpreadsheet(data, &exporter);
      40             : }
      41             : 
      42          24 : bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &)
      43             : {
      44          24 :     return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator);
      45             : }
      46             : 
      47         546 : bool MWAWCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
      48             : {
      49         546 :     rTypeName.clear();
      50             : 
      51         546 :     MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN;
      52         546 :     MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN;
      53         546 :     const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind);
      54             : 
      55         546 :     if (confidence == MWAWDocument::MWAW_C_EXCELLENT)
      56             :     {
      57          24 :         if (docKind == MWAWDocument::MWAW_K_SPREADSHEET || docKind == MWAWDocument::MWAW_K_DATABASE)
      58             :         {
      59          24 :             switch (docType)
      60             :             {
      61             :             case MWAWDocument::MWAW_T_BEAGLEWORKS:
      62           4 :                 rTypeName = "calc_Beagle_Works";
      63           4 :                 break;
      64             :             case MWAWDocument::MWAW_T_CLARISRESOLVE:
      65           1 :                 rTypeName = "calc_Claris_Resolve";
      66           1 :                 break;
      67             :             case MWAWDocument::MWAW_T_CLARISWORKS:
      68           8 :                 rTypeName = "calc_ClarisWorks";
      69           8 :                 break;
      70             :             case MWAWDocument::MWAW_T_GREATWORKS:
      71           4 :                 rTypeName = "calc_Great_Works";
      72           4 :                 break;
      73             :             case MWAWDocument::MWAW_T_MICROSOFTWORKS:
      74           6 :                 rTypeName = "calc_Mac_Works";
      75           6 :                 break;
      76             :             case MWAWDocument::MWAW_T_WINGZ:
      77           1 :                 rTypeName = "calc_Mac_Wingz";
      78           1 :                 break;
      79             : 
      80             :             case MWAWDocument::MWAW_T_ACTA:
      81             :             case MWAWDocument::MWAW_T_ADOBEILLUSTRATOR:
      82             :             case MWAWDocument::MWAW_T_DBASE:
      83             :             case MWAWDocument::MWAW_T_DOCMAKER:
      84             :             case MWAWDocument::MWAW_T_EDOC:
      85             :             case MWAWDocument::MWAW_T_FAMILYTREEMAKER:
      86             :             case MWAWDocument::MWAW_T_FILEMAKER:
      87             :             case MWAWDocument::MWAW_T_FOXBASE:
      88             :             case MWAWDocument::MWAW_T_FRAMEMAKER:
      89             :             case MWAWDocument::MWAW_T_FULLIMPACT:
      90             :             case MWAWDocument::MWAW_T_FULLPAINT:
      91             :             case MWAWDocument::MWAW_T_FULLWRITE:
      92             :             case MWAWDocument::MWAW_T_INFOGENIE:
      93             :             case MWAWDocument::MWAW_T_KALEIDAGRAPH:
      94             :             case MWAWDocument::MWAW_T_HANMACWORDJ:
      95             :             case MWAWDocument::MWAW_T_HANMACWORDK:
      96             :             case MWAWDocument::MWAW_T_LIGHTWAYTEXT:
      97             :             case MWAWDocument::MWAW_T_MACDOC:
      98             :             case MWAWDocument::MWAW_T_MACDRAFT:
      99             :             case MWAWDocument::MWAW_T_MACDRAW:
     100             :             case MWAWDocument::MWAW_T_MACDRAWPRO:
     101             :             case MWAWDocument::MWAW_T_MACPAINT:
     102             :             case MWAWDocument::MWAW_T_MACWRITE:
     103             :             case MWAWDocument::MWAW_T_MACWRITEPRO:
     104             :             case MWAWDocument::MWAW_T_MARINERWRITE:
     105             :             case MWAWDocument::MWAW_T_MINDWRITE:
     106             :             case MWAWDocument::MWAW_T_MICROSOFTFILE:
     107             :             case MWAWDocument::MWAW_T_MICROSOFTMULTIPLAN:
     108             :             case MWAWDocument::MWAW_T_MICROSOFTWORD:
     109             :             case MWAWDocument::MWAW_T_MORE:
     110             :             case MWAWDocument::MWAW_T_NISUSWRITER:
     111             :             case MWAWDocument::MWAW_T_OVERVUE:
     112             :             case MWAWDocument::MWAW_T_PAGEMAKER:
     113             :             case MWAWDocument::MWAW_T_PIXELPAINT:
     114             :             case MWAWDocument::MWAW_T_RAGTIME:
     115             :             case MWAWDocument::MWAW_T_READYSETGO:
     116             :             case MWAWDocument::MWAW_T_SUPERPAINT:
     117             :             case MWAWDocument::MWAW_T_SYMPOSIUM:
     118             :             case MWAWDocument::MWAW_T_TEACHTEXT:
     119             :             case MWAWDocument::MWAW_T_TEXEDIT:
     120             :             case MWAWDocument::MWAW_T_TRAPEZE:
     121             :             case MWAWDocument::MWAW_T_WRITENOW:
     122             :             case MWAWDocument::MWAW_T_WRITERPLUS:
     123             :             case MWAWDocument::MWAW_T_XPRESS:
     124             :             case MWAWDocument::MWAW_T_ZWRITE:
     125             :             case MWAWDocument::MWAW_T_4DIMENSION:
     126             : 
     127             :             case MWAWDocument::MWAW_T_RESERVED1:
     128             :             case MWAWDocument::MWAW_T_RESERVED2:
     129             :             case MWAWDocument::MWAW_T_RESERVED3:
     130             :             case MWAWDocument::MWAW_T_RESERVED4:
     131             :             case MWAWDocument::MWAW_T_RESERVED5:
     132             :             case MWAWDocument::MWAW_T_RESERVED6:
     133             :             case MWAWDocument::MWAW_T_RESERVED7:
     134             :             case MWAWDocument::MWAW_T_RESERVED8:
     135             :             case MWAWDocument::MWAW_T_RESERVED9:
     136             :             case MWAWDocument::MWAW_T_UNKNOWN:
     137             :             default:
     138           0 :                 break;
     139             :             }
     140             :         }
     141             :     }
     142             : 
     143         546 :     return !rTypeName.isEmpty();
     144             : }
     145             : 
     146          24 : void MWAWCalcImportFilter::doRegisterHandlers(OdsGenerator &rGenerator)
     147             : {
     148          24 :     rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
     149          24 :     rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject);
     150          24 : }
     151             : 
     152          19 : OUString MWAWCalcImportFilter_getImplementationName()
     153             : throw (RuntimeException)
     154             : {
     155          19 :     return OUString("com.sun.star.comp.Calc.MWAWCalcImportFilter");
     156             : }
     157             : 
     158           7 : Sequence< OUString > SAL_CALL MWAWCalcImportFilter_getSupportedServiceNames()
     159             : throw (RuntimeException)
     160             : {
     161           7 :     Sequence < OUString > aRet(2);
     162           7 :     OUString *pArray = aRet.getArray();
     163           7 :     pArray[0] =  "com.sun.star.document.ImportFilter";
     164           7 :     pArray[1] =  "com.sun.star.document.ExtendedTypeDetection";
     165           7 :     return aRet;
     166             : }
     167             : 
     168         524 : Reference< XInterface > SAL_CALL MWAWCalcImportFilter_createInstance(const Reference< XComponentContext > &rContext)
     169             : throw(Exception)
     170             : {
     171         524 :     return static_cast<cppu::OWeakObject *>(new MWAWCalcImportFilter(rContext));
     172             : }
     173             : 
     174             : // XServiceInfo
     175           1 : OUString SAL_CALL MWAWCalcImportFilter::getImplementationName()
     176             : throw (RuntimeException, std::exception)
     177             : {
     178           1 :     return MWAWCalcImportFilter_getImplementationName();
     179             : }
     180           0 : sal_Bool SAL_CALL MWAWCalcImportFilter::supportsService(const OUString &rServiceName)
     181             : throw (RuntimeException, std::exception)
     182             : {
     183           0 :     return cppu::supportsService(this, rServiceName);
     184             : }
     185           1 : Sequence< OUString > SAL_CALL MWAWCalcImportFilter::getSupportedServiceNames()
     186             : throw (RuntimeException, std::exception)
     187             : {
     188           1 :     return MWAWCalcImportFilter_getSupportedServiceNames();
     189             : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11