1*06bcd5d2SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06bcd5d2SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06bcd5d2SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06bcd5d2SAndrew Rist * distributed with this work for additional information 6*06bcd5d2SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06bcd5d2SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06bcd5d2SAndrew Rist * "License"); you may not use this file except in compliance 9*06bcd5d2SAndrew Rist * with the License. You may obtain a copy of the License at 10*06bcd5d2SAndrew Rist * 11*06bcd5d2SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*06bcd5d2SAndrew Rist * 13*06bcd5d2SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06bcd5d2SAndrew Rist * software distributed under the License is distributed on an 15*06bcd5d2SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06bcd5d2SAndrew Rist * KIND, either express or implied. See the License for the 17*06bcd5d2SAndrew Rist * specific language governing permissions and limitations 18*06bcd5d2SAndrew Rist * under the License. 19*06bcd5d2SAndrew Rist * 20*06bcd5d2SAndrew Rist *************************************************************/ 21*06bcd5d2SAndrew Rist 22*06bcd5d2SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_PDFIADAPTOR_HXX 25cdf0e10cSrcweir #define INCLUDED_PDFIADAPTOR_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "xmlemitter.hxx" 28cdf0e10cSrcweir #include "treevisitorfactory.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/xml/XImportFilter.hpp> 31cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 32cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 33cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp> 34cdf0e10cSrcweir #include <com/sun/star/document/XFilter.hpp> 35cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 36cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 37cdf0e10cSrcweir #include <com/sun/star/document/XImporter.hpp> 38cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 41cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace pdfi 45cdf0e10cSrcweir { 46cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< 47cdf0e10cSrcweir com::sun::star::document::XFilter, 48cdf0e10cSrcweir com::sun::star::document::XImporter > PDFIHybridAdaptorBase; 49cdf0e10cSrcweir 50cdf0e10cSrcweir class PDFIHybridAdaptor : private cppu::BaseMutex, 51cdf0e10cSrcweir public PDFIHybridAdaptorBase 52cdf0e10cSrcweir { 53cdf0e10cSrcweir private: 54cdf0e10cSrcweir com::sun::star::uno::Reference< 55cdf0e10cSrcweir com::sun::star::uno::XComponentContext > m_xContext; 56cdf0e10cSrcweir com::sun::star::uno::Reference< 57cdf0e10cSrcweir com::sun::star::frame::XModel > m_xModel; 58cdf0e10cSrcweir 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir explicit PDFIHybridAdaptor( const ::com::sun::star::uno::Reference< 61cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& xContext ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir // XFilter 64cdf0e10cSrcweir virtual sal_Bool SAL_CALL filter( const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rFilterData ) throw(com::sun::star::uno::RuntimeException); 65cdf0e10cSrcweir virtual void SAL_CALL cancel() throw(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // XImporter 68cdf0e10cSrcweir virtual void SAL_CALL setTargetDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDocument ) 69cdf0e10cSrcweir throw( com::sun::star::lang::IllegalArgumentException ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir 73cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< 74cdf0e10cSrcweir com::sun::star::xml::XImportFilter, 75cdf0e10cSrcweir com::sun::star::document::XImporter > PDFIAdaptorBase; 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Adapts raw pdf import to XImportFilter interface 78cdf0e10cSrcweir */ 79cdf0e10cSrcweir class PDFIRawAdaptor : private cppu::BaseMutex, 80cdf0e10cSrcweir public PDFIAdaptorBase 81cdf0e10cSrcweir { 82cdf0e10cSrcweir private: 83cdf0e10cSrcweir com::sun::star::uno::Reference< 84cdf0e10cSrcweir com::sun::star::uno::XComponentContext > m_xContext; 85cdf0e10cSrcweir com::sun::star::uno::Reference< 86cdf0e10cSrcweir com::sun::star::frame::XModel > m_xModel; 87cdf0e10cSrcweir TreeVisitorFactorySharedPtr m_pVisitorFactory; 88cdf0e10cSrcweir bool m_bEnableToplevelText; 89cdf0e10cSrcweir 90cdf0e10cSrcweir bool parse( const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInput, 91cdf0e10cSrcweir const com::sun::star::uno::Reference<com::sun::star::task::XInteractionHandler>& xIHdl, 92cdf0e10cSrcweir const rtl::OUString& rPwd, 93cdf0e10cSrcweir const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& xStatus, 94cdf0e10cSrcweir const XmlEmitterSharedPtr& rEmitter, 95cdf0e10cSrcweir const rtl::OUString& rURL ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir public: 98cdf0e10cSrcweir explicit PDFIRawAdaptor( const ::com::sun::star::uno::Reference< 99cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& xContext ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Set factory object used to create the tree visitors 102cdf0e10cSrcweir 103cdf0e10cSrcweir Used for customizing the tree to the specific output 104cdf0e10cSrcweir format (writer, draw, etc) 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir void setTreeVisitorFactory(const TreeVisitorFactorySharedPtr& rVisitorFactory); 107cdf0e10cSrcweir 108cdf0e10cSrcweir /// TEMP - enable writer-like text:p on doc level enableToplevelText()109cdf0e10cSrcweir void enableToplevelText() { m_bEnableToplevelText=true; } 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** Export pdf document to ODG 112cdf0e10cSrcweir 113cdf0e10cSrcweir @param xOutput 114cdf0e10cSrcweir Stream to write the flat xml file to 115cdf0e10cSrcweir 116cdf0e10cSrcweir @param xStatus 117cdf0e10cSrcweir Optional status indicator 118cdf0e10cSrcweir */ 119cdf0e10cSrcweir bool odfConvert( const rtl::OUString& rURL, 120cdf0e10cSrcweir const com::sun::star::uno::Reference<com::sun::star::io::XOutputStream>& xOutput, 121cdf0e10cSrcweir const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& xStatus ); 122cdf0e10cSrcweir 123cdf0e10cSrcweir // XImportFilter 124cdf0e10cSrcweir virtual sal_Bool SAL_CALL importer( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rSourceData, 125cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& rHdl, 126cdf0e10cSrcweir const com::sun::star::uno::Sequence< rtl::OUString >& rUserData ) throw( com::sun::star::uno::RuntimeException ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // XImporter 129cdf0e10cSrcweir virtual void SAL_CALL setTargetDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDocument ) 130cdf0e10cSrcweir throw( com::sun::star::lang::IllegalArgumentException ); 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir #endif 135