Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx
Line
Count
Source
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
0
    uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
70
71
#define MAKECMDSEQUENCE( a ) \
72
0
    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
0
{
83
0
    osl::Guard< osl::Mutex > aGuard( m_aMutex );
84
85
0
    if ( m_eKind == LINK )
86
0
    {
87
88
89
        // Link: Supported properties
90
91
92
0
        if ( isReadOnly() )
93
0
        {
94
0
            static const beans::Property aLinkPropertyInfoTable[] =
95
0
            {
96
97
                // Required properties
98
99
0
                beans::Property(
100
0
                    u"ContentType"_ustr,
101
0
                    -1,
102
0
                    cppu::UnoType<OUString>::get(),
103
0
                    beans::PropertyAttribute::BOUND
104
0
                        | beans::PropertyAttribute::READONLY
105
0
                ),
106
0
                beans::Property(
107
0
                    u"IsDocument"_ustr,
108
0
                    -1,
109
0
                    cppu::UnoType<bool>::get(),
110
0
                    beans::PropertyAttribute::BOUND
111
0
                        | beans::PropertyAttribute::READONLY
112
0
                ),
113
0
                beans::Property(
114
0
                    u"IsFolder"_ustr,
115
0
                    -1,
116
0
                    cppu::UnoType<bool>::get(),
117
0
                    beans::PropertyAttribute::BOUND
118
0
                        | beans::PropertyAttribute::READONLY
119
0
                ),
120
0
                beans::Property(
121
0
                    u"Title"_ustr,
122
0
                    -1,
123
0
                    cppu::UnoType<OUString>::get(),
124
0
                    beans::PropertyAttribute::BOUND
125
0
                        | beans::PropertyAttribute::READONLY
126
0
                ),
127
128
                // Optional standard properties
129
130
0
                beans::Property(
131
0
                    u"TargetURL"_ustr,
132
0
                    -1,
133
0
                    cppu::UnoType<OUString>::get(),
134
0
                    beans::PropertyAttribute::BOUND
135
0
                        | beans::PropertyAttribute::READONLY
136
0
                ),
137
0
                beans::Property(
138
0
                    u"CreatableContentsInfo"_ustr,
139
0
                    -1,
140
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
141
0
                    beans::PropertyAttribute::BOUND
142
0
                        | beans::PropertyAttribute::READONLY )
143
144
                // New properties
145
146
0
            };
147
0
            return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
148
0
        }
149
0
        else
150
0
        {
151
0
            static const beans::Property aLinkPropertyInfoTable[] =
152
0
            {
153
154
                // Required properties
155
156
0
                beans::Property(
157
0
                    u"ContentType"_ustr,
158
0
                    -1,
159
0
                    cppu::UnoType<OUString>::get(),
160
0
                    beans::PropertyAttribute::BOUND
161
0
                        | beans::PropertyAttribute::READONLY
162
0
                ),
163
0
                beans::Property(
164
0
                    u"IsDocument"_ustr,
165
0
                    -1,
166
0
                    cppu::UnoType<bool>::get(),
167
0
                    beans::PropertyAttribute::BOUND
168
0
                        | beans::PropertyAttribute::READONLY
169
0
                ),
170
0
                beans::Property(
171
0
                    u"IsFolder"_ustr,
172
0
                    -1,
173
0
                    cppu::UnoType<bool>::get(),
174
0
                    beans::PropertyAttribute::BOUND
175
0
                        | beans::PropertyAttribute::READONLY
176
0
                ),
177
0
                beans::Property(
178
0
                    u"Title"_ustr,
179
0
                    -1,
180
0
                    cppu::UnoType<OUString>::get(),
181
0
                    beans::PropertyAttribute::BOUND
182
0
                ),
183
184
                // Optional standard properties
185
186
0
                beans::Property(
187
0
                    u"TargetURL"_ustr,
188
0
                    -1,
189
0
                    cppu::UnoType<OUString>::get(),
190
0
                    beans::PropertyAttribute::BOUND
191
0
                ),
192
0
                beans::Property(
193
0
                    u"CreatableContentsInfo"_ustr,
194
0
                    -1,
195
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
196
0
                    beans::PropertyAttribute::BOUND
197
0
                        | beans::PropertyAttribute::READONLY )
198
199
                // New properties
200
201
0
            };
202
0
            return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
203
0
        }
204
0
    }
205
0
    else if ( m_eKind == FOLDER )
206
0
    {
207
208
209
        // Folder: Supported properties
210
211
212
0
        if ( isReadOnly() )
213
0
        {
214
0
            static const beans::Property aFolderPropertyInfoTable[] =
215
0
            {
216
217
                // Required properties
218
219
0
                beans::Property(
220
0
                    u"ContentType"_ustr,
221
0
                    -1,
222
0
                    cppu::UnoType<OUString>::get(),
223
0
                    beans::PropertyAttribute::BOUND
224
0
                        | beans::PropertyAttribute::READONLY
225
0
                ),
226
0
                beans::Property(
227
0
                    u"IsDocument"_ustr,
228
0
                    -1,
229
0
                    cppu::UnoType<bool>::get(),
230
0
                    beans::PropertyAttribute::BOUND
231
0
                        | beans::PropertyAttribute::READONLY
232
0
                ),
233
0
                beans::Property(
234
0
                    u"IsFolder"_ustr,
235
0
                    -1,
236
0
                    cppu::UnoType<bool>::get(),
237
0
                    beans::PropertyAttribute::BOUND
238
0
                        | beans::PropertyAttribute::READONLY
239
0
                ),
240
0
                beans::Property(
241
0
                    u"Title"_ustr,
242
0
                    -1,
243
0
                    cppu::UnoType<OUString>::get(),
244
0
                    beans::PropertyAttribute::BOUND
245
0
                        | beans::PropertyAttribute::READONLY
246
0
                ),
247
248
                // Optional standard properties
249
250
0
                beans::Property(
251
0
                    u"CreatableContentsInfo"_ustr,
252
0
                    -1,
253
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
254
0
                    beans::PropertyAttribute::BOUND
255
0
                        | beans::PropertyAttribute::READONLY )
256
257
                // New properties
258
259
0
            };
260
0
            return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
261
0
        }
262
0
        else
263
0
        {
264
0
            static const beans::Property aFolderPropertyInfoTable[] =
265
0
            {
266
267
                // Required properties
268
269
0
                beans::Property(
270
0
                    u"ContentType"_ustr,
271
0
                    -1,
272
0
                    cppu::UnoType<OUString>::get(),
273
0
                    beans::PropertyAttribute::BOUND
274
0
                        | beans::PropertyAttribute::READONLY
275
0
                ),
276
0
                beans::Property(
277
0
                    u"IsDocument"_ustr,
278
0
                    -1,
279
0
                    cppu::UnoType<bool>::get(),
280
0
                    beans::PropertyAttribute::BOUND
281
0
                        | beans::PropertyAttribute::READONLY
282
0
                ),
283
0
                beans::Property(
284
0
                    u"IsFolder"_ustr,
285
0
                    -1,
286
0
                    cppu::UnoType<bool>::get(),
287
0
                    beans::PropertyAttribute::BOUND
288
0
                        | beans::PropertyAttribute::READONLY
289
0
                ),
290
0
                beans::Property(
291
0
                    u"Title"_ustr,
292
0
                    -1,
293
0
                    cppu::UnoType<OUString>::get(),
294
0
                    beans::PropertyAttribute::BOUND
295
0
                ),
296
297
                // Optional standard properties
298
299
0
                beans::Property(
300
0
                    u"CreatableContentsInfo"_ustr,
301
0
                    -1,
302
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
303
0
                    beans::PropertyAttribute::BOUND
304
0
                        | beans::PropertyAttribute::READONLY )
305
306
                // New properties
307
308
0
            };
309
0
            return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
310
0
        }
311
0
    }
312
0
    else
313
0
    {
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
0
        static const beans::Property aRootFolderPropertyInfoTable[] =
323
0
        {
324
325
            // Required properties
326
327
0
            beans::Property(
328
0
                u"ContentType"_ustr,
329
0
                -1,
330
0
                cppu::UnoType<OUString>::get(),
331
0
                beans::PropertyAttribute::BOUND
332
0
                    | beans::PropertyAttribute::READONLY
333
0
            ),
334
0
            beans::Property(
335
0
                u"IsDocument"_ustr,
336
0
                -1,
337
0
                cppu::UnoType<bool>::get(),
338
0
                beans::PropertyAttribute::BOUND
339
0
                    | beans::PropertyAttribute::READONLY
340
0
            ),
341
0
            beans::Property(
342
0
                u"IsFolder"_ustr,
343
0
                -1,
344
0
                cppu::UnoType<bool>::get(),
345
0
                beans::PropertyAttribute::BOUND
346
0
                    | beans::PropertyAttribute::READONLY
347
0
            ),
348
0
            beans::Property(
349
0
                u"Title"_ustr,
350
0
                -1,
351
0
                cppu::UnoType<OUString>::get(),
352
0
                beans::PropertyAttribute::BOUND
353
0
                    | beans::PropertyAttribute::READONLY
354
0
            ),
355
356
            // Optional standard properties
357
358
0
            beans::Property(
359
0
                    u"CreatableContentsInfo"_ustr,
360
0
                    -1,
361
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
362
0
                    beans::PropertyAttribute::BOUND
363
0
                        | beans::PropertyAttribute::READONLY )
364
365
            // New properties
366
367
0
        };
368
0
        return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
369
0
    }
370
0
}
371
372
373
// virtual
374
uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
375
            const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
376
0
{
377
0
    osl::Guard< osl::Mutex > aGuard( m_aMutex );
378
379
0
    if ( m_eKind == LINK )
380
0
    {
381
382
383
        // Link: Supported commands
384
385
386
0
        if ( isReadOnly() )
387
0
        {
388
0
            static const ucb::CommandInfo aLinkCommandInfoTable[] =
389
0
            {
390
391
                // Required commands
392
393
0
                ucb::CommandInfo(
394
0
                    u"getCommandInfo"_ustr,
395
0
                    -1,
396
0
                    cppu::UnoType<void>::get()
397
0
                ),
398
0
                ucb::CommandInfo(
399
0
                    u"getPropertySetInfo"_ustr,
400
0
                    -1,
401
0
                    cppu::UnoType<void>::get()
402
0
                ),
403
0
                ucb::CommandInfo(
404
0
                    u"getPropertyValues"_ustr,
405
0
                    -1,
406
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
407
0
                ),
408
0
                ucb::CommandInfo(
409
0
                    u"setPropertyValues"_ustr,
410
0
                    -1,
411
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
412
0
                )
413
414
                // Optional standard commands
415
416
417
                // New commands
418
419
0
            };
420
0
            return MAKECMDSEQUENCE( aLinkCommandInfoTable );
421
0
        }
422
0
        else
423
0
        {
424
0
            static const ucb::CommandInfo aLinkCommandInfoTable[] =
425
0
            {
426
427
                // Required commands
428
429
0
                ucb::CommandInfo(
430
0
                    u"getCommandInfo"_ustr,
431
0
                    -1,
432
0
                    cppu::UnoType<void>::get()
433
0
                ),
434
0
                ucb::CommandInfo(
435
0
                    u"getPropertySetInfo"_ustr,
436
0
                    -1,
437
0
                    cppu::UnoType<void>::get()
438
0
                ),
439
0
                ucb::CommandInfo(
440
0
                    u"getPropertyValues"_ustr,
441
0
                    -1,
442
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
443
0
                ),
444
0
                ucb::CommandInfo(
445
0
                    u"setPropertyValues"_ustr,
446
0
                    -1,
447
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
448
0
                ),
449
450
                // Optional standard commands
451
452
0
                ucb::CommandInfo(
453
0
                    u"delete"_ustr,
454
0
                    -1,
455
0
                    cppu::UnoType<bool>::get()
456
0
                ),
457
0
                ucb::CommandInfo(
458
0
                    u"insert"_ustr,
459
0
                    -1,
460
0
                    cppu::UnoType<void>::get()
461
0
                )
462
463
                // New commands
464
465
0
            };
466
0
            return MAKECMDSEQUENCE( aLinkCommandInfoTable );
467
0
        }
468
0
    }
469
0
    else if ( m_eKind == FOLDER )
470
0
    {
471
472
473
        // Folder: Supported commands
474
475
476
0
        if ( isReadOnly() )
477
0
        {
478
0
            static const ucb::CommandInfo aFolderCommandInfoTable[] =
479
0
            {
480
481
                // Required commands
482
483
0
                ucb::CommandInfo(
484
0
                    u"getCommandInfo"_ustr,
485
0
                    -1,
486
0
                    cppu::UnoType<void>::get()
487
0
                ),
488
0
                ucb::CommandInfo(
489
0
                    u"getPropertySetInfo"_ustr,
490
0
                    -1,
491
0
                    cppu::UnoType<void>::get()
492
0
                ),
493
0
                ucb::CommandInfo(
494
0
                    u"getPropertyValues"_ustr,
495
0
                    -1,
496
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
497
0
                ),
498
0
                ucb::CommandInfo(
499
0
                    u"setPropertyValues"_ustr,
500
0
                    -1,
501
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
502
0
                ),
503
504
                // Optional standard commands
505
506
0
                ucb::CommandInfo(
507
0
                    u"open"_ustr,
508
0
                    -1,
509
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
510
0
                )
511
512
                // New commands
513
514
0
            };
515
0
            return MAKECMDSEQUENCE( aFolderCommandInfoTable );
516
0
        }
517
0
        else
518
0
        {
519
0
            static const ucb::CommandInfo aFolderCommandInfoTable[] =
520
0
            {
521
522
                // Required commands
523
524
0
                ucb::CommandInfo(
525
0
                    u"getCommandInfo"_ustr,
526
0
                    -1,
527
0
                    cppu::UnoType<void>::get()
528
0
                ),
529
0
                ucb::CommandInfo(
530
0
                    u"getPropertySetInfo"_ustr,
531
0
                    -1,
532
0
                    cppu::UnoType<void>::get()
533
0
                ),
534
0
                ucb::CommandInfo(
535
0
                    u"getPropertyValues"_ustr,
536
0
                    -1,
537
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
538
0
                ),
539
0
                ucb::CommandInfo(
540
0
                    u"setPropertyValues"_ustr,
541
0
                    -1,
542
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
543
0
                ),
544
545
                // Optional standard commands
546
547
0
                ucb::CommandInfo(
548
0
                    u"delete"_ustr,
549
0
                    -1,
550
0
                    cppu::UnoType<bool>::get()
551
0
                ),
552
0
                ucb::CommandInfo(
553
0
                    u"insert"_ustr,
554
0
                    -1,
555
0
                    cppu::UnoType<void>::get()
556
0
                ),
557
0
                ucb::CommandInfo(
558
0
                    u"open"_ustr,
559
0
                    -1,
560
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
561
0
                ),
562
0
                ucb::CommandInfo(
563
0
                    u"transfer"_ustr,
564
0
                    -1,
565
0
                    cppu::UnoType<ucb::TransferInfo>::get()
566
0
                ),
567
0
                ucb::CommandInfo(
568
0
                    u"createNewContent"_ustr,
569
0
                    -1,
570
0
                    cppu::UnoType<ucb::ContentInfo>::get()
571
0
                )
572
573
                // New commands
574
575
0
            };
576
0
            return MAKECMDSEQUENCE( aFolderCommandInfoTable );
577
0
        }
578
0
    }
579
0
    else
580
0
    {
581
582
583
        // Root Folder: Supported commands
584
585
586
0
        if ( isReadOnly() )
587
0
        {
588
0
            static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
589
0
            {
590
591
                // Required commands
592
593
0
                ucb::CommandInfo(
594
0
                    u"getCommandInfo"_ustr,
595
0
                    -1,
596
0
                    cppu::UnoType<void>::get()
597
0
                ),
598
0
                ucb::CommandInfo(
599
0
                    u"getPropertySetInfo"_ustr,
600
0
                    -1,
601
0
                    cppu::UnoType<void>::get()
602
0
                ),
603
0
                ucb::CommandInfo(
604
0
                    u"getPropertyValues"_ustr,
605
0
                    -1,
606
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
607
0
                ),
608
0
                ucb::CommandInfo(
609
0
                    u"setPropertyValues"_ustr,
610
0
                    -1,
611
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
612
0
                ),
613
614
                // Optional standard commands
615
616
0
                ucb::CommandInfo(
617
0
                    u"open"_ustr,
618
0
                    -1,
619
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
620
0
                )
621
622
                // New commands
623
624
0
            };
625
0
            return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
626
0
        }
627
0
        else
628
0
        {
629
0
            static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
630
0
            {
631
632
                // Required commands
633
634
0
                ucb::CommandInfo(
635
0
                    u"getCommandInfo"_ustr,
636
0
                    -1,
637
0
                    cppu::UnoType<void>::get()
638
0
                ),
639
0
                ucb::CommandInfo(
640
0
                    u"getPropertySetInfo"_ustr,
641
0
                    -1,
642
0
                    cppu::UnoType<void>::get()
643
0
                ),
644
0
                ucb::CommandInfo(
645
0
                    u"getPropertyValues"_ustr,
646
0
                    -1,
647
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
648
0
                ),
649
0
                ucb::CommandInfo(
650
0
                    u"setPropertyValues"_ustr,
651
0
                    -1,
652
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
653
0
                ),
654
655
                // Optional standard commands
656
657
0
                ucb::CommandInfo(
658
0
                    u"open"_ustr,
659
0
                    -1,
660
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
661
0
                ),
662
0
                ucb::CommandInfo(
663
0
                    u"transfer"_ustr,
664
0
                    -1,
665
0
                    cppu::UnoType<ucb::TransferInfo>::get()
666
0
                ),
667
0
                ucb::CommandInfo(
668
0
                    u"createNewContent"_ustr,
669
0
                    -1,
670
0
                    cppu::UnoType<ucb::ContentInfo>::get()
671
0
                )
672
673
                // New commands
674
675
0
            };
676
0
            return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
677
0
        }
678
0
    }
679
0
}
680
681
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */