1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __OWNVIEW_HXX_
25 #define __OWNVIEW_HXX_
26 
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/util/XCloseListener.hpp>
29 #include <com/sun/star/document/XEventListener.hpp>
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/io/XStream.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <cppuhelper/implbase2.hxx>
34 
35 #include <osl/mutex.hxx>
36 
37 class OwnView_Impl : public ::cppu::WeakImplHelper2 < ::com::sun::star::util::XCloseListener,
38 													  ::com::sun::star::document::XEventListener >
39 {
40 	::osl::Mutex m_aMutex;
41 
42 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
43 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
44 
45 	::rtl::OUString m_aTempFileURL;
46 	::rtl::OUString m_aNativeTempURL;
47 
48 	::rtl::OUString m_aFilterName;
49 
50 	sal_Bool m_bBusy;
51 
52 	sal_Bool m_bUseNative;
53 
54 private:
55 	sal_Bool CreateModelFromURL( const ::rtl::OUString& aFileURL );
56 
57 	sal_Bool CreateModel( sal_Bool bUseNative );
58 
59 	sal_Bool ReadContentsAndGenerateTempFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream, sal_Bool bParseHeader );
60 
61 	void CreateNative();
62 
63 public:
64     static ::rtl::OUString GetFilterNameFromExtentionAndInStream(
65                                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
66                                 const ::rtl::OUString& aNameWithExtention,
67                                 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInputStream );
68 
69 	OwnView_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
70 				  const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream );
71 	virtual ~OwnView_Impl();
72 
73 	sal_Bool Open();
74 
75 	void Close();
76 
77     virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
78 
79     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);
80     virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
81 
82     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
83 };
84 
85 #endif
86 
87