1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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>
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
;
42 XInteractionSupplyNameImpl::acquire( void )
45 OWeakObject::acquire();
51 XInteractionSupplyNameImpl::release( void )
54 OWeakObject::release();
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 //////////////////////////////////////////////////////////////////////////////////////////
72 //////////////////////////////////////////////////////////////////////////////////////////
74 XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl
,
76 XInteractionSupplyName
)
81 XInteractionAbortImpl::acquire( void )
84 OWeakObject::acquire();
90 XInteractionAbortImpl::release( void )
93 OWeakObject::release();
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 //////////////////////////////////////////////////////////////////////////////////////////
111 //////////////////////////////////////////////////////////////////////////////////////////
113 XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl
,
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
),
128 m_aClashingName(aClashingName
),
132 pShell
->retrieveError(CommandId
,m_nErrorCode
,m_nMinorError
);
133 m_aSeq
[0] = Reference
<XInteractionContinuation
>(p1
);
134 m_aSeq
[1] = Reference
<XInteractionContinuation
>(p2
);
139 XInteractionRequestImpl::acquire( void )
142 OWeakObject::acquire();
148 XInteractionRequestImpl::release( void )
151 OWeakObject::release();
157 XInteractionRequestImpl::queryInterface( const Type
& rType
)
158 throw( RuntimeException
)
161 cppu::queryInterface(
163 (static_cast< lang::XTypeProvider
* >(this)),
164 (static_cast< XInteractionRequest
* >(this)) );
165 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
169 //////////////////////////////////////////////////////////////////////////////////////////
171 //////////////////////////////////////////////////////////////////////////////////////////
173 XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl
,
175 XInteractionRequest
)
179 XInteractionRequestImpl::getRequest()
180 throw(RuntimeException
)
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");
192 else if(m_nErrorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
194 InteractiveAugmentedIOException excep
;
195 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
197 prop
.Name
= rtl::OUString("ResourceName");
199 prop
.Value
<<= m_aClashingName
;
200 Sequence
<Any
> seq(1);
202 excep
.Arguments
= seq
;
203 excep
.Classification
= InteractionClassification_ERROR
;
204 excep
.Context
= m_xOrigin
;
205 excep
.Message
= rtl::OUString( "the name contained invalid characters");
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */