1*b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b557fc96SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b557fc96SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b557fc96SAndrew Rist * distributed with this work for additional information
6*b557fc96SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b557fc96SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b557fc96SAndrew Rist * "License"); you may not use this file except in compliance
9*b557fc96SAndrew Rist * with the License. You may obtain a copy of the License at
10*b557fc96SAndrew Rist *
11*b557fc96SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b557fc96SAndrew Rist *
13*b557fc96SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b557fc96SAndrew Rist * software distributed under the License is distributed on an
15*b557fc96SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b557fc96SAndrew Rist * KIND, either express or implied. See the License for the
17*b557fc96SAndrew Rist * specific language governing permissions and limitations
18*b557fc96SAndrew Rist * under the License.
19*b557fc96SAndrew Rist *
20*b557fc96SAndrew Rist *************************************************************/
21*b557fc96SAndrew Rist
22*b557fc96SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_fpicker.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir #include "controlcommand.hxx"
31cdf0e10cSrcweir #include "controlcommandrequest.hxx"
32cdf0e10cSrcweir #include "controlcommandresult.hxx"
33cdf0e10cSrcweir #include "filepickerstate.hxx"
34cdf0e10cSrcweir
35cdf0e10cSrcweir //---------------------------------------------
36cdf0e10cSrcweir //
37cdf0e10cSrcweir //---------------------------------------------
38cdf0e10cSrcweir
CControlCommand(sal_Int16 aControlId)39cdf0e10cSrcweir CControlCommand::CControlCommand( sal_Int16 aControlId ) :
40cdf0e10cSrcweir m_NextCommand( NULL ),
41cdf0e10cSrcweir m_aControlId( aControlId )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
45cdf0e10cSrcweir //---------------------------------------------
46cdf0e10cSrcweir //
47cdf0e10cSrcweir //---------------------------------------------
48cdf0e10cSrcweir
~CControlCommand()49cdf0e10cSrcweir CControlCommand::~CControlCommand( )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir //---------------------------------------------
54cdf0e10cSrcweir //
55cdf0e10cSrcweir //---------------------------------------------
56cdf0e10cSrcweir
handleRequest(CControlCommandRequest * pRequest)57cdf0e10cSrcweir CControlCommandResult* SAL_CALL CControlCommand::handleRequest( CControlCommandRequest* pRequest )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir // if the command does not support handleRequest, it should at least
60cdf0e10cSrcweir // redirect the request to the next element
61cdf0e10cSrcweir // so the base class implementation has to do it
62cdf0e10cSrcweir
63cdf0e10cSrcweir OSL_ENSURE( pRequest, "inavlid parameter" );
64cdf0e10cSrcweir
65cdf0e10cSrcweir CControlCommandResult* result;
66cdf0e10cSrcweir CControlCommand* nextCommand;
67cdf0e10cSrcweir
68cdf0e10cSrcweir nextCommand = getNextCommand( );
69cdf0e10cSrcweir if ( nextCommand )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir result = nextCommand->handleRequest( pRequest );
72cdf0e10cSrcweir }
73cdf0e10cSrcweir else
74cdf0e10cSrcweir {
75cdf0e10cSrcweir result = new CControlCommandResult();
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir return result;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir //---------------------------------------------
82cdf0e10cSrcweir //
83cdf0e10cSrcweir //---------------------------------------------
84cdf0e10cSrcweir
getNextCommand() const85cdf0e10cSrcweir CControlCommand* SAL_CALL CControlCommand::getNextCommand( ) const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir return m_NextCommand;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir //---------------------------------------------
91cdf0e10cSrcweir //
92cdf0e10cSrcweir //---------------------------------------------
93cdf0e10cSrcweir
setNextCommand(CControlCommand * nextCommand)94cdf0e10cSrcweir void SAL_CALL CControlCommand::setNextCommand( CControlCommand* nextCommand )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir m_NextCommand = nextCommand;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir //---------------------------------------------
100cdf0e10cSrcweir //
101cdf0e10cSrcweir //---------------------------------------------
102cdf0e10cSrcweir
getControlId() const103cdf0e10cSrcweir sal_Int16 SAL_CALL CControlCommand::getControlId( ) const
104cdf0e10cSrcweir {
105cdf0e10cSrcweir return m_aControlId;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir
109cdf0e10cSrcweir //---------------------------------------------
110cdf0e10cSrcweir //
111cdf0e10cSrcweir //---------------------------------------------
112cdf0e10cSrcweir
CValueControlCommand(sal_Int16 aControlId,sal_Int16 aControlAction,const::com::sun::star::uno::Any & aValue)113cdf0e10cSrcweir CValueControlCommand::CValueControlCommand(
114cdf0e10cSrcweir sal_Int16 aControlId,
115cdf0e10cSrcweir sal_Int16 aControlAction,
116cdf0e10cSrcweir const ::com::sun::star::uno::Any& aValue ) :
117cdf0e10cSrcweir CControlCommand( aControlId ),
118cdf0e10cSrcweir m_aControlAction( aControlAction ),
119cdf0e10cSrcweir m_aValue( aValue )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir //---------------------------------------------
124cdf0e10cSrcweir //
125cdf0e10cSrcweir //---------------------------------------------
126cdf0e10cSrcweir
exec(CFilePickerState * aFilePickerState)127cdf0e10cSrcweir void SAL_CALL CValueControlCommand::exec( CFilePickerState* aFilePickerState )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir OSL_ENSURE( aFilePickerState, "empty reference" );
130cdf0e10cSrcweir
131cdf0e10cSrcweir aFilePickerState->setValue(
132cdf0e10cSrcweir getControlId( ),
133cdf0e10cSrcweir m_aControlAction,
134cdf0e10cSrcweir m_aValue );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir //---------------------------------------------
138cdf0e10cSrcweir //
139cdf0e10cSrcweir //---------------------------------------------
140cdf0e10cSrcweir
handleRequest(CControlCommandRequest * aRequest)141cdf0e10cSrcweir CControlCommandResult* SAL_CALL CValueControlCommand::handleRequest( CControlCommandRequest* aRequest )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir CValueControlCommandRequest* value_request =
144cdf0e10cSrcweir dynamic_cast< CValueControlCommandRequest* >( aRequest );
145cdf0e10cSrcweir
146cdf0e10cSrcweir CControlCommandResult* result;
147cdf0e10cSrcweir CControlCommand* nextCommand;
148cdf0e10cSrcweir
149cdf0e10cSrcweir if ( value_request &&
150cdf0e10cSrcweir (value_request->getControlId( ) == getControlId( )) &&
151cdf0e10cSrcweir (value_request->getControlAction( ) == m_aControlAction) )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir result = new CValueCommandResult( sal_True, m_aValue );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir else
156cdf0e10cSrcweir {
157cdf0e10cSrcweir nextCommand = getNextCommand( );
158cdf0e10cSrcweir if ( nextCommand )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir result = nextCommand->handleRequest( aRequest );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir else
163cdf0e10cSrcweir {
164cdf0e10cSrcweir result = new CControlCommandResult( );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir return result;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir //---------------------------------------------
172cdf0e10cSrcweir //
173cdf0e10cSrcweir //---------------------------------------------
174cdf0e10cSrcweir
getControlAction() const175cdf0e10cSrcweir sal_Int16 SAL_CALL CValueControlCommand::getControlAction( ) const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir return m_aControlAction;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir //---------------------------------------------
181cdf0e10cSrcweir //
182cdf0e10cSrcweir //---------------------------------------------
183cdf0e10cSrcweir
getValue() const184cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL CValueControlCommand::getValue( ) const
185cdf0e10cSrcweir {
186cdf0e10cSrcweir return m_aValue;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir
190cdf0e10cSrcweir //---------------------------------------------
191cdf0e10cSrcweir //
192cdf0e10cSrcweir //---------------------------------------------
193cdf0e10cSrcweir
CLabelControlCommand(sal_Int16 aControlId,const rtl::OUString & aLabel)194cdf0e10cSrcweir CLabelControlCommand::CLabelControlCommand(
195cdf0e10cSrcweir sal_Int16 aControlId,
196cdf0e10cSrcweir const rtl::OUString& aLabel ) :
197cdf0e10cSrcweir CControlCommand( aControlId ),
198cdf0e10cSrcweir m_aLabel( aLabel )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir //---------------------------------------------
203cdf0e10cSrcweir //
204cdf0e10cSrcweir //---------------------------------------------
205cdf0e10cSrcweir
exec(CFilePickerState * aFilePickerState)206cdf0e10cSrcweir void SAL_CALL CLabelControlCommand::exec( CFilePickerState* aFilePickerState )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir OSL_ENSURE( aFilePickerState, "empty reference" );
209cdf0e10cSrcweir
210cdf0e10cSrcweir aFilePickerState->setLabel( getControlId( ), m_aLabel );
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir //---------------------------------------------
214cdf0e10cSrcweir //
215cdf0e10cSrcweir //---------------------------------------------
216cdf0e10cSrcweir
handleRequest(CControlCommandRequest * aRequest)217cdf0e10cSrcweir CControlCommandResult* SAL_CALL CLabelControlCommand::handleRequest( CControlCommandRequest* aRequest )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir OSL_ENSURE( aRequest, "inavlid parameter" );
220cdf0e10cSrcweir
221cdf0e10cSrcweir CControlCommandResult* result;
222cdf0e10cSrcweir CControlCommand* nextCommand;
223cdf0e10cSrcweir
224cdf0e10cSrcweir CValueControlCommandRequest* value_request =
225cdf0e10cSrcweir dynamic_cast< CValueControlCommandRequest* >( aRequest );
226cdf0e10cSrcweir
227cdf0e10cSrcweir if ( !value_request &&
228cdf0e10cSrcweir (aRequest->getControlId( ) == getControlId( )) )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir result = new CLabelCommandResult( sal_True, m_aLabel );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir else
233cdf0e10cSrcweir {
234cdf0e10cSrcweir nextCommand = getNextCommand( );
235cdf0e10cSrcweir if ( nextCommand )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir result = nextCommand->handleRequest( aRequest );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir else
240cdf0e10cSrcweir {
241cdf0e10cSrcweir result = new CControlCommandResult( );
242cdf0e10cSrcweir }
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir return result;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir
248cdf0e10cSrcweir //---------------------------------------------
249cdf0e10cSrcweir //
250cdf0e10cSrcweir //---------------------------------------------
251cdf0e10cSrcweir
getLabel() const252cdf0e10cSrcweir rtl::OUString SAL_CALL CLabelControlCommand::getLabel( ) const
253cdf0e10cSrcweir {
254cdf0e10cSrcweir return m_aLabel;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir //---------------------------------------------
258cdf0e10cSrcweir //
259cdf0e10cSrcweir //---------------------------------------------
260cdf0e10cSrcweir
CEnableControlCommand(sal_Int16 aControlId,sal_Bool bEnable)261cdf0e10cSrcweir CEnableControlCommand::CEnableControlCommand(
262cdf0e10cSrcweir sal_Int16 aControlId,
263cdf0e10cSrcweir sal_Bool bEnable ) :
264cdf0e10cSrcweir CControlCommand( aControlId ),
265cdf0e10cSrcweir m_bEnable( bEnable )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir //---------------------------------------------
270cdf0e10cSrcweir //
271cdf0e10cSrcweir //---------------------------------------------
272cdf0e10cSrcweir
exec(CFilePickerState * aFilePickerState)273cdf0e10cSrcweir void SAL_CALL CEnableControlCommand::exec( CFilePickerState* aFilePickerState )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir OSL_ENSURE( aFilePickerState, "empty reference" );
276cdf0e10cSrcweir
277cdf0e10cSrcweir aFilePickerState->enableControl( getControlId( ), m_bEnable );
278cdf0e10cSrcweir }
279