fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / writerperfect / source / writer / EBookImportFilter.cxx
bloba7db6c243cdc37af44fd0c44b74e73d01d995221
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* EBookImportFilter: Sets up the filter, and calls DocumentCollector
3 * to do the actual filtering
5 * This file is part of the LibreOffice project.
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/.
12 #include <com/sun/star/uno/Reference.h>
13 #include <cppuhelper/supportsservice.hxx>
15 #include <libe-book/libe-book.h>
17 #include "EBookImportFilter.hxx"
19 using com::sun::star::uno::Sequence;
20 using com::sun::star::uno::Reference;
21 using com::sun::star::uno::Any;
22 using com::sun::star::uno::XInterface;
23 using com::sun::star::uno::Exception;
24 using com::sun::star::uno::RuntimeException;
25 using com::sun::star::uno::XComponentContext;
27 using libebook::EBOOKDocument;
29 bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &rDescriptor)
31 EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;
33 rtl::OUString aFilterName;
35 rDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] >>= aFilterName;
36 assert(!aFilterName.isEmpty());
38 if (aFilterName == "BroadBand eBook")
39 type = EBOOKDocument::TYPE_BBEB;
40 if (aFilterName == "FictionBook 2")
41 type = EBOOKDocument::TYPE_FICTIONBOOK2;
42 else if (aFilterName == "PalmDoc")
43 type = EBOOKDocument::TYPE_PALMDOC;
44 else if (aFilterName == "Plucker eBook")
45 type = EBOOKDocument::TYPE_PLUCKER;
46 else if (aFilterName == "eReader eBook")
47 type = EBOOKDocument::TYPE_PEANUTPRESS;
48 else if (aFilterName == "TealDoc")
49 type = EBOOKDocument::TYPE_TEALDOC;
50 else if (aFilterName == "zTXT")
51 type = EBOOKDocument::TYPE_ZTXT;
53 if (EBOOKDocument::TYPE_UNKNOWN != type)
54 return EBOOKDocument::RESULT_OK == EBOOKDocument::parse(&rInput, &rGenerator, type);
56 return false;
59 bool EBookImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
61 rTypeName.clear();
63 EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;
65 if (EBOOKDocument::CONFIDENCE_EXCELLENT == EBOOKDocument::isSupported(&rInput, &type))
67 switch (type)
69 case EBOOKDocument::TYPE_BBEB :
70 rTypeName = "writer_BroadBand_eBook";
71 break;
72 case EBOOKDocument::TYPE_FICTIONBOOK2 :
73 rTypeName = "writer_FictionBook_2";
74 break;
75 case EBOOKDocument::TYPE_PALMDOC :
76 rTypeName = "writer_PalmDoc";
77 break;
78 case EBOOKDocument::TYPE_PLUCKER :
79 rTypeName = "writer_Plucker_eBook";
80 break;
81 case EBOOKDocument::TYPE_PEANUTPRESS :
82 rTypeName = "writer_eReader_eBook";
83 break;
84 case EBOOKDocument::TYPE_TEALDOC :
85 rTypeName = "writer_TealDoc";
86 break;
87 case EBOOKDocument::TYPE_ZTXT :
88 rTypeName = "writer_zTXT";
89 break;
90 default :
91 SAL_WARN_IF(type != EBOOKDocument::TYPE_UNKNOWN, "writerperfect", "EBookImportFilter::doDetectFormat: document type " << type << " detected, but ignored");
95 return !rTypeName.isEmpty();
98 OUString EBookImportFilter_getImplementationName()
99 throw (RuntimeException)
101 return OUString("org.libreoffice.comp.Writer.EBookImportFilter");
104 Sequence< OUString > SAL_CALL EBookImportFilter_getSupportedServiceNames()
105 throw (RuntimeException)
107 Sequence < OUString > aRet(2);
108 OUString *pArray = aRet.getArray();
109 pArray[0] = "com.sun.star.document.ImportFilter";
110 pArray[1] = "com.sun.star.document.ExtendedTypeDetection";
111 return aRet;
113 #undef SERVICE_NAME2
114 #undef SERVICE_NAME1
116 Reference< XInterface > SAL_CALL EBookImportFilter_createInstance(const Reference< XComponentContext > &rContext)
117 throw(Exception)
119 return (cppu::OWeakObject *) new EBookImportFilter(rContext);
122 // XServiceInfo
123 OUString SAL_CALL EBookImportFilter::getImplementationName()
124 throw (RuntimeException, std::exception)
126 return EBookImportFilter_getImplementationName();
128 sal_Bool SAL_CALL EBookImportFilter::supportsService(const OUString &rServiceName)
129 throw (RuntimeException, std::exception)
131 return cppu::supportsService(this, rServiceName);
133 Sequence< OUString > SAL_CALL EBookImportFilter::getSupportedServiceNames()
134 throw (RuntimeException, std::exception)
136 return EBookImportFilter_getSupportedServiceNames();
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */