LibreOffice Module ucb (master)  1
cmis_content.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 
10 #ifndef INCLUDED_UCB_SOURCE_UCP_CMIS_CMIS_CONTENT_HXX
11 #define INCLUDED_UCB_SOURCE_UCP_CMIS_CMIS_CONTENT_HXX
12 
13 #include "cmis_url.hxx"
14 #include "children_provider.hxx"
15 
16 #include <com/sun/star/io/XInputStream.hpp>
17 #include <com/sun/star/io/XOutputStream.hpp>
18 #include <com/sun/star/ucb/CheckinArgument.hpp>
19 #include <com/sun/star/ucb/CommandFailedException.hpp>
20 #include <com/sun/star/ucb/ContentCreationException.hpp>
21 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
22 #include <com/sun/star/ucb/TransferInfo.hpp>
23 #include <com/sun/star/ucb/XContentCreator.hpp>
24 #include <com/sun/star/document/CmisVersion.hpp>
26 
27 #if defined __GNUC__ && !defined __clang__
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wdeprecated"
30 #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
31 #endif
32 #include <libcmis/libcmis.hxx>
33 #if defined __GNUC__ && !defined __clang__
34 #pragma GCC diagnostic pop
35 #endif
36 
37 #include <list>
38 
39 namespace com { namespace sun { namespace star {
40  namespace beans {
41  struct Property;
42  struct PropertyValue;
43  }
44  namespace sdbc {
45  class XRow;
46  }
47 }}}
48 namespace ucbhelper
49 {
50  class Content;
51 }
52 
53 
54 namespace cmis
55 {
56 
57 #define CMIS_FILE_TYPE "application/vnd.libreoffice.cmis-file"
58 #define CMIS_FOLDER_TYPE "application/vnd.libreoffice.cmis-folder"
59 
60 class ContentProvider;
62  public css::ucb::XContentCreator,
63  public ChildrenProvider
64 {
65 private:
67  libcmis::Session* m_pSession;
68  libcmis::ObjectPtr m_pObject;
69  OUString m_sObjectPath;
70  OUString m_sObjectId;
71  OUString m_sURL;
73 
74  // Members to be set for non-persistent content
76  bool const m_bIsFolder;
77  libcmis::ObjectTypePtr m_pObjectType;
78  std::map< std::string, libcmis::PropertyPtr > m_pObjectProps;
79 
80  bool isFolder( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
81  void setCmisProperty(const std::string& rName, const std::string& rValue,
82  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
83 
84  css::uno::Any getBadArgExcept();
85 
86  css::uno::Reference< css::sdbc::XRow >
88  const css::uno::Sequence< css::beans::Property >& rProperties,
89  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
90 
91  libcmis::Session* getSession( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
92  libcmis::ObjectTypePtr const & getObjectType( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
93 
94 private:
96  typedef std::vector< ContentRef > ContentRefList;
97 
100  css::uno::Any open(const css::ucb::OpenCommandArgument2 & rArg,
101  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
102 
104  void transfer( const css::ucb::TransferInfo& rTransferInfo,
105  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
106 
108  void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
109  bool bReplaceExisting, const OUString & rMimeType,
110  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
111 
113  OUString checkIn( const css::ucb::CheckinArgument& rArg,
114  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
115 
117  OUString checkOut( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
118 
120  OUString cancelCheckOut( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
121 
122  static void copyData( const css::uno::Reference< css::io::XInputStream >& xIn,
123  const css::uno::Reference< css::io::XOutputStream >& xOut );
124 
125  css::uno::Sequence< css::uno::Any >
126  setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues,
127  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
128 
130  css::uno::Sequence< css::document::CmisVersion >
131  getAllVersions( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
132 
133  bool feedSink( const css::uno::Reference< css::uno::XInterface>& aSink,
134  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
135 
136 public:
138  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
139  ContentProvider *pProvider,
140  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
141  libcmis::ObjectPtr const & pObject = libcmis::ObjectPtr( ) );
142 
144  Content( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
145  ContentProvider *pProvider,
146  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
147  bool bIsFolder);
148 
149  virtual ~Content() override;
150 
151  virtual css::uno::Sequence< css::beans::Property >
152  getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
153 
154  libcmis::ObjectPtr updateProperties(
155  const css::uno::Any& iCmisProps,
156  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv);
157 
158  virtual css::uno::Sequence< css::ucb::CommandInfo >
159  getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
160 
161  virtual OUString getParentURL() override;
162 
163  // XInterface
164  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
165  virtual void SAL_CALL acquire()
166  throw() override;
167  virtual void SAL_CALL release()
168  throw() override;
169 
170  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
171  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
172 
173  virtual OUString SAL_CALL
174  getImplementationName() override;
175 
176  virtual css::uno::Sequence< OUString > SAL_CALL
177  getSupportedServiceNames() override;
178 
179  virtual OUString SAL_CALL
180  getContentType() override;
181 
182  virtual css::uno::Any SAL_CALL
183  execute( const css::ucb::Command& aCommand,
184  sal_Int32 CommandId,
185  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
186 
187  virtual void SAL_CALL abort( sal_Int32 CommandId ) override;
188 
189  virtual css::uno::Sequence< css::ucb::ContentInfo >
190  SAL_CALL queryCreatableContentsInfo() override;
191 
192  virtual css::uno::Reference< css::ucb::XContent >
193  SAL_CALL createNewContent( const css::ucb::ContentInfo& Info ) override;
194 
196  css::uno::Sequence< css::ucb::ContentInfo >
197  queryCreatableContentsInfo( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
198 
199  virtual std::vector< css::uno::Reference< css::ucb::XContent > > getChildren( ) override;
200 
204  libcmis::ObjectPtr const & getObject( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
205 };
206 
207 }
208 
209 #endif
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
Type
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
libcmis::ObjectPtr m_pObject
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
OUString m_sURL
bool feedSink(const css::uno::Reference< css::uno::XInterface > &aSink, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
signed char sal_Int8
virtual std::vector< css::uno::Reference< css::ucb::XContent > > getChildren() override
void transfer(const css::ucb::TransferInfo &rTransferInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, libcmis::ObjectPtr const &pObject=libcmis::ObjectPtr())
libcmis::ObjectPtr const & getObject(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
libcmis::ObjectPtr updateProperties(const css::uno::Any &iCmisProps, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual OUString getParentURL() override
libcmis::Session * getSession(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
libcmis::ObjectTypePtr m_pObjectType
css::uno::Any getBadArgExcept()
cmis::URL const m_aURL
void setCmisProperty(const std::string &rName, const std::string &rValue, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString cancelCheckOut(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
OUString m_sObjectId
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< ContentRef > ContentRefList
libcmis::ObjectTypePtr const & getObjectType(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 OUString SAL_CALL getContentType() override
ContentProvider * m_pProvider
css::uno::Sequence< css::document::CmisVersion > getAllVersions(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual ~Content() override
std::map< std::string, libcmis::PropertyPtr > m_pObjectProps
bool const m_bIsFolder
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
libcmis::Session * m_pSession
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL release() override
virtual OUString SAL_CALL getImplementationName() override
OUString checkOut(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const OUString &rMimeType, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString checkIn(const css::ucb::CheckinArgument &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void SAL_CALL abort(sal_Int32 CommandId) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
rtl::Reference< Content > ContentRef
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
static void copyData(const css::uno::Reference< css::io::XInputStream > &xIn, const css::uno::Reference< css::io::XOutputStream > &xOut)
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
virtual void SAL_CALL acquire() override
OUString m_sObjectPath