Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_contentcaps.cxx
blob384bac2f941f8a7d16e1dcc9e909ccc37b3e1e85
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 DateModified - - - - r r
38 Storage - - r r - -
39 DocumentModel - r - - - -
41 getCommandInfo x x x x x x
42 getPropertySetInfo x x x x x x
43 getPropertyValues x x x x x x
44 setPropertyValues x x x x x x
45 insert - - x x x(*) x(*)
46 delete - - x - x -
47 open x x x - x -
48 transfer - x x - - -
49 createNewContent - x x - - -
52 *************************************************************************/
54 #include <com/sun/star/beans/Property.hpp>
55 #include <com/sun/star/beans/PropertyAttribute.hpp>
56 #include <com/sun/star/beans/PropertyValue.hpp>
57 #include <com/sun/star/embed/XStorage.hpp>
58 #include <com/sun/star/frame/XModel.hpp>
59 #include <com/sun/star/ucb/CommandInfo.hpp>
60 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
61 #include <com/sun/star/ucb/TransferInfo.hpp>
62 #include <com/sun/star/util/DateTime.hpp>
63 #include <osl/diagnose.h>
64 #include <sal/macros.h>
65 #include "tdoc_content.hxx"
67 namespace com::sun::star::embed {
68 class XStorage;
71 using namespace com::sun::star;
72 using namespace tdoc_ucp;
75 // Content implementation.
78 #define MAKEPROPSEQUENCE( a ) \
79 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS(a) )
81 #define MAKECMDSEQUENCE( a ) \
82 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) )
85 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
86 // Content::getPropertyValues(...) must be adapted too!
89 // virtual
90 uno::Sequence< beans::Property > Content::getProperties(
91 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
93 osl::Guard< osl::Mutex > aGuard( m_aMutex );
95 if ( m_aProps.getType() == STREAM )
99 // Stream: Supported properties
102 static const beans::Property aStreamPropertyInfoTable[] =
105 // Mandatory properties
107 beans::Property(
108 "ContentType",
110 cppu::UnoType<OUString>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
114 beans::Property(
115 "IsDocument",
117 cppu::UnoType<bool>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
121 beans::Property(
122 "IsFolder",
124 cppu::UnoType<bool>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
128 beans::Property(
129 "Title",
131 cppu::UnoType<OUString>::get(),
132 beans::PropertyAttribute::BOUND
135 // Optional standard properties
137 beans::Property(
138 "CreatableContentsInfo",
140 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY
144 beans::Property(
145 "DateModified",
147 cppu::UnoType<css::util::DateTime>::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
164 static const beans::Property aFolderPropertyInfoTable[] =
167 // Mandatory properties
169 beans::Property(
170 "ContentType",
172 cppu::UnoType<OUString>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
176 beans::Property(
177 "IsDocument",
179 cppu::UnoType<bool>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
183 beans::Property(
184 "IsFolder",
186 cppu::UnoType<bool>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
190 beans::Property(
191 "Title",
193 cppu::UnoType<OUString>::get(),
194 beans::PropertyAttribute::BOUND
197 // Optional standard properties
199 beans::Property(
200 "CreatableContentsInfo",
202 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
203 beans::PropertyAttribute::BOUND
204 | beans::PropertyAttribute::READONLY
207 // New properties
209 beans::Property(
210 "Storage",
212 cppu::UnoType<embed::XStorage>::get(),
213 beans::PropertyAttribute::BOUND
214 | beans::PropertyAttribute::READONLY
217 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
219 else if ( m_aProps.getType() == DOCUMENT )
223 // Document: Supported properties
226 static const beans::Property aDocPropertyInfoTable[] =
229 // Mandatory properties
231 beans::Property(
232 "ContentType",
234 cppu::UnoType<OUString>::get(),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::READONLY
238 beans::Property(
239 "IsDocument",
241 cppu::UnoType<bool>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::READONLY
245 beans::Property(
246 "IsFolder",
248 cppu::UnoType<bool>::get(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::READONLY
252 beans::Property(
253 "Title",
255 cppu::UnoType<OUString>::get(),
256 beans::PropertyAttribute::BOUND
257 | beans::PropertyAttribute::READONLY
260 // Optional standard properties
262 beans::Property(
263 "CreatableContentsInfo",
265 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
266 beans::PropertyAttribute::BOUND
267 | beans::PropertyAttribute::READONLY
270 // New properties
272 beans::Property(
273 "DocumentModel",
275 cppu::UnoType<frame::XModel>::get(),
276 beans::PropertyAttribute::BOUND
277 | beans::PropertyAttribute::READONLY
280 return MAKEPROPSEQUENCE( aDocPropertyInfoTable );
282 else
286 // Root: Supported properties
289 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
291 static const beans::Property aRootPropertyInfoTable[] =
294 // Mandatory properties
296 beans::Property(
297 "ContentType",
299 cppu::UnoType<OUString>::get(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
303 beans::Property(
304 "IsDocument",
306 cppu::UnoType<bool>::get(),
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
310 beans::Property(
311 "IsFolder",
313 cppu::UnoType<bool>::get(),
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::READONLY
317 beans::Property(
318 "Title",
320 cppu::UnoType<OUString>::get(),
321 beans::PropertyAttribute::BOUND
322 | beans::PropertyAttribute::READONLY
325 // Optional standard properties
327 beans::Property(
328 "CreatableContentsInfo",
330 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
335 // New properties
338 return MAKEPROPSEQUENCE( aRootPropertyInfoTable );
343 // virtual
344 uno::Sequence< ucb::CommandInfo > Content::getCommands(
345 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
347 osl::Guard< osl::Mutex > aGuard( m_aMutex );
349 if ( m_aProps.getType() == STREAM )
351 Uri aUri( m_xIdentifier->getContentIdentifier() );
352 Uri aParentUri( aUri.getParentUri() );
354 if ( aParentUri.isDocument() )
358 // Stream, that is a child of a document: Supported commands
361 static const ucb::CommandInfo aStreamCommandInfoTable1[] =
364 // Mandatory commands
366 ucb::CommandInfo(
367 "getCommandInfo",
369 cppu::UnoType<void>::get()
371 ucb::CommandInfo(
372 "getPropertySetInfo",
374 cppu::UnoType<void>::get()
376 ucb::CommandInfo(
377 "getPropertyValues",
379 cppu::UnoType<uno::Sequence< beans::Property >>::get()
381 ucb::CommandInfo(
382 "setPropertyValues",
384 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
387 // Optional standard commands
389 ucb::CommandInfo(
390 "delete",
392 cppu::UnoType<bool>::get()
394 ucb::CommandInfo(
395 "open",
397 cppu::UnoType<ucb::OpenCommandArgument2>::get()
400 // New commands
403 return MAKECMDSEQUENCE( aStreamCommandInfoTable1 );
407 // Stream: Supported commands
410 static const ucb::CommandInfo aStreamCommandInfoTable[] =
413 // Mandatory commands
415 ucb::CommandInfo(
416 "getCommandInfo",
418 cppu::UnoType<void>::get()
420 ucb::CommandInfo(
421 "getPropertySetInfo",
423 cppu::UnoType<void>::get()
425 ucb::CommandInfo(
426 "getPropertyValues",
428 cppu::UnoType< uno::Sequence< beans::Property >>::get()
430 ucb::CommandInfo(
431 "setPropertyValues",
433 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
436 // Optional standard commands
438 ucb::CommandInfo(
439 "delete",
441 cppu::UnoType<bool>::get()
443 ucb::CommandInfo(
444 "insert",
446 cppu::UnoType<void>::get()
448 ucb::CommandInfo(
449 "open",
451 cppu::UnoType<ucb::OpenCommandArgument2>::get()
454 // New commands
457 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
459 else if ( m_aProps.getType() == FOLDER )
463 // Folder: Supported commands
466 static const ucb::CommandInfo aFolderCommandInfoTable[] =
469 // Mandatory commands
471 ucb::CommandInfo(
472 "getCommandInfo",
474 cppu::UnoType<void>::get()
476 ucb::CommandInfo(
477 "getPropertySetInfo",
479 cppu::UnoType<void>::get()
481 ucb::CommandInfo(
482 "getPropertyValues",
484 cppu::UnoType<uno::Sequence< beans::Property >>::get()
486 ucb::CommandInfo(
487 "setPropertyValues",
489 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
492 // Optional standard commands
494 ucb::CommandInfo(
495 "delete",
497 cppu::UnoType<bool>::get()
499 ucb::CommandInfo(
500 "insert",
502 cppu::UnoType<void>::get()
504 ucb::CommandInfo(
505 "open",
507 cppu::UnoType<ucb::OpenCommandArgument2>::get()
509 ucb::CommandInfo(
510 "transfer",
512 cppu::UnoType<ucb::TransferInfo>::get()
514 ucb::CommandInfo(
515 "createNewContent",
517 cppu::UnoType<ucb::ContentInfo>::get()
520 // New commands
523 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
525 else if ( m_aProps.getType() == DOCUMENT )
529 // Document: Supported commands
532 static const ucb::CommandInfo aDocCommandInfoTable[] =
535 // Mandatory commands
537 ucb::CommandInfo(
538 "getCommandInfo",
540 cppu::UnoType<void>::get()
542 ucb::CommandInfo(
543 "getPropertySetInfo",
545 cppu::UnoType<void>::get()
547 ucb::CommandInfo(
548 "getPropertyValues",
550 cppu::UnoType<uno::Sequence< beans::Property >>::get()
552 ucb::CommandInfo(
553 "setPropertyValues",
555 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
558 // Optional standard commands
560 ucb::CommandInfo(
561 "open",
563 cppu::UnoType<ucb::OpenCommandArgument2>::get()
565 ucb::CommandInfo(
566 "transfer",
568 cppu::UnoType<ucb::TransferInfo>::get()
570 ucb::CommandInfo(
571 "createNewContent",
573 cppu::UnoType<ucb::ContentInfo>::get()
576 // New commands
579 return MAKECMDSEQUENCE( aDocCommandInfoTable );
581 else
585 // Root: Supported commands
588 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
590 static const ucb::CommandInfo aRootCommandInfoTable[] =
593 // Mandatory commands
595 ucb::CommandInfo(
596 "getCommandInfo",
598 cppu::UnoType<void>::get()
600 ucb::CommandInfo(
601 "getPropertySetInfo",
603 cppu::UnoType<void>::get()
605 ucb::CommandInfo(
606 "getPropertyValues",
608 cppu::UnoType<uno::Sequence< beans::Property >>::get()
610 ucb::CommandInfo(
611 "setPropertyValues",
613 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
616 // Optional standard commands
618 ucb::CommandInfo(
619 "open",
621 cppu::UnoType<ucb::OpenCommandArgument2>::get()
624 // New commands
627 return MAKECMDSEQUENCE( aRootCommandInfoTable );
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */