Update git submodules
[LibreOffice.git] / ucb / source / ucp / package / pkgcontentcaps.cxx
blob73ef49f1f2b9752839f0a32c0fb62fe869220867
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 /**************************************************************************
22 TODO
23 **************************************************************************
25 Props/Commands:
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 - -
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 -
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"
62 using namespace com::sun::star;
63 using namespace package_ucp;
66 // Content implementation.
69 #define MAKEPROPSEQUENCE( a ) \
70 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
72 #define MAKECMDSEQUENCE( a ) \
73 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) )
76 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
77 // Content::getPropertyValues(...) must be adapted too!
80 // virtual
81 uno::Sequence< beans::Property > Content::getProperties(
82 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
84 osl::Guard< osl::Mutex > aGuard( m_aMutex );
86 if ( isFolder() )
88 if ( m_aUri.isRootFolder() )
92 // Root Folder: Supported properties
95 static const beans::Property aRootFolderPropertyInfoTable[] =
98 // Required properties
100 beans::Property(
101 u"ContentType"_ustr,
103 cppu::UnoType<OUString>::get(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::READONLY
107 beans::Property(
108 u"IsDocument"_ustr,
110 cppu::UnoType<bool>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
114 beans::Property(
115 u"IsFolder"_ustr,
117 cppu::UnoType<bool>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
121 beans::Property(
122 u"Title"_ustr,
124 cppu::UnoType<OUString>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
129 // Optional standard properties
131 beans::Property(
132 u"MediaType"_ustr,
134 cppu::UnoType<OUString>::get(),
135 beans::PropertyAttribute::BOUND
137 beans::Property(
138 u"CreatableContentsInfo"_ustr,
140 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY
145 // New properties
147 beans::Property(
148 u"HasEncryptedEntries"_ustr,
150 cppu::UnoType<bool>::get(),
151 beans::PropertyAttribute::BOUND
152 | beans::PropertyAttribute::READONLY
155 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
157 else
161 // Folder: Supported properties
164 static const beans::Property aFolderPropertyInfoTable[] =
167 // Required properties
169 beans::Property(
170 u"ContentType"_ustr,
172 cppu::UnoType<OUString>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
176 beans::Property(
177 u"IsDocument"_ustr,
179 cppu::UnoType<bool>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
183 beans::Property(
184 u"IsFolder"_ustr,
186 cppu::UnoType<bool>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
190 beans::Property(
191 u"Title"_ustr,
193 cppu::UnoType<OUString>::get(),
194 beans::PropertyAttribute::BOUND
197 // Optional standard properties
199 beans::Property(
200 u"MediaType"_ustr,
202 cppu::UnoType<OUString>::get(),
203 beans::PropertyAttribute::BOUND
205 beans::Property(
206 u"CreatableContentsInfo"_ustr,
208 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
209 beans::PropertyAttribute::BOUND
210 | beans::PropertyAttribute::READONLY
213 // New properties
216 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
219 else
223 // Stream: Supported properties
226 static const beans::Property aStreamPropertyInfoTable[] =
229 // Required properties
231 beans::Property(
232 u"ContentType"_ustr,
234 cppu::UnoType<OUString>::get(),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::READONLY
238 beans::Property(
239 u"IsDocument"_ustr,
241 cppu::UnoType<bool>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::READONLY
245 beans::Property(
246 u"IsFolder"_ustr,
248 cppu::UnoType<bool>::get(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::READONLY
252 beans::Property(
253 u"Title"_ustr,
255 cppu::UnoType<OUString>::get(),
256 beans::PropertyAttribute::BOUND
259 // Optional standard properties
261 beans::Property(
262 u"MediaType"_ustr,
264 cppu::UnoType<OUString>::get(),
265 beans::PropertyAttribute::BOUND
267 beans::Property(
268 u"Size"_ustr,
270 cppu::UnoType<sal_Int64>::get(),
271 beans::PropertyAttribute::BOUND
272 | beans::PropertyAttribute::READONLY
274 beans::Property(
275 u"CreatableContentsInfo"_ustr,
277 cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(),
278 beans::PropertyAttribute::BOUND
279 | beans::PropertyAttribute::READONLY
282 // New properties
284 beans::Property(
285 u"Compressed"_ustr,
287 cppu::UnoType<bool>::get(),
288 beans::PropertyAttribute::BOUND
290 beans::Property(
291 u"Encrypted"_ustr,
293 cppu::UnoType<bool>::get(),
294 beans::PropertyAttribute::BOUND
297 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
302 // virtual
303 uno::Sequence< ucb::CommandInfo > Content::getCommands(
304 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
306 osl::Guard< osl::Mutex > aGuard( m_aMutex );
308 if ( isFolder() )
310 if ( m_aUri.isRootFolder() )
314 // Root Folder: Supported commands
317 static const ucb::CommandInfo aRootFolderCommandInfoTable[] =
320 // Required commands
322 ucb::CommandInfo(
323 u"getCommandInfo"_ustr,
325 cppu::UnoType<void>::get()
327 ucb::CommandInfo(
328 u"getPropertySetInfo"_ustr,
330 cppu::UnoType<void>::get()
332 ucb::CommandInfo(
333 u"getPropertyValues"_ustr,
335 cppu::UnoType<uno::Sequence< beans::Property >>::get()
337 ucb::CommandInfo(
338 u"setPropertyValues"_ustr,
340 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
343 // Optional standard commands
345 ucb::CommandInfo(
346 u"open"_ustr,
348 cppu::UnoType<ucb::OpenCommandArgument2>::get()
350 ucb::CommandInfo(
351 u"transfer"_ustr,
353 cppu::UnoType<ucb::TransferInfo>::get()
355 ucb::CommandInfo(
356 u"createNewContent"_ustr,
358 cppu::UnoType<ucb::ContentInfo>::get()
361 // New commands
363 ucb::CommandInfo(
364 u"flush"_ustr,
366 cppu::UnoType<void>::get()
370 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
372 else
376 // Folder: Supported commands
379 static const ucb::CommandInfo aFolderCommandInfoTable[] =
382 // Required commands
384 ucb::CommandInfo(
385 u"getCommandInfo"_ustr,
387 cppu::UnoType<void>::get()
389 ucb::CommandInfo(
390 u"getPropertySetInfo"_ustr,
392 cppu::UnoType<void>::get()
394 ucb::CommandInfo(
395 u"getPropertyValues"_ustr,
397 cppu::UnoType<uno::Sequence< beans::Property >>::get()
399 ucb::CommandInfo(
400 u"setPropertyValues"_ustr,
402 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
405 // Optional standard commands
407 ucb::CommandInfo(
408 u"delete"_ustr,
410 cppu::UnoType<bool>::get()
412 ucb::CommandInfo(
413 u"insert"_ustr,
415 cppu::UnoType<void>::get()
417 ucb::CommandInfo(
418 u"open"_ustr,
420 cppu::UnoType<ucb::OpenCommandArgument2>::get()
422 ucb::CommandInfo(
423 u"transfer"_ustr,
425 cppu::UnoType<ucb::TransferInfo>::get()
427 ucb::CommandInfo(
428 u"createNewContent"_ustr,
430 cppu::UnoType<ucb::ContentInfo>::get()
433 // New commands
435 ucb::CommandInfo(
436 u"flush"_ustr,
438 cppu::UnoType<void>::get()
442 return MAKECMDSEQUENCE( aFolderCommandInfoTable );
445 else
449 // Stream: Supported commands
452 static const ucb::CommandInfo aStreamCommandInfoTable[] =
455 // Required commands
457 ucb::CommandInfo(
458 u"getCommandInfo"_ustr,
460 cppu::UnoType<void>::get()
462 ucb::CommandInfo(
463 u"getPropertySetInfo"_ustr,
465 cppu::UnoType<void>::get()
467 ucb::CommandInfo(
468 u"getPropertyValues"_ustr,
470 cppu::UnoType<uno::Sequence< beans::Property >>::get()
472 ucb::CommandInfo(
473 u"setPropertyValues"_ustr,
475 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get()
478 // Optional standard commands
480 ucb::CommandInfo(
481 u"delete"_ustr,
483 cppu::UnoType<bool>::get()
485 ucb::CommandInfo(
486 u"insert"_ustr,
488 cppu::UnoType<void>::get()
490 ucb::CommandInfo(
491 u"open"_ustr,
493 cppu::UnoType<ucb::OpenCommandArgument2>::get()
496 // New commands
500 return MAKECMDSEQUENCE( aStreamCommandInfoTable );
504 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */