Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / file / filinsreq.cxx
blobef2e2cafc5aa28fd30711569f6dccd4e8c22a898
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "filinsreq.hxx"
21 #include "shell.hxx"
22 #include "filglob.hxx"
23 #include <com/sun/star/ucb/IOErrorCode.hpp>
24 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
25 #include <com/sun/star/ucb/NameClashException.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
30 using namespace cppu;
31 using namespace com::sun::star;
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::lang;
34 using namespace com::sun::star::task;
35 using namespace com::sun::star::ucb;
36 using namespace com::sun::star::beans;
37 using namespace fileaccess;
41 void SAL_CALL
42 XInteractionSupplyNameImpl::acquire( void )
43 throw()
45 OWeakObject::acquire();
50 void SAL_CALL
51 XInteractionSupplyNameImpl::release( void )
52 throw()
54 OWeakObject::release();
59 Any SAL_CALL
60 XInteractionSupplyNameImpl::queryInterface( const Type& rType )
61 throw( RuntimeException )
63 Any aRet = cppu::queryInterface( rType,
64 (static_cast< lang::XTypeProvider* >(this)),
65 (static_cast< XInteractionSupplyName* >(this)) );
66 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
70 //////////////////////////////////////////////////////////////////////////////////////////
71 // XTypeProvider
72 //////////////////////////////////////////////////////////////////////////////////////////
74 XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl,
75 XTypeProvider,
76 XInteractionSupplyName )
80 void SAL_CALL
81 XInteractionAbortImpl::acquire( void )
82 throw()
84 OWeakObject::acquire();
89 void SAL_CALL
90 XInteractionAbortImpl::release( void )
91 throw()
93 OWeakObject::release();
98 Any SAL_CALL
99 XInteractionAbortImpl::queryInterface( const Type& rType )
100 throw( RuntimeException )
102 Any aRet = cppu::queryInterface( rType,
103 (static_cast< lang::XTypeProvider* >(this)),
104 (static_cast< XInteractionAbort* >(this)) );
105 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
109 //////////////////////////////////////////////////////////////////////////////////////////
110 // XTypeProvider
111 //////////////////////////////////////////////////////////////////////////////////////////
113 XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl,
114 XTypeProvider,
115 XInteractionAbort )
119 XInteractionRequestImpl::XInteractionRequestImpl(
120 const rtl::OUString& aClashingName,
121 const Reference<XInterface>& xOrigin,
122 shell *pShell,sal_Int32 CommandId)
123 : p1( new XInteractionSupplyNameImpl ),
124 p2( new XInteractionAbortImpl ),
125 m_nErrorCode(0),
126 m_nMinorError(0),
127 m_aSeq( 2 ),
128 m_aClashingName(aClashingName),
129 m_xOrigin(xOrigin)
131 if( pShell )
132 pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
133 m_aSeq[0] = Reference<XInteractionContinuation>(p1);
134 m_aSeq[1] = Reference<XInteractionContinuation>(p2);
138 void SAL_CALL
139 XInteractionRequestImpl::acquire( void )
140 throw()
142 OWeakObject::acquire();
147 void SAL_CALL
148 XInteractionRequestImpl::release( void )
149 throw()
151 OWeakObject::release();
156 Any SAL_CALL
157 XInteractionRequestImpl::queryInterface( const Type& rType )
158 throw( RuntimeException )
160 Any aRet =
161 cppu::queryInterface(
162 rType,
163 (static_cast< lang::XTypeProvider* >(this)),
164 (static_cast< XInteractionRequest* >(this)) );
165 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
169 //////////////////////////////////////////////////////////////////////////////////////////
170 // XTypeProvider
171 //////////////////////////////////////////////////////////////////////////////////////////
173 XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl,
174 XTypeProvider,
175 XInteractionRequest )
178 Any SAL_CALL
179 XInteractionRequestImpl::getRequest()
180 throw(RuntimeException)
182 Any aAny;
183 if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
185 NameClashException excep;
186 excep.Name = m_aClashingName;
187 excep.Classification = InteractionClassification_ERROR;
188 excep.Context = m_xOrigin;
189 excep.Message = rtl::OUString( "folder exists and overwritte forbidden");
190 aAny <<= excep;
192 else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
194 InteractiveAugmentedIOException excep;
195 excep.Code = IOErrorCode_INVALID_CHARACTER;
196 PropertyValue prop;
197 prop.Name = rtl::OUString("ResourceName");
198 prop.Handle = -1;
199 prop.Value <<= m_aClashingName;
200 Sequence<Any> seq(1);
201 seq[0] <<= prop;
202 excep.Arguments = seq;
203 excep.Classification = InteractionClassification_ERROR;
204 excep.Context = m_xOrigin;
205 excep.Message = rtl::OUString( "the name contained invalid characters");
206 aAny <<= excep;
209 return aAny;
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */