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 **************************************************************************
25 **************************************************************************
29 root folder folder link link
31 ----------------------------------------------------------------
37 CreatableContentsInfo x x x x x
39 getCommandInfo x x x x x
40 getPropertySetInfo x x x x x
41 getPropertyValues x x x x x
42 setPropertyValues x x x x x
49 *************************************************************************/
51 #include <com/sun/star/beans/Property.hpp>
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #include <com/sun/star/beans/PropertyValue.hpp>
54 #include <com/sun/star/ucb/CommandInfo.hpp>
55 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
56 #include <com/sun/star/ucb/TransferInfo.hpp>
57 #include <com/sun/star/uno/Sequence.hxx>
58 #include <sal/macros.h>
59 #include "hierarchycontent.hxx"
61 using namespace com::sun::star
;
62 using namespace hierarchy_ucp
;
66 // HierarchyContent implementation.
70 #define MAKEPROPSEQUENCE( a ) \
71 uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
73 #define MAKECMDSEQUENCE( a ) \
74 uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
78 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
79 // HierarchyContent::getPropertyValues(...) must be adapted too!
84 uno::Sequence
< beans::Property
> HierarchyContent::getProperties(
85 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
87 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
89 if ( m_eKind
== LINK
)
93 // Link: Supported properties
99 static const beans::Property aLinkPropertyInfoTable
[] =
102 // Required properties
105 OUString( "ContentType" ),
107 cppu::UnoType
<OUString
>::get(),
108 beans::PropertyAttribute::BOUND
109 | beans::PropertyAttribute::READONLY
112 OUString( "IsDocument" ),
114 cppu::UnoType
<bool>::get(),
115 beans::PropertyAttribute::BOUND
116 | beans::PropertyAttribute::READONLY
119 OUString( "IsFolder" ),
121 cppu::UnoType
<bool>::get(),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::READONLY
128 cppu::UnoType
<OUString
>::get(),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::READONLY
133 // Optional standard properties
136 OUString( "TargetURL" ),
138 cppu::UnoType
<OUString
>::get(),
139 beans::PropertyAttribute::BOUND
140 | beans::PropertyAttribute::READONLY
144 "CreatableContentsInfo" ),
146 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::READONLY
)
153 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
157 static const beans::Property aLinkPropertyInfoTable
[] =
160 // Required properties
163 OUString( "ContentType" ),
165 cppu::UnoType
<OUString
>::get(),
166 beans::PropertyAttribute::BOUND
167 | beans::PropertyAttribute::READONLY
170 OUString( "IsDocument" ),
172 cppu::UnoType
<bool>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
177 OUString( "IsFolder" ),
179 cppu::UnoType
<bool>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
186 cppu::UnoType
<OUString
>::get(),
187 beans::PropertyAttribute::BOUND
190 // Optional standard properties
193 OUString( "TargetURL" ),
195 cppu::UnoType
<OUString
>::get(),
196 beans::PropertyAttribute::BOUND
200 "CreatableContentsInfo" ),
202 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
203 beans::PropertyAttribute::BOUND
204 | beans::PropertyAttribute::READONLY
)
209 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
212 else if ( m_eKind
== FOLDER
)
216 // Folder: Supported properties
222 static const beans::Property aFolderPropertyInfoTable
[] =
225 // Required properties
228 OUString( "ContentType" ),
230 cppu::UnoType
<OUString
>::get(),
231 beans::PropertyAttribute::BOUND
232 | beans::PropertyAttribute::READONLY
235 OUString( "IsDocument" ),
237 cppu::UnoType
<bool>::get(),
238 beans::PropertyAttribute::BOUND
239 | beans::PropertyAttribute::READONLY
242 OUString( "IsFolder" ),
244 cppu::UnoType
<bool>::get(),
245 beans::PropertyAttribute::BOUND
246 | beans::PropertyAttribute::READONLY
251 cppu::UnoType
<OUString
>::get(),
252 beans::PropertyAttribute::BOUND
253 | beans::PropertyAttribute::READONLY
256 // Optional standard properties
260 "CreatableContentsInfo" ),
262 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
263 beans::PropertyAttribute::BOUND
264 | beans::PropertyAttribute::READONLY
)
269 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
273 static const beans::Property aFolderPropertyInfoTable
[] =
276 // Required properties
279 OUString( "ContentType" ),
281 cppu::UnoType
<OUString
>::get(),
282 beans::PropertyAttribute::BOUND
283 | beans::PropertyAttribute::READONLY
286 OUString( "IsDocument" ),
288 cppu::UnoType
<bool>::get(),
289 beans::PropertyAttribute::BOUND
290 | beans::PropertyAttribute::READONLY
293 OUString( "IsFolder" ),
295 cppu::UnoType
<bool>::get(),
296 beans::PropertyAttribute::BOUND
297 | beans::PropertyAttribute::READONLY
302 cppu::UnoType
<OUString
>::get(),
303 beans::PropertyAttribute::BOUND
306 // Optional standard properties
310 "CreatableContentsInfo" ),
312 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
313 beans::PropertyAttribute::BOUND
314 | beans::PropertyAttribute::READONLY
)
319 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
326 // Root Folder: Supported properties
330 // Currently no difference between reonly /read-write
331 // -> all props ar read-only
333 static const beans::Property aRootFolderPropertyInfoTable
[] =
336 // Required properties
339 OUString( "ContentType" ),
341 cppu::UnoType
<OUString
>::get(),
342 beans::PropertyAttribute::BOUND
343 | beans::PropertyAttribute::READONLY
346 OUString( "IsDocument" ),
348 cppu::UnoType
<bool>::get(),
349 beans::PropertyAttribute::BOUND
350 | beans::PropertyAttribute::READONLY
353 OUString( "IsFolder" ),
355 cppu::UnoType
<bool>::get(),
356 beans::PropertyAttribute::BOUND
357 | beans::PropertyAttribute::READONLY
362 cppu::UnoType
<OUString
>::get(),
363 beans::PropertyAttribute::BOUND
364 | beans::PropertyAttribute::READONLY
367 // Optional standard properties
371 "CreatableContentsInfo" ),
373 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
374 beans::PropertyAttribute::BOUND
375 | beans::PropertyAttribute::READONLY
)
380 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable
);
386 uno::Sequence
< ucb::CommandInfo
> HierarchyContent::getCommands(
387 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
389 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
391 if ( m_eKind
== LINK
)
395 // Link: Supported commands
401 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
407 OUString( "getCommandInfo" ),
409 cppu::UnoType
<void>::get()
412 OUString( "getPropertySetInfo" ),
414 cppu::UnoType
<void>::get()
417 OUString( "getPropertyValues" ),
419 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
422 OUString( "setPropertyValues" ),
424 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
427 // Optional standard commands
434 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
438 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
444 OUString( "getCommandInfo" ),
446 cppu::UnoType
<void>::get()
449 OUString( "getPropertySetInfo" ),
451 cppu::UnoType
<void>::get()
454 OUString( "getPropertyValues" ),
456 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
459 OUString( "setPropertyValues" ),
461 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
464 // Optional standard commands
467 OUString( "delete" ),
469 cppu::UnoType
<bool>::get()
472 OUString( "insert" ),
474 cppu::UnoType
<void>::get()
480 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
483 else if ( m_eKind
== FOLDER
)
487 // Folder: Supported commands
493 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
499 OUString( "getCommandInfo" ),
501 cppu::UnoType
<void>::get()
504 OUString( "getPropertySetInfo" ),
506 cppu::UnoType
<void>::get()
509 OUString( "getPropertyValues" ),
511 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
514 OUString( "setPropertyValues" ),
516 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
519 // Optional standard commands
524 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
530 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
534 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
540 OUString( "getCommandInfo" ),
542 cppu::UnoType
<void>::get()
545 OUString( "getPropertySetInfo" ),
547 cppu::UnoType
<void>::get()
550 OUString( "getPropertyValues" ),
552 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
555 OUString( "setPropertyValues" ),
557 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
560 // Optional standard commands
563 OUString( "delete" ),
565 cppu::UnoType
<bool>::get()
568 OUString( "insert" ),
570 cppu::UnoType
<void>::get()
575 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
578 OUString( "transfer" ),
580 cppu::UnoType
<ucb::TransferInfo
>::get()
583 OUString( "createNewContent" ),
585 cppu::UnoType
<ucb::ContentInfo
>::get()
591 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
598 // Root Folder: Supported commands
604 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
610 OUString( "getCommandInfo" ),
612 cppu::UnoType
<void>::get()
615 OUString( "getPropertySetInfo" ),
617 cppu::UnoType
<void>::get()
620 OUString( "getPropertyValues" ),
622 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
625 OUString( "setPropertyValues" ),
627 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
630 // Optional standard commands
635 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
641 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
645 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
651 OUString( "getCommandInfo" ),
653 cppu::UnoType
<void>::get()
656 OUString( "getPropertySetInfo" ),
658 cppu::UnoType
<void>::get()
661 OUString( "getPropertyValues" ),
663 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
666 OUString( "setPropertyValues" ),
668 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
671 // Optional standard commands
676 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
679 OUString( "transfer" ),
681 cppu::UnoType
<ucb::TransferInfo
>::get()
684 OUString( "createNewContent" ),
686 cppu::UnoType
<ucb::ContentInfo
>::get()
692 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */