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/.
10 #ifndef INCLUDED_UCB_SOURCE_UCP_CMIS_CMIS_CONTENT_HXX
11 #define INCLUDED_UCB_SOURCE_UCP_CMIS_CMIS_CONTENT_HXX
13 #include "cmis_url.hxx"
14 #include "children_provider.hxx"
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>
25 #include <ucbhelper/contenthelper.hxx>
26 #include <libcmis/libcmis.hxx>
30 namespace com
{ namespace sun
{ namespace star
{
48 #define CMIS_FILE_TYPE "application/vnd.libreoffice.cmis-file"
49 #define CMIS_FOLDER_TYPE "application/vnd.libreoffice.cmis-folder"
51 class ContentProvider
;
52 class Content
: public ::ucbhelper::ContentImplHelper
,
53 public com::sun::star::ucb::XContentCreator
,
54 public ChildrenProvider
57 ContentProvider
* m_pProvider
;
58 libcmis::Session
* m_pSession
;
59 libcmis::ObjectPtr m_pObject
;
60 OUString m_sObjectPath
;
65 // Members to be set for non-persistent content
68 libcmis::ObjectTypePtr m_pObjectType
;
69 std::map
< std::string
, libcmis::PropertyPtr
> m_pObjectProps
;
71 bool isFolder( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
72 void setCmisProperty(const std::string
& rName
, const std::string
& rValue
,
73 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
75 com::sun::star::uno::Any
getBadArgExcept();
77 com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
>
79 const com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>& rProperties
,
80 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
82 libcmis::Session
* getSession( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
83 libcmis::ObjectTypePtr
getObjectType( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
86 typedef rtl::Reference
< Content
> ContentRef
;
87 typedef std::list
< ContentRef
> ContentRefList
;
89 com::sun::star::uno::Any
open(const com::sun::star::ucb::OpenCommandArgument2
& rArg
,
90 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
91 throw( com::sun::star::uno::Exception
, libcmis::Exception
);
93 void transfer( const com::sun::star::ucb::TransferInfo
& rTransferInfo
,
94 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
95 throw( com::sun::star::uno::Exception
);
97 void insert( const com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> & xInputStream
,
98 bool bReplaceExisting
, const OUString
& rMimeType
,
99 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
100 throw (css::uno::Exception
, std::exception
);
102 OUString
checkIn( const com::sun::star::ucb::CheckinArgument
& rArg
,
103 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
104 throw( com::sun::star::uno::Exception
);
106 OUString
checkOut( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
107 throw( com::sun::star::uno::Exception
);
109 OUString
cancelCheckOut( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
110 throw( com::sun::star::uno::Exception
);
112 void destroy( ) throw( com::sun::star::uno::Exception
);
114 static void copyData( com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> xIn
,
115 com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
> xOut
);
117 com::sun::star::uno::Sequence
< com::sun::star::uno::Any
>
118 setPropertyValues( const com::sun::star::uno::Sequence
<
119 com::sun::star::beans::PropertyValue
>& rValues
,
120 const com::sun::star::uno::Reference
<
121 com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
123 com::sun::star::uno::Sequence
< com::sun::star::document::CmisVersion
>
124 getAllVersions( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> & xEnv
)
125 throw(com::sun::star::uno::Exception
,
128 bool feedSink( com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> aSink
,
129 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
132 Content( const com::sun::star::uno::Reference
<
133 com::sun::star::uno::XComponentContext
>& rxContext
, ContentProvider
*pProvider
,
134 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
>& Identifier
,
135 libcmis::ObjectPtr pObject
= libcmis::ObjectPtr( ) )
136 throw ( com::sun::star::ucb::ContentCreationException
);
138 Content( const com::sun::star::uno::Reference
<
139 com::sun::star::uno::XComponentContext
>& rxContext
, ContentProvider
*pProvider
,
140 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
>& Identifier
,
142 throw ( com::sun::star::ucb::ContentCreationException
);
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
) SAL_OVERRIDE
;
150 libcmis::ObjectPtr
updateProperties(
151 const com::sun::star::uno::Any
& iCmisProps
,
152 const com::sun::star::uno::Reference
<
153 com::sun::star::ucb::XCommandEnvironment
> & xEnv
);
155 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::CommandInfo
>
156 getCommands( const com::sun::star::uno::Reference
<
157 com::sun::star::ucb::XCommandEnvironment
> & xEnv
) SAL_OVERRIDE
;
159 virtual OUString
getParentURL() SAL_OVERRIDE
;
162 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
163 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
164 virtual void SAL_CALL
acquire()
165 throw() SAL_OVERRIDE
;
166 virtual void SAL_CALL
release()
167 throw() SAL_OVERRIDE
;
169 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
170 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
171 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
172 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
174 virtual OUString SAL_CALL
175 getImplementationName()
176 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
178 virtual com::sun::star::uno::Sequence
< OUString
> SAL_CALL
179 getSupportedServiceNames()
180 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
182 virtual OUString SAL_CALL
184 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
186 virtual com::sun::star::uno::Any SAL_CALL
187 execute( const com::sun::star::ucb::Command
& aCommand
,
189 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& Environment
)
190 throw( com::sun::star::uno::Exception
, com::sun::star::ucb::CommandAbortedException
, com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
192 virtual void SAL_CALL
abort( sal_Int32 CommandId
)
193 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
195 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::ContentInfo
>
196 SAL_CALL
queryCreatableContentsInfo()
197 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 virtual com::sun::star::uno::Reference
< com::sun::star::ucb::XContent
>
200 SAL_CALL
createNewContent( const com::sun::star::ucb::ContentInfo
& Info
)
201 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
203 com::sun::star::uno::Sequence
< com::sun::star::ucb::ContentInfo
>
204 queryCreatableContentsInfo( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
)
205 throw( com::sun::star::uno::RuntimeException
);
207 virtual std::list
< com::sun::star::uno::Reference
< com::sun::star::ucb::XContent
> > getChildren( ) SAL_OVERRIDE
;
209 libcmis::ObjectPtr
getObject( const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xEnv
) throw (css::uno::RuntimeException
, css::ucb::CommandFailedException
, libcmis::Exception
);
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */