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 INCLUDED_TDOC_PROVIDER_HXX 25 #define INCLUDED_TDOC_PROVIDER_HXX 26 27 #include "rtl/ref.hxx" 28 #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp> 29 #include <com/sun/star/packages/WrongPasswordException.hpp> 30 #include "ucbhelper/providerhelper.hxx" 31 #include "tdoc_uri.hxx" // for TDOC_URL_SCHEME 32 #include "tdoc_docmgr.hxx" 33 #include "tdoc_storage.hxx" // for StorageAccessMode 34 35 namespace com { namespace sun { namespace star { namespace embed { 36 class XStorage; 37 } } } } 38 39 namespace com { namespace sun { namespace star { namespace frame { 40 class XModel; 41 } } } } 42 43 namespace tdoc_ucp { 44 45 //========================================================================= 46 47 #define TDOC_CONTENT_PROVIDER_SERVICE_NAME \ 48 "com.sun.star.ucb.TransientDocumentsContentProvider" 49 #define TDOC_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 50 50 51 #define TDOC_ROOT_CONTENT_TYPE \ 52 "application/" TDOC_URL_SCHEME "-root" 53 #define TDOC_DOCUMENT_CONTENT_TYPE \ 54 "application/" TDOC_URL_SCHEME "-document" 55 #define TDOC_FOLDER_CONTENT_TYPE \ 56 "application/" TDOC_URL_SCHEME "-folder" 57 #define TDOC_STREAM_CONTENT_TYPE \ 58 "application/" TDOC_URL_SCHEME "-stream" 59 60 //========================================================================= 61 62 class StorageElementFactory; 63 64 class ContentProvider : 65 public ::ucbhelper::ContentProviderImplHelper, 66 public com::sun::star::frame::XTransientDocumentsDocumentContentFactory, 67 public OfficeDocumentsEventListener 68 { 69 public: 70 ContentProvider( const com::sun::star::uno::Reference< 71 com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); 72 virtual ~ContentProvider(); 73 74 // XInterface 75 XINTERFACE_DECL() 76 77 // XTypeProvider 78 XTYPEPROVIDER_DECL() 79 80 // XServiceInfo 81 XSERVICEINFO_DECL() 82 83 // XContentProvider 84 virtual com::sun::star::uno::Reference< 85 com::sun::star::ucb::XContent > SAL_CALL 86 queryContent( const com::sun::star::uno::Reference< 87 com::sun::star::ucb::XContentIdentifier >& Identifier ); 88 89 // XTransientDocumentsDocumentContentFactory 90 virtual com::sun::star::uno::Reference< 91 com::sun::star::ucb::XContent > SAL_CALL 92 createDocumentContent( const ::com::sun::star::uno::Reference< 93 com::sun::star::frame::XModel >& Model ); 94 95 // Non-UNO interfaces 96 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > 97 queryStorage( const rtl::OUString & rUri, StorageAccessMode eMode ) const; 98 99 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > 100 queryStorageClone( const rtl::OUString & rUri ) const; 101 102 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 103 queryInputStream( const rtl::OUString & rUri, 104 const rtl::OUString & rPassword ) const; 105 106 com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > 107 queryOutputStream( const rtl::OUString & rUri, 108 const rtl::OUString & rPassword, 109 bool bTruncate ) const; 110 111 com::sun::star::uno::Reference< com::sun::star::io::XStream > 112 queryStream( const rtl::OUString & rUri, 113 const rtl::OUString & rPassword, 114 bool bTruncate ) const; 115 116 bool queryNamesOfChildren( 117 const rtl::OUString & rUri, 118 com::sun::star::uno::Sequence< rtl::OUString > & rNames ) const; 119 120 // storage properties 121 rtl::OUString queryStorageTitle( const rtl::OUString & rUri ) const; 122 123 com::sun::star::uno::Reference< com::sun::star::frame::XModel > 124 queryDocumentModel( const rtl::OUString & rUri ) const; 125 126 // interface OfficeDocumentsEventListener 127 virtual void notifyDocumentOpened( const rtl::OUString & rDocId ); 128 virtual void notifyDocumentClosed( const rtl::OUString & rDocId ); 129 130 private: 131 rtl::Reference< OfficeDocumentsManager > m_xDocsMgr; 132 rtl::Reference< StorageElementFactory > m_xStgElemFac; 133 }; 134 135 } // namespace tdoc_ucp 136 137 #endif /* !INCLUDED_TDOC_PROVIDER_HXX */ 138