tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / writerperfect / source / calc / MWAWCalcImportFilter.cxx
blobe07c013732c09106a2b9ae927bf68eb917671b2f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* MWAWCalcImportFilter: 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 "MWAWCalcImportFilter.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.addDocumentHandler(pHandler, streamType);
33 return MWAWDocument::decodeSpreadsheet(data, &exporter);
36 bool MWAWCalcImportFilter::doImportDocument(weld::Window*, librevenge::RVNGInputStream& rInput,
37 OdsGenerator& rGenerator, utl::MediaDescriptor&)
39 return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator);
42 bool MWAWCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName)
44 rTypeName.clear();
46 MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN;
47 MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN;
48 const MWAWDocument::Confidence confidence
49 = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind);
51 if (confidence == MWAWDocument::MWAW_C_EXCELLENT)
53 switch (docKind)
55 case MWAWDocument::MWAW_K_DATABASE:
56 switch (docType)
58 case MWAWDocument::MWAW_T_CLARISWORKS:
59 rTypeName = "calc_ClarisWorks";
60 break;
61 case MWAWDocument::MWAW_T_MICROSOFTWORKS:
62 rTypeName = "calc_Mac_Works";
63 break;
64 default:
65 rTypeName = "MWAW_Database";
66 break;
68 break;
69 case MWAWDocument::MWAW_K_SPREADSHEET:
70 switch (docType)
72 case MWAWDocument::MWAW_T_CLARISRESOLVE:
73 rTypeName = "calc_Claris_Resolve";
74 break;
75 case MWAWDocument::MWAW_T_CLARISWORKS:
76 rTypeName = "calc_ClarisWorks";
77 break;
78 case MWAWDocument::MWAW_T_MICROSOFTWORKS:
79 rTypeName = "calc_Mac_Works";
80 break;
81 default:
82 rTypeName = "MWAW_Spreadsheet";
83 break;
85 break;
86 default:
87 break;
91 return !rTypeName.isEmpty();
94 void MWAWCalcImportFilter::doRegisterHandlers(OdsGenerator& rGenerator)
96 rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
97 rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods",
98 &handleEmbeddedMWAWSpreadsheetObject);
101 // XServiceInfo
102 OUString SAL_CALL MWAWCalcImportFilter::getImplementationName()
104 return u"com.sun.star.comp.Calc.MWAWCalcImportFilter"_ustr;
107 sal_Bool SAL_CALL MWAWCalcImportFilter::supportsService(const OUString& rServiceName)
109 return cppu::supportsService(this, rServiceName);
112 css::uno::Sequence<OUString> SAL_CALL MWAWCalcImportFilter::getSupportedServiceNames()
114 return { u"com.sun.star.document.ImportFilter"_ustr,
115 u"com.sun.star.document.ExtendedTypeDetection"_ustr };
118 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
119 com_sun_star_comp_Calc_MWAWCalcImportFilter_get_implementation(
120 css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&)
122 return cppu::acquire(new MWAWCalcImportFilter(context));
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */