Update ooo320-m1
[ooovba.git] / ucb / source / ucp / package / pkgcontentcaps.cxx
blob6e6e4a9123ce8f23d6c15b3b009802332a358beb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pkgcontentcaps.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 /**************************************************************************
35 TODO
36 **************************************************************************
38 Props/Commands:
40 rootfolder folder stream
41 ---------------------------------------------
42 ContentType r r r
43 IsDocument r r r
44 IsFolder r r r
45 MediaType (w) (w) w
46 Title r w w
47 Size - - r
48 Compressed - - w
49 Encrypted - - w
50 HasEncryptedEntries r - -
52 getCommandInfo x x x
53 getPropertySetInfo x x x
54 getPropertyValues x x x
55 setPropertyValues x x x
56 insert - x x
57 delete - x x
58 open x x x
59 transfer x x -
60 flush x x -
62 *************************************************************************/
63 #include <com/sun/star/beans/Property.hpp>
64 #include <com/sun/star/beans/PropertyAttribute.hpp>
65 #include <com/sun/star/beans/PropertyValue.hpp>
66 #include <com/sun/star/ucb/CommandInfo.hpp>
67 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
68 #include <com/sun/star/ucb/TransferInfo.hpp>
69 #include <com/sun/star/uno/Sequence.hxx>
70 #include "pkgcontent.hxx"
72 using namespace com::sun::star;
73 using namespace package_ucp;
75 //=========================================================================
77 // Content implementation.
79 //=========================================================================
81 //=========================================================================
83 // IMPORTENT: If any property data ( name / type / ... ) are changed, then
84 // Content::getPropertyValues(...) must be adapted too!
86 //=========================================================================
88 // virtual
89 uno::Sequence< beans::Property > Content::getProperties(
90 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
92 osl::Guard< osl::Mutex > aGuard( m_aMutex );
94 if ( isFolder() )
96 if ( m_aUri.isRootFolder() )
98 //=================================================================
100 // Root Folder: Supported properties
102 //=================================================================
104 static const beans::Property aRootFolderPropertyInfoTable[] =
106 ///////////////////////////////////////////////////////////////
107 // Required properties
108 ///////////////////////////////////////////////////////////////
109 beans::Property(
110 rtl::OUString(
111 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
113 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
114 beans::PropertyAttribute::BOUND
115 | beans::PropertyAttribute::READONLY
117 beans::Property(
118 rtl::OUString(
119 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
121 getCppuBooleanType(),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::READONLY
125 beans::Property(
126 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
128 getCppuBooleanType(),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::READONLY
132 beans::Property(
133 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
135 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::READONLY
139 ///////////////////////////////////////////////////////////////
140 // Optional standard properties
141 ///////////////////////////////////////////////////////////////
142 beans::Property(
143 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
145 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
146 beans::PropertyAttribute::BOUND
148 ///////////////////////////////////////////////////////////////
149 // New properties
150 ///////////////////////////////////////////////////////////////
151 beans::Property(
152 rtl::OUString(
153 RTL_CONSTASCII_USTRINGPARAM( "HasEncryptedEntries" ) ),
155 getCppuBooleanType(),
156 beans::PropertyAttribute::BOUND
157 | beans::PropertyAttribute::READONLY
160 return uno::Sequence< beans::Property >(
161 aRootFolderPropertyInfoTable, 6 );
163 else
165 //=================================================================
167 // Folder: Supported properties
169 //=================================================================
171 static const beans::Property aFolderPropertyInfoTable[] =
173 ///////////////////////////////////////////////////////////////
174 // Required properties
175 ///////////////////////////////////////////////////////////////
176 beans::Property(
177 rtl::OUString(
178 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
180 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::READONLY
184 beans::Property(
185 rtl::OUString(
186 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
188 getCppuBooleanType(),
189 beans::PropertyAttribute::BOUND
190 | beans::PropertyAttribute::READONLY
192 beans::Property(
193 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
195 getCppuBooleanType(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::READONLY
199 beans::Property(
200 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
202 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
203 beans::PropertyAttribute::BOUND
205 ///////////////////////////////////////////////////////////////
206 // Optional standard properties
207 ///////////////////////////////////////////////////////////////
208 beans::Property(
209 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
211 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
212 beans::PropertyAttribute::BOUND
214 ///////////////////////////////////////////////////////////////
215 // New properties
216 ///////////////////////////////////////////////////////////////
218 return uno::Sequence< beans::Property >(
219 aFolderPropertyInfoTable, 5 );
222 else
224 //=================================================================
226 // Stream: Supported properties
228 //=================================================================
230 static const beans::Property aStreamPropertyInfoTable[] =
232 ///////////////////////////////////////////////////////////////
233 // Required properties
234 ///////////////////////////////////////////////////////////////
235 beans::Property(
236 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
238 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
239 beans::PropertyAttribute::BOUND
240 | beans::PropertyAttribute::READONLY
242 beans::Property(
243 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
245 getCppuBooleanType(),
246 beans::PropertyAttribute::BOUND
247 | beans::PropertyAttribute::READONLY
249 beans::Property(
250 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
252 getCppuBooleanType(),
253 beans::PropertyAttribute::BOUND
254 | beans::PropertyAttribute::READONLY
256 beans::Property(
257 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
259 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
260 beans::PropertyAttribute::BOUND
262 ///////////////////////////////////////////////////////////////
263 // Optional standard properties
264 ///////////////////////////////////////////////////////////////
265 beans::Property(
266 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
268 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
269 beans::PropertyAttribute::BOUND
271 beans::Property(
272 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
274 getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
275 beans::PropertyAttribute::BOUND
276 | beans::PropertyAttribute::READONLY
278 ///////////////////////////////////////////////////////////////
279 // New properties
280 ///////////////////////////////////////////////////////////////
281 beans::Property(
282 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ),
284 getCppuBooleanType(),
285 beans::PropertyAttribute::BOUND
287 beans::Property(
288 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Encrypted" ) ),
290 getCppuBooleanType(),
291 beans::PropertyAttribute::BOUND
294 return uno::Sequence< beans::Property >( aStreamPropertyInfoTable, 8 );
298 //=========================================================================
299 // virtual
300 uno::Sequence< ucb::CommandInfo > Content::getCommands(
301 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
303 osl::Guard< osl::Mutex > aGuard( m_aMutex );
305 if ( isFolder() )
307 if ( m_aUri.isRootFolder() )
309 //=================================================================
311 // Root Folder: Supported commands
313 //=================================================================
315 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
317 ///////////////////////////////////////////////////////////
318 // Required commands
319 ///////////////////////////////////////////////////////////
320 ucb::CommandInfo(
321 rtl::OUString(
322 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
324 getCppuVoidType()
326 ucb::CommandInfo(
327 rtl::OUString(
328 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
330 getCppuVoidType()
332 ucb::CommandInfo(
333 rtl::OUString(
334 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
336 getCppuType(
337 static_cast<
338 uno::Sequence< beans::Property > * >( 0 ) )
340 ucb::CommandInfo(
341 rtl::OUString(
342 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
344 getCppuType(
345 static_cast<
346 uno::Sequence< beans::PropertyValue > * >( 0 ) )
348 ///////////////////////////////////////////////////////////
349 // Optional standard commands
350 ///////////////////////////////////////////////////////////
351 ucb::CommandInfo(
352 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
354 getCppuType(
355 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
357 ucb::CommandInfo(
358 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
360 getCppuType(
361 static_cast< ucb::TransferInfo * >( 0 ) )
363 ///////////////////////////////////////////////////////////
364 // New commands
365 ///////////////////////////////////////////////////////////
366 ucb::CommandInfo(
367 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flush" ) ),
369 getCppuVoidType()
373 return uno::Sequence<
374 ucb::CommandInfo >( aRootFolderCommandInfoTable, 7 );
376 else
378 //=================================================================
380 // Folder: Supported commands
382 //=================================================================
384 static const ucb::CommandInfo aFolderCommandInfoTable[] =
386 ///////////////////////////////////////////////////////////
387 // Required commands
388 ///////////////////////////////////////////////////////////
389 ucb::CommandInfo(
390 rtl::OUString(
391 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
393 getCppuVoidType()
395 ucb::CommandInfo(
396 rtl::OUString(
397 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
399 getCppuVoidType()
401 ucb::CommandInfo(
402 rtl::OUString(
403 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
405 getCppuType(
406 static_cast<
407 uno::Sequence< beans::Property > * >( 0 ) )
409 ucb::CommandInfo(
410 rtl::OUString(
411 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
413 getCppuType(
414 static_cast<
415 uno::Sequence< beans::PropertyValue > * >( 0 ) )
417 ///////////////////////////////////////////////////////////
418 // Optional standard commands
419 ///////////////////////////////////////////////////////////
420 ucb::CommandInfo(
421 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
423 getCppuBooleanType()
425 ucb::CommandInfo(
426 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
428 getCppuVoidType()
430 ucb::CommandInfo(
431 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
433 getCppuType(
434 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
436 ucb::CommandInfo(
437 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
439 getCppuType(
440 static_cast< ucb::TransferInfo * >( 0 ) )
442 ///////////////////////////////////////////////////////////
443 // New commands
444 ///////////////////////////////////////////////////////////
445 ucb::CommandInfo(
446 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flush" ) ),
448 getCppuVoidType()
452 return uno::Sequence<
453 ucb::CommandInfo >( aFolderCommandInfoTable, 9 );
456 else
458 //=================================================================
460 // Stream: Supported commands
462 //=================================================================
464 static const ucb::CommandInfo aStreamCommandInfoTable[] =
466 ///////////////////////////////////////////////////////////////
467 // Required commands
468 ///////////////////////////////////////////////////////////////
469 ucb::CommandInfo(
470 rtl::OUString(
471 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
473 getCppuVoidType()
475 ucb::CommandInfo(
476 rtl::OUString(
477 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
479 getCppuVoidType()
481 ucb::CommandInfo(
482 rtl::OUString(
483 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
485 getCppuType(
486 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
488 ucb::CommandInfo(
489 rtl::OUString(
490 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
492 getCppuType(
493 static_cast<
494 uno::Sequence< beans::PropertyValue > * >( 0 ) )
496 ///////////////////////////////////////////////////////////////
497 // Optional standard commands
498 ///////////////////////////////////////////////////////////////
499 ucb::CommandInfo(
500 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
502 getCppuBooleanType()
504 ucb::CommandInfo(
505 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
507 getCppuVoidType()
509 ucb::CommandInfo(
510 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
512 getCppuType(
513 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
515 ///////////////////////////////////////////////////////////////
516 // New commands
517 ///////////////////////////////////////////////////////////////
520 return uno::Sequence< ucb::CommandInfo >(
521 aStreamCommandInfoTable, 7 );