LibreOffice Module writerperfect (master) 1
StarOfficeCalcImportFilter.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.addDocumentHandler(pHandler, streamType);
35 return STOFFDocument::decodeSpreadsheet(data, &exporter);
36}
37
39 librevenge::RVNGInputStream& rInput,
40 OdsGenerator& rGenerator, utl::MediaDescriptor&)
41{
42 return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator);
43}
44
45bool StarOfficeCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput,
46 OUString& rTypeName)
47{
48 rTypeName.clear();
49 STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
50 const STOFFDocument::Confidence confidence
51 = STOFFDocument::isFileFormatSupported(&rInput, docKind);
52 if (confidence == STOFFDocument::STOFF_C_EXCELLENT
53 || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
54 {
55 switch (docKind)
56 {
57 case STOFFDocument::STOFF_K_DATABASE:
58 case STOFFDocument::STOFF_K_SPREADSHEET:
59 rTypeName = "StarOffice_Spreadsheet";
60 break;
61 default:
62 break;
63 }
64 }
65
66 return !rTypeName.isEmpty();
67}
68
70{
71 rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
72 rGenerator.registerEmbeddedObjectHandler("image/stoff-ods",
74}
75
76// XServiceInfo
78{
79 return "org.libreoffice.comp.Calc.StarOfficeCalcImportFilter";
80}
81
82sal_Bool SAL_CALL StarOfficeCalcImportFilter::supportsService(const OUString& rServiceName)
83{
84 return cppu::supportsService(this, rServiceName);
85}
86
88{
89 return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
90}
91
92extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
94 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
95{
96 return cppu::acquire(new StarOfficeCalcImportFilter(context));
97}
98
99/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_libreoffice_comp_Calc_StarOfficeCalcImportFilter_get_implementation(css::uno::XComponentContext *const context, const css::uno::Sequence< css::uno::Any > &)
static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
virtual bool doImportDocument(weld::Window *pParent, librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void doRegisterHandlers(OdsGenerator &rGenerator) override
virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool