1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /**************************************************************************
23 **************************************************************************
25 **************************************************************************
29 root document folder folder stream stream
31 ----------------------------------------------------------------
32 ContentType r r r r r r
33 IsDocument r r r r r r
36 CreatableContentsInfo r r r r r r
38 DocumentModel - r - - - -
40 getCommandInfo x x x x x x
41 getPropertySetInfo x x x x x x
42 getPropertyValues x x x x x x
43 setPropertyValues x x x x x x
44 insert - - x x x(*) x(*)
48 createNewContent - x x - - -
50 #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
51 (*) not supported by streams that are direct children of document
54 *************************************************************************/
56 #include <com/sun/star/beans/Property.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/beans/PropertyValue.hpp>
59 #include <com/sun/star/embed/XStorage.hpp>
60 #include <com/sun/star/frame/XModel.hpp>
61 #include <com/sun/star/ucb/CommandInfo.hpp>
62 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
63 #include <com/sun/star/ucb/TransferInfo.hpp>
64 #include <osl/diagnose.h>
65 #include <sal/macros.h>
66 #include <tdoc_content.hxx>
68 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{
72 using namespace com::sun::star
;
73 using namespace tdoc_ucp
;
77 // Content implementation.
81 #define MAKEPROPSEQUENCE( a ) \
82 uno::Sequence< beans::Property >( a, (sizeof (a) / sizeof (a[0])) )
84 #define MAKECMDSEQUENCE( a ) \
85 uno::Sequence< ucb::CommandInfo >( a, (sizeof (a) / sizeof (a[0])) )
89 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
90 // Content::getPropertyValues(...) must be adapted too!
95 uno::Sequence
< beans::Property
> Content::getProperties(
96 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
98 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
100 if ( m_aProps
.getType() == STREAM
)
104 // Stream: Supported properties
108 static const beans::Property aStreamPropertyInfoTable
[] =
111 // Mandatory properties
114 OUString( "ContentType" ),
116 cppu::UnoType
<OUString
>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
121 OUString( "IsDocument" ),
123 cppu::UnoType
<bool>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
128 OUString( "IsFolder" ),
130 cppu::UnoType
<bool>::get(),
131 beans::PropertyAttribute::BOUND
132 | beans::PropertyAttribute::READONLY
137 cppu::UnoType
<OUString
>::get(),
138 beans::PropertyAttribute::BOUND
141 // Optional standard properties
145 "CreatableContentsInfo" ),
147 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::READONLY
155 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable
);
157 else if ( m_aProps
.getType() == FOLDER
)
161 // Folder: Supported properties
165 static const beans::Property aFolderPropertyInfoTable
[] =
168 // Mandatory properties
171 OUString( "ContentType" ),
173 cppu::UnoType
<OUString
>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
178 OUString( "IsDocument" ),
180 cppu::UnoType
<bool>::get(),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::READONLY
185 OUString( "IsFolder" ),
187 cppu::UnoType
<bool>::get(),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::READONLY
194 cppu::UnoType
<OUString
>::get(),
195 beans::PropertyAttribute::BOUND
198 // Optional standard properties
202 "CreatableContentsInfo" ),
204 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
205 beans::PropertyAttribute::BOUND
206 | beans::PropertyAttribute::READONLY
212 OUString( "Storage" ),
214 cppu::UnoType
<embed::XStorage
>::get(),
215 beans::PropertyAttribute::BOUND
216 | beans::PropertyAttribute::READONLY
219 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
221 else if ( m_aProps
.getType() == DOCUMENT
)
225 // Document: Supported properties
229 static const beans::Property aDocPropertyInfoTable
[] =
232 // Mandatory properties
235 OUString( "ContentType" ),
237 cppu::UnoType
<OUString
>::get(),
238 beans::PropertyAttribute::BOUND
239 | beans::PropertyAttribute::READONLY
242 OUString( "IsDocument" ),
244 cppu::UnoType
<bool>::get(),
245 beans::PropertyAttribute::BOUND
246 | beans::PropertyAttribute::READONLY
249 OUString( "IsFolder" ),
251 cppu::UnoType
<bool>::get(),
252 beans::PropertyAttribute::BOUND
253 | beans::PropertyAttribute::READONLY
258 cppu::UnoType
<OUString
>::get(),
259 beans::PropertyAttribute::BOUND
260 | beans::PropertyAttribute::READONLY
263 // Optional standard properties
267 "CreatableContentsInfo" ),
269 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
270 beans::PropertyAttribute::BOUND
271 | beans::PropertyAttribute::READONLY
277 OUString( "DocumentModel" ),
279 cppu::UnoType
<frame::XModel
>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
284 return MAKEPROPSEQUENCE( aDocPropertyInfoTable
);
290 // Root: Supported properties
294 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
296 static const beans::Property aRootPropertyInfoTable
[] =
299 // Mandatory properties
302 OUString( "ContentType" ),
304 cppu::UnoType
<OUString
>::get(),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::READONLY
309 OUString( "IsDocument" ),
311 cppu::UnoType
<bool>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::READONLY
316 OUString( "IsFolder" ),
318 cppu::UnoType
<bool>::get(),
319 beans::PropertyAttribute::BOUND
320 | beans::PropertyAttribute::READONLY
325 cppu::UnoType
<OUString
>::get(),
326 beans::PropertyAttribute::BOUND
327 | beans::PropertyAttribute::READONLY
330 // Optional standard properties
334 "CreatableContentsInfo" ),
336 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
337 beans::PropertyAttribute::BOUND
338 | beans::PropertyAttribute::READONLY
344 return MAKEPROPSEQUENCE( aRootPropertyInfoTable
);
350 uno::Sequence
< ucb::CommandInfo
> Content::getCommands(
351 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
353 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
355 if ( m_aProps
.getType() == STREAM
)
357 #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
358 Uri
aUri( m_xIdentifier
->getContentIdentifier() );
359 Uri
aParentUri( aUri
.getParentUri() );
361 if ( aParentUri
.isDocument() )
365 // Stream, that is a child of a document: Supported commands
369 static const ucb::CommandInfo aStreamCommandInfoTable1
[] =
372 // Mandatory commands
375 OUString( "getCommandInfo" ),
377 cppu::UnoType
<void>::get()
380 OUString( "getPropertySetInfo" ),
382 cppu::UnoType
<void>::get()
385 OUString( "getPropertyValues" ),
387 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
390 OUString( "setPropertyValues" ),
392 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
395 // Optional standard commands
398 OUString( "delete" ),
400 cppu::UnoType
<bool>::get()
405 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
411 return MAKECMDSEQUENCE( aStreamCommandInfoTable1
);
416 // Stream: Supported commands
420 static const ucb::CommandInfo aStreamCommandInfoTable
[] =
423 // Mandatory commands
426 OUString( "getCommandInfo" ),
428 cppu::UnoType
<void>::get()
431 OUString( "getPropertySetInfo" ),
433 cppu::UnoType
<void>::get()
436 OUString( "getPropertyValues" ),
438 cppu::UnoType
< uno::Sequence
< beans::Property
>>::get()
441 OUString( "setPropertyValues" ),
443 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
446 // Optional standard commands
449 OUString( "delete" ),
451 cppu::UnoType
<bool>::get()
454 OUString( "insert" ),
456 cppu::UnoType
<void>::get()
461 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
467 return MAKECMDSEQUENCE( aStreamCommandInfoTable
);
469 else if ( m_aProps
.getType() == FOLDER
)
473 // Folder: Supported commands
477 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
480 // Mandatory commands
483 OUString( "getCommandInfo" ),
485 cppu::UnoType
<void>::get()
488 OUString( "getPropertySetInfo" ),
490 cppu::UnoType
<void>::get()
493 OUString( "getPropertyValues" ),
495 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
498 OUString( "setPropertyValues" ),
500 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
503 // Optional standard commands
506 OUString( "delete" ),
508 cppu::UnoType
<bool>::get()
511 OUString( "insert" ),
513 cppu::UnoType
<void>::get()
518 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
521 OUString( "transfer" ),
523 cppu::UnoType
<ucb::TransferInfo
>::get()
526 OUString( "createNewContent" ),
528 cppu::UnoType
<ucb::ContentInfo
>::get()
534 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
536 else if ( m_aProps
.getType() == DOCUMENT
)
540 // Document: Supported commands
544 static const ucb::CommandInfo aDocCommandInfoTable
[] =
547 // Mandatory commands
550 OUString( "getCommandInfo" ),
552 cppu::UnoType
<void>::get()
555 OUString( "getPropertySetInfo" ),
557 cppu::UnoType
<void>::get()
560 OUString( "getPropertyValues" ),
562 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
565 OUString( "setPropertyValues" ),
567 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
570 // Optional standard commands
575 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
578 OUString( "transfer" ),
580 cppu::UnoType
<ucb::TransferInfo
>::get()
583 OUString( "createNewContent" ),
585 cppu::UnoType
<ucb::ContentInfo
>::get()
591 return MAKECMDSEQUENCE( aDocCommandInfoTable
);
597 // Root: Supported commands
601 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
603 static const ucb::CommandInfo aRootCommandInfoTable
[] =
606 // Mandatory commands
609 OUString( "getCommandInfo" ),
611 cppu::UnoType
<void>::get()
614 OUString( "getPropertySetInfo" ),
616 cppu::UnoType
<void>::get()
619 OUString( "getPropertyValues" ),
621 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
624 OUString( "setPropertyValues" ),
626 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
629 // Optional standard commands
634 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
640 return MAKECMDSEQUENCE( aRootCommandInfoTable
);
644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */