LibreOffice Module sdext (master)  1
pdfiadaptor.hxx
Go to the documentation of this file.
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 
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 ) override;
63  virtual void SAL_CALL cancel() override;
64 
65  // XImporter
66  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDocument ) override;
67 
68  OUString SAL_CALL getImplementationName() override;
69 
70  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
71 
72  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
73  };
74 
75  typedef ::cppu::WeakComponentImplHelper<
76  css::xml::XImportFilter,
77  css::document::XImporter,
78  css::lang::XServiceInfo> PDFIAdaptorBase;
79 
83  public PDFIAdaptorBase
84  {
85  private:
86  OUString const m_implementationName;
87  css::uno::Reference<
88  css::uno::XComponentContext > m_xContext;
89  css::uno::Reference<
90  css::frame::XModel > m_xModel;
92 
93  bool parse( const css::uno::Reference<css::io::XInputStream>& xInput,
94  const css::uno::Reference<css::task::XInteractionHandler>& xIHdl,
95  const OUString& rPwd,
96  const css::uno::Reference<css::task::XStatusIndicator>& xStatus,
97  const XmlEmitterSharedPtr& rEmitter,
98  const OUString& rURL,
99  const OUString& rFilterOptions);
100 
101  public:
102  explicit PDFIRawAdaptor( OUString const & implementationName,
103  const css::uno::Reference<
104  css::uno::XComponentContext >& xContext );
105 
111  void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr& rVisitorFactory);
112 
121  bool odfConvert( const OUString& rURL,
122  const css::uno::Reference<css::io::XOutputStream>& xOutput,
123  const css::uno::Reference<css::task::XStatusIndicator>& xStatus );
124 
125  // XImportFilter
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;
129 
130  // XImporter
131  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDocument ) override;
132 
133  OUString SAL_CALL getImplementationName() override;
134 
135  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
136 
137  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
138  };
139 }
140 
141 #endif
142 
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: pdfiadaptor.hxx:53
virtual sal_Bool SAL_CALL importer(const css::uno::Sequence< css::beans::PropertyValue > &rSourceData, const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHdl, const css::uno::Sequence< OUString > &rUserData) override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
::cppu::WeakComponentImplHelper< css::document::XFilter, css::document::XImporter, css::lang::XServiceInfo > PDFIHybridAdaptorBase
Definition: pdfiadaptor.hxx:46
std::shared_ptr< TreeVisitorFactory > TreeVisitorFactorySharedPtr
css::uno::Reference< css::frame::XModel > m_xModel
Definition: pdfiadaptor.hxx:55
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: pdfiadaptor.hxx:88
OUString SAL_CALL getImplementationName() override
Adapts raw pdf import to XImportFilter interface.
Definition: pdfiadaptor.hxx:82
bool parse(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::task::XInteractionHandler > &xIHdl, const OUString &rPwd, const css::uno::Reference< css::task::XStatusIndicator > &xStatus, const XmlEmitterSharedPtr &rEmitter, const OUString &rURL, const OUString &rFilterOptions)
std::shared_ptr< XmlEmitter > XmlEmitterSharedPtr
Definition: xmlemitter.hxx:48
PDFIRawAdaptor(OUString const &implementationName, const css::uno::Reference< css::uno::XComponentContext > &xContext)
OUString const m_implementationName
Definition: pdfiadaptor.hxx:86
unsigned char sal_Bool
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString SAL_CALL getImplementationName() override
TreeVisitorFactorySharedPtr m_pVisitorFactory
Definition: pdfiadaptor.hxx:91
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDocument) override
::cppu::WeakComponentImplHelper< css::xml::XImportFilter, css::document::XImporter, css::lang::XServiceInfo > PDFIAdaptorBase
Definition: pdfiadaptor.hxx:78
void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr &rVisitorFactory)
Set factory object used to create the tree visitors.
bool odfConvert(const OUString &rURL, const css::uno::Reference< css::io::XOutputStream > &xOutput, const css::uno::Reference< css::task::XStatusIndicator > &xStatus)
Export pdf document to ODG.
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &rFilterData) override
Definition: pdfiadaptor.cxx:53
css::uno::Reference< css::frame::XModel > m_xModel
Definition: pdfiadaptor.hxx:90
virtual void SAL_CALL cancel() override
PDFIHybridAdaptor(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: pdfiadaptor.cxx:45
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDocument) override