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
;
65 // HierarchyContent implementation.
68 #define MAKEPROPSEQUENCE( a ) \
69 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) )
71 #define MAKECMDSEQUENCE( a ) \
72 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) )
75 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
76 // HierarchyContent::getPropertyValues(...) must be adapted too!
80 uno::Sequence
< beans::Property
> HierarchyContent::getProperties(
81 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
83 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
85 if ( m_eKind
== LINK
)
89 // Link: Supported properties
94 static const beans::Property aLinkPropertyInfoTable
[] =
97 // Required properties
102 cppu::UnoType
<OUString
>::get(),
103 beans::PropertyAttribute::BOUND
104 | beans::PropertyAttribute::READONLY
109 cppu::UnoType
<bool>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::READONLY
116 cppu::UnoType
<bool>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::READONLY
123 cppu::UnoType
<OUString
>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::READONLY
128 // Optional standard properties
133 cppu::UnoType
<OUString
>::get(),
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::READONLY
138 "CreatableContentsInfo",
140 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY
)
147 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
151 static const beans::Property aLinkPropertyInfoTable
[] =
154 // Required properties
159 cppu::UnoType
<OUString
>::get(),
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::READONLY
166 cppu::UnoType
<bool>::get(),
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::READONLY
173 cppu::UnoType
<bool>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::READONLY
180 cppu::UnoType
<OUString
>::get(),
181 beans::PropertyAttribute::BOUND
184 // Optional standard properties
189 cppu::UnoType
<OUString
>::get(),
190 beans::PropertyAttribute::BOUND
193 "CreatableContentsInfo",
195 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::READONLY
)
202 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
205 else if ( m_eKind
== FOLDER
)
209 // Folder: Supported properties
214 static const beans::Property aFolderPropertyInfoTable
[] =
217 // Required properties
222 cppu::UnoType
<OUString
>::get(),
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::READONLY
229 cppu::UnoType
<bool>::get(),
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::READONLY
236 cppu::UnoType
<bool>::get(),
237 beans::PropertyAttribute::BOUND
238 | beans::PropertyAttribute::READONLY
243 cppu::UnoType
<OUString
>::get(),
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::READONLY
248 // Optional standard properties
251 "CreatableContentsInfo",
253 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::READONLY
)
260 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
264 static const beans::Property aFolderPropertyInfoTable
[] =
267 // Required properties
272 cppu::UnoType
<OUString
>::get(),
273 beans::PropertyAttribute::BOUND
274 | beans::PropertyAttribute::READONLY
279 cppu::UnoType
<bool>::get(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::READONLY
286 cppu::UnoType
<bool>::get(),
287 beans::PropertyAttribute::BOUND
288 | beans::PropertyAttribute::READONLY
293 cppu::UnoType
<OUString
>::get(),
294 beans::PropertyAttribute::BOUND
297 // Optional standard properties
300 "CreatableContentsInfo",
302 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
303 beans::PropertyAttribute::BOUND
304 | beans::PropertyAttribute::READONLY
)
309 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
316 // Root Folder: Supported properties
319 // Currently no difference between read-only/read-write
320 // -> all props are read-only
322 static const beans::Property aRootFolderPropertyInfoTable
[] =
325 // Required properties
330 cppu::UnoType
<OUString
>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
337 cppu::UnoType
<bool>::get(),
338 beans::PropertyAttribute::BOUND
339 | beans::PropertyAttribute::READONLY
344 cppu::UnoType
<bool>::get(),
345 beans::PropertyAttribute::BOUND
346 | beans::PropertyAttribute::READONLY
351 cppu::UnoType
<OUString
>::get(),
352 beans::PropertyAttribute::BOUND
353 | beans::PropertyAttribute::READONLY
356 // Optional standard properties
359 "CreatableContentsInfo",
361 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
362 beans::PropertyAttribute::BOUND
363 | beans::PropertyAttribute::READONLY
)
368 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable
);
374 uno::Sequence
< ucb::CommandInfo
> HierarchyContent::getCommands(
375 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
377 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
379 if ( m_eKind
== LINK
)
383 // Link: Supported commands
388 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
396 cppu::UnoType
<void>::get()
399 "getPropertySetInfo",
401 cppu::UnoType
<void>::get()
406 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
411 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
414 // Optional standard commands
420 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
424 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
432 cppu::UnoType
<void>::get()
435 "getPropertySetInfo",
437 cppu::UnoType
<void>::get()
442 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
447 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
450 // Optional standard commands
455 cppu::UnoType
<bool>::get()
460 cppu::UnoType
<void>::get()
466 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
469 else if ( m_eKind
== FOLDER
)
473 // Folder: Supported commands
478 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
486 cppu::UnoType
<void>::get()
489 "getPropertySetInfo",
491 cppu::UnoType
<void>::get()
496 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
501 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
504 // Optional standard commands
509 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
515 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
519 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
527 cppu::UnoType
<void>::get()
530 "getPropertySetInfo",
532 cppu::UnoType
<void>::get()
537 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
542 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
545 // Optional standard commands
550 cppu::UnoType
<bool>::get()
555 cppu::UnoType
<void>::get()
560 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
565 cppu::UnoType
<ucb::TransferInfo
>::get()
570 cppu::UnoType
<ucb::ContentInfo
>::get()
576 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
583 // Root Folder: Supported commands
588 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
596 cppu::UnoType
<void>::get()
599 "getPropertySetInfo",
601 cppu::UnoType
<void>::get()
606 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
611 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
614 // Optional standard commands
619 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
625 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
629 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
637 cppu::UnoType
<void>::get()
640 "getPropertySetInfo",
642 cppu::UnoType
<void>::get()
647 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
652 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
655 // Optional standard commands
660 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
665 cppu::UnoType
<ucb::TransferInfo
>::get()
670 cppu::UnoType
<ucb::ContentInfo
>::get()
676 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */