1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 /**************************************************************************
23 **************************************************************************
27 rootfolder folder stream
28 ---------------------------------------------
35 CreatableContentsInfo r r r
38 HasEncryptedEntries r - -
41 getPropertySetInfo x x x
42 getPropertyValues x x x
43 setPropertyValues x 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
;
67 // Content implementation.
71 #define MAKEPROPSEQUENCE( a ) \
72 uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
74 #define MAKECMDSEQUENCE( a ) \
75 uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
79 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
80 // Content::getPropertyValues(...) must be adapted too!
85 uno::Sequence
< beans::Property
> Content::getProperties(
86 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
88 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
92 if ( m_aUri
.isRootFolder() )
96 // Root Folder: Supported properties
100 static const beans::Property aRootFolderPropertyInfoTable
[] =
103 // Required properties
106 OUString( "ContentType" ),
108 cppu::UnoType
<OUString
>::get(),
109 beans::PropertyAttribute::BOUND
110 | beans::PropertyAttribute::READONLY
113 OUString( "IsDocument" ),
115 cppu::UnoType
<bool>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::READONLY
120 OUString( "IsFolder" ),
122 cppu::UnoType
<bool>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::READONLY
129 cppu::UnoType
<OUString
>::get(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::READONLY
134 // Optional standard properties
137 OUString( "MediaType" ),
139 cppu::UnoType
<OUString
>::get(),
140 beans::PropertyAttribute::BOUND
144 "CreatableContentsInfo" ),
146 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::READONLY
154 OUString( "HasEncryptedEntries" ),
156 cppu::UnoType
<bool>::get(),
157 beans::PropertyAttribute::BOUND
158 | beans::PropertyAttribute::READONLY
161 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable
);
167 // Folder: Supported properties
171 static const beans::Property aFolderPropertyInfoTable
[] =
174 // Required properties
177 OUString( "ContentType" ),
179 cppu::UnoType
<OUString
>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
184 OUString( "IsDocument" ),
186 cppu::UnoType
<bool>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
191 OUString( "IsFolder" ),
193 cppu::UnoType
<bool>::get(),
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::READONLY
200 cppu::UnoType
<OUString
>::get(),
201 beans::PropertyAttribute::BOUND
204 // Optional standard properties
207 OUString( "MediaType" ),
209 cppu::UnoType
<OUString
>::get(),
210 beans::PropertyAttribute::BOUND
214 "CreatableContentsInfo" ),
216 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
217 beans::PropertyAttribute::BOUND
218 | beans::PropertyAttribute::READONLY
224 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
231 // Stream: Supported properties
235 static const beans::Property aStreamPropertyInfoTable
[] =
238 // Required properties
241 OUString( "ContentType" ),
243 cppu::UnoType
<OUString
>::get(),
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::READONLY
248 OUString( "IsDocument" ),
250 cppu::UnoType
<bool>::get(),
251 beans::PropertyAttribute::BOUND
252 | beans::PropertyAttribute::READONLY
255 OUString( "IsFolder" ),
257 cppu::UnoType
<bool>::get(),
258 beans::PropertyAttribute::BOUND
259 | beans::PropertyAttribute::READONLY
264 cppu::UnoType
<OUString
>::get(),
265 beans::PropertyAttribute::BOUND
268 // Optional standard properties
271 OUString( "MediaType" ),
273 cppu::UnoType
<OUString
>::get(),
274 beans::PropertyAttribute::BOUND
279 cppu::UnoType
<sal_Int64
>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
285 "CreatableContentsInfo" ),
287 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
288 beans::PropertyAttribute::BOUND
289 | beans::PropertyAttribute::READONLY
295 OUString( "Compressed" ),
297 cppu::UnoType
<bool>::get(),
298 beans::PropertyAttribute::BOUND
301 OUString( "Encrypted" ),
303 cppu::UnoType
<bool>::get(),
304 beans::PropertyAttribute::BOUND
307 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable
);
313 uno::Sequence
< ucb::CommandInfo
> Content::getCommands(
314 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
316 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
320 if ( m_aUri
.isRootFolder() )
324 // Root Folder: Supported commands
328 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
334 OUString( "getCommandInfo" ),
336 cppu::UnoType
<void>::get()
339 OUString( "getPropertySetInfo" ),
341 cppu::UnoType
<void>::get()
344 OUString( "getPropertyValues" ),
346 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
349 OUString( "setPropertyValues" ),
351 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
354 // Optional standard commands
359 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
362 OUString( "transfer" ),
364 cppu::UnoType
<ucb::TransferInfo
>::get()
367 OUString( "createNewContent" ),
369 cppu::UnoType
<ucb::ContentInfo
>::get()
377 cppu::UnoType
<void>::get()
381 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
387 // Folder: Supported commands
391 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
397 OUString( "getCommandInfo" ),
399 cppu::UnoType
<void>::get()
402 OUString( "getPropertySetInfo" ),
404 cppu::UnoType
<void>::get()
407 OUString( "getPropertyValues" ),
409 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
412 OUString( "setPropertyValues" ),
414 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
417 // Optional standard commands
420 OUString( "delete" ),
422 cppu::UnoType
<bool>::get()
425 OUString( "insert" ),
427 cppu::UnoType
<void>::get()
432 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
435 OUString( "transfer" ),
437 cppu::UnoType
<ucb::TransferInfo
>::get()
440 OUString( "createNewContent" ),
442 cppu::UnoType
<ucb::ContentInfo
>::get()
450 cppu::UnoType
<void>::get()
454 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
461 // Stream: Supported commands
465 static const ucb::CommandInfo aStreamCommandInfoTable
[] =
471 OUString( "getCommandInfo" ),
473 cppu::UnoType
<void>::get()
476 OUString( "getPropertySetInfo" ),
478 cppu::UnoType
<void>::get()
481 OUString( "getPropertyValues" ),
483 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
486 OUString( "setPropertyValues" ),
488 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
491 // Optional standard commands
494 OUString( "delete" ),
496 cppu::UnoType
<bool>::get()
499 OUString( "insert" ),
501 cppu::UnoType
<void>::get()
506 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
513 return MAKECMDSEQUENCE( aStreamCommandInfoTable
);
517 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */