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 #ifndef INCLUDED_UCB_SOURCE_UCP_GIO_GIO_CONTENT_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_GIO_GIO_CONTENT_HXX
22 
23 #include <com/sun/star/io/XInputStream.hpp>
24 #include <com/sun/star/io/XOutputStream.hpp>
25 #include <com/sun/star/ucb/ContentCreationException.hpp>
26 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
27 #include <com/sun/star/ucb/TransferInfo.hpp>
28 #include <com/sun/star/ucb/XContentCreator.hpp>
30 #include <gio/gio.h>
31 
32 #include <vector>
33 
34 namespace com { namespace sun { namespace star {
35  namespace beans {
36  struct Property;
37  struct PropertyValue;
38  }
39  namespace sdbc {
40  class XRow;
41  }
42 }}}
43 namespace ucbhelper
44 {
45  class Content;
46 }
47 
48 
49 namespace gio
50 {
51 
52 
53 #define GIO_FILE_TYPE "application/vnd.sun.staroffice.gio-file"
54 #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder"
55 
56 css::uno::Any convertToException(GError *pError,
57  const css::uno::Reference< css::uno::XInterface >& rContext, bool bThrow=true);
60 void convertToIOException(GError *pError,
61  const css::uno::Reference< css::uno::XInterface >& rContext);
62 
63 class ContentProvider;
64 class Content : public ::ucbhelper::ContentImplHelper, public css::ucb::XContentCreator
65 {
66 private:
68  GFile* mpFile;
69  GFileInfo *mpInfo;
71 
72  GFileInfo *getGFileInfo(const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
73  GError **ppError=nullptr);
74  bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv);
75 
76  css::uno::Any mapGIOError( GError *error );
77  css::uno::Any getBadArgExcept();
78 
79  css::uno::Reference< css::sdbc::XRow >
81  const css::uno::Sequence< css::beans::Property >& rProperties,
82  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
83 private:
85  typedef std::vector< ContentRef > ContentRefList;
86 
87  void queryChildren( ContentRefList& rChildren );
88 
89  bool doSetFileInfo ( GFileInfo *pNewInfo );
90 
92  css::uno::Any open(const css::ucb::OpenCommandArgument2 & rArg,
93  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
94 
96  void transfer( const css::ucb::TransferInfo& rTransferInfo,
97  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
98 
100  void insert( const css::uno::Reference< css::io::XInputStream > & xInputStream,
101  bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
102 
104  void destroy( bool bDeletePhysical );
105 
106  static void copyData( const css::uno::Reference< css::io::XInputStream >& xIn,
107  const css::uno::Reference< css::io::XOutputStream >& xOut );
108 
109  css::uno::Sequence< css::uno::Any >
110  setPropertyValues( const css::uno::Sequence<
111  css::beans::PropertyValue >& rValues,
112  const css::uno::Reference<
113  css::ucb::XCommandEnvironment >& xEnv );
114 
115  bool feedSink( const css::uno::Reference< css::uno::XInterface>& aSink );
116 
117  bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId);
118 
119  void getFileInfo(
120  css::uno::Reference<css::ucb::XCommandEnvironment> const & env, GFileInfo ** info,
121  bool fail);
122 
123 public:
125  Content( const css::uno::Reference<
126  css::uno::XComponentContext >& rxContext, ContentProvider *pProvider,
127  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier);
128 
130  Content( const css::uno::Reference<
131  css::uno::XComponentContext >& rxContext, ContentProvider *pProvider,
132  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
133  bool bIsFolder);
134 
135  virtual ~Content() override;
136 
137  virtual css::uno::Sequence< css::beans::Property >
138  getProperties( const css::uno::Reference<
139  css::ucb::XCommandEnvironment > & xEnv ) override;
140 
141  virtual css::uno::Sequence< css::ucb::CommandInfo >
142  getCommands( const css::uno::Reference<
143  css::ucb::XCommandEnvironment > & xEnv ) override;
144 
145  virtual OUString getParentURL() override;
146 
147  // XInterface
148  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
149  virtual void SAL_CALL acquire()
150  throw() override;
151  virtual void SAL_CALL release()
152  throw() override;
153 
154  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
155  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
156 
157  virtual OUString SAL_CALL
158  getImplementationName() override;
159 
160  virtual css::uno::Sequence< OUString > SAL_CALL
161  getSupportedServiceNames() override;
162 
163  virtual OUString SAL_CALL
164  getContentType() override;
165 
166  virtual css::uno::Any SAL_CALL
167  execute( const css::ucb::Command& aCommand,
168  sal_Int32 CommandId,
169  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
170 
171  virtual void SAL_CALL abort( sal_Int32 CommandId ) override;
172 
173  virtual css::uno::Sequence< css::ucb::ContentInfo >
174  SAL_CALL queryCreatableContentsInfo() override;
175  virtual css::uno::Reference< css::ucb::XContent >
176  SAL_CALL createNewContent( const css::ucb::ContentInfo& Info ) override;
177 
179  css::uno::Sequence< css::ucb::ContentInfo >
181  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv);
182 
183  GFile* getGFile();
184 };
185 
186 }
187 
188 #endif
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~Content() override
Definition: gio_content.cxx:97
css::uno::Any getBadArgExcept()
Type
signed char sal_Int8
ContentProvider *const m_pProvider
Definition: gio_content.hxx:67
GFile * mpFile
Definition: gio_content.hxx:68
void destroy(bool bDeletePhysical)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
css::uno::Any mapGIOError(GError *error)
virtual void SAL_CALL release() override
void getFileInfo(css::uno::Reference< css::ucb::XCommandEnvironment > const &env, GFileInfo **info, bool fail)
virtual void SAL_CALL acquire() override
GFile * getGFile()
void convertToIOException(GError *pError, const css::uno::Reference< css::uno::XInterface > &rContext)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getContentType() override
GFileInfo * mpInfo
Definition: gio_content.hxx:69
bool feedSink(const css::uno::Reference< css::uno::XInterface > &aSink)
Content(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
Definition: gio_content.cxx:74
static void copyData(const css::uno::Reference< css::io::XInputStream > &xIn, const css::uno::Reference< css::io::XOutputStream > &xOut)
virtual OUString getParentURL() override
void transfer(const css::ucb::TransferInfo &rTransferInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
std::vector< ContentRef > ContentRefList
Definition: gio_content.hxx:85
rtl::Reference< Content > ContentRef
Definition: gio_content.hxx:84
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
GFileInfo * getGFileInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, GError **ppError=nullptr)
void queryChildren(ContentRefList &rChildren)
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) 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
css::uno::Any convertToException(GError *pError, const css::uno::Reference< css::uno::XInterface > &rContext, bool bThrow)
virtual void SAL_CALL abort(sal_Int32 CommandId) override
bool doSetFileInfo(GFileInfo *pNewInfo)
css::uno::Any open(const css::ucb::OpenCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void insert(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bReplaceExisting, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override