LibreOffice Module ucb (master) 1
filinsreq.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "filinsreq.hxx"
21#include "filtask.hxx"
22
24
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>
29
30
31using namespace cppu;
32using namespace com::sun::star;
33using namespace com::sun::star::uno;
34using namespace com::sun::star::lang;
35using namespace com::sun::star::task;
36using namespace com::sun::star::ucb;
37using namespace com::sun::star::beans;
38using namespace fileaccess;
39
40
41XInteractionRequestImpl::XInteractionRequestImpl(
42 const OUString& aClashingName,
43 const Reference<XInterface>& xOrigin,
44 TaskManager *pShell,sal_Int32 CommandId)
46 p2( new XInteractionAbortImpl ),
47 m_xOrigin(xOrigin)
48{
49 sal_Int32 nErrorCode(0), nMinorError(0);
50 if( pShell )
51 pShell->retrieveError(CommandId,nErrorCode,nMinorError);
52 std::vector<uno::Reference<task::XInteractionContinuation>> continuations{
55 Any aAny;
56 if(nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
57 {
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";
63 aAny <<= excep;
64 }
65 else if(nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
66 {
67 InteractiveAugmentedIOException excep;
68 excep.Code = IOErrorCode_INVALID_CHARACTER;
69 PropertyValue prop;
70 prop.Name = "ResourceName";
71 prop.Handle = -1;
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";
77 aAny <<= excep;
78
79 }
80 m_xRequest.set(new ::comphelper::OInteractionRequest(aAny, std::move(continuations)));
81}
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void retrieveError(sal_Int32 CommandId, sal_Int32 &ErrorCode, sal_Int32 &minorCode)
Definition: filtask.cxx:422
#define TASKHANDLING_FOLDER_EXISTS_MKDIR
Definition: filerror.hxx:66
#define TASKHANDLING_INVALID_NAME_MKDIR
Definition: filerror.hxx:67