fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / writerperfect / source / calc / MWAWCalcImportFilter.cxx
blob5b2f3f79f2bae21f6733a0262fe2e47858337cf9
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 <com/sun/star/uno/Reference.h>
13 #include <cppuhelper/supportsservice.hxx>
15 #include <libmwaw/libmwaw.hxx>
16 #include <libodfgen/libodfgen.hxx>
18 #include "MWAWCalcImportFilter.hxx"
20 using com::sun::star::uno::Sequence;
21 using com::sun::star::uno::Reference;
22 using com::sun::star::uno::Any;
23 using com::sun::star::uno::XInterface;
24 using com::sun::star::uno::Exception;
25 using com::sun::star::uno::RuntimeException;
26 using com::sun::star::uno::XComponentContext;
28 static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
30 OdgGenerator exporter;
31 exporter.addDocumentHandler(pHandler, streamType);
32 return MWAWDocument::decodeGraphic(data, &exporter);
35 static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
37 OdsGenerator exporter;
38 exporter.addDocumentHandler(pHandler, streamType);
39 return MWAWDocument::decodeSpreadsheet(data, &exporter);
42 bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &)
44 return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator);
47 bool MWAWCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
49 rTypeName.clear();
51 MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN;
52 MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN;
53 const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind);
55 if (confidence == MWAWDocument::MWAW_C_EXCELLENT)
57 if (docKind == MWAWDocument::MWAW_K_SPREADSHEET || docKind == MWAWDocument::MWAW_K_DATABASE)
59 switch (docType)
61 case MWAWDocument::MWAW_T_BEAGLEWORKS:
62 rTypeName = "calc_Beagle_Works";
63 break;
64 case MWAWDocument::MWAW_T_CLARISRESOLVE:
65 rTypeName = "calc_Claris_Resolve";
66 break;
67 case MWAWDocument::MWAW_T_CLARISWORKS:
68 rTypeName = "calc_ClarisWorks";
69 break;
70 case MWAWDocument::MWAW_T_GREATWORKS:
71 rTypeName = "calc_Great_Works";
72 break;
73 case MWAWDocument::MWAW_T_MICROSOFTWORKS:
74 rTypeName = "calc_Mac_Works";
75 break;
76 case MWAWDocument::MWAW_T_WINGZ:
77 rTypeName = "calc_Mac_Wingz";
78 break;
80 case MWAWDocument::MWAW_T_ACTA:
81 case MWAWDocument::MWAW_T_ADOBEILLUSTRATOR:
82 case MWAWDocument::MWAW_T_DBASE:
83 case MWAWDocument::MWAW_T_DOCMAKER:
84 case MWAWDocument::MWAW_T_EDOC:
85 case MWAWDocument::MWAW_T_FAMILYTREEMAKER:
86 case MWAWDocument::MWAW_T_FILEMAKER:
87 case MWAWDocument::MWAW_T_FOXBASE:
88 case MWAWDocument::MWAW_T_FRAMEMAKER:
89 case MWAWDocument::MWAW_T_FULLIMPACT:
90 case MWAWDocument::MWAW_T_FULLPAINT:
91 case MWAWDocument::MWAW_T_FULLWRITE:
92 case MWAWDocument::MWAW_T_INFOGENIE:
93 case MWAWDocument::MWAW_T_KALEIDAGRAPH:
94 case MWAWDocument::MWAW_T_HANMACWORDJ:
95 case MWAWDocument::MWAW_T_HANMACWORDK:
96 case MWAWDocument::MWAW_T_LIGHTWAYTEXT:
97 case MWAWDocument::MWAW_T_MACDOC:
98 case MWAWDocument::MWAW_T_MACDRAFT:
99 case MWAWDocument::MWAW_T_MACDRAW:
100 case MWAWDocument::MWAW_T_MACDRAWPRO:
101 case MWAWDocument::MWAW_T_MACPAINT:
102 case MWAWDocument::MWAW_T_MACWRITE:
103 case MWAWDocument::MWAW_T_MACWRITEPRO:
104 case MWAWDocument::MWAW_T_MARINERWRITE:
105 case MWAWDocument::MWAW_T_MINDWRITE:
106 case MWAWDocument::MWAW_T_MICROSOFTFILE:
107 case MWAWDocument::MWAW_T_MICROSOFTMULTIPLAN:
108 case MWAWDocument::MWAW_T_MICROSOFTWORD:
109 case MWAWDocument::MWAW_T_MORE:
110 case MWAWDocument::MWAW_T_NISUSWRITER:
111 case MWAWDocument::MWAW_T_OVERVUE:
112 case MWAWDocument::MWAW_T_PAGEMAKER:
113 case MWAWDocument::MWAW_T_PIXELPAINT:
114 case MWAWDocument::MWAW_T_RAGTIME:
115 case MWAWDocument::MWAW_T_READYSETGO:
116 case MWAWDocument::MWAW_T_SUPERPAINT:
117 case MWAWDocument::MWAW_T_SYMPOSIUM:
118 case MWAWDocument::MWAW_T_TEACHTEXT:
119 case MWAWDocument::MWAW_T_TEXEDIT:
120 case MWAWDocument::MWAW_T_TRAPEZE:
121 case MWAWDocument::MWAW_T_WRITENOW:
122 case MWAWDocument::MWAW_T_WRITERPLUS:
123 case MWAWDocument::MWAW_T_XPRESS:
124 case MWAWDocument::MWAW_T_ZWRITE:
125 case MWAWDocument::MWAW_T_4DIMENSION:
127 case MWAWDocument::MWAW_T_RESERVED1:
128 case MWAWDocument::MWAW_T_RESERVED2:
129 case MWAWDocument::MWAW_T_RESERVED3:
130 case MWAWDocument::MWAW_T_RESERVED4:
131 case MWAWDocument::MWAW_T_RESERVED5:
132 case MWAWDocument::MWAW_T_RESERVED6:
133 case MWAWDocument::MWAW_T_RESERVED7:
134 case MWAWDocument::MWAW_T_RESERVED8:
135 case MWAWDocument::MWAW_T_RESERVED9:
136 case MWAWDocument::MWAW_T_UNKNOWN:
137 default:
138 break;
143 return !rTypeName.isEmpty();
146 void MWAWCalcImportFilter::doRegisterHandlers(OdsGenerator &rGenerator)
148 rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
149 rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject);
152 OUString MWAWCalcImportFilter_getImplementationName()
153 throw (RuntimeException)
155 return OUString("com.sun.star.comp.Calc.MWAWCalcImportFilter");
158 Sequence< OUString > SAL_CALL MWAWCalcImportFilter_getSupportedServiceNames()
159 throw (RuntimeException)
161 Sequence < OUString > aRet(2);
162 OUString *pArray = aRet.getArray();
163 pArray[0] = "com.sun.star.document.ImportFilter";
164 pArray[1] = "com.sun.star.document.ExtendedTypeDetection";
165 return aRet;
168 Reference< XInterface > SAL_CALL MWAWCalcImportFilter_createInstance(const Reference< XComponentContext > &rContext)
169 throw(Exception)
171 return (cppu::OWeakObject *) new MWAWCalcImportFilter(rContext);
174 // XServiceInfo
175 OUString SAL_CALL MWAWCalcImportFilter::getImplementationName()
176 throw (RuntimeException, std::exception)
178 return MWAWCalcImportFilter_getImplementationName();
180 sal_Bool SAL_CALL MWAWCalcImportFilter::supportsService(const OUString &rServiceName)
181 throw (RuntimeException, std::exception)
183 return cppu::supportsService(this, rServiceName);
185 Sequence< OUString > SAL_CALL MWAWCalcImportFilter::getSupportedServiceNames()
186 throw (RuntimeException, std::exception)
188 return MWAWCalcImportFilter_getSupportedServiceNames();
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */