fpicker/Library_fps.mk | 18 fpicker/source/win32/filepicker/FPServiceInfo.hxx | 22 fpicker/source/win32/filepicker/FPentry.cxx | 20 fpicker/source/win32/filepicker/FileOpenDlg.cxx | 562 ------ fpicker/source/win32/filepicker/FileOpenDlg.hxx | 293 --- fpicker/source/win32/filepicker/FilePicker.cxx | 555 ------ fpicker/source/win32/filepicker/FilePicker.hxx | 179 -- fpicker/source/win32/filepicker/PreviewCtrl.cxx | 525 ------ fpicker/source/win32/filepicker/PreviewCtrl.hxx | 189 -- fpicker/source/win32/filepicker/VistaFilePicker.cxx | 6 fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx | 5 fpicker/source/win32/filepicker/VistaFilePickerEventHandler.hxx | 5 fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 5 fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx | 5 fpicker/source/win32/filepicker/WinFileOpenImpl.cxx | 830 ---------- fpicker/source/win32/filepicker/WinFileOpenImpl.hxx | 201 -- fpicker/source/win32/filepicker/asynceventnotifier.cxx | 261 --- fpicker/source/win32/filepicker/asynceventnotifier.hxx | 94 - fpicker/source/win32/filepicker/controlaccess.cxx | 203 -- fpicker/source/win32/filepicker/controlaccess.hxx | 66 fpicker/source/win32/filepicker/controlcommand.cxx | 219 -- fpicker/source/win32/filepicker/controlcommand.hxx | 118 - fpicker/source/win32/filepicker/controlcommandrequest.hxx | 73 fpicker/source/win32/filepicker/controlcommandresult.hxx | 92 - fpicker/source/win32/filepicker/customcontrol.cxx | 46 fpicker/source/win32/filepicker/customcontrol.hxx | 51 fpicker/source/win32/filepicker/customcontrolcontainer.cxx | 74 fpicker/source/win32/filepicker/customcontrolcontainer.hxx | 54 fpicker/source/win32/filepicker/customcontrolfactory.cxx | 71 fpicker/source/win32/filepicker/customcontrolfactory.hxx | 45 fpicker/source/win32/filepicker/dialogcustomcontrols.cxx | 154 - fpicker/source/win32/filepicker/dialogcustomcontrols.hxx | 99 - fpicker/source/win32/filepicker/dibpreview.cxx | 387 ---- fpicker/source/win32/filepicker/dibpreview.hxx | 101 - fpicker/source/win32/filepicker/eventnotification.hxx | 45 fpicker/source/win32/filepicker/filepickereventnotification.cxx | 57 fpicker/source/win32/filepicker/filepickereventnotification.hxx | 67 fpicker/source/win32/filepicker/filepickerstate.cxx | 622 ------- fpicker/source/win32/filepicker/filepickerstate.hxx | 150 - fpicker/source/win32/filepicker/getfilenamewrapper.cxx | 260 --- fpicker/source/win32/filepicker/getfilenamewrapper.hxx | 56 fpicker/source/win32/filepicker/helppopupwindow.cxx | 551 ------ fpicker/source/win32/filepicker/helppopupwindow.hxx | 133 - fpicker/source/win32/filepicker/platform_xp.h | 48 fpicker/source/win32/filepicker/previewadapter.cxx | 455 ----- fpicker/source/win32/filepicker/previewadapter.hxx | 98 - fpicker/source/win32/filepicker/previewbase.cxx | 106 - fpicker/source/win32/filepicker/previewbase.hxx | 82 fpicker/source/win32/misc/WinImplHelper.cxx | 230 -- fpicker/source/win32/misc/WinImplHelper.hxx | 40 50 files changed, 4 insertions(+), 8624 deletions(-)
New commits: commit ffbfe477b116c82e6b27bf3b39535382359bea99 Author: Michael Stahl <[email protected]> Date: Mon May 29 15:10:49 2017 +0200 fpicker: remove ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ No idea what SDK problem this once worked around but surely it's obsolete now. Change-Id: I5cfa37710ea8cecee8acc9c8f5a6a08fae4babbd diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index ebe19f3b42b8..f0481f5a756b 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -23,9 +23,6 @@ #include "VistaFilePicker.hxx" -// Without IFileDialogCustomize we can't do much -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - #include "../misc/WinImplHelper.hxx" #include "shared.hxx" @@ -531,6 +528,4 @@ css::uno::Sequence< OUString > SAL_CALL VistaFilePicker::getSupportedServiceName } // namespace win32 } // namespace fpicker -#endif // __IFileDialogCustomize_INTERFACE_DEFINED__ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx index 6233f0e17693..4817ff129170 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx @@ -20,9 +20,6 @@ #include "VistaFilePickerEventHandler.hxx" -// Without IFileDialogCustomize we can't do much -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - #include "asyncrequests.hxx" #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -328,6 +325,4 @@ void VistaFilePickerEventHandler::impl_sendEvent( EEventType eEventType, } // namespace win32 } // namespace fpicker -#endif // __IFileDialogCustomize_INTERFACE_DEFINED__ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.hxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.hxx index 103e2667299d..6a8a783dce7d 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.hxx @@ -26,9 +26,6 @@ #include <shobjidl.h> -// Without IFileDialogCustomize we can't do this -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - #include "comptr.hxx" #include "vistatypes.h" #include "IVistaFilePickerInternalNotify.hxx" @@ -198,8 +195,6 @@ class VistaFilePickerEventHandler : public ::cppu::BaseMutex } // namespace win32 } // namespace fpicker -#endif // __IFileDialogCustomize_INTERFACE_DEFINED__ - #endif // INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKEREVENTHANDLER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 0c8dc884aabf..e7a6697d4fb8 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -19,9 +19,6 @@ #include "VistaFilePickerImpl.hxx" -// Without IFileDialogCustomize we can't do much -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -1225,6 +1222,4 @@ bool VistaFilePickerImpl::onFileTypeChanged( UINT /*nTypeIndex*/ ) } // namespace win32 } // namespace fpicker -#endif // __IFileDialogCustomize_INTERFACE_DEFINED__ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx index ee3b7f4d856c..b7ea4de5fc0e 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx @@ -34,9 +34,6 @@ #pragma warning(pop) #endif -// Without IFileDialogCustomize we can't do this -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - #include "asyncrequests.hxx" #include "comptr.hxx" #include "vistatypes.h" @@ -328,8 +325,6 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex } // namespace win32 } // namespace fpicker -#endif // __IFileDialogCustomize_INTERFACE_DEFINED__ - #endif // INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 1493eef1379a457c636959f423286612849e3691 Author: Michael Stahl <[email protected]> Date: Mon May 29 15:05:58 2017 +0200 fpicker: remove some Win32 helper code that is now unused Change-Id: I5414df94487fc9918ca28b694d6f94eeeac20b70 diff --git a/fpicker/source/win32/misc/WinImplHelper.cxx b/fpicker/source/win32/misc/WinImplHelper.cxx index 105045e4e467..d31dd622a8df 100644 --- a/fpicker/source/win32/misc/WinImplHelper.cxx +++ b/fpicker/source/win32/misc/WinImplHelper.cxx @@ -77,236 +77,6 @@ bool SAL_CALL IsWindowsVistaOrNewer() #endif } -void SAL_CALL ListboxAddString( HWND hwnd, const OUString& aString ) -{ - LRESULT rc = SendMessageW( - hwnd, CB_ADDSTRING, 0, reinterpret_cast< LPARAM >(aString.getStr( )) ); - (void) rc; // avoid warning - 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++; - - std::vector<sal_Unicode> vec(lItem); - - LRESULT lRet = - SendMessageW( - hwnd, CB_GETLBTEXT, aPosition, - reinterpret_cast<LPARAM>(&vec[0])); - - OSL_ASSERT( lRet != CB_ERR ); - - if ( CB_ERR != lRet ) - aString = OUString(&vec[0], lRet); - } - - return aString; -} - -void SAL_CALL ListboxAddItem( HWND hwnd, const Any& aItem, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - if ( !aItem.hasValue( ) || - aItem.getValueType( ) != cppu::UnoType<OUString>::get() ) - throw IllegalArgumentException( - "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 ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - if ( !aItemList.hasValue( ) || - aItemList.getValueType( ) != cppu::UnoType<Sequence<OUString>>::get() ) - throw IllegalArgumentException( - "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 ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - if ( !aPosition.hasValue( ) || - ( (aPosition.getValueType( ) != cppu::UnoType<sal_Int32>::get()) && - (aPosition.getValueType( ) != cppu::UnoType<sal_Int16>::get()) && - (aPosition.getValueType( ) != cppu::UnoType<sal_Int8>::get()) ) ) - throw IllegalArgumentException( - "invalid value type or any has no value", - rXInterface, - aArgPos ); - - sal_Int32 nPos; - aPosition >>= nPos; - - LRESULT lRet = SendMessageW( hwnd, CB_DELETESTRING, nPos, 0 ); - - // if the return value is CB_ERR the given - // index was not correct - if ( CB_ERR == lRet ) - throw IllegalArgumentException( - "invalid item position", - rXInterface, - aArgPos ); -} - -void SAL_CALL ListboxDeleteItems( HWND hwnd, const Any&, const Reference< XInterface >&, sal_Int16 ) -{ - 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 ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - if ( !aPosition.hasValue( ) || - ( (aPosition.getValueType( ) != cppu::UnoType<sal_Int32>::get()) && - (aPosition.getValueType( ) != cppu::UnoType<sal_Int16>::get()) && - (aPosition.getValueType( ) != cppu::UnoType<sal_Int8>::get()) ) ) - throw IllegalArgumentException( - "invalid value type or any has no value", - rXInterface, - aArgPos ); - - sal_Int32 nPos; - aPosition >>= nPos; - - if ( nPos < -1 ) - throw IllegalArgumentException( - "invalid index", - rXInterface, - aArgPos ); - - LRESULT lRet = SendMessageW( hwnd, CB_SETCURSEL, nPos, 0 ); - - if ( (CB_ERR == lRet) && (-1 != nPos) ) - throw IllegalArgumentException( - "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 ( LRESULT i = 0; i < nItemCount; i++ ) - { - aItemList[i] = ListboxGetString( hwnd, i ); - } - } - - return Any(aItemList); -} - -Any SAL_CALL ListboxGetSelectedItem( HWND hwnd ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - LRESULT idxItem = SendMessageW( hwnd, CB_GETCURSEL, 0, 0 ); - - return Any( ListboxGetString( hwnd, idxItem ) ); -} - -Any SAL_CALL ListboxGetSelectedItemIndex( HWND hwnd ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - LRESULT idxItem = SendMessageW( hwnd, CB_GETCURSEL, 0, 0 ); - - return Any( static_cast< sal_Int32 >( idxItem ) ); -} - -Any SAL_CALL CheckboxGetState( HWND hwnd ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - LRESULT lChkState = SendMessageW( hwnd, BM_GETCHECK, 0, 0 ); - bool bChkState = (lChkState == BST_CHECKED); - return Any(bChkState); -} - -void SAL_CALL CheckboxSetState( - HWND hwnd, const css::uno::Any& aState, const Reference< XInterface >& rXInterface, sal_Int16 aArgPos ) -{ - OSL_ASSERT( IsWindow( hwnd ) ); - - if ( !aState.hasValue( ) || - aState.getValueType( ) != cppu::UnoType<sal_Bool>::get()) - throw IllegalArgumentException( - "invalid value type or any has no value", - rXInterface, - aArgPos ); - - bool bCheckState = *static_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; -} void Replace( const OUString& aLabel, sal_Unicode OldChar, sal_Unicode NewChar, OUStringBuffer& aBuffer ) { diff --git a/fpicker/source/win32/misc/WinImplHelper.hxx b/fpicker/source/win32/misc/WinImplHelper.hxx index 369e127bd48a..2e78cdaed136 100644 --- a/fpicker/source/win32/misc/WinImplHelper.hxx +++ b/fpicker/source/win32/misc/WinImplHelper.hxx @@ -36,46 +36,6 @@ bool SAL_CALL IsWindowsVistaOrNewer(); -// set actions -/// @throws css::lang::IllegalArgumentException -void SAL_CALL ListboxAddItem( - HWND hwnd, const css::uno::Any& aItem, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -/// @throws css::lang::IllegalArgumentException -void SAL_CALL ListboxAddItems( - HWND hwnd, const css::uno::Any& aItemList, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -/// @throws css::lang::IllegalArgumentException -void SAL_CALL ListboxDeleteItem( - HWND hwnd, const css::uno::Any& aPosition, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -/// @throws css::lang::IllegalArgumentException -void SAL_CALL ListboxDeleteItems( - HWND hwnd, const css::uno::Any& aUnused, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -/// @throws css::lang::IllegalArgumentException -void SAL_CALL ListboxSetSelectedItem( - HWND hwnd, const css::uno::Any& aPosition, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -// get actions -css::uno::Any SAL_CALL ListboxGetItems( HWND hwnd ); -css::uno::Any SAL_CALL ListboxGetSelectedItem( HWND hwnd ); -css::uno::Any SAL_CALL ListboxGetSelectedItemIndex( HWND hwnd ); - -// checkbox helper functions -css::uno::Any SAL_CALL CheckboxGetState( HWND hwnd ); - -/// @throws css::lang::IllegalArgumentException -void SAL_CALL CheckboxSetState( - HWND hwnd, const css::uno::Any& aState, const css::uno::Reference< css::uno::XInterface >& rXInterface, sal_Int16 aArgPos ); - -// 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 ); - - // converts a soffice label to a windows label // the following rules for character replacements // will be done: commit 99643e0d69ad2cd87a1c1e9602edf3a7fe7bd9cf Author: Michael Stahl <[email protected]> Date: Mon May 29 14:57:25 2017 +0200 fpicker: remove PreviewCtrl.[ch]xx These were apparently never used; the Windows 7 file picker can preview images nicely without this anyway. Change-Id: I0e4a1bb94506cbeae10675400a471b2211659d6e diff --git a/fpicker/Library_fps.mk b/fpicker/Library_fps.mk index c4b2c2e2d7e1..1cec714107db 100644 --- a/fpicker/Library_fps.mk +++ b/fpicker/Library_fps.mk @@ -70,6 +70,5 @@ $(eval $(call gb_Library_add_exception_objects,fps,\ fpicker/source/win32/misc/resourceprovider \ fpicker/source/win32/misc/WinImplHelper \ )) -# fpicker/source/win32/filepicker/PreviewCtrl \ # vim: set noet sw=4 ts=4: diff --git a/fpicker/source/win32/filepicker/PreviewCtrl.cxx b/fpicker/source/win32/filepicker/PreviewCtrl.cxx deleted file mode 100644 index b979b0c98029..000000000000 --- a/fpicker/source/win32/filepicker/PreviewCtrl.cxx +++ /dev/null @@ -1,525 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#include "PreviewCtrl.hxx" -#include <osl/diagnose.h> - -#if defined _MSC_VER -#pragma warning(push, 1) -#endif -#include <windows.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif -#include <ocidl.h> -#include <olectl.h> - -#define PREVIEWWND_CLASS_NAME L"PreviewWnd###" - -#define HIMETRIC_INCH 2540 - -// means 3 pixel left and 3 pixel right -#define HORZ_BORDER_SPACE 6 - -// means 3 pixel top and 3 pixel bottom -#define VERT_BORDER_SPACE 6 - -CFilePreview* CFilePreview::s_FilePreviewInst = NULL; -CFilePreview::FILEPREVIEW_SINGLETON_DESTROYER_T CFilePreview::s_SingletonDestroyer; - -namespace -{ - 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_BORDER_SPACE ) >= aPicSize.m_cx ) && - ( ( nHeightWnd - VERT_BORDER_SPACE ) >= aPicSize.m_cy ) ); - } - - // calc the dimensions 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; - } -} // unnamed 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_FAIL( "Creation of the preview window failed" ); - } - catch( CAutoOleInit::COleInitException& ) - { - OSL_ASSERT( !s_FilePreviewInst ); - OSL_FAIL( "OleInitialize 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 - WNDCLASSEX wndClsEx; - ZeroMemory(&wndClsEx, sizeof(wndClsEx)); - - wndClsEx.cbSize = sizeof(wndClsEx); - 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 automatically - // 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 = UnregisterClassW( - (PCWSTR)(DWORD_PTR)MAKELONG( m_atomPrevWndClass, 0 ), - m_hInstance ); - SAL_WARN_IF( !bRet, "fpicker", "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, sal_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 -// occurred (the file in not there or not accessible etc.) -sal_Bool SAL_CALL CFilePreview::update( const 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, sal_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 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, sal_False, &pIStream ); - - if ( SUCCEEDED( hr ) ) - { - hr = OleLoadPicture( - pIStream, fsize, sal_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 = sal_True; - break; - - default: - return DefWindowProc( hWnd, uMsg, wParam, lParam ); - } - - return lResult; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/PreviewCtrl.hxx b/fpicker/source/win32/filepicker/PreviewCtrl.hxx deleted file mode 100644 index 3ae39f6d8570..000000000000 --- a/fpicker/source/win32/filepicker/PreviewCtrl.hxx +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_PREVIEWCTRL_HXX -#define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_PREVIEWCTRL_HXX - -#include <sal/types.h> -#include <rtl/ustring.hxx> - -#include <comdef.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 - // initialization 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 -// implemented 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 - // occurred (the file in not there or not accessible etc.) - virtual sal_Bool SAL_CALL update( const 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 unique_ptr class as singleton destroyer - typedef std::unique_ptr< CFilePreview > FILEPREVIEW_SINGLETON_DESTROYER_T; - -protected: - virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC ); - - sal_Bool loadFile( const 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 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 200f02d55c806c3ae7ce054b43e66013c508062c Author: Michael Stahl <[email protected]> Date: Mon May 29 13:38:44 2017 +0200 fpicker: remove legacy XP FilePicker implementation Long live VistaFilePicker. Change-Id: I362a582a1922abad66ecfd1f5c4ce1a5a25fcd11 diff --git a/fpicker/Library_fps.mk b/fpicker/Library_fps.mk index 30c0a5af380a..c4b2c2e2d7e1 100644 --- a/fpicker/Library_fps.mk +++ b/fpicker/Library_fps.mk @@ -58,29 +58,12 @@ $(eval $(call gb_Library_add_libs,fps,\ endif $(eval $(call gb_Library_add_exception_objects,fps,\ - fpicker/source/win32/filepicker/asynceventnotifier \ fpicker/source/win32/filepicker/asyncrequests \ - fpicker/source/win32/filepicker/controlaccess \ - fpicker/source/win32/filepicker/controlcommand \ - fpicker/source/win32/filepicker/customcontrolcontainer \ - fpicker/source/win32/filepicker/customcontrol \ - fpicker/source/win32/filepicker/customcontrolfactory \ - fpicker/source/win32/filepicker/dialogcustomcontrols \ - fpicker/source/win32/filepicker/dibpreview \ - fpicker/source/win32/filepicker/FileOpenDlg \ - fpicker/source/win32/filepicker/FilePicker \ - fpicker/source/win32/filepicker/filepickereventnotification \ - fpicker/source/win32/filepicker/filepickerstate \ fpicker/source/win32/filepicker/FilterContainer \ fpicker/source/win32/filepicker/FPentry \ - fpicker/source/win32/filepicker/getfilenamewrapper \ - fpicker/source/win32/filepicker/helppopupwindow \ - fpicker/source/win32/filepicker/previewadapter \ - fpicker/source/win32/filepicker/previewbase \ fpicker/source/win32/filepicker/VistaFilePicker \ fpicker/source/win32/filepicker/VistaFilePickerEventHandler \ fpicker/source/win32/filepicker/VistaFilePickerImpl \ - fpicker/source/win32/filepicker/WinFileOpenImpl \ fpicker/source/win32/folderpicker/FolderPicker \ fpicker/source/win32/folderpicker/MtaFop \ fpicker/source/win32/folderpicker/WinFOPImpl \ diff --git a/fpicker/source/win32/filepicker/FPServiceInfo.hxx b/fpicker/source/win32/filepicker/FPServiceInfo.hxx index 9e03045a6bd3..36aadf4b1c97 100644 --- a/fpicker/source/win32/filepicker/FPServiceInfo.hxx +++ b/fpicker/source/win32/filepicker/FPServiceInfo.hxx @@ -17,31 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #ifndef INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FPSERVICEINFO_HXX #define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FPSERVICEINFO_HXX -// the service name is a description of a set of -// interfaces (is the same as component categories in COM) - -#define TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID 1001 - -#define TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID 2001 - -#define TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID 3001 - -#define TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID 4001 - -#define TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX 5001 - -#define TMPL2000_PLAY_PUSHBUTTON 6001 - -#define TMPL2000_AUTOEXT_SELECTION_BOX 7001 - -#define TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID 8001 - -#define TMPL2000_FILESAVE_AUTOEXT 9001 - // the service names #define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.SystemFilePicker" diff --git a/fpicker/source/win32/filepicker/FPentry.cxx b/fpicker/source/win32/filepicker/FPentry.cxx index 7c8af8725e71..5eaf4d00c023 100644 --- a/fpicker/source/win32/filepicker/FPentry.cxx +++ b/fpicker/source/win32/filepicker/FPentry.cxx @@ -19,7 +19,6 @@ #include <cppuhelper/factory.hxx> #include <com/sun/star/container/XSet.hpp> -#include "FilePicker.hxx" #include "FPServiceInfo.hxx" #ifdef _MSC_VER @@ -45,22 +44,11 @@ static Reference< XInterface > SAL_CALL createInstance( { Reference< XInterface > xDlg; -#ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ - bool bVistaOrNewer = IsWindowsVistaOrNewer(); + if (!IsWindowsVistaOrNewer()) + std::abort(); // not supported - if (bVistaOrNewer) - { - xDlg.set( - static_cast< XFilePicker2* >( - new ::fpicker::win32::vista::VistaFilePicker( rServiceManager ) ) ); - } - else -#endif - { - xDlg.set( - static_cast< XFilePicker2* >( - new CFilePicker( rServiceManager ) ) ); - } + xDlg.set(static_cast<XFilePicker2*>( + new ::fpicker::win32::vista::VistaFilePicker(rServiceManager))); return xDlg; } diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.cxx b/fpicker/source/win32/filepicker/FileOpenDlg.cxx deleted file mode 100644 index 8d4537c7dcc8..000000000000 --- a/fpicker/source/win32/filepicker/FileOpenDlg.cxx +++ /dev/null @@ -1,562 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> -#include "../misc/WinImplHelper.hxx" -#include "FileOpenDlg.hxx" - - -// constants - - -namespace /* private */ -{ - // 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 override 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 sal_Int32 MAX_FILENAME_BUFF_SIZE = 32000; - const sal_Int32 MAX_FILETITLE_BUFF_SIZE = 32000; - const sal_Int32 MAX_FILTER_BUFF_SIZE = 4096; - - const PCWSTR CURRENT_INSTANCE = L"CurrInst"; - - - // find an appropriate parent window - - - inline bool is_current_process_window(HWND hwnd) - { - DWORD pid; - GetWindowThreadProcessId(hwnd, &pid); - return (pid == GetCurrentProcessId()); - } - - HWND choose_parent_window() - { - HWND hwnd_parent = GetForegroundWindow(); - if (!is_current_process_window(hwnd_parent)) - hwnd_parent = GetDesktopWindow(); - - return hwnd_parent; - } -}; - - -CFileOpenDialog::CFileOpenDialog( - bool bFileOpenDialog, - sal_uInt32 dwFlags, - sal_uInt32 dwTemplateId, - HINSTANCE hInstance) : - m_hwndFileOpenDlg(nullptr), - m_hwndFileOpenDlgChild(nullptr), - m_bFileOpenDialog(bFileOpenDialog), - m_filterBuffer(MAX_FILTER_BUFF_SIZE), - m_fileTitleBuffer(MAX_FILETITLE_BUFF_SIZE), - m_helperBuffer(MAX_FILENAME_BUFF_SIZE), - m_fileNameBuffer(MAX_FILENAME_BUFF_SIZE), - m_pfnBaseDlgProc(nullptr) -{ - // initialize the OPENFILENAME struct - ZeroMemory(&m_ofn, sizeof(m_ofn)); - m_ofn.lStructSize = sizeof(m_ofn); - - // 0x02000000 for #97681, sfx will make the entry into - // the recent document list - m_ofn.Flags |= dwFlags | - OFN_EXPLORER | - OFN_ENABLEHOOK | - OFN_HIDEREADONLY | - OFN_PATHMUSTEXIST | - OFN_FILEMUSTEXIST | - OFN_OVERWRITEPROMPT | - OFN_ENABLESIZING | - OFN_DONTADDTORECENT; // 0x02000000 -> OFN_DONTADDTORECENT only available with new platform sdk - - // it is a little hack but how else could - // we get a parent window (using a vcl window?) - m_ofn.hwndOwner = choose_parent_window(); - - m_ofn.lpstrFile = reinterpret_cast<PWSTR>(const_cast<sal_Unicode*>(m_fileNameBuffer.getStr())); - m_ofn.nMaxFile = m_fileNameBuffer.getCapacity(); - - m_ofn.lpstrFileTitle = reinterpret_cast<PWSTR>(const_cast<sal_Unicode*>(m_fileTitleBuffer.getStr())); - m_ofn.nMaxFileTitle = m_fileTitleBuffer.getCapacity(); - - m_ofn.lpfnHook = CFileOpenDialog::ofnHookProc; - - // set a custom template - - if (dwTemplateId) - { - OSL_ASSERT(hInstance); - - m_ofn.Flags |= OFN_ENABLETEMPLATE; - m_ofn.lpTemplateName = MAKEINTRESOURCE(dwTemplateId); - m_ofn.hInstance = hInstance; - } - - // set a pointer to myself as ofn parameter - m_ofn.lCustData = reinterpret_cast<sal_IntPtr>(this); -} - - -CFileOpenDialog::~CFileOpenDialog() -{ -} - - -void SAL_CALL CFileOpenDialog::setTitle(const OUString& aTitle) -{ - m_dialogTitle = aTitle; - m_ofn.lpstrTitle = reinterpret_cast<PCWSTR>(m_dialogTitle.getStr()); -} - - -void CFileOpenDialog::setFilter(const OUString& aFilter) -{ - // Format is like - // "*.TXT" or multiple separate by ';' like "*.TXT;*.DOC;*.SXW" - // Do not include spaces in the pattern string - m_filterBuffer.ensureCapacity(aFilter.getLength()); - m_filterBuffer.setLength(0); - m_filterBuffer.append(aFilter); - m_ofn.lpstrFilter = reinterpret_cast<PCWSTR>(m_filterBuffer.getStr()); -} - - -bool CFileOpenDialog::setFilterIndex(sal_uInt32 aIndex) -{ - OSL_ASSERT(aIndex > 0); - m_ofn.nFilterIndex = aIndex; - return true; -} - - -sal_uInt32 CFileOpenDialog::getSelectedFilterIndex() const -{ - return m_ofn.nFilterIndex; -} - - -void SAL_CALL CFileOpenDialog::setDefaultName(const OUString& aName) -{ - m_fileNameBuffer.setLength(0); - m_fileNameBuffer.append(aName); - m_ofn.lpstrFile = reinterpret_cast<PWSTR>(const_cast<sal_Unicode*>(m_fileNameBuffer.getStr())); -} - - -void SAL_CALL CFileOpenDialog::setDisplayDirectory(const OUString& aDirectory) -{ - m_displayDirectory = aDirectory; - m_ofn.lpstrInitialDir = reinterpret_cast<PCWSTR>(m_displayDirectory.getStr()); -} - - -OUString SAL_CALL CFileOpenDialog::getLastDisplayDirectory() const -{ - return m_displayDirectory; -} - - -OUString SAL_CALL CFileOpenDialog::getFullFileName() const -{ - return OUString(m_fileNameBuffer.getStr(), - wcslenex(m_fileNameBuffer.getStr())); -} - - -OUString SAL_CALL CFileOpenDialog::getFileName() const -{ - return OUString(m_fileTitleBuffer.getStr()); -} - - -OUString CFileOpenDialog::getFileExtension() -{ - if (m_ofn.nFileExtension) - return OUString(m_fileNameBuffer.getStr() + m_ofn.nFileExtension, - rtl_ustr_getLength(m_fileNameBuffer.getStr() + m_ofn.nFileExtension)); - - return OUString(); -} - - -void CFileOpenDialog::setDefaultFileExtension(const OUString& aExtension) -{ - m_defaultExtension = aExtension; - m_ofn.lpstrDefExt = reinterpret_cast<PCWSTR>(m_defaultExtension.getStr()); -} - - -void SAL_CALL CFileOpenDialog::setMultiSelectionMode(bool bMode) -{ - if (bMode) - m_ofn.Flags |= OFN_ALLOWMULTISELECT; - else - m_ofn.Flags &= ~OFN_ALLOWMULTISELECT; -} - - -bool SAL_CALL CFileOpenDialog::getMultiSelectionMode() const -{ - return ((m_ofn.Flags & OFN_ALLOWMULTISELECT) > 0); -} - - -sal_Int16 SAL_CALL CFileOpenDialog::doModal() -{ - sal_Int16 nRC = -1; - - // pre-processing - if (preModal()) - { - bool bRet; - - if (m_bFileOpenDialog) - bRet = m_GetFileNameWrapper.getOpenFileName( - reinterpret_cast<LPOPENFILENAME>(&m_ofn)); - else - bRet = m_GetFileNameWrapper.getSaveFileName( - reinterpret_cast<LPOPENFILENAME>(&m_ofn)); - - nRC = 1; - - if (!bRet) - nRC = (0 == m_GetFileNameWrapper.commDlgExtendedError()) ? 0 : -1; - - // post-processing - postModal(nRC); - } - - return nRC; -} - - -sal_uInt32 SAL_CALL CFileOpenDialog::getLastDialogError() -{ - return CommDlgExtendedError(); -} - - -bool SAL_CALL CFileOpenDialog::preModal() -{ - return true; -} - - -void SAL_CALL CFileOpenDialog::postModal(sal_Int16 nDialogResult) -{ - OSL_ASSERT((-1 <= nDialogResult) && (nDialogResult <= 1)); - - if (1 == nDialogResult) - { - // Attention: assuming that nFileOffset is always greater 0 because under - // Windows there is always a drive letter or a server in a complete path - // the OPENFILENAME docu never says that nFileOffset can be 0 - m_displayDirectory = OUString(reinterpret_cast<const sal_Unicode*>(m_ofn.lpstrFile),m_ofn.nFileOffset); - } -} - - -OUString SAL_CALL CFileOpenDialog::getCurrentFilePath() const -{ - OSL_ASSERT(IsWindow(m_hwndFileOpenDlg)); - - LPARAM nLen = SendMessageW( - m_hwndFileOpenDlg, - CDM_GETFILEPATH, - m_helperBuffer.getCapacity(), - reinterpret_cast<LPARAM>(m_helperBuffer.getStr())); - - if (nLen > 0) - { - m_helperBuffer.setLength((nLen * sizeof(sal_Unicode)) - 1); - return OUString(m_helperBuffer.getStr()); - } - return OUString(); -} - - -OUString SAL_CALL CFileOpenDialog::getCurrentFolderPath() const -{ - OSL_ASSERT(IsWindow(m_hwndFileOpenDlg)); - - LPARAM nLen = SendMessageW( - m_hwndFileOpenDlg, - CDM_GETFOLDERPATH, - m_helperBuffer.getCapacity(), - reinterpret_cast<LPARAM>(m_helperBuffer.getStr())); - - if (nLen > 0) - { - m_helperBuffer.setLength((nLen * sizeof(sal_Unicode)) - 1); - return OUString(m_helperBuffer.getStr()); - } - return OUString(); -} - - -OUString SAL_CALL CFileOpenDialog::getCurrentFileName() const -{ - OSL_ASSERT(IsWindow(m_hwndFileOpenDlg)); - - LPARAM nLen = SendMessageW( - m_hwndFileOpenDlg, - CDM_GETSPEC, - m_helperBuffer.getCapacity(), - reinterpret_cast<LPARAM>(m_helperBuffer.getStr())); - - if (nLen > 0) - { - m_helperBuffer.setLength((nLen * sizeof(sal_Unicode)) - 1); - return OUString(m_helperBuffer.getStr()); - } - return OUString(); -} - - -sal_uInt32 SAL_CALL CFileOpenDialog::onShareViolation(const OUString&) -{ - return 0; -} - - -sal_uInt32 SAL_CALL CFileOpenDialog::onFileOk() -{ - return 0; -} - - -void SAL_CALL CFileOpenDialog::onSelChanged(HWND) -{ -} - - -void SAL_CALL CFileOpenDialog::onHelp() -{ -} - - -void SAL_CALL CFileOpenDialog::onInitDone() -{ - centerPositionToParent(); -} - - -void SAL_CALL CFileOpenDialog::onFolderChanged() -{ -} - - -void SAL_CALL CFileOpenDialog::onTypeChanged(sal_uInt32) -{ -} - - -sal_uInt32 SAL_CALL CFileOpenDialog::onCtrlCommand(HWND, sal_uInt16, sal_uInt16) -{ - return 0; -} - - -sal_uInt32 SAL_CALL CFileOpenDialog::onWMNotify( HWND, LPOFNOTIFY lpOfNotify ) -{ - switch(lpOfNotify->hdr.code) - { - case CDN_SHAREVIOLATION: - return onShareViolation(reinterpret_cast<const sal_Unicode*>(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: - m_ofn.nFilterIndex = lpOfNotify->lpOFN->nFilterIndex; - onTypeChanged(lpOfNotify->lpOFN->nFilterIndex); - break; - } - - return 0; -} - - -void SAL_CALL CFileOpenDialog::handleInitDialog(HWND hwndDlg, HWND hwndChild) -{ - m_hwndFileOpenDlg = hwndDlg; - m_hwndFileOpenDlgChild = hwndChild; - - OSL_ASSERT(GetParent(hwndChild) == hwndDlg); - - // calling virtual function which the client can override - onInitDialog(hwndDlg); -} - - -UINT_PTR CALLBACK CFileOpenDialog::ofnHookProc( - HWND hChildDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - HWND hwndDlg = GetParent(hChildDlg); - CFileOpenDialog* pImpl = nullptr; - - switch( uiMsg ) - { - case WM_INITDIALOG: - { - LPOPENFILENAME_ lpofn = reinterpret_cast<LPOPENFILENAME_>(lParam); - pImpl = reinterpret_cast<CFileOpenDialog*>(lpofn->lCustData); - OSL_ASSERT(pImpl); - - // subclass the base dialog for WM_NCDESTROY processing - pImpl->m_pfnBaseDlgProc = - reinterpret_cast<WNDPROC>( - SetWindowLongPtr( - hwndDlg, - GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(CFileOpenDialog::BaseDlgProc))); - // connect the instance handle to the window - SetPropW(hwndDlg, CURRENT_INSTANCE, pImpl); - pImpl->handleInitDialog(hwndDlg, hChildDlg); - } - return 0; - - case WM_NOTIFY: - { - pImpl = getCurrentInstance(hwndDlg); - return pImpl->onWMNotify( - hChildDlg, reinterpret_cast<LPOFNOTIFY>(lParam)); - } - - case WM_COMMAND: - { - pImpl = getCurrentInstance(hwndDlg); - OSL_ASSERT(pImpl); - - return pImpl->onCtrlCommand( - hChildDlg, LOWORD(wParam), HIWORD(lParam)); - } - } - - return 0; -} - - -LRESULT CALLBACK CFileOpenDialog::BaseDlgProc( - HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam) -{ - CFileOpenDialog* pImpl = nullptr; - - if (WM_NCDESTROY == wMessage) - { - pImpl = static_cast<CFileOpenDialog*>( - RemovePropW(hWnd,CURRENT_INSTANCE)); - - SetWindowLongPtr(hWnd, GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(pImpl->m_pfnBaseDlgProc)); - } - else - { - pImpl = getCurrentInstance(hWnd); - } - - OSL_ASSERT(pImpl); - - return CallWindowProc( - reinterpret_cast<WNDPROC>(pImpl->m_pfnBaseDlgProc), - hWnd,wMessage,wParam,lParam); -} - - -CFileOpenDialog* SAL_CALL CFileOpenDialog::getCurrentInstance(HWND hwnd) -{ - OSL_ASSERT(IsWindow( hwnd)); - return static_cast<CFileOpenDialog*>( - GetPropW(hwnd, CURRENT_INSTANCE)); -} - - -void SAL_CALL CFileOpenDialog::centerPositionToParent() const -{ - OSL_PRECOND(IsWindow(m_hwndFileOpenDlg), "no dialog window, call method only after or in onInitDone"); - - HWND hwndParent = m_ofn.hwndOwner; - - if (!IsWindow(hwndParent)) - hwndParent = GetDesktopWindow(); - - OSL_ASSERT(IsWindow(hwndParent)); - - RECT rcPar; - GetWindowRect(hwndParent, &rcPar); - - RECT rcDlg; - GetWindowRect(m_hwndFileOpenDlg, &rcDlg); - - int lDlgW = rcDlg.right - rcDlg.left; - int lDlgH = rcDlg.bottom - rcDlg.top; - - int x = (rcPar.left + rcPar.right - lDlgW) / 2; - int y = (rcPar.top + rcPar.bottom - lDlgH) / 2; - - HDC hdc = GetDC(m_hwndFileOpenDlg); - - int hResol = GetDeviceCaps(hdc, HORZRES); - int vResol = GetDeviceCaps(hdc, VERTRES); - - ReleaseDC(m_hwndFileOpenDlg, hdc); - - if (x < 0) - x = 0; - else if ((x + lDlgW) > hResol) - x = hResol - lDlgW; - - if (y < 0) - y = 0; - else if ((y + lDlgH) > vResol) - y = vResol - lDlgH; - - SetWindowPos( - m_hwndFileOpenDlg, - nullptr, x, y, 0, 0, - SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.hxx b/fpicker/source/win32/filepicker/FileOpenDlg.hxx deleted file mode 100644 index 28b01da16ce2..000000000000 --- a/fpicker/source/win32/filepicker/FileOpenDlg.hxx +++ /dev/null @@ -1,293 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FILEOPENDLG_HXX -#define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FILEOPENDLG_HXX - -#include <sal/types.h> - -#include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> - -#include "platform_xp.h" -#include "getfilenamewrapper.hxx" - -// because we don't want to import the new W2k platform sdk -// into our build environment if have stolen the definition -// for the new OPENFILENAME structure from the new headers - -typedef struct { - DWORD lStructSize; - HWND hwndOwner; - HINSTANCE hInstance; - LPCSTR lpstrFilter; - LPSTR lpstrCustomFilter; - DWORD nMaxCustFilter; - DWORD nFilterIndex; - LPSTR lpstrFile; - DWORD nMaxFile; - LPSTR lpstrFileTitle; - DWORD nMaxFileTitle; - LPCSTR lpstrInitialDir; - LPCSTR lpstrTitle; - DWORD Flags; - WORD nFileOffset; - WORD nFileExtension; - LPCSTR lpstrDefExt; - LPARAM lCustData; - LPOFNHOOKPROC lpfnHook; - LPCSTR lpTemplateName; -#ifdef _MAC - LPEDITMENU lpEditInfo; - LPCSTR lpstrPrompt; -#endif - void * pvReserved; - DWORD dwReserved; - DWORD FlagsEx; -} OPENFILENAMEA_, *LPOPENFILENAMEA_; - -typedef struct { - 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; - void * pvReserved; - DWORD dwReserved; - DWORD FlagsEx; -} OPENFILENAMEW_, *LPOPENFILENAMEW_; - -#ifdef UNICODE -typedef OPENFILENAMEW_ OPENFILENAME_; -typedef LPOPENFILENAMEW_ LPOPENFILENAME_; -#else -typedef OPENFILENAMEA_ OPENFILENAME_; -typedef LPOPENFILENAMEA_ LPOPENFILENAME_; -#endif // UNICODE - -// 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: - // ctor - // bFileOpenDialog indicates 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( - bool bFileOpenDialog = true, - sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - sal_uInt32 dwTemplateId = 0, - HINSTANCE hInstance = nullptr); - - virtual ~CFileOpenDialog(); - - virtual void SAL_CALL setTitle(const 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 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 - 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 OUString& aName); - - // set the initial directory - virtual void SAL_CALL setDisplayDirectory(const OUString& aDirectory); - - // returns only the path of the selected file - virtual OUString SAL_CALL getLastDisplayDirectory() const; - - // returns the full file name including drive letter, path - // file name and file extension - virtual OUString SAL_CALL getFullFileName() const; - - // returns the file name and the file extension without - // drive letter and path - OUString SAL_CALL getFileName() const; - - // returns the file extension of the selected file - 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 OUString& aExtension); - - // enables or disables the multiselection mode for - // the FileOpen/FileSave dialog - void SAL_CALL setMultiSelectionMode(bool bMode); - - // returns whether multi-selection mode is enabled or not - bool SAL_CALL getMultiSelectionMode() const; - - // 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 occurred - sal_Int16 SAL_CALL doModal(); - - // returns the last dialog error that occurred - static sal_uInt32 SAL_CALL getLastDialogError(); - - // retrievs the currently selected file - // including path and drive information - // can be called only if the dialog is - // already displayed - OUString SAL_CALL getCurrentFilePath() const; - - // retrievs the currently selected folder - OUString SAL_CALL getCurrentFolderPath() const; - - // retrievs the currently selected file name - // without drive and path - OUString SAL_CALL getCurrentFileName() const; - -protected: - // 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 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 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); - - virtual void SAL_CALL onInitDialog(HWND hwndDlg) = 0; - - 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 functions (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; - - OPENFILENAME_ m_ofn; - - // we connect the instance with the dialog window using - // SetProp, with this function we can reconnect from - // callback functions to this instance - static CFileOpenDialog* SAL_CALL getCurrentInstance(HWND hwnd); - - void SAL_CALL centerPositionToParent() const; - -private: - // FileOpen or FileSaveDialog - bool m_bFileOpenDialog; - OUString m_dialogTitle; - OUString m_displayDirectory; - OUString m_defaultExtension; - - mutable OUStringBuffer m_filterBuffer; - mutable OUStringBuffer m_fileTitleBuffer; - mutable OUStringBuffer m_helperBuffer; - mutable OUStringBuffer m_fileNameBuffer; - - CGetFileNameWrapper m_GetFileNameWrapper; - - WNDPROC m_pfnBaseDlgProc; - - // callback function - static UINT_PTR CALLBACK ofnHookProc( - HWND hChildDlg, // handle to child dialog box - UINT uiMsg, // message identifier - WPARAM wParam, // message parameter - LPARAM lParam // message parameter - ); - - // we have to subclass the dialog in order - // to clean up the window property we are - // using to connect the window with a class - // instance in WM_NCDESTROY - static LRESULT CALLBACK BaseDlgProc( - HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam ); - -private: - // avoid copy and assignment - CFileOpenDialog(const CFileOpenDialog&); - CFileOpenDialog& operator=(const CFileOpenDialog&); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/FilePicker.cxx b/fpicker/source/win32/filepicker/FilePicker.cxx deleted file mode 100644 index 7b60b0bb1dd6..000000000000 --- a/fpicker/source/win32/filepicker/FilePicker.cxx +++ /dev/null @@ -1,555 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#include <memory> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/supportsservice.hxx> -#include <osl/diagnose.h> - -#include "FilePicker.hxx" -#include "WinFileOpenImpl.hxx" - -#include "FPServiceInfo.hxx" -#include "../misc/WinImplHelper.hxx" -#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include "filepickereventnotification.hxx" - -#include <comphelper/sequence.hxx> - -using namespace com::sun::star; -using namespace ::com::sun::star::ui::dialogs; -using namespace ::com::sun::star::ui::dialogs::TemplateDescription; - -#define FILE_PICKER_DLL_NAME L"fps.dll" - -namespace -{ - // controlling event notifications - const bool STARTUP_SUSPENDED = true; - - uno::Sequence<OUString> SAL_CALL FilePicker_getSupportedServiceNames() - { - uno::Sequence<OUString> aRet(2); - aRet[0] = "com.sun.star.ui.dialogs.FilePicker"; - aRet[1] = "com.sun.star.ui.dialogs.SystemFilePicker"; - return aRet; - } -} - -CFilePicker::CFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) : - CFilePicker_Base(m_rbHelperMtx), - m_xServiceMgr(xServiceMgr), - m_aAsyncEventNotifier(rBHelper) -{ - HINSTANCE hInstance = GetModuleHandleW(FILE_PICKER_DLL_NAME); - SAL_WARN_IF( !hInstance, "fpicker", "The name of the service dll must have changed" ); - - // create a default FileOpen dialog without any additional ui elements - m_pImpl = std::unique_ptr< CWinFileOpenImpl >( - new CWinFileOpenImpl( - this, - true, - 0, - 0, - hInstance ) ); -} - -// XFPEventListenerManager - -void SAL_CALL CFilePicker::addFilePickerListener(const uno::Reference<XFilePickerListener>& xListener) -{ - if ( rBHelper.bDisposed ) - throw lang::DisposedException( - "object is already disposed", - static_cast< XFilePicker2* >( this ) ); - - if ( !rBHelper.bInDispose && !rBHelper.bDisposed ) - rBHelper.aLC.addInterface(cppu::UnoType<decltype(xListener)>::get(), xListener ); -} - -void SAL_CALL CFilePicker::removeFilePickerListener(const uno::Reference<XFilePickerListener>& xListener ) -{ - if ( rBHelper.bDisposed ) - throw lang::DisposedException( - "object is already disposed", - static_cast< XFilePicker2* >( this ) ); - - rBHelper.aLC.removeInterface(cppu::UnoType<decltype(xListener)>::get(), xListener ); -} - -// XEventListener - -void SAL_CALL CFilePicker::disposing(const lang::EventObject& aEvent) -{ - uno::Reference<XFilePickerListener> xFilePickerListener(aEvent.Source, css::uno::UNO_QUERY); - - if (xFilePickerListener.is()) - removeFilePickerListener(xFilePickerListener); -} - -void SAL_CALL CFilePicker::fileSelectionChanged(FilePickerEvent aEvent) -{ - aEvent.Source.set(static_cast<XFilePickerNotifier*>(this)); - m_aAsyncEventNotifier.notifyEvent( - new CFilePickerParamEventNotification(&XFilePickerListener::fileSelectionChanged,aEvent)); -} - -void SAL_CALL CFilePicker::directoryChanged(FilePickerEvent aEvent) -{ - aEvent.Source.set(static_cast<XFilePickerNotifier*>(this)); - m_aAsyncEventNotifier.notifyEvent( - new CFilePickerParamEventNotification(&XFilePickerListener::directoryChanged,aEvent)); -} - -void SAL_CALL CFilePicker::controlStateChanged(FilePickerEvent aEvent) -{ - aEvent.Source.set(static_cast<XFilePickerNotifier*>(this)); - m_aAsyncEventNotifier.notifyEvent( - new CFilePickerParamEventNotification(&XFilePickerListener::controlStateChanged,aEvent)); -} - -void SAL_CALL CFilePicker::dialogSizeChanged() -{ - m_aAsyncEventNotifier.notifyEvent( - new CFilePickerEventNotification(&XFilePickerListener::dialogSizeChanged)); -} - -// If there are more than one listener the return value of the last one wins - -OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const -{ - OUString aHelpText; - - ::cppu::OInterfaceContainerHelper* pICHelper = - rBHelper.getContainer( cppu::UnoType<XFilePickerListener>::get()); - - if (pICHelper) - { - ::cppu::OInterfaceIteratorHelper iter(*pICHelper); - - while(iter.hasMoreElements()) - { - try - { - /* - if there are multiple listeners responding - to this notification the next response - overwrites the one before if it is not empty - */ - - OUString temp; - - uno::Reference<XFilePickerListener> xFPListener(iter.next(), uno::UNO_QUERY); - if (xFPListener.is()) - { - temp = xFPListener->helpRequested(aEvent); - if (temp.getLength()) - aHelpText = temp; - } - - } - catch(uno::RuntimeException&) - { - OSL_FAIL( "RuntimeException during event dispatching" ); - } - } - } - - return aHelpText; -} - -bool CFilePicker::startupEventNotification(bool bStartupSuspended) -{ - return m_aAsyncEventNotifier.startup(bStartupSuspended); -} - -void CFilePicker::shutdownEventNotification() -{ - m_aAsyncEventNotifier.shutdown(); -} - -void CFilePicker::suspendEventNotification() -{ - m_aAsyncEventNotifier.suspend(); -} - -void CFilePicker::resumeEventNotification() -{ - m_aAsyncEventNotifier.resume(); -} - -// XFilePicker - -void SAL_CALL CFilePicker::setMultiSelectionMode(sal_Bool bMode) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setMultiSelectionMode(bMode); -} - -void SAL_CALL CFilePicker::setTitle(const OUString& aTitle) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setTitle(aTitle); -} - -void SAL_CALL CFilePicker::appendFilter(const OUString& aTitle, const OUString& aFilter) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->appendFilter(aTitle, aFilter); -} - -void SAL_CALL CFilePicker::setCurrentFilter(const OUString& aTitle) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setCurrentFilter(aTitle); -} - -OUString SAL_CALL CFilePicker::getCurrentFilter() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getCurrentFilter(); -} - -void SAL_CALL CFilePicker::appendFilterGroup(const OUString& sGroupTitle, const uno::Sequence<beans::StringPair>& aFilters) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->appendFilterGroup(sGroupTitle, aFilters); -} - -void SAL_CALL CFilePicker::setDefaultName(const OUString& aName) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setDefaultName(aName); -} - -void SAL_CALL CFilePicker::setDisplayDirectory(const OUString& aDirectory) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setDisplayDirectory(aDirectory); -} - -OUString SAL_CALL CFilePicker::getDisplayDirectory() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getDisplayDirectory(); -} - -uno::Sequence<OUString> SAL_CALL CFilePicker::getFiles() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getFiles(); -} - -uno::Sequence< OUString > SAL_CALL CFilePicker::getSelectedFiles() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - osl::MutexGuard aGuard(m_aMutex); - - const uno::Sequence< OUString > lSource = m_pImpl->getFiles(); - const ::sal_Int32 c = lSource.getLength(); - if (c < 2) - return lSource; - - const OUString sPath = lSource[0]; - ::std::vector< OUString > lTarget; - ::sal_Int32 i = 1; - for (i=1; i<c; ++i) - { - const OUString sFile = lSource[i]; - if (sFile.indexOf ('/') > 0) - { - // a) file contains own path ! - lTarget.push_back(sFile); - } - else - { - // b) file is relative to given path - OUStringBuffer sFull(256); - - sFull.append (sPath); - sFull.append("/" ); - sFull.append (sFile); - - lTarget.push_back(sFull.makeStringAndClear()); - } - } - - return comphelper::containerToSequence(lTarget); -} - -sal_Int16 SAL_CALL CFilePicker::execute() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - sal_Int16 ret; - - if (startupEventNotification(STARTUP_SUSPENDED)) - { - // we should not block in this call else - // in the case of an event the client can't - // call another function an we run into a - // deadlock !!!!! - ret = m_pImpl->execute( ); - - shutdownEventNotification(); - } - else - { - OSL_FAIL("Could not start event notifier thread!"); - - throw uno::RuntimeException( - "Error executing dialog", - static_cast<XFilePicker2*>(this)); - } - - return ret; -} - -void SAL_CALL CFilePicker::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setValue(aControlId, aControlAction, aValue); -} - -uno::Any SAL_CALL CFilePicker::getValue(sal_Int16 aControlId, sal_Int16 aControlAction) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getValue(aControlId, aControlAction); -} - -void SAL_CALL CFilePicker::enableControl(sal_Int16 aControlId, sal_Bool bEnable) -{ - OSL_ASSERT( nullptr != m_pImpl.get( ) ); - - osl::MutexGuard aGuard( m_aMutex ); - m_pImpl->enableControl( aControlId, bEnable ); -} - -void SAL_CALL CFilePicker::setLabel(sal_Int16 aControlId, const OUString& aLabel) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setLabel(aControlId, aLabel); -} - -OUString SAL_CALL CFilePicker::getLabel(sal_Int16 aControlId) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getLabel(aControlId); -} - -uno::Sequence<sal_Int16> SAL_CALL CFilePicker::getSupportedImageFormats() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getSupportedImageFormats(); -} - -sal_Int32 SAL_CALL CFilePicker::getTargetColorDepth() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getTargetColorDepth(); -} - -sal_Int32 SAL_CALL CFilePicker::getAvailableWidth() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getAvailableWidth(); -} - -sal_Int32 SAL_CALL CFilePicker::getAvailableHeight() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getAvailableHeight(); -} - -void SAL_CALL CFilePicker::setImage(sal_Int16 aImageFormat, const uno::Any& aImage) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->setImage(aImageFormat, aImage); -} - -sal_Bool SAL_CALL CFilePicker::setShowState(sal_Bool bShowState) -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->setShowState(bShowState); -} - -sal_Bool SAL_CALL CFilePicker::getShowState() -{ - OSL_ASSERT(nullptr != m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - return m_pImpl->getShowState(); -} - -void SAL_CALL CFilePicker::initialize(const uno::Sequence<uno::Any>& aArguments) -{ - // parameter checking - uno::Any aAny; - if ( 0 == aArguments.getLength( ) ) - throw lang::IllegalArgumentException( - "no arguments", - static_cast<XFilePicker2*>(this), 1); - - aAny = aArguments[0]; - - if ( (aAny.getValueType() != ::cppu::UnoType<sal_Int16>::get()) && - (aAny.getValueType() != ::cppu::UnoType<sal_Int8>::get()) ) - throw lang::IllegalArgumentException( - "invalid argument type", - static_cast<XFilePicker2*>(this), 1); - - sal_Int16 templateId = -1; - aAny >>= templateId; - - bool bFileOpenDialog = true; - sal_uInt32 winResTemplateId = 0; - - switch ( templateId ) - { - case FILEOPEN_SIMPLE: - bFileOpenDialog = true; - break; - - case FILESAVE_SIMPLE: - bFileOpenDialog = false; - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD: - bFileOpenDialog = false; - winResTemplateId = TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID; - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: - bFileOpenDialog = false; - winResTemplateId = TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX; - break; - - case FILESAVE_AUTOEXTENSION_SELECTION: - bFileOpenDialog = false; - winResTemplateId = TMPL2000_AUTOEXT_SELECTION_BOX; - break; - - case FILESAVE_AUTOEXTENSION_TEMPLATE: - bFileOpenDialog = false; - winResTemplateId = TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID; - break; - - case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: - winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID; - break; - - case FILEOPEN_PLAY: - case FILEOPEN_LINK_PLAY: //FIXME: FILEOPEN_LINK_PLAY needs an own template, no idea how to create one - winResTemplateId = TMPL2000_PLAY_PUSHBUTTON; - break; - - case FILEOPEN_READONLY_VERSION: - winResTemplateId = TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID; - break; - - case FILEOPEN_LINK_PREVIEW: - case FILEOPEN_PREVIEW: //FIXME: FILEOPEN_PREVIEW needs an own template, no idea how to create one - winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID; - break; - - case FILESAVE_AUTOEXTENSION: - bFileOpenDialog = false; - winResTemplateId = TMPL2000_FILESAVE_AUTOEXT; - break; - - default: - throw lang::IllegalArgumentException( - "Unknown template", - static_cast< XFilePicker2* >( this ), - 1 ); - } - - HINSTANCE hInstance = GetModuleHandle( FILE_PICKER_DLL_NAME ); - SAL_WARN_IF( !hInstance, "fpicker", "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::unique_ptr< CWinFileOpenImpl >( - new CWinFileOpenImpl( - this, - bFileOpenDialog, - 0, - winResTemplateId, - hInstance ) ); -} - -void SAL_CALL CFilePicker::cancel() -{ - OSL_ASSERT(m_pImpl.get()); - - osl::MutexGuard aGuard(m_aMutex); - m_pImpl->cancel(); -} - -// XServiceInfo - -OUString SAL_CALL CFilePicker::getImplementationName() -{ - return OUString(FILE_PICKER_IMPL_NAME); -} - -sal_Bool SAL_CALL CFilePicker::supportsService(const OUString& ServiceName) -{ - return cppu::supportsService(this, ServiceName); -} - -uno::Sequence<OUString> SAL_CALL CFilePicker::getSupportedServiceNames() -{ - return FilePicker_getSupportedServiceNames(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/FilePicker.hxx b/fpicker/source/win32/filepicker/FilePicker.hxx deleted file mode 100644 index 23cddeafadd0..000000000000 --- a/fpicker/source/win32/filepicker/FilePicker.hxx +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FILEPICKER_HXX -#define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FILEPICKER_HXX - -#include <cppuhelper/compbase.hxx> -#include <osl/mutex.hxx> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> -#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> -#include <com/sun/star/ui/dialogs/XFilePreview.hpp> -#include "asynceventnotifier.hxx" -#include "eventnotification.hxx" - -#include <memory> - -// Implementation class for the XFilePicker Interface - -class CWinFileOpenImpl; - -class CFilePickerDummy -{ -protected: - osl::Mutex m_aMutex; - osl::Mutex m_rbHelperMtx; -}; - -typedef ::cppu::WeakComponentImplHelper < - css::ui::dialogs::XFilePicker3, - css::ui::dialogs::XFilePickerControlAccess, - css::ui::dialogs::XFilePreview, - css::lang::XInitialization, - css::lang::XServiceInfo > CFilePicker_Base; - -class CFilePicker : - public CFilePickerDummy, - public CFilePicker_Base -{ -public: - - // ctor - explicit CFilePicker( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceMgr ); - - // XFilePickerNotifier - - virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override; - virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override; - - // XExecutableDialog functions - - virtual void SAL_CALL setTitle( const OUString& aTitle ) override; - - virtual sal_Int16 SAL_CALL execute( ) override; - - // XFilePicker functions - - virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) override; - - virtual void SAL_CALL setDefaultName( const OUString& aName ) override; - - virtual void SAL_CALL setDisplayDirectory( const OUString& aDirectory ) override; - - virtual OUString SAL_CALL getDisplayDirectory( ) override; - - virtual css::uno::Sequence< OUString > SAL_CALL getFiles( ) override; - - // XFilePicker2 functions - - virtual css::uno::Sequence< OUString > SAL_CALL getSelectedFiles( ) override; - - // XFilterManager functions - - virtual void SAL_CALL appendFilter( const OUString& aTitle, const OUString& aFilter ) override; - - virtual void SAL_CALL setCurrentFilter( const OUString& aTitle ) override; - - virtual OUString SAL_CALL getCurrentFilter( ) override; - - // XFilterGroupManager functions - - virtual void SAL_CALL appendFilterGroup( const OUString& sGroupTitle, const css::uno::Sequence< css::beans::StringPair >& aFilters ) override; - - // XFilePickerControlAccess functions - - virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const css::uno::Any& aValue ) override; - - virtual css::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) override; - - virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) override; - - virtual void SAL_CALL setLabel( sal_Int16 aControlId, const OUString& aLabel ) override; - - virtual OUString SAL_CALL getLabel( sal_Int16 aControlId ) override; - - // XFilePreview - - virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) override; - - virtual sal_Int32 SAL_CALL getTargetColorDepth( ) override; - - virtual sal_Int32 SAL_CALL getAvailableWidth( ) override; - - virtual sal_Int32 SAL_CALL getAvailableHeight( ) override; - - virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const css::uno::Any& aImage ) override; - - virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) override; - - virtual sal_Bool SAL_CALL getShowState( ) override; - - // XInitialization - - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; - - // XCancellable - - virtual void SAL_CALL cancel( ) override; - - // XEventListener - - /// @throws css::uno::RuntimeException - virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ); - - // XServiceInfo - - virtual OUString SAL_CALL getImplementationName( ) override; - - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - - // FilePicker Event functions - - void SAL_CALL fileSelectionChanged( css::ui::dialogs::FilePickerEvent aEvent ); - void SAL_CALL directoryChanged( css::ui::dialogs::FilePickerEvent aEvent ); - OUString SAL_CALL helpRequested( css::ui::dialogs::FilePickerEvent aEvent ) const; - void SAL_CALL controlStateChanged( css::ui::dialogs::FilePickerEvent aEvent ); - void SAL_CALL dialogSizeChanged( ); - - bool startupEventNotification(bool bStartupSuspended); - void shutdownEventNotification(); - void suspendEventNotification(); - void resumeEventNotification(); - -private: - // prevent copy and assignment - CFilePicker( const CFilePicker& ); - CFilePicker& operator=( const CFilePicker& ); - - using WeakComponentImplHelperBase::disposing; - -private: - css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceMgr; // to instanciate own services - CAsyncEventNotifier m_aAsyncEventNotifier; - std::unique_ptr<CWinFileOpenImpl> m_pImpl; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index 05ba2266f103..ebe19f3b42b8 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -26,7 +26,6 @@ // Without IFileDialogCustomize we can't do much #ifdef __IFileDialogCustomize_INTERFACE_DEFINED__ -#include "WinFileOpenImpl.hxx" #include "../misc/WinImplHelper.hxx" #include "shared.hxx" diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx deleted file mode 100644 index 30f20acfee94..000000000000 --- a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx +++ /dev/null @@ -1,830 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#include "shared.hxx" -#include "WinFileOpenImpl.hxx" -#include <osl/diagnose.h> -#include <osl/file.hxx> -#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> -#include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> -#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> -#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp> -#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> -#include "../misc/WinImplHelper.hxx" - -#include "FilePicker.hxx" -#include "controlaccess.hxx" -#include "customcontrolfactory.hxx" -#include <rtl/ustrbuf.hxx> -#include <rtl/string.hxx> -#include <osl/thread.hxx> -#include "filepickerstate.hxx" - -using namespace com::sun::star; - -using com::sun::star::ui::dialogs::FilePickerEvent; -using com::sun::star::lang::IllegalArgumentException; -using com::sun::star::ui::dialogs::XFilePicker2; - -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 -{ - INIT_CUSTOM_CONTROLS, - CACHE_CONTROL_VALUES -}; - -struct EnumParam -{ - ECW_ACTION_T m_action; - CWinFileOpenImpl* m_instance; - - EnumParam( ECW_ACTION_T action, CWinFileOpenImpl* instance ): - m_action( action ), - m_instance( instance ) - {} -}; - -CWinFileOpenImpl::CWinFileOpenImpl( - CFilePicker* aFilePicker, - bool bFileOpenDialog, - sal_uInt32 dwFlags, - sal_uInt32 dwTemplateId, - HINSTANCE hInstance) : - CFileOpenDialog(bFileOpenDialog, dwFlags, dwTemplateId, hInstance), - m_filterContainer(new CFilterContainer()), - m_Preview(new CPreviewAdapter(hInstance)), - m_CustomControls(CCustomControlFactory::CreateCustomControlContainer()), - m_FilePicker(aFilePicker), - m_bInitialSelChanged(true), - m_HelpPopupWindow(hInstance, m_hwndFileOpenDlg), - m_ExecuteFilePickerState(new CExecuteFilePickerState()), - m_NonExecuteFilePickerState(new CNonExecuteFilePickerState()) -{ - m_FilePickerState = m_NonExecuteFilePickerState; -} - -CWinFileOpenImpl::~CWinFileOpenImpl() -{ - delete m_ExecuteFilePickerState; - delete m_NonExecuteFilePickerState; -} - -// we expect the directory in URL format - -void CWinFileOpenImpl::setDisplayDirectory(const OUString& aDirectory) -{ - OUString aSysDirectory; - if( aDirectory.getLength() > 0) - { - if ( ::osl::FileBase::E_None != - ::osl::FileBase::getSystemPathFromFileURL(aDirectory,aSysDirectory)) - throw IllegalArgumentException( - "Invalid directory", - static_cast<XFilePicker2*>(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 - // hierarchy 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() -{ - return m_FilePickerState->getDisplayDirectory(this); -} - -void SAL_CALL CWinFileOpenImpl::setDefaultName(const OUString& aName) -{ - // 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 - -uno::Sequence<OUString> SAL_CALL CWinFileOpenImpl::getFiles() -{ - return m_FilePickerState->getFiles(this); -} - -// shows the FileOpen/FileSave dialog - -sal_Int16 SAL_CALL CWinFileOpenImpl::execute( ) -{ - sal_Int16 rc = CFileOpenDialog::doModal(); - - if (1 == rc) - rc = css::ui::dialogs::ExecutableDialogResults::OK; - else if (0 == rc) - rc = css::ui::dialogs::ExecutableDialogResults::CANCEL; - else - throw uno::RuntimeException( - "Error executing dialog", - static_cast<XFilePicker2*>(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) -{ - bool bRet = m_filterContainer->addFilter(aTitle, aFilter); - - if (!bRet) - throw IllegalArgumentException( - "filter already exists", - static_cast<XFilePicker2*>(m_FilePicker), 1); - - // #95345# see MSDN OPENFILENAME - // If nFilterIndex is zero and lpstrCustomFilter is NULL, - // the system uses the first filter in the lpstrFilter buffer. - // to reflect this we must set the filter index so that calls - // to getSelectedFilterIndex without explicitly calling - // setFilterIndex before does not return 0 which leads to a - // false state - if (0 == getSelectedFilterIndex()) - CFileOpenDialog::setFilterIndex(1); -} - -// sets a current filter - -void SAL_CALL CWinFileOpenImpl::setCurrentFilter(const OUString& aTitle) -{ - sal_Int32 filterPos = m_filterContainer->getFilterPos(aTitle); - - if (filterPos < 0) - throw IllegalArgumentException( - "filter doesn't exist", - static_cast<XFilePicker2*>(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() -{ - sal_uInt32 nIndex = getSelectedFilterIndex(); - - OUString currentFilter; - if (nIndex > 0) - { - // filter index of the base class starts with 1 - if (!m_filterContainer->getFilter(nIndex - 1, currentFilter)) { - OSL_ASSERT(false); - } - } - - return currentFilter; -} - -inline void SAL_CALL CWinFileOpenImpl::appendFilterGroupSeparator() -{ - m_filterContainer->addFilter(FILTER_SEPARATOR, ALL_FILES_WILDCARD, ALLOW_DUPLICATES); -} - -// XFilterGroupManager - -void SAL_CALL CWinFileOpenImpl::appendFilterGroup(const OUString& sGroupTitle, const uno::Sequence<beans::StringPair>& aFilters) -{ - (void) sGroupTitle; // avoid warning - OSL_ENSURE(0 == sGroupTitle.getLength(), "appendFilterGroup: Parameter 'GroupTitle' currently ignored"); - - sal_Int32 nFilters = aFilters.getLength(); - - OSL_PRECOND(nFilters > 0, "Empty filter list"); - - if (nFilters > 0) - { - // append a separator before the next group if - // there is already a group of filters - if (m_filterContainer->numFilter() > 0) - appendFilterGroupSeparator(); - - for (int i = 0; i < nFilters; i++) - appendFilter(aFilters[i].First, aFilters[i].Second); - } -} - -// XExtendedFilePicker - -// #i90917: Due to a different feature set for the system-dependent file pickers -// it's possible that generic code (e.g. sfx2) provides control ids -// (see ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR) which are NOT -// available on all platforms. This filter function should filter out control ids -// which are only available on KDE/GTK file pickers. -static bool filterControlCommand( sal_Int16 nControlId ) -{ - if ( nControlId == LISTBOX_FILTER_SELECTOR ) - return true; - return false; -} - -void SAL_CALL CWinFileOpenImpl::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) -{ - OSL_ASSERT(m_FilePickerState); - if ( !filterControlCommand( aControlId )) - m_FilePickerState->setValue(aControlId, aControlAction, aValue); -} - -// returns the value of an custom template element -// we assume that there are only checkboxes or comboboxes - -uno::Any SAL_CALL CWinFileOpenImpl::getValue(sal_Int16 aControlId, sal_Int16 aControlAction) -{ - OSL_ASSERT(m_FilePickerState); - if ( !filterControlCommand( aControlId )) - return m_FilePickerState->getValue(aControlId, aControlAction); - else - return uno::Any(); -} - -// enables a custom template element - ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
