Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* MSPUBImportFilter: Sets up the filter, and calls OdgExporter
3 : * to do the actual filtering
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 :
10 : #include <com/sun/star/uno/Reference.h>
11 : #include <com/sun/star/uno/XComponentContext.hpp>
12 : #include <cppuhelper/supportsservice.hxx>
13 :
14 : #include <libmspub/libmspub.h>
15 : #include <libodfgen/libodfgen.hxx>
16 :
17 : #include "MSPUBImportFilter.hxx"
18 :
19 : #include <iostream>
20 :
21 : using com::sun::star::uno::Reference;
22 : using com::sun::star::uno::Exception;
23 : using com::sun::star::uno::RuntimeException;
24 : using com::sun::star::uno::Sequence;
25 : using com::sun::star::uno::XComponentContext;
26 : using com::sun::star::uno::XInterface;
27 :
28 4 : bool MSPUBImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &)
29 : {
30 4 : return libmspub::MSPUBDocument::parse(&rInput, &rGenerator);
31 : }
32 :
33 88 : bool MSPUBImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
34 : {
35 88 : if (libmspub::MSPUBDocument::isSupported(&rInput))
36 : {
37 4 : rTypeName = "draw_Publisher_Document";
38 4 : return true;
39 : }
40 :
41 84 : return false;
42 : }
43 :
44 38 : OUString MSPUBImportFilter_getImplementationName()
45 : throw (RuntimeException)
46 : {
47 38 : return OUString("com.sun.star.comp.Draw.MSPUBImportFilter");
48 : }
49 :
50 5 : Sequence< OUString > SAL_CALL MSPUBImportFilter_getSupportedServiceNames()
51 : throw (RuntimeException)
52 : {
53 5 : Sequence < OUString > aRet(2);
54 5 : OUString *pArray = aRet.getArray();
55 5 : pArray[0] = "com.sun.star.document.ImportFilter";
56 5 : pArray[1] = "com.sun.star.document.ExtendedTypeDetection";
57 5 : return aRet;
58 : }
59 :
60 86 : Reference< XInterface > SAL_CALL MSPUBImportFilter_createInstance(const Reference< XComponentContext > &rContext)
61 : throw(Exception)
62 : {
63 86 : return static_cast<cppu::OWeakObject *>(new MSPUBImportFilter(rContext));
64 : }
65 :
66 : // XServiceInfo
67 1 : OUString SAL_CALL MSPUBImportFilter::getImplementationName()
68 : throw (RuntimeException, std::exception)
69 : {
70 1 : return MSPUBImportFilter_getImplementationName();
71 : }
72 0 : sal_Bool SAL_CALL MSPUBImportFilter::supportsService(const OUString &rServiceName)
73 : throw (RuntimeException, std::exception)
74 : {
75 0 : return cppu::supportsService(this, rServiceName);
76 : }
77 1 : Sequence< OUString > SAL_CALL MSPUBImportFilter::getSupportedServiceNames()
78 : throw (RuntimeException, std::exception)
79 : {
80 1 : return MSPUBImportFilter_getSupportedServiceNames();
81 18 : }
82 :
83 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|