Debian Codegraph @

ucb/source/ucp/gio/gio_content.hxx

raw
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 #pragma once
21
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>
29 #include <gio/gio.h>
30
31 #include <vector>
32
33 namespace com::sun::star {
34 namespace beans {
35 struct Property;
36 struct PropertyValue;
37 }
38 namespace sdbc {
39 class XRow;
40 }
41 }
42 namespace ucbhelper
43 {
44 class Content;
45 }
46
47
48 namespace gio
49 {
50
51
52 inline constexpr OUString GIO_FILE_TYPE = u"application/vnd.sun.staroffice.gio-file"_ustr;
53 inline constexpr OUString GIO_FOLDER_TYPE = u"application/vnd.sun.staroffice.gio-folder"_ustr;
54
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);
61
62 class ContentProvider;
63 class Content : public ::ucbhelper::ContentImplHelper, public css::ucb::XContentCreator
64 {
65 private:
66 ContentProvider *m_pProvider;
67 GFile* mpFile;
68 GFileInfo *mpInfo;
69 bool mbTransient;
70
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);
74
75 css::uno::Any mapGIOError( GError *error );
76 css::uno::Any getBadArgExcept();
77
78 css::uno::Reference< css::sdbc::XRow >
79 getPropertyValues(
80 const css::uno::Sequence< css::beans::Property >& rProperties,
81 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
82 private:
83 typedef rtl::Reference< Content > ContentRef;
84 typedef std::vector< ContentRef > ContentRefList;
85
86 void queryChildren( ContentRefList& rChildren );
87
88 bool doSetFileInfo ( GFileInfo *pNewInfo );
89
90 /// @throws css::uno::Exception
91 css::uno::Any open(const css::ucb::OpenCommandArgument2 & rArg,
92 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
93
94 /// @throws css::uno::Exception
95 void transfer( const css::ucb::TransferInfo& rTransferInfo,
96 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
97
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 );
101
102 /// @throws css::uno::Exception
103 void destroy( bool bDeletePhysical );
104
105 static void copyData( const css::uno::Reference< css::io::XInputStream >& xIn,
106 const css::uno::Reference< css::io::XOutputStream >& xOut );
107
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 );
113
114 bool feedSink( const css::uno::Reference< css::uno::XInterface>& aSink );
115
116 bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId);
117
118 void getFileInfo(
119 css::uno::Reference<css::ucb::XCommandEnvironment> const & env, GFileInfo ** info,
120 bool fail);
121
122 public:
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);
127
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,
132 bool bIsFolder);
133
134 virtual ~Content() override;
135
136 virtual css::uno::Sequence< css::beans::Property >
137 getProperties( const css::uno::Reference<
138 css::ucb::XCommandEnvironment > & xEnv ) override;
139
140 virtual css::uno::Sequence< css::ucb::CommandInfo >
141 getCommands( const css::uno::Reference<
142 css::ucb::XCommandEnvironment > & xEnv ) override;
143
144 virtual OUString getParentURL() override;
145
146 // XInterface
147 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
148 virtual void SAL_CALL acquire()
149 noexcept override;
150 virtual void SAL_CALL release()
151 noexcept override;
152
153 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
154 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
155
156 virtual OUString SAL_CALL
157 getImplementationName() override;
158
159 virtual css::uno::Sequence< OUString > SAL_CALL
160 getSupportedServiceNames() override;
161
162 virtual OUString SAL_CALL
163 getContentType() override;
164
165 virtual css::uno::Any SAL_CALL
166 execute( const css::ucb::Command& aCommand,
167 sal_Int32 CommandId,
168 const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
169
170 virtual void SAL_CALL abort( sal_Int32 CommandId ) override;
171
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;
176
177 /// @throws css::uno::RuntimeException
178 css::uno::Sequence< css::ucb::ContentInfo >
179 queryCreatableContentsInfo(
180 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv);
181
182 GFile* getGFile();
183 };
184
185 }
186
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */