LibreOffice Module ucb (master) 1
gio_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 * 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>
29#include <gio/gio.h>
30
31#include <vector>
32
33namespace com::sun::star {
34 namespace beans {
35 struct Property;
36 struct PropertyValue;
37 }
38 namespace sdbc {
39 class XRow;
40 }
41}
42namespace ucbhelper
43{
44 class Content;
45}
46
47
48namespace gio
49{
50
51
52inline constexpr OUStringLiteral GIO_FILE_TYPE = u"application/vnd.sun.staroffice.gio-file";
53inline constexpr OUStringLiteral GIO_FOLDER_TYPE = u"application/vnd.sun.staroffice.gio-folder";
54
55css::uno::Any convertToException(GError *pError,
56 const css::uno::Reference< css::uno::XInterface >& rContext, bool bThrow=true);
59void convertToIOException(GError *pError,
60 const css::uno::Reference< css::uno::XInterface >& rContext);
61
62class ContentProvider;
63class Content : public ::ucbhelper::ContentImplHelper, public css::ucb::XContentCreator
64{
65private:
67 GFile* mpFile;
68 GFileInfo *mpInfo;
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 >
80 const css::uno::Sequence< css::beans::Property >& rProperties,
81 const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
82private:
84 typedef std::vector< ContentRef > ContentRefList;
85
86 void queryChildren( ContentRefList& rChildren );
87
88 bool doSetFileInfo ( GFileInfo *pNewInfo );
89
91 css::uno::Any open(const css::ucb::OpenCommandArgument2 & rArg,
92 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
93
95 void transfer( const css::ucb::TransferInfo& rTransferInfo,
96 const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
97
99 void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
100 bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
101
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
122public:
124 Content( const css::uno::Reference<
125 css::uno::XComponentContext >& rxContext, ContentProvider *pProvider,
126 const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier);
127
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
178 css::uno::Sequence< css::ucb::ContentInfo >
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: */
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Any getBadArgExcept()
GFile * mpFile
Definition: gio_content.hxx:67
GFileInfo * mpInfo
Definition: gio_content.hxx:68
void getFileInfo(css::uno::Reference< css::ucb::XCommandEnvironment > const &env, GFileInfo **info, bool fail)
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
void destroy(bool bDeletePhysical)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Any mapGIOError(GError *error)
bool feedSink(const css::uno::Reference< css::uno::XInterface > &aSink)
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
GFile * getGFile()
ContentProvider * m_pProvider
Definition: gio_content.hxx:66
bool doSetFileInfo(GFileInfo *pNewInfo)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, 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)
virtual void SAL_CALL abort(sal_Int32 CommandId) override
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
virtual ~Content() override
Definition: gio_content.cxx:98
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
void transfer(const css::ucb::TransferInfo &rTransferInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void SAL_CALL release() noexcept override
rtl::Reference< Content > ContentRef
Definition: gio_content.hxx:83
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
Definition: gio_content.cxx:75
void queryChildren(ContentRefList &rChildren)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
GFileInfo * getGFileInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, GError **ppError=nullptr)
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
static void copyData(const css::uno::Reference< css::io::XInputStream > &xIn, const css::uno::Reference< css::io::XOutputStream > &xOut)
virtual OUString SAL_CALL getContentType() override
virtual OUString getParentURL() override
std::vector< ContentRef > ContentRefList
Definition: gio_content.hxx:84
float u
Type
constexpr OUStringLiteral GIO_FILE_TYPE
Definition: gio_content.hxx:52
css::uno::Any convertToException(GError *pError, const css::uno::Reference< css::uno::XInterface > &rContext, bool bThrow)
constexpr OUStringLiteral GIO_FOLDER_TYPE
Definition: gio_content.hxx:53
void convertToIOException(GError *pError, const css::uno::Reference< css::uno::XInterface > &rContext)
signed char sal_Int8