xref: /AOO41X/main/ucb/source/ucp/file/filglob.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir  /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucb.hxx"
30*cdf0e10cSrcweir #include <stdio.h>
31*cdf0e10cSrcweir #include "filglob.hxx"
32*cdf0e10cSrcweir #ifndef _FILERROR_HXX_
33*cdf0e10cSrcweir #include "filerror.hxx"
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include "shell.hxx"
36*cdf0e10cSrcweir #include "bc.hxx"
37*cdf0e10cSrcweir #include <osl/file.hxx>
38*cdf0e10cSrcweir #ifndef INCLUDED_STL_VECTOR
39*cdf0e10cSrcweir #include <vector>
40*cdf0e10cSrcweir #define INCLUDED_STL_VECTOR
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx>
43*cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/ucb/MissingInputStreamException.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
53*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyState.hpp"
54*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp"
55*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
56*cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
57*cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
58*cdf0e10cSrcweir #include "osl/diagnose.h"
59*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
60*cdf0e10cSrcweir #include <rtl/uri.hxx>
61*cdf0e10cSrcweir #include <rtl/ustring.hxx>
62*cdf0e10cSrcweir #include "sal/types.h"
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using namespace ucbhelper;
65*cdf0e10cSrcweir using namespace osl;
66*cdf0e10cSrcweir using namespace ::com::sun::star;
67*cdf0e10cSrcweir using namespace com::sun::star::task;
68*cdf0e10cSrcweir using namespace com::sun::star::beans;
69*cdf0e10cSrcweir using namespace com::sun::star::lang;
70*cdf0e10cSrcweir using namespace com::sun::star::uno;
71*cdf0e10cSrcweir using namespace com::sun::star::ucb;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir namespace {
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir     Sequence< Any > generateErrorArguments(
76*cdf0e10cSrcweir         rtl::OUString const & rPhysicalUrl)
77*cdf0e10cSrcweir     {
78*cdf0e10cSrcweir         rtl::OUString aResourceName;
79*cdf0e10cSrcweir         rtl::OUString aResourceType;
80*cdf0e10cSrcweir         sal_Bool      bRemovable;
81*cdf0e10cSrcweir         bool bResourceName = false;
82*cdf0e10cSrcweir         bool bResourceType = false;
83*cdf0e10cSrcweir         bool bRemoveProperty = false;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir         if (osl::FileBase::getSystemPathFromFileURL(
86*cdf0e10cSrcweir                 rPhysicalUrl,
87*cdf0e10cSrcweir                 aResourceName)
88*cdf0e10cSrcweir             == osl::FileBase::E_None)
89*cdf0e10cSrcweir             bResourceName = true;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         // The resource types "folder" (i.e., directory) and
92*cdf0e10cSrcweir         // "volume" seem to be
93*cdf0e10cSrcweir         // the most interesting when producing meaningful error messages:
94*cdf0e10cSrcweir         osl::DirectoryItem aItem;
95*cdf0e10cSrcweir         if (osl::DirectoryItem::get(rPhysicalUrl, aItem) ==
96*cdf0e10cSrcweir             osl::FileBase::E_None)
97*cdf0e10cSrcweir         {
98*cdf0e10cSrcweir             osl::FileStatus aStatus( FileStatusMask_Type );
99*cdf0e10cSrcweir             if (aItem.getFileStatus(aStatus) == osl::FileBase::E_None)
100*cdf0e10cSrcweir                 switch (aStatus.getFileType())
101*cdf0e10cSrcweir                 {
102*cdf0e10cSrcweir                     case osl::FileStatus::Directory:
103*cdf0e10cSrcweir                         aResourceType
104*cdf0e10cSrcweir                             = rtl::OUString(
105*cdf0e10cSrcweir                                 RTL_CONSTASCII_USTRINGPARAM("folder"));
106*cdf0e10cSrcweir                         bResourceType = true;
107*cdf0e10cSrcweir                         break;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir                     case osl::FileStatus::Volume:
110*cdf0e10cSrcweir                     {
111*cdf0e10cSrcweir                         aResourceType
112*cdf0e10cSrcweir                             = rtl::OUString(
113*cdf0e10cSrcweir                                 RTL_CONSTASCII_USTRINGPARAM("volume"));
114*cdf0e10cSrcweir                         bResourceType = true;
115*cdf0e10cSrcweir                         osl::VolumeInfo aVolumeInfo(
116*cdf0e10cSrcweir                             VolumeInfoMask_Attributes );
117*cdf0e10cSrcweir                         if( osl::Directory::getVolumeInfo(
118*cdf0e10cSrcweir                             rPhysicalUrl,aVolumeInfo ) ==
119*cdf0e10cSrcweir                             osl::FileBase::E_None )
120*cdf0e10cSrcweir                         {
121*cdf0e10cSrcweir                             bRemovable = aVolumeInfo.getRemoveableFlag();
122*cdf0e10cSrcweir                             bRemoveProperty = true;
123*cdf0e10cSrcweir                         }
124*cdf0e10cSrcweir                     }
125*cdf0e10cSrcweir                     break;
126*cdf0e10cSrcweir                     case osl::FileStatus::Regular:
127*cdf0e10cSrcweir                     case osl::FileStatus::Fifo:
128*cdf0e10cSrcweir                     case osl::FileStatus::Socket:
129*cdf0e10cSrcweir                     case osl::FileStatus::Link:
130*cdf0e10cSrcweir                     case osl::FileStatus::Special:
131*cdf0e10cSrcweir                     case osl::FileStatus::Unknown:
132*cdf0e10cSrcweir                         // do nothing for now
133*cdf0e10cSrcweir                         break;
134*cdf0e10cSrcweir                 }
135*cdf0e10cSrcweir         }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         Sequence< Any > aArguments( 1              +
138*cdf0e10cSrcweir                                     (bResourceName ? 1 : 0)     +
139*cdf0e10cSrcweir                                     (bResourceType ? 1 : 0)     +
140*cdf0e10cSrcweir                                     (bRemoveProperty ? 1 : 0) );
141*cdf0e10cSrcweir         sal_Int32 i = 0;
142*cdf0e10cSrcweir         aArguments[i++]
143*cdf0e10cSrcweir             <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
144*cdf0e10cSrcweir                 "Uri")),
145*cdf0e10cSrcweir                               -1,
146*cdf0e10cSrcweir                               makeAny(rPhysicalUrl),
147*cdf0e10cSrcweir                               PropertyState_DIRECT_VALUE);
148*cdf0e10cSrcweir         if (bResourceName)
149*cdf0e10cSrcweir             aArguments[i++]
150*cdf0e10cSrcweir                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
151*cdf0e10cSrcweir                     "ResourceName")),
152*cdf0e10cSrcweir                                   -1,
153*cdf0e10cSrcweir                                   makeAny(aResourceName),
154*cdf0e10cSrcweir                                   PropertyState_DIRECT_VALUE);
155*cdf0e10cSrcweir         if (bResourceType)
156*cdf0e10cSrcweir             aArguments[i++]
157*cdf0e10cSrcweir                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
158*cdf0e10cSrcweir                     "ResourceType")),
159*cdf0e10cSrcweir                                   -1,
160*cdf0e10cSrcweir                                   makeAny(aResourceType),
161*cdf0e10cSrcweir                                   PropertyState_DIRECT_VALUE);
162*cdf0e10cSrcweir         if (bRemoveProperty)
163*cdf0e10cSrcweir             aArguments[i++]
164*cdf0e10cSrcweir                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
165*cdf0e10cSrcweir                     "Removable")),
166*cdf0e10cSrcweir                                   -1,
167*cdf0e10cSrcweir                                   makeAny(bRemovable),
168*cdf0e10cSrcweir                                   PropertyState_DIRECT_VALUE);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         return aArguments;
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir namespace fileaccess {
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     sal_Bool isChild( const rtl::OUString& srcUnqPath,
180*cdf0e10cSrcweir                       const rtl::OUString& dstUnqPath )
181*cdf0e10cSrcweir     {
182*cdf0e10cSrcweir         static sal_Unicode slash = '/';
183*cdf0e10cSrcweir         // Simple lexical comparison
184*cdf0e10cSrcweir         sal_Int32 srcL = srcUnqPath.getLength();
185*cdf0e10cSrcweir         sal_Int32 dstL = dstUnqPath.getLength();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         return (
188*cdf0e10cSrcweir             ( srcUnqPath == dstUnqPath )
189*cdf0e10cSrcweir             ||
190*cdf0e10cSrcweir             ( ( dstL > srcL )
191*cdf0e10cSrcweir               &&
192*cdf0e10cSrcweir               ( srcUnqPath.compareTo( dstUnqPath, srcL ) == 0 )
193*cdf0e10cSrcweir               &&
194*cdf0e10cSrcweir               ( dstUnqPath[ srcL ] == slash ) )
195*cdf0e10cSrcweir         );
196*cdf0e10cSrcweir     }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     rtl::OUString newName(
200*cdf0e10cSrcweir         const rtl::OUString& aNewPrefix,
201*cdf0e10cSrcweir         const rtl::OUString& aOldPrefix,
202*cdf0e10cSrcweir         const rtl::OUString& old_Name )
203*cdf0e10cSrcweir     {
204*cdf0e10cSrcweir         sal_Int32 srcL = aOldPrefix.getLength();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         rtl::OUString new_Name = old_Name.copy( srcL );
207*cdf0e10cSrcweir         new_Name = ( aNewPrefix + new_Name );
208*cdf0e10cSrcweir         return new_Name;
209*cdf0e10cSrcweir     }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir     rtl::OUString getTitle( const rtl::OUString& aPath )
213*cdf0e10cSrcweir     {
214*cdf0e10cSrcweir         sal_Unicode slash = '/';
215*cdf0e10cSrcweir         sal_Int32 lastIndex = aPath.lastIndexOf( slash );
216*cdf0e10cSrcweir         return aPath.copy( lastIndex + 1 );
217*cdf0e10cSrcweir     }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     rtl::OUString getParentName( const rtl::OUString& aFileName )
221*cdf0e10cSrcweir     {
222*cdf0e10cSrcweir         sal_Int32 lastIndex = aFileName.lastIndexOf( sal_Unicode('/') );
223*cdf0e10cSrcweir         rtl::OUString aParent = aFileName.copy( 0,lastIndex );
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir         if( aParent[ aParent.getLength()-1] == sal_Unicode(':') && aParent.getLength() == 6 )
226*cdf0e10cSrcweir             aParent += rtl::OUString::createFromAscii( "/" );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir         if( 0 == aParent.compareToAscii( "file://" ) )
229*cdf0e10cSrcweir             aParent = rtl::OUString::createFromAscii( "file:///" );
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         return aParent;
232*cdf0e10cSrcweir     }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     osl::FileBase::RC osl_File_copy( const rtl::OUString& strPath,
236*cdf0e10cSrcweir                                      const rtl::OUString& strDestPath,
237*cdf0e10cSrcweir                                      sal_Bool test )
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         if( test )
240*cdf0e10cSrcweir         {
241*cdf0e10cSrcweir             osl::DirectoryItem aItem;
242*cdf0e10cSrcweir             if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
243*cdf0e10cSrcweir                 return osl::FileBase::E_EXIST;
244*cdf0e10cSrcweir         }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir         return osl::File::copy( strPath,strDestPath );
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     osl::FileBase::RC osl_File_move( const rtl::OUString& strPath,
251*cdf0e10cSrcweir                                      const rtl::OUString& strDestPath,
252*cdf0e10cSrcweir                                      sal_Bool test )
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir         if( test )
255*cdf0e10cSrcweir         {
256*cdf0e10cSrcweir             osl::DirectoryItem aItem;
257*cdf0e10cSrcweir             if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
258*cdf0e10cSrcweir                 return osl::FileBase::E_EXIST;
259*cdf0e10cSrcweir         }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         return osl::File::move( strPath,strDestPath );
262*cdf0e10cSrcweir     }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir     void throw_handler(
265*cdf0e10cSrcweir         sal_Int32 errorCode,
266*cdf0e10cSrcweir         sal_Int32 minorCode,
267*cdf0e10cSrcweir         const Reference< XCommandEnvironment >& xEnv,
268*cdf0e10cSrcweir         const rtl::OUString& aUncPath,
269*cdf0e10cSrcweir         BaseContent* pContent,
270*cdf0e10cSrcweir         bool isHandled )
271*cdf0e10cSrcweir     {
272*cdf0e10cSrcweir         Reference<XCommandProcessor> xComProc(pContent);
273*cdf0e10cSrcweir         Any aAny;
274*cdf0e10cSrcweir         IOErrorCode ioErrorCode;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         if( errorCode ==  TASKHANDLER_UNSUPPORTED_COMMAND )
277*cdf0e10cSrcweir         {
278*cdf0e10cSrcweir             aAny <<= UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
279*cdf0e10cSrcweir             cancelCommandExecution( aAny,xEnv );
280*cdf0e10cSrcweir         }
281*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT ||
282*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT ||
283*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_OPEN_ARGUMENT              ||
284*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_DELETE_ARGUMENT            ||
285*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_TRANSFER_ARGUMENT          ||
286*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT            ||
287*cdf0e10cSrcweir                  errorCode == TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT )
288*cdf0e10cSrcweir         {
289*cdf0e10cSrcweir             IllegalArgumentException excep;
290*cdf0e10cSrcweir             excep.ArgumentPosition = 0;
291*cdf0e10cSrcweir             aAny <<= excep;
292*cdf0e10cSrcweir             cancelCommandExecution(
293*cdf0e10cSrcweir                 aAny,xEnv);
294*cdf0e10cSrcweir         }
295*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_UNSUPPORTED_OPEN_MODE )
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             UnsupportedOpenModeException excep;
298*cdf0e10cSrcweir             excep.Mode = sal::static_int_cast< sal_Int16 >(minorCode);
299*cdf0e10cSrcweir             aAny <<= excep;
300*cdf0e10cSrcweir                 cancelCommandExecution( aAny,xEnv );
301*cdf0e10cSrcweir         }
302*cdf0e10cSrcweir         else if(errorCode == TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND  ||
303*cdf0e10cSrcweir                 errorCode == TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND ||
304*cdf0e10cSrcweir                 errorCode == TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND )
305*cdf0e10cSrcweir         {
306*cdf0e10cSrcweir             // What to do here?
307*cdf0e10cSrcweir         }
308*cdf0e10cSrcweir         else if(
309*cdf0e10cSrcweir             // error in opening file
310*cdf0e10cSrcweir             errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE ||
311*cdf0e10cSrcweir             // error in opening file
312*cdf0e10cSrcweir             errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_WRITE     ||
313*cdf0e10cSrcweir             // error in opening file
314*cdf0e10cSrcweir             errorCode == TASKHANDLING_OPEN_FOR_STREAM            ||
315*cdf0e10cSrcweir             // error in opening file
316*cdf0e10cSrcweir             errorCode == TASKHANDLING_OPEN_FOR_INPUTSTREAM       ||
317*cdf0e10cSrcweir             // error in opening file
318*cdf0e10cSrcweir             errorCode == TASKHANDLING_OPEN_FILE_FOR_PAGING )
319*cdf0e10cSrcweir         {
320*cdf0e10cSrcweir             switch( minorCode )
321*cdf0e10cSrcweir             {
322*cdf0e10cSrcweir                 case FileBase::E_NAMETOOLONG:
323*cdf0e10cSrcweir                     // pathname was too long
324*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
325*cdf0e10cSrcweir                     break;
326*cdf0e10cSrcweir                 case FileBase::E_NXIO:
327*cdf0e10cSrcweir                     // No such device or address
328*cdf0e10cSrcweir                 case FileBase::E_NODEV:
329*cdf0e10cSrcweir                     // No such device
330*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_DEVICE;
331*cdf0e10cSrcweir                     break;
332*cdf0e10cSrcweir                 case FileBase::E_NOENT:
333*cdf0e10cSrcweir                     // No such file or directory
334*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
335*cdf0e10cSrcweir                     break;
336*cdf0e10cSrcweir                 case FileBase::E_ROFS:
337*cdf0e10cSrcweir                     // #i4735# handle ROFS transparently as ACCESS_DENIED
338*cdf0e10cSrcweir                 case FileBase::E_ACCES:
339*cdf0e10cSrcweir                     // permission denied<P>
340*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
341*cdf0e10cSrcweir                     break;
342*cdf0e10cSrcweir                 case FileBase::E_ISDIR:
343*cdf0e10cSrcweir                     // Is a directory<p>
344*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NO_FILE;
345*cdf0e10cSrcweir                     break;
346*cdf0e10cSrcweir                 case FileBase::E_NOTREADY:
347*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
348*cdf0e10cSrcweir                     break;
349*cdf0e10cSrcweir                 case FileBase::E_MFILE:
350*cdf0e10cSrcweir                     // too many open files used by the process
351*cdf0e10cSrcweir                 case FileBase::E_NFILE:
352*cdf0e10cSrcweir                     // too many open files in the system
353*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
354*cdf0e10cSrcweir                     break;
355*cdf0e10cSrcweir                 case FileBase::E_INVAL:
356*cdf0e10cSrcweir                     // the format of the parameters was not valid
357*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
358*cdf0e10cSrcweir                     break;
359*cdf0e10cSrcweir                 case FileBase::E_NOMEM:
360*cdf0e10cSrcweir                     // not enough memory for allocating structures
361*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
362*cdf0e10cSrcweir                     break;
363*cdf0e10cSrcweir                 case FileBase::E_BUSY:
364*cdf0e10cSrcweir                     // Text file busy
365*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
366*cdf0e10cSrcweir                     break;
367*cdf0e10cSrcweir                 case FileBase::E_AGAIN:
368*cdf0e10cSrcweir                     // Operation would block
369*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
370*cdf0e10cSrcweir                     break;
371*cdf0e10cSrcweir                 case FileBase::E_NOLCK:  // No record locks available
372*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
373*cdf0e10cSrcweir                     break;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir                 case FileBase::E_FAULT: // Bad address
376*cdf0e10cSrcweir                 case FileBase::E_LOOP:	// Too many symbolic links encountered
377*cdf0e10cSrcweir                 case FileBase::E_NOSPC:	// No space left on device
378*cdf0e10cSrcweir                 case FileBase::E_INTR:	// function call was interrupted
379*cdf0e10cSrcweir                 case FileBase::E_IO:	// I/O error
380*cdf0e10cSrcweir                 case FileBase::E_MULTIHOP:		// Multihop attempted
381*cdf0e10cSrcweir                 case FileBase::E_NOLINK:	    // Link has been severed
382*cdf0e10cSrcweir                 default:
383*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
384*cdf0e10cSrcweir                     break;
385*cdf0e10cSrcweir             }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir             cancelCommandExecution(
388*cdf0e10cSrcweir                 ioErrorCode,
389*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
390*cdf0e10cSrcweir                 xEnv,
391*cdf0e10cSrcweir                 rtl::OUString(
392*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
393*cdf0e10cSrcweir                         "an error occured during file opening")),
394*cdf0e10cSrcweir                 xComProc);
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_OPEN_FOR_DIRECTORYLISTING  ||
397*cdf0e10cSrcweir                  errorCode == TASKHANDLING_OPENDIRECTORY_FOR_REMOVE )
398*cdf0e10cSrcweir         {
399*cdf0e10cSrcweir             switch( minorCode )
400*cdf0e10cSrcweir             {
401*cdf0e10cSrcweir                 case FileBase::E_INVAL:
402*cdf0e10cSrcweir                     // the format of the parameters was not valid
403*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
404*cdf0e10cSrcweir                     break;
405*cdf0e10cSrcweir                 case FileBase::E_NOENT:
406*cdf0e10cSrcweir                     // the specified path doesn't exist
407*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
408*cdf0e10cSrcweir                     break;
409*cdf0e10cSrcweir                 case FileBase::E_NOTDIR:
410*cdf0e10cSrcweir                     // the specified path is not an directory
411*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NO_DIRECTORY;
412*cdf0e10cSrcweir                     break;
413*cdf0e10cSrcweir                 case FileBase::E_NOMEM:
414*cdf0e10cSrcweir                     // not enough memory for allocating structures
415*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
416*cdf0e10cSrcweir                     break;
417*cdf0e10cSrcweir                 case FileBase::E_ROFS:
418*cdf0e10cSrcweir                     // #i4735# handle ROFS transparently as ACCESS_DENIED
419*cdf0e10cSrcweir                 case FileBase::E_ACCES:		     // permission denied
420*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
421*cdf0e10cSrcweir                     break;
422*cdf0e10cSrcweir                 case FileBase::E_NOTREADY:
423*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
424*cdf0e10cSrcweir                     break;
425*cdf0e10cSrcweir                 case FileBase::E_MFILE:
426*cdf0e10cSrcweir                     // too many open files used by the process
427*cdf0e10cSrcweir                 case FileBase::E_NFILE:
428*cdf0e10cSrcweir                     // too many open files in the system
429*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
430*cdf0e10cSrcweir                     break;
431*cdf0e10cSrcweir                 case FileBase::E_NAMETOOLONG:
432*cdf0e10cSrcweir                     // File name too long
433*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
434*cdf0e10cSrcweir                     break;
435*cdf0e10cSrcweir                 case FileBase::E_LOOP:
436*cdf0e10cSrcweir                     // Too many symbolic links encountered<p>
437*cdf0e10cSrcweir                 default:
438*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
439*cdf0e10cSrcweir                     break;
440*cdf0e10cSrcweir             }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir             cancelCommandExecution(
443*cdf0e10cSrcweir                 ioErrorCode,
444*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
445*cdf0e10cSrcweir                 xEnv,
446*cdf0e10cSrcweir                 rtl::OUString(
447*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
448*cdf0e10cSrcweir                         "an error occured during opening a directory")),
449*cdf0e10cSrcweir                 xComProc);
450*cdf0e10cSrcweir         }
451*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_NOTCONNECTED_FOR_WRITE          ||
452*cdf0e10cSrcweir                  errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE    ||
453*cdf0e10cSrcweir                  errorCode == TASKHANDLING_IOEXCEPTION_FOR_WRITE           ||
454*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NOTCONNECTED_FOR_PAGING         ||
455*cdf0e10cSrcweir                  errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING   ||
456*cdf0e10cSrcweir                  errorCode == TASKHANDLING_IOEXCEPTION_FOR_PAGING         )
457*cdf0e10cSrcweir         {
458*cdf0e10cSrcweir             ioErrorCode = IOErrorCode_UNKNOWN;
459*cdf0e10cSrcweir             cancelCommandExecution(
460*cdf0e10cSrcweir                 ioErrorCode,
461*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
462*cdf0e10cSrcweir                 xEnv,
463*cdf0e10cSrcweir                 rtl::OUString(
464*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
465*cdf0e10cSrcweir                         "an error occured writing or reading from a file")),
466*cdf0e10cSrcweir                 xComProc );
467*cdf0e10cSrcweir         }
468*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_NO_SPACE )
469*cdf0e10cSrcweir         {
470*cdf0e10cSrcweir             ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
471*cdf0e10cSrcweir             cancelCommandExecution(
472*cdf0e10cSrcweir                 ioErrorCode,
473*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
474*cdf0e10cSrcweir                 xEnv,
475*cdf0e10cSrcweir                 rtl::OUString(
476*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
477*cdf0e10cSrcweir                         "device full")),
478*cdf0e10cSrcweir                 xComProc);
479*cdf0e10cSrcweir         }
480*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_WRITE ||
481*cdf0e10cSrcweir                  errorCode == TASKHANDLING_READING_FILE_FOR_PAGING )
482*cdf0e10cSrcweir         {
483*cdf0e10cSrcweir             switch( minorCode )
484*cdf0e10cSrcweir             {
485*cdf0e10cSrcweir                 case FileBase::E_INVAL:
486*cdf0e10cSrcweir                     // the format of the parameters was not valid
487*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
488*cdf0e10cSrcweir                     break;
489*cdf0e10cSrcweir                 case FileBase::E_FBIG:
490*cdf0e10cSrcweir                     // File too large
491*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_CANT_WRITE;
492*cdf0e10cSrcweir                     break;
493*cdf0e10cSrcweir                 case FileBase::E_NOSPC:
494*cdf0e10cSrcweir                     // No space left on device
495*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
496*cdf0e10cSrcweir                     break;
497*cdf0e10cSrcweir                 case FileBase::E_NXIO:
498*cdf0e10cSrcweir                     // No such device or address
499*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_DEVICE;
500*cdf0e10cSrcweir                     break;
501*cdf0e10cSrcweir                 case FileBase::E_NOLINK:
502*cdf0e10cSrcweir                     // Link has been severed
503*cdf0e10cSrcweir                 case FileBase::E_ISDIR:
504*cdf0e10cSrcweir                     // Is a directory
505*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NO_FILE;
506*cdf0e10cSrcweir                     break;
507*cdf0e10cSrcweir                 case FileBase::E_AGAIN:
508*cdf0e10cSrcweir                     // Operation would block
509*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
510*cdf0e10cSrcweir                     break;
511*cdf0e10cSrcweir                 case FileBase::E_TIMEDOUT:
512*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
513*cdf0e10cSrcweir                     break;
514*cdf0e10cSrcweir                 case FileBase::E_NOLCK:  // No record locks available
515*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
516*cdf0e10cSrcweir                     break;
517*cdf0e10cSrcweir                 case FileBase::E_IO:	 // I/O error
518*cdf0e10cSrcweir                 case FileBase::E_BADF:	 // Bad file
519*cdf0e10cSrcweir                 case FileBase::E_FAULT:	 // Bad address
520*cdf0e10cSrcweir                 case FileBase::E_INTR:	 // function call was interrupted
521*cdf0e10cSrcweir                 default:
522*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
523*cdf0e10cSrcweir                     break;
524*cdf0e10cSrcweir             }
525*cdf0e10cSrcweir             cancelCommandExecution(
526*cdf0e10cSrcweir                 ioErrorCode,
527*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
528*cdf0e10cSrcweir                 xEnv,
529*cdf0e10cSrcweir                 rtl::OUString(
530*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
531*cdf0e10cSrcweir                         "an error occured during opening a file")),
532*cdf0e10cSrcweir                 xComProc);
533*cdf0e10cSrcweir         }
534*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND ||
535*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND )
536*cdf0e10cSrcweir         {
537*cdf0e10cSrcweir             Sequence< ::rtl::OUString > aSeq( 1 );
538*cdf0e10cSrcweir             aSeq[0] =
539*cdf0e10cSrcweir                 ( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND )  ?
540*cdf0e10cSrcweir                 rtl::OUString::createFromAscii( "Title" )               :
541*cdf0e10cSrcweir                 rtl::OUString::createFromAscii( "ContentType" );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir             aAny <<= MissingPropertiesException(
544*cdf0e10cSrcweir                 rtl::OUString(
545*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
546*cdf0e10cSrcweir                         "a property is missing necessary"
547*cdf0e10cSrcweir                         "to create a content")),
548*cdf0e10cSrcweir                 xComProc,
549*cdf0e10cSrcweir                 aSeq);
550*cdf0e10cSrcweir             cancelCommandExecution(aAny,xEnv);
551*cdf0e10cSrcweir         }
552*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_FILESIZE_FOR_WRITE )
553*cdf0e10cSrcweir         {
554*cdf0e10cSrcweir             switch( minorCode )
555*cdf0e10cSrcweir             {
556*cdf0e10cSrcweir                 case FileBase::E_INVAL:
557*cdf0e10cSrcweir                     // the format of the parameters was not valid
558*cdf0e10cSrcweir                 case FileBase::E_OVERFLOW:
559*cdf0e10cSrcweir                     // The resulting file offset would be a value which cannot
560*cdf0e10cSrcweir                     // be represented correctly for regular files
561*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
562*cdf0e10cSrcweir                     break;
563*cdf0e10cSrcweir                 default:
564*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
565*cdf0e10cSrcweir                     break;
566*cdf0e10cSrcweir             }
567*cdf0e10cSrcweir             cancelCommandExecution(
568*cdf0e10cSrcweir                 ioErrorCode,
569*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
570*cdf0e10cSrcweir                 xEnv,
571*cdf0e10cSrcweir                 rtl::OUString(
572*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
573*cdf0e10cSrcweir                         "there were problems with the filesize")),
574*cdf0e10cSrcweir                 xComProc);
575*cdf0e10cSrcweir         }
576*cdf0e10cSrcweir         else if(errorCode == TASKHANDLING_INPUTSTREAM_FOR_WRITE)
577*cdf0e10cSrcweir         {
578*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
579*cdf0e10cSrcweir             aAny <<=
580*cdf0e10cSrcweir                 MissingInputStreamException(
581*cdf0e10cSrcweir                     rtl::OUString(
582*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
583*cdf0e10cSrcweir                             "the inputstream is missing necessary"
584*cdf0e10cSrcweir                             "to create a content")),
585*cdf0e10cSrcweir                     xContext);
586*cdf0e10cSrcweir             cancelCommandExecution(aAny,xEnv);
587*cdf0e10cSrcweir         }
588*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE )
589*cdf0e10cSrcweir             // Overwrite = false and file exists
590*cdf0e10cSrcweir         {
591*cdf0e10cSrcweir             NameClashException excep;
592*cdf0e10cSrcweir             excep.Name = getTitle(aUncPath);
593*cdf0e10cSrcweir             excep.Classification = InteractionClassification_ERROR;
594*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
595*cdf0e10cSrcweir             excep.Context = xContext;
596*cdf0e10cSrcweir             excep.Message = rtl::OUString(
597*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
598*cdf0e10cSrcweir                     "file exists and overwrite forbidden"));
599*cdf0e10cSrcweir             aAny <<= excep;
600*cdf0e10cSrcweir             cancelCommandExecution( aAny,xEnv );
601*cdf0e10cSrcweir         }
602*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR )
603*cdf0e10cSrcweir         {
604*cdf0e10cSrcweir             InteractiveAugmentedIOException excep;
605*cdf0e10cSrcweir             excep.Code = IOErrorCode_INVALID_CHARACTER;
606*cdf0e10cSrcweir             PropertyValue prop;
607*cdf0e10cSrcweir             prop.Name = rtl::OUString::createFromAscii("ResourceName");
608*cdf0e10cSrcweir             prop.Handle = -1;
609*cdf0e10cSrcweir             rtl::OUString m_aClashingName(
610*cdf0e10cSrcweir                 rtl::Uri::decode(
611*cdf0e10cSrcweir                     getTitle(aUncPath),
612*cdf0e10cSrcweir                     rtl_UriDecodeWithCharset,
613*cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8));
614*cdf0e10cSrcweir             prop.Value <<= m_aClashingName;
615*cdf0e10cSrcweir             Sequence<Any> seq(1);
616*cdf0e10cSrcweir             seq[0] <<= prop;
617*cdf0e10cSrcweir             excep.Arguments = seq;
618*cdf0e10cSrcweir             excep.Classification = InteractionClassification_ERROR;
619*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
620*cdf0e10cSrcweir             excep.Context = xContext;
621*cdf0e10cSrcweir             excep.Message = rtl::OUString(
622*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
623*cdf0e10cSrcweir                     "the name contained invalid characters"));
624*cdf0e10cSrcweir             if(isHandled)
625*cdf0e10cSrcweir                 throw excep;
626*cdf0e10cSrcweir             else {
627*cdf0e10cSrcweir                 aAny <<= excep;
628*cdf0e10cSrcweir                 cancelCommandExecution( aAny,xEnv );
629*cdf0e10cSrcweir             }
630*cdf0e10cSrcweir //              ioErrorCode = IOErrorCode_INVALID_CHARACTER;
631*cdf0e10cSrcweir //              cancelCommandExecution(
632*cdf0e10cSrcweir //                  ioErrorCode,
633*cdf0e10cSrcweir //                  generateErrorArguments(aUncPath),
634*cdf0e10cSrcweir //                  xEnv,
635*cdf0e10cSrcweir //                  rtl::OUString(
636*cdf0e10cSrcweir //                      RTL_CONSTASCII_USTRINGPARAM(
637*cdf0e10cSrcweir //                          "the name contained invalid characters")),
638*cdf0e10cSrcweir //                  xComProc );
639*cdf0e10cSrcweir         }
640*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR )
641*cdf0e10cSrcweir         {
642*cdf0e10cSrcweir             NameClashException excep;
643*cdf0e10cSrcweir             excep.Name = getTitle(aUncPath);
644*cdf0e10cSrcweir             excep.Classification = InteractionClassification_ERROR;
645*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
646*cdf0e10cSrcweir             excep.Context = xContext;
647*cdf0e10cSrcweir             excep.Message = rtl::OUString(
648*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
649*cdf0e10cSrcweir                     "folder exists and overwrite forbidden"));
650*cdf0e10cSrcweir             if(isHandled)
651*cdf0e10cSrcweir                 throw excep;
652*cdf0e10cSrcweir             else {
653*cdf0e10cSrcweir                 aAny <<= excep;
654*cdf0e10cSrcweir                 cancelCommandExecution( aAny,xEnv );
655*cdf0e10cSrcweir             }
656*cdf0e10cSrcweir //              ioErrorCode = IOErrorCode_ALREADY_EXISTING;
657*cdf0e10cSrcweir //              cancelCommandExecution(
658*cdf0e10cSrcweir //                  ioErrorCode,
659*cdf0e10cSrcweir //                  generateErrorArguments(aUncPath),
660*cdf0e10cSrcweir //                  xEnv,
661*cdf0e10cSrcweir //                  rtl::OUString(
662*cdf0e10cSrcweir //                      RTL_CONSTASCII_USTRINGPARAM(
663*cdf0e10cSrcweir //                          "the folder exists")),
664*cdf0e10cSrcweir //                  xComProc );
665*cdf0e10cSrcweir         }
666*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_ENSUREDIR_FOR_WRITE  ||
667*cdf0e10cSrcweir                  errorCode == TASKHANDLING_CREATEDIRECTORY_MKDIR )
668*cdf0e10cSrcweir         {
669*cdf0e10cSrcweir             switch( minorCode )
670*cdf0e10cSrcweir             {
671*cdf0e10cSrcweir             case FileBase::E_ACCES:
672*cdf0e10cSrcweir                 ioErrorCode = IOErrorCode_ACCESS_DENIED;
673*cdf0e10cSrcweir                 break;
674*cdf0e10cSrcweir             case FileBase::E_ROFS:
675*cdf0e10cSrcweir                 ioErrorCode = IOErrorCode_WRITE_PROTECTED;
676*cdf0e10cSrcweir                 break;
677*cdf0e10cSrcweir             case FileBase::E_NAMETOOLONG:
678*cdf0e10cSrcweir                 ioErrorCode = IOErrorCode_NAME_TOO_LONG;
679*cdf0e10cSrcweir                 break;
680*cdf0e10cSrcweir             default:
681*cdf0e10cSrcweir                 ioErrorCode = IOErrorCode_NOT_EXISTING_PATH;
682*cdf0e10cSrcweir                 break;
683*cdf0e10cSrcweir             }
684*cdf0e10cSrcweir             cancelCommandExecution(
685*cdf0e10cSrcweir                 ioErrorCode,
686*cdf0e10cSrcweir                 generateErrorArguments(getParentName(aUncPath)),
687*cdf0e10cSrcweir                 //TODO! ok to supply physical URL to getParentName()?
688*cdf0e10cSrcweir                 xEnv,
689*cdf0e10cSrcweir                 rtl::OUString(
690*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
691*cdf0e10cSrcweir                         "a folder could not be created")),
692*cdf0e10cSrcweir                 xComProc  );
693*cdf0e10cSrcweir         }
694*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE  ||
695*cdf0e10cSrcweir                  errorCode == TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE       ||
696*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE )
697*cdf0e10cSrcweir         {
698*cdf0e10cSrcweir             switch( minorCode )
699*cdf0e10cSrcweir             {
700*cdf0e10cSrcweir                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
701*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
702*cdf0e10cSrcweir                     break;
703*cdf0e10cSrcweir                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
704*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
705*cdf0e10cSrcweir                     break;
706*cdf0e10cSrcweir                 case FileBase::E_ROFS: // #i4735# handle ROFS transparently as ACCESS_DENIED
707*cdf0e10cSrcweir                 case FileBase::E_ACCES:		    // permission denied
708*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
709*cdf0e10cSrcweir                     break;
710*cdf0e10cSrcweir                 case FileBase::E_MFILE:		    // too many open files used by the process
711*cdf0e10cSrcweir                 case FileBase::E_NFILE:		    // too many open files in the system
712*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
713*cdf0e10cSrcweir                     break;
714*cdf0e10cSrcweir                 case FileBase::E_NOLINK:		// Link has been severed
715*cdf0e10cSrcweir                 case FileBase::E_NOENT:		    // No such file or directory
716*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
717*cdf0e10cSrcweir                     break;
718*cdf0e10cSrcweir                 case FileBase::E_NAMETOOLONG:	// File name too long
719*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
720*cdf0e10cSrcweir                     break;
721*cdf0e10cSrcweir                 case FileBase::E_NOTDIR:	 // A component of the path prefix of path is not a directory
722*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING_PATH;
723*cdf0e10cSrcweir                     break;
724*cdf0e10cSrcweir                 case FileBase::E_LOOP:			// Too many symbolic links encountered
725*cdf0e10cSrcweir                 case FileBase::E_IO:			// I/O error
726*cdf0e10cSrcweir                 case FileBase::E_MULTIHOP:		// Multihop attempted
727*cdf0e10cSrcweir                 case FileBase::E_FAULT:		    // Bad address
728*cdf0e10cSrcweir                 case FileBase::E_INTR:			// function call was interrupted
729*cdf0e10cSrcweir                 case FileBase::E_NOSYS:         // Function not implemented
730*cdf0e10cSrcweir                 case FileBase::E_NOSPC:		    // No space left on device
731*cdf0e10cSrcweir                 case FileBase::E_NXIO:			// No such device or address
732*cdf0e10cSrcweir                 case FileBase::E_OVERFLOW:		// Value too large for defined data type
733*cdf0e10cSrcweir                 case FileBase::E_BADF:			// Invalid oslDirectoryItem parameter
734*cdf0e10cSrcweir                 default:
735*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
736*cdf0e10cSrcweir                     break;
737*cdf0e10cSrcweir             }
738*cdf0e10cSrcweir             cancelCommandExecution(
739*cdf0e10cSrcweir                 ioErrorCode,
740*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
741*cdf0e10cSrcweir                 xEnv,
742*cdf0e10cSrcweir                 rtl::OUString(
743*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
744*cdf0e10cSrcweir                         "a file status object could not be filled")),
745*cdf0e10cSrcweir                 xComProc  );
746*cdf0e10cSrcweir         }
747*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_DELETEFILE_FOR_REMOVE  ||
748*cdf0e10cSrcweir                  errorCode == TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE )
749*cdf0e10cSrcweir         {
750*cdf0e10cSrcweir             switch( minorCode )
751*cdf0e10cSrcweir             {
752*cdf0e10cSrcweir                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
753*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
754*cdf0e10cSrcweir                     break;
755*cdf0e10cSrcweir                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
756*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
757*cdf0e10cSrcweir                     break;
758*cdf0e10cSrcweir                 case FileBase::E_ACCES:		    // Permission denied
759*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
760*cdf0e10cSrcweir                     break;
761*cdf0e10cSrcweir                 case FileBase::E_PERM:			// Operation not permitted
762*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
763*cdf0e10cSrcweir                     break;
764*cdf0e10cSrcweir                 case FileBase::E_NAMETOOLONG:	// File name too long
765*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
766*cdf0e10cSrcweir                     break;
767*cdf0e10cSrcweir                 case FileBase::E_NOLINK:		// Link has been severed
768*cdf0e10cSrcweir                 case FileBase::E_NOENT:	        // No such file or directory
769*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
770*cdf0e10cSrcweir                     break;
771*cdf0e10cSrcweir                 case FileBase::E_ISDIR:		    // Is a directory
772*cdf0e10cSrcweir                 case FileBase::E_ROFS:			// Read-only file system
773*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
774*cdf0e10cSrcweir                     break;
775*cdf0e10cSrcweir                 case FileBase::E_BUSY:			// Device or resource busy
776*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
777*cdf0e10cSrcweir                     break;
778*cdf0e10cSrcweir                 case FileBase::E_FAULT:		    // Bad address
779*cdf0e10cSrcweir                 case FileBase::E_LOOP:			// Too many symbolic links encountered
780*cdf0e10cSrcweir                 case FileBase::E_IO:			// I/O error
781*cdf0e10cSrcweir                 case FileBase::E_INTR:			// function call was interrupted
782*cdf0e10cSrcweir                 case FileBase::E_MULTIHOP:		// Multihop attempted
783*cdf0e10cSrcweir                 default:
784*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
785*cdf0e10cSrcweir                     break;
786*cdf0e10cSrcweir             }
787*cdf0e10cSrcweir             cancelCommandExecution(
788*cdf0e10cSrcweir                 ioErrorCode,
789*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
790*cdf0e10cSrcweir                 xEnv,
791*cdf0e10cSrcweir                 rtl::OUString(
792*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
793*cdf0e10cSrcweir                         "a file or directory could not be deleted")),
794*cdf0e10cSrcweir                 xComProc );
795*cdf0e10cSrcweir         }
796*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE         ||
797*cdf0e10cSrcweir                  errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT     ||
798*cdf0e10cSrcweir                  errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE         ||
799*cdf0e10cSrcweir                  errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT     ||
800*cdf0e10cSrcweir                  errorCode == TASKHANDLING_TRANSFER_DESTFILETYPE           ||
801*cdf0e10cSrcweir                  errorCode == TASKHANDLING_FILETYPE_FOR_REMOVE             ||
802*cdf0e10cSrcweir                  errorCode == TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE   ||
803*cdf0e10cSrcweir                  errorCode == TASKHANDLING_TRANSFER_INVALIDURL )
804*cdf0e10cSrcweir         {
805*cdf0e10cSrcweir             rtl::OUString aMsg;
806*cdf0e10cSrcweir             switch( minorCode )
807*cdf0e10cSrcweir             {
808*cdf0e10cSrcweir                 case FileBase::E_NOENT:	        // No such file or directory
809*cdf0e10cSrcweir                     if ( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE         ||
810*cdf0e10cSrcweir                          errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT     ||
811*cdf0e10cSrcweir                          errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE         ||
812*cdf0e10cSrcweir                          errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT )
813*cdf0e10cSrcweir                     {
814*cdf0e10cSrcweir                         ioErrorCode = IOErrorCode_NOT_EXISTING;
815*cdf0e10cSrcweir                         aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
816*cdf0e10cSrcweir                             "source file/folder does not exist"));
817*cdf0e10cSrcweir                         break;
818*cdf0e10cSrcweir                     }
819*cdf0e10cSrcweir                     else
820*cdf0e10cSrcweir                     {
821*cdf0e10cSrcweir                         ioErrorCode = IOErrorCode_GENERAL;
822*cdf0e10cSrcweir                         aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
823*cdf0e10cSrcweir                             "a general error during transfer command"));
824*cdf0e10cSrcweir                     break;
825*cdf0e10cSrcweir                     }
826*cdf0e10cSrcweir                 default:
827*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
828*cdf0e10cSrcweir                     aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
829*cdf0e10cSrcweir                         "a general error during transfer command"));
830*cdf0e10cSrcweir                     break;
831*cdf0e10cSrcweir             }
832*cdf0e10cSrcweir             cancelCommandExecution(
833*cdf0e10cSrcweir                 ioErrorCode,
834*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
835*cdf0e10cSrcweir                 xEnv,
836*cdf0e10cSrcweir                 aMsg,
837*cdf0e10cSrcweir                 xComProc );
838*cdf0e10cSrcweir         }
839*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_TRANSFER_ACCESSINGROOT )
840*cdf0e10cSrcweir         {
841*cdf0e10cSrcweir             ioErrorCode = IOErrorCode_WRITE_PROTECTED;
842*cdf0e10cSrcweir             cancelCommandExecution(
843*cdf0e10cSrcweir                 ioErrorCode,
844*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
845*cdf0e10cSrcweir                 xEnv,
846*cdf0e10cSrcweir                 rtl::OUString(
847*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
848*cdf0e10cSrcweir                         "accessing the root during transfer")),
849*cdf0e10cSrcweir                 xComProc );
850*cdf0e10cSrcweir         }
851*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_TRANSFER_INVALIDSCHEME )
852*cdf0e10cSrcweir         {
853*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir             aAny <<=
856*cdf0e10cSrcweir                 InteractiveBadTransferURLException(
857*cdf0e10cSrcweir                     rtl::OUString(
858*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
859*cdf0e10cSrcweir                             "bad tranfer url")),
860*cdf0e10cSrcweir                     xContext);
861*cdf0e10cSrcweir             cancelCommandExecution( aAny,xEnv );
862*cdf0e10cSrcweir         }
863*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_OVERWRITE_FOR_MOVE      ||
864*cdf0e10cSrcweir                  errorCode == TASKHANDLING_OVERWRITE_FOR_COPY      ||
865*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_MOVE  ||
866*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_COPY  ||
867*cdf0e10cSrcweir                  errorCode == TASKHANDLING_KEEPERROR_FOR_MOVE      ||
868*cdf0e10cSrcweir                  errorCode == TASKHANDLING_KEEPERROR_FOR_COPY      ||
869*cdf0e10cSrcweir                  errorCode == TASKHANDLING_RENAME_FOR_MOVE         ||
870*cdf0e10cSrcweir                  errorCode == TASKHANDLING_RENAME_FOR_COPY         ||
871*cdf0e10cSrcweir                  errorCode == TASKHANDLING_RENAMEMOVE_FOR_MOVE     ||
872*cdf0e10cSrcweir                  errorCode == TASKHANDLING_RENAMEMOVE_FOR_COPY    )
873*cdf0e10cSrcweir         {
874*cdf0e10cSrcweir             rtl::OUString aMsg(RTL_CONSTASCII_USTRINGPARAM(
875*cdf0e10cSrcweir                         "general error during transfer"));
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir             switch( minorCode )
878*cdf0e10cSrcweir             {
879*cdf0e10cSrcweir                 case FileBase::E_EXIST:
880*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ALREADY_EXISTING;
881*cdf0e10cSrcweir                     break;
882*cdf0e10cSrcweir                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
883*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
884*cdf0e10cSrcweir                     break;
885*cdf0e10cSrcweir                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
886*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
887*cdf0e10cSrcweir                     break;
888*cdf0e10cSrcweir                 case FileBase::E_ACCES:		    // Permission denied
889*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
890*cdf0e10cSrcweir                     break;
891*cdf0e10cSrcweir                 case FileBase::E_PERM:		    // Operation not permitted
892*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
893*cdf0e10cSrcweir                     break;
894*cdf0e10cSrcweir                 case FileBase::E_NAMETOOLONG:	// File name too long
895*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
896*cdf0e10cSrcweir                     break;
897*cdf0e10cSrcweir                 case FileBase::E_NOENT:         // No such file or directory
898*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
899*cdf0e10cSrcweir                     aMsg = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
900*cdf0e10cSrcweir                         "file/folder does not exist"));
901*cdf0e10cSrcweir                     break;
902*cdf0e10cSrcweir                 case FileBase::E_ROFS:			// Read-only file system<p>
903*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_NOT_EXISTING;
904*cdf0e10cSrcweir                     break;
905*cdf0e10cSrcweir                 default:
906*cdf0e10cSrcweir                     ioErrorCode = IOErrorCode_GENERAL;
907*cdf0e10cSrcweir                     break;
908*cdf0e10cSrcweir             }
909*cdf0e10cSrcweir             cancelCommandExecution(
910*cdf0e10cSrcweir                 ioErrorCode,
911*cdf0e10cSrcweir                 generateErrorArguments(aUncPath),
912*cdf0e10cSrcweir                 xEnv,
913*cdf0e10cSrcweir                 aMsg,
914*cdf0e10cSrcweir                 xComProc );
915*cdf0e10cSrcweir         }
916*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY   ||
917*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NAMECLASH_FOR_MOVE )
918*cdf0e10cSrcweir         {
919*cdf0e10cSrcweir             NameClashException excep;
920*cdf0e10cSrcweir             excep.Name = getTitle(aUncPath);
921*cdf0e10cSrcweir             excep.Classification = InteractionClassification_ERROR;
922*cdf0e10cSrcweir             Reference<XInterface> xContext(xComProc,UNO_QUERY);
923*cdf0e10cSrcweir             excep.Context = xContext;
924*cdf0e10cSrcweir             excep.Message = rtl::OUString(
925*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
926*cdf0e10cSrcweir                     "name clash during copy or move"));
927*cdf0e10cSrcweir             aAny <<= excep;
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir             cancelCommandExecution(aAny,xEnv);
930*cdf0e10cSrcweir         }
931*cdf0e10cSrcweir         else if( errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE   ||
932*cdf0e10cSrcweir                  errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY )
933*cdf0e10cSrcweir         {
934*cdf0e10cSrcweir             Reference<XInterface> xContext(
935*cdf0e10cSrcweir                 xComProc,UNO_QUERY);
936*cdf0e10cSrcweir             UnsupportedNameClashException excep;
937*cdf0e10cSrcweir             excep.NameClash = minorCode;
938*cdf0e10cSrcweir             excep.Context = xContext;
939*cdf0e10cSrcweir             excep.Message = rtl::OUString(
940*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
941*cdf0e10cSrcweir                     "name clash value not supported during copy or move"));
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir             aAny <<= excep;
944*cdf0e10cSrcweir             cancelCommandExecution(aAny,xEnv);
945*cdf0e10cSrcweir         }
946*cdf0e10cSrcweir         else
947*cdf0e10cSrcweir         {
948*cdf0e10cSrcweir             // case TASKHANDLER_NO_ERROR:
949*cdf0e10cSrcweir             return;
950*cdf0e10cSrcweir         }
951*cdf0e10cSrcweir     }
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir }   // end namespace fileaccess
955