bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / package / pkgcontent.hxx
blob38b26b2becc686728426e1c7b0f3b56435a8ab2b
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 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
25 #include <vector>
26 #include <rtl/ref.hxx>
28 #include <com/sun/star/ucb/XContentCreator.hpp>
29 #include <ucbhelper/contenthelper.hxx>
30 #include "pkguri.hxx"
32 namespace com::sun::star {
33 namespace beans
35 struct Property;
36 struct PropertyValue;
38 namespace container
40 class XHierarchicalNameAccess;
41 class XEnumeration;
43 namespace io
45 class XInputStream;
47 namespace sdbc
49 class XRow;
51 namespace ucb
53 struct OpenCommandArgument2;
54 struct TransferInfo;
58 namespace package_ucp
62 struct ContentProperties
64 OUString aTitle; // Title
65 OUString aContentType; // ContentType
66 bool bIsDocument; // IsDocument
67 bool bIsFolder; // IsFolder
68 OUString aMediaType; // MediaType
69 css::uno::Sequence < sal_Int8 > aEncryptionKey; // EncryptionKey
70 sal_Int64 nSize; // Size
71 bool bCompressed; // Compressed
72 bool bEncrypted; // Encrypted
73 bool bHasEncryptedEntries; // HasEncryptedEntries
75 ContentProperties()
76 : bIsDocument( true ), bIsFolder( false ), nSize( 0 ),
77 bCompressed( true ), bEncrypted( false ),
78 bHasEncryptedEntries( false ) {}
80 explicit ContentProperties( const OUString& rContentType );
82 css::uno::Sequence< css::ucb::ContentInfo >
83 getCreatableContentsInfo( PackageUri const & rUri ) const;
87 class ContentProvider;
89 class Content : public ::ucbhelper::ContentImplHelper,
90 public css::ucb::XContentCreator
92 enum ContentState { TRANSIENT, // created via CreateNewContent,
93 // but did not process "insert" yet
94 PERSISTENT, // processed "insert"
95 DEAD // processed "delete"
98 PackageUri m_aUri;
99 ContentProperties m_aProps;
100 ContentState m_eState;
101 css::uno::Reference<
102 css::container::XHierarchicalNameAccess > m_xPackage;
103 ContentProvider* m_pProvider;
104 sal_uInt32 m_nModifiedProps;
106 private:
107 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
108 ContentProvider* pProvider,
109 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
110 const css::uno::Reference< css::container::XHierarchicalNameAccess >& Package,
111 const PackageUri& rUri,
112 const ContentProperties& rProps );
113 Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
114 ContentProvider* pProvider,
115 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
116 const css::uno::Reference< css::container::XHierarchicalNameAccess >& Package,
117 const PackageUri& rUri,
118 const css::ucb::ContentInfo& Info );
120 virtual css::uno::Sequence< css::beans::Property >
121 getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
122 virtual css::uno::Sequence< css::ucb::CommandInfo >
123 getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
124 virtual OUString getParentURL() override;
126 static css::uno::Reference< css::sdbc::XRow >
127 getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
128 const css::uno::Sequence< css::beans::Property >& rProperties,
129 const ContentProperties& rData,
130 const rtl::Reference< ::ucbhelper::ContentProviderImplHelper >& rProvider,
131 const OUString& rContentId );
133 css::uno::Reference< css::sdbc::XRow >
134 getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
135 /// @throws css::uno::Exception
136 css::uno::Sequence< css::uno::Any >
137 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
138 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
140 css::uno::Reference< css::container::XHierarchicalNameAccess >
141 getPackage( const PackageUri& rURI );
142 css::uno::Reference< css::container::XHierarchicalNameAccess >
143 getPackage();
145 static bool
146 loadData( ContentProvider* pProvider,
147 const PackageUri& rURI,
148 ContentProperties& rProps,
149 css::uno::Reference< css::container::XHierarchicalNameAccess > & rxPackage );
150 static bool
151 hasData( ContentProvider* pProvider,
152 const PackageUri& rURI,
153 css::uno::Reference< css::container::XHierarchicalNameAccess > & rxPackage );
155 bool
156 hasData( const PackageUri& rURI );
157 void
158 renameData( const css::uno::Reference< css::ucb::XContentIdentifier >& xOldId,
159 const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
160 bool
161 storeData( const css::uno::Reference< css::io::XInputStream >& xStream );
162 bool
163 removeData();
165 bool
166 flushData();
168 typedef rtl::Reference< Content > ContentRef;
169 typedef std::vector< ContentRef > ContentRefList;
170 void queryChildren( ContentRefList& rChildren );
172 bool
173 exchangeIdentity( const css::uno::Reference<
174 css::ucb::XContentIdentifier >& xNewId );
176 /// @throws css::uno::Exception
177 css::uno::Any
178 open( const css::ucb::OpenCommandArgument2& rArg,
179 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
181 /// @throws css::uno::Exception
182 void insert( const css::uno::Reference< css::io::XInputStream >& xStream,
183 sal_Int32 nNameClashResolve,
184 const css::uno::Reference<
185 css::ucb::XCommandEnvironment > & xEnv );
187 /// @throws css::uno::Exception
188 void destroy( bool bDeletePhysical,
189 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
191 /// @throws css::uno::Exception
192 void transfer( const css::ucb::TransferInfo& rInfo,
193 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
195 css::uno::Reference< css::io::XInputStream >
196 getInputStream();
198 bool isFolder() const { return m_aProps.bIsFolder; }
200 public:
201 // Create existing content. Fail, if not already exists.
202 static rtl::Reference<Content> create(
203 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
204 ContentProvider* pProvider,
205 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier );
207 // Create new content. Fail, if already exists.
208 static rtl::Reference<Content> create(
209 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
210 ContentProvider* pProvider,
211 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
212 const css::ucb::ContentInfo& Info );
214 virtual ~Content() override;
216 // XInterface
217 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
218 virtual void SAL_CALL acquire()
219 noexcept override;
220 virtual void SAL_CALL release()
221 noexcept override;
223 // XTypeProvider
224 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
225 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
227 // XServiceInfo
228 virtual OUString SAL_CALL
229 getImplementationName() override;
230 virtual css::uno::Sequence< OUString > SAL_CALL
231 getSupportedServiceNames() override;
233 // XContent
234 virtual OUString SAL_CALL
235 getContentType() override;
237 // XCommandProcessor
238 virtual css::uno::Any SAL_CALL
239 execute( const css::ucb::Command& aCommand,
240 sal_Int32 CommandId,
241 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
242 virtual void SAL_CALL
243 abort( sal_Int32 CommandId ) override;
246 // Additional interfaces
249 // XContentCreator
250 virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
251 queryCreatableContentsInfo() override;
252 virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
253 createNewContent( const css::ucb::ContentInfo& Info ) override;
256 // Non-interface methods.
259 // Called from resultset data supplier.
260 static css::uno::Reference< css::sdbc::XRow >
261 getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
262 const css::uno::Sequence< css::beans::Property >& rProperties,
263 ContentProvider* pProvider,
264 const OUString& rContentId );
266 // Called from resultset data supplier.
267 css::uno::Reference< css::container::XEnumeration >
268 getIterator();
270 static OUString
271 getContentType( std::u16string_view aScheme, bool bFolder );
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */