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
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
63 virtual void SAL_CALL
cancel() throw(std::exception
) SAL_OVERRIDE
;
66 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDocument
)
67 throw( css::lang::IllegalArgumentException
, std::exception
) SAL_OVERRIDE
;
69 OUString SAL_CALL
getImplementationName()
70 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
72 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
73 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
75 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
76 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
79 typedef ::cppu::WeakComponentImplHelper
<
80 css::xml::XImportFilter
,
81 css::document::XImporter
,
82 css::lang::XServiceInfo
> PDFIAdaptorBase
;
84 /** Adapts raw pdf import to XImportFilter interface
86 class PDFIRawAdaptor
: private cppu::BaseMutex
,
87 public PDFIAdaptorBase
90 OUString
const m_implementationName
;
92 css::uno::XComponentContext
> m_xContext
;
94 css::frame::XModel
> m_xModel
;
95 TreeVisitorFactorySharedPtr m_pVisitorFactory
;
96 bool m_bEnableToplevelText
;
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());
107 explicit PDFIRawAdaptor( OUString
const & implementationName
,
108 const css::uno::Reference
<
109 css::uno::XComponentContext
>& xContext
);
111 /** Set factory object used to create the tree visitors
113 Used for customizing the tree to the specific output
114 format (writer, draw, etc)
116 void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr
& rVisitorFactory
);
118 /// TEMP - enable writer-like text:p on doc level
119 void enableToplevelText() { m_bEnableToplevelText
=true; }
121 /** Export pdf document to ODG
124 Stream to write the flat xml file to
127 Optional status indicator
129 bool odfConvert( const OUString
& rURL
,
130 const css::uno::Reference
<css::io::XOutputStream
>& xOutput
,
131 const css::uno::Reference
<css::task::XStatusIndicator
>& xStatus
);
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
;
139 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDocument
)
140 throw( css::lang::IllegalArgumentException
, std::exception
) SAL_OVERRIDE
;
142 OUString SAL_CALL
getImplementationName()
143 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
145 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
146 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
148 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
149 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */