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 
31 using namespace cppu;
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;
39 
40 
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 ),
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  Sequence<Any> seq(1);
74  seq[0] <<= prop;
75  excep.Arguments = seq;
76  excep.Classification = InteractionClassification_ERROR;
77  excep.Context = m_xOrigin;
78  excep.Message = "the name contained invalid characters";
79  aAny <<= excep;
80 
81  }
82  m_xRequest.set(new ::comphelper::OInteractionRequest(aAny, continuations));
83 }
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void retrieveError(sal_Int32 CommandId, sal_Int32 &ErrorCode, sal_Int32 &minorCode)
Definition: filtask.cxx:430
#define TASKHANDLING_FOLDER_EXISTS_MKDIR
Definition: filerror.hxx:67
#define TASKHANDLING_INVALID_NAME_MKDIR
Definition: filerror.hxx:68