LibreOffice Module ucb (master)  1
pkgcontent.hxx
Go to the documentation of this file.
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  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_UCB_SOURCE_UCP_PACKAGE_PKGCONTENT_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_PACKAGE_PKGCONTENT_HXX
22 
23 #include <vector>
24 #include <rtl/ref.hxx>
25 
26 #include <com/sun/star/ucb/XContentCreator.hpp>
28 #include "pkguri.hxx"
29 
30 namespace com { namespace sun { namespace star {
31  namespace beans
32  {
33  struct Property;
34  struct PropertyValue;
35  }
36  namespace container
37  {
38  class XHierarchicalNameAccess;
39  class XEnumeration;
40  }
41  namespace io
42  {
43  class XInputStream;
44  }
45  namespace sdbc
46  {
47  class XRow;
48  }
49  namespace ucb
50  {
51  struct OpenCommandArgument2;
52  struct TransferInfo;
53  }
54 } } }
55 
56 namespace package_ucp
57 {
58 
59 
61 {
62  OUString aTitle; // Title
63  OUString aContentType; // ContentType
64  bool bIsDocument; // IsDocument
65  bool bIsFolder; // IsFolder
66  OUString aMediaType; // MediaType
67  css::uno::Sequence < sal_Int8 > aEncryptionKey; // EncryptionKey
68  sal_Int64 nSize; // Size
69  bool bCompressed; // Compressed
70  bool bEncrypted; // Encrypted
71  bool bHasEncryptedEntries; // HasEncryptedEntries
72 
74  : bIsDocument( true ), bIsFolder( false ), nSize( 0 ),
75  bCompressed( true ), bEncrypted( false ),
76  bHasEncryptedEntries( false ) {}
77 
78  explicit ContentProperties( const OUString& rContentType );
79 
80  css::uno::Sequence< css::ucb::ContentInfo >
81  getCreatableContentsInfo( PackageUri const & rUri ) const;
82 };
83 
84 
85 class ContentProvider;
86 
88  public css::ucb::XContentCreator
89 {
90  enum ContentState { TRANSIENT, // created via CreateNewContent,
91  // but did not process "insert" yet
92  PERSISTENT, // processed "insert"
93  DEAD // processed "delete"
94  };
95 
99  css::uno::Reference<
100  css::container::XHierarchicalNameAccess > m_xPackage;
102  sal_uInt32 m_nModifiedProps;
103 
104 private:
105  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
106  ContentProvider* pProvider,
107  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
108  const css::uno::Reference< css::container::XHierarchicalNameAccess >& Package,
109  const PackageUri& rUri,
110  const ContentProperties& rProps );
111  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
112  ContentProvider* pProvider,
113  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
114  const css::uno::Reference< css::container::XHierarchicalNameAccess >& Package,
115  const PackageUri& rUri,
116  const css::ucb::ContentInfo& Info );
117 
118  virtual css::uno::Sequence< css::beans::Property >
119  getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
120  virtual css::uno::Sequence< css::ucb::CommandInfo >
121  getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
122  virtual OUString getParentURL() override;
123 
124  static css::uno::Reference< css::sdbc::XRow >
125  getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
126  const css::uno::Sequence< css::beans::Property >& rProperties,
127  const ContentProperties& rData,
129  const OUString& rContentId );
130 
131  css::uno::Reference< css::sdbc::XRow >
132  getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
134  css::uno::Sequence< css::uno::Any >
135  setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
136  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
137 
138  css::uno::Reference< css::container::XHierarchicalNameAccess >
139  getPackage( const PackageUri& rURI );
140  css::uno::Reference< css::container::XHierarchicalNameAccess >
141  getPackage();
142 
143  static bool
144  loadData( ContentProvider* pProvider,
145  const PackageUri& rURI,
146  ContentProperties& rProps,
147  css::uno::Reference< css::container::XHierarchicalNameAccess > & rxPackage );
148  static bool
149  hasData( ContentProvider* pProvider,
150  const PackageUri& rURI,
151  css::uno::Reference< css::container::XHierarchicalNameAccess > & rxPackage );
152 
153  bool
154  hasData( const PackageUri& rURI );
155  void
156  renameData( const css::uno::Reference< css::ucb::XContentIdentifier >& xOldId,
157  const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
158  bool
159  storeData( const css::uno::Reference< css::io::XInputStream >& xStream );
160  bool
161  removeData();
162 
163  bool
164  flushData();
165 
167  typedef std::vector< ContentRef > ContentRefList;
168  void queryChildren( ContentRefList& rChildren );
169 
170  bool
171  exchangeIdentity( const css::uno::Reference<
172  css::ucb::XContentIdentifier >& xNewId );
173 
175  css::uno::Any
176  open( const css::ucb::OpenCommandArgument2& rArg,
177  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
178 
180  void insert( const css::uno::Reference< css::io::XInputStream >& xStream,
181  sal_Int32 nNameClashResolve,
182  const css::uno::Reference<
183  css::ucb::XCommandEnvironment > & xEnv );
184 
186  void destroy( bool bDeletePhysical,
187  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
188 
190  void transfer( const css::ucb::TransferInfo& rInfo,
191  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
192 
193  css::uno::Reference< css::io::XInputStream >
194  getInputStream();
195 
196  bool isFolder() const { return m_aProps.bIsFolder; }
197 
198 public:
199  // Create existing content. Fail, if not already exists.
200  static Content* create(
201  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
202  ContentProvider* pProvider,
203  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier );
204 
205  // Create new content. Fail, if already exists.
206  static Content* create(
207  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
208  ContentProvider* pProvider,
209  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
210  const css::ucb::ContentInfo& Info );
211 
212  virtual ~Content() override;
213 
214  // XInterface
215  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
216  virtual void SAL_CALL acquire()
217  throw() override;
218  virtual void SAL_CALL release()
219  throw() override;
220 
221  // XTypeProvider
222  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
223  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
224 
225  // XServiceInfo
226  virtual OUString SAL_CALL
227  getImplementationName() override;
228  virtual css::uno::Sequence< OUString > SAL_CALL
229  getSupportedServiceNames() override;
230 
231  // XContent
232  virtual OUString SAL_CALL
233  getContentType() override;
234 
235  // XCommandProcessor
236  virtual css::uno::Any SAL_CALL
237  execute( const css::ucb::Command& aCommand,
238  sal_Int32 CommandId,
239  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
240  virtual void SAL_CALL
241  abort( sal_Int32 CommandId ) override;
242 
243 
244  // Additional interfaces
245 
246 
247  // XContentCreator
248  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
249  queryCreatableContentsInfo() override;
250  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
251  createNewContent( const css::ucb::ContentInfo& Info ) override;
252 
253 
254  // Non-interface methods.
255 
256 
257  // Called from resultset data supplier.
258  static css::uno::Reference< css::sdbc::XRow >
259  getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
260  const css::uno::Sequence< css::beans::Property >& rProperties,
261  ContentProvider* pProvider,
262  const OUString& rContentId );
263 
264  // Called from resultset data supplier.
265  css::uno::Reference< css::container::XEnumeration >
266  getIterator();
267 
268  static OUString
269  getContentType( const OUString& aScheme, bool bFolder );
270 };
271 
272 }
273 
274 #endif
275 
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
css::uno::Sequence< sal_Int8 > aEncryptionKey
Definition: pkgcontent.hxx:67
rtl::Reference< Content > ContentRef
Definition: pkgcontent.hxx:166
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
signed char sal_Int8
static css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Sequence< css::beans::Property > &rProperties, const ContentProperties &rData, const rtl::Reference< ::ucbhelper::ContentProviderImplHelper > &rProvider, const OUString &rContentId)
virtual OUString SAL_CALL getContentType() override
Definition: pkgcontent.cxx:373
virtual ~Content() override
Definition: pkgcontent.cxx:269
std::vector< ContentRef > ContentRefList
Definition: pkgcontent.hxx:167
void transfer(const css::ucb::TransferInfo &rInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: pkgcontent.cxx:313
virtual OUString SAL_CALL getImplementationName() override
Definition: pkgcontent.cxx:356
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
Definition: pkgcontent.cxx:627
ContentState m_eState
Definition: pkgcontent.hxx:98
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
void destroy(bool bDeletePhysical, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: pkgcontent.cxx:363
void renameData(const css::uno::Reference< css::ucb::XContentIdentifier > &xOldId, const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
virtual void SAL_CALL abort(sal_Int32 CommandId) override
Definition: pkgcontent.cxx:615
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
static bool hasData(ContentProvider *pProvider, const PackageUri &rURI, css::uno::Reference< css::container::XHierarchicalNameAccess > &rxPackage)
ContentProvider * m_pProvider
Definition: pkgcontent.hxx:101
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
sal_uInt32 m_nModifiedProps
Definition: pkgcontent.hxx:102
void queryChildren(ContentRefList &rChildren)
static bool loadData(ContentProvider *pProvider, const PackageUri &rURI, ContentProperties &rProps, css::uno::Reference< css::container::XHierarchicalNameAccess > &rxPackage)
css::uno::Reference< css::container::XHierarchicalNameAccess > getPackage()
static Content * create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void insert(const css::uno::Reference< css::io::XInputStream > &xStream, sal_Int32 nNameClashResolve, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Sequence< css::ucb::ContentInfo > getCreatableContentsInfo(PackageUri const &rUri) const
Definition: pkgcontent.cxx:102
css::uno::Reference< css::container::XHierarchicalNameAccess > m_xPackage
Definition: pkgcontent.hxx:100
bool storeData(const css::uno::Reference< css::io::XInputStream > &xStream)
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
virtual void SAL_CALL acquire() override
Definition: pkgcontent.cxx:278
css::uno::Reference< css::io::XInputStream > getInputStream()
ContentProperties m_aProps
Definition: pkgcontent.hxx:97
virtual void SAL_CALL release() override
Definition: pkgcontent.cxx:286
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, const css::uno::Reference< css::container::XHierarchicalNameAccess > &Package, const PackageUri &rUri, const ContentProperties &rProps)
virtual OUString getParentURL() override
Definition: pkgcontent.cxx:675
bool isFolder() const
Definition: pkgcontent.hxx:196
css::uno::Reference< css::container::XEnumeration > getIterator()