LibreOffice Module ucb (master) 1
hierarchycontentcaps.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21/**************************************************************************
22 TODO
23 **************************************************************************
24
25 **************************************************************************
26
27 Props/Commands:
28
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
38
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
48
49 *************************************************************************/
50
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"
60
61using namespace com::sun::star;
62using namespace hierarchy_ucp;
63
64
65// HierarchyContent implementation.
66
67
68#define MAKEPROPSEQUENCE( a ) \
69 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
70
71#define MAKECMDSEQUENCE( a ) \
72 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) )
73
74
75// IMPORTANT: If any property data ( name / type / ... ) are changed, then
76// HierarchyContent::getPropertyValues(...) must be adapted too!
77
78
79// virtual
80uno::Sequence< beans::Property > HierarchyContent::getProperties(
81 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
82{
83 osl::Guard< osl::Mutex > aGuard( m_aMutex );
84
85 if ( m_eKind == LINK )
86 {
87
88
89 // Link: Supported properties
90
91
92 if ( isReadOnly() )
93 {
94 static const beans::Property aLinkPropertyInfoTable[] =
95 {
96
97 // Required properties
98
99 beans::Property(
100 "ContentType",
101 -1,
103 beans::PropertyAttribute::BOUND
104 | beans::PropertyAttribute::READONLY
105 ),
106 beans::Property(
107 "IsDocument",
108 -1,
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::READONLY
112 ),
113 beans::Property(
114 "IsFolder",
115 -1,
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
119 ),
120 beans::Property(
121 "Title",
122 -1,
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
126 ),
127
128 // Optional standard properties
129
130 beans::Property(
131 "TargetURL",
132 -1,
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::READONLY
136 ),
137 beans::Property(
138 "CreatableContentsInfo",
139 -1,
140 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY )
143
144 // New properties
145
146 };
147 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
148 }
149 else
150 {
151 static const beans::Property aLinkPropertyInfoTable[] =
152 {
153
154 // Required properties
155
156 beans::Property(
157 "ContentType",
158 -1,
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::READONLY
162 ),
163 beans::Property(
164 "IsDocument",
165 -1,
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::READONLY
169 ),
170 beans::Property(
171 "IsFolder",
172 -1,
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
176 ),
177 beans::Property(
178 "Title",
179 -1,
181 beans::PropertyAttribute::BOUND
182 ),
183
184 // Optional standard properties
185
186 beans::Property(
187 "TargetURL",
188 -1,
190 beans::PropertyAttribute::BOUND
191 ),
192 beans::Property(
193 "CreatableContentsInfo",
194 -1,
195 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::READONLY )
198
199 // New properties
200
201 };
202 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
203 }
204 }
205 else if ( m_eKind == FOLDER )
206 {
207
208
209 // Folder: Supported properties
210
211
212 if ( isReadOnly() )
213 {
214 static const beans::Property aFolderPropertyInfoTable[] =
215 {
216
217 // Required properties
218
219 beans::Property(
220 "ContentType",
221 -1,
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::READONLY
225 ),
226 beans::Property(
227 "IsDocument",
228 -1,
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::READONLY
232 ),
233 beans::Property(
234 "IsFolder",
235 -1,
237 beans::PropertyAttribute::BOUND
238 | beans::PropertyAttribute::READONLY
239 ),
240 beans::Property(
241 "Title",
242 -1,
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::READONLY
246 ),
247
248 // Optional standard properties
249
250 beans::Property(
251 "CreatableContentsInfo",
252 -1,
253 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::READONLY )
256
257 // New properties
258
259 };
260 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
261 }
262 else
263 {
264 static const beans::Property aFolderPropertyInfoTable[] =
265 {
266
267 // Required properties
268
269 beans::Property(
270 "ContentType",
271 -1,
273 beans::PropertyAttribute::BOUND
274 | beans::PropertyAttribute::READONLY
275 ),
276 beans::Property(
277 "IsDocument",
278 -1,
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
282 ),
283 beans::Property(
284 "IsFolder",
285 -1,
287 beans::PropertyAttribute::BOUND
288 | beans::PropertyAttribute::READONLY
289 ),
290 beans::Property(
291 "Title",
292 -1,
294 beans::PropertyAttribute::BOUND
295 ),
296
297 // Optional standard properties
298
299 beans::Property(
300 "CreatableContentsInfo",
301 -1,
302 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
303 beans::PropertyAttribute::BOUND
304 | beans::PropertyAttribute::READONLY )
305
306 // New properties
307
308 };
309 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
310 }
311 }
312 else
313 {
314
315
316 // Root Folder: Supported properties
317
318
319 // Currently no difference between read-only/read-write
320 // -> all props are read-only
321
322 static const beans::Property aRootFolderPropertyInfoTable[] =
323 {
324
325 // Required properties
326
327 beans::Property(
328 "ContentType",
329 -1,
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
333 ),
334 beans::Property(
335 "IsDocument",
336 -1,
338 beans::PropertyAttribute::BOUND
339 | beans::PropertyAttribute::READONLY
340 ),
341 beans::Property(
342 "IsFolder",
343 -1,
345 beans::PropertyAttribute::BOUND
346 | beans::PropertyAttribute::READONLY
347 ),
348 beans::Property(
349 "Title",
350 -1,
352 beans::PropertyAttribute::BOUND
353 | beans::PropertyAttribute::READONLY
354 ),
355
356 // Optional standard properties
357
358 beans::Property(
359 "CreatableContentsInfo",
360 -1,
361 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
362 beans::PropertyAttribute::BOUND
363 | beans::PropertyAttribute::READONLY )
364
365 // New properties
366
367 };
368 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
369 }
370}
371
372
373// virtual
374uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
375 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
376{
377 osl::Guard< osl::Mutex > aGuard( m_aMutex );
378
379 if ( m_eKind == LINK )
380 {
381
382
383 // Link: Supported commands
384
385
386 if ( isReadOnly() )
387 {
388 static const ucb::CommandInfo aLinkCommandInfoTable[] =
389 {
390
391 // Required commands
392
393 ucb::CommandInfo(
394 "getCommandInfo",
395 -1,
397 ),
398 ucb::CommandInfo(
399 "getPropertySetInfo",
400 -1,
402 ),
403 ucb::CommandInfo(
404 "getPropertyValues",
405 -1,
406 cppu::UnoType<uno::Sequence< beans::Property >>::get()
407 ),
408 ucb::CommandInfo(
409 "setPropertyValues",
410 -1,
411 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
412 )
413
414 // Optional standard commands
415
416
417 // New commands
418
419 };
420 return MAKECMDSEQUENCE( aLinkCommandInfoTable );
421 }
422 else
423 {
424 static const ucb::CommandInfo aLinkCommandInfoTable[] =
425 {
426
427 // Required commands
428
429 ucb::CommandInfo(
430 "getCommandInfo",
431 -1,
433 ),
434 ucb::CommandInfo(
435 "getPropertySetInfo",
436 -1,
438 ),
439 ucb::CommandInfo(
440 "getPropertyValues",
441 -1,
442 cppu::UnoType<uno::Sequence< beans::Property >>::get()
443 ),
444 ucb::CommandInfo(
445 "setPropertyValues",
446 -1,
447 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
448 ),
449
450 // Optional standard commands
451
452 ucb::CommandInfo(
453 "delete",
454 -1,
456 ),
457 ucb::CommandInfo(
458 "insert",
459 -1,
461 )
462
463 // New commands
464
465 };
466 return MAKECMDSEQUENCE( aLinkCommandInfoTable );
467 }
468 }
469 else if ( m_eKind == FOLDER )
470 {
471
472
473 // Folder: Supported commands
474
475
476 if ( isReadOnly() )
477 {
478 static const ucb::CommandInfo aFolderCommandInfoTable[] =
479 {
480
481 // Required commands
482
483 ucb::CommandInfo(
484 "getCommandInfo",
485 -1,
487 ),
488 ucb::CommandInfo(
489 "getPropertySetInfo",
490 -1,
492 ),
493 ucb::CommandInfo(
494 "getPropertyValues",
495 -1,
496 cppu::UnoType<uno::Sequence< beans::Property >>::get()
497 ),
498 ucb::CommandInfo(
499 "setPropertyValues",
500 -1,
501 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
502 ),
503
504 // Optional standard commands
505
506 ucb::CommandInfo(
507 "open",
508 -1,
510 )
511
512 // New commands
513
514 };
515 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
516 }
517 else
518 {
519 static const ucb::CommandInfo aFolderCommandInfoTable[] =
520 {
521
522 // Required commands
523
524 ucb::CommandInfo(
525 "getCommandInfo",
526 -1,
528 ),
529 ucb::CommandInfo(
530 "getPropertySetInfo",
531 -1,
533 ),
534 ucb::CommandInfo(
535 "getPropertyValues",
536 -1,
537 cppu::UnoType<uno::Sequence< beans::Property >>::get()
538 ),
539 ucb::CommandInfo(
540 "setPropertyValues",
541 -1,
542 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
543 ),
544
545 // Optional standard commands
546
547 ucb::CommandInfo(
548 "delete",
549 -1,
551 ),
552 ucb::CommandInfo(
553 "insert",
554 -1,
556 ),
557 ucb::CommandInfo(
558 "open",
559 -1,
561 ),
562 ucb::CommandInfo(
563 "transfer",
564 -1,
566 ),
567 ucb::CommandInfo(
568 "createNewContent",
569 -1,
571 )
572
573 // New commands
574
575 };
576 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
577 }
578 }
579 else
580 {
581
582
583 // Root Folder: Supported commands
584
585
586 if ( isReadOnly() )
587 {
588 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
589 {
590
591 // Required commands
592
593 ucb::CommandInfo(
594 "getCommandInfo",
595 -1,
597 ),
598 ucb::CommandInfo(
599 "getPropertySetInfo",
600 -1,
602 ),
603 ucb::CommandInfo(
604 "getPropertyValues",
605 -1,
606 cppu::UnoType<uno::Sequence< beans::Property >>::get()
607 ),
608 ucb::CommandInfo(
609 "setPropertyValues",
610 -1,
611 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
612 ),
613
614 // Optional standard commands
615
616 ucb::CommandInfo(
617 "open",
618 -1,
620 )
621
622 // New commands
623
624 };
625 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
626 }
627 else
628 {
629 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
630 {
631
632 // Required commands
633
634 ucb::CommandInfo(
635 "getCommandInfo",
636 -1,
638 ),
639 ucb::CommandInfo(
640 "getPropertySetInfo",
641 -1,
643 ),
644 ucb::CommandInfo(
645 "getPropertyValues",
646 -1,
647 cppu::UnoType<uno::Sequence< beans::Property >>::get()
648 ),
649 ucb::CommandInfo(
650 "setPropertyValues",
651 -1,
652 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
653 ),
654
655 // Optional standard commands
656
657 ucb::CommandInfo(
658 "open",
659 -1,
661 ),
662 ucb::CommandInfo(
663 "transfer",
664 -1,
666 ),
667 ucb::CommandInfo(
668 "createNewContent",
669 -1,
671 )
672
673 // New commands
674
675 };
676 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
677 }
678 }
679}
680
681/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
#define MAKECMDSEQUENCE(a)
#define MAKEPROPSEQUENCE(a)