Debian Codegraph @

ucb/source/ucp/package/pkgcontentcaps.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 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 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
81 uno::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 u"ContentType"_ustr,
102 -1,
103 cppu::UnoType<OUString>::get(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::READONLY
106 ),
107 beans::Property(
108 u"IsDocument"_ustr,
109 -1,
110 cppu::UnoType<bool>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
113 ),
114 beans::Property(
115 u"IsFolder"_ustr,
116 -1,
117 cppu::UnoType<bool>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
120 ),
121 beans::Property(
122 u"Title"_ustr,
123 -1,
124 cppu::UnoType<OUString>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
127 ),
128
129 // Optional standard properties
130
131 beans::Property(
132 u"MediaType"_ustr,
133 -1,
134 cppu::UnoType<OUString>::get(),
135 beans::PropertyAttribute::BOUND
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
145 // New properties
146
147 beans::Property(
148 u"HasEncryptedEntries"_ustr,
149 -1,
150 cppu::UnoType<bool>::get(),
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 u"ContentType"_ustr,
171 -1,
172 cppu::UnoType<OUString>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
175 ),
176 beans::Property(
177 u"IsDocument"_ustr,
178 -1,
179 cppu::UnoType<bool>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
182 ),
183 beans::Property(
184 u"IsFolder"_ustr,
185 -1,
186 cppu::UnoType<bool>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
189 ),
190 beans::Property(
191 u"Title"_ustr,
192 -1,
193 cppu::UnoType<OUString>::get(),
194 beans::PropertyAttribute::BOUND
195 ),
196
197 // Optional standard properties
198
199 beans::Property(
200 u"MediaType"_ustr,
201 -1,
202 cppu::UnoType<OUString>::get(),
203 beans::PropertyAttribute::BOUND
204 ),
205 beans::Property(
206 u"CreatableContentsInfo"_ustr,
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 u"ContentType"_ustr,
233 -1,
234 cppu::UnoType<OUString>::get(),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::READONLY
237 ),
238 beans::Property(
239 u"IsDocument"_ustr,
240 -1,
241 cppu::UnoType<bool>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::READONLY
244 ),
245 beans::Property(
246 u"IsFolder"_ustr,
247 -1,
248 cppu::UnoType<bool>::get(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::READONLY
251 ),
252 beans::Property(
253 u"Title"_ustr,
254 -1,
255 cppu::UnoType<OUString>::get(),
256 beans::PropertyAttribute::BOUND
257 ),
258
259 // Optional standard properties
260
261 beans::Property(
262 u"MediaType"_ustr,
263 -1,
264 cppu::UnoType<OUString>::get(),
265 beans::PropertyAttribute::BOUND
266 ),
267 beans::Property(
268 u"Size"_ustr,
269 -1,
270 cppu::UnoType<sal_Int64>::get(),
271 beans::PropertyAttribute::BOUND
272 | beans::PropertyAttribute::READONLY
273 ),
274 beans::Property(
275 u"CreatableContentsInfo"_ustr,
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 u"Compressed"_ustr,
286 -1,
287 cppu::UnoType<bool>::get(),
288 beans::PropertyAttribute::BOUND
289 ),
290 beans::Property(
291 u"Encrypted"_ustr,
292 -1,
293 cppu::UnoType<bool>::get(),
294 beans::PropertyAttribute::BOUND
295 )
296 };
297 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
298 }
299 }
300
301
302 // virtual
303 uno::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 u"getCommandInfo"_ustr,
324 -1,
325 cppu::UnoType<void>::get()
326 ),
327 ucb::CommandInfo(
328 u"getPropertySetInfo"_ustr,
329 -1,
330 cppu::UnoType<void>::get()
331 ),
332 ucb::CommandInfo(
333 u"getPropertyValues"_ustr,
334 -1,
335 cppu::UnoType<uno::Sequence< beans::Property >>::get()
336 ),
337 ucb::CommandInfo(
338 u"setPropertyValues"_ustr,
339 -1,
340 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
341 ),
342
343 // Optional standard commands
344
345 ucb::CommandInfo(
346 u"open"_ustr,
347 -1,
348 cppu::UnoType<ucb::OpenCommandArgument2>::get()
349 ),
350 ucb::CommandInfo(
351 u"transfer"_ustr,
352 -1,
353 cppu::UnoType<ucb::TransferInfo>::get()
354 ),
355 ucb::CommandInfo(
356 u"createNewContent"_ustr,
357 -1,
358 cppu::UnoType<ucb::ContentInfo>::get()
359 ),
360
361 // New commands
362
363 ucb::CommandInfo(
364 u"flush"_ustr,
365 -1,
366 cppu::UnoType<void>::get()
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 u"getCommandInfo"_ustr,
386 -1,
387 cppu::UnoType<void>::get()
388 ),
389 ucb::CommandInfo(
390 u"getPropertySetInfo"_ustr,
391 -1,
392 cppu::UnoType<void>::get()
393 ),
394 ucb::CommandInfo(
395 u"getPropertyValues"_ustr,
396 -1,
397 cppu::UnoType<uno::Sequence< beans::Property >>::get()
398 ),
399 ucb::CommandInfo(
400 u"setPropertyValues"_ustr,
401 -1,
402 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
403 ),
404
405 // Optional standard commands
406
407 ucb::CommandInfo(
408 u"delete"_ustr,
409 -1,
410 cppu::UnoType<bool>::get()
411 ),
412 ucb::CommandInfo(
413 u"insert"_ustr,
414 -1,
415 cppu::UnoType<void>::get()
416 ),
417 ucb::CommandInfo(
418 u"open"_ustr,
419 -1,
420 cppu::UnoType<ucb::OpenCommandArgument2>::get()
421 ),
422 ucb::CommandInfo(
423 u"transfer"_ustr,
424 -1,
425 cppu::UnoType<ucb::TransferInfo>::get()
426 ),
427 ucb::CommandInfo(
428 u"createNewContent"_ustr,
429 -1,
430 cppu::UnoType<ucb::ContentInfo>::get()
431 ),
432
433 // New commands
434
435 ucb::CommandInfo(
436 u"flush"_ustr,
437 -1,
438 cppu::UnoType<void>::get()
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 u"getCommandInfo"_ustr,
459 -1,
460 cppu::UnoType<void>::get()
461 ),
462 ucb::CommandInfo(
463 u"getPropertySetInfo"_ustr,
464 -1,
465 cppu::UnoType<void>::get()
466 ),
467 ucb::CommandInfo(
468 u"getPropertyValues"_ustr,
469 -1,
470 cppu::UnoType<uno::Sequence< beans::Property >>::get()
471 ),
472 ucb::CommandInfo(
473 u"setPropertyValues"_ustr,
474 -1,
475 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
476 ),
477
478 // Optional standard commands
479
480 ucb::CommandInfo(
481 u"delete"_ustr,
482 -1,
483 cppu::UnoType<bool>::get()
484 ),
485 ucb::CommandInfo(
486 u"insert"_ustr,
487 -1,
488 cppu::UnoType<void>::get()
489 ),
490 ucb::CommandInfo(
491 u"open"_ustr,
492 -1,
493 cppu::UnoType<ucb::OpenCommandArgument2>::get()
494 )
495
496 // New commands
497
498 };
499
500 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
501 }
502 }
503
504 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */