LibreOffice Module ucb (master) 1
tdoc_contentcaps.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 **************************************************************************
26
27 Props/Commands:
28
29 root document folder folder stream stream
30 (new) (new)
31 ----------------------------------------------------------------
32 ContentType r r r r r r
33 IsDocument r r r r r r
34 IsFolder r r r r r r
35 Title r r w w w w
36 CreatableContentsInfo r r r r r r
37 DateModified - - - - r r
38 Storage - - r r - -
39 DocumentModel - r - - - -
40
41 getCommandInfo x x x x x x
42 getPropertySetInfo x x x x x x
43 getPropertyValues x x x x x x
44 setPropertyValues x x x x x x
45 insert - - x x x(*) x(*)
46 delete - - x - x -
47 open x x x - x -
48 transfer - x x - - -
49 createNewContent - x x - - -
50
51
52 *************************************************************************/
53
54#include <com/sun/star/beans/Property.hpp>
55#include <com/sun/star/beans/PropertyAttribute.hpp>
56#include <com/sun/star/beans/PropertyValue.hpp>
57#include <com/sun/star/embed/XStorage.hpp>
58#include <com/sun/star/frame/XModel.hpp>
59#include <com/sun/star/ucb/CommandInfo.hpp>
60#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
61#include <com/sun/star/ucb/TransferInfo.hpp>
62#include <com/sun/star/util/DateTime.hpp>
63#include <osl/diagnose.h>
64#include <sal/macros.h>
65#include "tdoc_content.hxx"
66
67namespace com::sun::star::embed {
68 class XStorage;
69}
70
71using namespace com::sun::star;
72using namespace tdoc_ucp;
73
74
75// Content implementation.
76
77
78#define MAKEPROPSEQUENCE( a ) \
79 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS(a) )
80
81#define MAKECMDSEQUENCE( a ) \
82 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) )
83
84
85// IMPORTANT: If any property data ( name / type / ... ) are changed, then
86// Content::getPropertyValues(...) must be adapted too!
87
88
89// virtual
90uno::Sequence< beans::Property > Content::getProperties(
91 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
92{
93 osl::Guard< osl::Mutex > aGuard( m_aMutex );
94
95 if ( m_aProps.getType() == STREAM )
96 {
97
98
99 // Stream: Supported properties
100
101
102 static const beans::Property aStreamPropertyInfoTable[] =
103 {
104
105 // Mandatory properties
106
107 beans::Property(
108 "ContentType",
109 -1,
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
113 ),
114 beans::Property(
115 "IsDocument",
116 -1,
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
120 ),
121 beans::Property(
122 "IsFolder",
123 -1,
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
127 ),
128 beans::Property(
129 "Title",
130 -1,
132 beans::PropertyAttribute::BOUND
133 ),
134
135 // Optional standard properties
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 beans::Property(
145 "DateModified",
146 -1,
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::READONLY
150 )
151
152 // New properties
153
154 };
155 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
156 }
157 else if ( m_aProps.getType() == FOLDER )
158 {
159
160
161 // Folder: Supported properties
162
163
164 static const beans::Property aFolderPropertyInfoTable[] =
165 {
166
167 // Mandatory 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 "CreatableContentsInfo",
201 -1,
202 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
203 beans::PropertyAttribute::BOUND
204 | beans::PropertyAttribute::READONLY
205 ),
206
207 // New properties
208
209 beans::Property(
210 "Storage",
211 -1,
213 beans::PropertyAttribute::BOUND
214 | beans::PropertyAttribute::READONLY
215 )
216 };
217 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
218 }
219 else if ( m_aProps.getType() == DOCUMENT )
220 {
221
222
223 // Document: Supported properties
224
225
226 static const beans::Property aDocPropertyInfoTable[] =
227 {
228
229 // Mandatory 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 | beans::PropertyAttribute::READONLY
258 ),
259
260 // Optional standard properties
261
262 beans::Property(
263 "CreatableContentsInfo",
264 -1,
265 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
266 beans::PropertyAttribute::BOUND
267 | beans::PropertyAttribute::READONLY
268 ),
269
270 // New properties
271
272 beans::Property(
273 "DocumentModel",
274 -1,
276 beans::PropertyAttribute::BOUND
277 | beans::PropertyAttribute::READONLY
278 )
279 };
280 return MAKEPROPSEQUENCE( aDocPropertyInfoTable );
281 }
282 else
283 {
284
285
286 // Root: Supported properties
287
288
289 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
290
291 static const beans::Property aRootPropertyInfoTable[] =
292 {
293
294 // Mandatory properties
295
296 beans::Property(
297 "ContentType",
298 -1,
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
302 ),
303 beans::Property(
304 "IsDocument",
305 -1,
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
309 ),
310 beans::Property(
311 "IsFolder",
312 -1,
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::READONLY
316 ),
317 beans::Property(
318 "Title",
319 -1,
321 beans::PropertyAttribute::BOUND
322 | beans::PropertyAttribute::READONLY
323 ),
324
325 // Optional standard properties
326
327 beans::Property(
328 "CreatableContentsInfo",
329 -1,
330 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
333 )
334
335 // New properties
336
337 };
338 return MAKEPROPSEQUENCE( aRootPropertyInfoTable );
339 }
340}
341
342
343// virtual
344uno::Sequence< ucb::CommandInfo > Content::getCommands(
345 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
346{
347 osl::Guard< osl::Mutex > aGuard( m_aMutex );
348
349 if ( m_aProps.getType() == STREAM )
350 {
351 Uri aUri( m_xIdentifier->getContentIdentifier() );
352 Uri aParentUri( aUri.getParentUri() );
353
354 if ( aParentUri.isDocument() )
355 {
356
357
358 // Stream, that is a child of a document: Supported commands
359
360
361 static const ucb::CommandInfo aStreamCommandInfoTable1[] =
362 {
363
364 // Mandatory commands
365
366 ucb::CommandInfo(
367 "getCommandInfo",
368 -1,
370 ),
371 ucb::CommandInfo(
372 "getPropertySetInfo",
373 -1,
375 ),
376 ucb::CommandInfo(
377 "getPropertyValues",
378 -1,
379 cppu::UnoType<uno::Sequence< beans::Property >>::get()
380 ),
381 ucb::CommandInfo(
382 "setPropertyValues",
383 -1,
384 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
385 ),
386
387 // Optional standard commands
388
389 ucb::CommandInfo(
390 "delete",
391 -1,
393 ),
394 ucb::CommandInfo(
395 "open",
396 -1,
398 )
399
400 // New commands
401
402 };
403 return MAKECMDSEQUENCE( aStreamCommandInfoTable1 );
404 }
405
406
407 // Stream: Supported commands
408
409
410 static const ucb::CommandInfo aStreamCommandInfoTable[] =
411 {
412
413 // Mandatory commands
414
415 ucb::CommandInfo(
416 "getCommandInfo",
417 -1,
419 ),
420 ucb::CommandInfo(
421 "getPropertySetInfo",
422 -1,
424 ),
425 ucb::CommandInfo(
426 "getPropertyValues",
427 -1,
428 cppu::UnoType< uno::Sequence< beans::Property >>::get()
429 ),
430 ucb::CommandInfo(
431 "setPropertyValues",
432 -1,
433 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
434 ),
435
436 // Optional standard commands
437
438 ucb::CommandInfo(
439 "delete",
440 -1,
442 ),
443 ucb::CommandInfo(
444 "insert",
445 -1,
447 ),
448 ucb::CommandInfo(
449 "open",
450 -1,
452 )
453
454 // New commands
455
456 };
457 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
458 }
459 else if ( m_aProps.getType() == FOLDER )
460 {
461
462
463 // Folder: Supported commands
464
465
466 static const ucb::CommandInfo aFolderCommandInfoTable[] =
467 {
468
469 // Mandatory commands
470
471 ucb::CommandInfo(
472 "getCommandInfo",
473 -1,
475 ),
476 ucb::CommandInfo(
477 "getPropertySetInfo",
478 -1,
480 ),
481 ucb::CommandInfo(
482 "getPropertyValues",
483 -1,
484 cppu::UnoType<uno::Sequence< beans::Property >>::get()
485 ),
486 ucb::CommandInfo(
487 "setPropertyValues",
488 -1,
489 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
490 ),
491
492 // Optional standard commands
493
494 ucb::CommandInfo(
495 "delete",
496 -1,
498 ),
499 ucb::CommandInfo(
500 "insert",
501 -1,
503 ),
504 ucb::CommandInfo(
505 "open",
506 -1,
508 ),
509 ucb::CommandInfo(
510 "transfer",
511 -1,
513 ),
514 ucb::CommandInfo(
515 "createNewContent",
516 -1,
518 )
519
520 // New commands
521
522 };
523 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
524 }
525 else if ( m_aProps.getType() == DOCUMENT )
526 {
527
528
529 // Document: Supported commands
530
531
532 static const ucb::CommandInfo aDocCommandInfoTable[] =
533 {
534
535 // Mandatory commands
536
537 ucb::CommandInfo(
538 "getCommandInfo",
539 -1,
541 ),
542 ucb::CommandInfo(
543 "getPropertySetInfo",
544 -1,
546 ),
547 ucb::CommandInfo(
548 "getPropertyValues",
549 -1,
550 cppu::UnoType<uno::Sequence< beans::Property >>::get()
551 ),
552 ucb::CommandInfo(
553 "setPropertyValues",
554 -1,
555 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
556 ),
557
558 // Optional standard commands
559
560 ucb::CommandInfo(
561 "open",
562 -1,
564 ),
565 ucb::CommandInfo(
566 "transfer",
567 -1,
569 ),
570 ucb::CommandInfo(
571 "createNewContent",
572 -1,
574 )
575
576 // New commands
577
578 };
579 return MAKECMDSEQUENCE( aDocCommandInfoTable );
580 }
581 else
582 {
583
584
585 // Root: Supported commands
586
587
588 OSL_ENSURE( m_aProps.getType() == ROOT, "Wrong content type!" );
589
590 static const ucb::CommandInfo aRootCommandInfoTable[] =
591 {
592
593 // Mandatory commands
594
595 ucb::CommandInfo(
596 "getCommandInfo",
597 -1,
599 ),
600 ucb::CommandInfo(
601 "getPropertySetInfo",
602 -1,
604 ),
605 ucb::CommandInfo(
606 "getPropertyValues",
607 -1,
608 cppu::UnoType<uno::Sequence< beans::Property >>::get()
609 ),
610 ucb::CommandInfo(
611 "setPropertyValues",
612 -1,
613 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
614 ),
615
616 // Optional standard commands
617
618 ucb::CommandInfo(
619 "open",
620 -1,
622 )
623
624 // New commands
625
626 };
627 return MAKECMDSEQUENCE( aRootCommandInfoTable );
628 }
629}
630
631/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentType getType() const
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
ContentProperties m_aProps
css::uno::Reference< css::ucb::XContentIdentifier > m_xIdentifier
#define MAKECMDSEQUENCE(a)
#define MAKEPROPSEQUENCE(a)