Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/ucb/source/ucp/package/pkgcontentcaps.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
    Props/Commands:
26
27
                        rootfolder folder  stream
28
    ---------------------------------------------
29
    ContentType           r         r         r
30
    IsDocument            r         r         r
31
    IsFolder              r         r         r
32
    MediaType            (w)       (w)        w
33
    Title                 r         w         w
34
    Size                  -         -         r
35
    CreatableContentsInfo r         r         r
36
    Compressed            -         -         w
37
    Encrypted             -         -         w
38
    HasEncryptedEntries   r         -         -
39
40
    getCommandInfo        x         x         x
41
    getPropertySetInfo    x         x         x
42
    getPropertyValues     x         x         x
43
    setPropertyValues     x         x         x
44
    insert                -         x         x
45
    delete                -         x         x
46
    open                  x         x         x
47
    transfer              x         x         -
48
    flush                 x         x         -
49
    createNewContent      x         x         -
50
51
 *************************************************************************/
52
#include <com/sun/star/beans/Property.hpp>
53
#include <com/sun/star/beans/PropertyAttribute.hpp>
54
#include <com/sun/star/beans/PropertyValue.hpp>
55
#include <com/sun/star/ucb/CommandInfo.hpp>
56
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
57
#include <com/sun/star/ucb/TransferInfo.hpp>
58
#include <com/sun/star/uno/Sequence.hxx>
59
#include <sal/macros.h>
60
#include "pkgcontent.hxx"
61
62
using namespace com::sun::star;
63
using namespace package_ucp;
64
65
66
// Content implementation.
67
68
69
#define MAKEPROPSEQUENCE( a ) \
70
0
    uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
71
72
#define MAKECMDSEQUENCE( a ) \
73
0
    uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) )
74
75
76
// IMPORTANT: If any property data ( name / type / ... ) are changed, then
77
//            Content::getPropertyValues(...) must be adapted too!
78
79
80
// virtual
81
uno::Sequence< beans::Property > Content::getProperties(
82
            const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
83
0
{
84
0
    osl::Guard< osl::Mutex > aGuard( m_aMutex );
85
86
0
    if ( isFolder() )
87
0
    {
88
0
        if ( m_aUri.isRootFolder() )
89
0
        {
90
91
92
            // Root Folder: Supported properties
93
94
95
0
            static const beans::Property aRootFolderPropertyInfoTable[] =
96
0
            {
97
98
                // Required properties
99
100
0
                beans::Property(
101
0
                    u"ContentType"_ustr,
102
0
                    -1,
103
0
                    cppu::UnoType<OUString>::get(),
104
0
                    beans::PropertyAttribute::BOUND
105
0
                        | beans::PropertyAttribute::READONLY
106
0
                ),
107
0
                beans::Property(
108
0
                    u"IsDocument"_ustr,
109
0
                    -1,
110
0
                    cppu::UnoType<bool>::get(),
111
0
                    beans::PropertyAttribute::BOUND
112
0
                        | beans::PropertyAttribute::READONLY
113
0
                ),
114
0
                beans::Property(
115
0
                    u"IsFolder"_ustr,
116
0
                    -1,
117
0
                    cppu::UnoType<bool>::get(),
118
0
                    beans::PropertyAttribute::BOUND
119
0
                        | beans::PropertyAttribute::READONLY
120
0
                ),
121
0
                beans::Property(
122
0
                    u"Title"_ustr,
123
0
                    -1,
124
0
                    cppu::UnoType<OUString>::get(),
125
0
                    beans::PropertyAttribute::BOUND
126
0
                        | beans::PropertyAttribute::READONLY
127
0
                ),
128
129
                // Optional standard properties
130
131
0
                beans::Property(
132
0
                    u"MediaType"_ustr,
133
0
                    -1,
134
0
                    cppu::UnoType<OUString>::get(),
135
0
                    beans::PropertyAttribute::BOUND
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
0
                ),
144
145
                // New properties
146
147
0
                beans::Property(
148
0
                    u"HasEncryptedEntries"_ustr,
149
0
                    -1,
150
0
                    cppu::UnoType<bool>::get(),
151
0
                    beans::PropertyAttribute::BOUND
152
0
                        | beans::PropertyAttribute::READONLY
153
0
                )
154
0
            };
155
0
            return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
156
0
        }
157
0
        else
158
0
        {
159
160
161
            // Folder: Supported properties
162
163
164
0
            static const beans::Property aFolderPropertyInfoTable[] =
165
0
            {
166
167
                // Required properties
168
169
0
                beans::Property(
170
0
                    u"ContentType"_ustr,
171
0
                    -1,
172
0
                    cppu::UnoType<OUString>::get(),
173
0
                    beans::PropertyAttribute::BOUND
174
0
                        | beans::PropertyAttribute::READONLY
175
0
                ),
176
0
                beans::Property(
177
0
                    u"IsDocument"_ustr,
178
0
                    -1,
179
0
                    cppu::UnoType<bool>::get(),
180
0
                    beans::PropertyAttribute::BOUND
181
0
                        | beans::PropertyAttribute::READONLY
182
0
                ),
183
0
                beans::Property(
184
0
                    u"IsFolder"_ustr,
185
0
                    -1,
186
0
                    cppu::UnoType<bool>::get(),
187
0
                    beans::PropertyAttribute::BOUND
188
0
                        | beans::PropertyAttribute::READONLY
189
0
                ),
190
0
                beans::Property(
191
0
                    u"Title"_ustr,
192
0
                    -1,
193
0
                    cppu::UnoType<OUString>::get(),
194
0
                    beans::PropertyAttribute::BOUND
195
0
                ),
196
197
                // Optional standard properties
198
199
0
                beans::Property(
200
0
                    u"MediaType"_ustr,
201
0
                    -1,
202
0
                    cppu::UnoType<OUString>::get(),
203
0
                    beans::PropertyAttribute::BOUND
204
0
                ),
205
0
                beans::Property(
206
0
                    u"CreatableContentsInfo"_ustr,
207
0
                    -1,
208
0
                    cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
209
0
                    beans::PropertyAttribute::BOUND
210
0
                        | beans::PropertyAttribute::READONLY
211
0
                )
212
213
                // New properties
214
215
0
            };
216
0
            return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
217
0
        }
218
0
    }
219
0
    else
220
0
    {
221
222
223
        // Stream: Supported properties
224
225
226
0
        static const beans::Property aStreamPropertyInfoTable[] =
227
0
        {
228
229
            // Required properties
230
231
0
            beans::Property(
232
0
                u"ContentType"_ustr,
233
0
                -1,
234
0
                cppu::UnoType<OUString>::get(),
235
0
                beans::PropertyAttribute::BOUND
236
0
                    | beans::PropertyAttribute::READONLY
237
0
            ),
238
0
            beans::Property(
239
0
                u"IsDocument"_ustr,
240
0
                -1,
241
0
                cppu::UnoType<bool>::get(),
242
0
                beans::PropertyAttribute::BOUND
243
0
                    | beans::PropertyAttribute::READONLY
244
0
            ),
245
0
            beans::Property(
246
0
                u"IsFolder"_ustr,
247
0
                -1,
248
0
                cppu::UnoType<bool>::get(),
249
0
                beans::PropertyAttribute::BOUND
250
0
                    | beans::PropertyAttribute::READONLY
251
0
            ),
252
0
            beans::Property(
253
0
                u"Title"_ustr,
254
0
                -1,
255
0
                cppu::UnoType<OUString>::get(),
256
0
                beans::PropertyAttribute::BOUND
257
0
            ),
258
259
            // Optional standard properties
260
261
0
            beans::Property(
262
0
                u"MediaType"_ustr,
263
0
                -1,
264
0
                cppu::UnoType<OUString>::get(),
265
0
                beans::PropertyAttribute::BOUND
266
0
            ),
267
0
            beans::Property(
268
0
                u"Size"_ustr,
269
0
                -1,
270
0
                cppu::UnoType<sal_Int64>::get(),
271
0
                beans::PropertyAttribute::BOUND
272
0
                    | beans::PropertyAttribute::READONLY
273
0
            ),
274
0
            beans::Property(
275
0
                u"CreatableContentsInfo"_ustr,
276
0
                -1,
277
0
                cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
278
0
                beans::PropertyAttribute::BOUND
279
0
                | beans::PropertyAttribute::READONLY
280
0
            ),
281
282
            // New properties
283
284
0
            beans::Property(
285
0
                u"Compressed"_ustr,
286
0
                -1,
287
0
                cppu::UnoType<bool>::get(),
288
0
                beans::PropertyAttribute::BOUND
289
0
            ),
290
0
            beans::Property(
291
0
                u"Encrypted"_ustr,
292
0
                -1,
293
0
                cppu::UnoType<bool>::get(),
294
0
                beans::PropertyAttribute::BOUND
295
0
            )
296
0
        };
297
0
        return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
298
0
    }
299
0
}
300
301
302
// virtual
303
uno::Sequence< ucb::CommandInfo > Content::getCommands(
304
            const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
305
0
{
306
0
    osl::Guard< osl::Mutex > aGuard( m_aMutex );
307
308
0
    if ( isFolder() )
309
0
    {
310
0
        if ( m_aUri.isRootFolder() )
311
0
        {
312
313
314
            // Root Folder: Supported commands
315
316
317
0
            static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
318
0
            {
319
320
                // Required commands
321
322
0
                ucb::CommandInfo(
323
0
                    u"getCommandInfo"_ustr,
324
0
                    -1,
325
0
                    cppu::UnoType<void>::get()
326
0
                ),
327
0
                ucb::CommandInfo(
328
0
                    u"getPropertySetInfo"_ustr,
329
0
                    -1,
330
0
                    cppu::UnoType<void>::get()
331
0
                ),
332
0
                ucb::CommandInfo(
333
0
                    u"getPropertyValues"_ustr,
334
0
                    -1,
335
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
336
0
                ),
337
0
                ucb::CommandInfo(
338
0
                    u"setPropertyValues"_ustr,
339
0
                    -1,
340
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
341
0
                ),
342
343
                // Optional standard commands
344
345
0
                ucb::CommandInfo(
346
0
                    u"open"_ustr,
347
0
                    -1,
348
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
349
0
                ),
350
0
                ucb::CommandInfo(
351
0
                    u"transfer"_ustr,
352
0
                    -1,
353
0
                    cppu::UnoType<ucb::TransferInfo>::get()
354
0
                ),
355
0
                ucb::CommandInfo(
356
0
                    u"createNewContent"_ustr,
357
0
                    -1,
358
0
                    cppu::UnoType<ucb::ContentInfo>::get()
359
0
                ),
360
361
                // New commands
362
363
0
                ucb::CommandInfo(
364
0
                    u"flush"_ustr,
365
0
                    -1,
366
0
                    cppu::UnoType<void>::get()
367
0
                )
368
0
            };
369
370
0
            return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
371
0
        }
372
0
        else
373
0
        {
374
375
376
            // Folder: Supported commands
377
378
379
0
            static const ucb::CommandInfo aFolderCommandInfoTable[] =
380
0
            {
381
382
                // Required commands
383
384
0
                ucb::CommandInfo(
385
0
                    u"getCommandInfo"_ustr,
386
0
                    -1,
387
0
                    cppu::UnoType<void>::get()
388
0
                ),
389
0
                ucb::CommandInfo(
390
0
                    u"getPropertySetInfo"_ustr,
391
0
                    -1,
392
0
                    cppu::UnoType<void>::get()
393
0
                ),
394
0
                ucb::CommandInfo(
395
0
                    u"getPropertyValues"_ustr,
396
0
                    -1,
397
0
                    cppu::UnoType<uno::Sequence< beans::Property >>::get()
398
0
                ),
399
0
                ucb::CommandInfo(
400
0
                    u"setPropertyValues"_ustr,
401
0
                    -1,
402
0
                    cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
403
0
                ),
404
405
                // Optional standard commands
406
407
0
                ucb::CommandInfo(
408
0
                    u"delete"_ustr,
409
0
                    -1,
410
0
                    cppu::UnoType<bool>::get()
411
0
                ),
412
0
                ucb::CommandInfo(
413
0
                    u"insert"_ustr,
414
0
                    -1,
415
0
                    cppu::UnoType<void>::get()
416
0
                ),
417
0
                ucb::CommandInfo(
418
0
                    u"open"_ustr,
419
0
                    -1,
420
0
                    cppu::UnoType<ucb::OpenCommandArgument2>::get()
421
0
                ),
422
0
                ucb::CommandInfo(
423
0
                    u"transfer"_ustr,
424
0
                    -1,
425
0
                    cppu::UnoType<ucb::TransferInfo>::get()
426
0
                ),
427
0
                ucb::CommandInfo(
428
0
                    u"createNewContent"_ustr,
429
0
                    -1,
430
0
                    cppu::UnoType<ucb::ContentInfo>::get()
431
0
                ),
432
433
                // New commands
434
435
0
                ucb::CommandInfo(
436
0
                    u"flush"_ustr,
437
0
                    -1,
438
0
                    cppu::UnoType<void>::get()
439
0
                )
440
0
            };
441
442
0
            return MAKECMDSEQUENCE( aFolderCommandInfoTable );
443
0
        }
444
0
    }
445
0
    else
446
0
    {
447
448
449
        // Stream: Supported commands
450
451
452
0
        static const ucb::CommandInfo aStreamCommandInfoTable[] =
453
0
        {
454
455
            // Required commands
456
457
0
            ucb::CommandInfo(
458
0
                u"getCommandInfo"_ustr,
459
0
                -1,
460
0
                cppu::UnoType<void>::get()
461
0
            ),
462
0
            ucb::CommandInfo(
463
0
                u"getPropertySetInfo"_ustr,
464
0
                -1,
465
0
                cppu::UnoType<void>::get()
466
0
            ),
467
0
            ucb::CommandInfo(
468
0
                u"getPropertyValues"_ustr,
469
0
                -1,
470
0
                cppu::UnoType<uno::Sequence< beans::Property >>::get()
471
0
            ),
472
0
            ucb::CommandInfo(
473
0
                u"setPropertyValues"_ustr,
474
0
                -1,
475
0
                cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
476
0
            ),
477
478
            // Optional standard commands
479
480
0
            ucb::CommandInfo(
481
0
                u"delete"_ustr,
482
0
                -1,
483
0
                cppu::UnoType<bool>::get()
484
0
            ),
485
0
            ucb::CommandInfo(
486
0
                u"insert"_ustr,
487
0
                -1,
488
0
                cppu::UnoType<void>::get()
489
0
            ),
490
0
            ucb::CommandInfo(
491
0
                u"open"_ustr,
492
0
                -1,
493
0
                cppu::UnoType<ucb::OpenCommandArgument2>::get()
494
0
            )
495
496
            // New commands
497
498
0
        };
499
500
0
        return MAKECMDSEQUENCE( aStreamCommandInfoTable );
501
0
    }
502
0
}
503
504
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */