LibreOffice Module ucb (master) 1
pkgcontentcaps.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 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
62using namespace com::sun::star;
63using namespace package_ucp;
64
65
66// Content implementation.
67
68
69#define MAKEPROPSEQUENCE( a ) \
70 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
71
72#define MAKECMDSEQUENCE( a ) \
73 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
81uno::Sequence< beans::Property > Content::getProperties(
82 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
83{
84 osl::Guard< osl::Mutex > aGuard( m_aMutex );
85
86 if ( isFolder() )
87 {
88 if ( m_aUri.isRootFolder() )
89 {
90
91
92 // Root Folder: Supported properties
93
94
95 static const beans::Property aRootFolderPropertyInfoTable[] =
96 {
97
98 // Required properties
99
100 beans::Property(
101 "ContentType",
102 -1,
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::READONLY
106 ),
107 beans::Property(
108 "IsDocument",
109 -1,
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
113 ),
114 beans::Property(
115 "IsFolder",
116 -1,
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
120 ),
121 beans::Property(
122 "Title",
123 -1,
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
127 ),
128
129 // Optional standard properties
130
131 beans::Property(
132 "MediaType",
133 -1,
135 beans::PropertyAttribute::BOUND
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
145 // New properties
146
147 beans::Property(
148 "HasEncryptedEntries",
149 -1,
151 beans::PropertyAttribute::BOUND
152 | beans::PropertyAttribute::READONLY
153 )
154 };
155 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
156 }
157 else
158 {
159
160
161 // Folder: Supported properties
162
163
164 static const beans::Property aFolderPropertyInfoTable[] =
165 {
166
167 // Required properties
168
169 beans::Property(
170 "ContentType",
171 -1,
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
175 ),
176 beans::Property(
177 "IsDocument",
178 -1,
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
182 ),
183 beans::Property(
184 "IsFolder",
185 -1,
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
189 ),
190 beans::Property(
191 "Title",
192 -1,
194 beans::PropertyAttribute::BOUND
195 ),
196
197 // Optional standard properties
198
199 beans::Property(
200 "MediaType",
201 -1,
203 beans::PropertyAttribute::BOUND
204 ),
205 beans::Property(
206 "CreatableContentsInfo",
207 -1,
208 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
209 beans::PropertyAttribute::BOUND
210 | beans::PropertyAttribute::READONLY
211 )
212
213 // New properties
214
215 };
216 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
217 }
218 }
219 else
220 {
221
222
223 // Stream: Supported properties
224
225
226 static const beans::Property aStreamPropertyInfoTable[] =
227 {
228
229 // Required properties
230
231 beans::Property(
232 "ContentType",
233 -1,
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::READONLY
237 ),
238 beans::Property(
239 "IsDocument",
240 -1,
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::READONLY
244 ),
245 beans::Property(
246 "IsFolder",
247 -1,
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::READONLY
251 ),
252 beans::Property(
253 "Title",
254 -1,
256 beans::PropertyAttribute::BOUND
257 ),
258
259 // Optional standard properties
260
261 beans::Property(
262 "MediaType",
263 -1,
265 beans::PropertyAttribute::BOUND
266 ),
267 beans::Property(
268 "Size",
269 -1,
271 beans::PropertyAttribute::BOUND
272 | beans::PropertyAttribute::READONLY
273 ),
274 beans::Property(
275 "CreatableContentsInfo",
276 -1,
277 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
278 beans::PropertyAttribute::BOUND
279 | beans::PropertyAttribute::READONLY
280 ),
281
282 // New properties
283
284 beans::Property(
285 "Compressed",
286 -1,
288 beans::PropertyAttribute::BOUND
289 ),
290 beans::Property(
291 "Encrypted",
292 -1,
294 beans::PropertyAttribute::BOUND
295 )
296 };
297 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
298 }
299}
300
301
302// virtual
303uno::Sequence< ucb::CommandInfo > Content::getCommands(
304 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
305{
306 osl::Guard< osl::Mutex > aGuard( m_aMutex );
307
308 if ( isFolder() )
309 {
310 if ( m_aUri.isRootFolder() )
311 {
312
313
314 // Root Folder: Supported commands
315
316
317 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
318 {
319
320 // Required commands
321
322 ucb::CommandInfo(
323 "getCommandInfo",
324 -1,
326 ),
327 ucb::CommandInfo(
328 "getPropertySetInfo",
329 -1,
331 ),
332 ucb::CommandInfo(
333 "getPropertyValues",
334 -1,
335 cppu::UnoType<uno::Sequence< beans::Property >>::get()
336 ),
337 ucb::CommandInfo(
338 "setPropertyValues",
339 -1,
340 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
341 ),
342
343 // Optional standard commands
344
345 ucb::CommandInfo(
346 "open",
347 -1,
349 ),
350 ucb::CommandInfo(
351 "transfer",
352 -1,
354 ),
355 ucb::CommandInfo(
356 "createNewContent",
357 -1,
359 ),
360
361 // New commands
362
363 ucb::CommandInfo(
364 "flush",
365 -1,
367 )
368 };
369
370 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
371 }
372 else
373 {
374
375
376 // Folder: Supported commands
377
378
379 static const ucb::CommandInfo aFolderCommandInfoTable[] =
380 {
381
382 // Required commands
383
384 ucb::CommandInfo(
385 "getCommandInfo",
386 -1,
388 ),
389 ucb::CommandInfo(
390 "getPropertySetInfo",
391 -1,
393 ),
394 ucb::CommandInfo(
395 "getPropertyValues",
396 -1,
397 cppu::UnoType<uno::Sequence< beans::Property >>::get()
398 ),
399 ucb::CommandInfo(
400 "setPropertyValues",
401 -1,
402 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
403 ),
404
405 // Optional standard commands
406
407 ucb::CommandInfo(
408 "delete",
409 -1,
411 ),
412 ucb::CommandInfo(
413 "insert",
414 -1,
416 ),
417 ucb::CommandInfo(
418 "open",
419 -1,
421 ),
422 ucb::CommandInfo(
423 "transfer",
424 -1,
426 ),
427 ucb::CommandInfo(
428 "createNewContent",
429 -1,
431 ),
432
433 // New commands
434
435 ucb::CommandInfo(
436 "flush",
437 -1,
439 )
440 };
441
442 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
443 }
444 }
445 else
446 {
447
448
449 // Stream: Supported commands
450
451
452 static const ucb::CommandInfo aStreamCommandInfoTable[] =
453 {
454
455 // Required commands
456
457 ucb::CommandInfo(
458 "getCommandInfo",
459 -1,
461 ),
462 ucb::CommandInfo(
463 "getPropertySetInfo",
464 -1,
466 ),
467 ucb::CommandInfo(
468 "getPropertyValues",
469 -1,
470 cppu::UnoType<uno::Sequence< beans::Property >>::get()
471 ),
472 ucb::CommandInfo(
473 "setPropertyValues",
474 -1,
475 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
476 ),
477
478 // Optional standard commands
479
480 ucb::CommandInfo(
481 "delete",
482 -1,
484 ),
485 ucb::CommandInfo(
486 "insert",
487 -1,
489 ),
490 ucb::CommandInfo(
491 "open",
492 -1,
494 )
495
496 // New commands
497
498 };
499
500 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
501 }
502}
503
504/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isFolder() const
Definition: pkgcontent.hxx:198
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
bool isRootFolder() const
Definition: pkguri.hxx:81
#define MAKECMDSEQUENCE(a)
#define MAKEPROPSEQUENCE(a)