fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_content.hxx
bloba173d246adc37c41a4507bb8a344d854afb32bdd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_CONTENT_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_CONTENT_HXX
23 #include <ucbhelper/contenthelper.hxx>
24 #include <com/sun/star/task/DocumentPasswordRequest.hpp>
25 #include <com/sun/star/ucb/XContentCreator.hpp>
26 #include <com/sun/star/ucb/CommandFailedException.hpp>
27 #include "tdoc_provider.hxx"
29 #define NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 1
31 namespace com { namespace sun { namespace star {
32 namespace sdbc { class XRow; }
33 namespace io { class XInputStream; class XOutputStream; }
34 namespace beans { struct PropertyValue; }
35 namespace ucb { struct OpenCommandArgument2; struct TransferInfo;
36 struct ContentInfo; }
37 } } }
39 namespace tdoc_ucp
44 #define TDOC_ROOT_CONTENT_SERVICE_NAME \
45 "com.sun.star.ucb.TransientDocumentsRootContent"
46 #define TDOC_DOCUMENT_CONTENT_SERVICE_NAME \
47 "com.sun.star.ucb.TransientDocumentsDocumentContent"
48 #define TDOC_FOLDER_CONTENT_SERVICE_NAME \
49 "com.sun.star.ucb.TransientDocumentsFolderContent"
50 #define TDOC_STREAM_CONTENT_SERVICE_NAME \
51 "com.sun.star.ucb.TransientDocumentsStreamContent"
55 enum ContentType { STREAM, FOLDER, DOCUMENT, ROOT };
57 class ContentProperties
59 public:
60 ContentProperties()
61 : m_eType( STREAM )
64 ContentProperties( const ContentType & rType, const OUString & rTitle )
65 : m_eType( rType ),
66 m_aContentType( rType == STREAM
67 ? OUString( TDOC_STREAM_CONTENT_TYPE )
68 : rType == FOLDER
69 ? OUString( TDOC_FOLDER_CONTENT_TYPE )
70 : rType == DOCUMENT
71 ? OUString( TDOC_DOCUMENT_CONTENT_TYPE )
72 : OUString( TDOC_ROOT_CONTENT_TYPE ) ),
73 m_aTitle( rTitle )
76 ContentType getType() const { return m_eType; }
78 // Properties
80 const OUString & getContentType() const { return m_aContentType; }
82 bool getIsFolder() const { return m_eType > STREAM; }
83 bool getIsDocument() const { return !getIsFolder(); }
85 const OUString & getTitle() const { return m_aTitle; }
86 void setTitle( const OUString & rTitle ) { m_aTitle = rTitle; }
88 com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
89 getCreatableContentsInfo() const;
91 bool isContentCreator() const;
93 private:
94 ContentType m_eType;
95 OUString m_aContentType;
96 OUString m_aTitle;
101 class Content : public ::ucbhelper::ContentImplHelper,
102 public com::sun::star::ucb::XContentCreator
104 enum ContentState { TRANSIENT, // created via createNewContent,
105 // but did not process "insert" yet
106 PERSISTENT, // processed "insert"
107 DEAD // processed "delete" / document was closed
110 ContentProperties m_aProps;
111 ContentState m_eState;
112 ContentProvider* m_pProvider;
114 private:
115 Content( const com::sun::star::uno::Reference<
116 com::sun::star::uno::XComponentContext >& rxContext,
117 ContentProvider* pProvider,
118 const com::sun::star::uno::Reference<
119 com::sun::star::ucb::XContentIdentifier >& Identifier,
120 const ContentProperties & rProps );
121 Content( const com::sun::star::uno::Reference<
122 com::sun::star::uno::XComponentContext >& rxContext,
123 ContentProvider* pProvider,
124 const com::sun::star::uno::Reference<
125 com::sun::star::ucb::XContentIdentifier >& Identifier,
126 const com::sun::star::ucb::ContentInfo& Info );
128 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
129 getProperties( const com::sun::star::uno::Reference<
130 com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
131 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
132 getCommands( const com::sun::star::uno::Reference<
133 com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
134 virtual OUString getParentURL() SAL_OVERRIDE;
136 static bool hasData( ContentProvider* pProvider, const Uri & rUri );
137 bool hasData( const Uri & rUri ) { return hasData( m_pProvider, rUri ); }
139 static bool loadData( ContentProvider* pProvider,
140 const Uri & rUri,
141 ContentProperties& rProps );
142 bool storeData( const com::sun::star::uno::Reference<
143 com::sun::star::io::XInputStream >& xData,
144 const com::sun::star::uno::Reference<
145 com::sun::star::ucb::XCommandEnvironment >& xEnv )
146 throw ( ::com::sun::star::ucb::CommandFailedException,
147 ::com::sun::star::task::DocumentPasswordRequest,
148 css::uno::RuntimeException );
149 bool renameData( const com::sun::star::uno::Reference<
150 com::sun::star::ucb::XContentIdentifier >& xOldId,
151 const com::sun::star::uno::Reference<
152 com::sun::star::ucb::XContentIdentifier >& xNewId );
153 bool removeData();
155 bool copyData( const Uri & rSourceUri, const OUString & rNewName );
157 ::com::sun::star::uno::Reference<
158 ::com::sun::star::ucb::XContentIdentifier >
159 makeNewIdentifier( const OUString& rTitle );
161 typedef rtl::Reference< Content > ContentRef;
162 typedef std::list< ContentRef > ContentRefList;
163 void queryChildren( ContentRefList& rChildren );
165 bool exchangeIdentity(
166 const ::com::sun::star::uno::Reference<
167 ::com::sun::star::ucb::XContentIdentifier >& xNewId );
169 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
170 getPropertyValues( const ::com::sun::star::uno::Sequence<
171 ::com::sun::star::beans::Property >& rProperties );
172 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
173 setPropertyValues(
174 const ::com::sun::star::uno::Sequence<
175 ::com::sun::star::beans::PropertyValue >& rValues,
176 const ::com::sun::star::uno::Reference<
177 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
178 throw( ::com::sun::star::uno::Exception );
180 com::sun::star::uno::Any
181 open( const ::com::sun::star::ucb::OpenCommandArgument2& rArg,
182 const ::com::sun::star::uno::Reference<
183 ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
184 throw( ::com::sun::star::uno::Exception );
186 void insert( const ::com::sun::star::uno::Reference<
187 ::com::sun::star::io::XInputStream >& xData,
188 sal_Int32 nNameClashResolve,
189 const ::com::sun::star::uno::Reference<
190 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
191 throw( ::com::sun::star::uno::Exception );
193 void destroy( bool bDeletePhysical,
194 const ::com::sun::star::uno::Reference<
195 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
196 throw( ::com::sun::star::uno::Exception );
198 void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
199 const ::com::sun::star::uno::Reference<
200 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
201 throw( ::com::sun::star::uno::Exception );
203 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
204 getPropertyValues( const ::com::sun::star::uno::Reference<
205 ::com::sun::star::uno::XComponentContext >& rxContext,
206 const ::com::sun::star::uno::Sequence<
207 ::com::sun::star::beans::Property >& rProperties,
208 const ContentProperties& rData,
209 ContentProvider* pProvider,
210 const OUString& rContentId );
213 static bool commitStorage(
214 const com::sun::star::uno::Reference<
215 com::sun::star::embed::XStorage > & xStorage );
217 static bool closeOutputStream(
218 const com::sun::star::uno::Reference<
219 com::sun::star::io::XOutputStream > & xOut );
221 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
222 getInputStream( const ::com::sun::star::uno::Reference<
223 ::com::sun::star::ucb::XCommandEnvironment > &
224 xEnv )
225 throw ( css::ucb::CommandFailedException,
226 css::task::DocumentPasswordRequest,
227 css::uno::RuntimeException );
229 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
230 getTruncatedOutputStream(
231 const ::com::sun::star::uno::Reference<
232 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
233 throw ( css::ucb::CommandFailedException,
234 css::task::DocumentPasswordRequest,
235 css::uno::RuntimeException );
237 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >
238 queryChildContent( const OUString & rRelativeChildUri );
240 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >
241 getStream( const ::com::sun::star::uno::Reference<
242 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
243 throw ( css::ucb::CommandFailedException,
244 css::task::DocumentPasswordRequest,
245 css::uno::RuntimeException );
247 public:
248 // Create existing content. Fail, if not already exists.
249 static Content* create(
250 const com::sun::star::uno::Reference<
251 com::sun::star::uno::XComponentContext >& rxContext,
252 ContentProvider* pProvider,
253 const com::sun::star::uno::Reference<
254 com::sun::star::ucb::XContentIdentifier >& Identifier );
256 // Create new content. Fail, if already exists.
257 static Content* create(
258 const com::sun::star::uno::Reference<
259 com::sun::star::uno::XComponentContext >& rxContext,
260 ContentProvider* pProvider,
261 const com::sun::star::uno::Reference<
262 com::sun::star::ucb::XContentIdentifier >& Identifier,
263 const com::sun::star::ucb::ContentInfo& Info );
265 virtual ~Content();
267 // XInterface
268 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
269 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
270 virtual void SAL_CALL acquire()
271 throw() SAL_OVERRIDE;
272 virtual void SAL_CALL release()
273 throw() SAL_OVERRIDE;
275 // XTypeProvider
276 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
277 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
278 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
279 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
281 // XServiceInfo
282 virtual OUString SAL_CALL
283 getImplementationName()
284 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
285 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
286 getSupportedServiceNames()
287 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
289 // XContent
290 virtual OUString SAL_CALL
291 getContentType()
292 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
293 virtual com::sun::star::uno::Reference<
294 com::sun::star::ucb::XContentIdentifier > SAL_CALL
295 getIdentifier()
296 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
298 // XCommandProcessor
299 virtual com::sun::star::uno::Any SAL_CALL
300 execute( const com::sun::star::ucb::Command& aCommand,
301 sal_Int32 CommandId,
302 const com::sun::star::uno::Reference<
303 com::sun::star::ucb::XCommandEnvironment >& Environment )
304 throw( com::sun::star::uno::Exception,
305 com::sun::star::ucb::CommandAbortedException,
306 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
307 virtual void SAL_CALL
308 abort( sal_Int32 CommandId )
309 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
312 // Additional interfaces
315 // XContentCreator
316 virtual com::sun::star::uno::Sequence<
317 com::sun::star::ucb::ContentInfo > SAL_CALL
318 queryCreatableContentsInfo()
319 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
320 virtual com::sun::star::uno::Reference<
321 com::sun::star::ucb::XContent > SAL_CALL
322 createNewContent( const com::sun::star::ucb::ContentInfo& Info )
323 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
326 // Non-interface methods.
329 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
330 getPropertyValues( const ::com::sun::star::uno::Reference<
331 ::com::sun::star::uno::XComponentContext >& rxContext,
332 const ::com::sun::star::uno::Sequence<
333 ::com::sun::star::beans::Property >& rProperties,
334 ContentProvider* pProvider,
335 const OUString& rContentId );
337 void notifyDocumentClosed();
338 void notifyChildRemoved( const OUString & rRelativeChildUri );
339 void notifyChildInserted( const OUString & rRelativeChildUri );
341 rtl::Reference< ContentProvider > getContentProvider() const
342 { return rtl::Reference< ContentProvider >( m_pProvider ); }
345 } // namespace tdoc_ucp
347 #endif // INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_CONTENT_HXX
349 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */