LibreOffice Module writerperfect (master) 1
MWAWPresentationImportFilter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* MWAWPresentationImportFilter: 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
13
14#include <libmwaw/libmwaw.hxx>
15
17
18static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData& data,
19 OdfDocumentHandler* pHandler,
20 const OdfStreamType streamType)
21{
22 OdgGenerator exporter;
23 exporter.addDocumentHandler(pHandler, streamType);
24 return MWAWDocument::decodeGraphic(data, &exporter);
25}
26
27static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData& data,
28 OdfDocumentHandler* pHandler,
29 const OdfStreamType streamType)
30{
31 OdsGenerator exporter;
32 exporter.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
33 exporter.addDocumentHandler(pHandler, streamType);
34 return MWAWDocument::decodeSpreadsheet(data, &exporter);
35}
36
38 librevenge::RVNGInputStream& rInput,
39 OdpGenerator& rGenerator, utl::MediaDescriptor&)
40{
41 return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator);
42}
43
44bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput,
45 OUString& rTypeName)
46{
47 rTypeName.clear();
48
49 MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN;
50 MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN;
51 const MWAWDocument::Confidence confidence
52 = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind);
53
54 if (confidence == MWAWDocument::MWAW_C_EXCELLENT)
55 {
56 if (docKind == MWAWDocument::MWAW_K_PRESENTATION)
57 {
58 switch (docType)
59 {
60 case MWAWDocument::MWAW_T_CLARISWORKS:
61 rTypeName = "impress_ClarisWorks";
62 break;
63 case MWAWDocument::MWAW_T_RESERVED8:
64 rTypeName = "impress_PowerPoint3";
65 break;
66 default:
67 rTypeName = "MWAW_Presentation";
68 break;
69 }
70 }
71 }
72
73 return !rTypeName.isEmpty();
74}
75
77{
78 rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
79 rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods",
81}
82
83// XServiceInfo
85{
86 return "com.sun.star.comp.Impress.MWAWPresentationImportFilter";
87}
88sal_Bool SAL_CALL MWAWPresentationImportFilter::supportsService(const OUString& rServiceName)
89{
90 return cppu::supportsService(this, rServiceName);
91}
92css::uno::Sequence<OUString> SAL_CALL MWAWPresentationImportFilter::getSupportedServiceNames()
93{
94 return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
95}
96
97extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
99 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
100{
101 return cppu::acquire(new MWAWPresentationImportFilter(context));
102}
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Impress_MWAWPresentationImportFilter_get_implementation(css::uno::XComponentContext *const context, const css::uno::Sequence< css::uno::Any > &)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override
virtual bool doImportDocument(weld::Window *pParent, librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) override
virtual void doRegisterHandlers(OdpGenerator &rGenerator) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool