1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pdfiadaptor.hxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef INCLUDED_PDFIADAPTOR_HXX
33 #define INCLUDED_PDFIADAPTOR_HXX
35 #include "xmlemitter.hxx"
36 #include "treevisitorfactory.hxx"
38 #include <com/sun/star/xml/XImportFilter.hpp>
39 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #include <com/sun/star/task/XStatusIndicator.hpp>
42 #include <com/sun/star/document/XFilter.hpp>
43 #include <com/sun/star/io/XInputStream.hpp>
44 #include <com/sun/star/io/XOutputStream.hpp>
45 #include <com/sun/star/document/XImporter.hpp>
46 #include <com/sun/star/frame/XModel.hpp>
48 #include <cppuhelper/compbase2.hxx>
49 #include <cppuhelper/basemutex.hxx>
54 typedef ::cppu::WeakComponentImplHelper2
<
55 com::sun::star::document::XFilter
,
56 com::sun::star::document::XImporter
> PDFIHybridAdaptorBase
;
58 class PDFIHybridAdaptor
: private cppu::BaseMutex
,
59 public PDFIHybridAdaptorBase
62 com::sun::star::uno::Reference
<
63 com::sun::star::uno::XComponentContext
> m_xContext
;
64 com::sun::star::uno::Reference
<
65 com::sun::star::frame::XModel
> m_xModel
;
68 explicit PDFIHybridAdaptor( const ::com::sun::star::uno::Reference
<
69 ::com::sun::star::uno::XComponentContext
>& xContext
);
72 virtual sal_Bool SAL_CALL
filter( const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& rFilterData
) throw(com::sun::star::uno::RuntimeException
);
73 virtual void SAL_CALL
cancel() throw();
76 virtual void SAL_CALL
setTargetDocument( const com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
>& xDocument
)
77 throw( com::sun::star::lang::IllegalArgumentException
);
81 typedef ::cppu::WeakComponentImplHelper2
<
82 com::sun::star::xml::XImportFilter
,
83 com::sun::star::document::XImporter
> PDFIAdaptorBase
;
85 /** Adapts raw pdf import to XImportFilter interface
87 class PDFIRawAdaptor
: private cppu::BaseMutex
,
88 public PDFIAdaptorBase
91 com::sun::star::uno::Reference
<
92 com::sun::star::uno::XComponentContext
> m_xContext
;
93 com::sun::star::uno::Reference
<
94 com::sun::star::frame::XModel
> m_xModel
;
95 TreeVisitorFactorySharedPtr m_pVisitorFactory
;
96 bool m_bEnableToplevelText
;
98 bool parse( const com::sun::star::uno::Reference
<com::sun::star::io::XInputStream
>& xInput
,
99 const com::sun::star::uno::Reference
<com::sun::star::task::XInteractionHandler
>& xIHdl
,
100 const rtl::OUString
& rPwd
,
101 const com::sun::star::uno::Reference
<com::sun::star::task::XStatusIndicator
>& xStatus
,
102 const XmlEmitterSharedPtr
& rEmitter
,
103 const rtl::OUString
& rURL
);
106 explicit PDFIRawAdaptor( const ::com::sun::star::uno::Reference
<
107 ::com::sun::star::uno::XComponentContext
>& xContext
);
109 /** Set factory object used to create the tree visitors
111 Used for customizing the tree to the specific output
112 format (writer, draw, etc)
114 void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr
& rVisitorFactory
);
116 /// TEMP - enable writer-like text:p on doc level
117 void enableToplevelText() { m_bEnableToplevelText
=true; }
119 /** Export pdf document to ODG
122 Stream to write the flat xml file to
125 Optional status indicator
127 bool odfConvert( const rtl::OUString
& rURL
,
128 const com::sun::star::uno::Reference
<com::sun::star::io::XOutputStream
>& xOutput
,
129 const com::sun::star::uno::Reference
<com::sun::star::task::XStatusIndicator
>& xStatus
);
132 virtual sal_Bool SAL_CALL
importer( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& rSourceData
,
133 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
>& rHdl
,
134 const com::sun::star::uno::Sequence
< rtl::OUString
>& rUserData
) throw( com::sun::star::uno::RuntimeException
);
137 virtual void SAL_CALL
setTargetDocument( const com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
>& xDocument
)
138 throw( com::sun::star::lang::IllegalArgumentException
);