1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdoc_contentcaps.cxx,v $
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 /**************************************************************************
36 **************************************************************************
38 **************************************************************************
42 root document folder folder stream stream
44 ----------------------------------------------------------------
45 ContentType r r r r r r
46 IsDocument r r r r 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(*)
61 #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
62 (*) not supported by streams that are direct children of document
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
{
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 //=========================================================================
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 ///////////////////////////////////////////////////////////
119 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
121 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::READONLY
127 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
129 getCppuBooleanType(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::READONLY
134 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
136 getCppuBooleanType(),
137 beans::PropertyAttribute::BOUND
138 | beans::PropertyAttribute::READONLY
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 ///////////////////////////////////////////////////////////
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 ///////////////////////////////////////////////////////////
170 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
172 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
178 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
180 getCppuBooleanType(),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::READONLY
185 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
187 getCppuBooleanType(),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::READONLY
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 ///////////////////////////////////////////////////////////
202 ///////////////////////////////////////////////////////////
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 ///////////////////////////////////////////////////////////
229 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
231 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
232 beans::PropertyAttribute::BOUND
233 | beans::PropertyAttribute::READONLY
237 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
239 getCppuBooleanType(),
240 beans::PropertyAttribute::BOUND
241 | beans::PropertyAttribute::READONLY
244 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
246 getCppuBooleanType(),
247 beans::PropertyAttribute::BOUND
248 | beans::PropertyAttribute::READONLY
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 ///////////////////////////////////////////////////////////
262 ///////////////////////////////////////////////////////////
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 );
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 ///////////////////////////////////////////////////////////////
290 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
292 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
293 beans::PropertyAttribute::BOUND
294 | beans::PropertyAttribute::READONLY
297 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
299 getCppuBooleanType(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
304 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
306 getCppuBooleanType(),
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
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 ///////////////////////////////////////////////////////////////
322 ///////////////////////////////////////////////////////////////
324 return uno::Sequence
< beans::Property
>( aRootPropertyInfoTable
, 4 );
328 //=========================================================================
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 ///////////////////////////////////////////////////////////
356 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
362 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
368 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
371 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
375 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
379 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
381 ///////////////////////////////////////////////////////////
382 // Optional standard commands
383 ///////////////////////////////////////////////////////////
385 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
390 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
393 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
395 ///////////////////////////////////////////////////////////
397 ///////////////////////////////////////////////////////////
399 return uno::Sequence
<
400 ucb::CommandInfo
>( aStreamCommandInfoTable1
, 6 );
403 //=================================================================
405 // Stream: Supported commands
407 //=================================================================
409 static const ucb::CommandInfo aStreamCommandInfoTable
[] =
411 ///////////////////////////////////////////////////////////
412 // Mandatory commands
413 ///////////////////////////////////////////////////////////
416 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
422 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
428 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
431 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
435 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
439 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
441 ///////////////////////////////////////////////////////////
442 // Optional standard commands
443 ///////////////////////////////////////////////////////////
445 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
450 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
455 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
458 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
460 ///////////////////////////////////////////////////////////
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 ///////////////////////////////////////////////////////////
482 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
488 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
494 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
497 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
501 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
505 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
507 ///////////////////////////////////////////////////////////
508 // Optional standard commands
509 ///////////////////////////////////////////////////////////
511 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
516 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
521 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
524 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
527 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
529 getCppuType( static_cast< ucb::TransferInfo
* >( 0 ) )
531 ///////////////////////////////////////////////////////////
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 ///////////////////////////////////////////////////////////
553 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
559 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
565 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
568 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
572 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
576 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
578 ///////////////////////////////////////////////////////////
579 // Optional standard commands
580 ///////////////////////////////////////////////////////////
582 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
585 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
588 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
590 getCppuType( static_cast< ucb::TransferInfo
* >( 0 ) )
592 ///////////////////////////////////////////////////////////
594 ///////////////////////////////////////////////////////////
596 return uno::Sequence
<
597 ucb::CommandInfo
>( aDocCommandInfoTable
, 6 );
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 ///////////////////////////////////////////////////////////
616 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
622 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
628 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
631 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
635 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
639 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
641 ///////////////////////////////////////////////////////////
642 // Optional standard commands
643 ///////////////////////////////////////////////////////////
645 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
648 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
650 ///////////////////////////////////////////////////////////
652 ///////////////////////////////////////////////////////////
654 return uno::Sequence
<
655 ucb::CommandInfo
>( aRootCommandInfoTable
, 5 );