Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / file / filinsreq.cxx
blob1ac3d39944c129797aa16fbb592ef8475f141d08
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "filinsreq.hxx"
30 #include "shell.hxx"
31 #include "filglob.hxx"
32 #include <com/sun/star/ucb/IOErrorCode.hpp>
33 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
34 #include <com/sun/star/ucb/NameClashException.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
39 using namespace cppu;
40 using namespace com::sun::star;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::task;
44 using namespace com::sun::star::ucb;
45 using namespace com::sun::star::beans;
46 using namespace fileaccess;
50 void SAL_CALL
51 XInteractionSupplyNameImpl::acquire( void )
52 throw()
54 OWeakObject::acquire();
59 void SAL_CALL
60 XInteractionSupplyNameImpl::release( void )
61 throw()
63 OWeakObject::release();
68 Any SAL_CALL
69 XInteractionSupplyNameImpl::queryInterface( const Type& rType )
70 throw( RuntimeException )
72 Any aRet = cppu::queryInterface( rType,
73 (static_cast< lang::XTypeProvider* >(this)),
74 (static_cast< XInteractionSupplyName* >(this)) );
75 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
79 //////////////////////////////////////////////////////////////////////////////////////////
80 // XTypeProvider
81 //////////////////////////////////////////////////////////////////////////////////////////
83 XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl,
84 XTypeProvider,
85 XInteractionSupplyName )
89 void SAL_CALL
90 XInteractionAbortImpl::acquire( void )
91 throw()
93 OWeakObject::acquire();
98 void SAL_CALL
99 XInteractionAbortImpl::release( void )
100 throw()
102 OWeakObject::release();
107 Any SAL_CALL
108 XInteractionAbortImpl::queryInterface( const Type& rType )
109 throw( RuntimeException )
111 Any aRet = cppu::queryInterface( rType,
112 (static_cast< lang::XTypeProvider* >(this)),
113 (static_cast< XInteractionAbort* >(this)) );
114 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
118 //////////////////////////////////////////////////////////////////////////////////////////
119 // XTypeProvider
120 //////////////////////////////////////////////////////////////////////////////////////////
122 XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl,
123 XTypeProvider,
124 XInteractionAbort )
128 XInteractionRequestImpl::XInteractionRequestImpl(
129 const rtl::OUString& aClashingName,
130 const Reference<XInterface>& xOrigin,
131 shell *pShell,sal_Int32 CommandId)
132 : p1( new XInteractionSupplyNameImpl ),
133 p2( new XInteractionAbortImpl ),
134 m_nErrorCode(0),
135 m_nMinorError(0),
136 m_aSeq( 2 ),
137 m_aClashingName(aClashingName),
138 m_xOrigin(xOrigin)
140 if( pShell )
141 pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
142 m_aSeq[0] = Reference<XInteractionContinuation>(p1);
143 m_aSeq[1] = Reference<XInteractionContinuation>(p2);
147 void SAL_CALL
148 XInteractionRequestImpl::acquire( void )
149 throw()
151 OWeakObject::acquire();
156 void SAL_CALL
157 XInteractionRequestImpl::release( void )
158 throw()
160 OWeakObject::release();
165 Any SAL_CALL
166 XInteractionRequestImpl::queryInterface( const Type& rType )
167 throw( RuntimeException )
169 Any aRet =
170 cppu::queryInterface(
171 rType,
172 (static_cast< lang::XTypeProvider* >(this)),
173 (static_cast< XInteractionRequest* >(this)) );
174 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
178 //////////////////////////////////////////////////////////////////////////////////////////
179 // XTypeProvider
180 //////////////////////////////////////////////////////////////////////////////////////////
182 XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl,
183 XTypeProvider,
184 XInteractionRequest )
187 Any SAL_CALL
188 XInteractionRequestImpl::getRequest()
189 throw(RuntimeException)
191 Any aAny;
192 if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
194 NameClashException excep;
195 excep.Name = m_aClashingName;
196 excep.Classification = InteractionClassification_ERROR;
197 excep.Context = m_xOrigin;
198 excep.Message = rtl::OUString( "folder exists and overwritte forbidden");
199 aAny <<= excep;
201 else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
203 InteractiveAugmentedIOException excep;
204 excep.Code = IOErrorCode_INVALID_CHARACTER;
205 PropertyValue prop;
206 prop.Name = rtl::OUString("ResourceName");
207 prop.Handle = -1;
208 prop.Value <<= m_aClashingName;
209 Sequence<Any> seq(1);
210 seq[0] <<= prop;
211 excep.Arguments = seq;
212 excep.Classification = InteractionClassification_ERROR;
213 excep.Context = m_xOrigin;
214 excep.Message = rtl::OUString( "the name contained invalid characters");
215 aAny <<= excep;
218 return aAny;
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */