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 // @@@ Adjust multi-include-protection-ifdef.
29*cdf0e10cSrcweir #ifndef _MYUCP_CONTENT_HXX
30*cdf0e10cSrcweir #define _MYUCP_CONTENT_HXX
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <list>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "rtl/ref.hxx"
35*cdf0e10cSrcweir #include "ucbhelper/contenthelper.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans {
38*cdf0e10cSrcweir 	struct Property;
39*cdf0e10cSrcweir 	struct PropertyValue;
40*cdf0e10cSrcweir } } } }
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sdbc {
43*cdf0e10cSrcweir 	class XRow;
44*cdf0e10cSrcweir } } } }
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace io {
47*cdf0e10cSrcweir 	class XInputStream;
48*cdf0e10cSrcweir } } } }
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir // @@@ Adjust namespace name.
51*cdf0e10cSrcweir namespace myucp
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //=========================================================================
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir // @@@ Adjust service name.
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir // UNO service name for the content. Prefix with reversed company domain main.
59*cdf0e10cSrcweir #define MYUCP_CONTENT_SERVICE_NAME "com.sun.star.ucb.MyContent"
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir //=========================================================================
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir struct ContentProperties
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	::rtl::OUString aTitle;    		// Title
66*cdf0e10cSrcweir 	::rtl::OUString aContentType;	// ContentType
67*cdf0e10cSrcweir 	sal_Bool        bIsDocument;    // IsDocument
68*cdf0e10cSrcweir 	sal_Bool        bIsFolder;    	// IsFolder
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	// @@@ Add other properties supported by your content.
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 	ContentProperties()
73*cdf0e10cSrcweir 	: bIsDocument( sal_True ), bIsFolder( sal_False ) {}
74*cdf0e10cSrcweir };
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir //=========================================================================
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir class Content : public ::ucbhelper::ContentImplHelper
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	ContentProperties m_aProps;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir private:
83*cdf0e10cSrcweir 	virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
84*cdf0e10cSrcweir 	getProperties( const com::sun::star::uno::Reference<
85*cdf0e10cSrcweir 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
86*cdf0e10cSrcweir 	virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
87*cdf0e10cSrcweir 	getCommands( const com::sun::star::uno::Reference<
88*cdf0e10cSrcweir 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
89*cdf0e10cSrcweir     virtual ::rtl::OUString getParentURL();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
92*cdf0e10cSrcweir 	getPropertyValues( const ::com::sun::star::uno::Sequence<
93*cdf0e10cSrcweir                         ::com::sun::star::beans::Property >& rProperties,
94*cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
95*cdf0e10cSrcweir 						::com::sun::star::ucb::XCommandEnvironment >& xEnv );
96*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
97*cdf0e10cSrcweir     setPropertyValues( const ::com::sun::star::uno::Sequence<
98*cdf0e10cSrcweir                         ::com::sun::star::beans::PropertyValue >& rValues,
99*cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
100*cdf0e10cSrcweir                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir #define IMPLEMENT_COMMAND_OPEN
103*cdf0e10cSrcweir #define IMPLEMENT_COMMAND_INSERT
104*cdf0e10cSrcweir #define IMPLEMENT_COMMAND_DELETE
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT
107*cdf0e10cSrcweir     typedef rtl::Reference< Content > ContentRef;
108*cdf0e10cSrcweir     typedef std::list< ContentRef > ContentRefList;
109*cdf0e10cSrcweir     void queryChildren( ContentRefList& rChildren );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     // Command "insert"
112*cdf0e10cSrcweir     void insert( const ::com::sun::star::uno::Reference<
113*cdf0e10cSrcweir                  ::com::sun::star::io::XInputStream > & xInputStream,
114*cdf0e10cSrcweir                  sal_Bool bReplaceExisting,
115*cdf0e10cSrcweir                  const com::sun::star::uno::Reference<
116*cdf0e10cSrcweir                  com::sun::star::ucb::XCommandEnvironment >& Environment )
117*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
118*cdf0e10cSrcweir #endif
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     // Command "delete"
123*cdf0e10cSrcweir 	void destroy( sal_Bool bDeletePhysical )
124*cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
125*cdf0e10cSrcweir #endif
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir public:
128*cdf0e10cSrcweir 	Content( const ::com::sun::star::uno::Reference<
129*cdf0e10cSrcweir 				::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
130*cdf0e10cSrcweir 			 ::ucbhelper::ContentProviderImplHelper* pProvider,
131*cdf0e10cSrcweir 			 const ::com::sun::star::uno::Reference<
132*cdf0e10cSrcweir 				::com::sun::star::ucb::XContentIdentifier >& Identifier );
133*cdf0e10cSrcweir 	virtual ~Content();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	// XInterface
136*cdf0e10cSrcweir 	XINTERFACE_DECL()
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 	// XTypeProvider
139*cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     // XServiceInfo
142*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL
143*cdf0e10cSrcweir 	getImplementationName()
144*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
145*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
146*cdf0e10cSrcweir 	getSupportedServiceNames()
147*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	// XContent
150*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL
151*cdf0e10cSrcweir 	getContentType()
152*cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	// XCommandProcessor
155*cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
156*cdf0e10cSrcweir 	execute( const com::sun::star::ucb::Command& aCommand,
157*cdf0e10cSrcweir 			 sal_Int32 CommandId,
158*cdf0e10cSrcweir 			 const com::sun::star::uno::Reference<
159*cdf0e10cSrcweir 			 	com::sun::star::ucb::XCommandEnvironment >& Environment )
160*cdf0e10cSrcweir     	throw( com::sun::star::uno::Exception,
161*cdf0e10cSrcweir 			   com::sun::star::ucb::CommandAbortedException,
162*cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
163*cdf0e10cSrcweir     virtual void SAL_CALL
164*cdf0e10cSrcweir 	abort( sal_Int32 CommandId )
165*cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
168*cdf0e10cSrcweir 	// Additional interfaces
169*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	// @@@ Add additional interfaces ( like com::sun::star::ucb::XContentCreator ).
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
174*cdf0e10cSrcweir 	// Non-interface methods.
175*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	// Called from resultset data supplier.
178*cdf0e10cSrcweir 	static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
179*cdf0e10cSrcweir 	getPropertyValues( const ::com::sun::star::uno::Reference<
180*cdf0e10cSrcweir 						::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
181*cdf0e10cSrcweir 					   const ::com::sun::star::uno::Sequence<
182*cdf0e10cSrcweir 					   	::com::sun::star::beans::Property >& rProperties,
183*cdf0e10cSrcweir 					   const ContentProperties& rData,
184*cdf0e10cSrcweir                        const rtl::Reference<
185*cdf0e10cSrcweir 					   	::ucbhelper::ContentProviderImplHelper >& rProvider,
186*cdf0e10cSrcweir                        const ::rtl::OUString& rContentId );
187*cdf0e10cSrcweir };
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir #endif
192