xref: /aoo42x/main/ucb/source/ucp/file/filinsreq.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir  /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucb.hxx"
30*cdf0e10cSrcweir #include "filinsreq.hxx"
31*cdf0e10cSrcweir #include "shell.hxx"
32*cdf0e10cSrcweir #include "filglob.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir using namespace cppu;
41*cdf0e10cSrcweir using namespace com::sun::star;
42*cdf0e10cSrcweir using namespace com::sun::star::uno;
43*cdf0e10cSrcweir using namespace com::sun::star::lang;
44*cdf0e10cSrcweir using namespace com::sun::star::task;
45*cdf0e10cSrcweir using namespace com::sun::star::ucb;
46*cdf0e10cSrcweir using namespace com::sun::star::beans;
47*cdf0e10cSrcweir using namespace fileaccess;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir void SAL_CALL
52*cdf0e10cSrcweir XInteractionSupplyNameImpl::acquire( void )
53*cdf0e10cSrcweir 	throw()
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir 	OWeakObject::acquire();
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir void SAL_CALL
61*cdf0e10cSrcweir XInteractionSupplyNameImpl::release( void )
62*cdf0e10cSrcweir 	throw()
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	OWeakObject::release();
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir Any SAL_CALL
70*cdf0e10cSrcweir XInteractionSupplyNameImpl::queryInterface( const Type& rType )
71*cdf0e10cSrcweir 	throw( RuntimeException )
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	Any aRet = cppu::queryInterface( rType,
74*cdf0e10cSrcweir                                      SAL_STATIC_CAST( lang::XTypeProvider*, this ),
75*cdf0e10cSrcweir                                      SAL_STATIC_CAST( XInteractionSupplyName*,this) );
76*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
81*cdf0e10cSrcweir //  XTypeProvider
82*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl,
85*cdf0e10cSrcweir 					  XTypeProvider,
86*cdf0e10cSrcweir 					  XInteractionSupplyName )
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir void SAL_CALL
91*cdf0e10cSrcweir XInteractionAbortImpl::acquire( void )
92*cdf0e10cSrcweir 	throw()
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir 	OWeakObject::acquire();
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir void SAL_CALL
100*cdf0e10cSrcweir XInteractionAbortImpl::release( void )
101*cdf0e10cSrcweir 	throw()
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	OWeakObject::release();
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir Any SAL_CALL
109*cdf0e10cSrcweir XInteractionAbortImpl::queryInterface( const Type& rType )
110*cdf0e10cSrcweir 	throw( RuntimeException )
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	Any aRet = cppu::queryInterface( rType,
113*cdf0e10cSrcweir                                      SAL_STATIC_CAST( lang::XTypeProvider*, this ),
114*cdf0e10cSrcweir                                      SAL_STATIC_CAST( XInteractionAbort*,this) );
115*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
120*cdf0e10cSrcweir //  XTypeProvider
121*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl,
124*cdf0e10cSrcweir 					  XTypeProvider,
125*cdf0e10cSrcweir 					  XInteractionAbort )
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir XInteractionRequestImpl::XInteractionRequestImpl(
130*cdf0e10cSrcweir     const rtl::OUString& aClashingName,
131*cdf0e10cSrcweir     const Reference<XInterface>& xOrigin,
132*cdf0e10cSrcweir 	shell *pShell,sal_Int32 CommandId)
133*cdf0e10cSrcweir 	: p1( new XInteractionSupplyNameImpl ),
134*cdf0e10cSrcweir 	  p2( new XInteractionAbortImpl ),
135*cdf0e10cSrcweir 	  m_nErrorCode(0),
136*cdf0e10cSrcweir 	  m_nMinorError(0),
137*cdf0e10cSrcweir       m_aSeq( 2 ),
138*cdf0e10cSrcweir       m_aClashingName(aClashingName),
139*cdf0e10cSrcweir       m_xOrigin(xOrigin)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	if( pShell )
142*cdf0e10cSrcweir 		pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
143*cdf0e10cSrcweir 	m_aSeq[0] = Reference<XInteractionContinuation>(p1);
144*cdf0e10cSrcweir 	m_aSeq[1] = Reference<XInteractionContinuation>(p2);
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir void SAL_CALL
149*cdf0e10cSrcweir XInteractionRequestImpl::acquire( void )
150*cdf0e10cSrcweir 	throw()
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	OWeakObject::acquire();
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir void SAL_CALL
158*cdf0e10cSrcweir XInteractionRequestImpl::release( void )
159*cdf0e10cSrcweir 	throw()
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	OWeakObject::release();
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir Any SAL_CALL
167*cdf0e10cSrcweir XInteractionRequestImpl::queryInterface( const Type& rType )
168*cdf0e10cSrcweir 	throw( RuntimeException )
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir 	Any aRet =
171*cdf0e10cSrcweir         cppu::queryInterface(
172*cdf0e10cSrcweir             rType,
173*cdf0e10cSrcweir             SAL_STATIC_CAST( lang::XTypeProvider*, this ),
174*cdf0e10cSrcweir             SAL_STATIC_CAST( XInteractionRequest*,this) );
175*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
180*cdf0e10cSrcweir //  XTypeProvider
181*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl,
184*cdf0e10cSrcweir 					  XTypeProvider,
185*cdf0e10cSrcweir 					  XInteractionRequest )
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir Any SAL_CALL
189*cdf0e10cSrcweir XInteractionRequestImpl::getRequest()
190*cdf0e10cSrcweir     throw(RuntimeException)
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir 	Any aAny;
193*cdf0e10cSrcweir 	if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
194*cdf0e10cSrcweir 	{
195*cdf0e10cSrcweir 		NameClashException excep;
196*cdf0e10cSrcweir 		excep.Name = m_aClashingName;
197*cdf0e10cSrcweir 		excep.Classification = InteractionClassification_ERROR;
198*cdf0e10cSrcweir 		excep.Context = m_xOrigin;
199*cdf0e10cSrcweir 		excep.Message = rtl::OUString(
200*cdf0e10cSrcweir 			RTL_CONSTASCII_USTRINGPARAM(
201*cdf0e10cSrcweir 				"folder exists and overwritte forbidden"));
202*cdf0e10cSrcweir 		aAny <<= excep;
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir 	else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
205*cdf0e10cSrcweir 	{
206*cdf0e10cSrcweir 		InteractiveAugmentedIOException excep;
207*cdf0e10cSrcweir 		excep.Code = IOErrorCode_INVALID_CHARACTER;
208*cdf0e10cSrcweir 		PropertyValue prop;
209*cdf0e10cSrcweir 		prop.Name = rtl::OUString::createFromAscii("ResourceName");
210*cdf0e10cSrcweir 		prop.Handle = -1;
211*cdf0e10cSrcweir 		prop.Value <<= m_aClashingName;
212*cdf0e10cSrcweir 		Sequence<Any> seq(1);
213*cdf0e10cSrcweir 		seq[0] <<= prop;
214*cdf0e10cSrcweir 		excep.Arguments = seq;
215*cdf0e10cSrcweir 		excep.Classification = InteractionClassification_ERROR;
216*cdf0e10cSrcweir 		excep.Context = m_xOrigin;
217*cdf0e10cSrcweir 		excep.Message = rtl::OUString(
218*cdf0e10cSrcweir 			RTL_CONSTASCII_USTRINGPARAM(
219*cdf0e10cSrcweir 				"the name contained invalid characters"));
220*cdf0e10cSrcweir 		aAny <<= excep;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	}
223*cdf0e10cSrcweir     return aAny;
224*cdf0e10cSrcweir }
225