1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_TDOC_PROVIDER_HXX
29*cdf0e10cSrcweir #define INCLUDED_TDOC_PROVIDER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "rtl/ref.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/packages/WrongPasswordException.hpp>
34*cdf0e10cSrcweir #include "ucbhelper/providerhelper.hxx"
35*cdf0e10cSrcweir #include "tdoc_uri.hxx" // for TDOC_URL_SCHEME
36*cdf0e10cSrcweir #include "tdoc_docmgr.hxx"
37*cdf0e10cSrcweir #include "tdoc_storage.hxx" // for StorageAccessMode
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace embed {
40*cdf0e10cSrcweir     class XStorage;
41*cdf0e10cSrcweir } } } }
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace frame {
44*cdf0e10cSrcweir     class XModel;
45*cdf0e10cSrcweir } } } }
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace tdoc_ucp {
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //=========================================================================
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #define TDOC_CONTENT_PROVIDER_SERVICE_NAME \
52*cdf0e10cSrcweir                 "com.sun.star.ucb.TransientDocumentsContentProvider"
53*cdf0e10cSrcweir #define TDOC_CONTENT_PROVIDER_SERVICE_NAME_LENGTH   50
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #define TDOC_ROOT_CONTENT_TYPE \
56*cdf0e10cSrcweir                 "application/" TDOC_URL_SCHEME "-root"
57*cdf0e10cSrcweir #define TDOC_DOCUMENT_CONTENT_TYPE \
58*cdf0e10cSrcweir                 "application/" TDOC_URL_SCHEME "-document"
59*cdf0e10cSrcweir #define TDOC_FOLDER_CONTENT_TYPE \
60*cdf0e10cSrcweir                 "application/" TDOC_URL_SCHEME "-folder"
61*cdf0e10cSrcweir #define TDOC_STREAM_CONTENT_TYPE \
62*cdf0e10cSrcweir                 "application/" TDOC_URL_SCHEME "-stream"
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir //=========================================================================
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir class StorageElementFactory;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class ContentProvider :
69*cdf0e10cSrcweir     public ::ucbhelper::ContentProviderImplHelper,
70*cdf0e10cSrcweir     public com::sun::star::frame::XTransientDocumentsDocumentContentFactory,
71*cdf0e10cSrcweir     public OfficeDocumentsEventListener
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir public:
74*cdf0e10cSrcweir     ContentProvider( const com::sun::star::uno::Reference<
75*cdf0e10cSrcweir                         com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
76*cdf0e10cSrcweir     virtual ~ContentProvider();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	// XInterface
79*cdf0e10cSrcweir 	XINTERFACE_DECL()
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	// XTypeProvider
82*cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     // XServiceInfo
85*cdf0e10cSrcweir 	XSERVICEINFO_DECL()
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 	// XContentProvider
88*cdf0e10cSrcweir 	virtual com::sun::star::uno::Reference<
89*cdf0e10cSrcweir 				com::sun::star::ucb::XContent > SAL_CALL
90*cdf0e10cSrcweir 	queryContent( const com::sun::star::uno::Reference<
91*cdf0e10cSrcweir 					com::sun::star::ucb::XContentIdentifier >& Identifier )
92*cdf0e10cSrcweir 		throw( com::sun::star::ucb::IllegalIdentifierException,
93*cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     // XTransientDocumentsDocumentContentFactory
96*cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
97*cdf0e10cSrcweir         com::sun::star::ucb::XContent > SAL_CALL
98*cdf0e10cSrcweir     createDocumentContent( const ::com::sun::star::uno::Reference<
99*cdf0e10cSrcweir                                 com::sun::star::frame::XModel >& Model )
100*cdf0e10cSrcweir         throw ( com::sun::star::lang::IllegalArgumentException,
101*cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     // Non-UNO interfaces
104*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
105*cdf0e10cSrcweir     queryStorage( const rtl::OUString & rUri, StorageAccessMode eMode ) const;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
108*cdf0e10cSrcweir     queryStorageClone( const rtl::OUString & rUri ) const;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
111*cdf0e10cSrcweir     queryInputStream( const rtl::OUString & rUri,
112*cdf0e10cSrcweir                       const rtl::OUString & rPassword ) const
113*cdf0e10cSrcweir         throw ( com::sun::star::packages::WrongPasswordException );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >
116*cdf0e10cSrcweir     queryOutputStream( const rtl::OUString & rUri,
117*cdf0e10cSrcweir                        const rtl::OUString & rPassword,
118*cdf0e10cSrcweir                        bool bTruncate ) const
119*cdf0e10cSrcweir         throw ( com::sun::star::packages::WrongPasswordException );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XStream >
122*cdf0e10cSrcweir     queryStream( const rtl::OUString & rUri,
123*cdf0e10cSrcweir                  const rtl::OUString & rPassword,
124*cdf0e10cSrcweir                  bool bTruncate ) const
125*cdf0e10cSrcweir         throw ( com::sun::star::packages::WrongPasswordException );
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     bool queryNamesOfChildren(
128*cdf0e10cSrcweir         const rtl::OUString & rUri,
129*cdf0e10cSrcweir         com::sun::star::uno::Sequence< rtl::OUString > & rNames ) const;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     // storage properties
132*cdf0e10cSrcweir     rtl::OUString queryStorageTitle( const rtl::OUString & rUri ) const;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::frame::XModel >
135*cdf0e10cSrcweir     queryDocumentModel( const rtl::OUString & rUri ) const;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     // interface OfficeDocumentsEventListener
138*cdf0e10cSrcweir     virtual void notifyDocumentOpened( const rtl::OUString & rDocId );
139*cdf0e10cSrcweir     virtual void notifyDocumentClosed( const rtl::OUString & rDocId );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir private:
142*cdf0e10cSrcweir     rtl::Reference< OfficeDocumentsManager > m_xDocsMgr;
143*cdf0e10cSrcweir     rtl::Reference< StorageElementFactory >  m_xStgElemFac;
144*cdf0e10cSrcweir };
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir } // namespace tdoc_ucp
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir #endif /* !INCLUDED_TDOC_PROVIDER_HXX */
149