1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* NumbersImportFilter: 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 <libetonyek/libetonyek.h>
14 #include <com/sun/star/uno/Reference.h>
16 #include <cppuhelper/supportsservice.hxx>
18 #include "NumbersImportFilter.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 using libetonyek::EtonyekDocument
;
30 bool NumbersImportFilter::doImportDocument(librevenge::RVNGInputStream
&rInput
, OdsGenerator
&rGenerator
, utl::MediaDescriptor
&)
32 return EtonyekDocument::parse(&rInput
, &rGenerator
);
35 bool NumbersImportFilter::doDetectFormat(librevenge::RVNGInputStream
&rInput
, OUString
&rTypeName
)
37 EtonyekDocument::Type type
= EtonyekDocument::TYPE_UNKNOWN
;
38 const EtonyekDocument::Confidence confidence
= EtonyekDocument::isSupported(&rInput
, &type
);
39 if ((confidence
== EtonyekDocument::CONFIDENCE_EXCELLENT
) && (type
== EtonyekDocument::TYPE_NUMBERS
))
41 rTypeName
= "calc_AppleNumbers";
48 void NumbersImportFilter::doRegisterHandlers(OdsGenerator
&)
52 OUString
NumbersImportFilter_getImplementationName()
53 throw (RuntimeException
)
55 return OUString("org.libreoffice.comp.Calc.NumbersImportFilter");
58 Sequence
< OUString
> SAL_CALL
NumbersImportFilter_getSupportedServiceNames()
59 throw (RuntimeException
)
61 Sequence
< OUString
> aRet(2);
62 OUString
*pArray
= aRet
.getArray();
63 pArray
[0] = "com.sun.star.document.ImportFilter";
64 pArray
[1] = "com.sun.star.document.ExtendedTypeDetection";
68 Reference
< XInterface
> SAL_CALL
NumbersImportFilter_createInstance(const Reference
< XComponentContext
> &rContext
)
71 return static_cast<cppu::OWeakObject
*>(new NumbersImportFilter(rContext
));
75 OUString SAL_CALL
NumbersImportFilter::getImplementationName()
76 throw (RuntimeException
, std::exception
)
78 return NumbersImportFilter_getImplementationName();
80 sal_Bool SAL_CALL
NumbersImportFilter::supportsService(const OUString
&rServiceName
)
81 throw (RuntimeException
, std::exception
)
83 return cppu::supportsService(this, rServiceName
);
85 Sequence
< OUString
> SAL_CALL
NumbersImportFilter::getSupportedServiceNames()
86 throw (RuntimeException
, std::exception
)
88 return NumbersImportFilter_getSupportedServiceNames();
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */