1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_fpicker.hxx"
31 //------------------------------------------------------------------------
33 //------------------------------------------------------------------------
34 #include "controlcommand.hxx"
35 #include "controlcommandrequest.hxx"
36 #include "controlcommandresult.hxx"
37 #include "filepickerstate.hxx"
39 //---------------------------------------------
41 //---------------------------------------------
43 CControlCommand::CControlCommand( sal_Int16 aControlId
) :
44 m_NextCommand( NULL
),
45 m_aControlId( aControlId
)
49 //---------------------------------------------
51 //---------------------------------------------
53 CControlCommand::~CControlCommand( )
57 //---------------------------------------------
59 //---------------------------------------------
61 CControlCommandResult
* SAL_CALL
CControlCommand::handleRequest( CControlCommandRequest
* pRequest
)
63 // if the command does not support handleRequest, it should at least
64 // redirect the request to the next element
65 // so the base class implementation has to do it
67 OSL_ENSURE( pRequest
, "inavlid parameter" );
69 CControlCommandResult
* result
;
70 CControlCommand
* nextCommand
;
72 nextCommand
= getNextCommand( );
75 result
= nextCommand
->handleRequest( pRequest
);
79 result
= new CControlCommandResult();
85 //---------------------------------------------
87 //---------------------------------------------
89 CControlCommand
* SAL_CALL
CControlCommand::getNextCommand( ) const
94 //---------------------------------------------
96 //---------------------------------------------
98 void SAL_CALL
CControlCommand::setNextCommand( CControlCommand
* nextCommand
)
100 m_NextCommand
= nextCommand
;
103 //---------------------------------------------
105 //---------------------------------------------
107 sal_Int16 SAL_CALL
CControlCommand::getControlId( ) const
113 //---------------------------------------------
115 //---------------------------------------------
117 CValueControlCommand::CValueControlCommand(
118 sal_Int16 aControlId
,
119 sal_Int16 aControlAction
,
120 const ::com::sun::star::uno::Any
& aValue
) :
121 CControlCommand( aControlId
),
122 m_aControlAction( aControlAction
),
127 //---------------------------------------------
129 //---------------------------------------------
131 void SAL_CALL
CValueControlCommand::exec( CFilePickerState
* aFilePickerState
)
133 OSL_ENSURE( aFilePickerState
, "empty reference" );
135 aFilePickerState
->setValue(
141 //---------------------------------------------
143 //---------------------------------------------
145 CControlCommandResult
* SAL_CALL
CValueControlCommand::handleRequest( CControlCommandRequest
* aRequest
)
147 CValueControlCommandRequest
* value_request
=
148 dynamic_cast< CValueControlCommandRequest
* >( aRequest
);
150 CControlCommandResult
* result
;
151 CControlCommand
* nextCommand
;
153 if ( value_request
&&
154 (value_request
->getControlId( ) == getControlId( )) &&
155 (value_request
->getControlAction( ) == m_aControlAction
) )
157 result
= new CValueCommandResult( sal_True
, m_aValue
);
161 nextCommand
= getNextCommand( );
164 result
= nextCommand
->handleRequest( aRequest
);
168 result
= new CControlCommandResult( );
175 //---------------------------------------------
177 //---------------------------------------------
179 sal_Int16 SAL_CALL
CValueControlCommand::getControlAction( ) const
181 return m_aControlAction
;
184 //---------------------------------------------
186 //---------------------------------------------
188 ::com::sun::star::uno::Any SAL_CALL
CValueControlCommand::getValue( ) const
194 //---------------------------------------------
196 //---------------------------------------------
198 CLabelControlCommand::CLabelControlCommand(
199 sal_Int16 aControlId
,
200 const rtl::OUString
& aLabel
) :
201 CControlCommand( aControlId
),
206 //---------------------------------------------
208 //---------------------------------------------
210 void SAL_CALL
CLabelControlCommand::exec( CFilePickerState
* aFilePickerState
)
212 OSL_ENSURE( aFilePickerState
, "empty reference" );
214 aFilePickerState
->setLabel( getControlId( ), m_aLabel
);
217 //---------------------------------------------
219 //---------------------------------------------
221 CControlCommandResult
* SAL_CALL
CLabelControlCommand::handleRequest( CControlCommandRequest
* aRequest
)
223 OSL_ENSURE( aRequest
, "inavlid parameter" );
225 CControlCommandResult
* result
;
226 CControlCommand
* nextCommand
;
228 CValueControlCommandRequest
* value_request
=
229 dynamic_cast< CValueControlCommandRequest
* >( aRequest
);
231 if ( !value_request
&&
232 (aRequest
->getControlId( ) == getControlId( )) )
234 result
= new CLabelCommandResult( sal_True
, m_aLabel
);
238 nextCommand
= getNextCommand( );
241 result
= nextCommand
->handleRequest( aRequest
);
245 result
= new CControlCommandResult( );
252 //---------------------------------------------
254 //---------------------------------------------
256 rtl::OUString SAL_CALL
CLabelControlCommand::getLabel( ) const
261 //---------------------------------------------
263 //---------------------------------------------
265 CEnableControlCommand::CEnableControlCommand(
266 sal_Int16 aControlId
,
268 CControlCommand( aControlId
),
273 //---------------------------------------------
275 //---------------------------------------------
277 void SAL_CALL
CEnableControlCommand::exec( CFilePickerState
* aFilePickerState
)
279 OSL_ENSURE( aFilePickerState
, "empty reference" );
281 aFilePickerState
->enableControl( getControlId( ), m_bEnable
);