2001-06-28 05:17:00 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* $RCSfile: controlaccess.cxx,v $
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2006-10-12 04:50:21 -05:00
|
|
|
* $Revision: 1.11 $
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2006-10-12 04:50:21 -05:00
|
|
|
* last change: $Author: obo $ $Date: 2006-10-12 10:50:21 $
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* 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.
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* 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.
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
2005-09-08 17:40:57 -05:00
|
|
|
* 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
|
2001-06-28 05:17:00 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 11:54:43 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_fpicker.hxx"
|
|
|
|
|
2001-06-28 05:17:00 -05:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// includes
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2003-03-25 11:05:07 -06:00
|
|
|
#include <tchar.h>
|
|
|
|
|
2001-06-28 05:17:00 -05:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _CONTROLACCESS_HXX_
|
|
|
|
#include "controlaccess.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WINIMPLHELPER_HXX_
|
|
|
|
#include "..\misc\WinImplHelper.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// we are using a table based algorithm to dispatch control
|
|
|
|
// actions there is one table containing one action table for
|
|
|
|
// each control class and one action table per control class
|
|
|
|
// which contains function pointer to control action functions
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// namespace directives
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
using rtl::OUString;
|
|
|
|
|
|
|
|
namespace // private
|
|
|
|
{
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// table setup
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_SETVALUE_FUNCTION_T CheckboxSetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
CheckboxSetState
|
|
|
|
};
|
|
|
|
const size_t SIZE_CHECKBOX_SETVALUE_FUNCTION_TABLE =
|
|
|
|
sizeof( CheckboxSetValueFunctionTable ) / sizeof( CTRL_SETVALUE_FUNCTION_T );
|
|
|
|
|
|
|
|
CTRL_GETVALUE_FUNCTION_T CheckboxGetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
CheckboxGetState
|
|
|
|
};
|
|
|
|
const size_t SIZE_CHECKBOX_GETVALUE_FUNCTION_TABLE =
|
|
|
|
sizeof( CheckboxGetValueFunctionTable ) / sizeof( CTRL_GETVALUE_FUNCTION_T );
|
|
|
|
|
|
|
|
CTRL_SETVALUE_FUNCTION_T ListboxSetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
ListboxAddItem,
|
|
|
|
ListboxAddItems,
|
|
|
|
ListboxDeleteItem,
|
|
|
|
ListboxDeleteItems,
|
|
|
|
ListboxSetSelectedItem
|
|
|
|
};
|
|
|
|
const size_t SIZE_LISTBOX_SETVALUE_FUNCTION_TABLE =
|
|
|
|
sizeof( ListboxSetValueFunctionTable ) / sizeof( CTRL_SETVALUE_FUNCTION_T );
|
|
|
|
|
|
|
|
CTRL_GETVALUE_FUNCTION_T ListboxGetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
ListboxGetItems,
|
2001-11-14 09:40:55 -06:00
|
|
|
ListboxGetSelectedItem,
|
|
|
|
ListboxGetSelectedItemIndex
|
2001-06-28 05:17:00 -05:00
|
|
|
};
|
|
|
|
const size_t SIZE_LISTBOX_GETVALUE_ACTION_TABLE =
|
|
|
|
sizeof( ListboxGetValueFunctionTable ) / sizeof( CTRL_GETVALUE_FUNCTION_T );
|
|
|
|
|
|
|
|
struct _ENTRY
|
|
|
|
{
|
|
|
|
LPVOID lpFunctionTable;
|
|
|
|
size_t TableSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
// an array of function tables, one for each control class
|
|
|
|
_ENTRY CtrlClassSetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
{ NULL, 0 },
|
|
|
|
{ CheckboxSetValueFunctionTable, SIZE_CHECKBOX_SETVALUE_FUNCTION_TABLE },
|
|
|
|
{ ListboxSetValueFunctionTable, SIZE_LISTBOX_SETVALUE_FUNCTION_TABLE },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
// an array of function tables, one for each control class
|
|
|
|
_ENTRY CtrlClassGetValueFunctionTable[] =
|
|
|
|
{
|
|
|
|
{ NULL, 0 },
|
|
|
|
{ CheckboxGetValueFunctionTable, SIZE_CHECKBOX_GETVALUE_FUNCTION_TABLE },
|
|
|
|
{ ListboxGetValueFunctionTable, SIZE_LISTBOX_GETVALUE_ACTION_TABLE },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_SETVALUE_FUNCTION_T SAL_CALL GetCtrlSetValueFunction(
|
|
|
|
CTRL_SETVALUE_FUNCTION_T* aCtrlSetValueFunctionTable, size_t aTableSize, sal_Int16 aCtrlAction )
|
|
|
|
{
|
|
|
|
if ( !aCtrlSetValueFunctionTable ||
|
2006-10-12 04:50:21 -05:00
|
|
|
aCtrlAction < 0
|
|
|
|
|| sal::static_int_cast< sal_uInt16 >(aCtrlAction) >= aTableSize )
|
2001-06-28 05:17:00 -05:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return aCtrlSetValueFunctionTable[aCtrlAction];
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_GETVALUE_FUNCTION_T SAL_CALL GetCtrlGetValueFunction(
|
|
|
|
CTRL_GETVALUE_FUNCTION_T* aCtrlGetValueFunctionTable, size_t aTableSize, sal_Int16 aCtrlAction )
|
|
|
|
{
|
|
|
|
if ( !aCtrlGetValueFunctionTable ||
|
2006-10-12 04:50:21 -05:00
|
|
|
aCtrlAction < 0 ||
|
|
|
|
sal::static_int_cast< sal_uInt16 >(aCtrlAction) >= aTableSize )
|
2001-06-28 05:17:00 -05:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return aCtrlGetValueFunctionTable[aCtrlAction];
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
|
|
|
_ENTRY SAL_CALL GetCtrlClassSetValueFunctionTable( CTRL_CLASS aCtrlClass )
|
|
|
|
{
|
|
|
|
return CtrlClassSetValueFunctionTable[aCtrlClass];
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
|
|
|
_ENTRY SAL_CALL GetCtrlClassGetValueFunctionTable( CTRL_CLASS aCtrlClass )
|
|
|
|
{
|
|
|
|
return CtrlClassGetValueFunctionTable[aCtrlClass];
|
|
|
|
}
|
|
|
|
|
|
|
|
int WindowsFileOpenCtrlIds[] =
|
|
|
|
{
|
|
|
|
0,
|
2002-10-30 07:48:34 -06:00
|
|
|
IDOK, // PUSHBUTTON_OK
|
|
|
|
IDCANCEL, // PUSHBUTTON_CANCEL
|
|
|
|
cmb1, // LISTBOX_FILTER
|
|
|
|
0, // CONTROL_FILEVIEW
|
|
|
|
0, // not available in system file picker
|
|
|
|
stc2, // LISTBOX_FILTER_LABEL
|
|
|
|
stc3 // LISTBOX_FILE_NAME_LABEL
|
2001-06-28 05:17:00 -05:00
|
|
|
};
|
2006-09-25 06:52:15 -05:00
|
|
|
const int SIZE_WINDOWS_FILEOPEN_CTRL_IDS =
|
2002-10-30 07:48:34 -06:00
|
|
|
sizeof(WindowsFileOpenCtrlIds)/sizeof(WindowsFileOpenCtrlIds[0]);
|
2001-06-28 05:17:00 -05:00
|
|
|
|
|
|
|
}; // end namespace
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_SETVALUE_FUNCTION_T SAL_CALL GetCtrlSetValueFunction( CTRL_CLASS aCtrlClass, sal_Int16 aCtrlAction )
|
|
|
|
{
|
|
|
|
_ENTRY aEntry =
|
|
|
|
GetCtrlClassSetValueFunctionTable( aCtrlClass );
|
|
|
|
|
|
|
|
return GetCtrlSetValueFunction(
|
|
|
|
reinterpret_cast< CTRL_SETVALUE_FUNCTION_T* >( aEntry.lpFunctionTable ),
|
|
|
|
aEntry.TableSize,
|
|
|
|
aCtrlAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_GETVALUE_FUNCTION_T SAL_CALL GetCtrlGetValueFunction( CTRL_CLASS aCtrlClass, sal_Int16 aCtrlAction )
|
|
|
|
{
|
|
|
|
_ENTRY aEntry =
|
|
|
|
GetCtrlClassGetValueFunctionTable( aCtrlClass );
|
|
|
|
|
|
|
|
return GetCtrlGetValueFunction(
|
|
|
|
reinterpret_cast< CTRL_GETVALUE_FUNCTION_T* >( aEntry.lpFunctionTable ),
|
|
|
|
aEntry.TableSize,
|
|
|
|
aCtrlAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
CTRL_CLASS SAL_CALL GetCtrlClass( HWND hwndCtrl )
|
|
|
|
{
|
|
|
|
CTRL_CLASS aCtrlClass = UNKNOWN;
|
2003-03-25 11:05:07 -06:00
|
|
|
TCHAR aClassName[256];
|
2001-06-28 05:17:00 -05:00
|
|
|
|
2003-04-08 09:47:59 -05:00
|
|
|
int nRet = GetClassName(hwndCtrl,aClassName,(sizeof(aClassName)/sizeof(TCHAR)));
|
2002-03-21 00:40:13 -06:00
|
|
|
if (nRet)
|
2001-06-28 05:17:00 -05:00
|
|
|
{
|
2003-03-25 11:05:07 -06:00
|
|
|
if (0 == _tcsicmp(aClassName,TEXT("button")))
|
2001-06-28 05:17:00 -05:00
|
|
|
{
|
|
|
|
// button means many things so we have
|
|
|
|
// to find out what button it is
|
2002-03-21 00:40:13 -06:00
|
|
|
LONG lBtnStyle = GetWindowLong(hwndCtrl,GWL_STYLE);
|
|
|
|
if (lBtnStyle & BS_CHECKBOX)
|
2001-06-28 05:17:00 -05:00
|
|
|
aCtrlClass = CHECKBOX;
|
2002-03-21 00:40:13 -06:00
|
|
|
else if (((lBtnStyle & BS_PUSHBUTTON) == 0) || (lBtnStyle & BS_DEFPUSHBUTTON))
|
2001-06-28 05:17:00 -05:00
|
|
|
aCtrlClass = PUSHBUTTON;
|
|
|
|
}
|
2003-03-25 11:05:07 -06:00
|
|
|
else if (0 == _tcsicmp(aClassName,TEXT("listbox")) ||
|
|
|
|
0 == _tcsicmp(aClassName,TEXT("combobox")))
|
2001-06-28 05:17:00 -05:00
|
|
|
aCtrlClass = LISTBOX;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aCtrlClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
int SAL_CALL CommonFilePickerCtrlIdToWinFileOpenCtrlId( sal_Int16 aControlId )
|
|
|
|
{
|
|
|
|
if ( aControlId < 0 || aControlId > SIZE_WINDOWS_FILEOPEN_CTRL_IDS )
|
|
|
|
return aControlId;
|
|
|
|
|
|
|
|
return WindowsFileOpenCtrlIds[aControlId];
|
|
|
|
}
|