diff options
Diffstat (limited to 'fpicker/source/win32/misc')
-rw-r--r-- | fpicker/source/win32/misc/AutoBuffer.cxx | 202 | ||||
-rw-r--r-- | fpicker/source/win32/misc/AutoBuffer.hxx | 121 | ||||
-rw-r--r-- | fpicker/source/win32/misc/WinImplHelper.cxx | 403 | ||||
-rw-r--r-- | fpicker/source/win32/misc/WinImplHelper.hxx | 132 | ||||
-rw-r--r-- | fpicker/source/win32/misc/makefile.mk | 89 | ||||
-rw-r--r-- | fpicker/source/win32/misc/resourceprovider.cxx | 280 | ||||
-rw-r--r-- | fpicker/source/win32/misc/resourceprovider.hxx | 96 |
7 files changed, 1323 insertions, 0 deletions
diff --git a/fpicker/source/win32/misc/AutoBuffer.cxx b/fpicker/source/win32/misc/AutoBuffer.cxx new file mode 100644 index 000000000000..593964ee9a7c --- /dev/null +++ b/fpicker/source/win32/misc/AutoBuffer.cxx @@ -0,0 +1,202 @@ +/************************************************************************* + * + * $RCSfile: AutoBuffer.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:11:06 $ + * + * 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 _AUTO_BUFFER_HXX_ +#include "AutoBuffer.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include <windows.h> + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using rtl::OUString; + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CAutoUnicodeBuffer::CAutoUnicodeBuffer( size_t size, sal_Bool bLazyCreation ) : + m_buffSize( size ), + m_pBuff( NULL ) +{ + if ( !bLazyCreation ) + init( ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CAutoUnicodeBuffer::~CAutoUnicodeBuffer( ) +{ + delete [] m_pBuff; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CAutoUnicodeBuffer::resize( size_t new_size ) +{ + OSL_ASSERT( new_size >= 0 ); + + if ( new_size != m_buffSize ) + { + if ( new_size > m_buffSize ) + { + delete [] m_pBuff; + m_pBuff = NULL; + } + + m_buffSize = new_size; + } + + return sal_True; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CAutoUnicodeBuffer::empty( ) +{ + if ( m_pBuff ) + ZeroMemory( m_pBuff, m_buffSize * sizeof( sal_Unicode ) ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CAutoUnicodeBuffer::fill( const sal_Unicode* pContent, size_t nLen ) +{ + OSL_ASSERT( pContent && m_buffSize && (m_buffSize >= nLen) ); + + init( ); + + sal_Bool bRet = sal_False; + + if ( m_pBuff && pContent && nLen ) + { + CopyMemory( m_pBuff, pContent, nLen * sizeof( sal_Unicode ) ); + bRet = sal_True; + } + + return bRet; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +size_t SAL_CALL CAutoUnicodeBuffer::size( ) const +{ + return m_buffSize; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CAutoUnicodeBuffer::operator sal_Unicode*( ) +{ + return m_pBuff; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Unicode* CAutoUnicodeBuffer::operator&( ) +{ + return m_pBuff; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +const sal_Unicode* CAutoUnicodeBuffer::operator&( ) const +{ + return m_pBuff; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CAutoUnicodeBuffer::init( ) +{ + if ( !m_pBuff && (m_buffSize > 0) ) + m_pBuff = new sal_Unicode[ m_buffSize ]; + + empty( ); +} diff --git a/fpicker/source/win32/misc/AutoBuffer.hxx b/fpicker/source/win32/misc/AutoBuffer.hxx new file mode 100644 index 000000000000..5d9d27178d67 --- /dev/null +++ b/fpicker/source/win32/misc/AutoBuffer.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: AutoBuffer.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:10:59 $ + * + * 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 _AUTO_BUFFER_HXX_ +#define _AUTO_BUFFER_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring> +#endif + +//------------------------------------------------------------- +// A simple unicode buffer management class, the class itself +// is responsible for the allocated unicode buffer, any +// modification of the buffer size outside the class may lead +// to undefined behaviour +//------------------------------------------------------------- + +class CAutoUnicodeBuffer +{ +public: + + // if bLazyCreation is true the buffer will be created + // when someone wants to fill the buffer + CAutoUnicodeBuffer( size_t size, sal_Bool bLazyCreation = sal_False ); + ~CAutoUnicodeBuffer( ); + + // resizes the buffer + sal_Bool SAL_CALL resize( size_t new_size ); + + // zeros the buffer + void SAL_CALL empty( ); + + // fills the buffer with a given content + sal_Bool SAL_CALL fill( const sal_Unicode* pContent, size_t nLen ); + + // returns the size of the buffer + size_t SAL_CALL size( ) const; + + // conversion operator + operator sal_Unicode*( ); + + // address operator + sal_Unicode* operator&( ); + + const sal_Unicode* operator&( ) const; + +private: + void SAL_CALL init( ); + +private: + size_t m_buffSize; // the number of unicode chars + sal_Unicode* m_pBuff; +}; + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/misc/WinImplHelper.cxx b/fpicker/source/win32/misc/WinImplHelper.cxx new file mode 100644 index 000000000000..e8e6ecfed91f --- /dev/null +++ b/fpicker/source/win32/misc/WinImplHelper.cxx @@ -0,0 +1,403 @@ +/************************************************************************* + * + * $RCSfile: WinImplHelper.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:11:06 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _AUTO_BUFFER_HXX_ +#include "AutoBuffer.hxx" +#endif + +#ifndef _WINIMPLHELPER_HXX_ +#include "WinImplHelper.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +#include <systools/win32/user9x.h> + +//------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------ + +using rtl::OUString; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::XInterface; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Sequence; + +//------------------------------------------------------------ +// determine if we are running under Win2000 +//------------------------------------------------------------ + +sal_Bool SAL_CALL IsWin2000( ) +{ + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + sal_Bool bRet = sal_False; + + osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX ); + bOsVersionInfoEx = GetVersionEx( ( OSVERSIONINFO* )&osvi ); + if( !bOsVersionInfoEx ) + { + // if OSVERSIONINFOEX doesn't work + osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + if( !GetVersionEx( ( OSVERSIONINFO* )&osvi ) ) + return sal_False; + } + + if( ( VER_PLATFORM_WIN32_NT == osvi.dwPlatformId ) && ( osvi.dwMajorVersion >= 5 ) ) + bRet = sal_True; + + return bRet; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxAddString( HWND hwnd, const OUString& aString ) +{ + LRESULT rc = SendMessageW( + hwnd, CB_ADDSTRING, 0, reinterpret_cast< LPARAM >(aString.getStr( )) ); + + OSL_ASSERT( (CB_ERR != rc) && (CB_ERRSPACE != rc) ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +OUString SAL_CALL ListboxGetString( HWND hwnd, sal_Int32 aPosition ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + OUString aString; + + LRESULT lItem = + SendMessageW( hwnd, CB_GETLBTEXTLEN, aPosition, 0 ); + + if ( (CB_ERR != lItem) && (lItem > 0) ) + { + // message returns the len of a combobox item + // without trailing '\0' that's why += 1 + lItem++; + + CAutoUnicodeBuffer aBuff( lItem ); + + LRESULT lRet = + SendMessageW( + hwnd, CB_GETLBTEXT, aPosition, + reinterpret_cast<LPARAM>(&aBuff) ); + + OSL_ASSERT( lRet != CB_ERR ); + + if ( CB_ERR != lRet ) + aString = OUString( aBuff, lRet ); + } + + return aString; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxAddItem( HWND hwnd, const Any& aItem, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + if ( !aItem.hasValue( ) || + aItem.getValueType( ) != getCppuType((OUString*)0) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid value type or any has no value" ), + rXInterface, + aArgPos ); + + OUString cbItem; + aItem >>= cbItem; + + ListboxAddString( hwnd, cbItem ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxAddItems( HWND hwnd, const Any& aItemList, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + if ( !aItemList.hasValue( ) || + aItemList.getValueType( ) != getCppuType((Sequence<OUString>*)0) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid value type or any has no value" ), + rXInterface, + aArgPos ); + + Sequence< OUString > aStringList; + aItemList >>= aStringList; + + sal_Int32 nItemCount = aStringList.getLength( ); + for( sal_Int32 i = 0; i < nItemCount; i++ ) + { + ListboxAddString( hwnd, aStringList[i] ); + } +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxDeleteItem( HWND hwnd, const Any& aPosition, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + if ( !aPosition.hasValue( ) || + ( (aPosition.getValueType( ) != getCppuType((sal_Int32*)0)) && + (aPosition.getValueType( ) != getCppuType((sal_Int16*)0)) && + (aPosition.getValueType( ) != getCppuType((sal_Int8*)0)) ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid value type or any has no value" ), + rXInterface, + aArgPos ); + + sal_Int32 nPos; + aPosition >>= nPos; + + LRESULT lRet = SendMessage( hwnd, CB_DELETESTRING, nPos, 0 ); + + // if the return value is CB_ERR the given + // index was not correct + if ( CB_ERR == lRet ) + throw IllegalArgumentException( + OUString::createFromAscii( "inavlid item position" ), + rXInterface, + aArgPos ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxDeleteItems( HWND hwnd, const Any& /*unused*/, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + LRESULT lRet = 0; + + do + { + // the return value on success is the number + // of remaining elements in the listbox + lRet = SendMessageW( hwnd, CB_DELETESTRING, 0, 0 ); + } + while ( (lRet != CB_ERR) && (lRet > 0) ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL ListboxSetSelectedItem( HWND hwnd, const Any& aPosition, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + if ( !aPosition.hasValue( ) || + ( (aPosition.getValueType( ) != getCppuType((sal_Int32*)0)) && + (aPosition.getValueType( ) != getCppuType((sal_Int16*)0)) && + (aPosition.getValueType( ) != getCppuType((sal_Int8*)0)) ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid value type or any has no value" ), + rXInterface, + aArgPos ); + + sal_Int32 nPos; + aPosition >>= nPos; + + if ( nPos < -1 ) + throw IllegalArgumentException( + OUString::createFromAscii("invalid index"), + rXInterface, + aArgPos ); + + LRESULT lRet = SendMessageW( hwnd, CB_SETCURSEL, nPos, 0 ); + + if ( (CB_ERR == lRet) && (-1 != nPos) ) + throw IllegalArgumentException( + OUString::createFromAscii("invalid index"), + rXInterface, + aArgPos ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +Any SAL_CALL ListboxGetItems( HWND hwnd ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + LRESULT nItemCount = SendMessageW( hwnd, CB_GETCOUNT, 0, 0 ); + + Sequence< OUString > aItemList; + + if ( CB_ERR != nItemCount ) + { + aItemList.realloc( nItemCount ); + + for ( sal_Int32 i = 0; i < nItemCount; i++ ) + { + aItemList[i] = ListboxGetString( hwnd, i ); + } + } + + Any aAny; + aAny <<= aItemList; + + return aAny; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +Any SAL_CALL ListboxGetSelectedItem( HWND hwnd ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + LRESULT idxItem = SendMessageW( hwnd, CB_GETCURSEL, 0, 0 ); + + Any aAny; + aAny <<= ListboxGetString( hwnd, idxItem ); + + return aAny; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +Any SAL_CALL CheckboxGetState( HWND hwnd ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + LRESULT lChkState = SendMessageW( hwnd, BM_GETCHECK, 0, 0 ); + sal_Bool bChkState = (lChkState == BST_CHECKED) ? sal_True : sal_False; + Any aAny; + aAny.setValue( &bChkState, getCppuType((sal_Bool*)0) ); + return aAny; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +void SAL_CALL CheckboxSetState( + HWND hwnd, const ::com::sun::star::uno::Any& aState, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( IllegalArgumentException ) +{ + OSL_ASSERT( IsWindow( hwnd ) ); + + if ( !aState.hasValue( ) || + aState.getValueType( ) != getCppuType((sal_Bool*)0) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid value type or any has no value" ), + rXInterface, + aArgPos ); + + sal_Bool bCheckState = *reinterpret_cast< const sal_Bool* >( aState.getValue( ) ); + WPARAM wParam = bCheckState ? BST_CHECKED : BST_UNCHECKED; + SendMessageW( hwnd, BM_SETCHECK, wParam, 0 ); +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +sal_uInt32 SAL_CALL _wcslenex( const sal_Unicode* pStr ) +{ + if ( !pStr ) + return 0; + + const sal_Unicode* pTemp = pStr; + sal_uInt32 strLen = 0; + while( *pTemp || *(pTemp + 1) ) + { + pTemp++; + strLen++; + } + + return strLen; +} diff --git a/fpicker/source/win32/misc/WinImplHelper.hxx b/fpicker/source/win32/misc/WinImplHelper.hxx new file mode 100644 index 000000000000..92f909a92a2e --- /dev/null +++ b/fpicker/source/win32/misc/WinImplHelper.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * $RCSfile: WinImplHelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:10:59 $ + * + * 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 _WINIMPLHELPER_HXX_ +#define _WINIMPLHELPER_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring> +#endif + +#include <windows.h> + +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL IsWin2000( ); + +// set actions +void SAL_CALL ListboxAddItem( + HWND hwnd, const ::com::sun::star::uno::Any& aItem, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + +void SAL_CALL ListboxAddItems( + HWND hwnd, const ::com::sun::star::uno::Any& aItemList, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang:: IllegalArgumentException ); + +void SAL_CALL ListboxDeleteItem( + HWND hwnd, const ::com::sun::star::uno::Any& aPosition, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + +void SAL_CALL ListboxDeleteItems( + HWND hwnd, const ::com::sun::star::uno::Any& aUnused, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + +void SAL_CALL ListboxSetSelectedItem( + HWND hwnd, const ::com::sun::star::uno::Any& aPosition, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + +// get actions +::com::sun::star::uno::Any SAL_CALL ListboxGetItems( HWND hwnd ); +::com::sun::star::uno::Any SAL_CALL ListboxGetSelectedItem( HWND hwnd ); + +// checkbox helper functions +::com::sun::star::uno::Any SAL_CALL CheckboxGetState( HWND hwnd ); + +void SAL_CALL CheckboxSetState( + HWND hwnd, const ::com::sun::star::uno::Any& aState, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rXInterface, sal_Int16 aArgPos ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + +// calculates the length of '\0' separated and '\0\0' +// ending strings used in some Win32 functions +// e.g. Filter\0*.txt\0\0 +// the returned length excludes the last '\0' +sal_uInt32 SAL_CALL _wcslenex( const sal_Unicode* pStr ); + +#endif diff --git a/fpicker/source/win32/misc/makefile.mk b/fpicker/source/win32/misc/makefile.mk new file mode 100644 index 000000000000..8241dfe04ca9 --- /dev/null +++ b/fpicker/source/win32/misc/makefile.mk @@ -0,0 +1,89 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:11:15 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJNAME=fpicker +TARGET=utils +LIBTARGET=NO + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +.INCLUDE : ..$/..$/cppumaker.mk + +CFLAGS+=/GX + +# --- Files ------------------------------------- + +SLOFILES=$(SLO)$/WinImplHelper.obj\ + $(SLO)$/AutoBuffer.obj\ + $(SLO)$/resourceprovider.obj + +LIB1TARGET=$(SLB)$/$(TARGET).lib +LIB1OBJFILES=$(SLOFILES) + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/fpicker/source/win32/misc/resourceprovider.cxx b/fpicker/source/win32/misc/resourceprovider.cxx new file mode 100644 index 000000000000..5333f98cf33c --- /dev/null +++ b/fpicker/source/win32/misc/resourceprovider.cxx @@ -0,0 +1,280 @@ +/************************************************************************* + * + * $RCSfile: resourceprovider.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:11:06 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef _RESOURCEPROVIDER_HXX_ +#include "resourceprovider.hxx" +#endif + +#ifndef _TOOLS_RESMGR_HXX +#include <tools/resmgr.hxx> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_COMMONFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#endif + +#include <svtools/svtools.hrc> + +//------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------ + +using rtl::OUString; +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +#define RES_NAME svt + +// because the label of a listbox is +// a control itself (static text) we +// have defined a control id for this +// label which is the listbox control +// id + 100 +#define LB_LABEL_OFFSET 100 + +const rtl::OUString TILDE = OUString::createFromAscii( "~" ); +const sal_Unicode TILDE_SIGN = L'~'; + +#define FOLDERPICKER_TITLE 500 +#define FOLDER_PICKER_DEF_DESCRIPTION 501 + +//------------------------------------------------------------ +// we have to translate control ids to resource ids +//------------------------------------------------------------ + +struct _Entry +{ + sal_Int32 ctrlId; + sal_Int16 resId; +}; + +_Entry CtrlIdToResIdTable[] = { + { CHECKBOX_AUTOEXTENSION, STR_SVT_FILEPICKER_AUTO_EXTENSION }, + { CHECKBOX_PASSWORD, STR_SVT_FILEPICKER_PASSWORD }, + { CHECKBOX_FILTEROPTIONS, STR_SVT_FILEPICKER_FILTER_OPTIONS }, + { CHECKBOX_READONLY, STR_SVT_FILEPICKER_READONLY }, + { CHECKBOX_LINK, STR_SVT_FILEPICKER_INSERT_AS_LINK }, + { CHECKBOX_PREVIEW, STR_SVT_FILEPICKER_SHOW_PREVIEW }, + { PUSHBUTTON_PLAY, STR_SVT_FILEPICKER_PLAY }, + { LISTBOX_VERSION + LB_LABEL_OFFSET, STR_SVT_FILEPICKER_VERSION }, + { LISTBOX_TEMPLATE + LB_LABEL_OFFSET, STR_SVT_FILEPICKER_TEMPLATES }, + { LISTBOX_IMAGE_TEMPLATE + LB_LABEL_OFFSET, STR_SVT_FILEPICKER_IMAGE_TEMPLATE }, + { CHECKBOX_SELECTION, STR_SVT_FILEPICKER_SELECTION }, + { FOLDERPICKER_TITLE, STR_SVT_FOLDERPICKER_DEFAULT_TITLE }, + { FOLDER_PICKER_DEF_DESCRIPTION, STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION } +}; + +const sal_Int32 SIZE_TABLE = sizeof( CtrlIdToResIdTable ) / sizeof( _Entry ); + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +sal_Int16 CtrlIdToResId( sal_Int32 aControlId ) +{ + sal_Int16 aResId = -1; + + for ( sal_Int32 i = 0; i < SIZE_TABLE; i++ ) + { + if ( CtrlIdToResIdTable[i].ctrlId == aControlId ) + { + aResId = CtrlIdToResIdTable[i].resId; + break; + } + } + + return aResId; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +class CResourceProvider_Impl +{ +public: + + //------------------------------------- + // + //------------------------------------- + + CResourceProvider_Impl( ) + { + m_ResMgr = CREATEVERSIONRESMGR( RES_NAME ); + } + + //------------------------------------- + // + //------------------------------------- + + ~CResourceProvider_Impl( ) + { + delete m_ResMgr; + } + + //------------------------------------- + // + //------------------------------------- + + OUString getResString( sal_Int16 aId ) + { + String aResString; + OUString aResOUString; + + try + { + OSL_ASSERT( m_ResMgr ); + + // translate the control id to a resource id + sal_Int16 aResId = CtrlIdToResId( aId ); + + if ( aResId > -1 ) + { + aResString = String( ResId( aResId, m_ResMgr ) ); + aResOUString = OUString( aResString ); + + // remove '~' signs, if there are two '~' signs + // in a row we remove only one of them + if ( aResOUString.indexOf( TILDE ) > -1 ) + { + sal_Int32 nStrLen = aResOUString.getLength( ); + rtl::OUStringBuffer aBuffer( nStrLen ); + sal_Int32 i = 0; + const sal_Unicode* pPos = aResOUString.getStr( ); + const sal_Unicode* pNext = aResOUString.getStr( ) + 1; + const sal_Unicode* pEnd = aResOUString.getStr( ) + nStrLen; + + while( pPos < pEnd ) + { + // we insert the next character only if the current character + // in not a '~' or the following character is also a '~' + if ( (*pPos != TILDE_SIGN) || + ((*pPos == TILDE_SIGN) && (pNext < pEnd) && (*pNext == TILDE_SIGN)) ) + { + aBuffer.insert( i, *pPos ); + i++; + } + + pPos++; + pNext++; + } + + aResOUString = aBuffer.makeStringAndClear( ); + } + } + } + catch(...) + { + } + + return aResOUString; + } + +public: + ResMgr* m_ResMgr; +}; + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +CResourceProvider::CResourceProvider( ) : + m_pImpl( new CResourceProvider_Impl() ) +{ +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +CResourceProvider::~CResourceProvider( ) +{ + delete m_pImpl; +} + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +OUString CResourceProvider::getResString( sal_Int32 aId ) +{ + return m_pImpl->getResString( aId ); +}
\ No newline at end of file diff --git a/fpicker/source/win32/misc/resourceprovider.hxx b/fpicker/source/win32/misc/resourceprovider.hxx new file mode 100644 index 000000000000..97c55fc21832 --- /dev/null +++ b/fpicker/source/win32/misc/resourceprovider.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: resourceprovider.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:10:59 $ + * + * 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 _RESOURCEPROVIDER_HXX_ +#define _RESOURCEPROVIDER_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring> +#endif + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +class CResourceProvider_Impl; + +class CResourceProvider +{ +public: + CResourceProvider( ); + ~CResourceProvider( ); + + rtl::OUString getResString( sal_Int32 aId ); + +private: + CResourceProvider_Impl* m_pImpl; +}; + +#endif |