Line data Source code
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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_PDFIADAPTOR_HXX
21 : #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_PDFIADAPTOR_HXX
22 :
23 : #include "xmlemitter.hxx"
24 : #include "treevisitorfactory.hxx"
25 :
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/xml/XImportFilter.hpp>
28 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
29 : #include <com/sun/star/uno/XComponentContext.hpp>
30 : #include <com/sun/star/task/XStatusIndicator.hpp>
31 : #include <com/sun/star/document/XFilter.hpp>
32 : #include <com/sun/star/io/XInputStream.hpp>
33 : #include <com/sun/star/io/XOutputStream.hpp>
34 : #include <com/sun/star/document/XImporter.hpp>
35 : #include <com/sun/star/frame/XModel.hpp>
36 :
37 : #include <cppuhelper/compbase.hxx>
38 : #include <cppuhelper/basemutex.hxx>
39 :
40 :
41 : namespace pdfi
42 : {
43 : typedef ::cppu::WeakComponentImplHelper<
44 : css::document::XFilter,
45 : css::document::XImporter,
46 : css::lang::XServiceInfo> PDFIHybridAdaptorBase;
47 :
48 2 : class PDFIHybridAdaptor : private cppu::BaseMutex,
49 : public PDFIHybridAdaptorBase
50 : {
51 : private:
52 : css::uno::Reference<
53 : css::uno::XComponentContext > m_xContext;
54 : css::uno::Reference<
55 : css::frame::XModel > m_xModel;
56 :
57 : public:
58 : explicit PDFIHybridAdaptor( const css::uno::Reference<
59 : css::uno::XComponentContext >& xContext );
60 :
61 : // XFilter
62 : virtual sal_Bool SAL_CALL filter( const css::uno::Sequence<css::beans::PropertyValue>& rFilterData ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 : virtual void SAL_CALL cancel() throw(std::exception) SAL_OVERRIDE;
64 :
65 : // XImporter
66 : virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDocument )
67 : throw( css::lang::IllegalArgumentException, std::exception ) SAL_OVERRIDE;
68 :
69 : OUString SAL_CALL getImplementationName()
70 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 :
72 : sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
73 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 :
75 : css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
76 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 : };
78 :
79 : typedef ::cppu::WeakComponentImplHelper<
80 : css::xml::XImportFilter,
81 : css::document::XImporter,
82 : css::lang::XServiceInfo> PDFIAdaptorBase;
83 :
84 : /** Adapts raw pdf import to XImportFilter interface
85 : */
86 12 : class PDFIRawAdaptor : private cppu::BaseMutex,
87 : public PDFIAdaptorBase
88 : {
89 : private:
90 : OUString const m_implementationName;
91 : css::uno::Reference<
92 : css::uno::XComponentContext > m_xContext;
93 : css::uno::Reference<
94 : css::frame::XModel > m_xModel;
95 : TreeVisitorFactorySharedPtr m_pVisitorFactory;
96 : bool m_bEnableToplevelText;
97 :
98 : bool parse( const css::uno::Reference<css::io::XInputStream>& xInput,
99 : const css::uno::Reference<css::task::XInteractionHandler>& xIHdl,
100 : const OUString& rPwd,
101 : const css::uno::Reference<css::task::XStatusIndicator>& xStatus,
102 : const XmlEmitterSharedPtr& rEmitter,
103 : const OUString& rURL,
104 : const OUString& rFilterOptions = OUString());
105 :
106 : public:
107 : explicit PDFIRawAdaptor( OUString const & implementationName,
108 : const css::uno::Reference<
109 : css::uno::XComponentContext >& xContext );
110 :
111 : /** Set factory object used to create the tree visitors
112 :
113 : Used for customizing the tree to the specific output
114 : format (writer, draw, etc)
115 : */
116 : void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr& rVisitorFactory);
117 :
118 : /// TEMP - enable writer-like text:p on doc level
119 1 : void enableToplevelText() { m_bEnableToplevelText=true; }
120 :
121 : /** Export pdf document to ODG
122 :
123 : @param xOutput
124 : Stream to write the flat xml file to
125 :
126 : @param xStatus
127 : Optional status indicator
128 : */
129 : bool odfConvert( const OUString& rURL,
130 : const css::uno::Reference<css::io::XOutputStream>& xOutput,
131 : const css::uno::Reference<css::task::XStatusIndicator>& xStatus );
132 :
133 : // XImportFilter
134 : virtual sal_Bool SAL_CALL importer( const css::uno::Sequence< css::beans::PropertyValue >& rSourceData,
135 : const css::uno::Reference< css::xml::sax::XDocumentHandler >& rHdl,
136 : const css::uno::Sequence< OUString >& rUserData ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
137 :
138 : // XImporter
139 : virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDocument )
140 : throw( css::lang::IllegalArgumentException, std::exception ) SAL_OVERRIDE;
141 :
142 : OUString SAL_CALL getImplementationName()
143 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 :
145 : sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
146 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 :
148 : css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
149 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : };
151 : }
152 :
153 : #endif
154 :
155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|