tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / writerperfect / source / writer / EBookImportFilter.cxx
bloba4f5cdeebeb0d86e856f70ff0aaf9fbd249f3624
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 <cppuhelper/supportsservice.hxx>
13 #include <sal/log.hxx>
15 #include <libe-book/libe-book.h>
17 #include "EBookImportFilter.hxx"
19 using libebook::EBOOKDocument;
21 bool EBookImportFilter::doImportDocument(weld::Window*, librevenge::RVNGInputStream& rInput,
22 OdtGenerator& rGenerator,
23 utl::MediaDescriptor& rDescriptor)
25 OUString aFilterName;
27 rDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName;
28 assert(!aFilterName.isEmpty());
30 if (aFilterName == "Palm_Text_Document")
32 return EBOOKDocument::RESULT_OK == EBOOKDocument::parse(&rInput, &rGenerator);
34 else
36 EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;
38 if (aFilterName == "BroadBand eBook")
39 type = EBOOKDocument::TYPE_BBEB;
40 else 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;
47 if (EBOOKDocument::TYPE_UNKNOWN != type)
48 return EBOOKDocument::RESULT_OK == EBOOKDocument::parse(&rInput, &rGenerator, type);
51 return false;
54 bool EBookImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName)
56 rTypeName.clear();
58 EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;
60 if (EBOOKDocument::CONFIDENCE_EXCELLENT == EBOOKDocument::isSupported(&rInput, &type))
62 switch (type)
64 case EBOOKDocument::TYPE_BBEB:
65 rTypeName = "writer_BroadBand_eBook";
66 break;
67 case EBOOKDocument::TYPE_FICTIONBOOK2:
68 rTypeName = "writer_FictionBook_2";
69 break;
70 case EBOOKDocument::TYPE_PALMDOC:
71 rTypeName = "writer_PalmDoc";
72 break;
73 case EBOOKDocument::TYPE_PLUCKER:
74 rTypeName = "writer_Plucker_eBook";
75 break;
76 case EBOOKDocument::TYPE_PEANUTPRESS:
77 case EBOOKDocument::TYPE_TEALDOC:
78 case EBOOKDocument::TYPE_ZTXT:
79 rTypeName = "Palm_Text_Document";
80 break;
81 default:
82 SAL_WARN_IF(type != EBOOKDocument::TYPE_UNKNOWN, "writerperfect",
83 "EBookImportFilter::doDetectFormat: document type "
84 << type << " detected, but ignored");
88 return !rTypeName.isEmpty();
91 // XServiceInfo
92 OUString SAL_CALL EBookImportFilter::getImplementationName()
94 return u"org.libreoffice.comp.Writer.EBookImportFilter"_ustr;
97 sal_Bool SAL_CALL EBookImportFilter::supportsService(const OUString& rServiceName)
99 return cppu::supportsService(this, rServiceName);
102 css::uno::Sequence<OUString> SAL_CALL EBookImportFilter::getSupportedServiceNames()
104 return { u"com.sun.star.document.ImportFilter"_ustr,
105 u"com.sun.star.document.ExtendedTypeDetection"_ustr };
108 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
109 org_libreoffice_comp_Writer_EBookImportFilter_get_implementation(
110 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
112 return cppu::acquire(new EBookImportFilter(context));
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */