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
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>
14 #include <libmwaw/libmwaw.hxx>
16 #include "MWAWPresentationImportFilter.hxx"
18 static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData
& data
,
19 OdfDocumentHandler
* pHandler
,
20 const OdfStreamType streamType
)
22 OdgGenerator exporter
;
23 exporter
.addDocumentHandler(pHandler
, streamType
);
24 return MWAWDocument::decodeGraphic(data
, &exporter
);
27 static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData
& data
,
28 OdfDocumentHandler
* pHandler
,
29 const OdfStreamType streamType
)
31 OdsGenerator exporter
;
32 exporter
.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject
);
33 exporter
.addDocumentHandler(pHandler
, streamType
);
34 return MWAWDocument::decodeSpreadsheet(data
, &exporter
);
37 bool MWAWPresentationImportFilter::doImportDocument(weld::Window
*,
38 librevenge::RVNGInputStream
& rInput
,
39 OdpGenerator
& rGenerator
, utl::MediaDescriptor
&)
41 return MWAWDocument::MWAW_R_OK
== MWAWDocument::parse(&rInput
, &rGenerator
);
44 bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream
& rInput
,
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
);
54 if (confidence
== MWAWDocument::MWAW_C_EXCELLENT
)
56 if (docKind
== MWAWDocument::MWAW_K_PRESENTATION
)
60 case MWAWDocument::MWAW_T_CLARISWORKS
:
61 rTypeName
= "impress_ClarisWorks";
63 case MWAWDocument::MWAW_T_RESERVED8
:
64 rTypeName
= "impress_PowerPoint3";
67 rTypeName
= "MWAW_Presentation";
73 return !rTypeName
.isEmpty();
76 void MWAWPresentationImportFilter::doRegisterHandlers(OdpGenerator
& rGenerator
)
78 rGenerator
.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject
);
79 rGenerator
.registerEmbeddedObjectHandler("image/mwaw-ods",
80 &handleEmbeddedMWAWSpreadsheetObject
);
84 OUString SAL_CALL
MWAWPresentationImportFilter::getImplementationName()
86 return u
"com.sun.star.comp.Impress.MWAWPresentationImportFilter"_ustr
;
88 sal_Bool SAL_CALL
MWAWPresentationImportFilter::supportsService(const OUString
& rServiceName
)
90 return cppu::supportsService(this, rServiceName
);
92 css::uno::Sequence
<OUString
> SAL_CALL
MWAWPresentationImportFilter::getSupportedServiceNames()
94 return { u
"com.sun.star.document.ImportFilter"_ustr
,
95 u
"com.sun.star.document.ExtendedTypeDetection"_ustr
};
98 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
99 com_sun_star_comp_Impress_MWAWPresentationImportFilter_get_implementation(
100 css::uno::XComponentContext
* const context
, const css::uno::Sequence
<css::uno::Any
>&)
102 return cppu::acquire(new MWAWPresentationImportFilter(context
));
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */