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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_ucb.hxx" 30 #include "filinsreq.hxx" 31 #include "shell.hxx" 32 #include "filglob.hxx" 33 #include <com/sun/star/ucb/IOErrorCode.hpp> 34 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 35 #include <com/sun/star/ucb/NameClashException.hpp> 36 #include <com/sun/star/beans/PropertyValue.hpp> 37 38 39 40 using namespace cppu; 41 using namespace com::sun::star; 42 using namespace com::sun::star::uno; 43 using namespace com::sun::star::lang; 44 using namespace com::sun::star::task; 45 using namespace com::sun::star::ucb; 46 using namespace com::sun::star::beans; 47 using namespace fileaccess; 48 49 50 51 void SAL_CALL 52 XInteractionSupplyNameImpl::acquire( void ) 53 throw() 54 { 55 OWeakObject::acquire(); 56 } 57 58 59 60 void SAL_CALL 61 XInteractionSupplyNameImpl::release( void ) 62 throw() 63 { 64 OWeakObject::release(); 65 } 66 67 68 69 Any SAL_CALL 70 XInteractionSupplyNameImpl::queryInterface( const Type& rType ) 71 throw( RuntimeException ) 72 { 73 Any aRet = cppu::queryInterface( rType, 74 SAL_STATIC_CAST( lang::XTypeProvider*, this ), 75 SAL_STATIC_CAST( XInteractionSupplyName*,this) ); 76 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 77 } 78 79 80 ////////////////////////////////////////////////////////////////////////////////////////// 81 // XTypeProvider 82 ////////////////////////////////////////////////////////////////////////////////////////// 83 84 XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl, 85 XTypeProvider, 86 XInteractionSupplyName ) 87 88 89 90 void SAL_CALL 91 XInteractionAbortImpl::acquire( void ) 92 throw() 93 { 94 OWeakObject::acquire(); 95 } 96 97 98 99 void SAL_CALL 100 XInteractionAbortImpl::release( void ) 101 throw() 102 { 103 OWeakObject::release(); 104 } 105 106 107 108 Any SAL_CALL 109 XInteractionAbortImpl::queryInterface( const Type& rType ) 110 throw( RuntimeException ) 111 { 112 Any aRet = cppu::queryInterface( rType, 113 SAL_STATIC_CAST( lang::XTypeProvider*, this ), 114 SAL_STATIC_CAST( XInteractionAbort*,this) ); 115 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 116 } 117 118 119 ////////////////////////////////////////////////////////////////////////////////////////// 120 // XTypeProvider 121 ////////////////////////////////////////////////////////////////////////////////////////// 122 123 XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl, 124 XTypeProvider, 125 XInteractionAbort ) 126 127 128 129 XInteractionRequestImpl::XInteractionRequestImpl( 130 const rtl::OUString& aClashingName, 131 const Reference<XInterface>& xOrigin, 132 shell *pShell,sal_Int32 CommandId) 133 : p1( new XInteractionSupplyNameImpl ), 134 p2( new XInteractionAbortImpl ), 135 m_nErrorCode(0), 136 m_nMinorError(0), 137 m_aSeq( 2 ), 138 m_aClashingName(aClashingName), 139 m_xOrigin(xOrigin) 140 { 141 if( pShell ) 142 pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError); 143 m_aSeq[0] = Reference<XInteractionContinuation>(p1); 144 m_aSeq[1] = Reference<XInteractionContinuation>(p2); 145 } 146 147 148 void SAL_CALL 149 XInteractionRequestImpl::acquire( void ) 150 throw() 151 { 152 OWeakObject::acquire(); 153 } 154 155 156 157 void SAL_CALL 158 XInteractionRequestImpl::release( void ) 159 throw() 160 { 161 OWeakObject::release(); 162 } 163 164 165 166 Any SAL_CALL 167 XInteractionRequestImpl::queryInterface( const Type& rType ) 168 throw( RuntimeException ) 169 { 170 Any aRet = 171 cppu::queryInterface( 172 rType, 173 SAL_STATIC_CAST( lang::XTypeProvider*, this ), 174 SAL_STATIC_CAST( XInteractionRequest*,this) ); 175 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 176 } 177 178 179 ////////////////////////////////////////////////////////////////////////////////////////// 180 // XTypeProvider 181 ////////////////////////////////////////////////////////////////////////////////////////// 182 183 XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl, 184 XTypeProvider, 185 XInteractionRequest ) 186 187 188 Any SAL_CALL 189 XInteractionRequestImpl::getRequest() 190 throw(RuntimeException) 191 { 192 Any aAny; 193 if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR) 194 { 195 NameClashException excep; 196 excep.Name = m_aClashingName; 197 excep.Classification = InteractionClassification_ERROR; 198 excep.Context = m_xOrigin; 199 excep.Message = rtl::OUString( 200 RTL_CONSTASCII_USTRINGPARAM( 201 "folder exists and overwritte forbidden")); 202 aAny <<= excep; 203 } 204 else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR) 205 { 206 InteractiveAugmentedIOException excep; 207 excep.Code = IOErrorCode_INVALID_CHARACTER; 208 PropertyValue prop; 209 prop.Name = rtl::OUString::createFromAscii("ResourceName"); 210 prop.Handle = -1; 211 prop.Value <<= m_aClashingName; 212 Sequence<Any> seq(1); 213 seq[0] <<= prop; 214 excep.Arguments = seq; 215 excep.Classification = InteractionClassification_ERROR; 216 excep.Context = m_xOrigin; 217 excep.Message = rtl::OUString( 218 RTL_CONSTASCII_USTRINGPARAM( 219 "the name contained invalid characters")); 220 aAny <<= excep; 221 222 } 223 return aAny; 224 } 225