cid#1640468 Dereference after null check
[LibreOffice.git] / writerperfect / source / impress / StarOfficePresentationImportFilter.cxx
blob7249d1e1fcc220328e0457678cc931c0e85dd6ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <cppuhelper/supportsservice.hxx>
12 #include <libstaroffice/libstaroffice.hxx>
14 #include "StarOfficePresentationImportFilter.hxx"
16 using com::sun::star::uno::Sequence;
17 using com::sun::star::uno::XComponentContext;
18 using com::sun::star::uno::XInterface;
20 static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData& data,
21 OdfDocumentHandler* pHandler,
22 const OdfStreamType streamType)
24 OdgGenerator exporter;
25 exporter.addDocumentHandler(pHandler, streamType);
26 return STOFFDocument::decodeGraphic(data, &exporter);
29 static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData& data,
30 OdfDocumentHandler* pHandler,
31 const OdfStreamType streamType)
33 OdsGenerator exporter;
34 exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
35 exporter.addDocumentHandler(pHandler, streamType);
36 return STOFFDocument::decodeSpreadsheet(data, &exporter);
39 bool StarOfficePresentationImportFilter::doImportDocument(weld::Window*,
40 librevenge::RVNGInputStream& rInput,
41 OdpGenerator& rGenerator,
42 utl::MediaDescriptor&)
44 return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator);
47 bool StarOfficePresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput,
48 OUString& rTypeName)
50 rTypeName.clear();
52 STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
53 const STOFFDocument::Confidence confidence
54 = STOFFDocument::isFileFormatSupported(&rInput, docKind);
56 if (confidence == STOFFDocument::STOFF_C_EXCELLENT
57 || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
59 switch (docKind)
61 case STOFFDocument::STOFF_K_PRESENTATION:
62 rTypeName = "StarOffice_Presentation";
63 break;
64 default:
65 break;
69 return !rTypeName.isEmpty();
72 void StarOfficePresentationImportFilter::doRegisterHandlers(OdpGenerator& rGenerator)
74 rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
75 rGenerator.registerEmbeddedObjectHandler("image/stoff-ods",
76 &handleEmbeddedSTOFFSpreadsheetObject);
79 // XServiceInfo
80 OUString SAL_CALL StarOfficePresentationImportFilter::getImplementationName()
82 return u"org.libreoffice.comp.Impress.StarOfficePresentationImportFilter"_ustr;
85 sal_Bool SAL_CALL StarOfficePresentationImportFilter::supportsService(const OUString& rServiceName)
87 return cppu::supportsService(this, rServiceName);
90 Sequence<OUString> SAL_CALL StarOfficePresentationImportFilter::getSupportedServiceNames()
92 return { u"com.sun.star.document.ImportFilter"_ustr,
93 u"com.sun.star.document.ExtendedTypeDetection"_ustr };
96 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
97 org_libreoffice_comp_Presentation_StarOfficePresentationImportFilter_get_implementation(
98 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
100 return cppu::acquire(new StarOfficePresentationImportFilter(context));
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */