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 document folder folder stream stream
31 ----------------------------------------------------------------
32 ContentType r r r r r r
33 IsDocument r r r r r r
36 CreatableContentsInfo r r r r r r
38 DocumentModel - r - - - -
40 getCommandInfo x x x x x x
41 getPropertySetInfo x x x x x x
42 getPropertyValues x x x x x x
43 setPropertyValues x x x x x x
44 insert - - x x x(*) x(*)
48 createNewContent - x x - - -
51 *************************************************************************/
53 #include <com/sun/star/beans/Property.hpp>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #include <com/sun/star/embed/XStorage.hpp>
57 #include <com/sun/star/frame/XModel.hpp>
58 #include <com/sun/star/ucb/CommandInfo.hpp>
59 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
60 #include <com/sun/star/ucb/TransferInfo.hpp>
61 #include <osl/diagnose.h>
62 #include <sal/macros.h>
63 #include "tdoc_content.hxx"
65 namespace com::sun::star::embed
{
69 using namespace com::sun::star
;
70 using namespace tdoc_ucp
;
73 // Content implementation.
76 #define MAKEPROPSEQUENCE( a ) \
77 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS(a) )
79 #define MAKECMDSEQUENCE( a ) \
80 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) )
83 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
84 // Content::getPropertyValues(...) must be adapted too!
88 uno::Sequence
< beans::Property
> Content::getProperties(
89 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
91 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
93 if ( m_aProps
.getType() == STREAM
)
97 // Stream: Supported properties
100 static const beans::Property aStreamPropertyInfoTable
[] =
103 // Mandatory properties
108 cppu::UnoType
<OUString
>::get(),
109 beans::PropertyAttribute::BOUND
110 | beans::PropertyAttribute::READONLY
115 cppu::UnoType
<bool>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::READONLY
122 cppu::UnoType
<bool>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::READONLY
129 cppu::UnoType
<OUString
>::get(),
130 beans::PropertyAttribute::BOUND
133 // Optional standard properties
136 "CreatableContentsInfo",
138 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
139 beans::PropertyAttribute::BOUND
140 | beans::PropertyAttribute::READONLY
146 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable
);
148 else if ( m_aProps
.getType() == FOLDER
)
152 // Folder: Supported properties
155 static const beans::Property aFolderPropertyInfoTable
[] =
158 // Mandatory properties
163 cppu::UnoType
<OUString
>::get(),
164 beans::PropertyAttribute::BOUND
165 | beans::PropertyAttribute::READONLY
170 cppu::UnoType
<bool>::get(),
171 beans::PropertyAttribute::BOUND
172 | beans::PropertyAttribute::READONLY
177 cppu::UnoType
<bool>::get(),
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::READONLY
184 cppu::UnoType
<OUString
>::get(),
185 beans::PropertyAttribute::BOUND
188 // Optional standard properties
191 "CreatableContentsInfo",
193 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::READONLY
203 cppu::UnoType
<embed::XStorage
>::get(),
204 beans::PropertyAttribute::BOUND
205 | beans::PropertyAttribute::READONLY
208 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
210 else if ( m_aProps
.getType() == DOCUMENT
)
214 // Document: Supported properties
217 static const beans::Property aDocPropertyInfoTable
[] =
220 // Mandatory properties
225 cppu::UnoType
<OUString
>::get(),
226 beans::PropertyAttribute::BOUND
227 | beans::PropertyAttribute::READONLY
232 cppu::UnoType
<bool>::get(),
233 beans::PropertyAttribute::BOUND
234 | beans::PropertyAttribute::READONLY
239 cppu::UnoType
<bool>::get(),
240 beans::PropertyAttribute::BOUND
241 | beans::PropertyAttribute::READONLY
246 cppu::UnoType
<OUString
>::get(),
247 beans::PropertyAttribute::BOUND
248 | beans::PropertyAttribute::READONLY
251 // Optional standard properties
254 "CreatableContentsInfo",
256 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
257 beans::PropertyAttribute::BOUND
258 | beans::PropertyAttribute::READONLY
266 cppu::UnoType
<frame::XModel
>::get(),
267 beans::PropertyAttribute::BOUND
268 | beans::PropertyAttribute::READONLY
271 return MAKEPROPSEQUENCE( aDocPropertyInfoTable
);
277 // Root: Supported properties
280 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
282 static const beans::Property aRootPropertyInfoTable
[] =
285 // Mandatory properties
290 cppu::UnoType
<OUString
>::get(),
291 beans::PropertyAttribute::BOUND
292 | beans::PropertyAttribute::READONLY
297 cppu::UnoType
<bool>::get(),
298 beans::PropertyAttribute::BOUND
299 | beans::PropertyAttribute::READONLY
304 cppu::UnoType
<bool>::get(),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::READONLY
311 cppu::UnoType
<OUString
>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::READONLY
316 // Optional standard properties
319 "CreatableContentsInfo",
321 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
322 beans::PropertyAttribute::BOUND
323 | beans::PropertyAttribute::READONLY
329 return MAKEPROPSEQUENCE( aRootPropertyInfoTable
);
335 uno::Sequence
< ucb::CommandInfo
> Content::getCommands(
336 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
338 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
340 if ( m_aProps
.getType() == STREAM
)
342 Uri
aUri( m_xIdentifier
->getContentIdentifier() );
343 Uri
aParentUri( aUri
.getParentUri() );
345 if ( aParentUri
.isDocument() )
349 // Stream, that is a child of a document: Supported commands
352 static const ucb::CommandInfo aStreamCommandInfoTable1
[] =
355 // Mandatory commands
360 cppu::UnoType
<void>::get()
363 "getPropertySetInfo",
365 cppu::UnoType
<void>::get()
370 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
375 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
378 // Optional standard commands
383 cppu::UnoType
<bool>::get()
388 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
394 return MAKECMDSEQUENCE( aStreamCommandInfoTable1
);
398 // Stream: Supported commands
401 static const ucb::CommandInfo aStreamCommandInfoTable
[] =
404 // Mandatory commands
409 cppu::UnoType
<void>::get()
412 "getPropertySetInfo",
414 cppu::UnoType
<void>::get()
419 cppu::UnoType
< uno::Sequence
< beans::Property
>>::get()
424 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
427 // Optional standard commands
432 cppu::UnoType
<bool>::get()
437 cppu::UnoType
<void>::get()
442 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
448 return MAKECMDSEQUENCE( aStreamCommandInfoTable
);
450 else if ( m_aProps
.getType() == FOLDER
)
454 // Folder: Supported commands
457 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
460 // Mandatory commands
465 cppu::UnoType
<void>::get()
468 "getPropertySetInfo",
470 cppu::UnoType
<void>::get()
475 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
480 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
483 // Optional standard commands
488 cppu::UnoType
<bool>::get()
493 cppu::UnoType
<void>::get()
498 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
503 cppu::UnoType
<ucb::TransferInfo
>::get()
508 cppu::UnoType
<ucb::ContentInfo
>::get()
514 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
516 else if ( m_aProps
.getType() == DOCUMENT
)
520 // Document: Supported commands
523 static const ucb::CommandInfo aDocCommandInfoTable
[] =
526 // Mandatory commands
531 cppu::UnoType
<void>::get()
534 "getPropertySetInfo",
536 cppu::UnoType
<void>::get()
541 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
546 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
549 // Optional standard commands
554 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
559 cppu::UnoType
<ucb::TransferInfo
>::get()
564 cppu::UnoType
<ucb::ContentInfo
>::get()
570 return MAKECMDSEQUENCE( aDocCommandInfoTable
);
576 // Root: Supported commands
579 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
581 static const ucb::CommandInfo aRootCommandInfoTable
[] =
584 // Mandatory commands
589 cppu::UnoType
<void>::get()
592 "getPropertySetInfo",
594 cppu::UnoType
<void>::get()
599 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
604 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
607 // Optional standard commands
612 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
618 return MAKECMDSEQUENCE( aRootCommandInfoTable
);
622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */