1*b3b486c3SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3b486c3SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3b486c3SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3b486c3SAndrew Rist  * distributed with this work for additional information
6*b3b486c3SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3b486c3SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3b486c3SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3b486c3SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3b486c3SAndrew Rist  *
11*b3b486c3SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3b486c3SAndrew Rist  *
13*b3b486c3SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3b486c3SAndrew Rist  * software distributed under the License is distributed on an
15*b3b486c3SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3b486c3SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3b486c3SAndrew Rist  * specific language governing permissions and limitations
18*b3b486c3SAndrew Rist  * under the License.
19*b3b486c3SAndrew Rist  *
20*b3b486c3SAndrew Rist  *************************************************************/
21*b3b486c3SAndrew Rist 
22*b3b486c3SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // @@@ Adjust multi-include-protection-ifdef.
25cdf0e10cSrcweir #ifndef _MYUCP_CONTENT_HXX
26cdf0e10cSrcweir #define _MYUCP_CONTENT_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <list>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "rtl/ref.hxx"
31cdf0e10cSrcweir #include "ucbhelper/contenthelper.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans {
34cdf0e10cSrcweir 	struct Property;
35cdf0e10cSrcweir 	struct PropertyValue;
36cdf0e10cSrcweir } } } }
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sdbc {
39cdf0e10cSrcweir 	class XRow;
40cdf0e10cSrcweir } } } }
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace io {
43cdf0e10cSrcweir 	class XInputStream;
44cdf0e10cSrcweir } } } }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // @@@ Adjust namespace name.
47cdf0e10cSrcweir namespace myucp
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //=========================================================================
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // @@@ Adjust service name.
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // UNO service name for the content. Prefix with reversed company domain main.
55cdf0e10cSrcweir #define MYUCP_CONTENT_SERVICE_NAME "com.sun.star.ucb.MyContent"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //=========================================================================
58cdf0e10cSrcweir 
59cdf0e10cSrcweir struct ContentProperties
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	::rtl::OUString aTitle;    		// Title
62cdf0e10cSrcweir 	::rtl::OUString aContentType;	// ContentType
63cdf0e10cSrcweir 	sal_Bool        bIsDocument;    // IsDocument
64cdf0e10cSrcweir 	sal_Bool        bIsFolder;    	// IsFolder
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	// @@@ Add other properties supported by your content.
67cdf0e10cSrcweir 
ContentPropertiesmyucp::ContentProperties68cdf0e10cSrcweir 	ContentProperties()
69cdf0e10cSrcweir 	: bIsDocument( sal_True ), bIsFolder( sal_False ) {}
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir //=========================================================================
73cdf0e10cSrcweir 
74cdf0e10cSrcweir class Content : public ::ucbhelper::ContentImplHelper
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	ContentProperties m_aProps;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir private:
79cdf0e10cSrcweir 	virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
80cdf0e10cSrcweir 	getProperties( const com::sun::star::uno::Reference<
81cdf0e10cSrcweir 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
82cdf0e10cSrcweir 	virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
83cdf0e10cSrcweir 	getCommands( const com::sun::star::uno::Reference<
84cdf0e10cSrcweir 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
85cdf0e10cSrcweir     virtual ::rtl::OUString getParentURL();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
88cdf0e10cSrcweir 	getPropertyValues( const ::com::sun::star::uno::Sequence<
89cdf0e10cSrcweir                         ::com::sun::star::beans::Property >& rProperties,
90cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
91cdf0e10cSrcweir 						::com::sun::star::ucb::XCommandEnvironment >& xEnv );
92cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
93cdf0e10cSrcweir     setPropertyValues( const ::com::sun::star::uno::Sequence<
94cdf0e10cSrcweir                         ::com::sun::star::beans::PropertyValue >& rValues,
95cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
96cdf0e10cSrcweir                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir #define IMPLEMENT_COMMAND_OPEN
99cdf0e10cSrcweir #define IMPLEMENT_COMMAND_INSERT
100cdf0e10cSrcweir #define IMPLEMENT_COMMAND_DELETE
101cdf0e10cSrcweir 
102cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT
103cdf0e10cSrcweir     typedef rtl::Reference< Content > ContentRef;
104cdf0e10cSrcweir     typedef std::list< ContentRef > ContentRefList;
105cdf0e10cSrcweir     void queryChildren( ContentRefList& rChildren );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     // Command "insert"
108cdf0e10cSrcweir     void insert( const ::com::sun::star::uno::Reference<
109cdf0e10cSrcweir                  ::com::sun::star::io::XInputStream > & xInputStream,
110cdf0e10cSrcweir                  sal_Bool bReplaceExisting,
111cdf0e10cSrcweir                  const com::sun::star::uno::Reference<
112cdf0e10cSrcweir                  com::sun::star::ucb::XCommandEnvironment >& Environment )
113cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
114cdf0e10cSrcweir #endif
115cdf0e10cSrcweir 
116cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     // Command "delete"
119cdf0e10cSrcweir 	void destroy( sal_Bool bDeletePhysical )
120cdf0e10cSrcweir         throw( ::com::sun::star::uno::Exception );
121cdf0e10cSrcweir #endif
122cdf0e10cSrcweir 
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir 	Content( const ::com::sun::star::uno::Reference<
125cdf0e10cSrcweir 				::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
126cdf0e10cSrcweir 			 ::ucbhelper::ContentProviderImplHelper* pProvider,
127cdf0e10cSrcweir 			 const ::com::sun::star::uno::Reference<
128cdf0e10cSrcweir 				::com::sun::star::ucb::XContentIdentifier >& Identifier );
129cdf0e10cSrcweir 	virtual ~Content();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	// XInterface
132cdf0e10cSrcweir 	XINTERFACE_DECL()
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	// XTypeProvider
135cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     // XServiceInfo
138cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL
139cdf0e10cSrcweir 	getImplementationName()
140cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
141cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
142cdf0e10cSrcweir 	getSupportedServiceNames()
143cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	// XContent
146cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL
147cdf0e10cSrcweir 	getContentType()
148cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	// XCommandProcessor
151cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
152cdf0e10cSrcweir 	execute( const com::sun::star::ucb::Command& aCommand,
153cdf0e10cSrcweir 			 sal_Int32 CommandId,
154cdf0e10cSrcweir 			 const com::sun::star::uno::Reference<
155cdf0e10cSrcweir 			 	com::sun::star::ucb::XCommandEnvironment >& Environment )
156cdf0e10cSrcweir     	throw( com::sun::star::uno::Exception,
157cdf0e10cSrcweir 			   com::sun::star::ucb::CommandAbortedException,
158cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
159cdf0e10cSrcweir     virtual void SAL_CALL
160cdf0e10cSrcweir 	abort( sal_Int32 CommandId )
161cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
164cdf0e10cSrcweir 	// Additional interfaces
165cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	// @@@ Add additional interfaces ( like com::sun::star::ucb::XContentCreator ).
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
170cdf0e10cSrcweir 	// Non-interface methods.
171cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	// Called from resultset data supplier.
174cdf0e10cSrcweir 	static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
175cdf0e10cSrcweir 	getPropertyValues( const ::com::sun::star::uno::Reference<
176cdf0e10cSrcweir 						::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
177cdf0e10cSrcweir 					   const ::com::sun::star::uno::Sequence<
178cdf0e10cSrcweir 					   	::com::sun::star::beans::Property >& rProperties,
179cdf0e10cSrcweir 					   const ContentProperties& rData,
180cdf0e10cSrcweir                        const rtl::Reference<
181cdf0e10cSrcweir 					   	::ucbhelper::ContentProviderImplHelper >& rProvider,
182cdf0e10cSrcweir                        const ::rtl::OUString& rContentId );
183cdf0e10cSrcweir };
184cdf0e10cSrcweir 
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir #endif
188