1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_PDFIADAPTOR_HXX
21 #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_PDFIADAPTOR_HXX
23 #include <xmlemitter.hxx>
24 #include <treevisitorfactory.hxx>
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>
37 #include <cppuhelper/compbase.hxx>
38 #include <cppuhelper/basemutex.hxx>
43 typedef ::cppu::WeakComponentImplHelper
<
44 css::document::XFilter
,
45 css::document::XImporter
,
46 css::lang::XServiceInfo
> PDFIHybridAdaptorBase
;
48 class PDFIHybridAdaptor
: private cppu::BaseMutex
,
49 public PDFIHybridAdaptorBase
53 css::uno::XComponentContext
> m_xContext
;
55 css::frame::XModel
> m_xModel
;
58 explicit PDFIHybridAdaptor( const css::uno::Reference
<
59 css::uno::XComponentContext
>& xContext
);
62 virtual sal_Bool SAL_CALL
filter( const css::uno::Sequence
<css::beans::PropertyValue
>& rFilterData
) override
;
63 virtual void SAL_CALL
cancel() override
;
66 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDocument
) override
;
68 OUString SAL_CALL
getImplementationName() override
;
70 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
) override
;
72 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
75 typedef ::cppu::WeakComponentImplHelper
<
76 css::xml::XImportFilter
,
77 css::document::XImporter
,
78 css::lang::XServiceInfo
> PDFIAdaptorBase
;
80 /** Adapts raw pdf import to XImportFilter interface
82 class PDFIRawAdaptor
: private cppu::BaseMutex
,
83 public PDFIAdaptorBase
86 OUString
const m_implementationName
;
88 css::uno::XComponentContext
> m_xContext
;
90 css::frame::XModel
> m_xModel
;
91 TreeVisitorFactorySharedPtr m_pVisitorFactory
;
93 bool parse( const css::uno::Reference
<css::io::XInputStream
>& xInput
,
94 const css::uno::Reference
<css::task::XInteractionHandler
>& xIHdl
,
96 const css::uno::Reference
<css::task::XStatusIndicator
>& xStatus
,
97 const XmlEmitterSharedPtr
& rEmitter
,
99 const OUString
& rFilterOptions
);
102 explicit PDFIRawAdaptor( OUString
const & implementationName
,
103 const css::uno::Reference
<
104 css::uno::XComponentContext
>& xContext
);
106 /** Set factory object used to create the tree visitors
108 Used for customizing the tree to the specific output
109 format (writer, draw, etc)
111 void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr
& rVisitorFactory
);
113 /** Export pdf document to ODG
116 Stream to write the flat xml file to
119 Optional status indicator
121 bool odfConvert( const OUString
& rURL
,
122 const css::uno::Reference
<css::io::XOutputStream
>& xOutput
,
123 const css::uno::Reference
<css::task::XStatusIndicator
>& xStatus
);
126 virtual sal_Bool SAL_CALL
importer( const css::uno::Sequence
< css::beans::PropertyValue
>& rSourceData
,
127 const css::uno::Reference
< css::xml::sax::XDocumentHandler
>& rHdl
,
128 const css::uno::Sequence
< OUString
>& rUserData
) override
;
131 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDocument
) override
;
133 OUString SAL_CALL
getImplementationName() override
;
135 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
) override
;
137 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */