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/.
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 .
22 #include <com/sun/star/io/XInputStream.hpp>
23 #include <com/sun/star/io/XOutputStream.hpp>
24 #include <com/sun/star/ucb/ContentCreationException.hpp>
25 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
26 #include <com/sun/star/ucb/TransferInfo.hpp>
27 #include <com/sun/star/ucb/XContentCreator.hpp>
28 #include <ucbhelper/contenthelper.hxx>
33 namespace com::sun::star
{
52 #define GIO_FILE_TYPE "application/vnd.sun.staroffice.gio-file"
53 #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder"
55 css::uno::Any
convertToException(GError
*pError
,
56 const css::uno::Reference
< css::uno::XInterface
>& rContext
, bool bThrow
=true);
57 /// @throws css::io::IOException
58 /// @throws css::uno::RuntimeException
59 void convertToIOException(GError
*pError
,
60 const css::uno::Reference
< css::uno::XInterface
>& rContext
);
62 class ContentProvider
;
63 class Content
: public ::ucbhelper::ContentImplHelper
, public css::ucb::XContentCreator
66 ContentProvider
*m_pProvider
;
71 GFileInfo
*getGFileInfo(const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
,
72 GError
**ppError
=nullptr);
73 bool isFolder(const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
75 css::uno::Any
mapGIOError( GError
*error
);
76 css::uno::Any
getBadArgExcept();
78 css::uno::Reference
< css::sdbc::XRow
>
80 const css::uno::Sequence
< css::beans::Property
>& rProperties
,
81 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
83 typedef rtl::Reference
< Content
> ContentRef
;
84 typedef std::vector
< ContentRef
> ContentRefList
;
86 void queryChildren( ContentRefList
& rChildren
);
88 bool doSetFileInfo ( GFileInfo
*pNewInfo
);
90 /// @throws css::uno::Exception
91 css::uno::Any
open(const css::ucb::OpenCommandArgument2
& rArg
,
92 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
94 /// @throws css::uno::Exception
95 void transfer( const css::ucb::TransferInfo
& rTransferInfo
,
96 const css::uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
);
98 /// @throws css::uno::Exception
99 void insert( const css::uno::Reference
< css::io::XInputStream
> & xInputStream
,
100 bool bReplaceExisting
, const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
102 /// @throws css::uno::Exception
103 void destroy( bool bDeletePhysical
);
105 static void copyData( const css::uno::Reference
< css::io::XInputStream
>& xIn
,
106 const css::uno::Reference
< css::io::XOutputStream
>& xOut
);
108 css::uno::Sequence
< css::uno::Any
>
109 setPropertyValues( const css::uno::Sequence
<
110 css::beans::PropertyValue
>& rValues
,
111 const css::uno::Reference
<
112 css::ucb::XCommandEnvironment
>& xEnv
);
114 bool feedSink( const css::uno::Reference
< css::uno::XInterface
>& aSink
);
116 bool exchangeIdentity(const css::uno::Reference
< css::ucb::XContentIdentifier
>& xNewId
);
119 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & env
, GFileInfo
** info
,
123 /// @throws css::ucb::ContentCreationException
124 Content( const css::uno::Reference
<
125 css::uno::XComponentContext
>& rxContext
, ContentProvider
*pProvider
,
126 const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
);
128 /// @throws css::ucb::ContentCreationException
129 Content( const css::uno::Reference
<
130 css::uno::XComponentContext
>& rxContext
, ContentProvider
*pProvider
,
131 const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
,
134 virtual ~Content() override
;
136 virtual css::uno::Sequence
< css::beans::Property
>
137 getProperties( const css::uno::Reference
<
138 css::ucb::XCommandEnvironment
> & xEnv
) override
;
140 virtual css::uno::Sequence
< css::ucb::CommandInfo
>
141 getCommands( const css::uno::Reference
<
142 css::ucb::XCommandEnvironment
> & xEnv
) override
;
144 virtual OUString
getParentURL() override
;
147 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
148 virtual void SAL_CALL
acquire()
150 virtual void SAL_CALL
release()
153 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
154 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
156 virtual OUString SAL_CALL
157 getImplementationName() override
;
159 virtual css::uno::Sequence
< OUString
> SAL_CALL
160 getSupportedServiceNames() override
;
162 virtual OUString SAL_CALL
163 getContentType() override
;
165 virtual css::uno::Any SAL_CALL
166 execute( const css::ucb::Command
& aCommand
,
168 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& Environment
) override
;
170 virtual void SAL_CALL
abort( sal_Int32 CommandId
) override
;
172 virtual css::uno::Sequence
< css::ucb::ContentInfo
>
173 SAL_CALL
queryCreatableContentsInfo() override
;
174 virtual css::uno::Reference
< css::ucb::XContent
>
175 SAL_CALL
createNewContent( const css::ucb::ContentInfo
& Info
) override
;
177 /// @throws css::uno::RuntimeException
178 css::uno::Sequence
< css::ucb::ContentInfo
>
179 queryCreatableContentsInfo(
180 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xEnv
);
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */