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