bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_contentcaps.cxx
blob8b19f9ec94b8b88e3b795f04df4e5dfb84f7ec3e
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 - - -
51 *************************************************************************/
53 #include <com/sun/star/beans/Property.hpp>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #include <com/sun/star/embed/XStorage.hpp>
57 #include <com/sun/star/frame/XModel.hpp>
58 #include <com/sun/star/ucb/CommandInfo.hpp>
59 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
60 #include <com/sun/star/ucb/TransferInfo.hpp>
61 #include <osl/diagnose.h>
62 #include <sal/macros.h>
63 #include "tdoc_content.hxx"
65 namespace com::sun::star::embed {
66 class XStorage;
69 using namespace com::sun::star;
70 using namespace tdoc_ucp;
73 // Content implementation.
76 #define MAKEPROPSEQUENCE( a ) \
77 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS(a) )
79 #define MAKECMDSEQUENCE( a ) \
80 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) )
83 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
84 // Content::getPropertyValues(...) must be adapted too!
87 // virtual
88 uno::Sequence< beans::Property > Content::getProperties(
89 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
91 osl::Guard< osl::Mutex > aGuard( m_aMutex );
93 if ( m_aProps.getType() == STREAM )
97 // Stream: Supported properties
100 static const beans::Property aStreamPropertyInfoTable[] =
103 // Mandatory properties
105 beans::Property(
106 "ContentType",
108 cppu::UnoType<OUString>::get(),
109 beans::PropertyAttribute::BOUND
110 | beans::PropertyAttribute::READONLY
112 beans::Property(
113 "IsDocument",
115 cppu::UnoType<bool>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::READONLY
119 beans::Property(
120 "IsFolder",
122 cppu::UnoType<bool>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::READONLY
126 beans::Property(
127 "Title",
129 cppu::UnoType<OUString>::get(),
130 beans::PropertyAttribute::BOUND
133 // Optional standard properties
135 beans::Property(
136 "CreatableContentsInfo",
138 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
139 beans::PropertyAttribute::BOUND
140 | beans::PropertyAttribute::READONLY
143 // New properties
146 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
148 else if ( m_aProps.getType() == FOLDER )
152 // Folder: Supported properties
155 static const beans::Property aFolderPropertyInfoTable[] =
158 // Mandatory properties
160 beans::Property(
161 "ContentType",
163 cppu::UnoType<OUString>::get(),
164 beans::PropertyAttribute::BOUND
165 | beans::PropertyAttribute::READONLY
167 beans::Property(
168 "IsDocument",
170 cppu::UnoType<bool>::get(),
171 beans::PropertyAttribute::BOUND
172 | beans::PropertyAttribute::READONLY
174 beans::Property(
175 "IsFolder",
177 cppu::UnoType<bool>::get(),
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::READONLY
181 beans::Property(
182 "Title",
184 cppu::UnoType<OUString>::get(),
185 beans::PropertyAttribute::BOUND
188 // Optional standard properties
190 beans::Property(
191 "CreatableContentsInfo",
193 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::READONLY
198 // New properties
200 beans::Property(
201 "Storage",
203 cppu::UnoType<embed::XStorage>::get(),
204 beans::PropertyAttribute::BOUND
205 | beans::PropertyAttribute::READONLY
208 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
210 else if ( m_aProps.getType() == DOCUMENT )
214 // Document: Supported properties
217 static const beans::Property aDocPropertyInfoTable[] =
220 // Mandatory properties
222 beans::Property(
223 "ContentType",
225 cppu::UnoType<OUString>::get(),
226 beans::PropertyAttribute::BOUND
227 | beans::PropertyAttribute::READONLY
229 beans::Property(
230 "IsDocument",
232 cppu::UnoType<bool>::get(),
233 beans::PropertyAttribute::BOUND
234 | beans::PropertyAttribute::READONLY
236 beans::Property(
237 "IsFolder",
239 cppu::UnoType<bool>::get(),
240 beans::PropertyAttribute::BOUND
241 | beans::PropertyAttribute::READONLY
243 beans::Property(
244 "Title",
246 cppu::UnoType<OUString>::get(),
247 beans::PropertyAttribute::BOUND
248 | beans::PropertyAttribute::READONLY
251 // Optional standard properties
253 beans::Property(
254 "CreatableContentsInfo",
256 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
257 beans::PropertyAttribute::BOUND
258 | beans::PropertyAttribute::READONLY
261 // New properties
263 beans::Property(
264 "DocumentModel",
266 cppu::UnoType<frame::XModel>::get(),
267 beans::PropertyAttribute::BOUND
268 | beans::PropertyAttribute::READONLY
271 return MAKEPROPSEQUENCE( aDocPropertyInfoTable );
273 else
277 // Root: Supported properties
280 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
282 static const beans::Property aRootPropertyInfoTable[] =
285 // Mandatory properties
287 beans::Property(
288 "ContentType",
290 cppu::UnoType<OUString>::get(),
291 beans::PropertyAttribute::BOUND
292 | beans::PropertyAttribute::READONLY
294 beans::Property(
295 "IsDocument",
297 cppu::UnoType<bool>::get(),
298 beans::PropertyAttribute::BOUND
299 | beans::PropertyAttribute::READONLY
301 beans::Property(
302 "IsFolder",
304 cppu::UnoType<bool>::get(),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::READONLY
308 beans::Property(
309 "Title",
311 cppu::UnoType<OUString>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::READONLY
316 // Optional standard properties
318 beans::Property(
319 "CreatableContentsInfo",
321 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
322 beans::PropertyAttribute::BOUND
323 | beans::PropertyAttribute::READONLY
326 // New properties
329 return MAKEPROPSEQUENCE( aRootPropertyInfoTable );
334 // virtual
335 uno::Sequence< ucb::CommandInfo > Content::getCommands(
336 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
338 osl::Guard< osl::Mutex > aGuard( m_aMutex );
340 if ( m_aProps.getType() == STREAM )
342 Uri aUri( m_xIdentifier->getContentIdentifier() );
343 Uri aParentUri( aUri.getParentUri() );
345 if ( aParentUri.isDocument() )
349 // Stream, that is a child of a document: Supported commands
352 static const ucb::CommandInfo aStreamCommandInfoTable1[] =
355 // Mandatory commands
357 ucb::CommandInfo(
358 "getCommandInfo",
360 cppu::UnoType<void>::get()
362 ucb::CommandInfo(
363 "getPropertySetInfo",
365 cppu::UnoType<void>::get()
367 ucb::CommandInfo(
368 "getPropertyValues",
370 cppu::UnoType<uno::Sequence< beans::Property >>::get()
372 ucb::CommandInfo(
373 "setPropertyValues",
375 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
378 // Optional standard commands
380 ucb::CommandInfo(
381 "delete",
383 cppu::UnoType<bool>::get()
385 ucb::CommandInfo(
386 "open",
388 cppu::UnoType<ucb::OpenCommandArgument2>::get()
391 // New commands
394 return MAKECMDSEQUENCE( aStreamCommandInfoTable1 );
398 // Stream: Supported commands
401 static const ucb::CommandInfo aStreamCommandInfoTable[] =
404 // Mandatory commands
406 ucb::CommandInfo(
407 "getCommandInfo",
409 cppu::UnoType<void>::get()
411 ucb::CommandInfo(
412 "getPropertySetInfo",
414 cppu::UnoType<void>::get()
416 ucb::CommandInfo(
417 "getPropertyValues",
419 cppu::UnoType< uno::Sequence< beans::Property >>::get()
421 ucb::CommandInfo(
422 "setPropertyValues",
424 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
427 // Optional standard commands
429 ucb::CommandInfo(
430 "delete",
432 cppu::UnoType<bool>::get()
434 ucb::CommandInfo(
435 "insert",
437 cppu::UnoType<void>::get()
439 ucb::CommandInfo(
440 "open",
442 cppu::UnoType<ucb::OpenCommandArgument2>::get()
445 // New commands
448 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
450 else if ( m_aProps.getType() == FOLDER )
454 // Folder: Supported commands
457 static const ucb::CommandInfo aFolderCommandInfoTable[] =
460 // Mandatory commands
462 ucb::CommandInfo(
463 "getCommandInfo",
465 cppu::UnoType<void>::get()
467 ucb::CommandInfo(
468 "getPropertySetInfo",
470 cppu::UnoType<void>::get()
472 ucb::CommandInfo(
473 "getPropertyValues",
475 cppu::UnoType<uno::Sequence< beans::Property >>::get()
477 ucb::CommandInfo(
478 "setPropertyValues",
480 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
483 // Optional standard commands
485 ucb::CommandInfo(
486 "delete",
488 cppu::UnoType<bool>::get()
490 ucb::CommandInfo(
491 "insert",
493 cppu::UnoType<void>::get()
495 ucb::CommandInfo(
496 "open",
498 cppu::UnoType<ucb::OpenCommandArgument2>::get()
500 ucb::CommandInfo(
501 "transfer",
503 cppu::UnoType<ucb::TransferInfo>::get()
505 ucb::CommandInfo(
506 "createNewContent",
508 cppu::UnoType<ucb::ContentInfo>::get()
511 // New commands
514 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
516 else if ( m_aProps.getType() == DOCUMENT )
520 // Document: Supported commands
523 static const ucb::CommandInfo aDocCommandInfoTable[] =
526 // Mandatory commands
528 ucb::CommandInfo(
529 "getCommandInfo",
531 cppu::UnoType<void>::get()
533 ucb::CommandInfo(
534 "getPropertySetInfo",
536 cppu::UnoType<void>::get()
538 ucb::CommandInfo(
539 "getPropertyValues",
541 cppu::UnoType<uno::Sequence< beans::Property >>::get()
543 ucb::CommandInfo(
544 "setPropertyValues",
546 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
549 // Optional standard commands
551 ucb::CommandInfo(
552 "open",
554 cppu::UnoType<ucb::OpenCommandArgument2>::get()
556 ucb::CommandInfo(
557 "transfer",
559 cppu::UnoType<ucb::TransferInfo>::get()
561 ucb::CommandInfo(
562 "createNewContent",
564 cppu::UnoType<ucb::ContentInfo>::get()
567 // New commands
570 return MAKECMDSEQUENCE( aDocCommandInfoTable );
572 else
576 // Root: Supported commands
579 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
581 static const ucb::CommandInfo aRootCommandInfoTable[] =
584 // Mandatory commands
586 ucb::CommandInfo(
587 "getCommandInfo",
589 cppu::UnoType<void>::get()
591 ucb::CommandInfo(
592 "getPropertySetInfo",
594 cppu::UnoType<void>::get()
596 ucb::CommandInfo(
597 "getPropertyValues",
599 cppu::UnoType<uno::Sequence< beans::Property >>::get()
601 ucb::CommandInfo(
602 "setPropertyValues",
604 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
607 // Optional standard commands
609 ucb::CommandInfo(
610 "open",
612 cppu::UnoType<ucb::OpenCommandArgument2>::get()
615 // New commands
618 return MAKECMDSEQUENCE( aRootCommandInfoTable );
622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */