1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 /**************************************************************************
32 **************************************************************************
34 **************************************************************************
38 root folder folder link link
40 ----------------------------------------------------------------
46 CreatableContentsInfo x x x x x
48 getCommandInfo x x x x x
49 getPropertySetInfo x x x x x
50 getPropertyValues x x x x x
51 setPropertyValues x x x x x
58 *************************************************************************/
60 #include <com/sun/star/beans/Property.hpp>
61 #include <com/sun/star/beans/PropertyAttribute.hpp>
62 #include <com/sun/star/beans/PropertyValue.hpp>
63 #include <com/sun/star/ucb/CommandInfo.hpp>
64 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
65 #include <com/sun/star/ucb/TransferInfo.hpp>
66 #include <com/sun/star/uno/Sequence.hxx>
67 #include <sal/macros.h>
68 #include "hierarchycontent.hxx"
70 using namespace com::sun::star
;
71 using namespace hierarchy_ucp
;
73 //=========================================================================
75 // HierarchyContent implementation.
77 //=========================================================================
79 #define MAKEPROPSEQUENCE( a ) \
80 uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
82 #define MAKECMDSEQUENCE( a ) \
83 uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
85 //=========================================================================
87 // IMPORTENT: If any property data ( name / type / ... ) are changed, then
88 // HierarchyContent::getPropertyValues(...) must be adapted too!
90 //=========================================================================
93 uno::Sequence
< beans::Property
> HierarchyContent::getProperties(
94 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
96 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
98 if ( m_eKind
== LINK
)
100 //=================================================================
102 // Link: Supported properties
104 //=================================================================
108 static beans::Property aLinkPropertyInfoTable
[] =
110 ///////////////////////////////////////////////////////////
111 // Required properties
112 ///////////////////////////////////////////////////////////
115 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
117 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
123 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
125 getCppuBooleanType(),
126 beans::PropertyAttribute::BOUND
127 | beans::PropertyAttribute::READONLY
130 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
132 getCppuBooleanType(),
133 beans::PropertyAttribute::BOUND
134 | beans::PropertyAttribute::READONLY
137 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
139 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
140 beans::PropertyAttribute::BOUND
141 | beans::PropertyAttribute::READONLY
143 ///////////////////////////////////////////////////////////
144 // Optional standard properties
145 ///////////////////////////////////////////////////////////
147 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ) ),
149 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
150 beans::PropertyAttribute::BOUND
151 | beans::PropertyAttribute::READONLY
154 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
155 "CreatableContentsInfo" ) ),
157 getCppuType( static_cast<
158 const uno::Sequence
< ucb::ContentInfo
> * >( 0 ) ),
159 beans::PropertyAttribute::BOUND
160 | beans::PropertyAttribute::READONLY
)
161 ///////////////////////////////////////////////////////////
163 ///////////////////////////////////////////////////////////
165 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
169 static beans::Property aLinkPropertyInfoTable
[] =
171 ///////////////////////////////////////////////////////////
172 // Required properties
173 ///////////////////////////////////////////////////////////
176 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
178 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
179 beans::PropertyAttribute::BOUND
180 | beans::PropertyAttribute::READONLY
184 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
186 getCppuBooleanType(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
191 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
193 getCppuBooleanType(),
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::READONLY
198 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
200 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
201 beans::PropertyAttribute::BOUND
203 ///////////////////////////////////////////////////////////
204 // Optional standard properties
205 ///////////////////////////////////////////////////////////
207 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ) ),
209 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
210 beans::PropertyAttribute::BOUND
213 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
214 "CreatableContentsInfo" ) ),
216 getCppuType( static_cast<
217 const uno::Sequence
< ucb::ContentInfo
> * >( 0 ) ),
218 beans::PropertyAttribute::BOUND
219 | beans::PropertyAttribute::READONLY
)
220 ///////////////////////////////////////////////////////////
222 ///////////////////////////////////////////////////////////
224 return MAKEPROPSEQUENCE( aLinkPropertyInfoTable
);
227 else if ( m_eKind
== FOLDER
)
229 //=================================================================
231 // Folder: Supported properties
233 //=================================================================
237 static beans::Property aFolderPropertyInfoTable
[] =
239 ///////////////////////////////////////////////////////////
240 // Required properties
241 ///////////////////////////////////////////////////////////
244 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
246 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
247 beans::PropertyAttribute::BOUND
248 | beans::PropertyAttribute::READONLY
252 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
254 getCppuBooleanType(),
255 beans::PropertyAttribute::BOUND
256 | beans::PropertyAttribute::READONLY
259 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
261 getCppuBooleanType(),
262 beans::PropertyAttribute::BOUND
263 | beans::PropertyAttribute::READONLY
266 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
268 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
269 beans::PropertyAttribute::BOUND
270 | beans::PropertyAttribute::READONLY
272 ///////////////////////////////////////////////////////////
273 // Optional standard properties
274 ///////////////////////////////////////////////////////////
276 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
277 "CreatableContentsInfo" ) ),
279 getCppuType( static_cast<
280 const uno::Sequence
< ucb::ContentInfo
> * >( 0 ) ),
281 beans::PropertyAttribute::BOUND
282 | beans::PropertyAttribute::READONLY
)
283 ///////////////////////////////////////////////////////////
285 ///////////////////////////////////////////////////////////
287 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
291 static beans::Property aFolderPropertyInfoTable
[] =
293 ///////////////////////////////////////////////////////////
294 // Required properties
295 ///////////////////////////////////////////////////////////
298 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
300 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
301 beans::PropertyAttribute::BOUND
302 | beans::PropertyAttribute::READONLY
306 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
308 getCppuBooleanType(),
309 beans::PropertyAttribute::BOUND
310 | beans::PropertyAttribute::READONLY
313 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
315 getCppuBooleanType(),
316 beans::PropertyAttribute::BOUND
317 | beans::PropertyAttribute::READONLY
320 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
322 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
323 beans::PropertyAttribute::BOUND
325 ///////////////////////////////////////////////////////////
326 // Optional standard properties
327 ///////////////////////////////////////////////////////////
329 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
330 "CreatableContentsInfo" ) ),
332 getCppuType( static_cast<
333 const uno::Sequence
< ucb::ContentInfo
> * >( 0 ) ),
334 beans::PropertyAttribute::BOUND
335 | beans::PropertyAttribute::READONLY
)
336 ///////////////////////////////////////////////////////////
338 ///////////////////////////////////////////////////////////
340 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
345 //=================================================================
347 // Root Folder: Supported properties
349 //=================================================================
351 // Currently no difference between reonly /read-write
352 // -> all props ar read-only
354 static beans::Property aRootFolderPropertyInfoTable
[] =
356 ///////////////////////////////////////////////////////////////
357 // Required properties
358 ///////////////////////////////////////////////////////////////
360 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
362 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
363 beans::PropertyAttribute::BOUND
364 | beans::PropertyAttribute::READONLY
367 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
369 getCppuBooleanType(),
370 beans::PropertyAttribute::BOUND
371 | beans::PropertyAttribute::READONLY
374 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
376 getCppuBooleanType(),
377 beans::PropertyAttribute::BOUND
378 | beans::PropertyAttribute::READONLY
381 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
383 getCppuType( static_cast< const rtl::OUString
* >( 0 ) ),
384 beans::PropertyAttribute::BOUND
385 | beans::PropertyAttribute::READONLY
387 ///////////////////////////////////////////////////////////////
388 // Optional standard properties
389 ///////////////////////////////////////////////////////////////
391 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
392 "CreatableContentsInfo" ) ),
394 getCppuType( static_cast<
395 const uno::Sequence
< ucb::ContentInfo
> * >( 0 ) ),
396 beans::PropertyAttribute::BOUND
397 | beans::PropertyAttribute::READONLY
)
398 ///////////////////////////////////////////////////////////////
400 ///////////////////////////////////////////////////////////////
402 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable
);
406 //=========================================================================
408 uno::Sequence
< ucb::CommandInfo
> HierarchyContent::getCommands(
409 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
411 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
413 if ( m_eKind
== LINK
)
415 //=================================================================
417 // Link: Supported commands
419 //=================================================================
423 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
425 ///////////////////////////////////////////////////////////
427 ///////////////////////////////////////////////////////////
430 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
436 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
442 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
445 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
449 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
453 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
455 ///////////////////////////////////////////////////////////
456 // Optional standard commands
457 ///////////////////////////////////////////////////////////
459 ///////////////////////////////////////////////////////////
461 ///////////////////////////////////////////////////////////
463 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
467 static const ucb::CommandInfo aLinkCommandInfoTable
[] =
469 ///////////////////////////////////////////////////////////
471 ///////////////////////////////////////////////////////////
474 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
480 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
486 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
489 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
493 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
497 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
499 ///////////////////////////////////////////////////////////
500 // Optional standard commands
501 ///////////////////////////////////////////////////////////
503 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
508 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
512 ///////////////////////////////////////////////////////////
514 ///////////////////////////////////////////////////////////
516 return MAKECMDSEQUENCE( aLinkCommandInfoTable
);
519 else if ( m_eKind
== FOLDER
)
521 //=================================================================
523 // Folder: Supported commands
525 //=================================================================
529 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
531 ///////////////////////////////////////////////////////////
533 ///////////////////////////////////////////////////////////
536 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
542 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
548 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
551 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
555 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
559 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
561 ///////////////////////////////////////////////////////////
562 // Optional standard commands
563 ///////////////////////////////////////////////////////////
565 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
568 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
570 ///////////////////////////////////////////////////////////
572 ///////////////////////////////////////////////////////////
574 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
578 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
580 ///////////////////////////////////////////////////////////
582 ///////////////////////////////////////////////////////////
585 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
591 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
597 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
600 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
604 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
608 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
610 ///////////////////////////////////////////////////////////
611 // Optional standard commands
612 ///////////////////////////////////////////////////////////
614 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
619 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
624 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
627 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
630 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
632 getCppuType( static_cast< ucb::TransferInfo
* >( 0 ) )
636 RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
638 getCppuType( static_cast< ucb::ContentInfo
* >( 0 ) )
640 ///////////////////////////////////////////////////////////
642 ///////////////////////////////////////////////////////////
644 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
649 //=================================================================
651 // Root Folder: Supported commands
653 //=================================================================
657 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
659 ///////////////////////////////////////////////////////////
661 ///////////////////////////////////////////////////////////
664 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
670 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
676 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
679 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
683 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
687 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
689 ///////////////////////////////////////////////////////////
690 // Optional standard commands
691 ///////////////////////////////////////////////////////////
693 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
696 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
698 ///////////////////////////////////////////////////////////
700 ///////////////////////////////////////////////////////////
702 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
706 static const ucb::CommandInfo aRootFolderCommandInfoTable
[] =
708 ///////////////////////////////////////////////////////////
710 ///////////////////////////////////////////////////////////
713 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
719 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
725 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
728 static_cast< uno::Sequence
< beans::Property
> * >( 0 ) )
732 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
736 uno::Sequence
< beans::PropertyValue
> * >( 0 ) )
738 ///////////////////////////////////////////////////////////
739 // Optional standard commands
740 ///////////////////////////////////////////////////////////
742 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
745 static_cast< ucb::OpenCommandArgument2
* >( 0 ) )
748 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
750 getCppuType( static_cast< ucb::TransferInfo
* >( 0 ) )
754 RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
756 getCppuType( static_cast< ucb::ContentInfo
* >( 0 ) )
758 ///////////////////////////////////////////////////////////
760 ///////////////////////////////////////////////////////////
762 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable
);
767 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */