Debian Codegraph @

ucb/source/ucp/tdoc/tdoc_contentcaps.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 **************************************************************************
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
67 namespace com::sun::star::embed {
68 class XStorage;
69 }
70
71 using namespace com::sun::star;
72 using 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
90 uno::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 u"ContentType"_ustr,
109 -1,
110 cppu::UnoType<OUString>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
113 ),
114 beans::Property(
115 u"IsDocument"_ustr,
116 -1,
117 cppu::UnoType<bool>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
120 ),
121 beans::Property(
122 u"IsFolder"_ustr,
123 -1,
124 cppu::UnoType<bool>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
127 ),
128 beans::Property(
129 u"Title"_ustr,
130 -1,
131 cppu::UnoType<OUString>::get(),
132 beans::PropertyAttribute::BOUND
133 ),
134
135 // Optional standard properties
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 beans::Property(
145 u"DateModified"_ustr,
146 -1,
147 cppu::UnoType<css::util::DateTime>::get(),
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 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"CreatableContentsInfo"_ustr,
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 u"Storage"_ustr,
211 -1,
212 cppu::UnoType<embed::XStorage>::get(),
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 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 | beans::PropertyAttribute::READONLY
258 ),
259
260 // Optional standard properties
261
262 beans::Property(
263 u"CreatableContentsInfo"_ustr,
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 u"DocumentModel"_ustr,
274 -1,
275 cppu::UnoType<frame::XModel>::get(),
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 u"ContentType"_ustr,
298 -1,
299 cppu::UnoType<OUString>::get(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
302 ),
303 beans::Property(
304 u"IsDocument"_ustr,
305 -1,
306 cppu::UnoType<bool>::get(),
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
309 ),
310 beans::Property(
311 u"IsFolder"_ustr,
312 -1,
313 cppu::UnoType<bool>::get(),
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::READONLY
316 ),
317 beans::Property(
318 u"Title"_ustr,
319 -1,
320 cppu::UnoType<OUString>::get(),
321 beans::PropertyAttribute::BOUND
322 | beans::PropertyAttribute::READONLY
323 ),
324
325 // Optional standard properties
326
327 beans::Property(
328 u"CreatableContentsInfo"_ustr,
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
344 uno::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 u"getCommandInfo"_ustr,
368 -1,
369 cppu::UnoType<void>::get()
370 ),
371 ucb::CommandInfo(
372 u"getPropertySetInfo"_ustr,
373 -1,
374 cppu::UnoType<void>::get()
375 ),
376 ucb::CommandInfo(
377 u"getPropertyValues"_ustr,
378 -1,
379 cppu::UnoType<uno::Sequence< beans::Property >>::get()
380 ),
381 ucb::CommandInfo(
382 u"setPropertyValues"_ustr,
383 -1,
384 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
385 ),
386
387 // Optional standard commands
388
389 ucb::CommandInfo(
390 u"delete"_ustr,
391 -1,
392 cppu::UnoType<bool>::get()
393 ),
394 ucb::CommandInfo(
395 u"open"_ustr,
396 -1,
397 cppu::UnoType<ucb::OpenCommandArgument2>::get()
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 u"getCommandInfo"_ustr,
417 -1,
418 cppu::UnoType<void>::get()
419 ),
420 ucb::CommandInfo(
421 u"getPropertySetInfo"_ustr,
422 -1,
423 cppu::UnoType<void>::get()
424 ),
425 ucb::CommandInfo(
426 u"getPropertyValues"_ustr,
427 -1,
428 cppu::UnoType< uno::Sequence< beans::Property >>::get()
429 ),
430 ucb::CommandInfo(
431 u"setPropertyValues"_ustr,
432 -1,
433 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
434 ),
435
436 // Optional standard commands
437
438 ucb::CommandInfo(
439 u"delete"_ustr,
440 -1,
441 cppu::UnoType<bool>::get()
442 ),
443 ucb::CommandInfo(
444 u"insert"_ustr,
445 -1,
446 cppu::UnoType<void>::get()
447 ),
448 ucb::CommandInfo(
449 u"open"_ustr,
450 -1,
451 cppu::UnoType<ucb::OpenCommandArgument2>::get()
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 u"getCommandInfo"_ustr,
473 -1,
474 cppu::UnoType<void>::get()
475 ),
476 ucb::CommandInfo(
477 u"getPropertySetInfo"_ustr,
478 -1,
479 cppu::UnoType<void>::get()
480 ),
481 ucb::CommandInfo(
482 u"getPropertyValues"_ustr,
483 -1,
484 cppu::UnoType<uno::Sequence< beans::Property >>::get()
485 ),
486 ucb::CommandInfo(
487 u"setPropertyValues"_ustr,
488 -1,
489 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
490 ),
491
492 // Optional standard commands
493
494 ucb::CommandInfo(
495 u"delete"_ustr,
496 -1,
497 cppu::UnoType<bool>::get()
498 ),
499 ucb::CommandInfo(
500 u"insert"_ustr,
501 -1,
502 cppu::UnoType<void>::get()
503 ),
504 ucb::CommandInfo(
505 u"open"_ustr,
506 -1,
507 cppu::UnoType<ucb::OpenCommandArgument2>::get()
508 ),
509 ucb::CommandInfo(
510 u"transfer"_ustr,
511 -1,
512 cppu::UnoType<ucb::TransferInfo>::get()
513 ),
514 ucb::CommandInfo(
515 u"createNewContent"_ustr,
516 -1,
517 cppu::UnoType<ucb::ContentInfo>::get()
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 u"getCommandInfo"_ustr,
539 -1,
540 cppu::UnoType<void>::get()
541 ),
542 ucb::CommandInfo(
543 u"getPropertySetInfo"_ustr,
544 -1,
545 cppu::UnoType<void>::get()
546 ),
547 ucb::CommandInfo(
548 u"getPropertyValues"_ustr,
549 -1,
550 cppu::UnoType<uno::Sequence< beans::Property >>::get()
551 ),
552 ucb::CommandInfo(
553 u"setPropertyValues"_ustr,
554 -1,
555 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
556 ),
557
558 // Optional standard commands
559
560 ucb::CommandInfo(
561 u"open"_ustr,
562 -1,
563 cppu::UnoType<ucb::OpenCommandArgument2>::get()
564 ),
565 ucb::CommandInfo(
566 u"transfer"_ustr,
567 -1,
568 cppu::UnoType<ucb::TransferInfo>::get()
569 ),
570 ucb::CommandInfo(
571 u"createNewContent"_ustr,
572 -1,
573 cppu::UnoType<ucb::ContentInfo>::get()
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 u"getCommandInfo"_ustr,
597 -1,
598 cppu::UnoType<void>::get()
599 ),
600 ucb::CommandInfo(
601 u"getPropertySetInfo"_ustr,
602 -1,
603 cppu::UnoType<void>::get()
604 ),
605 ucb::CommandInfo(
606 u"getPropertyValues"_ustr,
607 -1,
608 cppu::UnoType<uno::Sequence< beans::Property >>::get()
609 ),
610 ucb::CommandInfo(
611 u"setPropertyValues"_ustr,
612 -1,
613 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
614 ),
615
616 // Optional standard commands
617
618 ucb::CommandInfo(
619 u"open"_ustr,
620 -1,
621 cppu::UnoType<ucb::OpenCommandArgument2>::get()
622 )
623
624 // New commands
625
626 };
627 return MAKECMDSEQUENCE( aRootCommandInfoTable );
628 }
629 }
630
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */