xref: /aoo42x/main/ucb/source/ucp/file/filinsreq.cxx (revision 421ed02e)
12f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52f86921cSAndrew Rist  * distributed with this work for additional information
62f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
92f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
102f86921cSAndrew Rist  *
112f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122f86921cSAndrew Rist  *
132f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142f86921cSAndrew Rist  * software distributed under the License is distributed on an
152f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
172f86921cSAndrew Rist  * specific language governing permissions and limitations
182f86921cSAndrew Rist  * under the License.
192f86921cSAndrew Rist  *
202f86921cSAndrew Rist  *************************************************************/
212f86921cSAndrew Rist 
222f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*421ed02eSdamjan #include "precompiled_file.hxx"
26cdf0e10cSrcweir #include "filinsreq.hxx"
27cdf0e10cSrcweir #include "shell.hxx"
28cdf0e10cSrcweir #include "filglob.hxx"
29cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp>
30cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
31cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace cppu;
37cdf0e10cSrcweir using namespace com::sun::star;
38cdf0e10cSrcweir using namespace com::sun::star::uno;
39cdf0e10cSrcweir using namespace com::sun::star::lang;
40cdf0e10cSrcweir using namespace com::sun::star::task;
41cdf0e10cSrcweir using namespace com::sun::star::ucb;
42cdf0e10cSrcweir using namespace com::sun::star::beans;
43cdf0e10cSrcweir using namespace fileaccess;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir void SAL_CALL
acquire(void)48cdf0e10cSrcweir XInteractionSupplyNameImpl::acquire( void )
49cdf0e10cSrcweir 	throw()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	OWeakObject::acquire();
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir void SAL_CALL
release(void)57cdf0e10cSrcweir XInteractionSupplyNameImpl::release( void )
58cdf0e10cSrcweir 	throw()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 	OWeakObject::release();
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir Any SAL_CALL
queryInterface(const Type & rType)66cdf0e10cSrcweir XInteractionSupplyNameImpl::queryInterface( const Type& rType )
67cdf0e10cSrcweir 	throw( RuntimeException )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	Any aRet = cppu::queryInterface( rType,
70cdf0e10cSrcweir                                      SAL_STATIC_CAST( lang::XTypeProvider*, this ),
71cdf0e10cSrcweir                                      SAL_STATIC_CAST( XInteractionSupplyName*,this) );
72cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
77cdf0e10cSrcweir //  XTypeProvider
78cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
79cdf0e10cSrcweir 
XTYPEPROVIDER_IMPL_2(XInteractionSupplyNameImpl,XTypeProvider,XInteractionSupplyName)80cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl,
81cdf0e10cSrcweir 					  XTypeProvider,
82cdf0e10cSrcweir 					  XInteractionSupplyName )
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir void SAL_CALL
87cdf0e10cSrcweir XInteractionAbortImpl::acquire( void )
88cdf0e10cSrcweir 	throw()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	OWeakObject::acquire();
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir void SAL_CALL
release(void)96cdf0e10cSrcweir XInteractionAbortImpl::release( void )
97cdf0e10cSrcweir 	throw()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	OWeakObject::release();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir Any SAL_CALL
queryInterface(const Type & rType)105cdf0e10cSrcweir XInteractionAbortImpl::queryInterface( const Type& rType )
106cdf0e10cSrcweir 	throw( RuntimeException )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	Any aRet = cppu::queryInterface( rType,
109cdf0e10cSrcweir                                      SAL_STATIC_CAST( lang::XTypeProvider*, this ),
110cdf0e10cSrcweir                                      SAL_STATIC_CAST( XInteractionAbort*,this) );
111cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
116cdf0e10cSrcweir //  XTypeProvider
117cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
118cdf0e10cSrcweir 
XTYPEPROVIDER_IMPL_2(XInteractionAbortImpl,XTypeProvider,XInteractionAbort)119cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl,
120cdf0e10cSrcweir 					  XTypeProvider,
121cdf0e10cSrcweir 					  XInteractionAbort )
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir XInteractionRequestImpl::XInteractionRequestImpl(
126cdf0e10cSrcweir     const rtl::OUString& aClashingName,
127cdf0e10cSrcweir     const Reference<XInterface>& xOrigin,
128cdf0e10cSrcweir 	shell *pShell,sal_Int32 CommandId)
129cdf0e10cSrcweir 	: p1( new XInteractionSupplyNameImpl ),
130cdf0e10cSrcweir 	  p2( new XInteractionAbortImpl ),
131cdf0e10cSrcweir 	  m_nErrorCode(0),
132cdf0e10cSrcweir 	  m_nMinorError(0),
133cdf0e10cSrcweir       m_aSeq( 2 ),
134cdf0e10cSrcweir       m_aClashingName(aClashingName),
135cdf0e10cSrcweir       m_xOrigin(xOrigin)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	if( pShell )
138cdf0e10cSrcweir 		pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
139cdf0e10cSrcweir 	m_aSeq[0] = Reference<XInteractionContinuation>(p1);
140cdf0e10cSrcweir 	m_aSeq[1] = Reference<XInteractionContinuation>(p2);
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
144cdf0e10cSrcweir void SAL_CALL
acquire(void)145cdf0e10cSrcweir XInteractionRequestImpl::acquire( void )
146cdf0e10cSrcweir 	throw()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	OWeakObject::acquire();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
153cdf0e10cSrcweir void SAL_CALL
release(void)154cdf0e10cSrcweir XInteractionRequestImpl::release( void )
155cdf0e10cSrcweir 	throw()
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	OWeakObject::release();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
162cdf0e10cSrcweir Any SAL_CALL
queryInterface(const Type & rType)163cdf0e10cSrcweir XInteractionRequestImpl::queryInterface( const Type& rType )
164cdf0e10cSrcweir 	throw( RuntimeException )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	Any aRet =
167cdf0e10cSrcweir         cppu::queryInterface(
168cdf0e10cSrcweir             rType,
169cdf0e10cSrcweir             SAL_STATIC_CAST( lang::XTypeProvider*, this ),
170cdf0e10cSrcweir             SAL_STATIC_CAST( XInteractionRequest*,this) );
171cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 
175cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
176cdf0e10cSrcweir //  XTypeProvider
177cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////
178cdf0e10cSrcweir 
XTYPEPROVIDER_IMPL_2(XInteractionRequestImpl,XTypeProvider,XInteractionRequest)179cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl,
180cdf0e10cSrcweir 					  XTypeProvider,
181cdf0e10cSrcweir 					  XInteractionRequest )
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir Any SAL_CALL
185cdf0e10cSrcweir XInteractionRequestImpl::getRequest()
186cdf0e10cSrcweir     throw(RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	Any aAny;
189cdf0e10cSrcweir 	if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
190cdf0e10cSrcweir 	{
191cdf0e10cSrcweir 		NameClashException excep;
192cdf0e10cSrcweir 		excep.Name = m_aClashingName;
193cdf0e10cSrcweir 		excep.Classification = InteractionClassification_ERROR;
194cdf0e10cSrcweir 		excep.Context = m_xOrigin;
195cdf0e10cSrcweir 		excep.Message = rtl::OUString(
196cdf0e10cSrcweir 			RTL_CONSTASCII_USTRINGPARAM(
197cdf0e10cSrcweir 				"folder exists and overwritte forbidden"));
198cdf0e10cSrcweir 		aAny <<= excep;
199cdf0e10cSrcweir 	}
200cdf0e10cSrcweir 	else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		InteractiveAugmentedIOException excep;
203cdf0e10cSrcweir 		excep.Code = IOErrorCode_INVALID_CHARACTER;
204cdf0e10cSrcweir 		PropertyValue prop;
205cdf0e10cSrcweir 		prop.Name = rtl::OUString::createFromAscii("ResourceName");
206cdf0e10cSrcweir 		prop.Handle = -1;
207cdf0e10cSrcweir 		prop.Value <<= m_aClashingName;
208cdf0e10cSrcweir 		Sequence<Any> seq(1);
209cdf0e10cSrcweir 		seq[0] <<= prop;
210cdf0e10cSrcweir 		excep.Arguments = seq;
211cdf0e10cSrcweir 		excep.Classification = InteractionClassification_ERROR;
212cdf0e10cSrcweir 		excep.Context = m_xOrigin;
213cdf0e10cSrcweir 		excep.Message = rtl::OUString(
214cdf0e10cSrcweir 			RTL_CONSTASCII_USTRINGPARAM(
215cdf0e10cSrcweir 				"the name contained invalid characters"));
216cdf0e10cSrcweir 		aAny <<= excep;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	}
219cdf0e10cSrcweir     return aAny;
220cdf0e10cSrcweir }
221