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 :
41 : void SAL_CALL
42 16 : XInteractionSupplyNameImpl::acquire( void )
43 : throw()
44 : {
45 16 : OWeakObject::acquire();
46 16 : }
47 :
48 :
49 :
50 : void SAL_CALL
51 16 : XInteractionSupplyNameImpl::release( void )
52 : throw()
53 : {
54 16 : OWeakObject::release();
55 16 : }
56 :
57 :
58 :
59 : Any SAL_CALL
60 0 : XInteractionSupplyNameImpl::queryInterface( const Type& rType )
61 : throw( RuntimeException )
62 : {
63 : Any aRet = cppu::queryInterface( rType,
64 : (static_cast< lang::XTypeProvider* >(this)),
65 0 : (static_cast< XInteractionSupplyName* >(this)) );
66 0 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
67 : }
68 :
69 :
70 : //////////////////////////////////////////////////////////////////////////////////////////
71 : // XTypeProvider
72 : //////////////////////////////////////////////////////////////////////////////////////////
73 :
74 0 : XTYPEPROVIDER_IMPL_2( XInteractionSupplyNameImpl,
75 : XTypeProvider,
76 : XInteractionSupplyName )
77 :
78 :
79 :
80 : void SAL_CALL
81 16 : XInteractionAbortImpl::acquire( void )
82 : throw()
83 : {
84 16 : OWeakObject::acquire();
85 16 : }
86 :
87 :
88 :
89 : void SAL_CALL
90 16 : XInteractionAbortImpl::release( void )
91 : throw()
92 : {
93 16 : OWeakObject::release();
94 16 : }
95 :
96 :
97 :
98 : Any SAL_CALL
99 0 : XInteractionAbortImpl::queryInterface( const Type& rType )
100 : throw( RuntimeException )
101 : {
102 : Any aRet = cppu::queryInterface( rType,
103 : (static_cast< lang::XTypeProvider* >(this)),
104 0 : (static_cast< XInteractionAbort* >(this)) );
105 0 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
106 : }
107 :
108 :
109 : //////////////////////////////////////////////////////////////////////////////////////////
110 : // XTypeProvider
111 : //////////////////////////////////////////////////////////////////////////////////////////
112 :
113 0 : XTYPEPROVIDER_IMPL_2( XInteractionAbortImpl,
114 : XTypeProvider,
115 : XInteractionAbort )
116 :
117 :
118 :
119 8 : XInteractionRequestImpl::XInteractionRequestImpl(
120 : const rtl::OUString& aClashingName,
121 : const Reference<XInterface>& xOrigin,
122 : shell *pShell,sal_Int32 CommandId)
123 8 : : p1( new XInteractionSupplyNameImpl ),
124 8 : p2( new XInteractionAbortImpl ),
125 : m_nErrorCode(0),
126 : m_nMinorError(0),
127 : m_aSeq( 2 ),
128 : m_aClashingName(aClashingName),
129 24 : m_xOrigin(xOrigin)
130 : {
131 8 : if( pShell )
132 8 : pShell->retrieveError(CommandId,m_nErrorCode,m_nMinorError);
133 8 : m_aSeq[0] = Reference<XInteractionContinuation>(p1);
134 8 : m_aSeq[1] = Reference<XInteractionContinuation>(p2);
135 8 : }
136 :
137 :
138 : void SAL_CALL
139 8 : XInteractionRequestImpl::acquire( void )
140 : throw()
141 : {
142 8 : OWeakObject::acquire();
143 8 : }
144 :
145 :
146 :
147 : void SAL_CALL
148 8 : XInteractionRequestImpl::release( void )
149 : throw()
150 : {
151 8 : OWeakObject::release();
152 8 : }
153 :
154 :
155 :
156 : Any SAL_CALL
157 0 : XInteractionRequestImpl::queryInterface( const Type& rType )
158 : throw( RuntimeException )
159 : {
160 : Any aRet =
161 : cppu::queryInterface(
162 : rType,
163 : (static_cast< lang::XTypeProvider* >(this)),
164 0 : (static_cast< XInteractionRequest* >(this)) );
165 0 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
166 : }
167 :
168 :
169 : //////////////////////////////////////////////////////////////////////////////////////////
170 : // XTypeProvider
171 : //////////////////////////////////////////////////////////////////////////////////////////
172 :
173 0 : XTYPEPROVIDER_IMPL_2( XInteractionRequestImpl,
174 : XTypeProvider,
175 : XInteractionRequest )
176 :
177 :
178 : Any SAL_CALL
179 0 : XInteractionRequestImpl::getRequest()
180 : throw(RuntimeException)
181 : {
182 0 : Any aAny;
183 0 : if(m_nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
184 : {
185 0 : NameClashException excep;
186 0 : excep.Name = m_aClashingName;
187 0 : excep.Classification = InteractionClassification_ERROR;
188 0 : excep.Context = m_xOrigin;
189 0 : excep.Message = rtl::OUString( "folder exists and overwritte forbidden");
190 0 : aAny <<= excep;
191 : }
192 0 : else if(m_nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
193 : {
194 0 : InteractiveAugmentedIOException excep;
195 0 : excep.Code = IOErrorCode_INVALID_CHARACTER;
196 0 : PropertyValue prop;
197 0 : prop.Name = rtl::OUString("ResourceName");
198 0 : prop.Handle = -1;
199 0 : prop.Value <<= m_aClashingName;
200 0 : Sequence<Any> seq(1);
201 0 : seq[0] <<= prop;
202 0 : excep.Arguments = seq;
203 0 : excep.Classification = InteractionClassification_ERROR;
204 0 : excep.Context = m_xOrigin;
205 0 : excep.Message = rtl::OUString( "the name contained invalid characters");
206 0 : aAny <<= excep;
207 :
208 : }
209 0 : return aAny;
210 : }
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|