xref: /aoo42x/main/ucb/source/ucp/file/filinsreq.hxx (revision 6df1ea1f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _FILINSREQ_HXX_
26 #define _FILINSREQ_HXX_
27 
28 #include <cppuhelper/weak.hxx>
29 #include <ucbhelper/macros.hxx>
30 #include <rtl/ustring.hxx>
31 #include <com/sun/star/uno/XInterface.hpp>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 #include <com/sun/star/task/XInteractionAbort.hpp>
34 #include <com/sun/star/ucb/XInteractionSupplyName.hpp>
35 #include <com/sun/star/task/XInteractionRequest.hpp>
36 
37 
38 namespace fileaccess {
39 
40 
41 	class shell;
42 
43 
44 	class XInteractionSupplyNameImpl
45 		: public cppu::OWeakObject,
46 		  public com::sun::star::lang::XTypeProvider,
47 		  public com::sun::star::ucb::XInteractionSupplyName
48 	{
49 	public:
50 
XInteractionSupplyNameImpl()51 		XInteractionSupplyNameImpl()
52 			: m_bSelected(false)
53 		{
54 		}
55 
56 		virtual com::sun::star::uno::Any SAL_CALL
57 		queryInterface(
58 			const com::sun::star::uno::Type& rType )
59 			throw( com::sun::star::uno::RuntimeException);
60 
61 		virtual void SAL_CALL
62 		acquire(
63 			void )
64 			throw();
65 
66 		virtual void SAL_CALL
67 		release(
68 			void )
69 			throw();
70 
71 
72 		// XTypeProvider
73 
XTYPEPROVIDER_DECL()74 		XTYPEPROVIDER_DECL()
75 
76 
77 		virtual void SAL_CALL select()
78 			throw (::com::sun::star::uno::RuntimeException)
79 		{
80 			m_bSelected = true;
81 		}
82 
setName(const::rtl::OUString & Name)83 	    void SAL_CALL setName(const ::rtl::OUString& Name)
84 			throw(::com::sun::star::uno::RuntimeException)
85 		{
86 			m_aNewName = Name;
87 		}
88 
getName() const89 		rtl::OUString getName() const
90 		{
91 			return m_aNewName;
92 		}
93 
isSelected() const94 		bool isSelected() const
95 		{
96 			return m_bSelected;
97 		}
98 
99 	private:
100 
101 		bool          m_bSelected;
102 		rtl::OUString m_aNewName;
103 	};
104 
105 
106 
107 	class XInteractionAbortImpl
108 		: public cppu::OWeakObject,
109 		  public com::sun::star::lang::XTypeProvider,
110 		  public com::sun::star::task::XInteractionAbort
111 	{
112 	public:
113 
XInteractionAbortImpl()114 		XInteractionAbortImpl()
115 			: m_bSelected(false)
116 		{
117 		}
118 
119 		virtual com::sun::star::uno::Any SAL_CALL
120 		queryInterface(
121 			const com::sun::star::uno::Type& rType )
122 			throw( com::sun::star::uno::RuntimeException);
123 
124 		virtual void SAL_CALL
125 		acquire(
126 			void )
127 			throw();
128 
129 		virtual void SAL_CALL
130 		release(
131 			void )
132 			throw();
133 
134 
135 		// XTypeProvider
136 
XTYPEPROVIDER_DECL()137 		XTYPEPROVIDER_DECL()
138 
139 
140 	    virtual void SAL_CALL select()
141 			throw (::com::sun::star::uno::RuntimeException)
142 		{
143 			m_bSelected = true;
144 		}
145 
146 
isSelected() const147 		bool isSelected() const
148 		{
149 			return m_bSelected;
150 		}
151 
152 	private:
153 
154 		bool          m_bSelected;
155 	};
156 
157 
158 
159 	class XInteractionRequestImpl
160 		: public cppu::OWeakObject,
161 		  public com::sun::star::lang::XTypeProvider,
162 		  public com::sun::star::task::XInteractionRequest
163 	{
164 	public:
165 
166 		XInteractionRequestImpl(
167             const rtl::OUString& aClashingName,
168             const com::sun::star::uno::Reference<
169             com::sun::star::uno::XInterface>& xOrigin,
170 			shell* pShell,
171 			sal_Int32 CommandId);
172 
173 		virtual com::sun::star::uno::Any SAL_CALL
174 		queryInterface(
175 			const com::sun::star::uno::Type& rType )
176 			throw( com::sun::star::uno::RuntimeException);
177 
178 		virtual void SAL_CALL
179 		acquire(
180 			void )
181 			throw();
182 
183 		virtual void SAL_CALL
184 		release(
185 			void )
186 			throw();
187 
188 
189 		// XTypeProvider
190 
191 		XTYPEPROVIDER_DECL()
192 
193 		::com::sun::star::uno::Any SAL_CALL getRequest(  )
194 			throw (::com::sun::star::uno::RuntimeException);
195 
196 		com::sun::star::uno::Sequence<
197             com::sun::star::uno::Reference<
198             com::sun::star::task::XInteractionContinuation > > SAL_CALL
getContinuations()199 		getContinuations(  )
200 			throw (::com::sun::star::uno::RuntimeException)
201 		{
202 			return m_aSeq;
203 		}
204 
aborted() const205 		bool aborted() const
206 		{
207 			return p2->isSelected();
208 		}
209 
newName() const210 		rtl::OUString newName() const
211 		{
212 			if( p1->isSelected() )
213 				return p1->getName();
214 			else
215 				return rtl::OUString();
216 		}
217 
218 	private:
219 
220 		XInteractionSupplyNameImpl* p1;
221 		XInteractionAbortImpl* p2;
222 		sal_Int32 m_nErrorCode,m_nMinorError;
223 
224 		com::sun::star::uno::Sequence<
225             com::sun::star::uno::Reference<
226             com::sun::star::task::XInteractionContinuation > > m_aSeq;
227 
228         rtl::OUString m_aClashingName;
229         com::sun::star::uno::Reference<
230             com::sun::star::uno::XInterface> m_xOrigin;
231 	};
232 
233 }
234 
235 
236 #endif
237