LibreOffice Module writerperfect (master) 1
StarOfficePresentationImportFilter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
11
12#include <libstaroffice/libstaroffice.hxx>
13
15
17using com::sun::star::uno::XComponentContext;
18using com::sun::star::uno::XInterface;
19
20static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData& data,
21 OdfDocumentHandler* pHandler,
22 const OdfStreamType streamType)
23{
24 OdgGenerator exporter;
25 exporter.addDocumentHandler(pHandler, streamType);
26 return STOFFDocument::decodeGraphic(data, &exporter);
27}
28
29static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData& data,
30 OdfDocumentHandler* pHandler,
31 const OdfStreamType streamType)
32{
33 OdsGenerator exporter;
34 exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
35 exporter.addDocumentHandler(pHandler, streamType);
36 return STOFFDocument::decodeSpreadsheet(data, &exporter);
37}
38
40 librevenge::RVNGInputStream& rInput,
41 OdpGenerator& rGenerator,
43{
44 return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator);
45}
46
47bool StarOfficePresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput,
48 OUString& rTypeName)
49{
50 rTypeName.clear();
51
52 STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
53 const STOFFDocument::Confidence confidence
54 = STOFFDocument::isFileFormatSupported(&rInput, docKind);
55
56 if (confidence == STOFFDocument::STOFF_C_EXCELLENT
57 || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
58 {
59 switch (docKind)
60 {
61 case STOFFDocument::STOFF_K_PRESENTATION:
62 rTypeName = "StarOffice_Presentation";
63 break;
64 default:
65 break;
66 }
67 }
68
69 return !rTypeName.isEmpty();
70}
71
73{
74 rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
75 rGenerator.registerEmbeddedObjectHandler("image/stoff-ods",
77}
78
79// XServiceInfo
81{
82 return "org.libreoffice.comp.Impress.StarOfficePresentationImportFilter";
83}
84
86{
87 return cppu::supportsService(this, rServiceName);
88}
89
91{
92 return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
93}
94
95extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
97 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
98{
99 return cppu::acquire(new StarOfficePresentationImportFilter(context));
100}
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_libreoffice_comp_Presentation_StarOfficePresentationImportFilter_get_implementation(css::uno::XComponentContext *const context, const css::uno::Sequence< css::uno::Any > &)
static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
virtual void doRegisterHandlers(OdpGenerator &rGenerator) override
virtual bool doImportDocument(weld::Window *pParent, librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool