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/.
12 #include <sal/config.h>
14 #include <string_view>
16 #include "cmis_url.hxx"
17 #include "children_provider.hxx"
19 #include <com/sun/star/io/XInputStream.hpp>
20 #include <com/sun/star/io/XOutputStream.hpp>
21 #include <com/sun/star/ucb/CheckinArgument.hpp>
22 #include <com/sun/star/ucb/CommandFailedException.hpp>
23 #include <com/sun/star/ucb/ContentCreationException.hpp>
24 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
25 #include <com/sun/star/ucb/TransferInfo.hpp>
26 #include <com/sun/star/ucb/XContentCreator.hpp>
27 #include <com/sun/star/document/CmisVersion.hpp>
28 #include <ucbhelper/contenthelper.hxx>
30 #if defined __GNUC__ && !defined __clang__
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wdeprecated"
33 #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
35 #include <libcmis/libcmis.hxx>
36 #if defined __GNUC__ && !defined __clang__
37 #pragma GCC diagnostic pop
40 namespace com::sun::star
{
58 inline constexpr OUString CMIS_FILE_TYPE
= u
"application/vnd.libreoffice.cmis-file"_ustr
;
59 inline constexpr OUString CMIS_FOLDER_TYPE
= u
"application/vnd.libreoffice.cmis-folder"_ustr
;
61 class ContentProvider
;
62 class Content
: public ::ucbhelper::ContentImplHelper
,
63 public css::ucb::XContentCreator
,
64 public ChildrenProvider
67 ContentProvider
* m_pProvider
;
68 libcmis::Session
* m_pSession
;
69 libcmis::ObjectPtr m_pObject
;
70 OUString m_sObjectPath
;
75 // Members to be set for non-persistent content
78 libcmis::ObjectTypePtr m_pObjectType
;
79 std::map
< std::string
, libcmis::PropertyPtr
> m_pObjectProps
;
81 bool isFolder( const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
82 void setCmisProperty(const std::string
& rName
, const std::string
& rValue
,
83 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
85 css::uno::Any
getBadArgExcept();
87 css::uno::Reference
< css::sdbc::XRow
>
89 const css::uno::Sequence
< css::beans::Property
>& rProperties
,
90 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
92 libcmis::Session
* getSession( const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
93 libcmis::ObjectTypePtr
const & getObjectType( const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
96 typedef rtl::Reference
< Content
> ContentRef
;
97 typedef std::vector
< ContentRef
> ContentRefList
;
99 /// @throws css::uno::Exception
100 /// @throws libcmis::Exception
101 css::uno::Any
open(const css::ucb::OpenCommandArgument2
& rArg
,
102 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
104 /// @throws css::uno::Exception
105 void transfer( const css::ucb::TransferInfo
& rTransferInfo
,
106 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
108 /// @throws css::uno::Exception
109 void insert( const css::uno::Reference
< css::io::XInputStream
> & xInputStream
,
110 bool bReplaceExisting
, std::u16string_view rMimeType
,
111 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
113 /// @throws css::uno::Exception
114 OUString
checkIn( const css::ucb::CheckinArgument
& rArg
,
115 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
117 /// @throws css::uno::Exception
118 OUString
checkOut( const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
120 /// @throws css::uno::Exception
121 OUString
cancelCheckOut( const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
123 static void copyData( const css::uno::Reference
< css::io::XInputStream
>& xIn
,
124 const css::uno::Reference
< css::io::XOutputStream
>& xOut
);
126 css::uno::Sequence
< css::uno::Any
>
127 setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& rValues
,
128 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
130 /// @throws css::uno::Exception
131 css::uno::Sequence
< css::document::CmisVersion
>
132 getAllVersions( const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
134 bool feedSink( const css::uno::Reference
< css::uno::XInterface
>& aSink
,
135 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
138 /// @throws css::ucb::ContentCreationException
139 Content( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
140 ContentProvider
*pProvider
,
141 const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
,
142 libcmis::ObjectPtr pObject
= libcmis::ObjectPtr( ) );
144 /// @throws css::ucb::ContentCreationException
145 Content( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
146 ContentProvider
*pProvider
,
147 const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
,
150 virtual ~Content() override
;
152 virtual css::uno::Sequence
< css::beans::Property
>
153 getProperties( const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
) override
;
155 libcmis::ObjectPtr
updateProperties(
156 const css::uno::Any
& iCmisProps
,
157 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
159 virtual css::uno::Sequence
< css::ucb::CommandInfo
>
160 getCommands( const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
) override
;
162 virtual OUString
getParentURL() override
;
165 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
166 virtual void SAL_CALL
acquire()
168 virtual void SAL_CALL
release()
171 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
172 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
174 virtual OUString SAL_CALL
175 getImplementationName() override
;
177 virtual css::uno::Sequence
< OUString
> SAL_CALL
178 getSupportedServiceNames() override
;
180 virtual OUString SAL_CALL
181 getContentType() override
;
183 virtual css::uno::Any SAL_CALL
184 execute( const css::ucb::Command
& aCommand
,
186 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& Environment
) override
;
188 virtual void SAL_CALL
abort( sal_Int32 CommandId
) override
;
190 virtual css::uno::Sequence
< css::ucb::ContentInfo
>
191 SAL_CALL
queryCreatableContentsInfo() override
;
193 virtual css::uno::Reference
< css::ucb::XContent
>
194 SAL_CALL
createNewContent( const css::ucb::ContentInfo
& Info
) override
;
196 /// @throws css::uno::RuntimeException
197 css::uno::Sequence
< css::ucb::ContentInfo
>
198 queryCreatableContentsInfo( const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
200 virtual std::vector
< css::uno::Reference
< css::ucb::XContent
> > getChildren( ) override
;
202 /// @throws css::uno::RuntimeException
203 /// @throws css::ucb::CommandFailedException
204 /// @throws libcmis::Exception
205 libcmis::ObjectPtr
const & getObject( const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */