bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_contentcaps.cxx
blob7cc288203be6a9f47326d8cf36622d70519ceb69
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 /**************************************************************************
22 TODO
23 **************************************************************************
25 **************************************************************************
27 Props/Commands:
29 root document folder folder stream stream
30 (new) (new)
31 ----------------------------------------------------------------
32 ContentType r r r r r r
33 IsDocument r r r r r r
34 IsFolder r r r r r r
35 Title r r w w w w
36 CreatableContentsInfo r r r r r r
37 Storage - - 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(*)
45 delete - - x - x -
46 open x x x - x -
47 transfer - 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
52 #endif
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 {
69 class XStorage;
70 } } } }
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!
94 // virtual
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
113 beans::Property(
114 OUString( "ContentType" ),
116 cppu::UnoType<OUString>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
120 beans::Property(
121 OUString( "IsDocument" ),
123 cppu::UnoType<bool>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
127 beans::Property(
128 OUString( "IsFolder" ),
130 cppu::UnoType<bool>::get(),
131 beans::PropertyAttribute::BOUND
132 | beans::PropertyAttribute::READONLY
134 beans::Property(
135 OUString( "Title" ),
137 cppu::UnoType<OUString>::get(),
138 beans::PropertyAttribute::BOUND
141 // Optional standard properties
143 beans::Property(
144 OUString(
145 "CreatableContentsInfo" ),
147 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::READONLY
152 // New properties
155 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
157 else if ( m_aProps.getType() == FOLDER )
161 // Folder: Supported properties
165 static const beans::Property aFolderPropertyInfoTable[] =
168 // Mandatory properties
170 beans::Property(
171 OUString( "ContentType" ),
173 cppu::UnoType<OUString>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
177 beans::Property(
178 OUString( "IsDocument" ),
180 cppu::UnoType<bool>::get(),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::READONLY
184 beans::Property(
185 OUString( "IsFolder" ),
187 cppu::UnoType<bool>::get(),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::READONLY
191 beans::Property(
192 OUString( "Title" ),
194 cppu::UnoType<OUString>::get(),
195 beans::PropertyAttribute::BOUND
198 // Optional standard properties
200 beans::Property(
201 OUString(
202 "CreatableContentsInfo" ),
204 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
205 beans::PropertyAttribute::BOUND
206 | beans::PropertyAttribute::READONLY
209 // New properties
211 beans::Property(
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
234 beans::Property(
235 OUString( "ContentType" ),
237 cppu::UnoType<OUString>::get(),
238 beans::PropertyAttribute::BOUND
239 | beans::PropertyAttribute::READONLY
241 beans::Property(
242 OUString( "IsDocument" ),
244 cppu::UnoType<bool>::get(),
245 beans::PropertyAttribute::BOUND
246 | beans::PropertyAttribute::READONLY
248 beans::Property(
249 OUString( "IsFolder" ),
251 cppu::UnoType<bool>::get(),
252 beans::PropertyAttribute::BOUND
253 | beans::PropertyAttribute::READONLY
255 beans::Property(
256 OUString( "Title" ),
258 cppu::UnoType<OUString>::get(),
259 beans::PropertyAttribute::BOUND
260 | beans::PropertyAttribute::READONLY
263 // Optional standard properties
265 beans::Property(
266 OUString(
267 "CreatableContentsInfo" ),
269 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
270 beans::PropertyAttribute::BOUND
271 | beans::PropertyAttribute::READONLY
274 // New properties
276 beans::Property(
277 OUString( "DocumentModel" ),
279 cppu::UnoType<frame::XModel>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
284 return MAKEPROPSEQUENCE( aDocPropertyInfoTable );
286 else
290 // Root: Supported properties
294 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
296 static const beans::Property aRootPropertyInfoTable[] =
299 // Mandatory properties
301 beans::Property(
302 OUString( "ContentType" ),
304 cppu::UnoType<OUString>::get(),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::READONLY
308 beans::Property(
309 OUString( "IsDocument" ),
311 cppu::UnoType<bool>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::READONLY
315 beans::Property(
316 OUString( "IsFolder" ),
318 cppu::UnoType<bool>::get(),
319 beans::PropertyAttribute::BOUND
320 | beans::PropertyAttribute::READONLY
322 beans::Property(
323 OUString( "Title" ),
325 cppu::UnoType<OUString>::get(),
326 beans::PropertyAttribute::BOUND
327 | beans::PropertyAttribute::READONLY
330 // Optional standard properties
332 beans::Property(
333 OUString(
334 "CreatableContentsInfo" ),
336 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
337 beans::PropertyAttribute::BOUND
338 | beans::PropertyAttribute::READONLY
341 // New properties
344 return MAKEPROPSEQUENCE( aRootPropertyInfoTable );
349 // virtual
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
374 ucb::CommandInfo(
375 OUString( "getCommandInfo" ),
377 cppu::UnoType<void>::get()
379 ucb::CommandInfo(
380 OUString( "getPropertySetInfo" ),
382 cppu::UnoType<void>::get()
384 ucb::CommandInfo(
385 OUString( "getPropertyValues" ),
387 cppu::UnoType<uno::Sequence< beans::Property >>::get()
389 ucb::CommandInfo(
390 OUString( "setPropertyValues" ),
392 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
395 // Optional standard commands
397 ucb::CommandInfo(
398 OUString( "delete" ),
400 cppu::UnoType<bool>::get()
402 ucb::CommandInfo(
403 OUString( "open" ),
405 cppu::UnoType<ucb::OpenCommandArgument2>::get()
408 // New commands
411 return MAKECMDSEQUENCE( aStreamCommandInfoTable1 );
413 #endif
416 // Stream: Supported commands
420 static const ucb::CommandInfo aStreamCommandInfoTable[] =
423 // Mandatory commands
425 ucb::CommandInfo(
426 OUString( "getCommandInfo" ),
428 cppu::UnoType<void>::get()
430 ucb::CommandInfo(
431 OUString( "getPropertySetInfo" ),
433 cppu::UnoType<void>::get()
435 ucb::CommandInfo(
436 OUString( "getPropertyValues" ),
438 cppu::UnoType< uno::Sequence< beans::Property >>::get()
440 ucb::CommandInfo(
441 OUString( "setPropertyValues" ),
443 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
446 // Optional standard commands
448 ucb::CommandInfo(
449 OUString( "delete" ),
451 cppu::UnoType<bool>::get()
453 ucb::CommandInfo(
454 OUString( "insert" ),
456 cppu::UnoType<void>::get()
458 ucb::CommandInfo(
459 OUString( "open" ),
461 cppu::UnoType<ucb::OpenCommandArgument2>::get()
464 // New commands
467 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
469 else if ( m_aProps.getType() == FOLDER )
473 // Folder: Supported commands
477 static const ucb::CommandInfo aFolderCommandInfoTable[] =
480 // Mandatory commands
482 ucb::CommandInfo(
483 OUString( "getCommandInfo" ),
485 cppu::UnoType<void>::get()
487 ucb::CommandInfo(
488 OUString( "getPropertySetInfo" ),
490 cppu::UnoType<void>::get()
492 ucb::CommandInfo(
493 OUString( "getPropertyValues" ),
495 cppu::UnoType<uno::Sequence< beans::Property >>::get()
497 ucb::CommandInfo(
498 OUString( "setPropertyValues" ),
500 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
503 // Optional standard commands
505 ucb::CommandInfo(
506 OUString( "delete" ),
508 cppu::UnoType<bool>::get()
510 ucb::CommandInfo(
511 OUString( "insert" ),
513 cppu::UnoType<void>::get()
515 ucb::CommandInfo(
516 OUString( "open" ),
518 cppu::UnoType<ucb::OpenCommandArgument2>::get()
520 ucb::CommandInfo(
521 OUString( "transfer" ),
523 cppu::UnoType<ucb::TransferInfo>::get()
525 ucb::CommandInfo(
526 OUString( "createNewContent" ),
528 cppu::UnoType<ucb::ContentInfo>::get()
531 // New commands
534 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
536 else if ( m_aProps.getType() == DOCUMENT )
540 // Document: Supported commands
544 static const ucb::CommandInfo aDocCommandInfoTable[] =
547 // Mandatory commands
549 ucb::CommandInfo(
550 OUString( "getCommandInfo" ),
552 cppu::UnoType<void>::get()
554 ucb::CommandInfo(
555 OUString( "getPropertySetInfo" ),
557 cppu::UnoType<void>::get()
559 ucb::CommandInfo(
560 OUString( "getPropertyValues" ),
562 cppu::UnoType<uno::Sequence< beans::Property >>::get()
564 ucb::CommandInfo(
565 OUString( "setPropertyValues" ),
567 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
570 // Optional standard commands
572 ucb::CommandInfo(
573 OUString( "open" ),
575 cppu::UnoType<ucb::OpenCommandArgument2>::get()
577 ucb::CommandInfo(
578 OUString( "transfer" ),
580 cppu::UnoType<ucb::TransferInfo>::get()
582 ucb::CommandInfo(
583 OUString( "createNewContent" ),
585 cppu::UnoType<ucb::ContentInfo>::get()
588 // New commands
591 return MAKECMDSEQUENCE( aDocCommandInfoTable );
593 else
597 // Root: Supported commands
601 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
603 static const ucb::CommandInfo aRootCommandInfoTable[] =
606 // Mandatory commands
608 ucb::CommandInfo(
609 OUString( "getCommandInfo" ),
611 cppu::UnoType<void>::get()
613 ucb::CommandInfo(
614 OUString( "getPropertySetInfo" ),
616 cppu::UnoType<void>::get()
618 ucb::CommandInfo(
619 OUString( "getPropertyValues" ),
621 cppu::UnoType<uno::Sequence< beans::Property >>::get()
623 ucb::CommandInfo(
624 OUString( "setPropertyValues" ),
626 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
629 // Optional standard commands
631 ucb::CommandInfo(
632 OUString( "open" ),
634 cppu::UnoType<ucb::OpenCommandArgument2>::get()
637 // New commands
640 return MAKECMDSEQUENCE( aRootCommandInfoTable );
644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */