Line data Source code
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 "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>
27 :
28 :
29 :
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;
38 :
39 :
40 1467 : XInteractionRequestImpl::XInteractionRequestImpl(
41 : const OUString& aClashingName,
42 : const Reference<XInterface>& xOrigin,
43 : shell *pShell,sal_Int32 CommandId)
44 1467 : : p1( new XInteractionSupplyNameImpl ),
45 1467 : p2( new XInteractionAbortImpl ),
46 : m_nErrorCode(0),
47 : m_nMinorError(0),
48 : m_aSeq( 2 ),
49 : m_aClashingName(aClashingName),
50 4401 : m_xOrigin(xOrigin)
51 : {
52 1467 : if( pShell )
53 1467 : pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
54 1467 : m_aSeq[0] = Reference<XInteractionContinuation>(p1);
55 1467 : m_aSeq[1] = Reference<XInteractionContinuation>(p2);
56 1467 : }
57 :
58 :
59 : Any SAL_CALL
60 0 : XInteractionRequestImpl::getRequest()
61 : throw(RuntimeException, std::exception)
62 : {
63 0 : Any aAny;
64 0 : if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
65 : {
66 0 : NameClashException excep;
67 0 : excep.Name = m_aClashingName;
68 0 : excep.Classification = InteractionClassification_ERROR;
69 0 : excep.Context = m_xOrigin;
70 0 : excep.Message = "folder exists and overwritte forbidden";
71 0 : aAny <<= excep;
72 : }
73 0 : else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
74 : {
75 0 : InteractiveAugmentedIOException excep;
76 0 : excep.Code = IOErrorCode_INVALID_CHARACTER;
77 0 : PropertyValue prop;
78 0 : prop.Name = "ResourceName";
79 0 : prop.Handle = -1;
80 0 : prop.Value <<= m_aClashingName;
81 0 : Sequence<Any> seq(1);
82 0 : seq[0] <<= prop;
83 0 : excep.Arguments = seq;
84 0 : excep.Classification = InteractionClassification_ERROR;
85 0 : excep.Context = m_xOrigin;
86 0 : excep.Message = "the name contained invalid characters";
87 0 : aAny <<= excep;
88 :
89 : }
90 0 : return aAny;
91 : }
92 :
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|