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_PDFIADAPTOR_HXX
21 : #define INCLUDED_PDFIADAPTOR_HXX
22 :
23 : #include "xmlemitter.hxx"
24 : #include "treevisitorfactory.hxx"
25 :
26 : #include <com/sun/star/xml/XImportFilter.hpp>
27 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
28 : #include <com/sun/star/uno/XComponentContext.hpp>
29 : #include <com/sun/star/task/XStatusIndicator.hpp>
30 : #include <com/sun/star/document/XFilter.hpp>
31 : #include <com/sun/star/io/XInputStream.hpp>
32 : #include <com/sun/star/io/XOutputStream.hpp>
33 : #include <com/sun/star/document/XImporter.hpp>
34 : #include <com/sun/star/frame/XModel.hpp>
35 :
36 : #include <cppuhelper/compbase2.hxx>
37 : #include <cppuhelper/basemutex.hxx>
38 :
39 :
40 : namespace pdfi
41 : {
42 : typedef ::cppu::WeakComponentImplHelper2<
43 : com::sun::star::document::XFilter,
44 : com::sun::star::document::XImporter > PDFIHybridAdaptorBase;
45 :
46 0 : class PDFIHybridAdaptor : private cppu::BaseMutex,
47 : public PDFIHybridAdaptorBase
48 : {
49 : private:
50 : com::sun::star::uno::Reference<
51 : com::sun::star::uno::XComponentContext > m_xContext;
52 : com::sun::star::uno::Reference<
53 : com::sun::star::frame::XModel > m_xModel;
54 :
55 : public:
56 : explicit PDFIHybridAdaptor( const ::com::sun::star::uno::Reference<
57 : ::com::sun::star::uno::XComponentContext >& xContext );
58 :
59 : // XFilter
60 : virtual sal_Bool SAL_CALL filter( const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rFilterData ) throw(com::sun::star::uno::RuntimeException);
61 : virtual void SAL_CALL cancel() throw();
62 :
63 : // XImporter
64 : virtual void SAL_CALL setTargetDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDocument )
65 : throw( com::sun::star::lang::IllegalArgumentException );
66 :
67 : };
68 :
69 : typedef ::cppu::WeakComponentImplHelper2<
70 : com::sun::star::xml::XImportFilter,
71 : com::sun::star::document::XImporter > PDFIAdaptorBase;
72 :
73 : /** Adapts raw pdf import to XImportFilter interface
74 : */
75 2 : class PDFIRawAdaptor : private cppu::BaseMutex,
76 : public PDFIAdaptorBase
77 : {
78 : private:
79 : com::sun::star::uno::Reference<
80 : com::sun::star::uno::XComponentContext > m_xContext;
81 : com::sun::star::uno::Reference<
82 : com::sun::star::frame::XModel > m_xModel;
83 : TreeVisitorFactorySharedPtr m_pVisitorFactory;
84 : bool m_bEnableToplevelText;
85 :
86 : bool parse( const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInput,
87 : const com::sun::star::uno::Reference<com::sun::star::task::XInteractionHandler>& xIHdl,
88 : const rtl::OUString& rPwd,
89 : const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& xStatus,
90 : const XmlEmitterSharedPtr& rEmitter,
91 : const rtl::OUString& rURL );
92 :
93 : public:
94 : explicit PDFIRawAdaptor( const ::com::sun::star::uno::Reference<
95 : ::com::sun::star::uno::XComponentContext >& xContext );
96 :
97 : /** Set factory object used to create the tree visitors
98 :
99 : Used for customizing the tree to the specific output
100 : format (writer, draw, etc)
101 : */
102 : void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr& rVisitorFactory);
103 :
104 : /// TEMP - enable writer-like text:p on doc level
105 0 : void enableToplevelText() { m_bEnableToplevelText=true; }
106 :
107 : /** Export pdf document to ODG
108 :
109 : @param xOutput
110 : Stream to write the flat xml file to
111 :
112 : @param xStatus
113 : Optional status indicator
114 : */
115 : bool odfConvert( const rtl::OUString& rURL,
116 : const com::sun::star::uno::Reference<com::sun::star::io::XOutputStream>& xOutput,
117 : const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& xStatus );
118 :
119 : // XImportFilter
120 : virtual sal_Bool SAL_CALL importer( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rSourceData,
121 : const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& rHdl,
122 : const com::sun::star::uno::Sequence< rtl::OUString >& rUserData ) throw( com::sun::star::uno::RuntimeException );
123 :
124 : // XImporter
125 : virtual void SAL_CALL setTargetDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDocument )
126 : throw( com::sun::star::lang::IllegalArgumentException );
127 : };
128 : }
129 :
130 : #endif
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|