1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef GIO_CONTENT_HXX 25 #define GIO_CONTENT_HXX 26 27 #include <com/sun/star/io/XInputStream.hpp> 28 #include <com/sun/star/io/XOutputStream.hpp> 29 #include <com/sun/star/ucb/ContentCreationException.hpp> 30 #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 31 #include <com/sun/star/ucb/TransferInfo.hpp> 32 #include <com/sun/star/ucb/XContentCreator.hpp> 33 #include <ucbhelper/contenthelper.hxx> 34 #include <gio/gio.h> 35 36 #include <list> 37 38 namespace com { namespace sun { namespace star { 39 namespace beans { 40 struct Property; 41 struct PropertyValue; 42 } 43 namespace sdbc { 44 class XRow; 45 } 46 }}} 47 namespace ucbhelper 48 { 49 class Content; 50 } 51 52 53 namespace gio 54 { 55 56 #define GIO_CONTENT_SERVICE_NAME "com.sun.star.ucb.GIOContent" 57 58 #define GIO_FILE_TYPE "application/vnd.sun.staroffice.gio-file" 59 #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder" 60 61 com::sun::star::uno::Any convertToException(GError *pError, 62 const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true); 63 64 class ContentProvider; 65 class ContentProperties; 66 class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator 67 { 68 private: 69 ContentProvider *m_pProvider; 70 GFile* mpFile; 71 GFileInfo *mpInfo; 72 bool mbTransient; 73 74 GFileInfo *getGFileInfo(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv, 75 GError **ppError=NULL); 76 bool isFolder(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv); 77 78 com::sun::star::uno::Any mapGIOError( GError *error ); 79 com::sun::star::uno::Any getBadArgExcept(); 80 81 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > 82 getPropertyValues( 83 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties, 84 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 85 private: 86 typedef rtl::Reference< Content > ContentRef; 87 typedef std::list< ContentRef > ContentRefList; 88 89 void queryChildren( ContentRefList& rChildren ); 90 91 bool doSetFileInfo ( GFileInfo *pNewInfo ); 92 93 com::sun::star::uno::Any open(const com::sun::star::ucb::OpenCommandArgument2 & rArg, 94 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ); 95 96 void transfer( const com::sun::star::ucb::TransferInfo& rTransferInfo, 97 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ); 98 99 void insert( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInputStream, 100 sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 101 102 void destroy( sal_Bool bDeletePhysical ); 103 104 void copyData( com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xIn, 105 com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOut ); 106 107 com::sun::star::uno::Sequence< com::sun::star::uno::Any > 108 setPropertyValues( const com::sun::star::uno::Sequence< 109 com::sun::star::beans::PropertyValue >& rValues, 110 const com::sun::star::uno::Reference< 111 com::sun::star::ucb::XCommandEnvironment >& xEnv ); 112 113 sal_Bool feedSink( com::sun::star::uno::Reference< com::sun::star::uno::XInterface> aSink, 114 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 115 116 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 117 createInputStream(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 118 119 sal_Bool exchangeIdentity(const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xNewId); 120 121 public: 122 Content( const com::sun::star::uno::Reference< 123 com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, 124 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier); 125 126 Content( const com::sun::star::uno::Reference< 127 com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, 128 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier, 129 sal_Bool bIsFolder); 130 131 virtual ~Content(); 132 133 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo( 134 GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr, 135 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv, 136 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties); 137 138 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > 139 getProperties( const com::sun::star::uno::Reference< 140 com::sun::star::ucb::XCommandEnvironment > & xEnv ); 141 142 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo > 143 getCommands( const com::sun::star::uno::Reference< 144 com::sun::star::ucb::XCommandEnvironment > & xEnv ); 145 146 virtual ::rtl::OUString getParentURL(); 147 148 XINTERFACE_DECL() 149 150 XTYPEPROVIDER_DECL() 151 152 virtual ::rtl::OUString SAL_CALL 153 getImplementationName(); 154 155 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 156 getSupportedServiceNames(); 157 158 virtual rtl::OUString SAL_CALL 159 getContentType(); 160 161 virtual com::sun::star::uno::Any SAL_CALL 162 execute( const com::sun::star::ucb::Command& aCommand, 163 sal_Int32 CommandId, 164 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment ); 165 166 virtual void SAL_CALL abort( sal_Int32 CommandId ); 167 168 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 169 SAL_CALL queryCreatableContentsInfo(); 170 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > 171 SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info ); 172 173 com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 174 queryCreatableContentsInfo( 175 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv); 176 177 GFile* getGFile(); 178 }; 179 180 } 181 182 #endif 183