1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __OWNVIEW_HXX_ 29 #define __OWNVIEW_HXX_ 30 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 #include <com/sun/star/util/XCloseListener.hpp> 33 #include <com/sun/star/document/XEventListener.hpp> 34 #include <com/sun/star/frame/XModel.hpp> 35 #include <com/sun/star/io/XStream.hpp> 36 #include <com/sun/star/io/XInputStream.hpp> 37 #include <cppuhelper/implbase2.hxx> 38 39 #include <osl/mutex.hxx> 40 41 class OwnView_Impl : public ::cppu::WeakImplHelper2 < ::com::sun::star::util::XCloseListener, 42 ::com::sun::star::document::XEventListener > 43 { 44 ::osl::Mutex m_aMutex; 45 46 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 47 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; 48 49 ::rtl::OUString m_aTempFileURL; 50 ::rtl::OUString m_aNativeTempURL; 51 52 ::rtl::OUString m_aFilterName; 53 54 sal_Bool m_bBusy; 55 56 sal_Bool m_bUseNative; 57 58 private: 59 sal_Bool CreateModelFromURL( const ::rtl::OUString& aFileURL ); 60 61 sal_Bool CreateModel( sal_Bool bUseNative ); 62 63 sal_Bool ReadContentsAndGenerateTempFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream, sal_Bool bParseHeader ); 64 65 void CreateNative(); 66 67 public: 68 static ::rtl::OUString GetFilterNameFromExtentionAndInStream( 69 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 70 const ::rtl::OUString& aNameWithExtention, 71 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInputStream ); 72 73 OwnView_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 74 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream ); 75 virtual ~OwnView_Impl(); 76 77 sal_Bool Open(); 78 79 void Close(); 80 81 virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); 82 83 virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, sal_Bool GetsOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException); 84 virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 85 86 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 87 }; 88 89 #endif 90 91