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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_PACKAGE_PKGCONTENT_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_PACKAGE_PKGCONTENT_HXX
24 #include <rtl/ref.hxx>
26 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
27 #include <com/sun/star/ucb/XContentCreator.hpp>
28 #include <ucbhelper/contenthelper.hxx>
31 namespace com
{ namespace sun
{ namespace star
{
39 class XHierarchicalNameAccess
;
52 struct OpenCommandArgument2
;
62 // UNO service name for the content.
63 #define PACKAGE_FOLDER_CONTENT_SERVICE_NAME \
64 "com.sun.star.ucb.PackageFolderContent"
65 #define PACKAGE_STREAM_CONTENT_SERVICE_NAME \
66 "com.sun.star.ucb.PackageStreamContent"
70 struct ContentProperties
72 OUString aTitle
; // Title
73 OUString aContentType
; // ContentType
74 bool bIsDocument
; // IsDocument
75 bool bIsFolder
; // IsFolder
76 OUString aMediaType
; // MediaType
77 com::sun::star::uno::Sequence
<
78 sal_Int8
> aEncryptionKey
; // EncryptionKey
79 sal_Int64 nSize
; // Size
80 bool bCompressed
; // Compressed
81 bool bEncrypted
; // Encrypted
82 bool bHasEncryptedEntries
; // HasEncryptedEntries
85 : bIsDocument( true ), bIsFolder( false ), nSize( 0 ),
86 bCompressed( true ), bEncrypted( false ),
87 bHasEncryptedEntries( false ) {}
89 ContentProperties( const OUString
& rContentType
);
91 com::sun::star::uno::Sequence
< com::sun::star::ucb::ContentInfo
>
92 getCreatableContentsInfo( PackageUri
const & rUri
) const;
97 class ContentProvider
;
99 class Content
: public ::ucbhelper::ContentImplHelper
,
100 public com::sun::star::ucb::XContentCreator
102 enum ContentState
{ TRANSIENT
, // created via CreateNewContent,
103 // but did not process "insert" yet
104 PERSISTENT
, // processed "insert"
105 DEAD
// processed "delete"
109 ContentProperties m_aProps
;
110 ContentState m_eState
;
111 com::sun::star::uno::Reference
<
112 com::sun::star::container::XHierarchicalNameAccess
> m_xPackage
;
113 ContentProvider
* m_pProvider
;
114 sal_uInt32 m_nModifiedProps
;
117 Content( const com::sun::star::uno::Reference
<
118 com::sun::star::uno::XComponentContext
>& rxContext
,
119 ContentProvider
* pProvider
,
120 const com::sun::star::uno::Reference
<
121 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
122 const ::com::sun::star::uno::Reference
<
123 com::sun::star::container::XHierarchicalNameAccess
>& Package
,
124 const PackageUri
& rUri
,
125 const ContentProperties
& rProps
);
126 Content( const com::sun::star::uno::Reference
<
127 com::sun::star::uno::XComponentContext
>& rxContext
,
128 ContentProvider
* pProvider
,
129 const com::sun::star::uno::Reference
<
130 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
131 const com::sun::star::uno::Reference
<
132 com::sun::star::container::XHierarchicalNameAccess
>& Package
,
133 const PackageUri
& rUri
,
134 const com::sun::star::ucb::ContentInfo
& Info
);
136 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>
137 getProperties( const com::sun::star::uno::Reference
<
138 com::sun::star::ucb::XCommandEnvironment
> & xEnv
) SAL_OVERRIDE
;
139 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::CommandInfo
>
140 getCommands( const com::sun::star::uno::Reference
<
141 com::sun::star::ucb::XCommandEnvironment
> & xEnv
) SAL_OVERRIDE
;
142 virtual OUString
getParentURL() SAL_OVERRIDE
;
144 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
145 getPropertyValues( const ::com::sun::star::uno::Reference
<
146 ::com::sun::star::uno::XComponentContext
>& rxContext
,
147 const ::com::sun::star::uno::Sequence
<
148 ::com::sun::star::beans::Property
>& rProperties
,
149 const ContentProperties
& rData
,
150 const rtl::Reference
<
151 ::ucbhelper::ContentProviderImplHelper
>& rProvider
,
152 const OUString
& rContentId
);
154 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
155 getPropertyValues( const ::com::sun::star::uno::Sequence
<
156 ::com::sun::star::beans::Property
>& rProperties
);
157 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
158 setPropertyValues( const ::com::sun::star::uno::Sequence
<
159 ::com::sun::star::beans::PropertyValue
>& rValues
,
160 const ::com::sun::star::uno::Reference
<
161 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
162 throw( ::com::sun::star::uno::Exception
);
164 com::sun::star::uno::Reference
<
165 com::sun::star::container::XHierarchicalNameAccess
>
166 getPackage( const PackageUri
& rURI
);
167 com::sun::star::uno::Reference
<
168 com::sun::star::container::XHierarchicalNameAccess
>
172 loadData( ContentProvider
* pProvider
,
173 const PackageUri
& rURI
,
174 ContentProperties
& rProps
,
175 com::sun::star::uno::Reference
<
176 com::sun::star::container::XHierarchicalNameAccess
> &
179 hasData( ContentProvider
* pProvider
,
180 const PackageUri
& rURI
,
181 com::sun::star::uno::Reference
<
182 com::sun::star::container::XHierarchicalNameAccess
> &
186 hasData( const PackageUri
& rURI
);
188 renameData( const com::sun::star::uno::Reference
<
189 com::sun::star::ucb::XContentIdentifier
>& xOldId
,
190 const com::sun::star::uno::Reference
<
191 com::sun::star::ucb::XContentIdentifier
>& xNewId
);
193 storeData( const com::sun::star::uno::Reference
<
194 com::sun::star::io::XInputStream
>& xStream
);
201 typedef rtl::Reference
< Content
> ContentRef
;
202 typedef std::list
< ContentRef
> ContentRefList
;
203 void queryChildren( ContentRefList
& rChildren
);
206 exchangeIdentity( const ::com::sun::star::uno::Reference
<
207 ::com::sun::star::ucb::XContentIdentifier
>& xNewId
);
209 ::com::sun::star::uno::Any
210 open( const ::com::sun::star::ucb::OpenCommandArgument2
& rArg
,
211 const ::com::sun::star::uno::Reference
<
212 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
213 throw( ::com::sun::star::uno::Exception
);
215 void insert( const ::com::sun::star::uno::Reference
<
216 ::com::sun::star::io::XInputStream
>& xStream
,
217 sal_Int32 nNameClashResolve
,
218 const ::com::sun::star::uno::Reference
<
219 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
220 throw( ::com::sun::star::uno::Exception
);
222 void destroy( bool bDeletePhysical
,
223 const ::com::sun::star::uno::Reference
<
224 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
225 throw( ::com::sun::star::uno::Exception
);
227 void transfer( const ::com::sun::star::ucb::TransferInfo
& rInfo
,
228 const ::com::sun::star::uno::Reference
<
229 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
230 throw( ::com::sun::star::uno::Exception
);
232 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
>
235 bool isFolder() const { return m_aProps
.bIsFolder
; }
238 // Create existing content. Fail, if not already exists.
239 static Content
* create(
240 const com::sun::star::uno::Reference
<
241 com::sun::star::uno::XComponentContext
>& rxContext
,
242 ContentProvider
* pProvider
,
243 const com::sun::star::uno::Reference
<
244 com::sun::star::ucb::XContentIdentifier
>& Identifier
);
246 // Create new content. Fail, if already exists.
247 static Content
* create(
248 const com::sun::star::uno::Reference
<
249 com::sun::star::uno::XComponentContext
>& rxContext
,
250 ContentProvider
* pProvider
,
251 const com::sun::star::uno::Reference
<
252 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
253 const com::sun::star::ucb::ContentInfo
& Info
);
258 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
259 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
260 virtual void SAL_CALL
acquire()
261 throw() SAL_OVERRIDE
;
262 virtual void SAL_CALL
release()
263 throw() SAL_OVERRIDE
;
266 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
267 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
268 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
269 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
272 virtual OUString SAL_CALL
273 getImplementationName()
274 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
275 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
276 getSupportedServiceNames()
277 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
280 virtual OUString SAL_CALL
282 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
285 virtual com::sun::star::uno::Any SAL_CALL
286 execute( const com::sun::star::ucb::Command
& aCommand
,
288 const com::sun::star::uno::Reference
<
289 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
290 throw( com::sun::star::uno::Exception
,
291 com::sun::star::ucb::CommandAbortedException
,
292 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
293 virtual void SAL_CALL
294 abort( sal_Int32 CommandId
)
295 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
298 // Additional interfaces
302 virtual com::sun::star::uno::Sequence
<
303 com::sun::star::ucb::ContentInfo
> SAL_CALL
304 queryCreatableContentsInfo()
305 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
306 virtual com::sun::star::uno::Reference
<
307 com::sun::star::ucb::XContent
> SAL_CALL
308 createNewContent( const com::sun::star::ucb::ContentInfo
& Info
)
309 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
312 // Non-interface methods.
315 // Called from resultset data supplier.
316 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
317 getPropertyValues( const ::com::sun::star::uno::Reference
<
318 ::com::sun::star::uno::XComponentContext
>& rxContext
,
319 const ::com::sun::star::uno::Sequence
<
320 ::com::sun::star::beans::Property
>& rProperties
,
321 ContentProvider
* pProvider
,
322 const OUString
& rContentId
);
324 // Called from resultset data supplier.
325 ::com::sun::star::uno::Reference
<
326 ::com::sun::star::container::XEnumeration
>
330 getContentType( const OUString
& aScheme
, bool bFolder
);
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */