1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pkgcontent.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _PKGCONTENT_HXX
32 #define _PKGCONTENT_HXX
35 #include <rtl/ref.hxx>
37 #ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_
38 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
40 #include <com/sun/star/ucb/XContentCreator.hpp>
41 #include <ucbhelper/contenthelper.hxx>
44 namespace com
{ namespace sun
{ namespace star
{
52 class XHierarchicalNameAccess
;
65 struct OpenCommandArgument2
;
73 //=========================================================================
75 // UNO service name for the content.
76 #define PACKAGE_FOLDER_CONTENT_SERVICE_NAME \
77 "com.sun.star.ucb.PackageFolderContent"
78 #define PACKAGE_STREAM_CONTENT_SERVICE_NAME \
79 "com.sun.star.ucb.PackageStreamContent"
81 //=========================================================================
83 struct ContentProperties
85 ::rtl::OUString aTitle
; // Title
86 ::rtl::OUString aContentType
; // ContentType
87 sal_Bool bIsDocument
; // IsDocument
88 sal_Bool bIsFolder
; // IsFolder
89 ::rtl::OUString aMediaType
; // MediaType
90 com::sun::star::uno::Sequence
<
91 sal_Int8
> aEncryptionKey
; // EncryptionKey
92 sal_Int64 nSize
; // Size
93 sal_Bool bCompressed
; // Compressed
94 sal_Bool bEncrypted
; // Encrypted
95 sal_Bool bHasEncryptedEntries
; // HasEncryptedEntries
98 : bIsDocument( sal_True
), bIsFolder( sal_False
), nSize( 0 ),
99 bCompressed( sal_True
), bEncrypted( sal_False
),
100 bHasEncryptedEntries( sal_False
) {}
102 ContentProperties( const ::rtl::OUString
& rContentType
);
105 //=========================================================================
107 class ContentProvider
;
109 class Content
: public ::ucbhelper::ContentImplHelper
,
110 public com::sun::star::ucb::XContentCreator
112 enum ContentState
{ TRANSIENT
, // created via CreateNewContent,
113 // but did not process "insert" yet
114 PERSISTENT
, // processed "insert"
115 DEAD
// processed "delete"
119 ContentProperties m_aProps
;
120 ContentState m_eState
;
121 com::sun::star::uno::Reference
<
122 com::sun::star::container::XHierarchicalNameAccess
> m_xPackage
;
123 ContentProvider
* m_pProvider
;
124 sal_uInt32 m_nModifiedProps
;
127 Content( const com::sun::star::uno::Reference
<
128 com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
129 ContentProvider
* pProvider
,
130 const com::sun::star::uno::Reference
<
131 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
132 const ::com::sun::star::uno::Reference
<
133 com::sun::star::container::XHierarchicalNameAccess
>& Package
,
134 const PackageUri
& rUri
,
135 const ContentProperties
& rProps
);
136 Content( const com::sun::star::uno::Reference
<
137 com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
138 ContentProvider
* pProvider
,
139 const com::sun::star::uno::Reference
<
140 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
141 const com::sun::star::uno::Reference
<
142 com::sun::star::container::XHierarchicalNameAccess
>& Package
,
143 const PackageUri
& rUri
,
144 const com::sun::star::ucb::ContentInfo
& Info
);
146 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>
147 getProperties( const com::sun::star::uno::Reference
<
148 com::sun::star::ucb::XCommandEnvironment
> & xEnv
);
149 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::CommandInfo
>
150 getCommands( const com::sun::star::uno::Reference
<
151 com::sun::star::ucb::XCommandEnvironment
> & xEnv
);
152 virtual ::rtl::OUString
getParentURL();
154 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
155 getPropertyValues( const ::com::sun::star::uno::Reference
<
156 ::com::sun::star::lang::XMultiServiceFactory
>& rSMgr
,
157 const ::com::sun::star::uno::Sequence
<
158 ::com::sun::star::beans::Property
>& rProperties
,
159 const ContentProperties
& rData
,
160 const rtl::Reference
<
161 ::ucbhelper::ContentProviderImplHelper
>& rProvider
,
162 const ::rtl::OUString
& rContentId
);
164 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
165 getPropertyValues( const ::com::sun::star::uno::Sequence
<
166 ::com::sun::star::beans::Property
>& rProperties
);
167 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
168 setPropertyValues( const ::com::sun::star::uno::Sequence
<
169 ::com::sun::star::beans::PropertyValue
>& rValues
,
170 const ::com::sun::star::uno::Reference
<
171 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
172 throw( ::com::sun::star::uno::Exception
);
174 com::sun::star::uno::Reference
<
175 com::sun::star::container::XHierarchicalNameAccess
>
176 getPackage( const PackageUri
& rURI
);
177 com::sun::star::uno::Reference
<
178 com::sun::star::container::XHierarchicalNameAccess
>
182 loadData( ContentProvider
* pProvider
,
183 const PackageUri
& rURI
,
184 ContentProperties
& rProps
,
185 com::sun::star::uno::Reference
<
186 com::sun::star::container::XHierarchicalNameAccess
> &
189 hasData( ContentProvider
* pProvider
,
190 const PackageUri
& rURI
,
191 com::sun::star::uno::Reference
<
192 com::sun::star::container::XHierarchicalNameAccess
> &
195 static ::rtl::OUString
196 GetContentType( const ::rtl::OUString
& aScheme
,
200 hasData( const PackageUri
& rURI
);
202 renameData( const com::sun::star::uno::Reference
<
203 com::sun::star::ucb::XContentIdentifier
>& xOldId
,
204 const com::sun::star::uno::Reference
<
205 com::sun::star::ucb::XContentIdentifier
>& xNewId
);
207 storeData( const com::sun::star::uno::Reference
<
208 com::sun::star::io::XInputStream
>& xStream
);
215 typedef rtl::Reference
< Content
> ContentRef
;
216 typedef std::list
< ContentRef
> ContentRefList
;
217 void queryChildren( ContentRefList
& rChildren
);
220 exchangeIdentity( const ::com::sun::star::uno::Reference
<
221 ::com::sun::star::ucb::XContentIdentifier
>& xNewId
);
223 ::com::sun::star::uno::Any
224 open( const ::com::sun::star::ucb::OpenCommandArgument2
& rArg
,
225 const ::com::sun::star::uno::Reference
<
226 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
227 throw( ::com::sun::star::uno::Exception
);
229 void insert( const ::com::sun::star::uno::Reference
<
230 ::com::sun::star::io::XInputStream
>& xStream
,
231 sal_Int32 nNameClashResolve
,
232 const ::com::sun::star::uno::Reference
<
233 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
234 throw( ::com::sun::star::uno::Exception
);
236 void destroy( sal_Bool bDeletePhysical
,
237 const ::com::sun::star::uno::Reference
<
238 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
239 throw( ::com::sun::star::uno::Exception
);
241 void transfer( const ::com::sun::star::ucb::TransferInfo
& rInfo
,
242 const ::com::sun::star::uno::Reference
<
243 ::com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
244 throw( ::com::sun::star::uno::Exception
);
246 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
>
249 sal_Bool
isFolder() const { return m_aProps
.bIsFolder
; }
252 // Create existing content. Fail, if not already exists.
253 static Content
* create(
254 const com::sun::star::uno::Reference
<
255 com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
256 ContentProvider
* pProvider
,
257 const com::sun::star::uno::Reference
<
258 com::sun::star::ucb::XContentIdentifier
>& Identifier
);
260 // Create new content. Fail, if already exists.
261 static Content
* create(
262 const com::sun::star::uno::Reference
<
263 com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
264 ContentProvider
* pProvider
,
265 const com::sun::star::uno::Reference
<
266 com::sun::star::ucb::XContentIdentifier
>& Identifier
,
267 const com::sun::star::ucb::ContentInfo
& Info
);
278 virtual ::rtl::OUString SAL_CALL
279 getImplementationName()
280 throw( ::com::sun::star::uno::RuntimeException
);
281 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
282 getSupportedServiceNames()
283 throw( ::com::sun::star::uno::RuntimeException
);
286 virtual rtl::OUString SAL_CALL
288 throw( com::sun::star::uno::RuntimeException
);
291 virtual com::sun::star::uno::Any SAL_CALL
292 execute( const com::sun::star::ucb::Command
& aCommand
,
294 const com::sun::star::uno::Reference
<
295 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
296 throw( com::sun::star::uno::Exception
,
297 com::sun::star::ucb::CommandAbortedException
,
298 com::sun::star::uno::RuntimeException
);
299 virtual void SAL_CALL
300 abort( sal_Int32 CommandId
)
301 throw( com::sun::star::uno::RuntimeException
);
303 //////////////////////////////////////////////////////////////////////
304 // Additional interfaces
305 //////////////////////////////////////////////////////////////////////
308 virtual com::sun::star::uno::Sequence
<
309 com::sun::star::ucb::ContentInfo
> SAL_CALL
310 queryCreatableContentsInfo()
311 throw( com::sun::star::uno::RuntimeException
);
312 virtual com::sun::star::uno::Reference
<
313 com::sun::star::ucb::XContent
> SAL_CALL
314 createNewContent( const com::sun::star::ucb::ContentInfo
& Info
)
315 throw( com::sun::star::uno::RuntimeException
);
317 //////////////////////////////////////////////////////////////////////
318 // Non-interface methods.
319 //////////////////////////////////////////////////////////////////////
321 // Called from resultset data supplier.
322 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
323 getPropertyValues( const ::com::sun::star::uno::Reference
<
324 ::com::sun::star::lang::XMultiServiceFactory
>& rSMgr
,
325 const ::com::sun::star::uno::Sequence
<
326 ::com::sun::star::beans::Property
>& rProperties
,
327 ContentProvider
* pProvider
,
328 const ::rtl::OUString
& rContentId
);
330 // Called from resultset data supplier.
331 ::com::sun::star::uno::Reference
<
332 ::com::sun::star::container::XEnumeration
>