bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchycontentcaps.cxx
blob836a136f62f3a719618be457a0a0ee51bc03cf68
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 folder folder link link
30 (new) (new)
31 ----------------------------------------------------------------
32 ContentType x x x x x
33 IsDocument x x x x x
34 IsFolder x x x x x
35 Title x x x x x
36 TargetURL x x
37 CreatableContentsInfo x x x x x
39 getCommandInfo x x x x x
40 getPropertySetInfo x x x x x
41 getPropertyValues x x x x x
42 setPropertyValues x x x x x
43 createNewContent x x
44 insert x x
45 delete x x
46 open x x
47 transfer x x
49 *************************************************************************/
51 #include <com/sun/star/beans/Property.hpp>
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #include <com/sun/star/beans/PropertyValue.hpp>
54 #include <com/sun/star/ucb/CommandInfo.hpp>
55 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
56 #include <com/sun/star/ucb/TransferInfo.hpp>
57 #include <com/sun/star/uno/Sequence.hxx>
58 #include <sal/macros.h>
59 #include "hierarchycontent.hxx"
61 using namespace com::sun::star;
62 using namespace hierarchy_ucp;
65 // HierarchyContent implementation.
68 #define MAKEPROPSEQUENCE( a ) \
69 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
71 #define MAKECMDSEQUENCE( a ) \
72 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) )
75 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
76 // HierarchyContent::getPropertyValues(...) must be adapted too!
79 // virtual
80 uno::Sequence< beans::Property > HierarchyContent::getProperties(
81 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
83 osl::Guard< osl::Mutex > aGuard( m_aMutex );
85 if ( m_eKind == LINK )
89 // Link: Supported properties
92 if ( isReadOnly() )
94 static const beans::Property aLinkPropertyInfoTable[] =
97 // Required properties
99 beans::Property(
100 "ContentType",
102 cppu::UnoType<OUString>::get(),
103 beans::PropertyAttribute::BOUND
104 | beans::PropertyAttribute::READONLY
106 beans::Property(
107 "IsDocument",
109 cppu::UnoType<bool>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::READONLY
113 beans::Property(
114 "IsFolder",
116 cppu::UnoType<bool>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
120 beans::Property(
121 "Title",
123 cppu::UnoType<OUString>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
128 // Optional standard properties
130 beans::Property(
131 "TargetURL",
133 cppu::UnoType<OUString>::get(),
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::READONLY
137 beans::Property(
138 "CreatableContentsInfo",
140 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY )
144 // New properties
147 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
149 else
151 static const beans::Property aLinkPropertyInfoTable[] =
154 // Required properties
156 beans::Property(
157 "ContentType",
159 cppu::UnoType<OUString>::get(),
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::READONLY
163 beans::Property(
164 "IsDocument",
166 cppu::UnoType<bool>::get(),
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::READONLY
170 beans::Property(
171 "IsFolder",
173 cppu::UnoType<bool>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
177 beans::Property(
178 "Title",
180 cppu::UnoType<OUString>::get(),
181 beans::PropertyAttribute::BOUND
184 // Optional standard properties
186 beans::Property(
187 "TargetURL",
189 cppu::UnoType<OUString>::get(),
190 beans::PropertyAttribute::BOUND
192 beans::Property(
193 "CreatableContentsInfo",
195 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::READONLY )
199 // New properties
202 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
205 else if ( m_eKind == FOLDER )
209 // Folder: Supported properties
212 if ( isReadOnly() )
214 static const beans::Property aFolderPropertyInfoTable[] =
217 // Required properties
219 beans::Property(
220 "ContentType",
222 cppu::UnoType<OUString>::get(),
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::READONLY
226 beans::Property(
227 "IsDocument",
229 cppu::UnoType<bool>::get(),
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::READONLY
233 beans::Property(
234 "IsFolder",
236 cppu::UnoType<bool>::get(),
237 beans::PropertyAttribute::BOUND
238 | beans::PropertyAttribute::READONLY
240 beans::Property(
241 "Title",
243 cppu::UnoType<OUString>::get(),
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::READONLY
248 // Optional standard properties
250 beans::Property(
251 "CreatableContentsInfo",
253 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::READONLY )
257 // New properties
260 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
262 else
264 static const beans::Property aFolderPropertyInfoTable[] =
267 // Required properties
269 beans::Property(
270 "ContentType",
272 cppu::UnoType<OUString>::get(),
273 beans::PropertyAttribute::BOUND
274 | beans::PropertyAttribute::READONLY
276 beans::Property(
277 "IsDocument",
279 cppu::UnoType<bool>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
283 beans::Property(
284 "IsFolder",
286 cppu::UnoType<bool>::get(),
287 beans::PropertyAttribute::BOUND
288 | beans::PropertyAttribute::READONLY
290 beans::Property(
291 "Title",
293 cppu::UnoType<OUString>::get(),
294 beans::PropertyAttribute::BOUND
297 // Optional standard properties
299 beans::Property(
300 "CreatableContentsInfo",
302 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
303 beans::PropertyAttribute::BOUND
304 | beans::PropertyAttribute::READONLY )
306 // New properties
309 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
312 else
316 // Root Folder: Supported properties
319 // Currently no difference between read-only/read-write
320 // -> all props are read-only
322 static const beans::Property aRootFolderPropertyInfoTable[] =
325 // Required properties
327 beans::Property(
328 "ContentType",
330 cppu::UnoType<OUString>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
334 beans::Property(
335 "IsDocument",
337 cppu::UnoType<bool>::get(),
338 beans::PropertyAttribute::BOUND
339 | beans::PropertyAttribute::READONLY
341 beans::Property(
342 "IsFolder",
344 cppu::UnoType<bool>::get(),
345 beans::PropertyAttribute::BOUND
346 | beans::PropertyAttribute::READONLY
348 beans::Property(
349 "Title",
351 cppu::UnoType<OUString>::get(),
352 beans::PropertyAttribute::BOUND
353 | beans::PropertyAttribute::READONLY
356 // Optional standard properties
358 beans::Property(
359 "CreatableContentsInfo",
361 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
362 beans::PropertyAttribute::BOUND
363 | beans::PropertyAttribute::READONLY )
365 // New properties
368 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
373 // virtual
374 uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
375 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
377 osl::Guard< osl::Mutex > aGuard( m_aMutex );
379 if ( m_eKind == LINK )
383 // Link: Supported commands
386 if ( isReadOnly() )
388 static const ucb::CommandInfo aLinkCommandInfoTable[] =
391 // Required commands
393 ucb::CommandInfo(
394 "getCommandInfo",
396 cppu::UnoType<void>::get()
398 ucb::CommandInfo(
399 "getPropertySetInfo",
401 cppu::UnoType<void>::get()
403 ucb::CommandInfo(
404 "getPropertyValues",
406 cppu::UnoType<uno::Sequence< beans::Property >>::get()
408 ucb::CommandInfo(
409 "setPropertyValues",
411 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
414 // Optional standard commands
417 // New commands
420 return MAKECMDSEQUENCE( aLinkCommandInfoTable );
422 else
424 static const ucb::CommandInfo aLinkCommandInfoTable[] =
427 // Required commands
429 ucb::CommandInfo(
430 "getCommandInfo",
432 cppu::UnoType<void>::get()
434 ucb::CommandInfo(
435 "getPropertySetInfo",
437 cppu::UnoType<void>::get()
439 ucb::CommandInfo(
440 "getPropertyValues",
442 cppu::UnoType<uno::Sequence< beans::Property >>::get()
444 ucb::CommandInfo(
445 "setPropertyValues",
447 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
450 // Optional standard commands
452 ucb::CommandInfo(
453 "delete",
455 cppu::UnoType<bool>::get()
457 ucb::CommandInfo(
458 "insert",
460 cppu::UnoType<void>::get()
463 // New commands
466 return MAKECMDSEQUENCE( aLinkCommandInfoTable );
469 else if ( m_eKind == FOLDER )
473 // Folder: Supported commands
476 if ( isReadOnly() )
478 static const ucb::CommandInfo aFolderCommandInfoTable[] =
481 // Required commands
483 ucb::CommandInfo(
484 "getCommandInfo",
486 cppu::UnoType<void>::get()
488 ucb::CommandInfo(
489 "getPropertySetInfo",
491 cppu::UnoType<void>::get()
493 ucb::CommandInfo(
494 "getPropertyValues",
496 cppu::UnoType<uno::Sequence< beans::Property >>::get()
498 ucb::CommandInfo(
499 "setPropertyValues",
501 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
504 // Optional standard commands
506 ucb::CommandInfo(
507 "open",
509 cppu::UnoType<ucb::OpenCommandArgument2>::get()
512 // New commands
515 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
517 else
519 static const ucb::CommandInfo aFolderCommandInfoTable[] =
522 // Required commands
524 ucb::CommandInfo(
525 "getCommandInfo",
527 cppu::UnoType<void>::get()
529 ucb::CommandInfo(
530 "getPropertySetInfo",
532 cppu::UnoType<void>::get()
534 ucb::CommandInfo(
535 "getPropertyValues",
537 cppu::UnoType<uno::Sequence< beans::Property >>::get()
539 ucb::CommandInfo(
540 "setPropertyValues",
542 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
545 // Optional standard commands
547 ucb::CommandInfo(
548 "delete",
550 cppu::UnoType<bool>::get()
552 ucb::CommandInfo(
553 "insert",
555 cppu::UnoType<void>::get()
557 ucb::CommandInfo(
558 "open",
560 cppu::UnoType<ucb::OpenCommandArgument2>::get()
562 ucb::CommandInfo(
563 "transfer",
565 cppu::UnoType<ucb::TransferInfo>::get()
567 ucb::CommandInfo(
568 "createNewContent",
570 cppu::UnoType<ucb::ContentInfo>::get()
573 // New commands
576 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
579 else
583 // Root Folder: Supported commands
586 if ( isReadOnly() )
588 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
591 // Required commands
593 ucb::CommandInfo(
594 "getCommandInfo",
596 cppu::UnoType<void>::get()
598 ucb::CommandInfo(
599 "getPropertySetInfo",
601 cppu::UnoType<void>::get()
603 ucb::CommandInfo(
604 "getPropertyValues",
606 cppu::UnoType<uno::Sequence< beans::Property >>::get()
608 ucb::CommandInfo(
609 "setPropertyValues",
611 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
614 // Optional standard commands
616 ucb::CommandInfo(
617 "open",
619 cppu::UnoType<ucb::OpenCommandArgument2>::get()
622 // New commands
625 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
627 else
629 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
632 // Required commands
634 ucb::CommandInfo(
635 "getCommandInfo",
637 cppu::UnoType<void>::get()
639 ucb::CommandInfo(
640 "getPropertySetInfo",
642 cppu::UnoType<void>::get()
644 ucb::CommandInfo(
645 "getPropertyValues",
647 cppu::UnoType<uno::Sequence< beans::Property >>::get()
649 ucb::CommandInfo(
650 "setPropertyValues",
652 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
655 // Optional standard commands
657 ucb::CommandInfo(
658 "open",
660 cppu::UnoType<ucb::OpenCommandArgument2>::get()
662 ucb::CommandInfo(
663 "transfer",
665 cppu::UnoType<ucb::TransferInfo>::get()
667 ucb::CommandInfo(
668 "createNewContent",
670 cppu::UnoType<ucb::ContentInfo>::get()
673 // New commands
676 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */