1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_ucb.hxx"
30 
31 /**************************************************************************
32 								TODO
33  **************************************************************************
34 
35  *************************************************************************/
36 #include <com/sun/star/beans/Property.hpp>
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/ucb/CommandInfo.hpp>
40 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
41 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
42 #include <com/sun/star/uno/Sequence.hxx>
43 #include <com/sun/star/util/DateTime.hpp>
44 #include <com/sun/star/ucb/TransferInfo.hpp>
45 #include "odma_content.hxx"
46 
47 using namespace com::sun::star;
48 using namespace odma;
49 
50 //=========================================================================
51 //
52 // Content implementation.
53 //
54 //=========================================================================
55 
56 //=========================================================================
57 //
58 // IMPORTENT: If any property data ( name / type / ... ) are changed, then
59 //            Content::getPropertyValues(...) must be adapted too!
60 //
61 //=========================================================================
62 
63 // virtual
64 uno::Sequence< beans::Property > Content::getProperties(
65     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
66 {
67 	// @@@ Add additional properties...
68 
69 	// @@@ Note: If your data source supports adding/removing properties,
70 	//           you should implement the interface XPropertyContainer
71 	//           by yourself and supply your own logic here. The base class
72 	//           uses the service "com.sun.star.ucb.Store" to maintain
73 	//           Additional Core properties. But using server functionality
74 	//           is preferred! In fact you should return a table conatining
75 	//           even that dynamicly added properties.
76 
77 //	osl::Guard< osl::Mutex > aGuard( m_aMutex );
78 
79 	//=================================================================
80 	//
81 	// Supported properties
82 	//
83 	//=================================================================
84 
85 	#define PROPERTY_COUNT 10
86 
87     static beans::Property aPropertyInfoTable[] =
88 	{
89 		///////////////////////////////////////////////////////////////
90 		// Required properties
91 		///////////////////////////////////////////////////////////////
92         beans::Property(
93             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
94 			-1,
95             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
96             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
97 		),
98         beans::Property(
99             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
100 			-1,
101 			getCppuBooleanType(),
102             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
103 		),
104         beans::Property(
105             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
106 			-1,
107 			getCppuBooleanType(),
108             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
109 		),
110         beans::Property(
111             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
112 			-1,
113             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
114             beans::PropertyAttribute::BOUND
115 		),
116 		///////////////////////////////////////////////////////////////
117 		// Optional standard properties
118 		///////////////////////////////////////////////////////////////
119 		beans::Property(
120             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
121 			-1,
122 			getCppuType(static_cast< const util::DateTime * >( 0 ) ),
123             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
124 		),
125 		beans::Property(
126             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ),
127 			-1,
128 			getCppuType(static_cast< const util::DateTime * >( 0 ) ),
129             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
130 		),
131 		beans::Property(
132             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
133 			-1,
134 			getCppuBooleanType(),
135             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
136 		),
137 		///////////////////////////////////////////////////////////////
138 		// New properties
139 		///////////////////////////////////////////////////////////////
140 		beans::Property(
141             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Author" ) ),
142 			-1,
143             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
144             beans::PropertyAttribute::BOUND
145 		),
146 		beans::Property(
147             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subject" ) ),
148 			-1,
149             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
150             beans::PropertyAttribute::BOUND
151 		),
152 		beans::Property(
153             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Keywords" ) ),
154 			-1,
155             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
156             beans::PropertyAttribute::BOUND
157 		)
158 	};
159     return uno::Sequence<
160             beans::Property >( aPropertyInfoTable, PROPERTY_COUNT );
161 }
162 
163 //=========================================================================
164 // virtual
165 uno::Sequence< ucb::CommandInfo > Content::getCommands(
166     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
167 {
168 	// @@@ Add additional commands...
169 
170 //	osl::Guard< osl::Mutex > aGuard( m_aMutex );
171 
172 	//=================================================================
173 	//
174 	// Supported commands
175 	//
176 	//=================================================================
177 
178 	#define COMMAND_COUNT 8
179 
180     static ucb::CommandInfo aCommandInfoTable[] =
181 	{
182 		///////////////////////////////////////////////////////////////
183 		// Required commands
184 		///////////////////////////////////////////////////////////////
185         ucb::CommandInfo(
186             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
187 			-1,
188 			getCppuVoidType()
189 		),
190         ucb::CommandInfo(
191             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
192 			-1,
193 			getCppuVoidType()
194 		),
195         ucb::CommandInfo(
196             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
197 			-1,
198             getCppuType(
199                 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
200 		),
201         ucb::CommandInfo(
202             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
203 			-1,
204             getCppuType(
205                 static_cast< uno::Sequence< beans::PropertyValue > * >( 0 ) )
206 		),
207 		///////////////////////////////////////////////////////////////
208 		// Optional standard commands
209 		///////////////////////////////////////////////////////////////
210 /*
211         ucb::CommandInfo(
212             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
213 			-1,
214 			getCppuBooleanType()
215 		),
216 */
217         ucb::CommandInfo(
218             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
219 			-1,
220             getCppuType(
221                 static_cast< ucb::InsertCommandArgument * >( 0 ) )
222 		),
223         ucb::CommandInfo(
224             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
225 			-1,
226             getCppuType( static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
227 		),
228 		ucb::CommandInfo(
229             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "close" ) ),
230 			-1,
231             getCppuVoidType( )
232 		),
233 		ucb::CommandInfo(
234             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
235 			-1,
236             getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
237 		)
238 
239 		///////////////////////////////////////////////////////////////
240 		// New commands
241 		///////////////////////////////////////////////////////////////
242 	};
243 
244     return uno::Sequence<
245             ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT );
246 }
247 
248