Debian Codegraph @

ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx

raw
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
61 using namespace com::sun::star;
62 using 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
80 uno::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 u"ContentType"_ustr,
101 -1,
102 cppu::UnoType<OUString>::get(),
103 beans::PropertyAttribute::BOUND
104 | beans::PropertyAttribute::READONLY
105 ),
106 beans::Property(
107 u"IsDocument"_ustr,
108 -1,
109 cppu::UnoType<bool>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::READONLY
112 ),
113 beans::Property(
114 u"IsFolder"_ustr,
115 -1,
116 cppu::UnoType<bool>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
119 ),
120 beans::Property(
121 u"Title"_ustr,
122 -1,
123 cppu::UnoType<OUString>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
126 ),
127
128 // Optional standard properties
129
130 beans::Property(
131 u"TargetURL"_ustr,
132 -1,
133 cppu::UnoType<OUString>::get(),
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::READONLY
136 ),
137 beans::Property(
138 u"CreatableContentsInfo"_ustr,
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 u"ContentType"_ustr,
158 -1,
159 cppu::UnoType<OUString>::get(),
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::READONLY
162 ),
163 beans::Property(
164 u"IsDocument"_ustr,
165 -1,
166 cppu::UnoType<bool>::get(),
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::READONLY
169 ),
170 beans::Property(
171 u"IsFolder"_ustr,
172 -1,
173 cppu::UnoType<bool>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
176 ),
177 beans::Property(
178 u"Title"_ustr,
179 -1,
180 cppu::UnoType<OUString>::get(),
181 beans::PropertyAttribute::BOUND
182 ),
183
184 // Optional standard properties
185
186 beans::Property(
187 u"TargetURL"_ustr,
188 -1,
189 cppu::UnoType<OUString>::get(),
190 beans::PropertyAttribute::BOUND
191 ),
192 beans::Property(
193 u"CreatableContentsInfo"_ustr,
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 u"ContentType"_ustr,
221 -1,
222 cppu::UnoType<OUString>::get(),
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::READONLY
225 ),
226 beans::Property(
227 u"IsDocument"_ustr,
228 -1,
229 cppu::UnoType<bool>::get(),
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::READONLY
232 ),
233 beans::Property(
234 u"IsFolder"_ustr,
235 -1,
236 cppu::UnoType<bool>::get(),
237 beans::PropertyAttribute::BOUND
238 | beans::PropertyAttribute::READONLY
239 ),
240 beans::Property(
241 u"Title"_ustr,
242 -1,
243 cppu::UnoType<OUString>::get(),
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::READONLY
246 ),
247
248 // Optional standard properties
249
250 beans::Property(
251 u"CreatableContentsInfo"_ustr,
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 u"ContentType"_ustr,
271 -1,
272 cppu::UnoType<OUString>::get(),
273 beans::PropertyAttribute::BOUND
274 | beans::PropertyAttribute::READONLY
275 ),
276 beans::Property(
277 u"IsDocument"_ustr,
278 -1,
279 cppu::UnoType<bool>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
282 ),
283 beans::Property(
284 u"IsFolder"_ustr,
285 -1,
286 cppu::UnoType<bool>::get(),
287 beans::PropertyAttribute::BOUND
288 | beans::PropertyAttribute::READONLY
289 ),
290 beans::Property(
291 u"Title"_ustr,
292 -1,
293 cppu::UnoType<OUString>::get(),
294 beans::PropertyAttribute::BOUND
295 ),
296
297 // Optional standard properties
298
299 beans::Property(
300 u"CreatableContentsInfo"_ustr,
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 u"ContentType"_ustr,
329 -1,
330 cppu::UnoType<OUString>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
333 ),
334 beans::Property(
335 u"IsDocument"_ustr,
336 -1,
337 cppu::UnoType<bool>::get(),
338 beans::PropertyAttribute::BOUND
339 | beans::PropertyAttribute::READONLY
340 ),
341 beans::Property(
342 u"IsFolder"_ustr,
343 -1,
344 cppu::UnoType<bool>::get(),
345 beans::PropertyAttribute::BOUND
346 | beans::PropertyAttribute::READONLY
347 ),
348 beans::Property(
349 u"Title"_ustr,
350 -1,
351 cppu::UnoType<OUString>::get(),
352 beans::PropertyAttribute::BOUND
353 | beans::PropertyAttribute::READONLY
354 ),
355
356 // Optional standard properties
357
358 beans::Property(
359 u"CreatableContentsInfo"_ustr,
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
374 uno::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 u"getCommandInfo"_ustr,
395 -1,
396 cppu::UnoType<void>::get()
397 ),
398 ucb::CommandInfo(
399 u"getPropertySetInfo"_ustr,
400 -1,
401 cppu::UnoType<void>::get()
402 ),
403 ucb::CommandInfo(
404 u"getPropertyValues"_ustr,
405 -1,
406 cppu::UnoType<uno::Sequence< beans::Property >>::get()
407 ),
408 ucb::CommandInfo(
409 u"setPropertyValues"_ustr,
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 u"getCommandInfo"_ustr,
431 -1,
432 cppu::UnoType<void>::get()
433 ),
434 ucb::CommandInfo(
435 u"getPropertySetInfo"_ustr,
436 -1,
437 cppu::UnoType<void>::get()
438 ),
439 ucb::CommandInfo(
440 u"getPropertyValues"_ustr,
441 -1,
442 cppu::UnoType<uno::Sequence< beans::Property >>::get()
443 ),
444 ucb::CommandInfo(
445 u"setPropertyValues"_ustr,
446 -1,
447 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
448 ),
449
450 // Optional standard commands
451
452 ucb::CommandInfo(
453 u"delete"_ustr,
454 -1,
455 cppu::UnoType<bool>::get()
456 ),
457 ucb::CommandInfo(
458 u"insert"_ustr,
459 -1,
460 cppu::UnoType<void>::get()
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 u"getCommandInfo"_ustr,
485 -1,
486 cppu::UnoType<void>::get()
487 ),
488 ucb::CommandInfo(
489 u"getPropertySetInfo"_ustr,
490 -1,
491 cppu::UnoType<void>::get()
492 ),
493 ucb::CommandInfo(
494 u"getPropertyValues"_ustr,
495 -1,
496 cppu::UnoType<uno::Sequence< beans::Property >>::get()
497 ),
498 ucb::CommandInfo(
499 u"setPropertyValues"_ustr,
500 -1,
501 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
502 ),
503
504 // Optional standard commands
505
506 ucb::CommandInfo(
507 u"open"_ustr,
508 -1,
509 cppu::UnoType<ucb::OpenCommandArgument2>::get()
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 u"getCommandInfo"_ustr,
526 -1,
527 cppu::UnoType<void>::get()
528 ),
529 ucb::CommandInfo(
530 u"getPropertySetInfo"_ustr,
531 -1,
532 cppu::UnoType<void>::get()
533 ),
534 ucb::CommandInfo(
535 u"getPropertyValues"_ustr,
536 -1,
537 cppu::UnoType<uno::Sequence< beans::Property >>::get()
538 ),
539 ucb::CommandInfo(
540 u"setPropertyValues"_ustr,
541 -1,
542 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
543 ),
544
545 // Optional standard commands
546
547 ucb::CommandInfo(
548 u"delete"_ustr,
549 -1,
550 cppu::UnoType<bool>::get()
551 ),
552 ucb::CommandInfo(
553 u"insert"_ustr,
554 -1,
555 cppu::UnoType<void>::get()
556 ),
557 ucb::CommandInfo(
558 u"open"_ustr,
559 -1,
560 cppu::UnoType<ucb::OpenCommandArgument2>::get()
561 ),
562 ucb::CommandInfo(
563 u"transfer"_ustr,
564 -1,
565 cppu::UnoType<ucb::TransferInfo>::get()
566 ),
567 ucb::CommandInfo(
568 u"createNewContent"_ustr,
569 -1,
570 cppu::UnoType<ucb::ContentInfo>::get()
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 u"getCommandInfo"_ustr,
595 -1,
596 cppu::UnoType<void>::get()
597 ),
598 ucb::CommandInfo(
599 u"getPropertySetInfo"_ustr,
600 -1,
601 cppu::UnoType<void>::get()
602 ),
603 ucb::CommandInfo(
604 u"getPropertyValues"_ustr,
605 -1,
606 cppu::UnoType<uno::Sequence< beans::Property >>::get()
607 ),
608 ucb::CommandInfo(
609 u"setPropertyValues"_ustr,
610 -1,
611 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
612 ),
613
614 // Optional standard commands
615
616 ucb::CommandInfo(
617 u"open"_ustr,
618 -1,
619 cppu::UnoType<ucb::OpenCommandArgument2>::get()
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 u"getCommandInfo"_ustr,
636 -1,
637 cppu::UnoType<void>::get()
638 ),
639 ucb::CommandInfo(
640 u"getPropertySetInfo"_ustr,
641 -1,
642 cppu::UnoType<void>::get()
643 ),
644 ucb::CommandInfo(
645 u"getPropertyValues"_ustr,
646 -1,
647 cppu::UnoType<uno::Sequence< beans::Property >>::get()
648 ),
649 ucb::CommandInfo(
650 u"setPropertyValues"_ustr,
651 -1,
652 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
653 ),
654
655 // Optional standard commands
656
657 ucb::CommandInfo(
658 u"open"_ustr,
659 -1,
660 cppu::UnoType<ucb::OpenCommandArgument2>::get()
661 ),
662 ucb::CommandInfo(
663 u"transfer"_ustr,
664 -1,
665 cppu::UnoType<ucb::TransferInfo>::get()
666 ),
667 ucb::CommandInfo(
668 u"createNewContent"_ustr,
669 -1,
670 cppu::UnoType<ucb::ContentInfo>::get()
671 )
672
673 // New commands
674
675 };
676 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
677 }
678 }
679 }
680
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */