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