bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / file / filinsreq.cxx
bloba2eb9709e1fc616ba84a0b4f5de9dda2ca1e9b8c
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;
40 XInteractionRequestImpl::XInteractionRequestImpl(
41 const OUString& aClashingName,
42 const Reference<XInterface>& xOrigin,
43 shell *pShell,sal_Int32 CommandId)
44 : p1( new XInteractionSupplyNameImpl ),
45 p2( new XInteractionAbortImpl ),
46 m_nErrorCode(0),
47 m_nMinorError(0),
48 m_aSeq( 2 ),
49 m_aClashingName(aClashingName),
50 m_xOrigin(xOrigin)
52 if( pShell )
53 pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
54 m_aSeq[0] = Reference<XInteractionContinuation>(p1);
55 m_aSeq[1] = Reference<XInteractionContinuation>(p2);
59 Any SAL_CALL
60 XInteractionRequestImpl::getRequest()
61 throw(RuntimeException, std::exception)
63 Any aAny;
64 if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
66 NameClashException excep;
67 excep.Name = m_aClashingName;
68 excep.Classification = InteractionClassification_ERROR;
69 excep.Context = m_xOrigin;
70 excep.Message = "folder exists and overwritte forbidden";
71 aAny <<= excep;
73 else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
75 InteractiveAugmentedIOException excep;
76 excep.Code = IOErrorCode_INVALID_CHARACTER;
77 PropertyValue prop;
78 prop.Name = "ResourceName";
79 prop.Handle = -1;
80 prop.Value <<= m_aClashingName;
81 Sequence<Any> seq(1);
82 seq[0] <<= prop;
83 excep.Arguments = seq;
84 excep.Classification = InteractionClassification_ERROR;
85 excep.Context = m_xOrigin;
86 excep.Message = "the name contained invalid characters";
87 aAny <<= excep;
90 return aAny;
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */