Debian Codegraph @

ucb/source/ucp/cmis/cmis_content.hxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
10 #pragma once
11
12 #include <sal/config.h>
13
14 #include <string_view>
15
16 #include "cmis_url.hxx"
17 #include "children_provider.hxx"
18
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>
29
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"
34 #endif
35 #include <libcmis/libcmis.hxx>
36 #if defined __GNUC__ && !defined __clang__
37 #pragma GCC diagnostic pop
38 #endif
39
40 namespace com::sun::star {
41 namespace beans {
42 struct Property;
43 struct PropertyValue;
44 }
45 namespace sdbc {
46 class XRow;
47 }
48 }
49 namespace ucbhelper
50 {
51 class Content;
52 }
53
54
55 namespace cmis
56 {
57 inline constexpr OUString CMIS_REPO_TYPE = u"application/vnd.libreoffice.cmis-repository"_ustr;
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;
60
61 class ContentProvider;
62 libcmis::Session* createSession(const css::uno::Reference<css::ucb::XCommandEnvironment>& xEnv,
63 ContentProvider& rProvider, const URL& rURL,
64 const OUString& rContentId,
65 const css::uno::Reference<css::ucb::XContent>& xContext);
66
67 class Content : public ::ucbhelper::ContentImplHelper,
68 public css::ucb::XContentCreator,
69 public ChildrenProvider
70 {
71 private:
72 ContentProvider* m_pProvider;
73 libcmis::Session* m_pSession;
74 libcmis::ObjectPtr m_pObject;
75 OUString m_sObjectPath;
76 OUString m_sObjectId;
77 OUString m_sURL;
78 cmis::URL m_aURL;
79
80 // Members to be set for non-persistent content
81 bool m_bTransient;
82 bool m_bIsFolder;
83 libcmis::ObjectTypePtr m_pObjectType;
84 std::map< std::string, libcmis::PropertyPtr > m_pObjectProps;
85
86 bool isFolder( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
87 void setCmisProperty(const std::string& rName, const std::string& rValue,
88 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
89
90 css::uno::Any getBadArgExcept();
91
92 css::uno::Reference< css::sdbc::XRow >
93 getPropertyValues(
94 const css::uno::Sequence< css::beans::Property >& rProperties,
95 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
96
97 libcmis::Session* getSession( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
98 libcmis::ObjectTypePtr const & getObjectType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
99
100 private:
101 typedef rtl::Reference< Content > ContentRef;
102 typedef std::vector< ContentRef > ContentRefList;
103
104 /// @throws css::uno::Exception
105 /// @throws libcmis::Exception
106 css::uno::Any open(const css::ucb::OpenCommandArgument2 & rArg,
107 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
108
109 /// @throws css::uno::Exception
110 void transfer( const css::ucb::TransferInfo& rTransferInfo,
111 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
112
113 /// @throws css::uno::Exception
114 void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
115 bool bReplaceExisting, std::u16string_view rMimeType,
116 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
117
118 /// @throws css::uno::Exception
119 OUString checkIn( const css::ucb::CheckinArgument& rArg,
120 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
121
122 /// @throws css::uno::Exception
123 OUString checkOut( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
124
125 /// @throws css::uno::Exception
126 OUString cancelCheckOut( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
127
128 static void copyData( const css::uno::Reference< css::io::XInputStream >& xIn,
129 const css::uno::Reference< css::io::XOutputStream >& xOut );
130
131 css::uno::Sequence< css::uno::Any >
132 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
133 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
134
135 /// @throws css::uno::Exception
136 css::uno::Sequence< css::document::CmisVersion >
137 getAllVersions( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
138
139 bool feedSink( const css::uno::Reference< css::uno::XInterface>& aSink,
140 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
141
142 public:
143 /// @throws css::ucb::ContentCreationException
144 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
145 ContentProvider *pProvider,
146 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
147 libcmis::ObjectPtr pObject = libcmis::ObjectPtr( ) );
148
149 /// @throws css::ucb::ContentCreationException
150 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
151 ContentProvider *pProvider,
152 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
153 bool bIsFolder);
154
155 virtual ~Content() override;
156
157 virtual css::uno::Sequence< css::beans::Property >
158 getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
159
160 libcmis::ObjectPtr updateProperties(
161 const css::uno::Any& iCmisProps,
162 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv);
163
164 virtual css::uno::Sequence< css::ucb::CommandInfo >
165 getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
166
167 virtual OUString getParentURL() override;
168
169 // XInterface
170 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
171 virtual void SAL_CALL acquire()
172 noexcept override;
173 virtual void SAL_CALL release()
174 noexcept override;
175
176 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
177 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
178
179 virtual OUString SAL_CALL
180 getImplementationName() override;
181
182 virtual css::uno::Sequence< OUString > SAL_CALL
183 getSupportedServiceNames() override;
184
185 virtual OUString SAL_CALL
186 getContentType() override;
187
188 virtual css::uno::Any SAL_CALL
189 execute( const css::ucb::Command& aCommand,
190 sal_Int32 CommandId,
191 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
192
193 virtual void SAL_CALL abort( sal_Int32 CommandId ) override;
194
195 virtual css::uno::Sequence< css::ucb::ContentInfo >
196 SAL_CALL queryCreatableContentsInfo() override;
197
198 virtual css::uno::Reference< css::ucb::XContent >
199 SAL_CALL createNewContent( const css::ucb::ContentInfo& Info ) override;
200
201 /// @throws css::uno::RuntimeException
202 css::uno::Sequence< css::ucb::ContentInfo >
203 queryCreatableContentsInfo( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
204
205 virtual std::vector< css::uno::Reference< css::ucb::XContent > > getChildren( ) override;
206
207 /// @throws css::uno::RuntimeException
208 /// @throws css::ucb::CommandFailedException
209 /// @throws libcmis::Exception
210 libcmis::ObjectPtr const & getObject( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
211 };
212
213 }
214
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */