xref: /trunk/main/ucb/source/ucp/file/filinsreq.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _FILINSREQ_HXX_
30 #define _FILINSREQ_HXX_
31 
32 #include <cppuhelper/weak.hxx>
33 #include <ucbhelper/macros.hxx>
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/uno/XInterface.hpp>
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <com/sun/star/task/XInteractionAbort.hpp>
38 #include <com/sun/star/ucb/XInteractionSupplyName.hpp>
39 #include <com/sun/star/task/XInteractionRequest.hpp>
40 
41 
42 namespace fileaccess {
43 
44 
45     class shell;
46 
47 
48     class XInteractionSupplyNameImpl
49         : public cppu::OWeakObject,
50           public com::sun::star::lang::XTypeProvider,
51           public com::sun::star::ucb::XInteractionSupplyName
52     {
53     public:
54 
55         XInteractionSupplyNameImpl()
56             : m_bSelected(false)
57         {
58         }
59 
60         virtual com::sun::star::uno::Any SAL_CALL
61         queryInterface(
62             const com::sun::star::uno::Type& rType )
63             throw( com::sun::star::uno::RuntimeException);
64 
65         virtual void SAL_CALL
66         acquire(
67             void )
68             throw();
69 
70         virtual void SAL_CALL
71         release(
72             void )
73             throw();
74 
75 
76         // XTypeProvider
77 
78         XTYPEPROVIDER_DECL()
79 
80 
81         virtual void SAL_CALL select()
82             throw (::com::sun::star::uno::RuntimeException)
83         {
84             m_bSelected = true;
85         }
86 
87         void SAL_CALL setName(const ::rtl::OUString& Name)
88             throw(::com::sun::star::uno::RuntimeException)
89         {
90             m_aNewName = Name;
91         }
92 
93         rtl::OUString getName() const
94         {
95             return m_aNewName;
96         }
97 
98         bool isSelected() const
99         {
100             return m_bSelected;
101         }
102 
103     private:
104 
105         bool          m_bSelected;
106         rtl::OUString m_aNewName;
107     };
108 
109 
110 
111     class XInteractionAbortImpl
112         : public cppu::OWeakObject,
113           public com::sun::star::lang::XTypeProvider,
114           public com::sun::star::task::XInteractionAbort
115     {
116     public:
117 
118         XInteractionAbortImpl()
119             : m_bSelected(false)
120         {
121         }
122 
123         virtual com::sun::star::uno::Any SAL_CALL
124         queryInterface(
125             const com::sun::star::uno::Type& rType )
126             throw( com::sun::star::uno::RuntimeException);
127 
128         virtual void SAL_CALL
129         acquire(
130             void )
131             throw();
132 
133         virtual void SAL_CALL
134         release(
135             void )
136             throw();
137 
138 
139         // XTypeProvider
140 
141         XTYPEPROVIDER_DECL()
142 
143 
144         virtual void SAL_CALL select()
145             throw (::com::sun::star::uno::RuntimeException)
146         {
147             m_bSelected = true;
148         }
149 
150 
151         bool isSelected() const
152         {
153             return m_bSelected;
154         }
155 
156     private:
157 
158         bool          m_bSelected;
159     };
160 
161 
162 
163     class XInteractionRequestImpl
164         : public cppu::OWeakObject,
165           public com::sun::star::lang::XTypeProvider,
166           public com::sun::star::task::XInteractionRequest
167     {
168     public:
169 
170         XInteractionRequestImpl(
171             const rtl::OUString& aClashingName,
172             const com::sun::star::uno::Reference<
173             com::sun::star::uno::XInterface>& xOrigin,
174             shell* pShell,
175             sal_Int32 CommandId);
176 
177         virtual com::sun::star::uno::Any SAL_CALL
178         queryInterface(
179             const com::sun::star::uno::Type& rType )
180             throw( com::sun::star::uno::RuntimeException);
181 
182         virtual void SAL_CALL
183         acquire(
184             void )
185             throw();
186 
187         virtual void SAL_CALL
188         release(
189             void )
190             throw();
191 
192 
193         // XTypeProvider
194 
195         XTYPEPROVIDER_DECL()
196 
197         ::com::sun::star::uno::Any SAL_CALL getRequest(  )
198             throw (::com::sun::star::uno::RuntimeException);
199 
200         com::sun::star::uno::Sequence<
201             com::sun::star::uno::Reference<
202             com::sun::star::task::XInteractionContinuation > > SAL_CALL
203         getContinuations(  )
204             throw (::com::sun::star::uno::RuntimeException)
205         {
206             return m_aSeq;
207         }
208 
209         bool aborted() const
210         {
211             return p2->isSelected();
212         }
213 
214         rtl::OUString newName() const
215         {
216             if( p1->isSelected() )
217                 return p1->getName();
218             else
219                 return rtl::OUString();
220         }
221 
222     private:
223 
224         XInteractionSupplyNameImpl* p1;
225         XInteractionAbortImpl* p2;
226         sal_Int32 m_nErrorCode,m_nMinorError;
227 
228         com::sun::star::uno::Sequence<
229             com::sun::star::uno::Reference<
230             com::sun::star::task::XInteractionContinuation > > m_aSeq;
231 
232         rtl::OUString m_aClashingName;
233         com::sun::star::uno::Reference<
234             com::sun::star::uno::XInterface> m_xOrigin;
235     };
236 
237 }
238 
239 
240 #endif
241