Updated core
[LibreOffice.git] / sdext / source / pdfimport / pdfiadaptor.hxx
blobc41cb29546024f58bdfdeadb2426d6a554e0836f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_PDFIADAPTOR_HXX
21 #define INCLUDED_PDFIADAPTOR_HXX
23 #include "xmlemitter.hxx"
24 #include "treevisitorfactory.hxx"
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>
36 #include <cppuhelper/compbase2.hxx>
37 #include <cppuhelper/basemutex.hxx>
40 namespace pdfi
42 typedef ::cppu::WeakComponentImplHelper2<
43 com::sun::star::document::XFilter,
44 com::sun::star::document::XImporter > PDFIHybridAdaptorBase;
46 class PDFIHybridAdaptor : private cppu::BaseMutex,
47 public PDFIHybridAdaptorBase
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;
55 public:
56 explicit PDFIHybridAdaptor( const ::com::sun::star::uno::Reference<
57 ::com::sun::star::uno::XComponentContext >& xContext );
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();
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 );
69 typedef ::cppu::WeakComponentImplHelper2<
70 com::sun::star::xml::XImportFilter,
71 com::sun::star::document::XImporter > PDFIAdaptorBase;
73 /** Adapts raw pdf import to XImportFilter interface
75 class PDFIRawAdaptor : private cppu::BaseMutex,
76 public PDFIAdaptorBase
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;
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 OUString& rPwd,
89 const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& xStatus,
90 const XmlEmitterSharedPtr& rEmitter,
91 const OUString& rURL );
93 public:
94 explicit PDFIRawAdaptor( const ::com::sun::star::uno::Reference<
95 ::com::sun::star::uno::XComponentContext >& xContext );
97 /** Set factory object used to create the tree visitors
99 Used for customizing the tree to the specific output
100 format (writer, draw, etc)
102 void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr& rVisitorFactory);
104 /// TEMP - enable writer-like text:p on doc level
105 void enableToplevelText() { m_bEnableToplevelText=true; }
107 /** Export pdf document to ODG
109 @param xOutput
110 Stream to write the flat xml file to
112 @param xStatus
113 Optional status indicator
115 bool odfConvert( const 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 );
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< OUString >& rUserData ) throw( com::sun::star::uno::RuntimeException );
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 );
130 #endif
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */