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
37 DateModified - - - - r r
39 DocumentModel - r - - - -
41 getCommandInfo x x x x x x
42 getPropertySetInfo x x x x x x
43 getPropertyValues x x x x x x
44 setPropertyValues x x x x x x
45 insert - - x x x(*) x(*)
49 createNewContent - x x - - -
52 *************************************************************************/
54 #include <com/sun/star/beans/Property.hpp>
55 #include <com/sun/star/beans/PropertyAttribute.hpp>
56 #include <com/sun/star/beans/PropertyValue.hpp>
57 #include <com/sun/star/embed/XStorage.hpp>
58 #include <com/sun/star/frame/XModel.hpp>
59 #include <com/sun/star/ucb/CommandInfo.hpp>
60 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
61 #include <com/sun/star/ucb/TransferInfo.hpp>
62 #include <com/sun/star/util/DateTime.hpp>
63 #include <osl/diagnose.h>
64 #include <sal/macros.h>
65 #include "tdoc_content.hxx"
67 namespace com::sun::star::embed
{
71 using namespace com::sun::star
;
72 using namespace tdoc_ucp
;
75 // Content implementation.
78 #define MAKEPROPSEQUENCE( a ) \
79 uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS(a) )
81 #define MAKECMDSEQUENCE( a ) \
82 uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) )
85 // IMPORTANT: If any property data ( name / type / ... ) are changed, then
86 // Content::getPropertyValues(...) must be adapted too!
90 uno::Sequence
< beans::Property
> Content::getProperties(
91 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
93 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
95 if ( m_aProps
.getType() == STREAM
)
99 // Stream: Supported properties
102 static const beans::Property aStreamPropertyInfoTable
[] =
105 // Mandatory properties
110 cppu::UnoType
<OUString
>::get(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::READONLY
117 cppu::UnoType
<bool>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY
124 cppu::UnoType
<bool>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::READONLY
131 cppu::UnoType
<OUString
>::get(),
132 beans::PropertyAttribute::BOUND
135 // Optional standard properties
138 "CreatableContentsInfo",
140 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::READONLY
147 cppu::UnoType
<css::util::DateTime
>::get(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::READONLY
155 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable
);
157 else if ( m_aProps
.getType() == FOLDER
)
161 // Folder: Supported properties
164 static const beans::Property aFolderPropertyInfoTable
[] =
167 // Mandatory properties
172 cppu::UnoType
<OUString
>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::READONLY
179 cppu::UnoType
<bool>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::READONLY
186 cppu::UnoType
<bool>::get(),
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::READONLY
193 cppu::UnoType
<OUString
>::get(),
194 beans::PropertyAttribute::BOUND
197 // Optional standard properties
200 "CreatableContentsInfo",
202 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
203 beans::PropertyAttribute::BOUND
204 | beans::PropertyAttribute::READONLY
212 cppu::UnoType
<embed::XStorage
>::get(),
213 beans::PropertyAttribute::BOUND
214 | beans::PropertyAttribute::READONLY
217 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable
);
219 else if ( m_aProps
.getType() == DOCUMENT
)
223 // Document: Supported properties
226 static const beans::Property aDocPropertyInfoTable
[] =
229 // Mandatory properties
234 cppu::UnoType
<OUString
>::get(),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::READONLY
241 cppu::UnoType
<bool>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::READONLY
248 cppu::UnoType
<bool>::get(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::READONLY
255 cppu::UnoType
<OUString
>::get(),
256 beans::PropertyAttribute::BOUND
257 | beans::PropertyAttribute::READONLY
260 // Optional standard properties
263 "CreatableContentsInfo",
265 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
266 beans::PropertyAttribute::BOUND
267 | beans::PropertyAttribute::READONLY
275 cppu::UnoType
<frame::XModel
>::get(),
276 beans::PropertyAttribute::BOUND
277 | beans::PropertyAttribute::READONLY
280 return MAKEPROPSEQUENCE( aDocPropertyInfoTable
);
286 // Root: Supported properties
289 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
291 static const beans::Property aRootPropertyInfoTable
[] =
294 // Mandatory properties
299 cppu::UnoType
<OUString
>::get(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::READONLY
306 cppu::UnoType
<bool>::get(),
307 beans::PropertyAttribute::BOUND
308 | beans::PropertyAttribute::READONLY
313 cppu::UnoType
<bool>::get(),
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::READONLY
320 cppu::UnoType
<OUString
>::get(),
321 beans::PropertyAttribute::BOUND
322 | beans::PropertyAttribute::READONLY
325 // Optional standard properties
328 "CreatableContentsInfo",
330 cppu::UnoType
<uno::Sequence
< ucb::ContentInfo
>>::get(),
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::READONLY
338 return MAKEPROPSEQUENCE( aRootPropertyInfoTable
);
344 uno::Sequence
< ucb::CommandInfo
> Content::getCommands(
345 const uno::Reference
< ucb::XCommandEnvironment
> & /*xEnv*/ )
347 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
349 if ( m_aProps
.getType() == STREAM
)
351 Uri
aUri( m_xIdentifier
->getContentIdentifier() );
352 Uri
aParentUri( aUri
.getParentUri() );
354 if ( aParentUri
.isDocument() )
358 // Stream, that is a child of a document: Supported commands
361 static const ucb::CommandInfo aStreamCommandInfoTable1
[] =
364 // Mandatory commands
369 cppu::UnoType
<void>::get()
372 "getPropertySetInfo",
374 cppu::UnoType
<void>::get()
379 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
384 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
387 // Optional standard commands
392 cppu::UnoType
<bool>::get()
397 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
403 return MAKECMDSEQUENCE( aStreamCommandInfoTable1
);
407 // Stream: Supported commands
410 static const ucb::CommandInfo aStreamCommandInfoTable
[] =
413 // Mandatory commands
418 cppu::UnoType
<void>::get()
421 "getPropertySetInfo",
423 cppu::UnoType
<void>::get()
428 cppu::UnoType
< uno::Sequence
< beans::Property
>>::get()
433 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
436 // Optional standard commands
441 cppu::UnoType
<bool>::get()
446 cppu::UnoType
<void>::get()
451 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
457 return MAKECMDSEQUENCE( aStreamCommandInfoTable
);
459 else if ( m_aProps
.getType() == FOLDER
)
463 // Folder: Supported commands
466 static const ucb::CommandInfo aFolderCommandInfoTable
[] =
469 // Mandatory commands
474 cppu::UnoType
<void>::get()
477 "getPropertySetInfo",
479 cppu::UnoType
<void>::get()
484 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
489 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
492 // Optional standard commands
497 cppu::UnoType
<bool>::get()
502 cppu::UnoType
<void>::get()
507 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
512 cppu::UnoType
<ucb::TransferInfo
>::get()
517 cppu::UnoType
<ucb::ContentInfo
>::get()
523 return MAKECMDSEQUENCE( aFolderCommandInfoTable
);
525 else if ( m_aProps
.getType() == DOCUMENT
)
529 // Document: Supported commands
532 static const ucb::CommandInfo aDocCommandInfoTable
[] =
535 // Mandatory commands
540 cppu::UnoType
<void>::get()
543 "getPropertySetInfo",
545 cppu::UnoType
<void>::get()
550 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
555 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
558 // Optional standard commands
563 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
568 cppu::UnoType
<ucb::TransferInfo
>::get()
573 cppu::UnoType
<ucb::ContentInfo
>::get()
579 return MAKECMDSEQUENCE( aDocCommandInfoTable
);
585 // Root: Supported commands
588 OSL_ENSURE( m_aProps
.getType() == ROOT
, "Wrong content type!" );
590 static const ucb::CommandInfo aRootCommandInfoTable
[] =
593 // Mandatory commands
598 cppu::UnoType
<void>::get()
601 "getPropertySetInfo",
603 cppu::UnoType
<void>::get()
608 cppu::UnoType
<uno::Sequence
< beans::Property
>>::get()
613 cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get()
616 // Optional standard commands
621 cppu::UnoType
<ucb::OpenCommandArgument2
>::get()
627 return MAKECMDSEQUENCE( aRootCommandInfoTable
);
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */