diff options
author | Tino Rachui <tra@openoffice.org> | 2001-06-28 10:17:00 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-06-28 10:17:00 +0000 |
commit | 6a593fde3453067fca02ec22a2d9f6196a0a5f5c (patch) | |
tree | 2ba6fd33dfee53c5843d95a597dec93c5aa2c19b | |
parent | #87759#not so strictly check in methods that expect sal_Int32 now also accept... (diff) | |
download | core-6a593fde3453067fca02ec22a2d9f6196a0a5f5c.tar.gz core-6a593fde3453067fca02ec22a2d9f6196a0a5f5c.zip |
moved from sysui because of cyclic build dependencies
47 files changed, 11075 insertions, 0 deletions
diff --git a/fpicker/prj/build.lst b/fpicker/prj/build.lst new file mode 100644 index 000000000000..bb0ad7287812 --- /dev/null +++ b/fpicker/prj/build.lst @@ -0,0 +1,5 @@ +fp fpicker : xml2cmp drafts rdbmaker svtools NULL +fp fpicker\source\win32\filepicker nmake - w fp_win32_filepicker NULL +fp fpicker\source\win32\folderpicker nmake - w fp_win32_folderpicker NULL +fp fpicker\source\win32\misc nmake - w fp_win32_misc fp_win32_filepicker fp_win32_folderpicker NULL +fp fpicker\util nmake - all fp_util fp_win32_filepicker fp_win32_misc fp_win32_folderpicker NULL diff --git a/fpicker/prj/d.lst b/fpicker/prj/d.lst new file mode 100644 index 000000000000..6a9b2d76a439 --- /dev/null +++ b/fpicker/prj/d.lst @@ -0,0 +1,4 @@ +..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll + +..\source\win32\filepicker\*.xml %_DEST%\xml%_EXT%\*.xml +..\source\win32\folderpicker\*.xml %_DEST%\xml%_EXT%\*.xml diff --git a/fpicker/source/win32/filepicker/FPServiceInfo.hxx b/fpicker/source/win32/filepicker/FPServiceInfo.hxx new file mode 100644 index 000000000000..76a9aca45e17 --- /dev/null +++ b/fpicker/source/win32/filepicker/FPServiceInfo.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * $RCSfile: FPServiceInfo.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _FPSERVICEINFO_HXX_ +#define _FPSERVICEINFO_HXX_ + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +// the service name is a description of a set of +// interfaces (is the same as component categories in COM) + +#define TMPL95_FILEOPEN_READONLY_VERSION_BOX_ID 1000 +#define TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID 1001 + +#define TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID 2000 +#define TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID 2001 + +#define TMPL95_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID 3000 +#define TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID 3001 + +#define TMPL95_FILESAVE_AUTOEXT_PASSWORD_BOX_ID 4000 +#define TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID 4001 + +#define TMPL95_AUTOEXT_PASSWORD_FILTEROPTION_BOX 5000 +#define TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX 5001 + +#define TMPL95_PLAY_PUSHBUTTON 6000 +#define TMPL2000_PLAY_PUSHBUTTON 6001 + +#define TMPL95_AUTOEXT_SELECTION_BOX 7000 +#define TMPL2000_AUTOEXT_SELECTION_BOX 7001 + +#define TMPL95_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID 8000 +#define TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID 8001 + +// the service names +#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.SystemFilePicker" + +// the implementation names +#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FilePicker" + +// the registry key names +// a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName" +// < Implementation-Name ></UNO/SERVICES/>< Service-Name > +#define FILE_PICKER_REGKEY_NAME "/com.sun.star.ui.dialogs.Win32FilePicker/UNO/SERVICES/com.sun.star.ui.dialogs.SystemFilePicker" + +#endif diff --git a/fpicker/source/win32/filepicker/FPentry.cxx b/fpicker/source/win32/filepicker/FPentry.cxx new file mode 100644 index 000000000000..29a92ba83dfb --- /dev/null +++ b/fpicker/source/win32/filepicker/FPentry.cxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * $RCSfile: FPentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//---------------------------------------------- +// includes of other projects +//---------------------------------------------- + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _FILEPICKER_HXX_ +#include "FilePicker.hxx" +#endif + +#ifndef _FPSERVICEINFO_HXX_ +#include "FPServiceInfo.hxx" +#endif + +//----------------------------------------------- +// namespace directives +//----------------------------------------------- + +using namespace ::rtl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::container ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::registry ; +using namespace ::cppu ; +using ::com::sun::star::ui::dialogs::XFilePicker; + +//------------------------------------------------ +// +//------------------------------------------------ + +static Reference< XInterface > SAL_CALL createInstance( + const Reference< XMultiServiceFactory >& rServiceManager ) +{ + return Reference< XInterface >( + static_cast< XFilePicker* >( + new CFilePicker( rServiceManager ) ) ); +} + +//------------------------------------------------ +// the three uno functions that will be exported +//------------------------------------------------ + +extern "C" +{ + +//------------------------------------------------ +// component_getImplementationEnvironment +//------------------------------------------------ + +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "InvalidRegistryException caught" ); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void* SAL_CALL component_getFactory( + const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) +{ + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME ); + + Reference< XSingleServiceFactory > xFactory ( createSingleFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.cxx b/fpicker/source/win32/filepicker/FileOpenDlg.cxx new file mode 100644 index 000000000000..fa40c98fcc49 --- /dev/null +++ b/fpicker/source/win32/filepicker/FileOpenDlg.cxx @@ -0,0 +1,683 @@ +/************************************************************************* + * + * $RCSfile: FileOpenDlg.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _WINIMPLHELPER_HXX_ +#include "..\misc\WinImplHelper.hxx" +#endif + +#ifndef _FILEOPENDLG_HXX_ +#include "FileOpenDlg.hxx" +#endif + +#include <systools/win32/comdlg9x.h> +#include <systools/win32/user9x.h> + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using rtl::OUString; + +//------------------------------------------------------------------------ +// constants +//------------------------------------------------------------------------ + +// we choose such large buffers because the size of +// an single line edit field can be up to 32k; if +// a user has a multi selection FilePicker and selects +// a lot of files in a large directory we may reach this +// limit and don't want to get out of memory; +// another much more elegant way would be to subclass the +// FileOpen dialog and overload the BM_CLICK event of the +// OK button so that we determine the size of the text +// currently in the edit field and resize our buffer +// appropriately - in the future we will do this +const size_t MAX_FILENAME_BUFF_SIZE = 32000; +const size_t MAX_FILETITLE_BUFF_SIZE = 32000; +const size_t MAX_FILTER_BUFF_SIZE = 4096; + +//------------------------------------------------------------------------ +// static member declaration +//------------------------------------------------------------------------ + +CFileOpenDialog* CFileOpenDialog::s_fileOpenDlgInst; + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CFileOpenDialog::CFileOpenDialog( + sal_Bool bFileOpenDialog, + sal_uInt32 dwFlags, + sal_uInt32 dwTemplateId, + HINSTANCE hInstance ) : + m_filterBuffer( MAX_FILTER_BUFF_SIZE, sal_True ), + m_fileNameBuffer( MAX_FILENAME_BUFF_SIZE ), + m_fileTitleBuffer( MAX_FILETITLE_BUFF_SIZE ), + m_helperBuffer( MAX_FILENAME_BUFF_SIZE ), + m_hwndFileOpenDlg( 0 ), + m_hwndFileOpenDlgChild( 0 ), + m_bFileOpenDialog( bFileOpenDialog ) +{ + // initialize the OPENFILENAME struct + if ( IsWin2000( ) ) + { + ZeroMemory( &m_ofn, sizeof( m_ofn ) ); + m_ofn.lStructSize = sizeof( m_ofn ); + } + else // OSVER < Win2000 + { + // the size of the OPENFILENAME structure is different + // under windows < win2000 + ZeroMemory( &m_ofn, _OPENFILENAME_SIZE_VERSION_400W ); + m_ofn.lStructSize = _OPENFILENAME_SIZE_VERSION_400W; + } + + m_ofn.Flags |= dwFlags | + OFN_EXPLORER | + OFN_ENABLEHOOK | + OFN_HIDEREADONLY | + OFN_PATHMUSTEXIST | + OFN_FILEMUSTEXIST; + + // it is a little hack but how else could + // we get a parent window (using a vcl window?) + m_ofn.hwndOwner = GetForegroundWindow( ); + + // we don't use custom filters + m_ofn.lpstrCustomFilter = 0; + + m_ofn.lpstrFile = m_fileNameBuffer; + m_ofn.nMaxFile = m_fileNameBuffer.size( ); + + m_ofn.lpstrFileTitle = m_fileTitleBuffer; + m_ofn.nMaxFileTitle = m_fileTitleBuffer.size( ); + + m_ofn.lpfnHook = CFileOpenDialog::ofnHookProc; + + // set a custom template + if ( dwTemplateId ) + { + OSL_ASSERT( hInstance ); + + m_ofn.Flags |= OFN_ENABLETEMPLATE; + m_ofn.lpTemplateName = MAKEINTRESOURCEW( dwTemplateId ); + m_ofn.hInstance = hInstance; + } + + // set a pointer to myself as ofn parameter + m_ofn.lCustData = reinterpret_cast< long > ( this ); + + // initialize the static member to reconnect + // to the instance from callback methods + s_fileOpenDlgInst = this; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CFileOpenDialog::~CFileOpenDialog( ) +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::setTitle( const OUString& aTitle ) +{ + m_dialogTitle = aTitle.getStr( ); + m_ofn.lpstrTitle = m_dialogTitle.getStr( ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void CFileOpenDialog::setFilter( const OUString& aFilter ) +{ + m_filterBuffer.resize( aFilter.getLength( ) + 1 ); + m_filterBuffer.fill( aFilter.getStr( ), aFilter.getLength( ) ); + m_ofn.lpstrFilter = m_filterBuffer; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool CFileOpenDialog::setFilterIndex( sal_uInt32 aIndex ) +{ + OSL_ASSERT( aIndex > 0 ); + m_ofn.nFilterIndex = aIndex; + return sal_True; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 CFileOpenDialog::getSelectedFilterIndex( ) const +{ + return m_ofn.nFilterIndex; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::setDefaultName( const OUString& aName ) +{ + m_fileNameBuffer.empty( ); + m_fileNameBuffer.fill( aName.getStr( ), aName.getLength( ) ); + m_ofn.lpstrFile = m_fileNameBuffer; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::setDisplayDirectory( const OUString& aDirectory ) +{ + m_displayDirectory = aDirectory; + m_ofn.lpstrInitialDir = m_displayDirectory; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +rtl::OUString SAL_CALL CFileOpenDialog::getDisplayDirectory( ) const +{ + return m_displayDirectory; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +rtl::OUString SAL_CALL CFileOpenDialog::getFullFileName( ) const +{ + return OUString( &m_fileNameBuffer, _wcslenex( &m_fileNameBuffer ) ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +rtl::OUString SAL_CALL CFileOpenDialog::getFileName( ) const +{ + return OUString( &m_fileTitleBuffer, wcslen( &m_fileTitleBuffer ) + 1 ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +rtl::OUString CFileOpenDialog::getFileExtension( ) +{ + OUString fileExt; + + if ( m_ofn.nFileExtension ) + fileExt = OUString( m_fileNameBuffer + m_ofn.nFileExtension, + wcslen( m_fileNameBuffer + m_ofn.nFileExtension ) ); + + return fileExt; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void CFileOpenDialog::setDefaultFileExtension( const OUString& aExtension ) +{ + m_defaultExtension = aExtension; + m_ofn.lpstrDefExt = m_defaultExtension.getStr( ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::setMultiSelectionMode( sal_Bool bMode ) +{ + if ( bMode ) + m_ofn.Flags |= OFN_ALLOWMULTISELECT; + else if ( m_ofn.Flags & OFN_ALLOWMULTISELECT ) + m_ofn.Flags ^= OFN_ALLOWMULTISELECT; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CFileOpenDialog::getMultiSelectionMode( ) const +{ + return ( m_ofn.Flags & OFN_ALLOWMULTISELECT ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool CFileOpenDialog::setControlLabel( sal_Int16 ElementID, const OUString& aLabel ) +{ + return sal_True; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::enableControl( sal_Int16 ElementID, sal_Bool bEnabled ) +{ + +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool CFileOpenDialog::showControl( sal_Int16 ElementID, sal_Bool bShow ) +{ + return sal_True; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CFileOpenDialog::POSITION SAL_CALL CFileOpenDialog::beginEnumFileNames( ) +{ + return 0; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CFileOpenDialog::getNextFileName( + POSITION& pos, OUString& aNextFileName ) +{ + return sal_False; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Int16 SAL_CALL CFileOpenDialog::doModal( ) +{ + sal_Int16 nRC = -1; + + // pre-processing + if ( preModal( ) ) + { + sal_Bool bRet; + if ( m_bFileOpenDialog ) + bRet = ::GetOpenFileNameW( reinterpret_cast< LPOPENFILENAMEW >( &m_ofn ) ); + else + bRet = ::GetSaveFileNameW( reinterpret_cast< LPOPENFILENAMEW >( &m_ofn ) ); + + nRC = 1; + if ( !bRet ) + { +#ifdef _DEBUG + sal_uInt32 nError = CommDlgExtendedError( ); + nRC = (0 == nError) ? 0 : -1; +#else + nRC = (0 == CommDlgExtendedError( )) ? 0 : -1; +#endif + } + + // post-processing + postModal( nRC ); + } + + return nRC; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 SAL_CALL CFileOpenDialog::getLastDialogError( ) const +{ + return CommDlgExtendedError( ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CFileOpenDialog::preModal( ) +{ + return sal_True; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::postModal( sal_Int16 nDialogResult ) +{ + OSL_ASSERT( (-1 <= nDialogResult) && (nDialogResult <= 1) ); + + if ( m_ofn.lpstrFile ) + { + OUString lastDir; + sal_Unicode* pLastDirChar = m_ofn.lpstrFile + m_ofn.nFileOffset - 1; + if ( m_ofn.nFileOffset && 0 == *pLastDirChar ) + lastDir = OUString( m_ofn.lpstrFile, m_ofn.nFileOffset - 1 ); + else if ( m_ofn.nFileOffset ) + lastDir = OUString( m_ofn.lpstrFile, m_ofn.nFileOffset ); + + m_displayDirectory = lastDir; + } +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +OUString SAL_CALL CFileOpenDialog::getCurrentFilePath( ) const +{ + OSL_ASSERT( IsWindow( m_hwndFileOpenDlg ) ); + + LPARAM nLen = SendMessageW( + m_hwndFileOpenDlg, + CDM_GETFILEPATH, + m_helperBuffer.size( ), + reinterpret_cast< LPARAM >( &m_helperBuffer ) ); + + OUString filePath; + + if ( nLen > 0 ) + filePath = OUString( &m_helperBuffer, (nLen - 1) ); + + return filePath; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +OUString SAL_CALL CFileOpenDialog::getCurrentFolderPath( ) const +{ + OSL_ASSERT( IsWindow( m_hwndFileOpenDlg ) ); + + LPARAM nLen = SendMessageW( + m_hwndFileOpenDlg, + CDM_GETFOLDERPATH, + m_helperBuffer.size( ), + reinterpret_cast< LPARAM >( &m_helperBuffer ) ); + + OUString folderPath; + + if ( nLen > 0 ) + folderPath = OUString( &m_helperBuffer, (nLen -1) ); + + return folderPath; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +OUString SAL_CALL CFileOpenDialog::getCurrentFileName( ) const +{ + OSL_ASSERT( IsWindow( m_hwndFileOpenDlg ) ); + + // this is an ugly hack because beause + // CDM_GETSPEC and BFFM_SETSTATUSTEXT + // message id are equal and we have only + // one SendMessageW wrapper for Win95 + int MsgId = CDM_GETSPEC; + + OSVERSIONINFO OSVerInfo; + + OSVerInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &OSVerInfo ); + + // if windows 95/98 + if ( VER_PLATFORM_WIN32_WINDOWS == OSVerInfo.dwPlatformId ) + MsgId = CDM_GETSPEC + 100; + + LPARAM nLen = SendMessageW( + m_hwndFileOpenDlg, + MsgId, + m_helperBuffer.size( ), + reinterpret_cast< LPARAM >( &m_helperBuffer ) ); + + OUString fileName; + + if ( nLen > 0 ) + fileName = OUString( &m_helperBuffer, (nLen - 1) ); + + return fileName; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 SAL_CALL CFileOpenDialog::onShareViolation( const OUString& aPathName) +{ + return 0; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 SAL_CALL CFileOpenDialog::onFileOk() +{ + return 0; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onSelChanged( HWND hwndListBox ) +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onHelp( ) +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onInitDone() +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onFolderChanged() +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onTypeChanged( sal_uInt32 nFilterIndex ) +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::onInitDialog( HWND hwndDlg, HWND hwndChild ) +{ + +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 SAL_CALL CFileOpenDialog::onCtrlCommand( + HWND hwndChild, sal_uInt16 ctrlId, sal_uInt16 notifyCode ) +{ + return 0; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_uInt32 SAL_CALL CFileOpenDialog::onWMNotify( HWND hwndChild, LPOFNOTIFYW lpOfNotify ) +{ + switch( lpOfNotify->hdr.code ) + { + case CDN_SHAREVIOLATION: + return onShareViolation( lpOfNotify->pszFile ); + + case CDN_FILEOK: + return onFileOk( ); + + case CDN_SELCHANGE: + onSelChanged( lpOfNotify->hdr.hwndFrom ); + break; + + case CDN_HELP: + onHelp( ); + break; + + case CDN_INITDONE: + onInitDone( ); + break; + + case CDN_FOLDERCHANGE: + onFolderChanged( ); + break; + + case CDN_TYPECHANGE: + onTypeChanged( lpOfNotify->lpOFN->nFilterIndex ); + break; + } + + return 0; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CFileOpenDialog::handleInitDialog( HWND hwndDlg, HWND hwndChild ) +{ + m_hwndFileOpenDlg = hwndDlg; + m_hwndFileOpenDlgChild = hwndChild; + + // calling virtual function which the + // client can overload + onInitDialog( hwndDlg, hwndChild ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +unsigned int CALLBACK CFileOpenDialog::ofnHookProc( + HWND hChildDlg, unsigned int uiMsg, WPARAM wParam, LPARAM lParam ) +{ + CFileOpenDialog* pImpl = CFileOpenDialog::s_fileOpenDlgInst; + OSL_ASSERT( pImpl ); + + switch( uiMsg ) + { + case WM_INITDIALOG: + pImpl->handleInitDialog( + GetParent( hChildDlg ), + hChildDlg ); + return 0; + + case WM_NOTIFY: + return pImpl->onWMNotify( + hChildDlg, reinterpret_cast< LPOFNOTIFYW >( lParam ) ); + + case WM_COMMAND: + return pImpl->onCtrlCommand( + hChildDlg, LOWORD( wParam ), HIWORD( lParam ) ); + } + + return 0; +} diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.hxx b/fpicker/source/win32/filepicker/FileOpenDlg.hxx new file mode 100644 index 000000000000..0f9542b3d68f --- /dev/null +++ b/fpicker/source/win32/filepicker/FileOpenDlg.hxx @@ -0,0 +1,350 @@ +/************************************************************************* + * + * $RCSfile: FileOpenDlg.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _FILEOPENDLG_HXX_ +#define _FILEOPENDLG_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring> +#endif + +#ifndef _AUTO_BUFFER_HXX_ +#include "..\misc\AutoBuffer.hxx" +#endif + +#include <windows.h> + +// because we don't want to import the new W2k platform skd +// into our build environment if have stolen the definition +// for the new OPENFILENAME structure from the new headers + +#if (_WIN32_WINNT >= 0x0500) + +#ifndef CDSIZEOF_STRUCT +#define CDSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) +#endif + +typedef struct _tagOFNW { + DWORD lStructSize; + HWND hwndOwner; + HINSTANCE hInstance; + LPCWSTR lpstrFilter; + LPWSTR lpstrCustomFilter; + DWORD nMaxCustFilter; + DWORD nFilterIndex; + LPWSTR lpstrFile; + DWORD nMaxFile; + LPWSTR lpstrFileTitle; + DWORD nMaxFileTitle; + LPCWSTR lpstrInitialDir; + LPCWSTR lpstrTitle; + DWORD Flags; + WORD nFileOffset; + WORD nFileExtension; + LPCWSTR lpstrDefExt; + LPARAM lCustData; + LPOFNHOOKPROC lpfnHook; + LPCWSTR lpTemplateName; +#ifdef _MAC + LPEDITMENU lpEditInfo; + LPCSTR lpstrPrompt; +#endif +#if (_WIN32_WINNT >= 0x0500) + void * pvReserved; + DWORD dwReserved; + DWORD FlagsEx; +#endif // (_WIN32_WINNT >= 0x0500) +} _OPENFILENAMEW, *_LPOPENFILENAMEW; + +#define _OPENFILENAME_SIZE_VERSION_400W CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName) + +#endif // (_WIN32_WINNT >= 0x0500) + + +//------------------------------------------------------------- +// A simple wrapper class around the Win32 GetOpenFileName API. +// This class is not thread-safe and only one instance at a +// time is allowed +//------------------------------------------------------------- + +class CFileOpenDialog +{ +public: + typedef sal_Unicode* POSITION; + +public: + + // ctor + // bFileOpenDialog idicates if we want a FileOpen or FileSave + // dialog + // dwFlags see OPENFILENAME + // dwTemplateId - an ID for custom templates + // hInstance - an instance handle for the module + // which provides the custom template, unused if dwTemplateId + // is 0 + CFileOpenDialog( + sal_Bool bFileOpenDialog = sal_True, + sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + sal_uInt32 dwTemplateId = 0, + HINSTANCE hInstance = 0 ); + + virtual ~CFileOpenDialog( ); + + virtual void SAL_CALL setTitle( const rtl::OUString& aTitle ); + + // to set a filter string using the M$ format + // e.g. FltName\0*.txt;*.rtf\0...\0\0 + void SAL_CALL setFilter( const rtl::OUString& aFilter ); + + // set the index of the current filter when the + // dialog is about to shown, the index starts with 1 + // the function succeeded if the given filter index + // is greater than zero and is a valid position + // within filter string that was previously set + sal_Bool SAL_CALL setFilterIndex( sal_uInt32 aIndex ); + + // get the index of the currently selected filter + // the index of the returned filter starts with 1 + sal_uInt32 SAL_CALL getSelectedFilterIndex( ) const; + + // set the name and optional the path of the + // file that will be initially be shown when + // the dialog will be displayed + virtual void SAL_CALL setDefaultName( const rtl::OUString& aName ); + + // set the initial directory + virtual void SAL_CALL setDisplayDirectory( const rtl::OUString& aDirectory ); + + // returns only the path of the selected file + virtual rtl::OUString SAL_CALL getDisplayDirectory( ) const; + + // returns the full file name including drive letter, path + // file name and file extension + virtual rtl::OUString SAL_CALL getFullFileName( ) const; + + // returns the file name and the file extension without + // drive letter and path + rtl::OUString SAL_CALL getFileName( ) const; + + // returns the file extension of the selected file + rtl::OUString SAL_CALL getFileExtension( ); + + // set a default extension, only the first three letters of + // the given extension will be used; the given extension + // should not contain a '.' + void SAL_CALL setDefaultFileExtension( const rtl::OUString& aExtension ); + + // enables or disables the multiselection mode for + // the FileOpen/FileSave dialog + void SAL_CALL setMultiSelectionMode( sal_Bool bMode ); + + // returns whether multi-selection mode is enabled or not + sal_Bool SAL_CALL getMultiSelectionMode( ) const; + + // sets the label of the specified control + // returns true on success or false if the control id + // is invalid or another error occured + sal_Bool SAL_CALL setControlLabel( sal_Int16 ElementID, const rtl::OUString& aLabel ); + + // enables or disables the specified control + virtual void SAL_CALL enableControl( sal_Int16 ElementID, sal_Bool bEnabled ); + + // shows or hides a control ( bShow = true shows the control + // and bShow = false hides the control ) + // returns true on success and false if the control id + // is invalid or another error occured + sal_Bool SAL_CALL showControl( sal_Int16 ElementID, sal_Bool bShow ); + + // starts enumerating the selected file names if + // the multiselection mode is enabled + POSITION SAL_CALL beginEnumFileNames( ); + + // returns true if multiselection mode is enabled and + // another file name was copied to aNextFileName + // else returns false + // on success the function returns the complete + // file name including drive letter and path + // pos is an in-out parameter and receives the next + // position when there are further file names or + // 0 if there aren't + sal_Bool SAL_CALL getNextFileName( + /*in|out*/ POSITION& pos, rtl::OUString& aNextFileName ); + + // shows the dialog, calls preModal before + // showing the dialog and postModal after + // showing the dialog + // the method returns: + // 0 - when the dialog was canceled by the user + // 1 - when the dialog was closed with ok + // -1 - when an error occured + sal_Int16 SAL_CALL doModal( ); + + // returns the last dialog error that occured + sal_uInt32 SAL_CALL getLastDialogError( ) const; + +protected: + + // retrievs the currently selected file + // including path and drive information + // can be called only if the dialog is + // already displayed + rtl::OUString SAL_CALL getCurrentFilePath( ) const; + + // retrievs the currently selected folder + rtl::OUString SAL_CALL getCurrentFolderPath( ) const; + + // retrievs the currently selected file name + // without drive and path + rtl::OUString SAL_CALL getCurrentFileName( ) const; + + // have to be overwritten when subclasses + // want to do special pre- and post-modal + // processing + + // if preModal return true processing will + // continue else doModal exit without showing + // a dialog and returns -1 + virtual sal_Bool SAL_CALL preModal( ); + + // post modal processing + // the function should accept only values returned from + // doModal and act appropriately + virtual void SAL_CALL postModal( sal_Int16 nDialogResult ); + + // message handler, to be overwritten by subclasses + virtual sal_uInt32 SAL_CALL onShareViolation( const rtl::OUString& aPathName ); + virtual sal_uInt32 SAL_CALL onFileOk(); + virtual void SAL_CALL onSelChanged( HWND hwndListBox ); + virtual void SAL_CALL onHelp( ); + + // only called back if OFN_EXPLORER is set + virtual void SAL_CALL onInitDone(); + virtual void SAL_CALL onFolderChanged(); + virtual void SAL_CALL onTypeChanged( sal_uInt32 nFilterIndex ); + + // call base class method first when overloading + virtual void SAL_CALL onInitDialog( HWND hwndDlg, HWND hwndChild ); + + virtual sal_uInt32 SAL_CALL onCtrlCommand( HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode ); + + sal_uInt32 SAL_CALL onWMNotify( HWND hwndChild, LPOFNOTIFYW lpOfNotify ); + + // we use non-virtual functions to do necessary work before + // calling the virtual funtions (see Gamma: Template method) + void SAL_CALL handleInitDialog( HWND hwndDlg, HWND hwndChild ); + +protected: + + // handle to the window of the + // FileOpen/FileSave dialog + // will be set on message + // WM_INITDIALOG, before this + // value is undefined + HWND m_hwndFileOpenDlg; + HWND m_hwndFileOpenDlgChild; + +#if (_WIN32_WINNT >= 0x0500) + _OPENFILENAMEW m_ofn; +#else + OPENFILENAMEW m_ofn; +#endif + + // to reconnect to the instance + // !!! implies that only one instance + // at a time is supported + static CFileOpenDialog* s_fileOpenDlgInst; + +private: + // FileOpen or FileSaveDialog + BOOL m_bFileOpenDialog; + rtl::OUString m_dialogTitle; + rtl::OUString m_displayDirectory; + rtl::OUString m_defaultExtension; + + CAutoUnicodeBuffer m_filterBuffer; + CAutoUnicodeBuffer m_fileNameBuffer; + CAutoUnicodeBuffer m_fileTitleBuffer; + CAutoUnicodeBuffer m_helperBuffer; + + // callback function + static unsigned int CALLBACK ofnHookProc( + HWND hChildDlg, // handle to child dialog box + unsigned int uiMsg, // message identifier + WPARAM wParam, // message parameter + LPARAM lParam // message parameter + ); + +private: + + // avoid copy and assignment + CFileOpenDialog( const CFileOpenDialog& ); + CFileOpenDialog& operator=( const CFileOpenDialog& ); +}; + +#endif diff --git a/fpicker/source/win32/filepicker/FilePicker.cxx b/fpicker/source/win32/filepicker/FilePicker.cxx new file mode 100644 index 000000000000..f47310969913 --- /dev/null +++ b/fpicker/source/win32/filepicker/FilePicker.cxx @@ -0,0 +1,682 @@ +/************************************************************************* + * + * $RCSfile: FilePicker.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +#ifndef _CPPUHELPER_INTERFACECONTAINER_H_ +#include <cppuhelper/interfacecontainer.h> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _FILEPICKER_HXX_ +#include "filepicker.hxx" +#endif + +#include "FPServiceInfo.hxx" +#include "..\misc\WinImplHelper.hxx" + +#ifndef _COM_SUN_STAR_UI_DIALOGS_TEMPLATEDESCRIPTION_HPP_ +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::lang::XEventListener; +using ::com::sun::star::lang::XServiceInfo; +using ::com::sun::star::lang::DisposedException; +using ::com::sun::star::lang::XInitialization; +using ::com::sun::star::lang::EventObject; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::XInterface; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Sequence; + +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; + +using ::cppu::WeakComponentImplHelper7; +using ::rtl::OUString; +using ::osl::MutexGuard; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define FILE_PICKER_DLL_NAME "fps.dll" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace +{ + Sequence< OUString > SAL_CALL FilePicker_getSupportedServiceNames() + { + Sequence< OUString > aRet(2); + aRet[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker"); + aRet[1] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker"); + return aRet; + } +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +CFilePicker::CFilePicker( const Reference< XMultiServiceFactory >& xServiceMgr ) : + WeakComponentImplHelper7< + XFilterManager, + XFilePickerControlAccess, + XFilePickerNotifier, + XFilePreview, + XInitialization, + XEventListener, + XServiceInfo >( m_rbHelperMtx ) +{ + // create a default FileOpen dialog without any additional ui elements + m_pImpl = std::auto_ptr< CWinFileOpenImpl >( new CWinFileOpenImpl( this ) ); +} + +//------------------------------------------------------------------------------------ +// XFPEventListenerManager +//------------------------------------------------------------------------------------ + +void SAL_CALL CFilePicker::addFilePickerListener( const Reference< XFilePickerListener >& xListener ) + throw( RuntimeException ) +{ + if ( rBHelper.bDisposed ) + throw DisposedException( + OUString::createFromAscii( "object is already disposed" ), + static_cast< XFilePicker* >( this ) ); + + if ( !rBHelper.bInDispose && !rBHelper.bDisposed ) + rBHelper.aLC.addInterface( getCppuType( &xListener ), xListener ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::removeFilePickerListener( const Reference< XFilePickerListener >& xListener ) + throw( RuntimeException ) +{ + if ( rBHelper.bDisposed ) + throw DisposedException( + OUString::createFromAscii( "object is already disposed" ), + static_cast< XFilePicker* >( this ) ); + + rBHelper.aLC.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------- +// XEventListener +// ------------------------------------------------- + +void SAL_CALL CFilePicker::disposing( const EventObject& aEvent ) throw(RuntimeException) +{ + Reference< XFilePickerListener > xFilePickerListener( aEvent.Source, ::com::sun::star::uno::UNO_QUERY ); + + if ( xFilePickerListener.is( ) ) + removeFilePickerListener( xFilePickerListener ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::fileSelectionChanged( FilePickerEvent aEvent ) const +{ + PFNCXFPLISTENER pfncFPListener = &XFilePickerListener::fileSelectionChanged; + aEvent.Source = Reference< XInterface > ( + static_cast< XFilePickerNotifier* >( + const_cast< CFilePicker* >( this ) ) ); + notifyAllListener( pfncFPListener, aEvent ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::directoryChanged( FilePickerEvent aEvent ) const +{ + PFNCXFPLISTENER pfncFPListener = &XFilePickerListener::directoryChanged; + aEvent.Source = Reference< XInterface > ( + static_cast< XFilePickerNotifier* >( + const_cast< CFilePicker* >( this ) ) ); + notifyAllListener( pfncFPListener, aEvent ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFilePicker::helpRequested( FilePickerEvent aEvent ) const +{ + /* + PFNCXFPLISTENER pfncFPListener = &XFilePickerListener::helpRequested; + aEvent.Source = Reference< XInterface > ( + static_cast< XFilePickerNotifier* >( + const_cast< CFilePicker* >( this ) ) ); + notifyAllListener( pfncFPListener, aEvent ); + */ + return OUString( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::controlStateChanged( FilePickerEvent aEvent ) const +{ + PFNCXFPLISTENER pfncFPListener = &XFilePickerListener::controlStateChanged; + aEvent.Source = Reference< XInterface > ( + static_cast< XFilePickerNotifier* >( + const_cast< CFilePicker* >( this ) ) ); + notifyAllListener( pfncFPListener, aEvent ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::dialogSizeChanged( ) const +{ + // not yet implemented +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::notifyAllListener( PFNCXFPLISTENER pfncFPListener, FilePickerEvent aEvent ) const +{ + OSL_ASSERT( 0 != pfncFPListener ); + + if ( !rBHelper.bDisposed ) + { + ::osl::ClearableMutexGuard aGuard( rBHelper.rMutex ); + + if ( !rBHelper.bDisposed ) + { + aGuard.clear( ); + + ::cppu::OInterfaceContainerHelper* pICHelper = + rBHelper.aLC.getContainer( getCppuType( ( Reference< XFilePickerListener > * ) 0 ) ); + + if ( pICHelper ) + { + ::cppu::OInterfaceIteratorHelper iter( *pICHelper ); + + while( iter.hasMoreElements( ) ) + { + try + { + Reference< XFilePickerListener > xFPListener( iter.next( ), ::com::sun::star::uno::UNO_QUERY ); + if ( xFPListener.is( ) ) + (xFPListener.get( )->*pfncFPListener)(aEvent); + } + catch( RuntimeException& ) + { + OSL_ENSURE( false, "RuntimeException during event dispatching" ); + } + } + } + } + } +} + +//------------------------------------------------------------------------------------ +// XFilePicker functions +//------------------------------------------------------------------------------------ + +void SAL_CALL CFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->setMultiSelectionMode( bMode ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::setTitle( const OUString& aTitle ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->setTitle( aTitle ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::appendFilter( const OUString& aTitle, const OUString& aFilter ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->appendFilter( aTitle, aFilter ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::setCurrentFilter( const OUString& aTitle ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->setCurrentFilter( aTitle ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFilePicker::getCurrentFilter( ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + return m_pImpl->getCurrentFilter( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::setDefaultName( const OUString& aName ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->setDefaultName( aName ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::setDisplayDirectory( const OUString& aDirectory ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pImpl->setDisplayDirectory( aDirectory ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFilePicker::getDisplayDirectory( ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + return m_pImpl->getDisplayDirectory( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL CFilePicker::getFiles( ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + return m_pImpl->getFiles( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int16 SAL_CALL CFilePicker::execute( ) throw(RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + + // we should not block in this call else + // in the case of an event the client can'tgetPImplFromHandle( hWnd ) + // call another function an we run into a + // deadlock !!!!! + return m_pImpl->execute( ); +} + +//------------------------------------------------------------------------------------ +// XFilePicker functions +//------------------------------------------------------------------------------------ + +void SAL_CALL CFilePicker::setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const Any& aValue ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + m_pImpl->setValue( aControlId, aControlAction, aValue ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +Any SAL_CALL CFilePicker::getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + return m_pImpl->getValue( aControlId, aControlAction ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::enableControl( sal_Int16 aControlId, sal_Bool bEnable ) + throw(IllegalArgumentException, RuntimeException) +{ + OSL_ASSERT( 0 != m_pImpl.get( ) ); + m_pImpl->enableControl( aControlId, bEnable ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilePicker::setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) + throw (IllegalArgumentException, RuntimeException) +{ + MutexGuard aGuard( m_aMutex ); + m_pImpl->setLabel( aControlId, aLabel ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFilePicker::getLabel( sal_Int16 aControlId ) + throw ( IllegalArgumentException, RuntimeException) +{ + MutexGuard aGuard( m_aMutex ); + return m_pImpl->getLabel( aControlId ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +Sequence< sal_Int16 > SAL_CALL CFilePicker::getSupportedImageFormats( ) throw (RuntimeException) +{ + return m_pImpl->getSupportedImageFormats( ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +sal_Int32 SAL_CALL CFilePicker::getTargetColorDepth( ) throw (RuntimeException) +{ + return m_pImpl->getTargetColorDepth( ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +sal_Int32 SAL_CALL CFilePicker::getAvailableWidth( ) throw (RuntimeException) +{ + return m_pImpl->getAvailableWidth( ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +sal_Int32 SAL_CALL CFilePicker::getAvailableHeight( ) throw (RuntimeException) +{ + return m_pImpl->getAvailableHeight( ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +void SAL_CALL CFilePicker::setImage( sal_Int16 aImageFormat, const Any& aImage ) + throw (IllegalArgumentException, RuntimeException) +{ + m_pImpl->setImage( aImageFormat, aImage ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +sal_Bool SAL_CALL CFilePicker::setShowState( sal_Bool bShowState ) throw (RuntimeException) +{ + return m_pImpl->setShowState( bShowState ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +sal_Bool SAL_CALL CFilePicker::getShowState( ) throw (RuntimeException) +{ + return m_pImpl->getShowState( ); +} + +//------------------------------------------------------------------------------------ +// +//------------------------------------------------------------------------------------ + +void SAL_CALL CFilePicker::initialize( const Sequence< Any >& aArguments ) + throw( Exception, RuntimeException) +{ + // parameter checking + Any aAny; + if ( !aArguments.getLength( ) || + (aAny = aArguments[0]).getValueType() != ::getCppuType( (sal_Int16*)0 ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid arguments" ), + static_cast< XFilePicker* >( this ), + 1 ); + + sal_Int16 templateId = -1; + aAny >>= templateId; + + sal_Bool bFileOpenDialog = sal_True; + sal_uInt32 winResTemplateId = 0; + sal_Bool bIsWin2000 = IsWin2000( ); + + switch ( templateId ) + { + case FILEOPEN_SIMPLE: + bFileOpenDialog = sal_True; + break; + + case FILESAVE_SIMPLE: + bFileOpenDialog = sal_False; + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD: + bFileOpenDialog = sal_False; + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID; + else + winResTemplateId = TMPL95_FILESAVE_AUTOEXT_PASSWORD_BOX_ID; + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: + bFileOpenDialog = sal_False; + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX; + else + winResTemplateId = TMPL95_AUTOEXT_PASSWORD_FILTEROPTION_BOX; + break; + + case FILESAVE_AUTOEXTENSION_SELECTION: + bFileOpenDialog = sal_False; + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_AUTOEXT_SELECTION_BOX; + else + winResTemplateId = TMPL95_AUTOEXT_SELECTION_BOX; + break; + + case FILESAVE_AUTOEXTENSION_TEMPLATE: + bFileOpenDialog = sal_False; + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID; + else + winResTemplateId = TMPL95_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID; + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID; + else + winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID; + break; + + case FILEOPEN_PLAY: + bFileOpenDialog = sal_False; + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_PLAY_PUSHBUTTON; + else + winResTemplateId = TMPL95_PLAY_PUSHBUTTON; + break; + + case FILEOPEN_READONLY_VERSION: + if ( bIsWin2000 ) + winResTemplateId = TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID; + else + winResTemplateId = TMPL95_FILEOPEN_READONLY_VERSION_BOX_ID; + break; + + default: + throw IllegalArgumentException( + OUString::createFromAscii( "Unknown template" ), + static_cast< XFilePicker* >( this ), + 1 ); + } + + HINSTANCE hInstance = GetModuleHandleA( FILE_PICKER_DLL_NAME ); + OSL_POSTCOND( hInstance, "The name of the service dll must have changed" ); + + // create a new impl-class here based on the + // given string, if the given string is empty + // we do nothing + m_pImpl = std::auto_ptr< CWinFileOpenImpl >( + new CWinFileOpenImpl( + this, + bFileOpenDialog, + 0, + winResTemplateId, + hInstance ) ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL CFilePicker::getImplementationName( ) + throw( RuntimeException ) +{ + return OUString::createFromAscii( FILE_PICKER_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL CFilePicker::supportsService( const OUString& ServiceName ) + throw( RuntimeException ) +{ + Sequence < OUString > SupportedServicesNames = FilePicker_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + if (SupportedServicesNames[n].compareTo(ServiceName) == 0) + return sal_True; + + return sal_False; +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +Sequence< OUString > SAL_CALL CFilePicker::getSupportedServiceNames( ) + throw( RuntimeException ) +{ + return FilePicker_getSupportedServiceNames(); +}
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/FilePicker.hxx b/fpicker/source/win32/filepicker/FilePicker.hxx new file mode 100644 index 000000000000..d83783952802 --- /dev/null +++ b/fpicker/source/win32/filepicker/FilePicker.hxx @@ -0,0 +1,285 @@ +/************************************************************************* + * + * $RCSfile: FilePicker.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _FILEPICKER_HXX_ +#define _FILEPICKER_HXX_ + +//_______________________________________________________________________________________________________________________ +// includes of other projects +//_______________________________________________________________________________________________________________________ + + +#ifndef _CPPUHELPER_COMPBASE7_HXX_ +#include <cppuhelper/compbase7.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_XFILEPICKERNOTIFIER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_XFILTERMANAGER_HPP_ +#include <com/sun/star/ui/dialogs/XFilterManager.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPREVIEW_HPP_ +#include <com/sun/star/ui/dialogs/XFilePreview.hpp> +#endif + +#ifndef _WINFILEOPENIMPL_HXX_ +#include "WinFileOpenImpl.hxx" +#endif + +#include <memory> + +//---------------------------------------------------------- +// Implementation class for the XFilePicker Interface +//---------------------------------------------------------- + +//---------------------------------------------------------- +// forward declarations +//---------------------------------------------------------- + +//class OFPImplBase; +class CFPImplFactory; + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CFilePickerDummy +{ +protected: + osl::Mutex m_aMutex; + osl::Mutex m_rbHelperMtx; +}; + +class CFilePicker : + public CFilePickerDummy, + public cppu::WeakComponentImplHelper7< + ::com::sun::star::ui::dialogs::XFilterManager, + ::com::sun::star::ui::dialogs::XFilePickerControlAccess, + ::com::sun::star::ui::dialogs::XFilePickerNotifier, + ::com::sun::star::ui::dialogs::XFilePreview, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::lang::XEventListener, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + // ctor + CFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); + + //------------------------------------------------------------------------------------ + // XFilePickerNotifier + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------------------------------------------ + // XExecutableDialog functions + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Int16 SAL_CALL execute( ) + throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------------------------------------------ + // XFilePicker functions + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( ) + throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------------------------------------------ + // XFilterManager functions + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::rtl::OUString SAL_CALL getCurrentFilter( ) + throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------------------------------------------ + // XFilePickerControlAccess functions + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XFilePreview + //------------------------------------------------ + + virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XInitialization + //------------------------------------------------ + + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XEventListener + //------------------------------------------------ + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XServiceInfo + //------------------------------------------------ + + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw(::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw(::com::sun::star::uno::RuntimeException); + + //------------------------------------------------------------------------------------ + // FilePicker Event functions + //------------------------------------------------------------------------------------ + + void SAL_CALL fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + void SAL_CALL dialogSizeChanged( ) const; + +private: + typedef void (SAL_CALL ::com::sun::star::ui::dialogs::XFilePickerListener::*PFNCXFPLISTENER)(const ::com::sun::star::ui::dialogs::FilePickerEvent&); + void SAL_CALL notifyAllListener( PFNCXFPLISTENER pfncFPListener, ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + +private: + // prevent copy and assignment + CFilePicker( const CFilePicker& ); + CFilePicker& operator=( const CFilePicker& ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; // to instanciate own services + std::auto_ptr< CWinFileOpenImpl > m_pImpl; +}; + +#endif diff --git a/fpicker/source/win32/filepicker/FilterContainer.cxx b/fpicker/source/win32/filepicker/FilterContainer.cxx new file mode 100644 index 000000000000..d35c28e2c02b --- /dev/null +++ b/fpicker/source/win32/filepicker/FilterContainer.cxx @@ -0,0 +1,353 @@ +/************************************************************************* + * + * $RCSfile: FilterContainer.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _FILTER_CONTAINER_HXX_ +#include "FilterContainer.hxx" +#endif + +#include <utility> +#include <windows.h> + +//------------------------------------------------------------------- +// namespace directives +//------------------------------------------------------------------- + +using ::rtl::OUString; + +//------------------------------------------------------------------------------------- +// ctor +//------------------------------------------------------------------------------------- + +CFilterContainer::CFilterContainer( sal_Int32 initSize ) : + m_vFilters( initSize ), + m_bIterInitialized( sal_False ) +{ +} + +//----------------------------------------------------------------------------------------- +// add a name/filter pair +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CFilterContainer::addFilter( + const OUString& aName, const OUString& aFilter, sal_Bool bAllowDuplicates ) +{ + // check if the filter is already in the container + sal_Int32 pos = -1; + + if ( !bAllowDuplicates ) + { + pos = getFilterTagPos( aName ); + if ( pos < 0 ) // if not there, append + { + m_vFilters.push_back( std::make_pair( aName, aFilter ) ); + m_bIterInitialized = sal_False; + } + } + else + { + m_vFilters.push_back( std::make_pair( aName, aFilter ) ); + m_bIterInitialized = sal_False; + } + + return ( pos < 0 ) ? sal_True : sal_False; +} + +//----------------------------------------------------------------------------------------- +// delete a filter +// Precondition: the container is not empty +// there is a filter identified by the given name +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CFilterContainer::delFilter( const OUString& aName ) +{ + OSL_ASSERT( m_vFilters.size() > 0 ); + + sal_Int32 pos = getFilterTagPos( aName ); + if ( pos > -1 ) + { + m_vFilters.erase( ( m_vFilters.begin() + pos ) ); + m_bIterInitialized = sal_False; + } + + return ( pos > -1 ) ? sal_True : sal_False; +} + +//----------------------------------------------------------------------------------------- +// return the number of filters currently in the container +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CFilterContainer::numFilter( ) +{ + return m_vFilters.size( ); +} + +//----------------------------------------------------------------------------------------- +// clear all entries +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilterContainer::empty() +{ + m_vFilters.clear( ); +} + +//----------------------------------------------------------------------------------------- +// get a filter by name +// Precondition: the container is not empty +// there is a filter identified by the name +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CFilterContainer::getFilter( const OUString& aName, OUString& theFilter ) const +{ + OSL_PRECOND( m_vFilters.size() > 0, "Empty filter container" ); + + sal_Int32 pos = getFilterTagPos( aName ); + + try + { + if ( pos > -1 ) + theFilter = m_vFilters.at( pos ).second; + } + catch( std::out_of_range& ) + { + OSL_ENSURE( sal_False, "Filter not in filter container" ); + pos = -1; + } + + return (pos > -1 ) ? sal_True : sal_False; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CFilterContainer::getFilter( sal_Int32 aIndex, OUString& theFilter ) const +{ + sal_Bool bRet = sal_True; + + try + { + theFilter = m_vFilters.at( aIndex ).first; + } + catch( std::out_of_range& ) + { + OSL_ENSURE( sal_False, "Filter index out of range" ); + bRet = sal_False; + } + + return bRet; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CFilterContainer::getFilterPos( const OUString& aName ) const +{ + return getFilterTagPos( aName ); +} + +//----------------------------------------------------------------------------------------- +// returns the index of the filter identified by name +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CFilterContainer::getFilterTagPos( const OUString& aName ) const +{ + if ( m_vFilters.size( ) > 0 ) + { + sal_Int32 i = 0; + FILTER_VECTOR_T::const_iterator iter; + FILTER_VECTOR_T::const_iterator iter_end = m_vFilters.end( ); + + for ( iter = m_vFilters.begin( ); iter != iter_end; ++iter, ++i ) + if ( ( *iter ).first.equalsIgnoreAsciiCase( aName ) ) + return i; + } + + return -1; +} + +//----------------------------------------------------------------------------------------- +// starts enumerating the filter in the container +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFilterContainer::beginEnumFilter( ) +{ + m_iter = m_vFilters.begin( ); + m_bIterInitialized = sal_True; +} + +//----------------------------------------------------------------------------------------- +// returns true if another filter has been retrieved +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CFilterContainer::getNextFilter( FILTER_ENTRY_T& nextFilterEntry ) +{ + OSL_ASSERT( m_bIterInitialized ); + + sal_Bool bRet = ( m_iter != m_vFilters.end( ) ); + + if ( bRet ) + nextFilterEntry = *m_iter++; + else + m_bIterInitialized = sal_False; + + return bRet; +} + + +//################################################################### + + +//------------------------------------------------------------------- +// calculates the length of a '\0' separated filter, that means +// length of the name + '\0' + length of the filter string + +// a trailing '\0' +//------------------------------------------------------------------- + +static sal_uInt32 _getLengthFilter( CFilterContainer::FILTER_ENTRY_T aFilterEntry ) +{ + return ( + aFilterEntry.first.getLength( ) + 1 + + aFilterEntry.second.getLength( ) + 1 ); +} + +//------------------------------------------------------------------- +// calculates the length of all filters currently in the container +//------------------------------------------------------------------- + +static sal_uInt32 _getTotalFilterLength( CFilterContainer& aFilterContainer ) +{ + CFilterContainer::FILTER_ENTRY_T nextFilter; + + aFilterContainer.beginEnumFilter( ); + + sal_uInt32 totalLength = 0; + while( aFilterContainer.getNextFilter( nextFilter ) ) + totalLength += _getLengthFilter( nextFilter ); + + return ( totalLength > 0 ) ? totalLength + 1 : totalLength; +} + +//------------------------------------------------------------------- +// +//------------------------------------------------------------------- + +inline +void _wcsmemcpy( sal_Unicode* pDest, const sal_Unicode* pSrc, sal_uInt32 nLength ) +{ + memcpy( pDest, pSrc, nLength * sizeof( sal_Unicode ) ); +} + +//------------------------------------------------------------------- +// a helper trivial helper function to create a filter buffer in the +// format the Win32 API requires, +// e.g. "Text\0*.txt\0Doc\0*.doc;*xls\0\0" +//------------------------------------------------------------------- + +rtl::OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer ) +{ + // calculate the required buffer size + sal_uInt32 reqBuffSize = _getTotalFilterLength( aFilterContainer ); + sal_Unicode* pBuff; + + // return if there are no filters or the buffer could not + // be allocated + if ( !reqBuffSize || !( pBuff = new sal_Unicode[reqBuffSize] ) ) + return OUString( ); + + // initialize the buffer with 0 + ZeroMemory( pBuff, sizeof( sal_Unicode ) * reqBuffSize ); + + OUString winFilterBuff; + CFilterContainer::FILTER_ENTRY_T nextFilter; + sal_uInt32 memPos = 0; + + aFilterContainer.beginEnumFilter( ); + + while( aFilterContainer.getNextFilter( nextFilter ) ) + { + _wcsmemcpy( + pBuff + memPos, + nextFilter.first.getStr( ), + nextFilter.first.getLength( ) ); + + memPos += nextFilter.first.getLength( ) + 1; + + _wcsmemcpy( + pBuff + memPos, + nextFilter.second.getStr( ), + nextFilter.second.getLength( ) ); + + memPos += nextFilter.second.getLength( ) + 1 ; + } + + winFilterBuff = OUString( pBuff, reqBuffSize ); + + // remove the allocated buffer + delete [] pBuff; + + return winFilterBuff; +} + diff --git a/fpicker/source/win32/filepicker/FilterContainer.hxx b/fpicker/source/win32/filepicker/FilterContainer.hxx new file mode 100644 index 000000000000..d5387b55d211 --- /dev/null +++ b/fpicker/source/win32/filepicker/FilterContainer.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: FilterContainer.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _FILTER_CONTAINER_HXX_ +#define _FILTER_CONTAINER_HXX_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#include <vector> + +//------------------------------------------------------ +// helper class, only useable by OFilterContainer +//------------------------------------------------------ + +class CFilterContainer +{ +public: + // defines a filter entry which is made of a name and a filter value + // e.g. 'Text *.txt' + typedef std::pair< rtl::OUString, rtl::OUString > FILTER_ENTRY_T; + +public: + explicit CFilterContainer( sal_Int32 initSize = 0 ); + + // add a new filter + // returns true if the filter was successfully added + // returns false if duplicates are not allowed and + // the filter is already in the container + sal_Bool SAL_CALL addFilter( + const ::rtl::OUString& aName, + const ::rtl::OUString& aFilter, + sal_Bool bAllowDuplicates = sal_False ); + + // delete the specified filter returns true on + // success and false if the filter was not found + sal_Bool SAL_CALL delFilter( const ::rtl::OUString& aName ); + + // the number of filter already added + sal_Int32 SAL_CALL numFilter( ); + + // clear all entries + void SAL_CALL empty( ); + + // retrieve a filter from the container both methods + // return true on success and false if the specified + // filter was not found + sal_Bool SAL_CALL getFilter( const ::rtl::OUString& aName, ::rtl::OUString& theFilter ) const; + sal_Bool SAL_CALL getFilter( sal_Int32 aIndex, ::rtl::OUString& theFilter ) const; + + // returns the position of the specified filter or -1 + // if the filter was not found + sal_Int32 SAL_CALL getFilterPos( const ::rtl::OUString& aName ) const; + + // starts enumerating the filter in the container + void SAL_CALL beginEnumFilter( ); + + // returns true if another filter has been retrieved + sal_Bool SAL_CALL getNextFilter( FILTER_ENTRY_T& nextFilterEntry ); + +protected: + typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T; + +private: + // prevent copy and assignment + CFilterContainer( const CFilterContainer& ); + CFilterContainer& SAL_CALL operator=( const CFilterContainer& ); + + sal_Int32 SAL_CALL getFilterTagPos( const ::rtl::OUString& aName ) const; + +private: + FILTER_VECTOR_T m_vFilters; + FILTER_VECTOR_T::const_iterator m_iter; + sal_Bool m_bIterInitialized; +}; + +//---------------------------------------------------------------- +// a helper function to create a filter buffer in the format +// the Win32 API requires, e.g. "Text\0*.txt\0Doc\0*.doc;*xls\0\0" +//---------------------------------------------------------------- + +rtl::OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer ); + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/Fps.rc b/fpicker/source/win32/filepicker/Fps.rc new file mode 100644 index 000000000000..dfd2a64298d3 --- /dev/null +++ b/fpicker/source/win32/filepicker/Fps.rc @@ -0,0 +1,374 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +1000 DIALOG DISCARDABLE 0, 0, 236, 71 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "",1119,0,0,236,38 + CONTROL "Mit Schreibschutz öffnen",103,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,54,56,154,14 + COMBOBOX 107,54,38,156,52,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Version:",207,5,38,47,11 +END + +1001 DIALOG DISCARDABLE 0, 0, 338, 67 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Mit Schreibschutz öffnen",103,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,130,51,161,14 + COMBOBOX 107,130,35,164,52,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Version:",207,68,37,56,11 + LTEXT "",1119,0,0,336,35 +END + +2000 DIALOG DISCARDABLE 0, 0, 185, 68 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Als Link einfügen",104,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,53,40,124,14 + CONTROL "Vorschau",105,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53, + 53,124,14 + LTEXT "",1119,0,0,185,25 + COMBOBOX 109,54,25,156,54,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Bildvorlage:",209,5,26,48,10 +END + +2001 DIALOG DISCARDABLE 0, 0, 280, 72 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Als Link einfügen",104,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,130,45,144,14 + CONTROL "Vorschau",105,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130, + 58,144,16 + LTEXT "",1119,0,0,281,28 + COMBOBOX 109,130,28,164,62,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | + WS_TABSTOP + LTEXT "Bildvorlage:",209,67,29,47,11 +END + +3000 DIALOG DISCARDABLE 0, 0, 216, 72 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,54,56,161,14 + COMBOBOX 108,54,38,156,52,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Vorlagen:",208,5,38,47,11 + LTEXT "",1119,0,0,215,38 +END + +3001 DIALOG DISCARDABLE 0, 0, 296, 72 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,130,58,157,14 + COMBOBOX 108,130,41,164,100,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Vorlagen:",208,67,42,58,8 + LTEXT "",1119,0,0,293,41 +END + +4000 DIALOG DISCARDABLE 0, 0, 237, 62 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,54,32,184,14 + LTEXT "",1119,0,0,238,32 + CONTROL "Mit Kennwort speichern",101,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,54,46,184,14 +END + +4001 DIALOG DISCARDABLE 0, 0, 278, 67 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,130,38,144,14 + LTEXT "",1119,0,0,277,38 + CONTROL "Mit Kennwort speichern",101,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,130,51,144,16 +END + +5000 DIALOG DISCARDABLE 0, 0, 235, 68 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,54,25,159,14 + CONTROL "Mit Kennwort speichern",101,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,54,39,124,14 + LTEXT "",1119,0,0,235,25 + CONTROL "Filtereinstellungen bearbeiten",102,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,54,53,124,14 +END + +5001 DIALOG DISCARDABLE 0, 0, 278, 79 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,130,38,144,14 + LTEXT "",1119,0,0,277,38 + CONTROL "Mit Kennwort speichern",101,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,130,52,144,13 + CONTROL "Filtereinstellungen bearbeiten",102,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,130,66,144,13 +END + +6000 DIALOG DISCARDABLE 0, 0, 278, 24 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "",1119,0,0,278,7 + PUSHBUTTON "Abspielen",106,222,7,50,15 +END + +6001 DIALOG DISCARDABLE 0, 0, 367, 36 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "",1119,0,0,367,18 + PUSHBUTTON "Abspielen",106,316,18,50,14 +END + +7000 DIALOG DISCARDABLE 0, 0, 237, 62 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,54,32,184,14 + LTEXT "",1119,0,0,238,32 + CONTROL "Selektion",110,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54, + 46,184,14 +END + +7001 DIALOG DISCARDABLE 0, 0, 278, 65 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatische Dateinamenserweiterung",100,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,130,38,144,14 + LTEXT "",1119,0,0,277,38 + CONTROL "Selektion",110,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 130,51,144,16 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + 1000, DIALOG + BEGIN + VERTGUIDE, 5 + VERTGUIDE, 20 + VERTGUIDE, 54 + HORZGUIDE, 38 + END + + 1001, DIALOG + BEGIN + RIGHTMARGIN, 336 + VERTGUIDE, 124 + VERTGUIDE, 130 + HORZGUIDE, 37 + END + + 2000, DIALOG + BEGIN + VERTGUIDE, 61 + HORZGUIDE, 25 + END + + 3000, DIALOG + BEGIN + VERTGUIDE, 51 + BOTTOMMARGIN, 71 + HORZGUIDE, 38 + END + + 3001, DIALOG + BEGIN + RIGHTMARGIN, 294 + VERTGUIDE, 67 + HORZGUIDE, 41 + END + + 4000, DIALOG + BEGIN + VERTGUIDE, 54 + HORZGUIDE, 34 + END + + 4001, DIALOG + BEGIN + RIGHTMARGIN, 277 + VERTGUIDE, 76 + HORZGUIDE, 52 + END + + 5000, DIALOG + BEGIN + RIGHTMARGIN, 185 + VERTGUIDE, 61 + BOTTOMMARGIN, 67 + HORZGUIDE, 25 + END + + 5001, DIALOG + BEGIN + RIGHTMARGIN, 277 + VERTGUIDE, 76 + HORZGUIDE, 52 + END + + 6001, DIALOG + BEGIN + HORZGUIDE, 20 + END + + 7000, DIALOG + BEGIN + VERTGUIDE, 54 + HORZGUIDE, 34 + END + + 7001, DIALOG + BEGIN + RIGHTMARGIN, 277 + VERTGUIDE, 76 + HORZGUIDE, 52 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +1000 DLGINIT +BEGIN + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3520, 0x322e, "\000" + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3420, 0x302e, "\000" + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3320, 0x302e, "\000" + 0 +END + +1001 DLGINIT +BEGIN + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3520, 0x322e, "\000" + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3420, 0x302e, "\000" + 107, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3320, 0x302e, "\000" + 0 +END + +3000 DLGINIT +BEGIN + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3520, 0x322e, "\000" + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3420, 0x302e, "\000" + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3320, 0x302e, "\000" + 0 +END + +3001 DLGINIT +BEGIN + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3520, 0x322e, "\000" + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3420, 0x302e, "\000" + 108, 0x403, 15, 0 +0x7453, 0x7261, 0x7257, 0x7469, 0x7265, 0x3320, 0x302e, "\000" + 0 +END + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/fpicker/source/win32/filepicker/PreviewCtrl.cxx b/fpicker/source/win32/filepicker/PreviewCtrl.cxx new file mode 100644 index 000000000000..40d4e1c0fdc6 --- /dev/null +++ b/fpicker/source/win32/filepicker/PreviewCtrl.cxx @@ -0,0 +1,647 @@ +/************************************************************************* + * + * $RCSfile: PreviewCtrl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _PREVIEWCTRL_HXX_ +#include "PreviewCtrl.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include <windows.h> +#include <ocidl.h> +#include <olectl.h> + +#include <systools/win32/user9x.h> +#include <systools/win32/kernel9x.h> + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define PREVIEWWND_CLASS_NAME L"PreviewWnd###" + +#define HIMETRIC_INCH 2540 + +// means 3 pixel left and 3 pixel right +#define HORZ_BODER_SPACE 6 + +// means 3 pixel top and 3 pixel bottom +#define VERT_BORDER_SPACE 6 + +//--------------------------------------------------- +// static member initialization +//--------------------------------------------------- + +CFilePreview* CFilePreview::s_FilePreviewInst = NULL; +CFilePreview::FILEPREVIEW_SINGLETON_DESTROYER_T CFilePreview::s_SingletonDestroyer; + +//--------------------------------------------------- +// some useful helper functions +//--------------------------------------------------- + +namespace // private +{ + class CPreviewException + { + // used when registering or creation + // of the preview window failed + }; + + //------------------------------------------------------------ + // + //------------------------------------------------------------ + + inline + sal_Int32 SubDiv( sal_Int32 nNumber, sal_Int32 nMinuend, sal_Int32 nDenominator ) + { + return ( static_cast<sal_Int32>( ( nNumber - nMinuend ) / nDenominator ) ); + } + + //------------------------------------------------------------ + // convert himetric to pixel + //------------------------------------------------------------ + + inline + sal_Int32 Himetric2Pixel( HDC hDC, sal_Int32 hmSize, sal_Int32 nIndex ) + { + return MulDiv( hmSize, GetDeviceCaps( hDC, nIndex), HIMETRIC_INCH ); + } + + //------------------------------------------------------------ + // + //------------------------------------------------------------ + + inline + sal_uInt32 _getWidthRect( const RECT& aRect ) + { + return ( aRect.right - aRect.left ); + } + + //------------------------------------------------------------ + // + //------------------------------------------------------------ + + inline + sal_uInt32 _getHeightRect( const RECT& aRect ) + { + return ( aRect.bottom - aRect.top ); + } + + //------------------------------------------------------------ + // calc the upper left corner so that a given window will be + // displayed centered within the given window + //------------------------------------------------------------ + + inline + POINT _calcULCorner( HWND hwnd, const CDimension& aPicSize ) + { + RECT rect; + GetClientRect( hwnd, &rect ); + + sal_Int32 nWidthWnd = _getWidthRect( rect ); + sal_Int32 nHeightWnd = _getHeightRect( rect ); + + POINT ulCorner; + ulCorner.x = SubDiv( nWidthWnd, aPicSize.m_cx, 2 ); + ulCorner.y = SubDiv( nHeightWnd, aPicSize.m_cy, 2 ); + + return ulCorner; + } + + //------------------------------------------------------------ + // test if a picture with the given dimensions fits into an + // arbitrary window + // we expect the width and height to be in pixel + //------------------------------------------------------------ + + inline + sal_Bool _pictureSizeFitsWindowSize( HWND hwnd, const CDimension& aPicSize ) + { + RECT rect; + GetClientRect( hwnd, &rect ); + + sal_Int32 nWidthWnd = _getWidthRect( rect ); + sal_Int32 nHeightWnd = _getHeightRect( rect ); + + return ( ( ( nWidthWnd - HORZ_BODER_SPACE ) >= aPicSize.m_cx ) && + ( ( nHeightWnd - VERT_BORDER_SPACE ) >= aPicSize.m_cy ) ); + } + + //------------------------------------------------------------ + // calc the dimemsions so that a given picture fits into a + // given window, if the picture fits into the given window + // the original CDimension will be returned + //------------------------------------------------------------ + + inline + CDimension _scalePictureSize( HWND hwnd, const CDimension& aPicSize ) + { + CDimension scaledPicSize = aPicSize; + + if ( !_pictureSizeFitsWindowSize( hwnd, aPicSize ) ) + { + RECT rect; + GetClientRect( hwnd, &rect ); + + // the dimensions of the preview wnd are not equal + // that's why we equalize it + sal_Int32 nHeightWnd = _getHeightRect( rect ) - VERT_BORDER_SPACE; + sal_Int32 nWidthWnd = nHeightWnd; + + if ( aPicSize.m_cx >= aPicSize.m_cy ) + { + scaledPicSize.m_cx = nWidthWnd; + scaledPicSize.m_cy = + static_cast< sal_Int32 >( + aPicSize.m_cy * nWidthWnd / aPicSize.m_cx ); + } + else + { + scaledPicSize.m_cx = + static_cast< sal_Int32 >( + aPicSize.m_cx * nHeightWnd / aPicSize.m_cy ); + scaledPicSize.m_cy = nHeightWnd; + } + } + + return scaledPicSize; + } + +} // end namespace + + +//--------------------------------------------------- +// to ensure only one instance (singleton) +//--------------------------------------------------- + +CFilePreview* CFilePreview::createInstance( + HWND aParent, + POINT ulCorner, + const CDimension& aSize, + HINSTANCE hInstance, + sal_Bool bShow, + sal_Bool bEnabled ) +{ + if ( !s_FilePreviewInst ) + { + try + { + s_FilePreviewInst = new CFilePreview( + aParent, ulCorner, aSize, hInstance, bShow, bEnabled ); + s_SingletonDestroyer.reset( s_FilePreviewInst ); + } + catch( CPreviewException& ) + { + OSL_ASSERT( !s_FilePreviewInst ); + OSL_ENSURE( sal_False, "Creation of the preview window failed" ); + } + catch( CAutoOleInit::COleInitException& ) + { + OSL_ASSERT( !s_FilePreviewInst ); + OSL_ENSURE( sal_False, "OleInitalize failed" ); + } + } + + return s_FilePreviewInst; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +CFilePreview::CFilePreview( + HWND aParent, + POINT ulCorner, + const CDimension& aSize, + HINSTANCE hInstance, + sal_Bool bShow, + sal_Bool bEnabled ) : + m_hInstance( hInstance ), + m_bEnabled( bEnabled ) +{ + // register the preview window class + WNDCLASSEXW wndClsEx; + ZeroMemory( &wndClsEx, sizeof( WNDCLASSEXW ) ); + + wndClsEx.cbSize = sizeof( WNDCLASSEXW ); + wndClsEx.style = CS_HREDRAW | CS_VREDRAW; + wndClsEx.lpfnWndProc = CFilePreview::WndProc; + wndClsEx.hInstance = m_hInstance; + wndClsEx.hbrBackground = (HBRUSH)( COLOR_INACTIVEBORDER + 1 ); + wndClsEx.lpszClassName = PREVIEWWND_CLASS_NAME; + + // register the preview window class + // !!! Win95 - the window class will be unregistered automaticly + // if the dll is unloaded + // Win2000 - the window class must be unregistered manually + // if the dll is unloaded + m_atomPrevWndClass = RegisterClassExW( &wndClsEx ); + if ( !m_atomPrevWndClass ) + throw CPreviewException( ); + + // create the preview window in invisible state + sal_uInt32 dwStyle = bShow ? (WS_CHILD | WS_VISIBLE) : WS_CHILD; + m_hwnd = CreateWindowExW( + WS_EX_CLIENTEDGE, + PREVIEWWND_CLASS_NAME, + L"", + dwStyle, + ulCorner.x, + ulCorner.y, + aSize.m_cx, + aSize.m_cy, + aParent, + (HMENU)100, // for child windows this will + // be used as child window identifier + m_hInstance, + 0 ); + if ( !IsWindow( m_hwnd ) ) + throw CPreviewException( ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +CFilePreview::~CFilePreview( ) +{ + // unregister preview window class + sal_Bool bRet = UnregisterClass( + (LPCTSTR)MAKELONG( m_atomPrevWndClass, 0 ), + m_hInstance ); + OSL_POSTCOND( bRet, "Unregister preview window class failed" ); +} + +//--------------------------------------------------- +// sets the size of the preview window +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::setSize( const CDimension& aSize ) +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + // resize the fileopen file listbox + return SetWindowPos( + m_hwnd, + NULL, + 0, + 0, + aSize.m_cx, + aSize.m_cy, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); +} + +//--------------------------------------------------- +// returns the dimension of the preview +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::getSize( CDimension& theSize ) const +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + RECT rect; + sal_Bool bRet = GetWindowRect( m_hwnd, &rect ); + + theSize.m_cx = _getWidthRect( rect ); + theSize.m_cy = _getHeightRect( rect ); + + return bRet; +} + +//--------------------------------------------------- +// sets the position of the upper left corner +// of the preview window relative to the +// upper left corner of the parent window +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::setPos( POINT ulCorner ) +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + // resize the fileopen file listbox + return SetWindowPos( + m_hwnd, + NULL, + ulCorner.x, + ulCorner.y, + 0, + 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); +} + +//--------------------------------------------------- +// returns the current position of the preview +// relative to the upper left corner of the +// parent window +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::getPos( POINT& ulCorner ) const +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + POINT pt = { 0, 0 }; + RECT rect; + + sal_Bool bRet = GetWindowRect( m_hwnd, &rect ); + + ulCorner.x = rect.left; + ulCorner.y = rect.top; + + ScreenToClient( m_hwnd, &ulCorner ); + + return bRet; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CFilePreview::enable( sal_Bool bEnable ) +{ + m_bEnabled = bEnable; + + // force a redraw + InvalidateRect( m_hwnd, NULL, TRUE ); + UpdateWindow( m_hwnd ); +} + +//--------------------------------------------------- +// shows the preview window +// possible values see SHOW_STATE +// SS_SHOW - make the window visible +// SS_HIDE - hide the window +// SS_ENABLED - enable the window +// SS_DISABLED - disable the window +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::show( sal_Bool bShow ) +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + sal_Int32 showState = bShow ? SW_SHOW : SW_HIDE; + return ShowWindow( m_hwnd, showState ); +} + +//--------------------------------------------------- +// if the preview is shown and enabled +// preview of the given file will be shown +// returns true on success or false if an error +// occured (the file in not there or not accessible etc.) +//--------------------------------------------------- + +sal_Bool SAL_CALL CFilePreview::update( const rtl::OUString& aFileName ) +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + try + { + if ( m_bEnabled ) + { + if ( m_IPicture ) + m_IPicture.Release( ); + + loadFile( aFileName ); + + // force a complete window redraw + InvalidateRect( m_hwnd, NULL, TRUE ); + UpdateWindow( m_hwnd ); + } + } + catch( _com_error& ) + { + } + + return sal_True; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CFilePreview::onPaint( HWND hWnd, HDC hDC ) +{ + OSL_PRECOND( IsWindow( m_hwnd ), "Preview window not initialized" ); + + try + { + if ( m_bEnabled ) + { + // get width and height of picture + long cxPicHIMETRIC; + long cyPicHIMETRIC; + + m_IPicture->get_Width( &cxPicHIMETRIC ); + m_IPicture->get_Height( &cyPicHIMETRIC ); + + // convert himetric to pixels + int cxPicPIXEL = Himetric2Pixel( hDC, cxPicHIMETRIC, LOGPIXELSX ); + int cyPicPIXEL = Himetric2Pixel( hDC, cyPicHIMETRIC, LOGPIXELSY ); + + // scale the picture based on the size of the preview window + RECT rcPrevWnd; + GetClientRect(hWnd, &rcPrevWnd); + + CDimension scaledPicSize = _scalePictureSize( + hWnd, CDimension( cxPicPIXEL, cyPicPIXEL ) ); + + // calc the upper left corner so that the picture + // is centered within the window + POINT ulCorner = _calcULCorner( hWnd, scaledPicSize ); + + // render the picture + HRESULT hr = m_IPicture->Render( + hDC, + ulCorner.x, + ulCorner.y, + scaledPicSize.m_cx, + scaledPicSize.m_cy, + 0, + cyPicHIMETRIC, + cxPicHIMETRIC, + -cyPicHIMETRIC, + &rcPrevWnd ); + } // end if ( m_bEnabled ) + } + catch( _com_error& ) + { + } +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +sal_Bool CFilePreview::loadFile( const rtl::OUString& aFileName ) +{ + HANDLE hFile = 0; + HGLOBAL hGlobal = 0; + LPVOID pData = NULL; + IStreamPtr pIStream; + HRESULT hr = E_FAIL; + sal_Bool bRet; + sal_uInt32 nBytesRead; + sal_uInt32 fszExtra; + sal_uInt32 fsize; + + hFile = CreateFileW( + aFileName.getStr( ), + GENERIC_READ, + 0, + NULL, + OPEN_EXISTING, + 0, + NULL ); + if ( INVALID_HANDLE_VALUE == hFile ) + goto CLEANUP_AND_EXIT; + + fszExtra = 0; + fsize = GetFileSize( hFile, &fszExtra ); + + // empty file, error or file to big + if ( -1 == fsize || 0 == fsize || fszExtra ) + goto CLEANUP_AND_EXIT; + + hGlobal = GlobalAlloc( GMEM_MOVEABLE, fsize ); + if ( !hGlobal ) + goto CLEANUP_AND_EXIT; + + pData = GlobalLock( hGlobal ); + if ( !pData ) + goto CLEANUP_AND_EXIT; + + bRet = ReadFile( + hFile, pData, fsize, &nBytesRead, NULL ); + + if ( !bRet ) + goto CLEANUP_AND_EXIT; + + hr = CreateStreamOnHGlobal( + hGlobal, FALSE, &pIStream ); + + if ( SUCCEEDED( hr ) ) + { + hr = OleLoadPicture( + pIStream, fsize, FALSE, + __uuidof( IPicture ), (LPVOID*)&m_IPicture ); + } + +CLEANUP_AND_EXIT: + if ( hFile ) + CloseHandle( hFile ); + + if ( pData ) + GlobalUnlock( hGlobal ); + + if ( hGlobal ) + GlobalFree( hGlobal ); + + return ( SUCCEEDED( hr ) ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +LRESULT CALLBACK CFilePreview::WndProc( + HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) +{ + LRESULT lResult = 0; + + switch( uMsg ) + { + case WM_PAINT: + { + OSL_PRECOND( s_FilePreviewInst, "Static member not initialized" ); + + HDC hDC; + PAINTSTRUCT ps; + + hDC = BeginPaint( hWnd, &ps ); + s_FilePreviewInst->onPaint( hWnd, hDC ); + EndPaint( hWnd, &ps ); + } + break; + + // under windows 95/98 the creation of the + // hidden target request window fails if + // we don't handle this message ourself + // because the DefWindowProc returns 0 as + // a result of handling WM_NCCREATE what + // leads to a failure of CreateWindow[Ex]!!! + case WM_NCCREATE: + lResult = TRUE; + break; + + default: + return DefWindowProc( hWnd, uMsg, wParam, lParam ); + } + + return lResult; +} + + + diff --git a/fpicker/source/win32/filepicker/PreviewCtrl.hxx b/fpicker/source/win32/filepicker/PreviewCtrl.hxx new file mode 100644 index 000000000000..ae550fc2d4dc --- /dev/null +++ b/fpicker/source/win32/filepicker/PreviewCtrl.hxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: PreviewCtrl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _PREVIEWCTRL_HXX_ +#define _PREVIEWCTRL_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#include <comdef.h> + +#include <systools/win32/user9x.h> +#include <systools/win32/kernel9x.h> + +#include <memory> + +//--------------------------------------------- +// declaration +//--------------------------------------------- + +class CDimension +{ +public: + CDimension( ) : + m_cx( 0 ), + m_cy( 0 ) + { + } + + CDimension( sal_Int32 cx, sal_Int32 cy ) : + m_cx( cx ), + m_cy( cy ) + { + } + + sal_Int32 m_cx; + sal_Int32 m_cy; +}; + +//-------------------------------------------------- +// we use OleInitialize here because we are calling +// some Ole functions to realize the picture preview +// and we expect to be called from the main thread +// so that there will be no problem calling +// OleInitialize (the main thread should be an STA) +// When OleInitialize should fail at worst the +// preview doesn't work +//-------------------------------------------------- + +class CAutoOleInit +{ +public: + + // used to communicate ole + // initialzation failures + class COleInitException { }; + + CAutoOleInit( ) + { + HRESULT hr = OleInitialize( NULL ); + if ( FAILED( hr ) ) + throw COleInitException( ); + } + + ~CAutoOleInit( ) + { + OleUninitialize( ); + } +}; + +//--------------------------------------------- +// A simple file preview class to preview some +// common picture formats like *.gif, *jpg, etc. +// This class is not thread-safe and is +// implmented as singleton, because the class +// has only one static member to reconnect +// from callback functions +// we use a singleton-destroyer to get rid off +// the singleton instance, but this happens +// only on shutdown (unloading of the dll) - +// it's a question of taste (other solutions +// are possible) +//--------------------------------------------- + +class CFilePreview +{ +public: + // to ensure only one instance (singleton) + static CFilePreview* createInstance( + HWND aParent, + POINT ulCorner, + const CDimension& aSize, + HINSTANCE hInstance, + sal_Bool bShow = sal_True, + sal_Bool bEnabled = sal_True ); + + // sets the size of the preview window + sal_Bool SAL_CALL setSize( const CDimension& aSize ); + + // returns the CDimension of the preview + sal_Bool SAL_CALL getSize( CDimension& theSize ) const; + + // sets the position of the upper left corner + // of the preview window relative to the + // upper left corner of the parent window + sal_Bool SAL_CALL setPos( POINT ulCorner ); + + // returns the current position of the preview + // relative to the upper left corner of the + // parent window + sal_Bool SAL_CALL getPos( POINT& ulCorner ) const; + + // enables or disables the preview window + // bEnable - true the window is enabled and updates its + // view when update is called + // bEnable - false the window shows itself in disabled + // mode and does not update its view when update is + // called + void SAL_CALL enable( sal_Bool bEnable ); + + // shows the preview window + // possible values see SHOW_STATE + sal_Bool SAL_CALL show( sal_Bool bShow ); + + + // if the preview is shown and enabled + // preview of the given file will be shown + // returns true on success or false if an error + // occured (the file in not there or not accessible etc.) + virtual sal_Bool SAL_CALL update( const rtl::OUString& aFileName ); + +protected: + // clients can create instances only through the static create method + CFilePreview( + HWND aParent, + POINT ulCorner, + const CDimension& aSize, + HINSTANCE hInstance, + sal_Bool bShow = sal_True, + sal_Bool bEnabled = sal_True ); + + // only the singleton destroyer class is allowed to delete the + // singleton instance of this class + virtual ~CFilePreview( ); + + // we use the stl auto_ptr class as singleton destroyer + typedef std::auto_ptr< CFilePreview > FILEPREVIEW_SINGLETON_DESTROYER_T; + +protected: + virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC ); + + sal_Bool loadFile( const rtl::OUString& aFileName ); + +private: + CAutoOleInit m_autoOleInit; + POINT m_pt; + CDimension m_dim; + HWND m_hwnd; + sal_Bool m_bEnabled; + IPicturePtr m_IPicture; + ATOM m_atomPrevWndClass; + HINSTANCE m_hInstance; + + static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); + + static CFilePreview* s_FilePreviewInst; + static FILEPREVIEW_SINGLETON_DESTROYER_T s_SingletonDestroyer; + +private: + friend FILEPREVIEW_SINGLETON_DESTROYER_T; +}; + + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx new file mode 100644 index 000000000000..00a526c7b29b --- /dev/null +++ b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx @@ -0,0 +1,1151 @@ +/************************************************************************* + * + * $RCSfile: WinFileOpenImpl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _WINFILEOPENIMPL_HXX_ +#include "WinFileOpenImpl.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.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_FILEPICKEREVENT_HPP_ +#include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXECUTABLEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.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_FILEPREVIEWIMAGEFORMATS_HPP_ +#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_LISTBOXCONTROLACTIONS_HPP_ +#include <com/sun/star/ui/dialogs/ListBoxControlActions.hpp> +#endif + +#ifndef _WINIMPLHELPER_HXX_ +#include "..\misc\WinImplHelper.hxx" +#endif + +#ifndef _FILEPICKER_HXX_ +#include "filepicker.hxx" +#endif + +#ifndef _CONTROLACCESS_HXX_ +#include "controlaccess.hxx" +#endif + +#ifndef _DIBPREVIEW_HXX_ +#include "dibpreview.hxx" +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#include <systools/win32/comdlg9x.h> +#include <systools/win32/user9x.h> + +#ifndef _RESOURCEPROVIDER_HXX_ +#include "..\misc\resourceprovider.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using namespace std; +using rtl::OUString; +using rtl::OUStringBuffer; + +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::XInterface; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::ui::dialogs::FilePickerEvent; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::ui::dialogs::XFilePicker; + +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::ListboxControlActions; + +//------------------------------------------------------------------------- +// to distinguish what to do in the enum child window callback function +//------------------------------------------------------------------------- + +enum ECW_ACTION_T +{ + CHECK_PREVIEW = 0, + INIT_CONTROL_VALUES, + CACHE_CONTROL_VALUES +}; + +//------------------------------------------------------------------------- +// +//------------------------------------------------------------------------- + +const sal_Int32 MAX_LABEL = 256; +const OUString BACKSLASH = OUString::createFromAscii( "\\" ); + +//------------------------------------------------------------------------- +// ctor +//------------------------------------------------------------------------- + +CWinFileOpenImpl::CWinFileOpenImpl( + CFilePicker* aFilePicker, + sal_Bool bFileOpenDialog, + sal_uInt32 dwFlags, + sal_uInt32 dwTemplateId, + HINSTANCE hInstance ) : + CFileOpenDialog( bFileOpenDialog, dwFlags, dwTemplateId, hInstance ), + m_filterContainer( new CFilterContainer( ) ), + m_FilePicker( aFilePicker ), + m_bPreviewExists( sal_False ), + m_bInExecuteMode( sal_False ) +{ +} + +//------------------------------------------------------------------------ +// dtor +//------------------------------------------------------------------------ + +CWinFileOpenImpl::~CWinFileOpenImpl( ) +{ +} + +//------------------------------------------------------------------------ +// we expect the directory in URL format +//------------------------------------------------------------------------ + +void CWinFileOpenImpl::setDisplayDirectory( const OUString& aDirectory ) + throw( IllegalArgumentException, RuntimeException ) +{ + OUString aSysDirectory; + if( aDirectory.getLength( ) > 0 ) + { + if ( ::osl::FileBase::E_None != + ::osl::FileBase::getSystemPathFromFileURL( aDirectory, aSysDirectory ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid directory" ), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + // we ensure that there is a trailing '/' at the end of + // he given file url, because the windows functions only + // works correctly when providing "c:\" or an environment + // variable like "=c:=c:\.." etc. is set, else the + // FolderPicker would stand in the root of the shell + // hierarchie which is the desktop folder + if ( aSysDirectory.lastIndexOf( BACKSLASH ) != (aSysDirectory.getLength( ) - 1) ) + aSysDirectory += BACKSLASH; + } + + // call base class method + CFileOpenDialog::setDisplayDirectory( aSysDirectory ); +} + +//------------------------------------------------------------------------ +// we return the directory in URL format +//------------------------------------------------------------------------ + +OUString CWinFileOpenImpl::getDisplayDirectory( ) throw( RuntimeException ) +{ + OUString pathURL; + OUString displayDir; + + if ( m_bInExecuteMode ) + { + displayDir = getCurrentFolderPath( ); + } + else + { + displayDir = CFileOpenDialog::getDisplayDirectory( ); + } + + if ( displayDir.getLength( ) ) + ::osl::FileBase::getFileURLFromSystemPath( displayDir, pathURL ); + + return pathURL; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::setDefaultName( const OUString& aName ) + throw( IllegalArgumentException, RuntimeException ) +{ + // we don't set the default name directly + // because this influences how the file open + // dialog sets the initial path when it is about + // to open (see MSDN: OPENFILENAME) + // so we save the default name which should + // appear in the file-name-box and set + // this name when processing onInitDone + m_defaultName = aName; +} + +//----------------------------------------------------------------------------------------- +// return format: URL +// if multiselection is allowed there are two different cases +// 1. one file selected: the sequence contains one entry path\filename.ext +// 2. multiple files selected: the sequence contains multiple entries +// the first entry is the path url, all other entries are file names +//----------------------------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL CWinFileOpenImpl::getFiles( ) throw(RuntimeException) +{ + 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 + if ( m_bInExecuteMode ) + { + // returns the currently selected file(s) + // including path information + aFilePath = 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; + } + } + else // not in execution mode + { + aFilePath = 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; +} + +//----------------------------------------------------------------------------------------- +// shows the FileOpen/FileSave dialog +//----------------------------------------------------------------------------------------- + +sal_Int16 SAL_CALL CWinFileOpenImpl::execute( ) throw(RuntimeException) +{ + sal_Int16 rc = CFileOpenDialog::doModal( ); + + if ( 1 == rc ) + rc = ::com::sun::star::ui::dialogs::ExecutableDialogResults::OK; + else if ( 0 == rc ) + rc = ::com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; + else + throw RuntimeException( + OUString::createFromAscii( "Error executing dialog" ), + static_cast< XFilePicker* >( m_FilePicker ) ); + + return rc; +} + +//----------------------------------------------------------------------------------------- +// appends a new filter +// returns false if the title (aTitle) was already added or the title or the filter are +// empty +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::appendFilter( const OUString& aTitle, const OUString& aFilter ) + throw(IllegalArgumentException, RuntimeException) +{ + sal_Bool bRet = m_filterContainer->addFilter( aTitle, aFilter ); + if ( !bRet ) + throw IllegalArgumentException( + OUString::createFromAscii("filter already exists"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); +} + +//----------------------------------------------------------------------------------------- +// sets a current filter +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::setCurrentFilter( const OUString& aTitle ) + throw( IllegalArgumentException, RuntimeException) +{ + sal_Int32 filterPos = m_filterContainer->getFilterPos( aTitle ); + + if ( filterPos < 0 ) + throw IllegalArgumentException( + OUString::createFromAscii( "filter doesn't exist"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + // filter index of the base class starts with 1 + CFileOpenDialog::setFilterIndex( filterPos + 1 ); +} + +//----------------------------------------------------------------------------------------- +// returns the currently selected filter +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CWinFileOpenImpl::getCurrentFilter( ) throw(RuntimeException) +{ + sal_uInt32 nIndex = getSelectedFilterIndex( ); + + OUString currentFilter; + if ( nIndex > 0 ) + { + // filter index of the base class starts with 1 + sal_Bool bRet = m_filterContainer->getFilter( nIndex - 1, currentFilter ); + OSL_ASSERT( bRet ); + } + + return currentFilter; +} + +//================================================================================================================= +// XExtendedFilePicker +//================================================================================================================= + +void SAL_CALL CWinFileOpenImpl::setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const Any& aValue ) + throw(IllegalArgumentException, RuntimeException) +{ + if ( m_bInExecuteMode ) + { + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + // the filter listbox can be manipulated via this + // method the caller should use XFilterManager + if ( !hwndCtrl || (aControlId == LISTBOX_FILTER) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid control id" ), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndCtrl ); + if ( UNKNOWN == aCtrlClass ) + throw IllegalArgumentException( + OUString::createFromAscii( "unsupported control class" ), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + CTRL_SETVALUE_FUNCTION_T lpfnSetValue = + GetCtrlSetValueFunction( aCtrlClass, aControlAction ); + + if ( !lpfnSetValue ) + throw IllegalArgumentException( + OUString::createFromAscii( "unsupported control action" ), + static_cast< XFilePicker* >( m_FilePicker ), + 2 ); + + // 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, static_cast< XFilePicker* >( m_FilePicker ), 3 ); + + } + else + { + // the last one wins if somebody adds an entry for + // a checkbox for instance multiple times + m_ControlCache.push_back( + ControlCacheEntry( aControlId, aControlAction, aValue ) ); + } +} + +//----------------------------------------------------------------------------------------- +// returns the value of an custom template element +// we assume that there are only checkboxes or comboboxes +//----------------------------------------------------------------------------------------- + +Any SAL_CALL CWinFileOpenImpl::getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) + throw(IllegalArgumentException, RuntimeException) +{ + Any aAny; + + if ( m_bInExecuteMode ) + { + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + // the filter listbox can be manipulated via this + // method the caller should use XFilterManager + if ( !hwndCtrl || (aControlId == LISTBOX_FILTER) ) + throw IllegalArgumentException( + OUString::createFromAscii( "invalid control id" ), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + CTRL_CLASS aCtrlClass = GetCtrlClass( hwndCtrl ); + if ( UNKNOWN == aCtrlClass ) + throw IllegalArgumentException( + OUString::createFromAscii( "unsupported control class" ), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + CTRL_GETVALUE_FUNCTION_T lpfnGetValue = + GetCtrlGetValueFunction( aCtrlClass, aControlAction ); + + if ( !lpfnGetValue ) + throw IllegalArgumentException( + OUString::createFromAscii( "unsupported control action" ), + static_cast< XFilePicker* >( m_FilePicker ), + 2 ); + + aAny = lpfnGetValue( hwndCtrl ); + } + else + { + ControlCache_T::iterator iter_end = m_ControlCache.end( ); + ControlCache_T::iterator iter = m_ControlCache.begin( ); + + for ( /* empty */; iter != iter_end; ++iter ) + { + if ( (iter->m_controlId == aControlId) && + (iter->m_controlAction == aControlAction) ) + { + aAny = iter->m_Value; + break; + } + } + } + + return aAny; +} + +//----------------------------------------------------------------------------------------- +// enables a custom template element +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::enableControl( sal_Int16 ControlID, sal_Bool bEnable ) + throw(IllegalArgumentException, RuntimeException) +{ + HWND hwndCtrl = GetHwndDlgItem( ControlID ); + + if ( !hwndCtrl ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid element id"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + EnableWindow( hwndCtrl, bEnable ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) + throw (IllegalArgumentException, RuntimeException) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + if ( !hwndCtrl ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid element id"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + // somewhat risky because we don't know if OUString + // has a terminating '\0' + SetWindowTextW( hwndCtrl, aLabel.getStr( ) ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CWinFileOpenImpl::getLabel( sal_Int16 aControlId ) + throw (IllegalArgumentException, RuntimeException) +{ + HWND hwndCtrl = GetHwndDlgItem( aControlId ); + + if ( !hwndCtrl ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid element id"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + sal_Unicode aLabel[MAX_LABEL]; + int nRet = GetWindowTextW( hwndCtrl, aLabel, MAX_LABEL ); + + OUString ctrlLabel; + if ( nRet ) + ctrlLabel = OUString( aLabel, wcslen( aLabel ) ); + + return ctrlLabel; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +Sequence< sal_Int16 > SAL_CALL CWinFileOpenImpl::getSupportedImageFormats( ) + throw (RuntimeException) +{ + Sequence< sal_Int16 > imgFormatList( 1 ); + imgFormatList[0] = ::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP; + return imgFormatList; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CWinFileOpenImpl::getTargetColorDepth( ) + throw (RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + return m_DIBPreview->getColorDepth( ); + + return 0; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CWinFileOpenImpl::getAvailableWidth( ) + throw (RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + return m_DIBPreview->getWidth( ); + + return 0; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int32 SAL_CALL CWinFileOpenImpl::getAvailableHeight( ) + throw (::com::sun::star::uno::RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + return m_DIBPreview->getHeight( ); + + return 0; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::setImage( sal_Int16 aImageFormat, const Any& aImage ) + throw (IllegalArgumentException, RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + { + if ( aImageFormat != ::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP ) + throw IllegalArgumentException( + OUString::createFromAscii("unsupported image format"), + static_cast< XFilePicker* >( m_FilePicker ), + 1 ); + + if ( aImage.hasValue( ) && + (aImage.getValueType( ) != getCppuType( (Sequence< sal_Int8 >*) 0 ) ) ) + throw IllegalArgumentException( + OUString::createFromAscii("invalid image data"), + static_cast< XFilePicker* >( m_FilePicker ), + 2 ); + + Sequence< sal_Int8 > ImageData; + + // if the any has no value we have an + // empty Sequence which clears the + // preview window + if ( aImage.hasValue( ) ) + aImage >>= ImageData; + + m_DIBPreview->setImage( ImageData ); + } +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CWinFileOpenImpl::setShowState( sal_Bool bShowState ) + throw (::com::sun::star::uno::RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + return m_DIBPreview->show( bShowState ); + + return sal_False; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CWinFileOpenImpl::getShowState( ) + throw (RuntimeException) +{ + if ( m_DIBPreview.get( ) ) + return m_DIBPreview->isVisible( ); + + return sal_False; +} + +//----------------------------------------------------------------------------------------- +// returns the id of a custom template element +//----------------------------------------------------------------------------------------- + +sal_Int16 SAL_CALL CWinFileOpenImpl::getFocused( ) +{ + sal_Int32 nID = GetDlgCtrlID( GetFocus( ) ); + + // we don't forward id's of standard file open + // dialog elements (ctlFirst is defined in dlgs.h + // in MS Platform SDK) + if ( nID >= ctlFirst ) + nID = 0; + + return nID; +} + +//----------------------------------------------------------------------------------------- +// our own DlgProc because we do subclass the dialog +// we catch the WM_NCDESTROY message in order to erase an entry in our static map +// if one instance dies +//----------------------------------------------------------------------------------------- + +unsigned int CALLBACK CWinFileOpenImpl::SubClassFunc( + HWND hWnd, WORD wMessage, WPARAM wParam, LPARAM lParam ) +{ + CWinFileOpenImpl* pImpl = + dynamic_cast< CWinFileOpenImpl* >( s_fileOpenDlgInst ); + OSL_ASSERT( pImpl ); + + unsigned int lResult = 0; + + switch( wMessage ) + { + + case WM_HELP: + { + FilePickerEvent evt; + pImpl->m_FilePicker->helpRequested( evt ); + } + break; + + default: + + // !!! we use CallWindowProcA + lResult = CallWindowProcA( + reinterpret_cast< WNDPROC >( pImpl->m_pfnOldDlgProc ), + hWnd, + wMessage, + wParam, + lParam ); + + break; + + } // switch + + return lResult; +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::InitControlState( HWND hWnd ) +{ + CResourceProvider aResProvider; + + ControlCache_T::iterator iter_end = m_ControlCache.end( ); + ControlCache_T::iterator iter = m_ControlCache.begin( ); + + for ( /* empty */; iter != iter_end; ++iter ) + { + try + { + if ( GetDlgCtrlID( hWnd ) == iter->m_controlId ) + setValue( + iter->m_controlId, + iter->m_controlAction, + iter->m_Value ); + } + catch( ... ) + { + // if setValue throws an exception + // we catch and ignore it because it may + // be that there are some invalid or old + // items in the cache + OSL_ASSERT( sal_False ); + } + } + + //----------------------------------------- + // set the labels for all extendet controls + //----------------------------------------- + + sal_Int32 aCtrlId = GetDlgCtrlID( hWnd ); + OUString aLabel = aResProvider.getResString( aCtrlId ); + if ( aLabel.getLength( ) ) + setLabel( aCtrlId, aLabel ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::CacheControlState( HWND hWnd ) +{ + CTRL_CLASS aCtrlClass = GetCtrlClass( hWnd ); + + if ( UNKNOWN == aCtrlClass ) + return; + + sal_Int16 aControlAction; + + if ( CHECKBOX == aCtrlClass ) + { + aControlAction = 0; + } + else if ( LISTBOX == aCtrlClass ) + { + // for listboxes we save only the + // last selected item + aControlAction = GET_SELECTED_ITEM; + } + + CTRL_GETVALUE_FUNCTION_T lpfnGetValue = + GetCtrlGetValueFunction( aCtrlClass, aControlAction ); + + OSL_ASSERT( lpfnGetValue ); + + m_ControlCache.push_back( + ControlCacheEntry( + GetDlgCtrlID( hWnd ), + aControlAction, + lpfnGetValue( hWnd ) ) ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +sal_Bool SAL_CALL CWinFileOpenImpl::HasPreview( HWND hWnd ) +{ + if ( CHECKBOX_PREVIEW == GetDlgCtrlID( hWnd ) ) + m_bPreviewExists = sal_True; + + return m_bPreviewExists; +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +BOOL CALLBACK CWinFileOpenImpl::EnumChildWndProc( HWND hWnd, LPARAM lParam ) +{ + ECW_ACTION_T action = (ECW_ACTION_T)lParam; + CWinFileOpenImpl* pImpl = + dynamic_cast< CWinFileOpenImpl* >( s_fileOpenDlgInst ); + + OSL_ASSERT( pImpl ); + + BOOL bRet = TRUE; + + switch( action ) + { + case CHECK_PREVIEW: + if ( pImpl->HasPreview( hWnd ) ) + bRet = FALSE; + break; + + case INIT_CONTROL_VALUES: + pImpl->InitControlState( hWnd ); + break; + + case CACHE_CONTROL_VALUES: + pImpl->CacheControlState( hWnd ); + break; + } + + return bRet; +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +sal_uInt32 SAL_CALL CWinFileOpenImpl::onFileOk() +{ + // fill the control value cache + m_ControlCache.clear( ); + EnumChildWindows( + m_hwndFileOpenDlgChild, + CWinFileOpenImpl::EnumChildWndProc, + (LPARAM) CACHE_CONTROL_VALUES ); + + return 0; +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onSelChanged( HWND hwndListBox ) +{ + FilePickerEvent evt; + evt.Source = static_cast< XFilePicker* >( m_FilePicker ); + m_FilePicker->fileSelectionChanged( evt ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onHelp( ) +{ + FilePickerEvent evt; + evt.ElementId = getFocused( ); + evt.Source = static_cast< XFilePicker* >( m_FilePicker ); + m_FilePicker->helpRequested( evt ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onInitDone() +{ + // manually setting the file name that appears + // initially in the file-name-box of the file + // open dialog (reason: see above setDefaultName) + if ( m_defaultName.getLength( ) ) + { + sal_Int32 edt1Id = edt1; + + // under W2k the there is a combobox instead + // of an edit field for the file name edit field + // the control id of this box is cmb13 and not + // edt1 as before so we must use this id + if ( IsWin2000( ) ) + edt1Id = cmb13; + + HWND hwndEdt1 = GetDlgItem( m_hwndFileOpenDlg, edt1Id ); + SetWindowTextW( hwndEdt1, m_defaultName ); + } + + // we check if the checkbox is present and if so + // create a preview window + EnumChildWindows( + m_hwndFileOpenDlgChild, + CWinFileOpenImpl::EnumChildWndProc, + (LPARAM) CHECK_PREVIEW ); + + // create and display the preview control + + if ( m_bPreviewExists ) + { + // lst1 is the file listbox and is defined by MS in dlgs.h + HWND hwndFileListbox = GetDlgItem( m_hwndFileOpenDlg, lst1 ); + OSL_ASSERT( IsWindow( hwndFileListbox ) ); + + // save the original size of the file listbox + RECT rcFileListbox; + GetWindowRect( hwndFileListbox, &rcFileListbox ); + + m_SizeFileListBoxOriginal = std::make_pair( + rcFileListbox.right - rcFileListbox.left, + rcFileListbox.bottom - rcFileListbox.top ); + + // shrink the width of the fileopen file listbox + sal_uInt32 newWidthFileListbox = + static_cast< sal_uInt32 >( + (rcFileListbox.right - rcFileListbox.left) / 2); + + // resize the fileopen file listbox + SetWindowPos( hwndFileListbox, + NULL, 0, 0, newWidthFileListbox, + m_SizeFileListBoxOriginal.second, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); + + // get the new size of the file listbox + GetWindowRect( hwndFileListbox, &rcFileListbox ); + + POINT ulCorner; + ulCorner.x = rcFileListbox.right; + ulCorner.y = rcFileListbox.top; + + ScreenToClient( m_hwndFileOpenDlg, &ulCorner ); + + DIMENSION_T sizePreviewWnd = std::make_pair( + (rcFileListbox.right - rcFileListbox.left) - 3, + (rcFileListbox.bottom - rcFileListbox.top) ); + + // we try to get a window handle to a control with + // the id 1119 which is defined as stc32 in the + // Platform SDK header files and has a special + // meaning (see MSDN under the title: + // "Explorer-Style Custom Templates") + // if this control is available, all standard controls, + // will be placed on this control, so we have to use + // it as parent for our preview window else the stc32 + // control may paint over the client area of our + // preview control + // if there is no stc32 control, all standard controls + // are childs of the dialog box itself + HWND hwndParent; + HWND hwndStc32 = GetDlgItem( m_hwndFileOpenDlgChild, 1119 ); + if ( IsWindow( hwndStc32 ) ) + hwndParent = hwndStc32; + else + hwndParent = m_hwndFileOpenDlg; + + // as parent we use the + CDIBPreview* pDIBPreview = new CDIBPreview( + ulCorner.x, + ulCorner.y, + sizePreviewWnd.first, + sizePreviewWnd.second, + hwndParent, + m_ofn.hInstance ); + + m_DIBPreview.reset( pDIBPreview ); + + // restore the origional size of the file listbox on failure + if ( m_DIBPreview.get( ) && + !(m_DIBPreview->getWidth( ) && m_DIBPreview->getHeight( )) ) + { + SetWindowPos( hwndFileListbox, + NULL, 0, 0, + m_SizeFileListBoxOriginal.first, + m_SizeFileListBoxOriginal.second, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); + } + } + + // initialize controls from cache + EnumChildWindows( + m_hwndFileOpenDlgChild, + CWinFileOpenImpl::EnumChildWndProc, + (LPARAM) INIT_CONTROL_VALUES ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onFolderChanged() +{ + FilePickerEvent evt; + evt.Source = static_cast< XFilePicker* >( m_FilePicker ); + m_FilePicker->directoryChanged( evt ); +} + +//----------------------------------------------------------------- +// +//----------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onTypeChanged( sal_uInt32 nFilterIndex ) +{ + FilePickerEvent evt; + evt.ElementId = LISTBOX_FILTER; + evt.Source = static_cast< XFilePicker* >( m_FilePicker ); + m_FilePicker->controlStateChanged( evt ); +} + +//----------------------------------------------------------------------------------------- +// onMessageCommand handler +//----------------------------------------------------------------------------------------- + +sal_uInt32 SAL_CALL CWinFileOpenImpl::onCtrlCommand( + HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode ) +{ + if ( ctrlId < ctlFirst ) + { + FilePickerEvent evt; + + evt.ElementId = ctrlId; + evt.Source = static_cast< XFilePicker* >( m_FilePicker ); + m_FilePicker->controlStateChanged( evt ); + } + + return 0; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CWinFileOpenImpl::onInitDialog( HWND hwndDlg, HWND hwndChild ) +{ + // subclass the dialog window + m_pfnOldDlgProc = + reinterpret_cast< DLGPROC >( + SetWindowLong( hwndDlg, + DWL_DLGPROC, + reinterpret_cast< DWORD >( SubClassFunc ) ) ); +} + +//----------------------------------------------------------------------------------------- +// processing before showing the dialog +//----------------------------------------------------------------------------------------- + +sal_Bool SAL_CALL CWinFileOpenImpl::preModal( ) +{ + CFileOpenDialog::setFilter( + makeWinFilterBuffer( *m_filterContainer.get( ) ) ); + + m_bInExecuteMode = sal_True; + + return sal_True; +} + +//----------------------------------------------------------------------------------------- +// processing after showing the dialog +//----------------------------------------------------------------------------------------- + +void CWinFileOpenImpl::postModal( sal_Int16 nDialogResult ) +{ + CFileOpenDialog::postModal( nDialogResult ); + + m_bInExecuteMode = sal_False; +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +HWND SAL_CALL CWinFileOpenImpl::GetHwndDlgItem( sal_Int16 ctrlId, sal_Bool bIncludeStdCtrls ) +{ + HWND hwndCtrl = GetDlgItem( m_hwndFileOpenDlgChild, ctrlId ); + + // maybe it's a control of the dialog itself for instance + // the ok and cancel button + if ( !hwndCtrl && bIncludeStdCtrls ) + { + ctrlId = CommonFilePickerCtrlIdToWinFileOpenCtrlId( ctrlId ); + hwndCtrl = GetDlgItem( m_hwndFileOpenDlg, ctrlId ); + } + + return hwndCtrl; +}
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.hxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.hxx new file mode 100644 index 000000000000..fd4fecb8b940 --- /dev/null +++ b/fpicker/source/win32/filepicker/WinFileOpenImpl.hxx @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: WinFileOpenImpl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _WINFILEOPENIMPL_HXX_ +#define _WINFILEOPENIMPL_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXTENDEDFILEPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_FILEPICKEREVENT_HPP_ +#include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> +#endif + +#ifndef _FILTER_CONTAINER_HXX_ +#include "FilterContainer.hxx" +#endif + +#ifndef _FILEOPENDLG_HXX_ +#include "FileOpenDlg.hxx" +#endif + +#ifndef _DIBPREVIEW_HXX_ +#include "dibpreview.hxx" +#endif + +#include <utility> +#include <memory> +#include <vector> + +//------------------------------------------------------------------------- +// a cache for the control values before and after execution of the dialog +//------------------------------------------------------------------------- + +struct ControlCacheEntry +{ + sal_Int16 m_controlId; + sal_Int16 m_controlAction; + ::com::sun::star::uno::Any m_Value; + + ControlCacheEntry( + sal_Int16 aControlId, sal_Int16 aControlAction, ::com::sun::star::uno::Any aValue ) : + m_controlId( aControlId ), + m_controlAction( aControlAction ), + m_Value( aValue ) + {} +}; + +typedef std::vector< ControlCacheEntry > ControlCache_T; + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +// forward declaration +class CFilePicker; + +class CWinFileOpenImpl : public CFileOpenDialog +{ +public: + CWinFileOpenImpl( + CFilePicker* aFilePicker, + sal_Bool bFileOpenDialog = sal_True, + sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + sal_uInt32 dwTemplateId = 0, + HINSTANCE hInstance = 0 ); + + virtual ~CWinFileOpenImpl( ); + + //----------------------------------------------------------------------------------------- + // XExecutableDialog + //----------------------------------------------------------------------------------------- + + virtual sal_Int16 SAL_CALL execute( ) throw( ::com::sun::star::uno::RuntimeException ); + + //----------------------------------------------------------------------------------------- + // XFilePicker + //----------------------------------------------------------------------------------------- + + virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( ) + throw(::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ) throw ( ::com::sun::star::uno::RuntimeException ); + + //----------------------------------------------------------------------------------------- + // XFilterManager + //----------------------------------------------------------------------------------------- + + virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::rtl::OUString SAL_CALL getCurrentFilter( ) + throw( ::com::sun::star::uno::RuntimeException ); + + //----------------------------------------------------------------------------------------- + // XExtendedFilePicker + //----------------------------------------------------------------------------------------- + + virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) + throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XFilePreview + //------------------------------------------------ + + virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getTargetColorDepth( ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getAvailableWidth( ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getAvailableHeight( ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL getShowState( ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + sal_Int16 SAL_CALL getFocused( ); + + virtual sal_Bool SAL_CALL preModal( ); + virtual void SAL_CALL postModal( sal_Int16 nDialogResult ); + + virtual sal_uInt32 SAL_CALL onFileOk(); + virtual void SAL_CALL onSelChanged( HWND hwndListBox ); + virtual void SAL_CALL onHelp( ); + + // only called back if OFN_EXPLORER is set + virtual void SAL_CALL onInitDone(); + virtual void SAL_CALL onFolderChanged(); + virtual void SAL_CALL onTypeChanged( sal_uInt32 nFilterIndex ); + + // call base class method first when overloading + virtual void SAL_CALL onInitDialog( HWND hwndDlg, HWND hwndChild ); + + virtual sal_uInt32 SAL_CALL onCtrlCommand( HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode ); + +private: + // initialize all controls from cache + void SAL_CALL InitControlState( HWND hWnd ); + + // save the control state + void SAL_CALL CacheControlState( HWND hWnd ); + + // checks wether there is the checkbox preview + sal_Bool SAL_CALL HasPreview( HWND hWnd ); + + // 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 ctrlId, sal_Bool bIncludeStdCtrls = sal_True ); + + static unsigned int CALLBACK SubClassFunc( HWND hWnd, WORD wMessage, WPARAM wParam, LPARAM lParam ); + + static BOOL CALLBACK EnumChildWndProc( HWND hWnd, LPARAM lParam ); + + typedef std::pair< int, int > DIMENSION_T; + +private: + std::auto_ptr< CFilterContainer > m_filterContainer; + std::auto_ptr< CDIBPreview > m_DIBPreview; + sal_Bool m_bPreviewExists; + CFilePicker* m_FilePicker; + DLGPROC m_pfnOldDlgProc; + DIMENSION_T m_SizeFileListBoxOriginal; + rtl::OUString m_defaultName; + sal_Bool m_bInExecuteMode; + ControlCache_T m_ControlCache; +}; + + +#endif diff --git a/fpicker/source/win32/filepicker/afxres.h b/fpicker/source/win32/filepicker/afxres.h new file mode 100644 index 000000000000..0961c334dd41 --- /dev/null +++ b/fpicker/source/win32/filepicker/afxres.h @@ -0,0 +1,2 @@ +#include <windows.h> +#include <dlgs.h> diff --git a/fpicker/source/win32/filepicker/controlaccess.cxx b/fpicker/source/win32/filepicker/controlaccess.cxx new file mode 100644 index 000000000000..aad7482e7479 --- /dev/null +++ b/fpicker/source/win32/filepicker/controlaccess.cxx @@ -0,0 +1,295 @@ +/************************************************************************* + * + * $RCSfile: controlaccess.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _CONTROLACCESS_HXX_ +#include "controlaccess.hxx" +#endif + +#ifndef _WINIMPLHELPER_HXX_ +#include "..\misc\WinImplHelper.hxx" +#endif + +#include <systools/win32/user9x.h> + +//------------------------------------------------------------ +// 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, + ListboxGetSelectedItem + }; + 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 || + aCtrlAction < 0 || aCtrlAction >= aTableSize ) + 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 || + aCtrlAction < 0 || aCtrlAction >= aTableSize ) + 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, + IDOK, + IDCANCEL, + cmb1 + }; + const SIZE_WINDOWS_FILEOPEN_CTRL_IDS = + sizeof( WindowsFileOpenCtrlIds ) / sizeof( int ); + +}; // 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; + char aClassName[256]; + + int nRet = GetClassNameA( hwndCtrl, aClassName, 256 ); + if ( nRet ) + { + if ( 0 == _stricmp( aClassName, "button" ) ) + { + // button means many things so we have + // to find out what button it is + LONG lBtnStyle = GetWindowLong( hwndCtrl, GWL_STYLE ); + if ( lBtnStyle & BS_CHECKBOX ) + aCtrlClass = CHECKBOX; + else if ( (lBtnStyle & BS_PUSHBUTTON) || + (lBtnStyle & BS_DEFPUSHBUTTON) ) + aCtrlClass = PUSHBUTTON; + } + else if ( 0 == _stricmp( aClassName, "listbox" ) || + 0 == _stricmp( aClassName, "combobox" ) ) + 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]; +} diff --git a/fpicker/source/win32/filepicker/controlaccess.hxx b/fpicker/source/win32/filepicker/controlaccess.hxx new file mode 100644 index 000000000000..7a6c78cf97d3 --- /dev/null +++ b/fpicker/source/win32/filepicker/controlaccess.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * $RCSfile: controlaccess.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _CONTROLACCESS_HXX_ +#define _CONTROLACCESS_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 + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +typedef void ( SAL_CALL *CTRL_SETVALUE_FUNCTION_T)( HWND, const ::com::sun::star::uno::Any&, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&, sal_Int16 ); +typedef ::com::sun::star::uno::Any ( SAL_CALL *CTRL_GETVALUE_FUNCTION_T )( HWND ); + +// the currently supported control classes +enum CTRL_CLASS +{ + UNKNOWN = 0, + CHECKBOX, + LISTBOX, + PUSHBUTTON +}; + +// returns the class of a control +CTRL_CLASS SAL_CALL GetCtrlClass( HWND hwndCtrl ); + +// returns a pointer to a setValue function based on the control class +// and the control action, if no function was found NULL will be returned +CTRL_SETVALUE_FUNCTION_T SAL_CALL GetCtrlSetValueFunction( CTRL_CLASS aCtrlClass, sal_Int16 aCtrlAction ); + +// returns a pointer to a getValue function based on the control class +// and the control action, if no function was found NULL will be returned +CTRL_GETVALUE_FUNCTION_T SAL_CALL GetCtrlGetValueFunction( CTRL_CLASS aCtrlClass, sal_Int16 aCtrlAction ); + +// translates a CommonFilePickerElementId as defined in CommonFilePickerElementIds.idl +// to a control id that is valid for the FileOpen dialog under windows as defined +// in dlgs.h in the Windows Platform SDK +int SAL_CALL CommonFilePickerCtrlIdToWinFileOpenCtrlId( sal_Int16 aControlId ); + +#endif diff --git a/fpicker/source/win32/filepicker/dibpreview.cxx b/fpicker/source/win32/filepicker/dibpreview.cxx new file mode 100644 index 000000000000..316340553265 --- /dev/null +++ b/fpicker/source/win32/filepicker/dibpreview.cxx @@ -0,0 +1,350 @@ +/************************************************************************* + * + * $RCSfile: dibpreview.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13: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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _DIBPREVIEW_HXX_ +#include "dibpreview.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include <systools/win32/user9x.h> + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +using ::com::sun::star::uno::Sequence; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define PREVIEWWND_CLASS_NAME L"DIBPreviewWnd###" + +// means 3 pixel left and 3 pixel right +#define HORZ_BODER_SPACE 6 + +// means 3 pixel top and 3 pixel bottom +#define VERT_BORDER_SPACE 6 + +//--------------------------------------------------- +// static member initialization +//--------------------------------------------------- + +CDIBPreview* CDIBPreview::s_DIBPreviewInst = NULL; + +//--------------------------------------------------- +// +//--------------------------------------------------- + +CDIBPreview::CDIBPreview( + sal_Int32 x, + sal_Int32 y, + sal_Int32 cx, + sal_Int32 cy, + HWND aParent, + HINSTANCE hInstance, + sal_Bool bShow ) : + m_hwnd( NULL ), + m_hInstance( hInstance ) +{ + // register the preview window class + WNDCLASSEXW wndClsEx; + ZeroMemory( &wndClsEx, sizeof( WNDCLASSEXW ) ); + + wndClsEx.cbSize = sizeof( WNDCLASSEXW ); + wndClsEx.style = CS_HREDRAW | CS_VREDRAW; + wndClsEx.lpfnWndProc = CDIBPreview::WndProc; + wndClsEx.hInstance = m_hInstance; + wndClsEx.hbrBackground = (HBRUSH)( COLOR_INACTIVEBORDER + 1 ); + wndClsEx.lpszClassName = PREVIEWWND_CLASS_NAME; + + // register the preview window class + // !!! Win95 - the window class will be unregistered automaticly + // if the dll is unloaded + // Win2000 - the window class must be unregistered manually + // if the dll is unloaded + m_ClassAtom = RegisterClassExW( &wndClsEx ); + if ( m_ClassAtom ) + { + // create the preview window in invisible state + sal_uInt32 dwStyle = bShow ? (WS_CHILD | WS_VISIBLE ) : (WS_CHILD ); + m_hwnd = CreateWindowExW( + WS_EX_CLIENTEDGE, PREVIEWWND_CLASS_NAME, + L"", dwStyle, x, y, cx, cy, aParent, + (HMENU)0x0, // for child windows this will + // be used as child window identifier + m_hInstance, 0 ); + + OSL_ASSERT( IsWindow( m_hwnd ) ); + } + + // set the static member + s_DIBPreviewInst = this; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +CDIBPreview::~CDIBPreview( ) +{ + UnregisterClass( + (LPCTSTR)MAKELONG( m_ClassAtom, 0 ), m_hInstance ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CDIBPreview::setWidth( sal_Int32 cx_new ) +{ + SetWindowPos( + m_hwnd, NULL, 0, 0, cx_new, getHeight( ), + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +sal_Int32 SAL_CALL CDIBPreview::getWidth( ) const +{ + RECT rect; + sal_Bool bRet = GetClientRect( m_hwnd, &rect ); + + sal_Int32 cx = 0; + + if ( bRet ) + cx = rect.right; + + return cx; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CDIBPreview::setHeight( sal_Int32 cy_new ) +{ + SetWindowPos( + m_hwnd, NULL, 0, 0, getWidth( ), cy_new, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +sal_Int32 SAL_CALL CDIBPreview::getHeight( ) const +{ + RECT rect; + sal_Bool bRet = GetClientRect( m_hwnd, &rect ); + + sal_Int32 cy = 0; + + if ( bRet ) + cy = rect.bottom; + + return cy; +} + +//--------------------------------------------------- +// shows or hides the preview window +//--------------------------------------------------- + +sal_Bool SAL_CALL CDIBPreview::show( sal_Bool bShow ) +{ + sal_Bool bRet = sal_False; + + if ( IsWindow( m_hwnd ) ) + { + ShowWindow( m_hwnd, bShow ? SW_SHOW : SW_HIDE ); + bRet = sal_True; + } + + return bRet; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +sal_Bool SAL_CALL CDIBPreview::isVisible( ) const +{ + return IsWindowVisible( m_hwnd ); +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +int SAL_CALL CDIBPreview::getColorDepth( ) +{ + HDC hdc = GetDC( m_hwnd ); + int clrRes = 0; + + if ( hdc ) + clrRes = GetDeviceCaps( hdc, COLORRES ); + + return clrRes; +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CDIBPreview::setImage( const Sequence< sal_Int8 >& ImageData ) +{ + // save the new image data and force a redraw + m_ImageData = ImageData; + InvalidateRect( m_hwnd, NULL, TRUE ); + UpdateWindow( m_hwnd ); +} +//--------------------------------------------------- +// +//--------------------------------------------------- + +void SAL_CALL CDIBPreview::onPaint( HWND hWnd, HDC hDC ) +{ + BITMAPFILEHEADER* pbmfh; + BITMAPINFO * pbmi; + BYTE * pBits; + int cxDib; + int cyDib; + + try + { + pbmfh = reinterpret_cast< BITMAPFILEHEADER* >( m_ImageData.getArray( ) ); + + if ( !IsBadReadPtr( pbmfh, sizeof( BITMAPFILEHEADER ) ) && + (pbmfh->bfType == *(WORD*)"BM") ) + { + pbmi = reinterpret_cast< BITMAPINFO * >( (pbmfh + 1) ); + pBits = reinterpret_cast< BYTE * >( ((DWORD)pbmfh) + pbmfh->bfOffBits ); + + cxDib = pbmi->bmiHeader.biWidth; + cyDib = abs (pbmi->bmiHeader.biHeight); + + int oldMode = SetStretchBltMode( hDC, COLORONCOLOR ); + + int GDIError = StretchDIBits( + hDC, 0, 0, getWidth( ), getHeight( ), + 0, 0, cxDib, cyDib, pBits, pbmi, + DIB_RGB_COLORS, SRCCOPY); + + OSL_ASSERT( GDI_ERROR != GDIError ); + } + } + catch(...) + { + } +} + +//--------------------------------------------------- +// +//--------------------------------------------------- + +LRESULT CALLBACK CDIBPreview::WndProc( + HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) +{ + LRESULT lResult = 0; + + switch( uMsg ) + { + case WM_PAINT: + { + OSL_PRECOND( s_DIBPreviewInst, "Static member not initialized" ); + + HDC hDC; + PAINTSTRUCT ps; + + hDC = BeginPaint( hWnd, &ps ); + s_DIBPreviewInst->onPaint( hWnd, hDC ); + EndPaint( hWnd, &ps ); + } + break; + + // under windows 95/98 the creation of the + // hidden target request window fails if + // we don't handle this message ourself + // because the DefWindowProc returns 0 as + // a result of handling WM_NCCREATE what + // leads to a failure of CreateWindow[Ex]!!! + case WM_NCCREATE: + lResult = TRUE; + break; + + default: + return DefWindowProc( hWnd, uMsg, wParam, lParam ); + } + + return lResult; +} + + + diff --git a/fpicker/source/win32/filepicker/dibpreview.hxx b/fpicker/source/win32/filepicker/dibpreview.hxx new file mode 100644 index 000000000000..f710e00195d6 --- /dev/null +++ b/fpicker/source/win32/filepicker/dibpreview.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: dibpreview.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $ + * + * 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 _DIBPREVIEW_HXX_ +#define _DIBPREVIEW_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX +#include <com/sun/star/uno/Sequence.hxx> +#endif + +#include <windows.h> + +//--------------------------------------------- +// A very simple wrapper for a window that does +// display DIBs. +// Maybe it would be better and more extensible +// to create another class that is responsible +// for rendering a specific image format into +// the area of the window, but for our purpose +// it's enough to go the simple way - KISS. +//--------------------------------------------- + +class CDIBPreview +{ +public: + // clients can create instances only + // through the static create method + CDIBPreview( + sal_Int32 x, + sal_Int32 y, + sal_Int32 cx, + sal_Int32 cy, + HWND aParent, + HINSTANCE hInstance, + sal_Bool bShow = sal_True ); + + // dtor + ~CDIBPreview( ); + + // window size information + + void SAL_CALL setWidth( sal_Int32 cx_new ); + + sal_Int32 SAL_CALL getWidth( ) const; + + void SAL_CALL setHeight( sal_Int32 cy_new ); + + sal_Int32 SAL_CALL getHeight( ) const; + + // shows the preview window + // possible values see SHOW_STATE + sal_Bool SAL_CALL show( sal_Bool bShow ); + + // returns true when the preview window is + // visible and + // false if not + sal_Bool SAL_CALL isVisible( ) const; + + // returns the currently supported color + // resolution of the preview window + int SAL_CALL getColorDepth( ); + + void SAL_CALL setImage( const ::com::sun::star::uno::Sequence< sal_Int8 >& pImageData ); + +private: + virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC ); + static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); + +private: + HWND m_hwnd; + ATOM m_ClassAtom; + HINSTANCE m_hInstance; + ::com::sun::star::uno::Sequence< sal_Int8 > m_ImageData; + sal_Int32 m_cx; + sal_Int32 m_cy; + + static CDIBPreview* s_DIBPreviewInst; + +// prevent copy and assignment +private: + CDIBPreview( const CDIBPreview& ); + CDIBPreview& operator=( const CDIBPreview& ); +}; + + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/filepicker/fps.xml b/fpicker/source/win32/filepicker/fps.xml new file mode 100644 index 000000000000..539fdcf48689 --- /dev/null +++ b/fpicker/source/win32/filepicker/fps.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name>fps</module-name> + <component-description> + <author> Tino Rachui </author> + <name> com.sun.star.comp.ui.dialogs.FilePicker </name> + <description> + The win32 implementation of the FilePicker service. +</description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language> c++ </language> + <status value="beta"/> + <supported-service> com.sun.star.ui.dialogs.FilePicker </supported-service> + <service-dependency>...</service-dependency> + <type> com.sun.star.ui.dialogs.XExecutableDialog </type> + <type> com.sun.star.ui.dialogs.XFilePicker </type> + <type> com.sun.star.ui.dialogs.XFilterManager </type> + <type> com.sun.star.ui.dialogs.XFilePickerListener </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogException </type> + <type> com.sun.star.ui.dialogs.XFilePickerNotifier </type> + <type> com.sun.star.ui.dialogs.XFilePickerControlAccess </type> + <type> com.sun.star.ui.dialogs.XFilePreview </type> + <type> com.sun.star.ui.dialogs.ExtendedFilePickerElementIds </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogResults </type> + <type> com.sun.star.ui.dialogs.FilePickerEvent </type> + <type> com.sun.star.ui.dialogs.CommonFilePickerElementIds </type> + <type> com.sun.star.ui.dialogs.ListboxControlActions </type> + <type> com.sun.star.ui.dialogs.TemplateDescription </type> + <type> com.sun.star.ui.dialogs.FilePreviewImageFormats </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.container.XSet </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/fpicker/source/win32/filepicker/makefile.mk b/fpicker/source/win32/filepicker/makefile.mk new file mode 100644 index 000000000000..38210dec87fe --- /dev/null +++ b/fpicker/source/win32/filepicker/makefile.mk @@ -0,0 +1,101 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:13:25 $ +# +# 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=fps +#LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) +COMPRDB=$(SOLARBINDIR)$/applicat.rdb + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +.INCLUDE : ..$/..$/cppumaker.mk + +CFLAGS+=/GX /GR /D_WIN32_WINNT=0x0500 + +# --- Resources ---------------------------------------------------- + +.IF "$(GUI)" == "WNT" +RCFILES=fps.rc +.ENDIF + +# --- Files -------------------------------------------------------- + +SLOFILES=$(SLO)$/FileOpenDlg.obj\ + $(SLO)$/FPentry.obj\ + $(SLO)$/FilePicker.obj\ + $(SLO)$/WinFileOpenImpl.obj\ + $(SLO)$/FilterContainer.obj\ + $(SLO)$/controlaccess.obj\ + $(SLO)$/dibpreview.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/fpicker/source/win32/filepicker/resource.h b/fpicker/source/win32/filepicker/resource.h new file mode 100644 index 000000000000..200b095e60f7 --- /dev/null +++ b/fpicker/source/win32/filepicker/resource.h @@ -0,0 +1,21 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Fps.rc +// +#define IDD_DIALOG1 101 +#define IDB_BITMAP1 117 +#define IDB_BITMAP2 118 +#define IDC_BUTTON1 1008 +#define stc32 -1 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 119 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1014 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/fpicker/source/win32/filepicker/workbench/Test_fps.cxx b/fpicker/source/win32/filepicker/workbench/Test_fps.cxx new file mode 100644 index 000000000000..0264a7c70d87 --- /dev/null +++ b/fpicker/source/win32/filepicker/workbench/Test_fps.cxx @@ -0,0 +1,469 @@ +/************************************************************************* + * + * $RCSfile: Test_fps.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:14:43 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +//_________________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________________ + +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include <com/sun/star/lang/XComponent.hpp> +#endif + +#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +//_________________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________________ + +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#include <cppuhelper/servicefactory.hxx> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePicker.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERMANAGER_HPP_ +#include <com/sun/star/ui/dialogs/XFilterManager.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_FILEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERLISTENER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERNOTIFIER_HPP_ +#include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_TEMPLATEDESCRIPTION_HPP_ +#include <com/sun/star/ui/dialogs/TemplateDescription.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_EXTENDEDFILEPICKERELEMENTIDS_HPP_ +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_LISTBOXCONTROLACTIONS_HPP_ +#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPREVIEW_HPP_ +#include <com/sun/star/ui/dialogs/XFilePreview.hpp> +#endif + +#include <osl/thread.h> + +#include <stdio.h> +#include <windows.h> + +#include "..\FPServiceInfo.hxx" + +// +// namesapces +// + +using namespace ::rtl ; +using namespace ::cppu ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::ui::dialogs ; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; + +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::ListboxControlActions; + +using namespace std ; + +// forward + +void TestFilterManager( Reference< XFilePicker > xFilePicker ); + + +#define RDB_SYSPATH "D:\\Projects\\gsl\\sysui\\wntmsci7\\bin\\applicat.rdb" + +//_________________________________________________________________________________________________________________________ +// global variables +//_________________________________________________________________________________________________________________________ + +Reference< XMultiServiceFactory > g_xFactory; + +const OUString BMP_EXTENSION = OUString::createFromAscii( "bmp" ); + +//------------------------------------------------------------------------------------------------------------------------- +// a test client +//------------------------------------------------------------------------------------------------------------------------- + +class FilePickerListener : public WeakImplHelper1< XFilePickerListener > +{ +public: + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw(::com::sun::star::uno::RuntimeException); + + // XFilePickerListener + virtual void SAL_CALL fileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL directoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + virtual OUString SAL_CALL helpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL controlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL dialogSizeChanged( ) + throw (::com::sun::star::uno::RuntimeException); +}; + +void SAL_CALL FilePickerListener::disposing( const ::com::sun::star::lang::EventObject& Source ) + throw(::com::sun::star::uno::RuntimeException) +{ +} + +void SAL_CALL FilePickerListener::fileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException) +{ + try + { + Reference< XFilePicker > rXFilePicker( aEvent.Source, UNO_QUERY ); + Reference< XFilePreview > rXFilePreview( rXFilePicker, UNO_QUERY ); + + if ( !rXFilePreview.is( ) ) + return; + + Sequence< OUString > aFileList = rXFilePicker->getFiles( ); + if ( 1 == aFileList.getLength( ) ) + { + OUString FilePath = aFileList[0]; + + // detect file extension + sal_Int32 nIndex = FilePath.lastIndexOf( BMP_EXTENSION ); + if ( (FilePath.getLength( ) - 3) == nIndex ) + { + OUString FileSysPath; + ::osl::FileBase::getSystemPathFromFileURL( + FilePath, FileSysPath ); + + HANDLE hFile = CreateFileW( + FileSysPath.getStr( ), + GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL) ; + + if (hFile == INVALID_HANDLE_VALUE) + return; + + DWORD dwHighSize; + DWORD dwFileSize = GetFileSize (hFile, &dwHighSize) ; + + if (dwHighSize) + { + CloseHandle (hFile) ; + return; + } + + Sequence< sal_Int8 > aDIB( dwFileSize ); + + DWORD dwBytesRead; + BOOL bSuccess = ReadFile (hFile, aDIB.getArray( ), dwFileSize, &dwBytesRead, NULL) ; + CloseHandle (hFile); + + BITMAPFILEHEADER* pbmfh = (BITMAPFILEHEADER*)aDIB.getConstArray( ); + if (!bSuccess || (dwBytesRead != dwFileSize) + || (pbmfh->bfType != * (WORD *) "BM") + || (pbmfh->bfSize != dwFileSize)) + { + return; + } + + Any aAny; + + aAny <<= aDIB; + rXFilePreview->setImage( 1, aAny ); + } + } + } + catch( IllegalArgumentException& ex ) + { + ex = ex; + } +} + +void SAL_CALL FilePickerListener::directoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException) +{ + Reference< XFilePickerControlAccess > rFilePickerCtrlAccess( aEvent.Source, UNO_QUERY ); +} + +OUString SAL_CALL FilePickerListener::helpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException) +{ + return OUString( ); +} + +void SAL_CALL FilePickerListener::controlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException) +{ + try + { + Reference< XFilePickerControlAccess > rFPCtrlAccess( aEvent.Source, UNO_QUERY ); + + Any aValue; + + OUString lbString( L"Ein Eintrag 1" ); + aValue <<= lbString; + rFPCtrlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aValue ); + + lbString = OUString( L"Ein Eintrag 2" ); + aValue <<= lbString; + rFPCtrlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aValue ); + + lbString = OUString( L"Ein Eintrag 3" ); + aValue <<= lbString; + rFPCtrlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aValue ); + + sal_Int16 nSel = 1; + aValue <<= nSel; + rFPCtrlAccess->setValue( LISTBOX_VERSION, SET_SELECT_ITEM, aValue ); + + sal_Int32 nDel = 0; + aValue <<= nDel; + rFPCtrlAccess->setValue( LISTBOX_VERSION, DELETE_ITEM, aValue ); + } + catch( ... ) + { + } +} + +void SAL_CALL FilePickerListener::dialogSizeChanged( ) + throw(::com::sun::star::uno::RuntimeException) +{ +} + +//-------------------------------------------------------- +// main +//-------------------------------------------------------- + + +int SAL_CALL main(int nArgc, char* Argv[], char* Env[] ) +{ + printf("Starting test of FPS-Service\n"); + + //------------------------------------------------- + // get the global service-manager + //------------------------------------------------- + + // Get global factory for uno services. + OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) ); + Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) ); + + // Print a message if an error occured. + if ( g_xFactory.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory"); + return(-1); + } + + //------------------------------------------------- + // try to get an Interface to a XFilePicker Service + //------------------------------------------------- + + Sequence< Any > arguments(1); + //arguments[0] = makeAny( FILEOPEN_SIMPLE ); + //arguments[0] = makeAny( FILESAVE_SIMPLE ); + //arguments[0] = makeAny( FILESAVE_AUTOEXTENSION_PASSWORD ); + //arguments[0] = makeAny( FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS ); + //arguments[0] = makeAny( FILESAVE_AUTOEXTENSION_SELECTION ); + //arguments[0] = makeAny( FILESAVE_AUTOEXTENSION_TEMPLATE ); + //arguments[0] = makeAny( FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE ); + //arguments[0] = makeAny( FILEOPEN_PLAY ); + arguments[0] = makeAny( FILEOPEN_READONLY_VERSION ); + + Reference< XFilePicker > xFilePicker = Reference< XFilePicker >( + g_xFactory->createInstanceWithArguments( + OUString::createFromAscii( FILE_PICKER_SERVICE_NAME ), arguments ), UNO_QUERY ); + + // install a FilePicker notifier + Reference< XFilePickerListener > xFPListener( + static_cast< XFilePickerListener* >( new FilePickerListener()), UNO_QUERY ); + + Reference< XFilePickerNotifier > xFPNotifier( xFilePicker, UNO_QUERY ); + if ( xFPNotifier.is( ) ) + xFPNotifier->addFilePickerListener( xFPListener ); + + xFilePicker->setTitle( OUString::createFromAscii("FileOpen Simple...")); + xFilePicker->setMultiSelectionMode( sal_True ); + xFilePicker->setDefaultName( OUString::createFromAscii("d:\\test2.sxw")); + + OUString aDirURL; + OUString aSysPath = OStringToOUString( "d:\\üäö", osl_getThreadTextEncoding( ) ); + ::osl::FileBase::getFileURLFromSystemPath( aSysPath, aDirURL ); + xFilePicker->setDisplayDirectory( aDirURL ); + + Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY ); + if ( xFilterMgr.is( ) ) + { + xFilterMgr->appendFilter( L"Alle", L"*.*" ); + xFilterMgr->appendFilter( L"BMP", L"*.bmp" ); + xFilterMgr->appendFilter( L"SDW", L"*.sdw;*.sdc;*.sdi" ); + xFilterMgr->appendFilter( L"SXW", L"*.sxw;*.sxi" ); + } + + Reference< XFilePickerControlAccess > xFPControlAccess( xFilePicker, UNO_QUERY ); + + Any aAny; + sal_Bool bChkState = sal_False; + + aAny.setValue( &bChkState, getCppuType( (sal_Bool*)0 ) ); + xFPControlAccess->setValue( CHECKBOX_AUTOEXTENSION, 0, aAny ); + + OUString aVersion( L"Version 1" ); + aAny <<= aVersion; + xFPControlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aAny ); + xFPControlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aAny ); + xFPControlAccess->setValue( LISTBOX_VERSION, ADD_ITEM, aAny ); + + xFilePicker->execute( ); + + sal_Bool bCheckState; + aAny = xFPControlAccess->getValue( CHECKBOX_AUTOEXTENSION, 0 ); + if ( aAny.hasValue( ) ) + bCheckState = *reinterpret_cast< const sal_Bool* >( aAny.getValue( ) ); + + aAny = xFPControlAccess->getValue( CHECKBOX_READONLY, 0 ); + if ( aAny.hasValue( ) ) + bCheckState = *reinterpret_cast< const sal_Bool* >( aAny.getValue( ) ); + + aAny = xFPControlAccess->getValue( LISTBOX_VERSION, GET_SELECTED_ITEM ); + sal_Int32 nSel; + if ( aAny.hasValue( ) ) + aAny >>= nSel; + + aDirURL = xFilePicker->getDisplayDirectory( ); + Sequence< OUString > aFileList = xFilePicker->getFiles( ); + for ( int i = 0; i < aFileList.getLength( ); i++ ) + { + OUString nextPath = aFileList[i]; + } + + if ( xFPNotifier.is( ) ) + xFPNotifier->removeFilePickerListener( xFPListener ); + + //-------------------------------------------------- + // shutdown + //-------------------------------------------------- + + // Cast factory to XComponent + Reference< XComponent > xComponent( g_xFactory, UNO_QUERY ); + + // Print a message if an error occured. + if ( xComponent.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Error shuting down"); + } + + // Dispose and clear factory + xComponent->dispose(); + g_xFactory.clear(); + g_xFactory = Reference< XMultiServiceFactory >(); + + printf("Test successful\n"); + + return 0; +} diff --git a/fpicker/source/win32/filepicker/workbench/makefile.mk b/fpicker/source/win32/filepicker/workbench/makefile.mk new file mode 100644 index 000000000000..1830d159d2f5 --- /dev/null +++ b/fpicker/source/win32/filepicker/workbench/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:14:36 $ +# +# 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=sysui +TARGET=testfps +LIBTARGET=NO +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.INCLUDE : ..$/..$/..$/cppumaker.mk + +CFLAGS+=/GR /GX + +# --- Files -------------------------------------------------------- + + +OBJFILES=$(OBJ)$/test_fps.obj + +APP1TARGET=$(TARGET) +APP1OBJS=$(OBJFILES) + +APP1STDLIBS+=\ + $(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + user32.lib\ + ole32.lib + +APP1DEF=$(MISC)$/$(APP1TARGET).def + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/fpicker/source/win32/folderpicker/FOPServiceInfo.hxx b/fpicker/source/win32/folderpicker/FOPServiceInfo.hxx new file mode 100644 index 000000000000..7cf72b2f4f21 --- /dev/null +++ b/fpicker/source/win32/folderpicker/FOPServiceInfo.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * $RCSfile: FOPServiceInfo.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:44 $ + * + * 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 _FOPSERVICEINFO_HXX_ +#define _FOPSERVICEINFO_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +// the service name is a description of a set of +// interfaces (is the same as component categories in COM) + +// the service names +#define FOLDER_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.SystemFolderPicker" + +// the implementation names +#define FOLDER_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker" + +// the registry key names +// a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName" +// < Implementation-Name ></UNO/SERVICES/>< Service-Name > +#define FOLDER_PICKER_REGKEY_NAME "/com.sun.star.ui.dialogs.Win32FolderPicker/UNO/SERVICES/com.sun.star.ui.dialogs.SystemFolderPicker" + +#endif diff --git a/fpicker/source/win32/folderpicker/FolderPicker.cxx b/fpicker/source/win32/folderpicker/FolderPicker.cxx new file mode 100644 index 000000000000..fa4e8b812912 --- /dev/null +++ b/fpicker/source/win32/folderpicker/FolderPicker.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * $RCSfile: FolderPicker.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:52 $ + * + * 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 _FOLDERPICKER_HXX_ +#include "folderpicker.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +#ifndef _WINFOPIMPL_HXX_ +#include "WinFOPImpl.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::Reference; +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::XInterface; +using com::sun::star::lang::XMultiServiceFactory; +using com::sun::star::lang::XServiceInfo; +using com::sun::star::lang::DisposedException; +using com::sun::star::lang::IllegalArgumentException; +using rtl::OUString; +using osl::MutexGuard; + +using namespace cppu; +using namespace com::sun::star::ui::dialogs; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define FOLDERPICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace +{ + Sequence< OUString > SAL_CALL FolderPicker_getSupportedServiceNames() + { + Sequence< OUString > aRet(2); + aRet[0] = OUString::createFromAscii("com.sun.star.ui.dialogs.FolderPicker"); + aRet[1] = OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFolderPicker"); + return aRet; + } +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +CFolderPicker::CFolderPicker( const Reference< XMultiServiceFactory >& xServiceMgr ) : + m_xServiceMgr( xServiceMgr ) +{ + m_pFolderPickerImpl = std::auto_ptr< CWinFolderPickerImpl > ( new CWinFolderPickerImpl( this ) ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFolderPicker::setTitle( const OUString& aTitle ) throw( RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pFolderPickerImpl->setTitle( aTitle ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFolderPicker::setDisplayDirectory( const OUString& aDirectory ) + throw( IllegalArgumentException, RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pFolderPickerImpl->setDisplayDirectory( aDirectory ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFolderPicker::getDisplayDirectory( ) + throw( RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + return m_pFolderPickerImpl->getDisplayDirectory( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +OUString SAL_CALL CFolderPicker::getDirectory( ) throw( RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + return m_pFolderPickerImpl->getDirectory( ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +void SAL_CALL CFolderPicker::setDescription( const OUString& aDescription ) throw( RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + MutexGuard aGuard( m_aMutex ); + m_pFolderPickerImpl->setDescription( aDescription ); +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +sal_Int16 SAL_CALL CFolderPicker::execute( ) + throw( RuntimeException ) +{ + OSL_ASSERT( m_pFolderPickerImpl.get( ) ); + + // we should not block in this call else + // in the case of an event the client can'tgetPImplFromHandle( hWnd ) + // call another function an we run into a + // deadlock !!!!! + return m_pFolderPickerImpl->execute( ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL CFolderPicker::getImplementationName( ) + throw( RuntimeException ) +{ + return OUString::createFromAscii( FOLDERPICKER_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL CFolderPicker::supportsService( const OUString& ServiceName ) + throw( RuntimeException ) +{ + Sequence < OUString > SupportedServicesNames = FolderPicker_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + if (SupportedServicesNames[n].compareTo(ServiceName) == 0) + return sal_True; + + return sal_False; +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +Sequence< OUString > SAL_CALL CFolderPicker::getSupportedServiceNames( ) + throw( RuntimeException ) +{ + return FolderPicker_getSupportedServiceNames(); +} + +//------------------------------------------------ +// overwrite base class method, which is called +// by base class dispose function +//------------------------------------------------ + +void SAL_CALL CFolderPicker::disposing() +{ +} + diff --git a/fpicker/source/win32/folderpicker/FolderPicker.hxx b/fpicker/source/win32/folderpicker/FolderPicker.hxx new file mode 100644 index 000000000000..d63ce8f1675b --- /dev/null +++ b/fpicker/source/win32/folderpicker/FolderPicker.hxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * $RCSfile: FolderPicker.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:44 $ + * + * 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 _FOLDERPICKER_HXX_ +#define _FOLDERPICKER_HXX_ + +//--------------------------------------------------------- +// includes of other projects +//--------------------------------------------------------- + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif + +#include <memory> + +#ifndef _FPIMPLBASE_HXX_ +#include "WinFOPImpl.hxx" +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CFolderPicker : + public cppu::WeakImplHelper2< + com::sun::star::ui::dialogs::XFolderPicker, + com::sun::star::lang::XServiceInfo > +{ +public: + + // ctor/dtor + CFolderPicker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); + + //------------------------------------------------------------------------------------ + // XExecutableDialog + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL setTitle( const rtl::OUString& aTitle ) + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Int16 SAL_CALL execute( ) + throw( com::sun::star::uno::RuntimeException ); + + //------------------------------------------------------------------------------------ + // XFolderPicker functions + //------------------------------------------------------------------------------------ + + virtual void SAL_CALL setDisplayDirectory( const rtl::OUString& aDirectory ) + throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException ); + + virtual rtl::OUString SAL_CALL getDisplayDirectory( ) + throw( com::sun::star::uno::RuntimeException ); + + virtual rtl::OUString SAL_CALL getDirectory( ) + throw( com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setDescription( const rtl::OUString& aDescription ) + throw( com::sun::star::uno::RuntimeException ); + + //------------------------------------------------ + // XServiceInfo + //------------------------------------------------ + + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw(::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw(::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // overwrite base class method, which is called + // by base class dispose function + //------------------------------------------------ + + virtual void SAL_CALL disposing(); + +private: + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; + std::auto_ptr< CWinFolderPickerImpl > m_pFolderPickerImpl; + osl::Mutex m_aMutex; + +// prevent copy and assignment +private: + CFolderPicker( const CFolderPicker& ); + CFolderPicker& operator=( const CFolderPicker& ); +}; + +#endif diff --git a/fpicker/source/win32/folderpicker/FopEvtDisp.hxx b/fpicker/source/win32/folderpicker/FopEvtDisp.hxx new file mode 100644 index 000000000000..1249c3a6c386 --- /dev/null +++ b/fpicker/source/win32/folderpicker/FopEvtDisp.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * $RCSfile: FopEvtDisp.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:44 $ + * + * 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 _FOPEVENTDISPATCHER_HXX_ +#define _FOPEVENTDISPATCHER_HXX_ + +#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HPP_ +#include <com/sun/star/lang/EventObject.hpp> +#endif + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ +class CFOPEventDispatcher +{ +public: + + // dispatches a FilePickerEvent to wherever + virtual void SAL_CALL helpRequested( ::com::sun::star::lang::EventObject aEvent ) const = 0; +}; + +#endif diff --git a/fpicker/source/win32/folderpicker/Fopentry.cxx b/fpicker/source/win32/folderpicker/Fopentry.cxx new file mode 100644 index 000000000000..461d28021505 --- /dev/null +++ b/fpicker/source/win32/folderpicker/Fopentry.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: Fopentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:52 $ + * + * 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 of other projects +//----------------------------------------------------------------------- + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _FILEPICKER_HXX_ +#include "folderpicker.hxx" +#endif + +#ifndef _FPSERVICEINFO_HXX_ +#include "FOPServiceInfo.hxx" +#endif + +#ifndef _WINFOPIMPL_HXX_ +#include "WinFOPImpl.hxx" +#endif + +//----------------------------------------------------------------------- +// namespace directives +//----------------------------------------------------------------------- + +using namespace ::rtl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::container ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::registry ; +using namespace ::cppu ; +using com::sun::star::ui::dialogs::XFolderPicker; + + +namespace +{ + + //----------------------------------------------------------------------- + // + //----------------------------------------------------------------------- + + Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) + { + return Reference< XInterface >( static_cast< XFolderPicker* >( new CFolderPicker( rServiceManager ) ) ); + } +} + +//----------------------------------------------------------------------- +// the 3 important functions which will be exported +//----------------------------------------------------------------------- + +extern "C" +{ + +//---------------------------------------------------------------------- +// component_getImplementationEnvironment +//---------------------------------------------------------------------- + +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//----------------------------------------------------------------------- +// +//----------------------------------------------------------------------- + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_REGKEY_NAME ) ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE(sal_False, "InvalidRegistryException caught"); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +//---------------------------------------------------------------------- +// component_getFactory +// returns a factory to create XFilePicker-Services +//---------------------------------------------------------------------- + +void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) +{ + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FOLDER_PICKER_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) ); + + Reference< XSingleServiceFactory > xFactory ( createSingleFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx new file mode 100644 index 000000000000..902d00793732 --- /dev/null +++ b/fpicker/source/win32/folderpicker/MtaFop.cxx @@ -0,0 +1,667 @@ +/************************************************************************* + * + * $RCSfile: MtaFop.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:52 $ + * + * 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 WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES 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): _______________________________________ + * + * + ************************************************************************/ + +#pragma warning( disable : 4290 ) // c++ exception specification ignored +#pragma warning( disable : 4786 ) // identifier was truncated to 'number' + // characters in the debug information + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include "MtaFop.hxx" +#include <wchar.h> +#include <process.h> +#include <comdef.h> + +#include <systools/win32/shell9x.h> + +#ifndef _RESOURCEPROVIDER_HXX_ +#include "..\misc\resourceprovider.hxx" +#endif + +//---------------------------------------------------------------- +// namespace directives +//---------------------------------------------------------------- + +using rtl::OUString; + +//---------------------------------------------------------------- +// defines +//---------------------------------------------------------------- + +namespace +{ + char FOLDERPICKER_SRV_DLL_NAME[] = "fop.dll"; + char g_szWndClsName[] = "MtaOleReqWnd###"; +} + +//-------------------------------------------------------- +// messages constants +//-------------------------------------------------------- + +const sal_uInt32 MSG_BROWSEFORFOLDER = WM_USER + 1; +const sal_uInt32 MSG_SHUTDOWN = WM_USER + 2; + +const sal_uInt32 MAX_WAITTIME = 10000; // msec + +const sal_Bool MANUAL_RESET = sal_True; +const sal_Bool AUTO_RESET = sal_False; +const sal_Bool INIT_NONSIGNALED = sal_False; + +//---------------------------------------------------------------- +// static member initialization +//---------------------------------------------------------------- + +CMtaFolderPicker* CMtaFolderPicker::s_mtaFolderPickerInst = NULL; + +//-------------------------------------------------------------------- +// ctor +//-------------------------------------------------------------------- + +CMtaFolderPicker::CMtaFolderPicker( sal_uInt32 Flags ) : + m_hStaThread( NULL ), + m_uStaThreadId( 0 ), + m_hEvtThrdReady( NULL ), + m_hwndMtaFolderPickerReqWnd( NULL ), + m_MtaFolderPickerReqWndClassAtom( 0 ), + m_hwndFolderPicker( NULL ) +{ + ZeroMemory( &m_bi, sizeof( m_bi ) ); + + m_bi.hwndOwner = GetForegroundWindow( ); + + /* + Flag Available + -------------------------------- + BIF_EDITBOX Version 4.71 + BIF_NEWDIALOGSTYLE Version 5.0 + BIF_SHAREABLE Version 5.0 + BIF_VALIDATE Version 4.71 + + Version 4.71 - Internet Explorer 4.0 + Version 5.0 - Internet Explorer 5.0 + Windows 2000 + */ + m_bi.ulFlags = Flags; + + m_bi.lpfn = CMtaFolderPicker::folderPickerCallback; + m_bi.lParam = reinterpret_cast< LPARAM >( this ); + + //--------------------------------------- + // read the default strings for title and + // description from a resource file + + CResourceProvider ResProvider; + + m_dialogTitle = ResProvider.getResString( 500 ); + m_Description = ResProvider.getResString( 501 ); + + // signals that the thread was + // successfully set up + m_hEvtThrdReady = CreateEventA( + 0, + MANUAL_RESET, + INIT_NONSIGNALED, + NULL ); + OSL_ASSERT( NULL != m_hEvtThrdReady ); + + s_mtaFolderPickerInst = this; + + // setup the sta thread + m_hStaThread = (HANDLE)_beginthreadex( + NULL, 0, CMtaFolderPicker::oleThreadProc, this, 0, &m_uStaThreadId ); + OSL_ASSERT( NULL != m_hStaThread ); +} + +//-------------------------------------------------------------------- +// dtor +//-------------------------------------------------------------------- + +CMtaFolderPicker::~CMtaFolderPicker( ) +{ + // block calling threads out + if ( NULL != m_hEvtThrdReady ) + ResetEvent( m_hEvtThrdReady ); + + // end the thread + // because DestroyWindow can only be called + // from within the thread that created the window + SendMessageA( + m_hwndMtaFolderPickerReqWnd, + MSG_SHUTDOWN, + static_cast< WPARAM >( 0 ), + static_cast< LPARAM >( 0 ) ); + + // wait for thread shutdown + sal_uInt32 dwResult = + WaitForSingleObject( m_hStaThread, MAX_WAITTIME ); + OSL_ENSURE( dwResult == WAIT_OBJECT_0, "Sta-Thread could not terminate" ); + + // terminate the thread if it doesn't shutdown itself + if ( WAIT_OBJECT_0 != dwResult ) + TerminateThread( m_hStaThread, 0 ); + + if ( NULL != m_hStaThread ) + CloseHandle( m_hStaThread ); + + if ( NULL != m_hEvtThrdReady ) + CloseHandle( m_hEvtThrdReady ); + + if ( m_MtaFolderPickerReqWndClassAtom ) + UnregisterClassA( g_szWndClsName, NULL ); + + s_mtaFolderPickerInst = NULL; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +sal_Bool CMtaFolderPicker::browseForFolder( ) +{ + /* + if ( !WaitForThreadReady( ) ) + return sal_False; + + // marshall request into the sta thread + return static_cast< sal_Bool >( SendMessageA( + m_hwndMtaFolderPickerReqWnd, + MSG_BROWSEFORFOLDER, + 0, + 0 ) ); + */ + return onBrowseForFolder( ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::setDisplayDirectory( const OUString& aDirectory ) +{ + m_displayDir = aDirectory; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +OUString SAL_CALL CMtaFolderPicker::getDisplayDirectory( ) +{ + return m_displayDir; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +OUString SAL_CALL CMtaFolderPicker::getDirectory( ) +{ + return m_SelectedDir; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::setDescription( const rtl::OUString& aDescription ) +{ + m_Description = aDescription; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::setTitle( const OUString& aTitle ) +{ + m_dialogTitle = aTitle; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +OUString SAL_CALL CMtaFolderPicker::getTitle( ) +{ + return m_dialogTitle; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +sal_Bool SAL_CALL CMtaFolderPicker::onBrowseForFolder( ) +{ + sal_Bool bRet; + LPITEMIDLIST lpiid; + + // pre SHBrowseFroFolder + + m_bi.pidlRoot = 0; + m_bi.pszDisplayName = m_pathBuff; + + if ( m_Description.getLength( ) ) + m_bi.lpszTitle = m_Description.getStr( ); + + lpiid = SHBrowseForFolderW( &m_bi ); + bRet = ( NULL != lpiid ); + + // post SHBrowseForFolder + + m_SelectedDir = getPathFromIdList( lpiid ); + releaseItemIdList( lpiid ); + + return bRet; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::releaseItemIdList( LPITEMIDLIST lpItemIdList ) +{ + IMallocPtr pIMalloc; + SHGetMalloc( &pIMalloc ); + + try + { + pIMalloc->Free( lpItemIdList ); + lpItemIdList = NULL; + } + catch( _com_error& ) + { + OSL_ASSERT( sal_False ); + } +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +LPITEMIDLIST SAL_CALL CMtaFolderPicker::getItemIdListFromPath( const rtl::OUString& aDirectory ) +{ + // parameter checking + if ( !aDirectory.getLength( ) ) + return NULL; + + IMallocPtr pIMalloc; + SHGetMalloc( &pIMalloc ); + LPITEMIDLIST lpItemIdList = NULL; + + try + { + lpItemIdList = static_cast< LPITEMIDLIST >( + pIMalloc->Alloc( sizeof( ITEMIDLIST ) ) ); + + if ( lpItemIdList ) + { + IShellFolderPtr pIShellFolder; + SHGetDesktopFolder( &pIShellFolder ); + pIShellFolder->ParseDisplayName( + NULL, + NULL, + const_cast< sal_Unicode* >( aDirectory.getStr( ) ), + NULL, + &lpItemIdList, + NULL ); + } + } + catch( _com_error& ) + { + if ( pIMalloc ) + pIMalloc->Free( lpItemIdList ); + + lpItemIdList = NULL; + } + + return lpItemIdList; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +OUString SAL_CALL CMtaFolderPicker::getPathFromIdList( LPCITEMIDLIST lpItemIdList ) +{ + OUString path; + + if ( lpItemIdList ) + { + sal_Bool bRet = SHGetPathFromIDListW( lpItemIdList, m_pathBuff ); + if ( bRet ) + path = m_pathBuff.get( ); + } + + return path; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::enableOk( sal_Bool bEnable ) +{ + OSL_ASSERT( IsWindow( m_hwnd ) ); + + SendMessageW( + m_hwnd, + BFFM_ENABLEOK, + static_cast< WPARAM >( 0 ), + static_cast< LPARAM >( bEnable ) ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::setSelection( const rtl::OUString& aDirectory ) +{ + OSL_ASSERT( IsWindow( m_hwnd ) ); + +#pragma message( "#######################################" ) +#pragma message( "SendMessageW wrapper has to be extended" ) +#pragma message( "#######################################" ) + + SendMessageW( + m_hwnd, + BFFM_SETSELECTIONW, + static_cast< WPARAM >( sal_True ), + reinterpret_cast< LPARAM >( aDirectory.getStr( ) ) ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::setStatusText( const rtl::OUString& aStatusText ) +{ + OSL_ASSERT( IsWindow( m_hwnd ) ); + + SendMessageW( + m_hwnd, + BFFM_SETSTATUSTEXTW, + static_cast< WPARAM >( 0 ), + reinterpret_cast< LPARAM >( aStatusText.getStr( ) ) ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::onInitialized( ) +{ + LPITEMIDLIST lpiidDisplayDir = getItemIdListFromPath( m_displayDir ); + + SendMessageA( + m_hwnd, + BFFM_SETSELECTION, + (WPARAM)FALSE, + (LPARAM) lpiidDisplayDir ); + + releaseItemIdList( lpiidDisplayDir ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void SAL_CALL CMtaFolderPicker::onSelChanged( const OUString& aNewPath ) +{ + // to be overwritten by subclasses +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +sal_uInt32 SAL_CALL CMtaFolderPicker::onValidateFailed( sal_Unicode* lpInvalidPath ) +{ + // to be overwritten by subclasses + return 1; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +int CALLBACK CMtaFolderPicker::folderPickerCallback( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) +{ + CMtaFolderPicker* pImpl = reinterpret_cast< CMtaFolderPicker* >( lpData ); + OSL_ASSERT( pImpl ); + + pImpl->m_hwnd = hwnd; + + int nRC = 0; + + switch( uMsg ) + { + case BFFM_INITIALIZED: + pImpl->onInitialized( ); + SetWindowTextW( hwnd, pImpl->m_dialogTitle ); + break; + + case BFFM_SELCHANGED: + pImpl->onSelChanged( + pImpl->getPathFromIdList( + reinterpret_cast< LPITEMIDLIST >( lParam ) ) ); + break; + + case BFFM_VALIDATEFAILEDW: + nRC = pImpl->onValidateFailed( reinterpret_cast< sal_Unicode* >( lParam ) ); + break; + + default: + OSL_ASSERT( sal_False ); + } + + return nRC; +} + +//-------------------------------------------------------------------- +// the window proc +//-------------------------------------------------------------------- + +LRESULT CALLBACK CMtaFolderPicker::mtaFolderPickerReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) +{ + LRESULT lResult = 0; + + __try + { + // get a connection to the class-instance via the static member + CMtaFolderPicker* pImpl = CMtaFolderPicker::s_mtaFolderPickerInst; + OSL_ASSERT( NULL != pImpl ); + + switch( uMsg ) + { + case MSG_BROWSEFORFOLDER: + lResult = pImpl->onBrowseForFolder( ); + break; + + case MSG_SHUTDOWN: + DestroyWindow( pImpl->m_hwndMtaFolderPickerReqWnd ); + break; + + // under windows 95/98 the creation of the + // hidden target request window fails if + // we don't handle this message ourself + // because the DefWindowProc returns 0 as + // a result of handling WM_NCCREATE what + // leads to a failure of CreateWindow[Ex]!!! + case WM_NCCREATE: + lResult = TRUE; + break; + + case WM_DESTROY: + PostQuitMessage( 0 ); + break; + + default: + lResult = DefWindowProc( hWnd, uMsg, wParam, lParam ); + break; + } + } + __except( EXCEPTION_EXECUTE_HANDLER ) + { + OSL_ENSURE( sal_False, "Kernel exception in window-proc caught!" ); + } + + return lResult; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +void CMtaFolderPicker::createMtaFolderPickerReqWnd( ) +{ + WNDCLASSEXA wcex; + + HINSTANCE hInst = GetModuleHandleA( FOLDERPICKER_SRV_DLL_NAME ); + OSL_ENSURE( NULL != hInst, "The name of the FolderPicker service dll must have changed" ); + + ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) ); + + wcex.cbSize = sizeof(WNDCLASSEXA); + wcex.style = 0; + wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaFolderPicker::mtaFolderPickerReqWndProc ); + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInst; + wcex.hIcon = NULL; + wcex.hCursor = NULL; + wcex.hbrBackground = NULL; + wcex.lpszMenuName = NULL; + wcex.lpszClassName = g_szWndClsName; + wcex.hIconSm = NULL; + + m_MtaFolderPickerReqWndClassAtom = RegisterClassExA( &wcex ); + + if ( 0 != m_MtaFolderPickerReqWndClassAtom ) + m_hwndMtaFolderPickerReqWnd = CreateWindowA( + g_szWndClsName, NULL, 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +unsigned int CMtaFolderPicker::run( ) +{ + HRESULT hr = CoInitialize( NULL ); + OSL_ASSERT( SUCCEEDED( hr ) ); + + createMtaFolderPickerReqWnd( ); + + unsigned int nRet; + + if ( IsWindow( m_hwndMtaFolderPickerReqWnd ) ) + { + if ( NULL != m_hEvtThrdReady ) + SetEvent( m_hEvtThrdReady ); + + // pumping messages + MSG msg; + while( GetMessageA( &msg, NULL, 0, 0 ) ) + DispatchMessageA( &msg ); + + nRet = 0; + } + else + nRet = -1; + + CoUninitialize( ); + + return nRet; +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +unsigned int WINAPI CMtaFolderPicker::oleThreadProc( LPVOID pParam ) +{ + CMtaFolderPicker* pInst = + reinterpret_cast<CMtaFolderPicker*>( pParam ); + OSL_ASSERT( NULL != pInst ); + + return pInst->run( ); +} + +//-------------------------------------------------------------------- +// +//-------------------------------------------------------------------- + +inline +sal_Bool CMtaFolderPicker::WaitForThreadReady( ) const +{ + sal_Bool bRet = sal_False; + + if ( NULL != m_hEvtThrdReady ) + { + DWORD dwResult = WaitForSingleObject( m_hEvtThrdReady, MAX_WAITTIME ); + bRet = ( dwResult == WAIT_OBJECT_0 ); + } + + return bRet; +} + diff --git a/fpicker/source/win32/folderpicker/MtaFop.hxx b/fpicker/source/win32/folderpicker/MtaFop.hxx new file mode 100644 index 000000000000..1202169d2184 --- /dev/null +++ b/fpicker/source/win32/folderpicker/MtaFop.hxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * $RCSfile: MtaFop.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:44 $ + * + * 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 WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES 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 _MTAFOP_HXX_ +#define _MTAFOP_HXX_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#include <utility> +#include <objidl.h> +#include <shlobj.h> + +#ifndef _WINIMPLHELPER_HXX_ +#include "..\misc\WinImplHelper.hxx" +#endif + +//---------------------------------------------------------------- +// a simple helper class used to provide a buffer for different +// Win32 file and directory functions +//---------------------------------------------------------------- + +class CAutoPathBuff +{ +public: + CAutoPathBuff( size_t size = 0 ) + { + if ( !size ) + { + if ( IsWin2000( ) ) + size = 32000; // max path length under Win2000 + else + size = MAX_PATH; + } + + pBuff = new sal_Unicode[ size ]; + OSL_POSTCOND( pBuff, \ + "Could not allocate path buffer" ); + } + + ~CAutoPathBuff( ) + { + delete [] pBuff; + } + + operator sal_Unicode*( ) + { + OSL_PRECOND( pBuff, \ + "No path buffer allocated" ); + return pBuff; + } + + sal_Unicode* get( ) + { + OSL_PRECOND( pBuff, \ + "No path buffer allocated" ); + return pBuff; + } + +private: + sal_Unicode* pBuff; +}; + +//-------------------------------------------------------- +// the Mta-Ole clipboard class is for internal use only! +// only one instance of this class should be created, the +// user has to ensure this! +// the class is not thread-safe because it will be used +// only from within the clipboard service and the methods +// of the clipboard service are already synchronized +//-------------------------------------------------------- + +class CMtaFolderPicker +{ +public: + CMtaFolderPicker( sal_uInt32 Flags ); + virtual ~CMtaFolderPicker( ); + + // shell functions + sal_Bool SAL_CALL browseForFolder( ); + + virtual void SAL_CALL setDisplayDirectory( const rtl::OUString& aDirectory ); + virtual rtl::OUString SAL_CALL getDisplayDirectory( ); + virtual rtl::OUString SAL_CALL getDirectory( ); + + virtual void SAL_CALL setDescription( const rtl::OUString& aDescription ); + + virtual void SAL_CALL setTitle( const rtl::OUString& aTitle ); + rtl::OUString SAL_CALL getTitle( ); + +protected: + void SAL_CALL enableOk( sal_Bool bEnable ); + void SAL_CALL setSelection( const rtl::OUString& aDirectory ); + void SAL_CALL setStatusText( const rtl::OUString& aStatusText ); + + virtual void SAL_CALL onInitialized( ); + virtual void SAL_CALL onSelChanged( const rtl::OUString& aNewPath ); + virtual sal_uInt32 SAL_CALL onValidateFailed( sal_Unicode* lpInvalidPath ); + +private: + // helper functions + LPITEMIDLIST SAL_CALL getItemIdListFromPath( const rtl::OUString& aDirectory ); + rtl::OUString SAL_CALL getPathFromIdList( LPCITEMIDLIST lpItemIdList ); + void SAL_CALL releaseItemIdList( LPITEMIDLIST lpItemIdList ); + + unsigned int run( ); + + // create a hidden windows which serves as an request + // target; so we guarantee synchronization + void createMtaFolderPickerReqWnd( ); + + //--------------------------------------------------------------- + // message handler functions; remeber these functions are called + // from a different thread context! + //--------------------------------------------------------------- + + sal_Bool SAL_CALL onBrowseForFolder( ); + + static LRESULT CALLBACK mtaFolderPickerReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); + static unsigned int WINAPI oleThreadProc( LPVOID pParam ); + static int CALLBACK folderPickerCallback( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ); + + sal_Bool WaitForThreadReady( ) const; + +protected: + HWND m_hwnd; + static CMtaFolderPicker* s_mtaFolderPickerInst; + +private: + HANDLE m_hStaThread; + unsigned m_uStaThreadId; + HANDLE m_hEvtThrdReady; + HWND m_hwndMtaFolderPickerReqWnd; + ATOM m_MtaFolderPickerReqWndClassAtom; + HWND m_hwndFolderPicker; + rtl::OUString m_dialogTitle; + rtl::OUString m_Description; + rtl::OUString m_displayDir; + rtl::OUString m_SelectedDir; + BROWSEINFOW m_bi; + CAutoPathBuff m_pathBuff; + +// not allowed +private: + CMtaFolderPicker( const CMtaFolderPicker& ); + CMtaFolderPicker& operator=( const CMtaFolderPicker& ); + + friend LRESULT CALLBACK mtaFolderPickerReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); +}; + +#endif
\ No newline at end of file diff --git a/fpicker/source/win32/folderpicker/WinFOPImpl.cxx b/fpicker/source/win32/folderpicker/WinFOPImpl.cxx new file mode 100644 index 000000000000..c6b4019bd1f5 --- /dev/null +++ b/fpicker/source/win32/folderpicker/WinFOPImpl.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * $RCSfile: WinFOPImpl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:52 $ + * + * 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 _WINDIRBROWSEIMPL_HXX_ +#include "WinFOPImpl.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HPP_ +#include <com/sun/star/lang/EventObject.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_FILEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#endif + +#ifndef _FOPEVENTDISPATCHER_HXX_ +#include "FopEvtDisp.hxx" +#endif + +#include <systools\win32\shell9x.h> + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifndef _FOLDERPICKER_HXX_ +#include "FolderPicker.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::RuntimeException; +using com::sun::star::lang::IllegalArgumentException; +using com::sun::star::lang::EventObject; +using rtl::OUString; + +using namespace com::sun::star::ui::dialogs; +using osl::FileBase; + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +const OUString BACKSLASH = OUString::createFromAscii( "\\" ); + +//------------------------------------------------------------------------ +// ctor +//------------------------------------------------------------------------ + +CWinFolderPickerImpl::CWinFolderPickerImpl( CFolderPicker* aFolderPicker ) : + CMtaFolderPicker( BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS | BIF_EDITBOX | BIF_VALIDATE ), + m_pFolderPicker( aFolderPicker ), + m_nLastDlgResult( ::com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL ) +{ +} + +//------------------------------------------------------------------------ +// get directory in URL format, convert it to system format and set the +// member variable +// If the given URL for the directory is invalid the function throws an +// IllegalArgumentException +// If the specified path is well formed but invalid for the underlying +// OS the FolderPicker starts in the root of the file system hierarchie +//------------------------------------------------------------------------ + +void SAL_CALL CWinFolderPickerImpl::setDisplayDirectory( const OUString& aDirectory ) + throw( IllegalArgumentException, RuntimeException ) +{ + OUString sysDir; + + if( aDirectory.getLength( ) ) + { + // assuming that this function succeeds after successful execution + // of getAbsolutePath + ::osl::FileBase::RC rc = + ::osl::FileBase::getSystemPathFromFileURL( aDirectory, sysDir ); + + if ( ::osl::FileBase::E_None != rc ) + throw IllegalArgumentException( + OUString::createFromAscii( "directory is not a valid file url" ), + static_cast< XFolderPicker* >( m_pFolderPicker ), + 1 ); + + // we ensure that there is a trailing '/' at the end of + // he given file url, because the windows functions only + // works correctly when providing "c:\" or an environment + // variable like "=c:=c:\.." etc. is set, else the + // FolderPicker would stand in the root of the shell + // hierarchie which is the desktop folder + if ( sysDir.lastIndexOf( BACKSLASH ) != (sysDir.getLength( ) - 1) ) + sysDir += BACKSLASH; + } + + // call base class method + CMtaFolderPicker::setDisplayDirectory( sysDir ); +} + +//------------------------------------------------------------------------ +// we return the directory in URL format +//------------------------------------------------------------------------ + +OUString CWinFolderPickerImpl::getDisplayDirectory( ) + throw( RuntimeException ) +{ + // call base class method to get the directory in system format + OUString displayDirectory = CMtaFolderPicker::getDisplayDirectory( ); + + OUString displayDirectoryURL; + if ( displayDirectory.getLength( ) ) + ::osl::FileBase::getFileURLFromSystemPath( displayDirectory, displayDirectoryURL ); + + return displayDirectoryURL; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +OUString SAL_CALL CWinFolderPickerImpl::getDirectory( ) throw( RuntimeException ) +{ + OUString sysDir = CMtaFolderPicker::getDirectory( ); + OUString dirURL; + + if ( sysDir.getLength( ) ) + ::osl::FileBase::getFileURLFromSystemPath( sysDir, dirURL ); + + return dirURL; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Int16 SAL_CALL CWinFolderPickerImpl::execute( ) throw( RuntimeException ) +{ + return m_nLastDlgResult = CMtaFolderPicker::browseForFolder( ) ? + ::com::sun::star::ui::dialogs::ExecutableDialogResults::OK : + ::com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; +} + +//--------------------------------------------------------------------- +// +//--------------------------------------------------------------------- + +void CWinFolderPickerImpl::onSelChanged( const OUString& aNewPath ) +{ + setStatusText( aNewPath ); +} diff --git a/fpicker/source/win32/folderpicker/WinFOPImpl.hxx b/fpicker/source/win32/folderpicker/WinFOPImpl.hxx new file mode 100644 index 000000000000..8d46705c8f62 --- /dev/null +++ b/fpicker/source/win32/folderpicker/WinFOPImpl.hxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: WinFOPImpl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:15:44 $ + * + * 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 _WINFOPIMPL_HXX_ +#define _WINFOPIMPL_HXX_ + + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif + +#ifndef _MTAFOP_HXX_ +#include "MtaFop.hxx" +#endif + +//------------------------------------------------------------------------ +// forward +//------------------------------------------------------------------------ + +class CFolderPicker; + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +class CWinFolderPickerImpl : public CMtaFolderPicker +{ +public: + CWinFolderPickerImpl( CFolderPicker* aFolderPicker ); + + //----------------------------------------------------------------------------------------- + // XExecutableDialog + //----------------------------------------------------------------------------------------- + + virtual sal_Int16 SAL_CALL execute( ) + throw( com::sun::star::uno::RuntimeException ); + + //----------------------------------------------------- + // XFolderPicker + //----------------------------------------------------- + + virtual void SAL_CALL setDisplayDirectory( const rtl::OUString& aDirectory ) + throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException ); + + virtual rtl::OUString SAL_CALL getDisplayDirectory( ) + throw( com::sun::star::uno::RuntimeException ); + + virtual rtl::OUString SAL_CALL getDirectory( ) + throw( com::sun::star::uno::RuntimeException ); + +protected: + virtual void SAL_CALL onSelChanged( const rtl::OUString& aNewPath ); + +private: + CFolderPicker* m_pFolderPicker; + sal_Int16 m_nLastDlgResult; +}; + +#endif diff --git a/fpicker/source/win32/folderpicker/fop.xml b/fpicker/source/win32/folderpicker/fop.xml new file mode 100644 index 000000000000..a5e506f73954 --- /dev/null +++ b/fpicker/source/win32/folderpicker/fop.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name>fop</module-name> + <component-description> + <author> Tino Rachui </author> + <name>com.sun.star.comp.ui.dialogs.FolderPicker</name> + <description> + The win32 implementation of the FolderPicker service. +</description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language> c++ </language> + <status value="beta"/> + <supported-service> com.sun.star.ui.dialogs.FolderPicker </supported-service> + <service-dependency>...</service-dependency> + <type> com.sun.star.ui.dialogs.XExecutableDialog </type> + <type> com.sun.star.ui.dialogs.XFolderPicker </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogException </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogResults </type> + <type> com.sun.star.ui.dialogs.ExtendedFilePickerElementIds </type> + <type> com.sun.star.ui.dialogs.CommonFilePickerElementIds </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.container.XSet </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/fpicker/source/win32/folderpicker/makefile.mk b/fpicker/source/win32/folderpicker/makefile.mk new file mode 100644 index 000000000000..326ce5fca43f --- /dev/null +++ b/fpicker/source/win32/folderpicker/makefile.mk @@ -0,0 +1,89 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:16:09 $ +# +# 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=fop +#LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) +COMPRDB=$(SOLARBINDIR)$/applicat.rdb + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +.INCLUDE : ..$/..$/cppumaker.mk + +# enable rtti +CFLAGS+=/GR + +SLOFILES=$(SLO)$/fopentry.obj\ + $(SLO)$/folderpicker.obj\ + $(SLO)$/WinFopImpl.obj\ + $(SLO)$/MtaFop.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/fpicker/source/win32/folderpicker/workbench/Test_fops.cxx b/fpicker/source/win32/folderpicker/workbench/Test_fops.cxx new file mode 100644 index 000000000000..2ec94fb86e9d --- /dev/null +++ b/fpicker/source/win32/folderpicker/workbench/Test_fops.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * + * $RCSfile: Test_fops.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-06-28 11:17:00 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +//----------------------------------------------------------- +// interface includes +//----------------------------------------------------------- + +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include <com/sun/star/lang/XComponent.hpp> +#endif + +#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +//-------------------------------------------------------------- +// other includes +//-------------------------------------------------------------- + +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#include <cppuhelper/servicefactory.hxx> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _COM_SUN_STAR_UI_XFOLDERPICKER_HPP_ +#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> +#endif + +#ifndef _COM_SUN_STAR_UI_FILEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +#include <stdio.h> + +#ifndef _FPSERVICEINFO_HXX_ +#include "..\FOPServiceInfo.hxx" +#endif + +#include <osl/file.hxx> + +#define _WIN32_DCOM + +#include <windows.h> + +//-------------------------------------------------------------- +// namesapces +//-------------------------------------------------------------- + +using namespace ::rtl ; +using namespace ::cppu ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::ui::dialogs; +using namespace std ; + +//-------------------------------------------------------------- +// defines +//-------------------------------------------------------------- + +#define RDB_SYSPATH "D:\\Projects\\gsl\\sysui\\wntmsci7\\bin\\applicat.rdb" + +//-------------------------------------------------------------- +// global variables +//-------------------------------------------------------------- + +Reference< XMultiServiceFactory > g_xFactory; + +/* +void CreateDeepDirectory( ) +{ + // create a deep directory + + OUString aPathURL( L"file:///d|/Deep" ); + OUString normalizedPath; + + OSL_ASSERT( ::osl::FileBase::E_None == \ + ::osl::FileBase::getNormalizedPathFromFileURL( aPathURL, normalizedPath ) ); + + while( ::osl::FileBase::E_None == osl::Directory::create( normalizedPath ) ) + { + aPathURL += L"/Deep"; + OSL_ASSERT( ::osl::FileBase::E_None == \ + ::osl::FileBase::getNormalizedPathFromFileURL( aPathURL, normalizedPath ) ); + } + +} +*/ + +//-------------------------------------------------------------- +// main +//-------------------------------------------------------------- + + +int SAL_CALL main(int nArgc, char* Argv[], char* Env[] ) +{ + CoInitializeEx( NULL, COINIT_MULTITHREADED ); + + printf("Starting test of FolderPicker Service\n"); + + //CreateDeepDirectory( ); + + //------------------------------------------------- + // get the global service-manager + //------------------------------------------------- + + // Get global factory for uno services. + OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) ); + Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) ); + + // Print a message if an error occured. + if ( g_xFactory.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory"); + return(-1); + } + + printf("Creating RegistryServiceFactory successful\n"); + + //------------------------------------------------- + // try to get an Interface to a XFilePicker Service + //------------------------------------------------- + + Reference< XFolderPicker > xFolderPicker; + + xFolderPicker = Reference< XFolderPicker >( + g_xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM ( FOLDER_PICKER_SERVICE_NAME ) ) ), UNO_QUERY ); + + if ( xFolderPicker.is() == sal_False ) + { + OSL_ENSURE( sal_False, "Error creating FolderPicker Service" ); + return(-1); + } + + try + { + xFolderPicker->setDisplayDirectory( L"file:///C|" ); + xFolderPicker->setTitle( L"FolderBrowse Dialog" ); + xFolderPicker->execute( ); + + OUString rootDir = xFolderPicker->getDisplayDirectory( ); + OUString selectedDir = xFolderPicker->getDirectory( ); + + xFolderPicker->setDisplayDirectory( selectedDir ); + xFolderPicker->execute( ); + + rootDir = xFolderPicker->getDisplayDirectory( ); + selectedDir = xFolderPicker->getDirectory( ); + } + catch(...) + { + MessageBox( NULL, "Exception caught!", "Error", MB_OK ); + } + + //-------------------------------------------------- + // shutdown + //-------------------------------------------------- + + // Cast factory to XComponent + Reference< XComponent > xComponent( g_xFactory, UNO_QUERY ); + + // Print a message if an error occured. + if ( xComponent.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Error shuting down"); + } + + // Dispose and clear factory + xComponent->dispose(); + g_xFactory.clear(); + g_xFactory = Reference< XMultiServiceFactory >(); + + printf("Test successful\n"); + + CoUninitialize( ); + + return 0; +} diff --git a/fpicker/source/win32/folderpicker/workbench/makefile.mk b/fpicker/source/win32/folderpicker/workbench/makefile.mk new file mode 100644 index 000000000000..f1a362c9ed10 --- /dev/null +++ b/fpicker/source/win32/folderpicker/workbench/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:16:52 $ +# +# 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= sysui +TARGET= testfops +LIBTARGET= NO +TARGETTYPE= CUI + + +# --- Settings ----------------------------------------------------- +#.INCLUDE : $(PRJ)$/util$/makefile.pmk + +.INCLUDE : settings.mk + +.INCLUDE : ..$/..$/..$/cppumaker.mk + +CFLAGS+=/GR /GX + +# --- Files -------------------------------------------------------- + + +OBJFILES= $(OBJ)$/test_fops.obj + +APP1TARGET= test_fops + +APP1OBJS= $(OBJ)$/test_fops.obj + +APP1STDLIBS+= $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + user32.lib\ + ole32.lib + +APP1DEF= $(MISC)$/$(APP1TARGET).def + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + 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 diff --git a/fpicker/util/exports.dxp b/fpicker/util/exports.dxp new file mode 100644 index 000000000000..028ac4175990 --- /dev/null +++ b/fpicker/util/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/fpicker/util/makefile.mk b/fpicker/util/makefile.mk new file mode 100644 index 000000000000..f93701931ca8 --- /dev/null +++ b/fpicker/util/makefile.mk @@ -0,0 +1,151 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-06-28 11:07:32 $ +# +# 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=fpicker +TARGET1=fps +TARGET2=fop +USE_LDUMP2=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + + +# --- fps dynlib ---------------------------------------------- + +.IF "$(GUI)"=="WNT" + +SHL1TARGET=$(TARGET1) + +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + $(VCLLIB)\ + $(TOOLSLIB)\ + shell32.lib\ + ole32.lib\ + gdi32.lib\ + oleaut32.lib\ + tools32.lib\ + comdlg32.lib\ + kernel32.lib\ + comsupp.lib\ + oleaut32.lib + +SHL1DEPN= +SHL1IMPLIB=i$(SHL1TARGET) + +SHL1LIBS=$(SLB)$/fps.lib\ + $(SLB)$/utils.lib\ + $(SOLARLIBDIR)$/shell9x.lib\ + $(SOLARLIBDIR)$/user9x.lib\ + $(SOLARLIBDIR)$/kernel9x.lib\ + $(SOLARLIBDIR)$/comdlg9x.lib + +SHL1OBJS=$(SLOFILES) + +SHL1RES=$(RES)$/$(TARGET1).res +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- fop dynlib -------------------------------------------------- + +SHL2TARGET=$(TARGET2) + +SHL2STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + $(TOOLSLIB)\ + $(VCLLIB)\ + ole32.lib\ + gdi32.lib\ + shell32.lib\ + comsupp.lib\ + oleaut32.lib + +SHL2DEPN= +SHL2IMPLIB=i$(SHL2TARGET) + +SHL2LIBS=\ + $(SLB)$/fop.lib\ + $(SLB)$/utils.lib\ + $(SOLARLIBDIR)$/shell9x.lib\ + $(SOLARLIBDIR)$/user9x.lib + +SHL2OBJS=$(SLOFILES) +SHL2DEF=$(MISC)$/$(SHL2TARGET).def + +DEF2NAME=$(SHL2TARGET) +DEF2EXPORTFILE= exports.dxp + + +# "$(GUI)"=="WNT" +.ENDIF + + +.INCLUDE : target.mk + |