Update ooo320-m1
[ooovba.git] / ucb / source / ucp / tdoc / tdoc_contentcaps.cxx
blobb9a1410b554ea51c03b01b83efa5565a48edcf74
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: tdoc_contentcaps.cxx,v $
10 * $Revision: 1.8 $
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 **************************************************************************
40 Props/Commands:
42 root document folder folder stream stream
43 (new) (new)
44 ----------------------------------------------------------------
45 ContentType r r r r r r
46 IsDocument r r r r r r
47 IsFolder r r r r r r
48 Title r r w w w w
49 Storage - - r r - -
50 DocumentModel - r - - - -
52 getCommandInfo x x x x x x
53 getPropertySetInfo x x x x x x
54 getPropertyValues x x x x x x
55 setPropertyValues x x x x x x
56 insert - - x x x(*) x(*)
57 delete - - x - x -
58 open x x x - x -
59 transfer - x x - - -
61 #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
62 (*) not supported by streams that are direct children of document
63 #endif
65 *************************************************************************/
67 #include "com/sun/star/beans/Property.hpp"
68 #include "com/sun/star/beans/PropertyAttribute.hpp"
69 #include "com/sun/star/beans/PropertyValue.hpp"
70 #include "com/sun/star/embed/XStorage.hpp"
71 #include "com/sun/star/frame/XModel.hpp"
72 #include "com/sun/star/ucb/CommandInfo.hpp"
73 #include "com/sun/star/ucb/OpenCommandArgument2.hpp"
74 #include "com/sun/star/ucb/TransferInfo.hpp"
76 #include "tdoc_content.hxx"
78 namespace com { namespace sun { namespace star { namespace embed {
79 class XStorage;
80 } } } }
82 using namespace com::sun::star;
83 using namespace tdoc_ucp;
85 //=========================================================================
87 // Content implementation.
89 //=========================================================================
91 //=========================================================================
93 // IMPORTENT: If any property data ( name / type / ... ) are changed, then
94 // Content::getPropertyValues(...) must be adapted too!
96 //=========================================================================
98 // virtual
99 uno::Sequence< beans::Property > Content::getProperties(
100 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
102 osl::Guard< osl::Mutex > aGuard( m_aMutex );
104 if ( m_aProps.getType() == STREAM )
106 //=================================================================
108 // Stream: Supported properties
110 //=================================================================
112 static const beans::Property aStreamPropertyInfoTable[] =
114 ///////////////////////////////////////////////////////////
115 // Mandatory properties
116 ///////////////////////////////////////////////////////////
117 beans::Property(
118 rtl::OUString(
119 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
121 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::READONLY
125 beans::Property(
126 rtl::OUString(
127 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
129 getCppuBooleanType(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::READONLY
133 beans::Property(
134 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
136 getCppuBooleanType(),
137 beans::PropertyAttribute::BOUND
138 | beans::PropertyAttribute::READONLY
140 beans::Property(
141 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
143 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
144 beans::PropertyAttribute::BOUND
146 ///////////////////////////////////////////////////////////
147 // Optional standard properties
148 ///////////////////////////////////////////////////////////
149 ///////////////////////////////////////////////////////////
150 // New properties
151 ///////////////////////////////////////////////////////////
153 return uno::Sequence< beans::Property >( aStreamPropertyInfoTable, 4 );
155 else if ( m_aProps.getType() == FOLDER )
157 //=================================================================
159 // Folder: Supported properties
161 //=================================================================
163 static const beans::Property aFolderPropertyInfoTable[] =
165 ///////////////////////////////////////////////////////////
166 // Mandatory properties
167 ///////////////////////////////////////////////////////////
168 beans::Property(
169 rtl::OUString(
170 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
172 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
176 beans::Property(
177 rtl::OUString(
178 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
180 getCppuBooleanType(),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::READONLY
184 beans::Property(
185 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
187 getCppuBooleanType(),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::READONLY
191 beans::Property(
192 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
194 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
195 beans::PropertyAttribute::BOUND
197 ///////////////////////////////////////////////////////////
198 // Optional standard properties
199 ///////////////////////////////////////////////////////////
200 ///////////////////////////////////////////////////////////
201 // New properties
202 ///////////////////////////////////////////////////////////
203 beans::Property(
204 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Storage" ) ),
206 getCppuType( static_cast<
207 const uno::Reference< embed::XStorage > * >( 0 ) ),
208 beans::PropertyAttribute::BOUND
209 | beans::PropertyAttribute::READONLY
212 return uno::Sequence< beans::Property >( aFolderPropertyInfoTable, 5 );
214 else if ( m_aProps.getType() == DOCUMENT )
216 //=================================================================
218 // Document: Supported properties
220 //=================================================================
222 static const beans::Property aDocPropertyInfoTable[] =
224 ///////////////////////////////////////////////////////////
225 // Mandatory properties
226 ///////////////////////////////////////////////////////////
227 beans::Property(
228 rtl::OUString(
229 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
231 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
232 beans::PropertyAttribute::BOUND
233 | beans::PropertyAttribute::READONLY
235 beans::Property(
236 rtl::OUString(
237 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
239 getCppuBooleanType(),
240 beans::PropertyAttribute::BOUND
241 | beans::PropertyAttribute::READONLY
243 beans::Property(
244 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
246 getCppuBooleanType(),
247 beans::PropertyAttribute::BOUND
248 | beans::PropertyAttribute::READONLY
250 beans::Property(
251 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
253 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::READONLY
257 ///////////////////////////////////////////////////////////
258 // Optional standard properties
259 ///////////////////////////////////////////////////////////
260 ///////////////////////////////////////////////////////////
261 // New properties
262 ///////////////////////////////////////////////////////////
263 beans::Property(
264 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentModel" ) ),
266 getCppuType( static_cast<
267 const uno::Reference< frame::XModel > * >( 0 ) ),
268 beans::PropertyAttribute::BOUND
269 | beans::PropertyAttribute::READONLY
272 return uno::Sequence< beans::Property >( aDocPropertyInfoTable, 5 );
274 else
276 //=================================================================
278 // Root: Supported properties
280 //=================================================================
282 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
284 static const beans::Property aRootPropertyInfoTable[] =
286 ///////////////////////////////////////////////////////////////
287 // Mandatory properties
288 ///////////////////////////////////////////////////////////////
289 beans::Property(
290 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
292 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
293 beans::PropertyAttribute::BOUND
294 | beans::PropertyAttribute::READONLY
296 beans::Property(
297 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
299 getCppuBooleanType(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
303 beans::Property(
304 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
306 getCppuBooleanType(),
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
310 beans::Property(
311 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
313 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::READONLY
317 ///////////////////////////////////////////////////////////////
318 // Optional standard properties
319 ///////////////////////////////////////////////////////////////
320 ///////////////////////////////////////////////////////////////
321 // New properties
322 ///////////////////////////////////////////////////////////////
324 return uno::Sequence< beans::Property >( aRootPropertyInfoTable, 4 );
328 //=========================================================================
329 // virtual
330 uno::Sequence< ucb::CommandInfo > Content::getCommands(
331 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
333 osl::Guard< osl::Mutex > aGuard( m_aMutex );
335 if ( m_aProps.getType() == STREAM )
337 #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
338 Uri aUri( m_xIdentifier->getContentIdentifier() );
339 Uri aParentUri( aUri.getParentUri() );
341 if ( aParentUri.isDocument() )
343 //=================================================================
345 // Stream, that is a child of a document: Supported commands
347 //=================================================================
349 static const ucb::CommandInfo aStreamCommandInfoTable1[] =
351 ///////////////////////////////////////////////////////////
352 // Mandatory commands
353 ///////////////////////////////////////////////////////////
354 ucb::CommandInfo(
355 rtl::OUString(
356 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
358 getCppuVoidType()
360 ucb::CommandInfo(
361 rtl::OUString(
362 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
364 getCppuVoidType()
366 ucb::CommandInfo(
367 rtl::OUString(
368 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
370 getCppuType(
371 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
373 ucb::CommandInfo(
374 rtl::OUString(
375 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
377 getCppuType(
378 static_cast<
379 uno::Sequence< beans::PropertyValue > * >( 0 ) )
381 ///////////////////////////////////////////////////////////
382 // Optional standard commands
383 ///////////////////////////////////////////////////////////
384 ucb::CommandInfo(
385 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
387 getCppuBooleanType()
389 ucb::CommandInfo(
390 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
392 getCppuType(
393 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
395 ///////////////////////////////////////////////////////////
396 // New commands
397 ///////////////////////////////////////////////////////////
399 return uno::Sequence<
400 ucb::CommandInfo >( aStreamCommandInfoTable1, 6 );
402 #endif
403 //=================================================================
405 // Stream: Supported commands
407 //=================================================================
409 static const ucb::CommandInfo aStreamCommandInfoTable[] =
411 ///////////////////////////////////////////////////////////
412 // Mandatory commands
413 ///////////////////////////////////////////////////////////
414 ucb::CommandInfo(
415 rtl::OUString(
416 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
418 getCppuVoidType()
420 ucb::CommandInfo(
421 rtl::OUString(
422 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
424 getCppuVoidType()
426 ucb::CommandInfo(
427 rtl::OUString(
428 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
430 getCppuType(
431 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
433 ucb::CommandInfo(
434 rtl::OUString(
435 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
437 getCppuType(
438 static_cast<
439 uno::Sequence< beans::PropertyValue > * >( 0 ) )
441 ///////////////////////////////////////////////////////////
442 // Optional standard commands
443 ///////////////////////////////////////////////////////////
444 ucb::CommandInfo(
445 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
447 getCppuBooleanType()
449 ucb::CommandInfo(
450 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
452 getCppuVoidType()
454 ucb::CommandInfo(
455 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
457 getCppuType(
458 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
460 ///////////////////////////////////////////////////////////
461 // New commands
462 ///////////////////////////////////////////////////////////
464 return uno::Sequence<
465 ucb::CommandInfo >( aStreamCommandInfoTable, 7 );
467 else if ( m_aProps.getType() == FOLDER )
469 //=================================================================
471 // Folder: Supported commands
473 //=================================================================
475 static const ucb::CommandInfo aFolderCommandInfoTable[] =
477 ///////////////////////////////////////////////////////////
478 // Mandatory commands
479 ///////////////////////////////////////////////////////////
480 ucb::CommandInfo(
481 rtl::OUString(
482 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
484 getCppuVoidType()
486 ucb::CommandInfo(
487 rtl::OUString(
488 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
490 getCppuVoidType()
492 ucb::CommandInfo(
493 rtl::OUString(
494 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
496 getCppuType(
497 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
499 ucb::CommandInfo(
500 rtl::OUString(
501 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
503 getCppuType(
504 static_cast<
505 uno::Sequence< beans::PropertyValue > * >( 0 ) )
507 ///////////////////////////////////////////////////////////
508 // Optional standard commands
509 ///////////////////////////////////////////////////////////
510 ucb::CommandInfo(
511 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
513 getCppuBooleanType()
515 ucb::CommandInfo(
516 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
518 getCppuVoidType()
520 ucb::CommandInfo(
521 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
523 getCppuType(
524 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
526 ucb::CommandInfo(
527 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
529 getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
531 ///////////////////////////////////////////////////////////
532 // New commands
533 ///////////////////////////////////////////////////////////
535 return uno::Sequence<
536 ucb::CommandInfo >( aFolderCommandInfoTable, 8 );
538 else if ( m_aProps.getType() == DOCUMENT )
540 //=================================================================
542 // Document: Supported commands
544 //=================================================================
546 static const ucb::CommandInfo aDocCommandInfoTable[] =
548 ///////////////////////////////////////////////////////////
549 // Mandatory commands
550 ///////////////////////////////////////////////////////////
551 ucb::CommandInfo(
552 rtl::OUString(
553 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
555 getCppuVoidType()
557 ucb::CommandInfo(
558 rtl::OUString(
559 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
561 getCppuVoidType()
563 ucb::CommandInfo(
564 rtl::OUString(
565 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
567 getCppuType(
568 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
570 ucb::CommandInfo(
571 rtl::OUString(
572 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
574 getCppuType(
575 static_cast<
576 uno::Sequence< beans::PropertyValue > * >( 0 ) )
578 ///////////////////////////////////////////////////////////
579 // Optional standard commands
580 ///////////////////////////////////////////////////////////
581 ucb::CommandInfo(
582 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
584 getCppuType(
585 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
587 ucb::CommandInfo(
588 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
590 getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
592 ///////////////////////////////////////////////////////////
593 // New commands
594 ///////////////////////////////////////////////////////////
596 return uno::Sequence<
597 ucb::CommandInfo >( aDocCommandInfoTable, 6 );
599 else
601 //=================================================================
603 // Root: Supported commands
605 //=================================================================
607 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
609 static const ucb::CommandInfo aRootCommandInfoTable[] =
611 ///////////////////////////////////////////////////////////
612 // Mandatory commands
613 ///////////////////////////////////////////////////////////
614 ucb::CommandInfo(
615 rtl::OUString(
616 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
618 getCppuVoidType()
620 ucb::CommandInfo(
621 rtl::OUString(
622 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
624 getCppuVoidType()
626 ucb::CommandInfo(
627 rtl::OUString(
628 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
630 getCppuType(
631 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
633 ucb::CommandInfo(
634 rtl::OUString(
635 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
637 getCppuType(
638 static_cast<
639 uno::Sequence< beans::PropertyValue > * >( 0 ) )
641 ///////////////////////////////////////////////////////////
642 // Optional standard commands
643 ///////////////////////////////////////////////////////////
644 ucb::CommandInfo(
645 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
647 getCppuType(
648 static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
650 ///////////////////////////////////////////////////////////
651 // New commands
652 ///////////////////////////////////////////////////////////
654 return uno::Sequence<
655 ucb::CommandInfo >( aRootCommandInfoTable, 5 );