1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef GIO_CONTENT_HXX 29 #define GIO_CONTENT_HXX 30 31 #include <com/sun/star/io/XInputStream.hpp> 32 #include <com/sun/star/io/XOutputStream.hpp> 33 #include <com/sun/star/ucb/ContentCreationException.hpp> 34 #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 35 #include <com/sun/star/ucb/TransferInfo.hpp> 36 #include <com/sun/star/ucb/XContentCreator.hpp> 37 #include <ucbhelper/contenthelper.hxx> 38 #include <gio/gio.h> 39 40 #include <list> 41 42 namespace com { namespace sun { namespace star { 43 namespace beans { 44 struct Property; 45 struct PropertyValue; 46 } 47 namespace sdbc { 48 class XRow; 49 } 50 }}} 51 namespace ucbhelper 52 { 53 class Content; 54 } 55 56 57 namespace gio 58 { 59 60 #define GIO_CONTENT_SERVICE_NAME "com.sun.star.ucb.GIOContent" 61 62 #define GIO_FILE_TYPE "application/vnd.sun.staroffice.gio-file" 63 #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder" 64 65 com::sun::star::uno::Any convertToException(GError *pError, 66 const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true); 67 68 class ContentProvider; 69 class ContentProperties; 70 class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator 71 { 72 private: 73 ContentProvider *m_pProvider; 74 GFile* mpFile; 75 GFileInfo *mpInfo; 76 bool mbTransient; 77 78 GFileInfo *getGFileInfo(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv, 79 GError **ppError=NULL); 80 bool isFolder(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv); 81 82 com::sun::star::uno::Any mapGIOError( GError *error ); 83 com::sun::star::uno::Any getBadArgExcept(); 84 85 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > 86 getPropertyValues( 87 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties, 88 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 89 private: 90 typedef rtl::Reference< Content > ContentRef; 91 typedef std::list< ContentRef > ContentRefList; 92 93 void queryChildren( ContentRefList& rChildren ); 94 95 bool doSetFileInfo ( GFileInfo *pNewInfo ); 96 97 com::sun::star::uno::Any open(const com::sun::star::ucb::OpenCommandArgument2 & rArg, 98 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ) 99 throw( com::sun::star::uno::Exception ); 100 101 void transfer( const com::sun::star::ucb::TransferInfo& rTransferInfo, 102 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ) 103 throw( com::sun::star::uno::Exception ); 104 105 void insert( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInputStream, 106 sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) 107 throw( com::sun::star::uno::Exception ); 108 109 void destroy( sal_Bool bDeletePhysical ) throw( com::sun::star::uno::Exception ); 110 111 void copyData( com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xIn, 112 com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOut ); 113 114 com::sun::star::uno::Sequence< com::sun::star::uno::Any > 115 setPropertyValues( const com::sun::star::uno::Sequence< 116 com::sun::star::beans::PropertyValue >& rValues, 117 const com::sun::star::uno::Reference< 118 com::sun::star::ucb::XCommandEnvironment >& xEnv ); 119 120 sal_Bool feedSink( com::sun::star::uno::Reference< com::sun::star::uno::XInterface> aSink, 121 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); 122 123 com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 124 createInputStream(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) 125 throw( com::sun::star::uno::Exception ); 126 127 sal_Bool exchangeIdentity(const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xNewId); 128 129 public: 130 Content( const com::sun::star::uno::Reference< 131 com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, 132 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier) 133 throw ( com::sun::star::ucb::ContentCreationException ); 134 135 Content( const com::sun::star::uno::Reference< 136 com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, 137 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier, 138 sal_Bool bIsFolder) 139 throw ( com::sun::star::ucb::ContentCreationException ); 140 141 virtual ~Content(); 142 143 com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo( 144 GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr, 145 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv, 146 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties); 147 148 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > 149 getProperties( const com::sun::star::uno::Reference< 150 com::sun::star::ucb::XCommandEnvironment > & xEnv ); 151 152 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo > 153 getCommands( const com::sun::star::uno::Reference< 154 com::sun::star::ucb::XCommandEnvironment > & xEnv ); 155 156 virtual ::rtl::OUString getParentURL(); 157 158 XINTERFACE_DECL() 159 160 XTYPEPROVIDER_DECL() 161 162 virtual ::rtl::OUString SAL_CALL 163 getImplementationName() 164 throw( com::sun::star::uno::RuntimeException ); 165 166 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 167 getSupportedServiceNames() 168 throw( com::sun::star::uno::RuntimeException ); 169 170 virtual rtl::OUString SAL_CALL 171 getContentType() 172 throw( com::sun::star::uno::RuntimeException ); 173 174 virtual com::sun::star::uno::Any SAL_CALL 175 execute( const com::sun::star::ucb::Command& aCommand, 176 sal_Int32 CommandId, 177 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment ) 178 throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException ); 179 180 virtual void SAL_CALL abort( sal_Int32 CommandId ) 181 throw( com::sun::star::uno::RuntimeException ); 182 183 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 184 SAL_CALL queryCreatableContentsInfo() 185 throw( com::sun::star::uno::RuntimeException ); 186 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > 187 SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info ) 188 throw( com::sun::star::uno::RuntimeException ); 189 190 com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 191 queryCreatableContentsInfo( 192 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv) 193 throw( com::sun::star::uno::RuntimeException ); 194 195 GFile* getGFile(); 196 }; 197 198 } 199 200 #endif 201