diff options
author | Tino Rachui <tra@openoffice.org> | 2001-08-10 11:09:26 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-08-10 11:09:26 +0000 |
commit | 0cd1092a9693bf9c4969bbf79bf8d4c130439798 (patch) | |
tree | 89c923867d307951a931f61fa0935a9a4db2fa35 /fpicker | |
parent | deea318fd1c6ec5612868d31f74409d3b44d24fd (diff) |
#89230#initial check-in
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/source/win32/filepicker/controlcommand.cxx | 298 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/controlcommand.hxx | 185 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/controlcommandrequest.hxx | 122 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/controlcommandresult.hxx | 150 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/filepickerstate.cxx | 715 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/filepickerstate.hxx | 204 |
6 files changed, 1674 insertions, 0 deletions
diff --git a/fpicker/source/win32/filepicker/controlcommand.cxx b/fpicker/source/win32/filepicker/controlcommand.cxx new file mode 100644 index 000000000000..110277b5f0cf --- /dev/null +++ b/fpicker/source/win32/filepicker/controlcommand.cxx @@ -0,0 +1,298 @@ +/************************************************************************* + * + * $RCSfile: controlcommand.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:08:54 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _CONTROLCOMMAND_HXX_ +#include "controlcommand.hxx" +#endif + +#ifndef _CONTROLCOMMANDREQUEST_HXX_ +#include "controlcommandrequest.hxx" +#endif + +#ifndef _CONTROLCOMMANDRESULT_HXX_ +#include "controlcommandresult.hxx" +#endif + +#ifndef _FILEPICKERSTATE_HXX_ +#include "filepickerstate.hxx" +#endif + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommand::CControlCommand( sal_Int16 aControlId ) : + m_NextCommand( NULL ), + m_aControlId( aControlId ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommand::~CControlCommand( ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommandResult* SAL_CALL CControlCommand::handleRequest( CControlCommandRequest* aRequest ) +{ + return new CControlCommandResult( ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommand* SAL_CALL CControlCommand::getNextCommand( ) const +{ + return m_NextCommand; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CControlCommand::setNextCommand( CControlCommand* nextCommand ) +{ + m_NextCommand = nextCommand; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +sal_Int16 SAL_CALL CControlCommand::getControlId( ) const +{ + return m_aControlId; +} + + +//--------------------------------------------- +// +//--------------------------------------------- + +CValueControlCommand::CValueControlCommand( + sal_Int16 aControlId, + sal_Int16 aControlAction, + const ::com::sun::star::uno::Any& aValue ) : + CControlCommand( aControlId ), + m_aControlAction( aControlAction ), + m_aValue( aValue ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CValueControlCommand::exec( CFilePickerState* aFilePickerState ) +{ + OSL_ENSURE( aFilePickerState, "empty reference" ); + + aFilePickerState->setValue( + getControlId( ), + m_aControlAction, + m_aValue ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommandResult* SAL_CALL CValueControlCommand::handleRequest( CControlCommandRequest* aRequest ) +{ + CValueControlCommandRequest* value_request = + dynamic_cast< CValueControlCommandRequest* >( aRequest ); + + CControlCommandResult* result; + CControlCommand* nextCommand; + + if ( value_request && + (value_request->getControlId( ) == getControlId( )) && + (value_request->getControlAction( ) == m_aControlAction) ) + { + result = new CValueCommandResult( sal_True, m_aValue ); + } + else if ( (nextCommand = getNextCommand( )) ) + { + result = nextCommand->handleRequest( aRequest ); + } + else + { + result = new CControlCommandResult( ); + } + + return result; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +sal_Int16 SAL_CALL CValueControlCommand::getControlAction( ) const +{ + return m_aControlAction; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +::com::sun::star::uno::Any SAL_CALL CValueControlCommand::getValue( ) const +{ + return m_aValue; +} + + +//--------------------------------------------- +// +//--------------------------------------------- + +CLabelControlCommand::CLabelControlCommand( + sal_Int16 aControlId, + const rtl::OUString& aLabel ) : + CControlCommand( aControlId ), + m_aLabel( aLabel ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CLabelControlCommand::exec( CFilePickerState* aFilePickerState ) +{ + OSL_ENSURE( aFilePickerState, "empty reference" ); + + aFilePickerState->setLabel( getControlId( ), m_aLabel ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommandResult* SAL_CALL CLabelControlCommand::handleRequest( CControlCommandRequest* aRequest ) +{ + OSL_ENSURE( aRequest, "inavlid parameter" ); + + CControlCommandResult* result; + CControlCommand* nextCommand; + + CValueControlCommandRequest* value_request = + dynamic_cast< CValueControlCommandRequest* >( aRequest ); + + if ( !value_request && + (aRequest->getControlId( ) == getControlId( )) ) + { + result = new CLabelCommandResult( sal_True, m_aLabel ); + } + else if ( (nextCommand = getNextCommand( )) ) + { + result = nextCommand->handleRequest( aRequest ); + } + else + { + result = new CControlCommandResult( ); + } + + return result; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +rtl::OUString SAL_CALL CLabelControlCommand::getLabel( ) const +{ + return m_aLabel; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CEnableControlCommand::CEnableControlCommand( + sal_Int16 aControlId, + sal_Bool bEnable ) : + CControlCommand( aControlId ), + m_bEnable( bEnable ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CEnableControlCommand::exec( CFilePickerState* aFilePickerState ) +{ + OSL_ENSURE( aFilePickerState, "empty reference" ); + + aFilePickerState->enableControl( getControlId( ), m_bEnable ); +} diff --git a/fpicker/source/win32/filepicker/controlcommand.hxx b/fpicker/source/win32/filepicker/controlcommand.hxx new file mode 100644 index 000000000000..934ba68b4bd6 --- /dev/null +++ b/fpicker/source/win32/filepicker/controlcommand.hxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: controlcommand.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:09:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONTROLCOMMAND_HXX_ +#define _CONTROLCOMMAND_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +//--------------------------------------------- +// +//--------------------------------------------- + +class CFilePickerState; +class CControlCommandRequest; +class CControlCommandResult; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CControlCommand +{ +public: + CControlCommand( sal_Int16 aControlId ); + virtual ~CControlCommand( ); + + virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ) = 0; + + // the client inherits the ownership of the returned + // CControlCommandResult and has to delete it or he may + // use the auto_ptr template for automatic deletion + virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest ); + + // clients of this method should use the returned + // pointer only temporary because it's not ref-counted + // and the ownerhsip belongs to this instance + CControlCommand* SAL_CALL getNextCommand( ) const; + + // transfers the ownership to this class + void SAL_CALL setNextCommand( CControlCommand* nextCommand ); + +protected: + sal_Int16 SAL_CALL getControlId( ) const; + +private: + CControlCommand* m_NextCommand; + sal_Int16 m_aControlId; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CValueControlCommand : public CControlCommand +{ +public: + CValueControlCommand( + sal_Int16 aControlId, + sal_Int16 aControlAction, + const ::com::sun::star::uno::Any& aValue ); + + virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ); + + virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest ); + + sal_Int16 SAL_CALL getControlAction( ) const; + + ::com::sun::star::uno::Any SAL_CALL getValue( ) const; + +private: + sal_Int16 m_aControlAction; + ::com::sun::star::uno::Any m_aValue; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CLabelControlCommand : public CControlCommand +{ +public: + CLabelControlCommand( + sal_Int16 aControlId, + const rtl::OUString& aLabel ); + + virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ); + + virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest ); + + rtl::OUString SAL_CALL getLabel( ) const; + +private: + rtl::OUString m_aLabel; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CEnableControlCommand : public CControlCommand +{ +public: + CEnableControlCommand( + sal_Int16 controlId, + sal_Bool bEnable ); + + virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ); + +private: + sal_Bool m_bEnable; +}; + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/controlcommandrequest.hxx b/fpicker/source/win32/filepicker/controlcommandrequest.hxx new file mode 100644 index 000000000000..87436af70b6c --- /dev/null +++ b/fpicker/source/win32/filepicker/controlcommandrequest.hxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: controlcommandrequest.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:09:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONTROLCOMMANDREQUEST_HXX_ +#define _CONTROLCOMMANDREQUEST_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +//--------------------------------------------- +// declaration +//--------------------------------------------- + +class CControlCommandRequest +{ +public: + CControlCommandRequest( sal_Int16 aControlId ) : + m_aControlId( aControlId ) + { + } + + virtual ~CControlCommandRequest( ) + { + } + + sal_Int16 SAL_CALL getControlId( ) const + { + return m_aControlId; + } + +private: + sal_Int16 m_aControlId; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CValueControlCommandRequest : public CControlCommandRequest +{ +public: + CValueControlCommandRequest( + sal_Int16 aControlId, + sal_Int16 aControlAction ) : + CControlCommandRequest( aControlId ), + m_aControlAction( aControlAction ) + { + } + + sal_Int16 SAL_CALL getControlAction( ) const + { + return m_aControlAction; + } + +private: + sal_Int16 m_aControlAction; +}; + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/controlcommandresult.hxx b/fpicker/source/win32/filepicker/controlcommandresult.hxx new file mode 100644 index 000000000000..dd3b90ae2cb4 --- /dev/null +++ b/fpicker/source/win32/filepicker/controlcommandresult.hxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * $RCSfile: controlcommandresult.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:09:01 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONTROLCOMMANDRESULT_HXX_ +#define _CONTROLCOMMANDRESULT_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +//--------------------------------------------- +// declaration +//--------------------------------------------- + +class CControlCommandResult +{ +public: + CControlCommandResult( sal_Bool bResult = sal_False ) : + m_bResult( bResult ) + { + } + + virtual ~CControlCommandResult( ) + { + } + + sal_Bool SAL_CALL hasResult( ) const + { + return m_bResult; + } + +private: + sal_Bool m_bResult; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CValueCommandResult : public CControlCommandResult +{ +public: + CValueCommandResult( sal_Bool bResult, const ::com::sun::star::uno::Any& aValue ) : + CControlCommandResult( bResult ), + m_aValue( aValue ) + { + } + + ::com::sun::star::uno::Any SAL_CALL getValue( ) const + { + return m_aValue; + } + +private: + ::com::sun::star::uno::Any m_aValue; +}; + +//--------------------------------------------- +// +//--------------------------------------------- + +class CLabelCommandResult : public CControlCommandResult +{ +public: + CLabelCommandResult( sal_Bool bResult, const rtl::OUString& aLabel ) : + CControlCommandResult( bResult ), + m_aLabel( aLabel ) + { + } + + rtl::OUString SAL_CALL getLabel( ) const + { + return m_aLabel; + } + +private: + rtl::OUString m_aLabel; +}; + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/filepickerstate.cxx b/fpicker/source/win32/filepicker/filepickerstate.cxx new file mode 100644 index 000000000000..e7e772eed791 --- /dev/null +++ b/fpicker/source/win32/filepicker/filepickerstate.cxx @@ -0,0 +1,715 @@ +/************************************************************************* + * + * $RCSfile: filepickerstate.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:09:26 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _FILEPICKERSTATE_HXX_ +#include "filepickerstate.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _CONTROLACCESS_HXX_ +#include "controlaccess.hxx" +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_COMMONFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_LISTBOXCONTROLACTIONS_HPP_ +#include <com/sun/star/ui/dialogs/ListBoxControlActions.hpp> +#endif + +#ifndef _CONTROLCOMMANDREQUEST_HXX_ +#include "controlcommandrequest.hxx" +#endif + +#ifndef _CONTROLCOMMANDRESULT_HXX_ +#include "controlcommandresult.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ +#include <com/sun/star/uno/Reference.hxx> +#endif + +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifndef _FILEOPENDLG_HXX_ +#include "FileOpenDlg.hxx" +#endif + +#include <memory> + +#ifndef _WINIMPLHELPER_HXX_ +#include "..\misc\WinImplHelper.hxx" +#endif +//--------------------------------------------- +// +//--------------------------------------------- + +using rtl::OUString; +using com::sun::star::uno::Any; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::Reference; +using com::sun::star::uno::XInterface; + +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::ListboxControlActions; + +//--------------------------------------------- +// +//--------------------------------------------- + +const sal_Int32 MAX_LABEL = 256; +const sal_Int16 LISTBOX_LABEL_OFFSET = 100; + +//--------------------------------------------- +// declaration +//--------------------------------------------- + +CFilePickerState::~CFilePickerState( ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CNonExecuteFilePickerState::CNonExecuteFilePickerState( ) : + m_FirstControlCommand( NULL ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CNonExecuteFilePickerState::~CNonExecuteFilePickerState( ) +{ + reset( ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CNonExecuteFilePickerState::setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const Any& aValue ) +{ + CValueControlCommand* value_command = new CValueControlCommand( + aControlId, aControlAction, aValue ); + + addControlCommand( value_command ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +Any SAL_CALL CNonExecuteFilePickerState::getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) +{ + CValueControlCommandRequest value_request( aControlId, aControlAction ); + + // pass the request along the command-chain + std::auto_ptr< CControlCommandResult > result( m_FirstControlCommand->handleRequest( &value_request ) ); + + OSL_ENSURE( result->hasResult( ), "invalid getValue request" ); + + Any aAny; + + if ( result->hasResult( ) ) + { + CValueCommandResult* value_result = dynamic_cast< CValueCommandResult* >( result.get( ) ); + OSL_ENSURE( value_result, "should have be a CValueCommandResult" ); + + aAny = value_result->getValue( ); + OSL_ENSURE( aAny.hasValue( ), "empty any" ); + } + + return aAny; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CNonExecuteFilePickerState::enableControl( sal_Int16 aControlId, sal_Bool bEnable ) +{ + CEnableControlCommand* enable_command = new CEnableControlCommand( + aControlId, bEnable ); + + addControlCommand( enable_command ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CNonExecuteFilePickerState::setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) +{ + CLabelControlCommand* label_command = new CLabelControlCommand( + aControlId, aLabel ); + + addControlCommand( label_command ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +OUString SAL_CALL CNonExecuteFilePickerState::getLabel( sal_Int16 aControlId ) +{ + CControlCommandRequest label_request( aControlId ); + + // pass the request along the command-chain + std::auto_ptr< CControlCommandResult > result( m_FirstControlCommand->handleRequest( &label_request ) ); + + OSL_ENSURE( result->hasResult( ), "invalid getValue request" ); + + OUString aLabel; + + if ( result->hasResult( ) ) + { + CLabelCommandResult* label_result = dynamic_cast< CLabelCommandResult* >( result.get( ) ); + OSL_ENSURE( label_result, "should have be a CLabelCommandResult" ); + + aLabel = label_result->getLabel( ); + } + + return aLabel; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +Sequence< OUString > SAL_CALL CNonExecuteFilePickerState::getFiles( CFileOpenDialog* aFileOpenDialog ) +{ + OSL_PRECOND( aFileOpenDialog, "invalid parameter" ); + + Sequence< OUString > aFilePathList; + OUString aFilePathURL; + OUString aFilePath; + ::osl::FileBase::RC rc; + + aFilePath = aFileOpenDialog->getFullFileName( ); + + if ( aFilePath.getLength( ) ) + { + // tokenize the returned string and copy the + // sub-strings separately into a sequence + const sal_Unicode* pTemp = aFilePath.getStr( ); + const sal_Unicode* pStrEnd = pTemp + aFilePath.getLength( ); + sal_uInt32 lSubStr; + + while ( pTemp < pStrEnd ) + { + // detect the length of the next + // sub string + lSubStr = wcslen( pTemp ); + + aFilePathList.realloc( + aFilePathList.getLength( ) + 1 ); + + aFilePathList[aFilePathList.getLength( ) - 1] = + OUString( pTemp, lSubStr ); + + pTemp += (lSubStr + 1); + } + + // change all entries to file URLs + sal_Int32 lenFileList = aFilePathList.getLength( ); + OSL_ASSERT( lenFileList >= 1 ); + + for ( sal_Int32 i = 0; i < lenFileList; i++ ) + { + rc = ::osl::FileBase::getFileURLFromSystemPath( + aFilePathList[i], aFilePathURL ); + + // we do return all or nothing, that means + // in case of failures we destroy the sequence + // and return an empty sequence + if ( rc != ::osl::FileBase::E_None ) + { + aFilePathList.realloc( 0 ); + break; + } + + aFilePathList[i] = aFilePathURL; + } + } + + return aFilePathList; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +OUString SAL_CALL CNonExecuteFilePickerState::getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ) +{ + OSL_PRECOND( aFileOpenDialog, "invalid parameter" ); + + OUString pathURL; + OUString displayDir; + + displayDir = aFileOpenDialog->getLastDisplayDirectory( ); + + if ( displayDir.getLength( ) ) + ::osl::FileBase::getFileURLFromSystemPath( displayDir, pathURL ); + + return pathURL; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CNonExecuteFilePickerState::reset( ) +{ + CControlCommand* nextCommand; + CControlCommand* currentCommand = m_FirstControlCommand; + + while( currentCommand ) + { + nextCommand = currentCommand->getNextCommand( ); + delete currentCommand; + currentCommand = nextCommand; + } + + m_FirstControlCommand = NULL; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +CControlCommand* SAL_CALL CNonExecuteFilePickerState::getControlCommand( ) const +{ + return m_FirstControlCommand; +} + +//--------------------------------------------- +// we append new control commands to the end +// of the list so that we are sure the commands +// will be executed as the client issued it +//--------------------------------------------- + +void SAL_CALL CNonExecuteFilePickerState::addControlCommand( CControlCommand* aControlCommand ) +{ + OSL_ASSERT( aControlCommand ); + + if ( NULL == m_FirstControlCommand ) + { + m_FirstControlCommand = aControlCommand; + } + else + { + CControlCommand* pNextControlCommand = m_FirstControlCommand; + + while ( pNextControlCommand->getNextCommand( ) != NULL ) + pNextControlCommand = pNextControlCommand->getNextCommand( ); + + pNextControlCommand->setNextCommand( aControlCommand ); + } +} + +//####################################################################### + +//--------------------------------------------- +// +//--------------------------------------------- + +CExecuteFilePickerState::CExecuteFilePickerState( HWND hwndDlg ) : + m_hwndDlg( hwndDlg ) +{ +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const Any& aValue ) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + // the filter listbox can be manipulated via this + // method the caller should use XFilterManager + if ( !hwndCtrl || (aControlId == LISTBOX_FILTER) ) + { + OSL_ENSURE( sal_False, "invalid control id" ); + return; + } + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndCtrl ); + if ( UNKNOWN == aCtrlClass ) + { + OSL_ENSURE( sal_False, "unsupported control class" ); + return; + } + + CTRL_SETVALUE_FUNCTION_T lpfnSetValue = + GetCtrlSetValueFunction( aCtrlClass, aControlAction ); + + if ( !lpfnSetValue ) + { + OSL_ENSURE( sal_False, "unsupported control action" ); + return; + } + + // the function that we call should throw an IllegalArgumentException if + // the given value is invalid or empty, that's why we provide a Reference + // to an XInterface and a argument position + lpfnSetValue( hwndCtrl, aValue, Reference< XInterface >( ), 3 ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +Any SAL_CALL CExecuteFilePickerState::getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + // the filter listbox can be manipulated via this + // method the caller should use XFilterManager + if ( !hwndCtrl || (aControlId == LISTBOX_FILTER) ) + { + OSL_ENSURE( sal_False, "invalid control id" ); + return Any( ); + } + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndCtrl ); + if ( UNKNOWN == aCtrlClass ) + { + OSL_ENSURE( sal_False, "unsupported control class" ); + return Any( ); + } + + CTRL_GETVALUE_FUNCTION_T lpfnGetValue = + GetCtrlGetValueFunction( aCtrlClass, aControlAction ); + + if ( !lpfnGetValue ) + { + OSL_ENSURE( sal_False, "unsupported control action" ); + return Any( ); + } + + return lpfnGetValue( hwndCtrl ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::enableControl( sal_Int16 aControlId, sal_Bool bEnable ) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + OSL_ENSURE( IsWindow( hwndCtrl ), "invalid element id"); + + EnableWindow( hwndCtrl, bEnable ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::setLabel( sal_Int16 aControlId, const OUString& aLabel ) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + OSL_ENSURE( IsWindow( hwndCtrl ), "invalid element id"); + + if ( IsListboxControl( hwndCtrl ) ) + hwndCtrl = GetListboxLabelItem( aControlId ); + + OUString aWinLabel = SOfficeToWindowsLabel( aLabel ); + + // somewhat risky because we don't know if OUString + // has a terminating '\0' + SetWindowTextW( hwndCtrl, aWinLabel.getStr( ) ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +OUString SAL_CALL CExecuteFilePickerState::getLabel( sal_Int16 aControlId ) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + OSL_ENSURE( IsWindow( hwndCtrl ), "invalid element id"); + + if ( IsListboxControl( hwndCtrl ) ) + hwndCtrl = GetListboxLabelItem( aControlId ); + + sal_Unicode aLabel[MAX_LABEL]; + int nRet = GetWindowTextW( hwndCtrl, aLabel, MAX_LABEL ); + + OUString ctrlLabel; + if ( nRet ) + { + ctrlLabel = OUString( aLabel, wcslen( aLabel ) ); + ctrlLabel = WindowsToSOfficeLabel( aLabel ); + } + + return ctrlLabel; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +Sequence< OUString > SAL_CALL CExecuteFilePickerState::getFiles( CFileOpenDialog* aFileOpenDialog ) +{ + OSL_POSTCOND( aFileOpenDialog, "invalid parameter" ); + + Sequence< OUString > aFilePathList; + OUString aFilePathURL; + OUString aFilePath; + ::osl::FileBase::RC rc; + + // in execution mode getFullFileName doesn't + // return anything, so we must use another way + + // returns the currently selected file(s) + // including path information + aFilePath = aFileOpenDialog->getCurrentFilePath( ); + + // if multiple files are selected or the user + // typed anything that doesn't seem to be a valid + // file name getFileURLFromSystemPath fails + // and we return an empty file list + rc = ::osl::FileBase::getFileURLFromSystemPath( + aFilePath, aFilePathURL ); + + if ( ::osl::FileBase::E_None == rc ) + { + aFilePathList.realloc( 1 ); + aFilePathList[0] = aFilePathURL; + } + + return aFilePathList; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +OUString SAL_CALL CExecuteFilePickerState::getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ) +{ + OSL_POSTCOND( aFileOpenDialog, "invalid parameter" ); + + OUString pathURL; + OUString displayDir; + + displayDir = aFileOpenDialog->getCurrentFolderPath( ); + + if ( displayDir.getLength( ) ) + ::osl::FileBase::getFileURLFromSystemPath( displayDir, pathURL ); + + return pathURL; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::initFilePickerControls( CControlCommand* firstControlCommand ) +{ + CControlCommand* aControlCommand = firstControlCommand; + + while ( aControlCommand ) + { + aControlCommand->exec( this ); + aControlCommand = aControlCommand->getNextCommand( ); + } +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::cacheControlState( HWND hwndControl, CFilePickerState* aNonExecFilePickerState ) +{ + OSL_ENSURE( hwndControl && aNonExecFilePickerState, "invalid parameters" ); + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndControl ); + + sal_Int16 aControlAction; + CTRL_GETVALUE_FUNCTION_T lpfnGetValue; + + if ( CHECKBOX == aCtrlClass ) + { + aControlAction = 0; + + lpfnGetValue = GetCtrlGetValueFunction( aCtrlClass, aControlAction ); + + OSL_ASSERT( lpfnGetValue ); + + aNonExecFilePickerState->setValue( + GetDlgCtrlID( hwndControl ), + aControlAction, + lpfnGetValue( hwndControl ) ); + + aNonExecFilePickerState->setLabel( + GetDlgCtrlID( hwndControl ), + getLabel( GetDlgCtrlID( hwndControl ) ) ); + } + else if ( LISTBOX == aCtrlClass ) + { + // for listboxes we save only the + // last selected item + aControlAction = GET_SELECTED_ITEM; + + lpfnGetValue = GetCtrlGetValueFunction( aCtrlClass, aControlAction ); + + aNonExecFilePickerState->setValue( + GetDlgCtrlID( hwndControl ), + aControlAction, + lpfnGetValue( hwndControl ) ); + } +} + +//--------------------------------------------- +// +//--------------------------------------------- + +void SAL_CALL CExecuteFilePickerState::setHwnd( HWND hwndDlg ) +{ + m_hwndDlg = hwndDlg; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +inline sal_Bool SAL_CALL CExecuteFilePickerState::IsListboxControl( HWND hwndControl ) const +{ + OSL_PRECOND( IsWindow( hwndControl ), "invalid parameter" ); + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndControl ); + return ( LISTBOX == aCtrlClass ); +} + +//--------------------------------------------- +// because listboxes (comboboxes) and their labels +// are seperated we have to translate the listbox +// id to their corresponding label id +// the convention is that the label id of a listbox +// is the id of the listbox + 100 +//--------------------------------------------- + +inline sal_Int16 SAL_CALL CExecuteFilePickerState::ListboxIdToListboxLabelId( sal_Int16 aListboxId ) const +{ + return ( aListboxId + LISTBOX_LABEL_OFFSET ); +} + +//--------------------------------------------- +// +//--------------------------------------------- + +inline HWND SAL_CALL CExecuteFilePickerState::GetListboxLabelItem( sal_Int16 aControlId ) const +{ + sal_Int16 aLabelId = ListboxIdToListboxLabelId( aControlId ); + HWND hwndCtrl = GetHwndDlgItem( aLabelId ); + + OSL_ASSERT( IsWindow( hwndCtrl ) ); + + return hwndCtrl; +} + +//--------------------------------------------- +// +//--------------------------------------------- + +HWND SAL_CALL CExecuteFilePickerState::GetHwndDlgItem( sal_Int16 aControlId, sal_Bool bIncludeStdCtrls ) const +{ + OSL_ENSURE( IsWindow( m_hwndDlg ), "no valid parent window set before" ); + + HWND hwndCtrl = GetDlgItem( m_hwndDlg, aControlId ); + + // maybe it's a control of the dialog itself for instance + // the ok and cancel button + if ( !hwndCtrl && bIncludeStdCtrls ) + { + aControlId = CommonFilePickerCtrlIdToWinFileOpenCtrlId( aControlId ); + hwndCtrl = GetDlgItem( GetParent( m_hwndDlg ), aControlId ); + } + + return hwndCtrl; +} diff --git a/fpicker/source/win32/filepicker/filepickerstate.hxx b/fpicker/source/win32/filepicker/filepickerstate.hxx new file mode 100644 index 000000000000..b5b2692f5182 --- /dev/null +++ b/fpicker/source/win32/filepicker/filepickerstate.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * $RCSfile: filepickerstate.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-08-10 12:09:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _FILEPICKERSTATE_HXX_ +#define _FILEPICKERSTATE_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _CONTROLCOMMAND_HXX_ +#include "controlcommand.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#include <systools/win32/user9x.h> + +//--------------------------------------------- +// +//--------------------------------------------- + +class CControlCommand; +class CFileOpenDialog; + +//--------------------------------------------- +// declaration +//--------------------------------------------- + +class CFilePickerState +{ +public: + virtual ~CFilePickerState( ); + + virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ) = 0; + + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) = 0; + + virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) = 0; + + virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) = 0; + + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ) = 0; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ) = 0; + + virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ) = 0; +}; + +//--------------------------------------------- +// this class is not thread-safe +//--------------------------------------------- + +class CNonExecuteFilePickerState : public CFilePickerState +{ +public: + CNonExecuteFilePickerState( ); + + virtual ~CNonExecuteFilePickerState( ); + + virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ); + + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ); + + virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ); + + virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ); + + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ); + + virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ); + + void SAL_CALL reset( ); + + CControlCommand* SAL_CALL getControlCommand( ) const; + +protected: + void SAL_CALL addControlCommand( CControlCommand* aControlCommand ); + +private: + CControlCommand* m_FirstControlCommand; +}; + +//--------------------------------------------- +// this class is not thread-safe +//--------------------------------------------- + +class CExecuteFilePickerState : public CFilePickerState +{ +public: + CExecuteFilePickerState( HWND hwndDlg = NULL ); + + virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ); + + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ); + + virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ); + + virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ); + + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ); + + virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ); + + void SAL_CALL initFilePickerControls( CControlCommand* firstControlCommand ); + + void SAL_CALL cacheControlState( HWND hwndControl, CFilePickerState* aFilePickerState ); + + void SAL_CALL setHwnd( HWND hwndDlg ); + +private: + + inline sal_Bool SAL_CALL IsListboxControl( HWND hwndControl ) const; + + inline sal_Int16 SAL_CALL ListboxIdToListboxLabelId( sal_Int16 aListboxId ) const; + + inline HWND SAL_CALL GetListboxLabelItem( sal_Int16 aControlId ) const; + + // returns a hwnd for a control if successful + // if bIncludeStdCtrls is false, the standard file dialog + // controls like OK button, etc. will not be considered + // the function return 0 on failure + HWND SAL_CALL GetHwndDlgItem( sal_Int16 aControlId, sal_Bool bIncludeStdCtrls = sal_True ) const; + + HWND m_hwndDlg; +}; + +#endif
\ No newline at end of file |