merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / controlcommand.cxx
blobd1d4f9984230a3199557d59f0a9d21462498b421
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: controlcommand.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_fpicker.hxx"
34 //------------------------------------------------------------------------
35 // includes
36 //------------------------------------------------------------------------
37 #include "controlcommand.hxx"
38 #include "controlcommandrequest.hxx"
39 #include "controlcommandresult.hxx"
40 #include "filepickerstate.hxx"
42 //---------------------------------------------
44 //---------------------------------------------
46 CControlCommand::CControlCommand( sal_Int16 aControlId ) :
47 m_NextCommand( NULL ),
48 m_aControlId( aControlId )
52 //---------------------------------------------
54 //---------------------------------------------
56 CControlCommand::~CControlCommand( )
60 //---------------------------------------------
62 //---------------------------------------------
64 CControlCommandResult* SAL_CALL CControlCommand::handleRequest( CControlCommandRequest* pRequest )
66 // if the command does not support handleRequest, it should at least
67 // redirect the request to the next element
68 // so the base class implementation has to do it
70 OSL_ENSURE( pRequest, "inavlid parameter" );
72 CControlCommandResult* result;
73 CControlCommand* nextCommand;
75 nextCommand = getNextCommand( );
76 if ( nextCommand )
78 result = nextCommand->handleRequest( pRequest );
80 else
82 result = new CControlCommandResult();
85 return result;
88 //---------------------------------------------
90 //---------------------------------------------
92 CControlCommand* SAL_CALL CControlCommand::getNextCommand( ) const
94 return m_NextCommand;
97 //---------------------------------------------
99 //---------------------------------------------
101 void SAL_CALL CControlCommand::setNextCommand( CControlCommand* nextCommand )
103 m_NextCommand = nextCommand;
106 //---------------------------------------------
108 //---------------------------------------------
110 sal_Int16 SAL_CALL CControlCommand::getControlId( ) const
112 return m_aControlId;
116 //---------------------------------------------
118 //---------------------------------------------
120 CValueControlCommand::CValueControlCommand(
121 sal_Int16 aControlId,
122 sal_Int16 aControlAction,
123 const ::com::sun::star::uno::Any& aValue ) :
124 CControlCommand( aControlId ),
125 m_aControlAction( aControlAction ),
126 m_aValue( aValue )
130 //---------------------------------------------
132 //---------------------------------------------
134 void SAL_CALL CValueControlCommand::exec( CFilePickerState* aFilePickerState )
136 OSL_ENSURE( aFilePickerState, "empty reference" );
138 aFilePickerState->setValue(
139 getControlId( ),
140 m_aControlAction,
141 m_aValue );
144 //---------------------------------------------
146 //---------------------------------------------
148 CControlCommandResult* SAL_CALL CValueControlCommand::handleRequest( CControlCommandRequest* aRequest )
150 CValueControlCommandRequest* value_request =
151 dynamic_cast< CValueControlCommandRequest* >( aRequest );
153 CControlCommandResult* result;
154 CControlCommand* nextCommand;
156 if ( value_request &&
157 (value_request->getControlId( ) == getControlId( )) &&
158 (value_request->getControlAction( ) == m_aControlAction) )
160 result = new CValueCommandResult( sal_True, m_aValue );
162 else
164 nextCommand = getNextCommand( );
165 if ( nextCommand )
167 result = nextCommand->handleRequest( aRequest );
169 else
171 result = new CControlCommandResult( );
175 return result;
178 //---------------------------------------------
180 //---------------------------------------------
182 sal_Int16 SAL_CALL CValueControlCommand::getControlAction( ) const
184 return m_aControlAction;
187 //---------------------------------------------
189 //---------------------------------------------
191 ::com::sun::star::uno::Any SAL_CALL CValueControlCommand::getValue( ) const
193 return m_aValue;
197 //---------------------------------------------
199 //---------------------------------------------
201 CLabelControlCommand::CLabelControlCommand(
202 sal_Int16 aControlId,
203 const rtl::OUString& aLabel ) :
204 CControlCommand( aControlId ),
205 m_aLabel( aLabel )
209 //---------------------------------------------
211 //---------------------------------------------
213 void SAL_CALL CLabelControlCommand::exec( CFilePickerState* aFilePickerState )
215 OSL_ENSURE( aFilePickerState, "empty reference" );
217 aFilePickerState->setLabel( getControlId( ), m_aLabel );
220 //---------------------------------------------
222 //---------------------------------------------
224 CControlCommandResult* SAL_CALL CLabelControlCommand::handleRequest( CControlCommandRequest* aRequest )
226 OSL_ENSURE( aRequest, "inavlid parameter" );
228 CControlCommandResult* result;
229 CControlCommand* nextCommand;
231 CValueControlCommandRequest* value_request =
232 dynamic_cast< CValueControlCommandRequest* >( aRequest );
234 if ( !value_request &&
235 (aRequest->getControlId( ) == getControlId( )) )
237 result = new CLabelCommandResult( sal_True, m_aLabel );
239 else
241 nextCommand = getNextCommand( );
242 if ( nextCommand )
244 result = nextCommand->handleRequest( aRequest );
246 else
248 result = new CControlCommandResult( );
252 return result;
255 //---------------------------------------------
257 //---------------------------------------------
259 rtl::OUString SAL_CALL CLabelControlCommand::getLabel( ) const
261 return m_aLabel;
264 //---------------------------------------------
266 //---------------------------------------------
268 CEnableControlCommand::CEnableControlCommand(
269 sal_Int16 aControlId,
270 sal_Bool bEnable ) :
271 CControlCommand( aControlId ),
272 m_bEnable( bEnable )
276 //---------------------------------------------
278 //---------------------------------------------
280 void SAL_CALL CEnableControlCommand::exec( CFilePickerState* aFilePickerState )
282 OSL_ENSURE( aFilePickerState, "empty reference" );
284 aFilePickerState->enableControl( getControlId( ), m_bEnable );