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"
21 #include "filtask.hxx"
23 #include <comphelper/interaction.hxx>
25 #include <com/sun/star/ucb/IOErrorCode.hpp>
26 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
27 #include <com/sun/star/ucb/NameClashException.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
32 using namespace com::sun::star
;
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::lang
;
35 using namespace com::sun::star::task
;
36 using namespace com::sun::star::ucb
;
37 using namespace com::sun::star::beans
;
38 using namespace fileaccess
;
41 XInteractionRequestImpl::XInteractionRequestImpl(
42 const OUString
& aClashingName
,
43 const Reference
<XInterface
>& xOrigin
,
44 TaskManager
*pShell
,sal_Int32 CommandId
)
45 : p1( new XInteractionSupplyNameImpl
),
46 p2( new XInteractionAbortImpl
),
49 sal_Int32
nErrorCode(0), nMinorError(0);
51 pShell
->retrieveError(CommandId
,nErrorCode
,nMinorError
);
52 std::vector
<uno::Reference
<task::XInteractionContinuation
>> continuations
{
53 Reference
<XInteractionContinuation
>(p1
),
54 Reference
<XInteractionContinuation
>(p2
) };
56 if(nErrorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
58 NameClashException excep
;
59 excep
.Name
= aClashingName
;
60 excep
.Classification
= InteractionClassification_ERROR
;
61 excep
.Context
= m_xOrigin
;
62 excep
.Message
= "folder exists and overwrite forbidden";
65 else if(nErrorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
67 InteractiveAugmentedIOException excep
;
68 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
70 prop
.Name
= "ResourceName";
72 prop
.Value
<<= aClashingName
;
73 excep
.Arguments
= { Any(prop
) };
74 excep
.Classification
= InteractionClassification_ERROR
;
75 excep
.Context
= m_xOrigin
;
76 excep
.Message
= "the name contained invalid characters";
80 m_xRequest
.set(new ::comphelper::OInteractionRequest(aAny
, continuations
));
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */