diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-21 14:20:12 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-29 13:58:47 +0100 |
commit | 09e3d45cdc5c739e5246388a83ccfc6d76bf66e9 (patch) | |
tree | 5ae533f38a626016951b02e7d2406c368b298723 /fpicker/source/office/iodlg.cxx | |
parent | 93a641d291adf86491cc68ac64f4f614c937183a (diff) |
weld fpicker cluster
Change-Id: I6566263809ff0032388a0b56571f0cf7428058d7
Reviewed-on: https://gerrit.libreoffice.org/81334
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'fpicker/source/office/iodlg.cxx')
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 1568 |
1 files changed, 571 insertions, 997 deletions
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index de406c908780..61e5b2ce0d55 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -28,8 +28,8 @@ #include <fpsofficeResMgr.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> -#include <vcl/errinf.hxx> -#include <vcl/event.hxx> +#include <vcl/graph.hxx> +#include <vcl/layout.hxx> #include <vcl/lstbox.hxx> #include <vcl/svapp.hxx> #include <vcl/timer.hxx> @@ -95,20 +95,14 @@ using namespace ExtendedFilePickerElementIds; using namespace CommonFilePickerElementIds; using namespace InternalFilePickerElementIds; -// Time to wait while traveling in the filterbox until -// the browsebox gets filtered ( in ms). -#define TRAVELFILTER_TIMEOUT 750 - // functions ------------------------------------------------------------- namespace { - - OUString getMostCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl> const & pImpl ) { assert( pImpl && "invalid impl pointer" ); - const SvtFileDialogFilter_Impl* pFilter = pImpl->_pUserFilter.get(); + const SvtFileDialogFilter_Impl* pFilter = pImpl->m_xUserFilter.get(); if ( !pFilter ) pFilter = pImpl->GetCurFilter(); @@ -119,7 +113,6 @@ namespace return pFilter->GetType(); } - bool restoreCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl> const & pImpl ) { SAL_WARN_IF( !pImpl->GetCurFilter(), "fpicker.office", "restoreCurrentFilter: no current filter!" ); @@ -283,360 +276,113 @@ namespace } // SvtFileDialog - -SvtFileDialog::SvtFileDialog -( - vcl::Window* _pParent, - PickerFlags nBits -) : - SvtFileDialog_Base( _pParent, "ExplorerFileDialog", "fps/ui/explorerfiledialog.ui" ) - - ,_pCbReadOnly( nullptr ) - ,_pCbLinkBox( nullptr) - ,_pCbPreviewBox( nullptr ) - ,_pCbSelection( nullptr ) - ,_pPbPlay( nullptr ) - ,_pPrevWin( nullptr ) - ,_pPrevBmp( nullptr ) - ,_pFileView( nullptr ) - ,_pFileNotifier( nullptr ) - ,pImpl( new SvtExpFileDlg_Impl ) - ,_nPickerFlags( nBits ) - ,_bIsInExecute( false ) - ,m_bInExecuteAsync( false ) - ,m_bHasFilename( false ) - ,m_context(comphelper::getProcessComponentContext()) -{ - Init_Impl( nBits ); -} - - -class CustomContainer : public vcl::Window -{ - enum FocusState - { - Prev = 0, - Places, - Add, - Delete, - FileView, - Next, - FocusCount - }; - - SvtExpFileDlg_Impl* pImpl; - VclPtr<SvtFileView> _pFileView; - VclPtr<Splitter> _pSplitter; - - int m_nCurrentFocus; - VclPtr<vcl::Window> m_pFocusWidgets[FocusState::FocusCount]; - -public: - explicit CustomContainer(vcl::Window *pParent) - : Window(pParent) - , pImpl(nullptr) - , _pFileView(nullptr) - , _pSplitter(nullptr) - , m_nCurrentFocus(FocusState::Prev) - { - } - virtual ~CustomContainer() override { disposeOnce(); } - virtual void dispose() override - { - _pFileView.clear(); - _pSplitter.clear(); - vcl::Window::dispose(); - } - - void init(SvtExpFileDlg_Impl* pImp, - SvtFileView* pFileView, - Splitter* pSplitter, - vcl::Window* pPrev, - vcl::Window* pNext) - { - pImpl = pImp; - _pFileView = pFileView; - _pSplitter = pSplitter; - - m_pFocusWidgets[FocusState::Prev] = pPrev; - m_pFocusWidgets[FocusState::Places] = pImpl->_pPlaces->GetPlacesListBox(); - m_pFocusWidgets[FocusState::Add] = pImpl->_pPlaces->GetAddButton(); - m_pFocusWidgets[FocusState::Delete] = pImpl->_pPlaces->GetDeleteButton(); - m_pFocusWidgets[FocusState::FileView] = pFileView; - m_pFocusWidgets[FocusState::Next] = pNext; - } - - virtual void Resize() override - { - Window::Resize(); - - if (!pImpl || !pImpl->_pPlaces) - return; - - Size aSize = GetSizePixel(); - - Point aBoxPos(_pFileView->GetPosPixel()); - Size aNewSize(aSize.Width() - aBoxPos.X(), aSize.Height()); - _pFileView->SetSizePixel( aNewSize ); - - // Resize the Splitter to fit the height - Size splitterNewSize = _pSplitter->GetSizePixel( ); - splitterNewSize.setHeight( aSize.Height() ); - _pSplitter->SetSizePixel( splitterNewSize ); - sal_Int32 nMinX = pImpl->_pPlaces->GetPosPixel( ).X( ); - sal_Int32 nMaxX = _pFileView->GetPosPixel( ).X( ) + _pFileView->GetSizePixel( ).Width() - nMinX; - _pSplitter->SetDragRectPixel( tools::Rectangle( Point( nMinX, 0 ), Size( nMaxX, aSize.Width() ) ) ); - - // Resize the places list box to fit the height of the FileView - Size placesNewSize(pImpl->_pPlaces->GetSizePixel()); - placesNewSize.setHeight( aSize.Height() ); - pImpl->_pPlaces->SetSizePixel( placesNewSize ); - } - - void changeFocus( bool bReverse ) - { - if( !_pFileView || !pImpl || !pImpl->_pPlaces ) - return; - - if( bReverse && m_nCurrentFocus > FocusState::Prev && m_nCurrentFocus <= FocusState::Next ) - { - m_pFocusWidgets[m_nCurrentFocus]->SetFakeFocus(false); - m_pFocusWidgets[m_nCurrentFocus]->LoseFocus(); - - m_pFocusWidgets[--m_nCurrentFocus]->SetFakeFocus( true ); - m_pFocusWidgets[m_nCurrentFocus]->GrabFocus(); - } - else if( !bReverse && m_nCurrentFocus >= FocusState::Prev && m_nCurrentFocus < FocusState::Next ) - { - m_pFocusWidgets[m_nCurrentFocus]->SetFakeFocus(false); - m_pFocusWidgets[m_nCurrentFocus]->LoseFocus(); - - m_pFocusWidgets[++m_nCurrentFocus]->SetFakeFocus( true ); - m_pFocusWidgets[m_nCurrentFocus]->GrabFocus(); - } - } - - virtual void GetFocus() override - { - if( !_pFileView || !pImpl || !pImpl->_pPlaces ) - return; - - GetFocusFlags aFlags = GetGetFocusFlags(); - - if( aFlags & GetFocusFlags::Forward ) - m_nCurrentFocus = FocusState::Places; - else if( aFlags & GetFocusFlags::Backward ) - m_nCurrentFocus = FocusState::FileView; - - if( m_nCurrentFocus >= FocusState::Prev && m_nCurrentFocus <= FocusState::Next ) - { - m_pFocusWidgets[m_nCurrentFocus]->SetFakeFocus( true ); - m_pFocusWidgets[m_nCurrentFocus]->GrabFocus(); - } - } - - virtual bool EventNotify( NotifyEvent& rNEvt ) override - { - if( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS ) - { - // we must also update counter when user change focus using mouse - for(int i = FocusState::Prev; i <= FocusState::Next; i++) - { - if( rNEvt.GetWindow() == m_pFocusWidgets[i] ) - { - m_nCurrentFocus = i; - return true; - } - } - - // GETFOCUS for one of FileView's subcontrols - m_nCurrentFocus = FocusState::FileView; - return true; - } - if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); - const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode(); - bool bShift = rCode.IsShift(); - if( rCode.GetCode() == KEY_TAB ) - { - changeFocus( bShift ); - return true; - } - } - return Window::EventNotify(rNEvt); - } -}; - -SvtFileDialog::~SvtFileDialog() -{ - disposeOnce(); -} - -void SvtFileDialog::dispose() -{ - if ( !pImpl->_aIniKey.isEmpty() ) - { - // save window state - SvtViewOptions aDlgOpt( EViewType::Dialog, pImpl->_aIniKey ); - aDlgOpt.SetWindowState(OStringToOUString(GetWindowState(), osl_getThreadTextEncoding())); - OUString sUserData = _pFileView->GetConfigString(); - aDlgOpt.SetUserItem( "UserData", - makeAny( sUserData ) ); - } - - _pFileView->SetSelectHdl( Link<SvTreeListBox*,void>() ); - - // Save bookmarked places - if(pImpl->_pPlaces->IsUpdated()) { - const std::vector<PlacePtr> aPlaces = pImpl->_pPlaces->GetPlaces(); - Sequence< OUString > placesUrlsList(pImpl->_pPlaces->GetNbEditablePlaces()); - Sequence< OUString > placesNamesList(pImpl->_pPlaces->GetNbEditablePlaces()); - int i(0); - for (auto const& place : aPlaces) - { - if(place->IsEditable()) { - placesUrlsList[i] = place->GetUrl(); - placesNamesList[i] = place->GetName(); - ++i; - } - } - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); - officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch); - officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch); - batch->commit(); - } - - _pFileView.disposeAndClear(); - pImpl.reset(); - _pSplitter.disposeAndClear(); - _pContainer.disposeAndClear(); - _pPrevBmp.disposeAndClear(); - _pCbReadOnly.clear(); - _pCbLinkBox.clear(); - _pCbPreviewBox.clear(); - _pCbSelection.clear(); - _pPbPlay.clear(); - _pPrevWin.clear(); - m_aDisabledControls.clear(); - Dialog::dispose(); -} - -void SvtFileDialog::Init_Impl -( - PickerFlags nStyle -) -{ - get(_pCbReadOnly, "readonly"); - get(_pCbLinkBox, "link"); - get(_pCbPreviewBox, "cb_preview"); - get(_pCbSelection, "selection"); - get(_pPrevWin, "preview"); - get(_pPbPlay, "play"); - get(pImpl->_pCbOptions, "options"); - get(pImpl->_pFtFileName, "file_name_label"); - get(pImpl->_pEdFileName, "file_name"); - pImpl->_pEdFileName->GetFocus(); - get(pImpl->_pFtFileType, "file_type_label"); - get(pImpl->_pLbFilter, "file_type"); - get(pImpl->_pEdCurrentPath, "current_path"); - get(pImpl->_pBtnFileOpen, "open"); - get(pImpl->_pBtnCancel, "cancel"); - get(pImpl->_pBtnHelp, "help"); - get(pImpl->_pBtnConnectToServer, "connect_to_server"); - get(pImpl->_pBtnNewFolder, "new_folder"); - get(pImpl->_pCbPassword, "password"); - get(pImpl->_pCbGPGEncrypt, "gpgencrypt"); - get(pImpl->_pCbAutoExtension, "extension"); - get(pImpl->_pFtFileVersion, "shared_label"); - get(pImpl->_pLbFileVersion, "shared"); - get(pImpl->_pFtTemplates, "shared_label"); - get(pImpl->_pLbTemplates, "shared"); - get(pImpl->_pFtImageTemplates, "shared_label"); - get(pImpl->_pLbImageTemplates, "shared"); - get(pImpl->_pFtImageAnchor, "shared_label"); - get(pImpl->_pLbImageAnchor, "shared"); - - pImpl->_pLbImageTemplates->setMaxWidthChars(40); - pImpl->_pLbFilter->setMaxWidthChars(40); - - vcl::Window *pUpContainer = get<vcl::Window>("up"); - pImpl->_pBtnUp = VclPtr<SvtUpButton_Impl>::Create(pUpContainer, this, 0); - pImpl->_pBtnUp->SetHelpId( HID_FILEOPEN_LEVELUP ); - pImpl->_pBtnUp->set_vexpand(true); - pImpl->_pBtnUp->Show(); - - pImpl->_nStyle = nStyle; - pImpl->_eMode = ( nStyle & PickerFlags::SaveAs ) ? FILEDLG_MODE_SAVE : FILEDLG_MODE_OPEN; - pImpl->_eDlgType = FILEDLG_TYPE_FILEDLG; - - if ( nStyle & PickerFlags::PathDialog ) - pImpl->_eDlgType = FILEDLG_TYPE_PATHDLG; +SvtFileDialog::SvtFileDialog(weld::Window* pParent, PickerFlags nStyle) + : SvtFileDialog_Base(pParent, "fps/ui/explorerfiledialog.ui", "ExplorerFileDialog") + , m_xCbReadOnly(m_xBuilder->weld_check_button("readonly")) + , m_xCbLinkBox(m_xBuilder->weld_check_button("link")) + , m_xCbPreviewBox(m_xBuilder->weld_check_button("cb_preview")) + , m_xCbSelection(m_xBuilder->weld_check_button("selection")) + , m_xPbPlay(m_xBuilder->weld_button("play")) + , m_xPreviewFrame(m_xBuilder->weld_widget("previewframe")) + , m_xPrevBmp(m_xBuilder->weld_image("preview")) + , m_pFileNotifier(nullptr) + , m_xImpl(new SvtExpFileDlg_Impl) + , m_nPickerFlags(nStyle) + , m_bIsInExecute(false) + , m_bInExecuteAsync(false) + , m_bHasFilename(false) + , m_xContext(comphelper::getProcessComponentContext()) +{ + m_xImpl->m_xCbOptions = m_xBuilder->weld_check_button("options"); + m_xImpl->m_xFtFileName = m_xBuilder->weld_label("file_name_label"); + m_xImpl->m_xEdFileName.reset(new URLBox(m_xBuilder->weld_combo_box("file_name"))); + m_xImpl->m_xFtFileType = m_xBuilder->weld_label("file_type_label"); + m_xImpl->m_xLbFilter = m_xBuilder->weld_combo_box("file_type"); + m_xImpl->m_xEdCurrentPath.reset(new URLBox(m_xBuilder->weld_combo_box("current_path"))); + m_xImpl->m_xBtnFileOpen = m_xBuilder->weld_button("open"); + m_xImpl->m_xBtnCancel = m_xBuilder->weld_button("cancel"); + m_xImpl->m_xBtnHelp = m_xBuilder->weld_button("help"); + m_xImpl->m_xBtnConnectToServer = m_xBuilder->weld_button("connect_to_server"); + m_xImpl->m_xBtnNewFolder = m_xBuilder->weld_button("new_folder"); + m_xImpl->m_xCbPassword = m_xBuilder->weld_check_button("password"); + m_xImpl->m_xCbGPGEncrypt = m_xBuilder->weld_check_button("gpgencrypt"); + m_xImpl->m_xCbAutoExtension = m_xBuilder->weld_check_button("extension"); + m_xImpl->m_xFtFileVersion = m_xBuilder->weld_label("shared_label"); + m_xImpl->m_xLbFileVersion = m_xBuilder->weld_combo_box("shared"); + m_xImpl->m_xFtTemplates = m_xBuilder->weld_label("shared_label"); + m_xImpl->m_xLbTemplates = m_xBuilder->weld_combo_box("shared"); + m_xImpl->m_xFtImageTemplates = m_xBuilder->weld_label("shared_label"); + m_xImpl->m_xLbImageTemplates = m_xBuilder->weld_combo_box("shared"); + m_xImpl->m_xFtImageAnchor = m_xBuilder->weld_label("shared_label"); + m_xImpl->m_xLbImageAnchor = m_xBuilder->weld_combo_box("shared"); + + // because the "<All Formats> (*.bmp,*...)" entry is too wide, + // we need to disable the auto width feature of the filter box + int nWidth = m_xImpl->m_xLbFilter->get_approximate_digit_width() * 60; + m_xImpl->m_xLbImageTemplates->set_size_request(nWidth, -1); + m_xImpl->m_xLbFilter->set_size_request(nWidth, -1); + + m_xImpl->m_xBtnUp.reset(new SvtUpButton_Impl(m_xBuilder->weld_toolbar("up_bar"), + m_xBuilder->weld_menu("up_menu"), + this)); + m_xImpl->m_xBtnUp->set_help_id(HID_FILEOPEN_LEVELUP); + m_xImpl->m_xBtnUp->show(); + + m_xImpl->m_nStyle = nStyle; + m_xImpl->m_eMode = ( nStyle & PickerFlags::SaveAs ) ? FILEDLG_MODE_SAVE : FILEDLG_MODE_OPEN; + m_xImpl->m_eDlgType = FILEDLG_TYPE_FILEDLG; + + if (nStyle & PickerFlags::PathDialog) + m_xImpl->m_eDlgType = FILEDLG_TYPE_PATHDLG; // Set the directory for the "back to the default dir" button INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); SetStandardDir( aStdDirObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); // Create control element, the order defines the tab control. - pImpl->_pEdFileName->SetSelectHdl( LINK( this, SvtFileDialog, EntrySelectHdl_Impl ) ); - pImpl->_pEdFileName->SetOpenHdl( LINK( this, SvtFileDialog, OpenUrlHdl_Impl ) ); + m_xImpl->m_xEdFileName->connect_changed( LINK( this, SvtFileDialog, EntrySelectHdl_Impl ) ); + m_xImpl->m_xEdFileName->connect_entry_activate( LINK( this, SvtFileDialog, OpenUrlHdl_Impl ) ); // in folder picker mode, only auto-complete directories (no files) - bool bIsFolderPicker = ( pImpl->_eDlgType == FILEDLG_TYPE_PATHDLG ); - pImpl->_pEdFileName->SetOnlyDirectories( bIsFolderPicker ); + bool bIsFolderPicker = m_xImpl->m_eDlgType == FILEDLG_TYPE_PATHDLG; + m_xImpl->m_xEdFileName->SetOnlyDirectories( bIsFolderPicker ); // in save mode, don't use the autocompletion as selection in the edit part - bool bSaveMode = ( FILEDLG_MODE_SAVE == pImpl->_eMode ); - pImpl->_pEdFileName->SetNoURLSelection( bSaveMode ); + bool bSaveMode = FILEDLG_MODE_SAVE == m_xImpl->m_eMode; + m_xImpl->m_xEdFileName->SetNoURLSelection( bSaveMode ); - pImpl->_pBtnUp->SetAccessibleName( pImpl->_pBtnUp->GetQuickHelpText() ); + if (nStyle & PickerFlags::MultiSelection) + m_xImpl->m_bMultiSelection = true; - if ( nStyle & PickerFlags::MultiSelection ) - pImpl->_bMultiSelection = true; + m_xContainer = m_xBuilder->weld_container("container"); + m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 95, -1); - _pContainer.reset(VclPtr<CustomContainer>::Create(get<vcl::Window>("container"))); - Size aSize(LogicToPixel(Size(270, 85), MapMode(MapUnit::MapAppFont))); - _pContainer->set_height_request(aSize.Height()); - _pContainer->set_width_request(aSize.Width()); - _pContainer->set_hexpand(true); - _pContainer->set_vexpand(true); - _pContainer->SetStyle( _pContainer->GetStyle() | WB_TABSTOP ); - - _pFileView = VclPtr<SvtFileView>::Create( _pContainer, WB_BORDER, - FILEDLG_TYPE_PATHDLG == pImpl->_eDlgType, - pImpl->_bMultiSelection ); - _pFileView->Show(); - _pFileView->EnableAutoResize(); - _pFileView->SetHelpId( HID_FILEDLG_STANDARD ); - _pFileView->SetStyle( _pFileView->GetStyle() | WB_TABSTOP ); - - _pSplitter = VclPtr<Splitter>::Create( _pContainer, WB_HSCROLL ); - _pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() )); - _pSplitter->SetSplitHdl( LINK( this, SvtFileDialog, Split_Hdl ) ); - - Image aNewFolderImg( GetButtonImage( BMP_FILEDLG_CREATEFOLDER ) ); - pImpl->_pBtnNewFolder->SetModeImage( aNewFolderImg ); + m_xFileView.reset(new SvtFileView(m_xDialog.get(), + m_xBuilder->weld_tree_view("fileview"), + m_xBuilder->weld_icon_view("iconview"), + FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType, + m_xImpl->m_bMultiSelection)); + m_xFileView->set_help_id( HID_FILEDLG_STANDARD ); if ( nStyle & PickerFlags::ReadOnly ) { - _pCbReadOnly->SetHelpId( HID_FILEOPEN_READONLY ); - _pCbReadOnly->SetText( FpsResId( STR_SVT_FILEPICKER_READONLY ) ); - _pCbReadOnly->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - _pCbReadOnly->Show(); + m_xCbReadOnly->set_help_id( HID_FILEOPEN_READONLY ); + m_xCbReadOnly->set_label( FpsResId( STR_SVT_FILEPICKER_READONLY ) ); + m_xCbReadOnly->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xCbReadOnly->show(); } if ( nStyle & PickerFlags::Password ) { - pImpl->_pCbPassword->SetText( FpsResId( STR_SVT_FILEPICKER_PASSWORD ) ); - pImpl->_pCbPassword->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - pImpl->_pCbPassword->Show(); - pImpl->_pCbGPGEncrypt->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - pImpl->_pCbGPGEncrypt->Show(); + m_xImpl->m_xCbPassword->set_label( FpsResId( STR_SVT_FILEPICKER_PASSWORD ) ); + m_xImpl->m_xCbPassword->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xImpl->m_xCbPassword->show(); + m_xImpl->m_xCbGPGEncrypt->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xImpl->m_xCbGPGEncrypt->show(); } // set the ini file for extracting the size - pImpl->_aIniKey = "FileDialog"; + m_xImpl->m_aIniKey = "FileDialog"; AddControls_Impl( ); @@ -652,70 +398,68 @@ void SvtFileDialog::Init_Impl if ( nStyle & PickerFlags::PathDialog ) { - pImpl->_pFtFileName->SetText( FpsResId( STR_PATHNAME ) ); + m_xImpl->m_xFtFileName->set_label( FpsResId( STR_PATHNAME ) ); pResId = STR_PATHSELECT; pButtonResId = STR_BUTTONSELECT; } - SetText( FpsResId( pResId ) ); + m_xDialog->set_title(FpsResId(pResId)); if ( pButtonResId ) - pImpl->_pBtnFileOpen->SetText( FpsResId( pButtonResId ) ); + m_xImpl->m_xBtnFileOpen->set_label( FpsResId( pButtonResId ) ); - if ( FILEDLG_TYPE_FILEDLG != pImpl->_eDlgType ) + if ( FILEDLG_TYPE_FILEDLG != m_xImpl->m_eDlgType ) { - pImpl->_pFtFileType->Hide(); - pImpl->GetFilterListControl()->Hide(); + m_xImpl->m_xFtFileType->hide(); + m_xImpl->GetFilterListControl()->hide(); } // Setting preferences of the control elements. - pImpl->_pBtnNewFolder->SetClickHdl( LINK( this, SvtFileDialog, NewFolderHdl_Impl ) ); - pImpl->_pBtnFileOpen->SetClickHdl( LINK( this, SvtFileDialog, OpenClickHdl_Impl ) ); - pImpl->_pBtnCancel->SetClickHdl( LINK( this, SvtFileDialog, CancelHdl_Impl ) ); - pImpl->SetFilterListSelectHdl( LINK( this, SvtFileDialog, FilterSelectHdl_Impl ) ); - pImpl->_pEdFileName->SetGetFocusHdl( LINK( this, SvtFileDialog, FileNameGetFocusHdl_Impl ) ); - pImpl->_pEdFileName->SetModifyHdl( LINK( this, SvtFileDialog, FileNameModifiedHdl_Impl ) ); - pImpl->_pEdCurrentPath->SetOpenHdl ( LINK( this, SvtFileDialog, URLBoxModifiedHdl_Impl ) ); - pImpl->_pBtnConnectToServer->SetClickHdl( LINK ( this, SvtFileDialog, ConnectToServerPressed_Hdl ) ); - - - _pFileView->SetSelectHdl( LINK( this, SvtFileDialog, SelectHdl_Impl ) ); - _pFileView->SetDoubleClickHdl( LINK( this, SvtFileDialog, DblClickHdl_Impl ) ); - _pFileView->SetOpenDoneHdl( LINK( this, SvtFileDialog, OpenDoneHdl_Impl ) ); - + m_xImpl->m_xBtnNewFolder->connect_clicked( LINK( this, SvtFileDialog, NewFolderHdl_Impl ) ); + m_xImpl->m_xBtnFileOpen->connect_clicked( LINK( this, SvtFileDialog, OpenClickHdl_Impl ) ); + m_xImpl->m_xBtnCancel->connect_clicked( LINK( this, SvtFileDialog, CancelHdl_Impl ) ); + m_xImpl->SetFilterListSelectHdl( LINK( this, SvtFileDialog, FilterSelectHdl_Impl ) ); + m_xImpl->m_xEdFileName->connect_focus_in( LINK( this, SvtFileDialog, FileNameGetFocusHdl_Impl ) ); + m_xImpl->m_xEdFileName->connect_changed( LINK( this, SvtFileDialog, FileNameModifiedHdl_Impl ) ); + m_xImpl->m_xEdCurrentPath->connect_entry_activate( LINK( this, SvtFileDialog, URLBoxModifiedHdl_Impl ) ); + m_xImpl->m_xBtnConnectToServer->connect_clicked( LINK ( this, SvtFileDialog, ConnectToServerPressed_Hdl ) ); + + m_xFileView->SetSelectHdl( LINK( this, SvtFileDialog, SelectHdl_Impl ) ); + m_xFileView->SetDoubleClickHdl( LINK( this, SvtFileDialog, DblClickHdl_Impl ) ); + m_xFileView->SetOpenDoneHdl( LINK( this, SvtFileDialog, OpenDoneHdl_Impl ) ); // set timer for the filterbox travel - pImpl->_aFilterTimer.SetTimeout( TRAVELFILTER_TIMEOUT ); - pImpl->_aFilterTimer.SetInvokeHandler( LINK( this, SvtFileDialog, FilterSelectTimerHdl_Impl ) ); + m_xImpl->m_aFilterIdle.SetPriority(TaskPriority::LOWEST); + m_xImpl->m_aFilterIdle.SetInvokeHandler( LINK( this, SvtFileDialog, FilterSelectTimerHdl_Impl ) ); if ( PickerFlags::SaveAs & nStyle ) { // different help ids if in save-as mode - SetHelpId( HID_FILESAVE_DIALOG ); + m_xDialog->set_help_id( HID_FILESAVE_DIALOG ); - pImpl->_pEdFileName->SetHelpId( HID_FILESAVE_FILEURL ); - pImpl->_pBtnFileOpen->SetHelpId( HID_FILESAVE_DOSAVE ); - pImpl->_pBtnNewFolder->SetHelpId( HID_FILESAVE_CREATEDIRECTORY ); - pImpl->_pBtnUp->SetHelpId( HID_FILESAVE_LEVELUP ); - pImpl->GetFilterListControl()->SetHelpId( HID_FILESAVE_FILETYPE ); - _pFileView->SetHelpId( HID_FILESAVE_FILEVIEW ); + m_xImpl->m_xEdFileName->set_help_id( HID_FILESAVE_FILEURL ); + m_xImpl->m_xBtnFileOpen->set_help_id( HID_FILESAVE_DOSAVE ); + m_xImpl->m_xBtnNewFolder->set_help_id( HID_FILESAVE_CREATEDIRECTORY ); + m_xImpl->m_xBtnUp->set_help_id( HID_FILESAVE_LEVELUP ); + m_xImpl->GetFilterListControl()->set_help_id( HID_FILESAVE_FILETYPE ); + m_xFileView->set_help_id( HID_FILESAVE_FILEVIEW ); // formerly, there was only _pLbFileVersion, which was used for 3 different // use cases. For reasons of maintainability, I introduced extra members (_pLbTemplates, _pLbImageTemplates) // for the extra use cases, and separated _pLbFileVersion // I did not find out in which cases the help ID is really needed HID_FILESAVE_TEMPLATE - all // tests I made lead to a dialog where _no_ of the three list boxes was present. - if ( pImpl->_pLbFileVersion ) - pImpl->_pLbFileVersion->SetHelpId( HID_FILESAVE_TEMPLATE ); - if ( pImpl->_pLbTemplates ) - pImpl->_pLbTemplates->SetHelpId( HID_FILESAVE_TEMPLATE ); - if ( pImpl->_pLbImageTemplates ) - pImpl->_pLbImageTemplates->SetHelpId( HID_FILESAVE_TEMPLATE ); + if ( m_xImpl->m_xLbFileVersion ) + m_xImpl->m_xLbFileVersion->set_help_id( HID_FILESAVE_TEMPLATE ); + if ( m_xImpl->m_xLbTemplates ) + m_xImpl->m_xLbTemplates->set_help_id( HID_FILESAVE_TEMPLATE ); + if ( m_xImpl->m_xLbImageTemplates ) + m_xImpl->m_xLbImageTemplates->set_help_id( HID_FILESAVE_TEMPLATE ); - if ( pImpl->_pCbPassword ) pImpl->_pCbPassword->SetHelpId( HID_FILESAVE_SAVEWITHPASSWORD ); - if ( pImpl->_pCbAutoExtension ) pImpl->_pCbAutoExtension->SetHelpId( HID_FILESAVE_AUTOEXTENSION ); - if ( pImpl->_pCbOptions ) pImpl->_pCbOptions->SetHelpId( HID_FILESAVE_CUSTOMIZEFILTER ); - if ( _pCbSelection ) _pCbSelection->SetHelpId( HID_FILESAVE_SELECTION ); + if ( m_xImpl->m_xCbPassword ) m_xImpl->m_xCbPassword->set_help_id( HID_FILESAVE_SAVEWITHPASSWORD ); + if ( m_xImpl->m_xCbAutoExtension ) m_xImpl->m_xCbAutoExtension->set_help_id( HID_FILESAVE_AUTOEXTENSION ); + if ( m_xImpl->m_xCbOptions ) m_xImpl->m_xCbOptions->set_help_id( HID_FILESAVE_CUSTOMIZEFILTER ); + if ( m_xCbSelection ) m_xCbSelection->set_help_id( HID_FILESAVE_SELECTION ); } /// read our settings from the configuration @@ -724,20 +468,54 @@ void SvtFileDialog::Init_Impl "/org.openoffice.Office.UI/FilePicker" ); - _pContainer->init(pImpl.get(), _pFileView, _pSplitter, pImpl->_pBtnNewFolder, pImpl->_pEdFileName); - _pContainer->Show(); + m_xDialog->connect_size_allocate(LINK(this, SvtFileDialog, SizeAllocHdl)); + SizeAllocHdl(Size()); +} + +SvtFileDialog::~SvtFileDialog() +{ + if (!m_xImpl->m_aIniKey.isEmpty()) + { + // save window state + SvtViewOptions aDlgOpt( EViewType::Dialog, m_xImpl->m_aIniKey ); + aDlgOpt.SetWindowState(OStringToOUString(m_xDialog->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_UTF8)); + OUString sUserData = m_xFileView->GetConfigString(); + aDlgOpt.SetUserItem( "UserData", + makeAny( sUserData ) ); + } + + m_xFileView->SetSelectHdl(Link<SvtFileView*,void>()); + + // Save bookmarked places + if (m_xImpl->m_xPlaces->IsUpdated()) { + const std::vector<PlacePtr> aPlaces = m_xImpl->m_xPlaces->GetPlaces(); + Sequence< OUString > placesUrlsList(m_xImpl->m_xPlaces->GetNbEditablePlaces()); + Sequence< OUString > placesNamesList(m_xImpl->m_xPlaces->GetNbEditablePlaces()); + int i(0); + for (auto const& place : aPlaces) + { + if(place->IsEditable()) { + placesUrlsList[i] = place->GetUrl(); + placesNamesList[i] = place->GetName(); + ++i; + } + } - Resize(); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_xContext)); + officecfg::Office::Common::Misc::FilePickerPlacesUrls::set(placesUrlsList, batch); + officecfg::Office::Common::Misc::FilePickerPlacesNames::set(placesNamesList, batch); + batch->commit(); + } } -IMPL_LINK_NOARG( SvtFileDialog, NewFolderHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvtFileDialog, NewFolderHdl_Impl, weld::Button&, void) { - _pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); - SmartContent aContent( _pFileView->GetViewURL( ) ); + SmartContent aContent( m_xFileView->GetViewURL( ) ); OUString aTitle; aContent.getTitle( aTitle ); - QueryFolderNameDialog aDlg(GetFrameWeld(), aTitle, FpsResId(STR_SVT_NEW_FOLDER)); + QueryFolderNameDialog aDlg(m_xDialog.get(), aTitle, FpsResId(STR_SVT_NEW_FOLDER)); bool bHandled = false; while ( !bHandled ) @@ -747,7 +525,7 @@ IMPL_LINK_NOARG( SvtFileDialog, NewFolderHdl_Impl, Button*, void) OUString aUrl = aContent.createFolder(aDlg.GetName()); if ( !aUrl.isEmpty( ) ) { - _pFileView->CreatedFolder(aUrl, aDlg.GetName()); + m_xFileView->CreatedFolder(aUrl, aDlg.GetName()); bHandled = true; } } @@ -759,7 +537,7 @@ IMPL_LINK_NOARG( SvtFileDialog, NewFolderHdl_Impl, Button*, void) void SvtFileDialog::createNewUserFilter( const OUString& _rNewFilter ) { // delete the old user filter and create a new one - pImpl->_pUserFilter.reset( new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter ) ); + m_xImpl->m_xUserFilter.reset( new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter ) ); // remember the extension bool bIsAllFiles = _rNewFilter == FILEDIALOG_FILTER_ALL; @@ -771,18 +549,18 @@ void SvtFileDialog::createNewUserFilter( const OUString& _rNewFilter ) // is always "*.<something>". But changing this would take some more time than I have now... // now, the default extension is set to the one of the user filter (or empty) - if ( pImpl->GetCurFilter( ) ) - SetDefaultExt( pImpl->GetCurFilter( )->GetExtension() ); + if ( m_xImpl->GetCurFilter( ) ) + SetDefaultExt( m_xImpl->GetCurFilter( )->GetExtension() ); else EraseDefaultExt(); } -AdjustFilterFlags SvtFileDialog::adjustFilter( const OUString& _rFilter ) +AdjustFilterFlags SvtFileDialog::adjustFilter( const OUString& rFilter ) { AdjustFilterFlags nReturn = AdjustFilterFlags::NONE; - const bool bNonEmpty = !_rFilter.isEmpty(); + const bool bNonEmpty = !rFilter.isEmpty(); if ( bNonEmpty ) { nReturn |= AdjustFilterFlags::NonEmpty; @@ -790,11 +568,11 @@ AdjustFilterFlags SvtFileDialog::adjustFilter( const OUString& _rFilter ) bool bFilterChanged = true; // search for a corresponding filter - SvtFileDialogFilter_Impl* pFilter = FindFilter_Impl( _rFilter, false, bFilterChanged ); + SvtFileDialogFilter_Impl* pFilter = FindFilter_Impl( rFilter, false, bFilterChanged ); // look for multi-ext filters if necessary if ( !pFilter ) - pFilter = FindFilter_Impl( _rFilter, true, bFilterChanged ); + pFilter = FindFilter_Impl( rFilter, true, bFilterChanged ); if ( bFilterChanged ) nReturn |= AdjustFilterFlags::Changed; @@ -803,15 +581,14 @@ AdjustFilterFlags SvtFileDialog::adjustFilter( const OUString& _rFilter ) { nReturn |= AdjustFilterFlags::UserFilter; // no filter found : use it as user defined filter - createNewUserFilter( _rFilter ); + createNewUserFilter( rFilter ); } } return nReturn; } - -IMPL_LINK_NOARG(SvtFileDialog, CancelHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvtFileDialog, CancelHdl_Impl, weld::Button&, void) { if ( m_pCurrentAsyncAction.is() ) { @@ -820,22 +597,24 @@ IMPL_LINK_NOARG(SvtFileDialog, CancelHdl_Impl, Button*, void) } else { - EndDialog(); + m_xDialog->response(RET_CANCEL); } } - -IMPL_LINK( SvtFileDialog, OpenClickHdl_Impl, Button*, pVoid, void ) +IMPL_LINK( SvtFileDialog, OpenClickHdl_Impl, weld::Button&, rVoid, void ) { - OpenHdl_Impl(pVoid); + OpenHdl_Impl(&rVoid); } -IMPL_LINK( SvtFileDialog, OpenUrlHdl_Impl, SvtURLBox*, pVoid, void ) + +IMPL_LINK( SvtFileDialog, OpenUrlHdl_Impl, weld::ComboBox&, rVoid, bool ) { - OpenHdl_Impl(pVoid); + OpenHdl_Impl(&rVoid); + return true; } + void SvtFileDialog::OpenHdl_Impl(void const * pVoid) { - if ( pImpl->_bMultiSelection && _pFileView->GetSelectionCount() > 1 ) + if ( m_xImpl->m_bMultiSelection && m_xFileView->GetSelectionCount() > 1 ) { // special open in case of multiselection OpenMultiSelection_Impl(); @@ -843,30 +622,28 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) } OUString aFileName; - OUString aOldPath( _pFileView->GetViewURL() ); - if ( pImpl->_bDoubleClick || _pFileView->HasChildPathFocus() ) + OUString aOldPath(m_xFileView->GetViewURL()); + if ( m_xImpl->m_bDoubleClick || m_xFileView->has_focus() ) + { // Selection done by doubleclicking in the view, get filename from the view - aFileName = _pFileView->GetCurrentURL(); + aFileName = m_xFileView->GetCurrentURL(); + } if ( aFileName.isEmpty() ) { // if an entry is selected in the view... - if ( _pFileView->GetSelectionCount() ) + if ( m_xFileView->GetSelectionCount() ) { // -> use this one. This will allow us to step down this folder - aFileName = _pFileView->GetCurrentURL(); + aFileName = m_xFileView->GetCurrentURL(); } } if ( aFileName.isEmpty() ) { - if ( pImpl->_eMode == FILEDLG_MODE_OPEN && pImpl->_pEdFileName->IsTravelSelect() ) - // OpenHdl called from URLBox; travelling through the list of URLs should not cause an opening - return; // MBA->PB: seems to be called never ?! - // get the URL from the edit field ( if not empty ) - if ( !pImpl->_pEdFileName->GetText().isEmpty() ) + if ( !m_xImpl->m_xEdFileName->get_active_text().isEmpty() ) { - OUString aText = pImpl->_pEdFileName->GetText(); + OUString aText = m_xImpl->m_xEdFileName->get_active_text(); // did we reach the root? if ( !INetURLObject( aOldPath ).getSegmentCount() ) @@ -881,26 +658,26 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) if ( ( 1 == aText.getLength() ) && ( '~' == aText[0] ) ) { // go to the home directory - if ( lcl_getHomeDirectory( _pFileView->GetViewURL(), aFileName ) ) + if ( lcl_getHomeDirectory( m_xFileView->GetViewURL(), aFileName ) ) // in case we got a home dir, reset the text of the edit - pImpl->_pEdFileName->SetText( OUString() ); + m_xImpl->m_xEdFileName->set_entry_text( OUString() ); } if ( aFileName.isEmpty() ) #endif { // get url from autocomplete edit - aFileName = pImpl->_pEdFileName->GetURL(); + aFileName = m_xImpl->m_xEdFileName->GetURL(); } } - else if ( pVoid == pImpl->_pBtnFileOpen.get() ) + else if ( pVoid == m_xImpl->m_xBtnFileOpen.get() ) // OpenHdl was called for the "Open" Button; if edit field is empty, use selected element in the view - aFileName = _pFileView->GetCurrentURL(); + aFileName = m_xFileView->GetCurrentURL(); } // MBA->PB: ?! - if ( aFileName.isEmpty() && pVoid == pImpl->_pEdFileName && pImpl->_pUserFilter ) + if ( aFileName.isEmpty() && pVoid == m_xImpl->m_xEdFileName.get() && m_xImpl->m_xUserFilter ) { - pImpl->_pUserFilter.reset(); + m_xImpl->m_xUserFilter.reset(); return; } @@ -908,9 +685,9 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) if ( !nLen ) { // if the dialog was opened to select a folder, the last selected folder should be selected - if( pImpl->_eDlgType == FILEDLG_TYPE_PATHDLG ) + if( m_xImpl->m_eDlgType == FILEDLG_TYPE_PATHDLG ) { - aFileName = pImpl->_pEdCurrentPath->GetText(); + aFileName = m_xImpl->m_xEdCurrentPath->get_active_text(); nLen = aFileName.getLength(); } else @@ -919,7 +696,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) } // mark input as selected - pImpl->_pEdFileName->SetSelection( Selection( 0, nLen ) ); + m_xImpl->m_xEdFileName->select_entry_region(0, nLen); // if a path with wildcards is given, divide the string into path and wildcards OUString aFilter; @@ -931,15 +708,15 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) if ( nNewFilterFlags & AdjustFilterFlags::Changed ) { // cut off all text before wildcard in edit and select wildcard - pImpl->_pEdFileName->SetText( aFilter ); - pImpl->_pEdFileName->SetSelection( Selection( 0, aFilter.getLength() ) ); + m_xImpl->m_xEdFileName->set_entry_text( aFilter ); + m_xImpl->m_xEdFileName->select_entry_region(0, -1); } { INetURLObject aFileObject( aFileName ); if ( ( aFileObject.GetProtocol() == INetProtocol::NotValid ) && !aFileName.isEmpty() ) { - OUString sCompleted = SvtURLBox::ParseSmart( aFileName, _pFileView->GetViewURL() ); + OUString sCompleted = SvtURLBox::ParseSmart( aFileName, m_xFileView->GetViewURL() ); if ( !sCompleted.isEmpty() ) aFileName = sCompleted; } @@ -980,7 +757,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) return; if ( m_aContent.isInvalid() && - ( pImpl->_eMode == FILEDLG_MODE_OPEN ) ) + ( m_xImpl->m_eMode == FILEDLG_MODE_OPEN ) ) { if ( !pHandler->wasUsed() ) ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTS ); @@ -995,35 +772,35 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) m_aContent.enableDefaultInteractionHandler(); } - if ( !bIsFolder // no existent folder - && pImpl->_pCbAutoExtension // auto extension is enabled in general - && pImpl->_pCbAutoExtension->IsChecked() // auto extension is really to be used - && !GetDefaultExt().isEmpty() // there is a default extension + if ( !bIsFolder // no existent folder + && m_xImpl->m_xCbAutoExtension // auto extension is enabled in general + && m_xImpl->m_xCbAutoExtension->get_active()// auto extension is really to be used + && !GetDefaultExt().isEmpty() // there is a default extension && GetDefaultExt() != "*" // the default extension is not "all" - && !( FILEDLG_MODE_SAVE == pImpl->_eMode // we're saving a file - && _pFileView->GetSelectionCount() // there is a selected file in the file view -> it will later on + && !( FILEDLG_MODE_SAVE == m_xImpl->m_eMode // we're saving a file + && m_xFileView->GetSelectionCount() // there is a selected file in the file view -> it will later on ) // (in SvtFileDialog::GetPathList) be taken as file to save to - && FILEDLG_MODE_OPEN != pImpl->_eMode // #i83408# don't append extension on open + && FILEDLG_MODE_OPEN != m_xImpl->m_eMode // #i83408# don't append extension on open ) { // check extension and append the default extension if necessary appendDefaultExtension(aFileName, GetDefaultExt(), - pImpl->GetCurFilter()->GetType()); + m_xImpl->GetCurFilter()->GetType()); } - bool bOpenFolder = ( FILEDLG_TYPE_PATHDLG == pImpl->_eDlgType ) && - !pImpl->_bDoubleClick && pVoid != pImpl->_pEdFileName; + bool bOpenFolder = ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType ) && + !m_xImpl->m_bDoubleClick && pVoid != m_xImpl->m_xEdFileName.get(); if ( bIsFolder ) { if ( bOpenFolder ) { - _aPath = aFileName; + m_aPath = aFileName; } else { - if ( aFileName != _pFileView->GetViewURL() ) + if ( aFileName != m_xFileView->GetViewURL() ) { OpenURL_Impl( aFileName ); } @@ -1039,7 +816,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) else if ( !( nNewFilterFlags & AdjustFilterFlags::NonEmpty ) ) { // if applicable save URL - _aPath = aFileName; + m_aPath = aFileName; } else { @@ -1056,7 +833,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) return; } - switch ( pImpl->_eMode ) + switch (m_xImpl->m_eMode) { case FILEDLG_MODE_SAVE: { @@ -1067,7 +844,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) "$filename$", aFileObj.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset) ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, aMsg)); if (xBox->run() != RET_YES) return; @@ -1113,7 +890,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) } sError = sError.replaceFirst( "$name$", sInvalidFile ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sError)); xBox->run(); return; @@ -1126,57 +903,37 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid) OSL_FAIL("SvtFileDialog, OpenHdl_Impl: invalid mode!"); } - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } - -void SvtFileDialog::EnableAutocompletion( bool _bEnable ) +void SvtFileDialog::EnableAutocompletion(bool bEnable) { - pImpl->_pEdFileName->EnableAutocompletion( _bEnable ); + m_xImpl->m_xEdFileName->EnableAutocomplete(bEnable); } - -IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, ListBox&, void ) +IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, weld::ComboBox&, void ) { OUString sSelectedFilterDisplayName; - SvtFileDialogFilter_Impl* pSelectedFilter = pImpl->GetSelectedFilterEntry( sSelectedFilterDisplayName ); + SvtFileDialogFilter_Impl* pSelectedFilter = m_xImpl->GetSelectedFilterEntry( sSelectedFilterDisplayName ); if ( !pSelectedFilter ) { // there is no current selection. This happens if for instance the user selects a group separator using // the keyboard, and then presses enter: When the selection happens, we immediately deselect the entry, // so in this situation there is no current selection. - if ( restoreCurrentFilter( pImpl ) ) + if ( restoreCurrentFilter( m_xImpl ) ) ExecuteFilter(); } else { - if ( pSelectedFilter->isGroupSeparator() ) - { // group separators can't be selected - // return to the previously selected entry - if ( pImpl->IsFilterListTravelSelect() ) - { - pImpl->SetNoFilterListSelection( ); - - // stop the timer for executing the filter - if ( pImpl->_aFilterTimer.IsActive() ) - pImpl->m_bNeedDelayedFilterExecute = true; - pImpl->_aFilterTimer.Stop(); - } - else - { - if ( restoreCurrentFilter( pImpl ) ) - ExecuteFilter(); - } - } - else if ( ( pSelectedFilter != pImpl->GetCurFilter() ) - || pImpl->_pUserFilter - ) + if ( ( pSelectedFilter != m_xImpl->GetCurFilter() ) + || m_xImpl->m_xUserFilter + ) { // Store the old filter for the auto extension handling - OUString sLastFilterExt = pImpl->GetCurFilter()->GetExtension(); - pImpl->_pUserFilter.reset(); + OUString sLastFilterExt = m_xImpl->GetCurFilter()->GetExtension(); + m_xImpl->m_xUserFilter.reset(); // if applicable remove filter of the user - pImpl->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName ); + m_xImpl->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName ); // if applicable show extension SetDefaultExt( pSelectedFilter->GetExtension() ); @@ -1190,20 +947,8 @@ IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, ListBox&, void ) // if the user is traveling fast through the filterbox // do not filter instantly - if ( pImpl->IsFilterListTravelSelect() ) - { - // FilterSelectHdl_Impl should be started again in - // TRAVELFILTER_TIMEOUT ms - pImpl->_aFilterTimer.Start(); - } - else - { - // stop previously started timer - pImpl->_aFilterTimer.Stop(); - - // filter the view again - ExecuteFilter(); - } + // FilterSelectHdl_Impl should be started again at idle + m_xImpl->m_aFilterIdle.Start(); } } } @@ -1214,38 +959,35 @@ IMPL_LINK_NOARG(SvtFileDialog, FilterSelectTimerHdl_Impl, Timer*, void) ExecuteFilter(); } -IMPL_LINK_NOARG( SvtFileDialog, FileNameGetFocusHdl_Impl, Control&, void ) +IMPL_LINK_NOARG( SvtFileDialog, FileNameGetFocusHdl_Impl, weld::Widget&, void ) { - _pFileView->SetNoSelection(); - _pFileView->Update(); + m_xFileView->SetNoSelection(); } - -IMPL_LINK_NOARG( SvtFileDialog, FileNameModifiedHdl_Impl, Edit&, void ) +IMPL_LINK( SvtFileDialog, FileNameModifiedHdl_Impl, weld::ComboBox&, rComboBox, void ) { - FileNameGetFocusHdl_Impl( *pImpl->_pEdFileName ); + FileNameGetFocusHdl_Impl(rComboBox); } - -IMPL_LINK_NOARG( SvtFileDialog, URLBoxModifiedHdl_Impl, SvtURLBox*, void ) +IMPL_LINK_NOARG(SvtFileDialog, URLBoxModifiedHdl_Impl, weld::ComboBox&, bool) { - OUString aPath = pImpl->_pEdCurrentPath->GetURL(); + OUString aPath = m_xImpl->m_xEdCurrentPath->GetURL(); OpenURL_Impl(aPath); + return true; } - -IMPL_LINK_NOARG( SvtFileDialog, ConnectToServerPressed_Hdl, Button*, void ) +IMPL_LINK_NOARG( SvtFileDialog, ConnectToServerPressed_Hdl, weld::Button&, void ) { - _pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); - PlaceEditDialog aDlg(GetFrameWeld()); + PlaceEditDialog aDlg(m_xDialog.get()); short aRetCode = aDlg.run(); switch (aRetCode) { case RET_OK : { PlacePtr newPlace = aDlg.GetPlace(); - pImpl->_pPlaces->AppendPlace(newPlace); + m_xImpl->m_xPlaces->AppendPlace(newPlace); break; } @@ -1256,32 +998,29 @@ IMPL_LINK_NOARG( SvtFileDialog, ConnectToServerPressed_Hdl, Button*, void ) }; } - -IMPL_LINK_NOARG ( SvtFileDialog, AddPlacePressed_Hdl, Button*, void ) +IMPL_LINK_NOARG ( SvtFileDialog, AddPlacePressed_Hdl, weld::Button&, void ) { // Maybe open the PlacesDialog would have been a better idea // there is an ux choice to make we did not make... - INetURLObject aURLObj( _pFileView->GetViewURL() ); + INetURLObject aURLObj( m_xFileView->GetViewURL() ); PlacePtr newPlace( new Place( aURLObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset), - _pFileView->GetViewURL(), true)); - pImpl->_pPlaces->AppendPlace(newPlace); + m_xFileView->GetViewURL(), true)); + m_xImpl->m_xPlaces->AppendPlace(newPlace); } - -IMPL_LINK_NOARG ( SvtFileDialog, RemovePlacePressed_Hdl, Button*, void ) +IMPL_LINK_NOARG ( SvtFileDialog, RemovePlacePressed_Hdl, weld::Button&, void ) { - pImpl->_pPlaces->RemoveSelectedPlace(); + m_xImpl->m_xPlaces->RemoveSelectedPlace(); } - SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl ( - const OUString& _rFilter, - bool _bMultiExt,/* TRUE - regard filter with several extensions + const OUString& rFilter, + bool bMultiExt,/* TRUE - regard filter with several extensions FALSE - do not ... */ - bool& _rFilterChanged + bool& rFilterChanged ) /* [Description] @@ -1291,7 +1030,7 @@ SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl { SvtFileDialogFilter_Impl* pFoundFilter = nullptr; - SvtFileDialogFilterList_Impl& rList = pImpl->m_aFilter; + SvtFileDialogFilterList_Impl& rList = m_xImpl->m_aFilter; sal_uInt16 nFilter = rList.size(); while ( nFilter-- ) @@ -1299,33 +1038,33 @@ SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl SvtFileDialogFilter_Impl* pFilter = rList[ nFilter ].get(); const OUString& rType = pFilter->GetType(); - if ( _bMultiExt ) + if ( bMultiExt ) { sal_Int32 nIdx = 0; while ( !pFoundFilter && nIdx != -1 ) { const OUString aSingleType = rType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nIdx ); #ifdef UNX - if ( aSingleType == _rFilter ) + if ( aSingleType == rFilter ) #else - if ( aSingleType.equalsIgnoreAsciiCase( _rFilter ) ) + if ( aSingleType.equalsIgnoreAsciiCase( rFilter ) ) #endif pFoundFilter = pFilter; } } #ifdef UNX - else if ( rType == _rFilter ) + else if ( rType == rFilter ) #else - else if ( rType.equalsIgnoreAsciiCase( _rFilter ) ) + else if ( rType.equalsIgnoreAsciiCase( rFilter ) ) #endif pFoundFilter = pFilter; if ( pFoundFilter ) { // activate filter - _rFilterChanged = pImpl->_pUserFilter || ( pImpl->GetCurFilter() != pFilter ); + rFilterChanged = m_xImpl->m_xUserFilter || ( m_xImpl->GetCurFilter() != pFilter ); - createNewUserFilter( _rFilter ); + createNewUserFilter( rFilter ); break; } @@ -1336,36 +1075,30 @@ SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl void SvtFileDialog::ExecuteFilter() { - pImpl->m_bNeedDelayedFilterExecute = false; - executeAsync( AsyncPickerAction::eExecuteFilter, OUString(), getMostCurrentFilter( pImpl ) ); + m_xImpl->m_bNeedDelayedFilterExecute = false; + executeAsync( AsyncPickerAction::eExecuteFilter, OUString(), getMostCurrentFilter(m_xImpl) ); } - -void SvtFileDialog::OpenMultiSelection_Impl() - /* [Description] OpenHandler for MultiSelection */ - +void SvtFileDialog::OpenMultiSelection_Impl() { - sal_uLong nCount = _pFileView->GetSelectionCount(); - SvTreeListEntry* pEntry = nCount ? _pFileView->FirstSelected() : nullptr; + SvtContentEntry* pEntry = m_xFileView->FirstSelected(); - if ( nCount && pEntry ) - _aPath = SvtFileView::GetURL( pEntry ); + if (pEntry) + m_aPath = pEntry->maURL; - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } - void SvtFileDialog::UpdateControls( const OUString& rURL ) { - pImpl->_pEdFileName->SetBaseURL( rURL ); + m_xImpl->m_xEdFileName->SetBaseURL( rURL ); INetURLObject aObj( rURL ); - { OUString sText; SAL_WARN_IF( INetProtocol::NotValid == aObj.GetProtocol(), "fpicker.office", "SvtFileDialog::UpdateControls: Invalid URL!" ); @@ -1385,9 +1118,9 @@ void SvtFileDialog::UpdateControls( const OUString& rURL ) } // path mode ? - if ( FILEDLG_TYPE_PATHDLG == pImpl->_eDlgType ) + if ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType ) // -> set new path in the edit field - pImpl->_pEdFileName->SetText( sText ); + m_xImpl->m_xEdFileName->set_entry_text( sText ); // in the "current path" field, truncate the trailing slash if ( aObj.hasFinalSlash() ) @@ -1401,88 +1134,82 @@ void SvtFileDialog::UpdateControls( const OUString& rURL ) if ( sText.isEmpty() && !rURL.isEmpty() ) // happens, for instance, for URLs which the INetURLObject does not know to belong to a hierarchical scheme sText = rURL; - pImpl->_pEdCurrentPath->SetText( sText ); + m_xImpl->m_xEdCurrentPath->set_entry_text(sText); } + m_aPath = rURL; - _aPath = rURL; - if ( _pFileNotifier ) - _pFileNotifier->notify( DIRECTORY_CHANGED, 0 ); -} + m_xImpl->m_xBtnUp->FillURLMenu(); + if (m_pFileNotifier) + m_pFileNotifier->notify( DIRECTORY_CHANGED, 0 ); +} -IMPL_LINK( SvtFileDialog, SelectHdl_Impl, SvTreeListBox*, pBox, void ) +IMPL_LINK( SvtFileDialog, SelectHdl_Impl, SvtFileView*, pBox, void ) { - SvTreeListEntry* pEntry = pBox->FirstSelected(); - assert( pEntry && "SelectHandler without selected entry" ); - SvtContentEntry* pUserData = static_cast<SvtContentEntry*>(pEntry->GetUserData()); - - if ( pUserData ) + SvtContentEntry* pUserData = pBox->FirstSelected(); + if (pUserData) { INetURLObject aObj( pUserData->maURL ); - if ( FILEDLG_TYPE_PATHDLG == pImpl->_eDlgType ) + if ( FILEDLG_TYPE_PATHDLG == m_xImpl->m_eDlgType ) { if ( aObj.GetProtocol() == INetProtocol::File ) { if ( !pUserData->mbIsFolder ) aObj.removeSegment(); OUString aName = aObj.getFSysPath( static_cast<FSysStyle>(FSysStyle::Detect & ~FSysStyle::Vos) ); - pImpl->_pEdFileName->SetText( aName ); - pImpl->_pEdFileName->SetSelection( Selection( 0, aName.getLength() ) ); - _aPath = pUserData->maURL; + m_xImpl->m_xEdFileName->set_entry_text( aName ); + m_xImpl->m_xEdFileName->select_entry_region(0, -1); + m_aPath = pUserData->maURL; } else if ( !pUserData->mbIsFolder ) { - pImpl->_pEdFileName->SetText( pUserData->maURL ); - pImpl->_pEdFileName->SetSelection( Selection( 0, pUserData->maURL.getLength() ) ); - _aPath = pUserData->maURL; + m_xImpl->m_xEdFileName->set_entry_text( pUserData->maURL ); + m_xImpl->m_xEdFileName->select_entry_region(0, -1); + m_aPath = pUserData->maURL; } else - pImpl->_pEdFileName->SetText( OUString() ); + m_xImpl->m_xEdFileName->set_entry_text( OUString() ); } else { if ( !pUserData->mbIsFolder ) { - OUString aName = SvTabListBox::GetEntryText( pEntry, 0 ); - pImpl->_pEdFileName->SetText( aName ); - pImpl->_pEdFileName->SetSelection( Selection( 0, aName.getLength() ) ); - _aPath = pUserData->maURL; + OUString aName = pBox->get_selected_text(); + m_xImpl->m_xEdFileName->set_entry_text( aName ); + m_xImpl->m_xEdFileName->select_entry_region(0, -1); + m_aPath = pUserData->maURL; } } } - if ( pImpl->_bMultiSelection && _pFileView->GetSelectionCount() > 1 ) + if ( m_xImpl->m_bMultiSelection && m_xFileView->GetSelectionCount() > 1 ) { // clear the file edit for multiselection - pImpl->_pEdFileName->SetText( OUString() ); + m_xImpl->m_xEdFileName->set_entry_text( OUString() ); } FileSelect(); } - -IMPL_LINK_NOARG(SvtFileDialog, DblClickHdl_Impl, SvTreeListBox*, bool) +IMPL_LINK_NOARG(SvtFileDialog, DblClickHdl_Impl, SvtFileView*, bool) { - pImpl->_bDoubleClick = true; + m_xImpl->m_bDoubleClick = true; OpenHdl_Impl( nullptr ); - pImpl->_bDoubleClick = false; - - return false; + m_xImpl->m_bDoubleClick = false; + return true; } - -IMPL_LINK_NOARG(SvtFileDialog, EntrySelectHdl_Impl, ComboBox&, void) +IMPL_LINK_NOARG(SvtFileDialog, EntrySelectHdl_Impl, weld::ComboBox&, void) { FileSelect(); } - IMPL_LINK( SvtFileDialog, OpenDoneHdl_Impl, SvtFileView*, pView, void ) { const OUString& sCurrentFolder( pView->GetViewURL() ); // check if we can create new folders - EnableControl( pImpl->_pBtnNewFolder, ContentCanMakeFolder( sCurrentFolder ) ); + EnableControl( m_xImpl->m_xBtnNewFolder.get(), ContentCanMakeFolder( sCurrentFolder ) ); // check if we can travel one level up bool bCanTravelUp = ContentHasParentFolder( pView->GetViewURL() ); @@ -1495,85 +1222,49 @@ IMPL_LINK( SvtFileDialog, OpenDoneHdl_Impl, SvtFileView*, pView, void ) aCurrentFolder.removeSegment(); } - EnableControl( pImpl->_pBtnUp, bCanTravelUp ); + EnableControl( m_xImpl->m_xBtnUp->getWidget(), bCanTravelUp ); } - -IMPL_LINK_NOARG(SvtFileDialog, AutoExtensionHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvtFileDialog, AutoExtensionHdl_Impl, weld::Button&, void) { - if ( _pFileNotifier ) - _pFileNotifier->notify( CTRL_STATE_CHANGED, - CHECKBOX_AUTOEXTENSION ); + if (m_pFileNotifier) + m_pFileNotifier->notify(CTRL_STATE_CHANGED, CHECKBOX_AUTOEXTENSION); // update the extension of the current file if necessary - lcl_autoUpdateFileExtension( this, pImpl->GetCurFilter()->GetExtension() ); + lcl_autoUpdateFileExtension( this, m_xImpl->GetCurFilter()->GetExtension() ); } - -IMPL_LINK( SvtFileDialog, ClickHdl_Impl, Button*, pCheckBox, void ) +IMPL_LINK( SvtFileDialog, ClickHdl_Impl, weld::Button&, rCheckBox, void ) { - if ( ! _pFileNotifier ) + if (!m_pFileNotifier) return; sal_Int16 nId = -1; - if ( pCheckBox == pImpl->_pCbOptions ) + if ( &rCheckBox == m_xImpl->m_xCbOptions.get() ) nId = CHECKBOX_FILTEROPTIONS; - else if ( pCheckBox == _pCbSelection ) + else if ( &rCheckBox == m_xCbSelection.get() ) nId = CHECKBOX_SELECTION; - else if ( pCheckBox == _pCbReadOnly ) + else if ( &rCheckBox == m_xCbReadOnly.get() ) nId = CHECKBOX_READONLY; - else if ( pCheckBox == pImpl->_pCbPassword ) + else if ( &rCheckBox == m_xImpl->m_xCbPassword.get() ) nId = CHECKBOX_PASSWORD; - else if ( pCheckBox == pImpl->_pCbGPGEncrypt ) + else if ( &rCheckBox == m_xImpl->m_xCbGPGEncrypt.get() ) nId = CHECKBOX_GPGENCRYPTION; - else if ( pCheckBox == _pCbLinkBox ) + else if ( &rCheckBox == m_xCbLinkBox.get() ) nId = CHECKBOX_LINK; - else if ( pCheckBox == _pCbPreviewBox ) + else if ( &rCheckBox == m_xCbPreviewBox.get() ) nId = CHECKBOX_PREVIEW; if ( nId != -1 ) - _pFileNotifier->notify( CTRL_STATE_CHANGED, nId ); + m_pFileNotifier->notify( CTRL_STATE_CHANGED, nId ); } -IMPL_LINK_NOARG(SvtFileDialog, PlayButtonHdl_Impl, Button*, void) -{ - if ( _pFileNotifier ) - _pFileNotifier->notify( CTRL_STATE_CHANGED, - PUSHBUTTON_PLAY ); -} - - -bool SvtFileDialog::EventNotify( NotifyEvent& rNEvt ) - -/* [Description] - - This method gets called to catch <BACKSPACE>. -*/ - +IMPL_LINK_NOARG(SvtFileDialog, PlayButtonHdl_Impl, weld::Button&, void) { - MouseNotifyEvent nType = rNEvt.GetType(); - bool bRet = false; - - if ( MouseNotifyEvent::KEYINPUT == nType && rNEvt.GetKeyEvent() ) - { - const vcl::KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); - sal_uInt16 nCode = rKeyCode.GetCode(); - - if ( !rKeyCode.GetModifier() && - KEY_BACKSPACE == nCode && !pImpl->_pEdFileName->HasChildPathFocus() ) - { - bRet = false; - - if ( !bRet && pImpl->_pBtnUp->IsEnabled() ) - { - PrevLevel_Impl(); - bRet = true; - } - } - } - return bRet || Dialog::EventNotify(rNEvt); + if (m_pFileNotifier) + m_pFileNotifier->notify(CTRL_STATE_CHANGED, PUSHBUTTON_PLAY); } namespace @@ -1642,30 +1333,30 @@ OUString SvtFileDialog::implGetInitialURL( const OUString& _rPath, const OUStrin } -short SvtFileDialog::Execute() +short SvtFileDialog::run() { if ( !PrepareExecute() ) return 0; // start the dialog - _bIsInExecute = true; - short nResult = Dialog::Execute(); - _bIsInExecute = false; + m_bIsInExecute = true; + short nResult = GenericDialogController::run(); + m_bIsInExecute = false; - SAL_WARN_IF( m_pCurrentAsyncAction.is(), "fpicker.office", "SvtFilePicker::Execute: still running an async action!" ); + SAL_WARN_IF( m_pCurrentAsyncAction.is(), "fpicker.office", "SvtFilePicker::run: still running an async action!" ); // the dialog should not be cancellable while an async action is running - first, the action // needs to be cancelled // remember last directory if ( RET_OK == nResult ) { - INetURLObject aURL( _aPath ); + INetURLObject aURL( m_aPath ); if ( aURL.GetProtocol() == INetProtocol::File ) { // remember the selected directory only for file URLs not for virtual folders sal_Int32 nLevel = aURL.getSegmentCount(); bool bDir = m_aContent.isFolder( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - if ( nLevel > 1 && ( FILEDLG_TYPE_FILEDLG == pImpl->_eDlgType || !bDir ) ) + if ( nLevel > 1 && ( FILEDLG_TYPE_FILEDLG == m_xImpl->m_eDlgType || !bDir ) ) aURL.removeSegment(); } } @@ -1673,21 +1364,12 @@ short SvtFileDialog::Execute() return nResult; } -bool SvtFileDialog::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) -{ - if (!PrepareExecute()) - return false; - - // start of the dialog - return Dialog::StartExecuteAsync(rCtx); -} - void SvtFileDialog::onAsyncOperationStarted() { EnableUI( false ); // the cancel button must be always enabled - pImpl->_pBtnCancel->Enable(); - pImpl->_pBtnCancel->GrabFocus(); + m_xImpl->m_xBtnCancel->set_sensitive(true); + m_xImpl->m_xBtnCancel->grab_focus(); } void SvtFileDialog::onAsyncOperationFinished() @@ -1695,18 +1377,16 @@ void SvtFileDialog::onAsyncOperationFinished() EnableUI( true ); m_pCurrentAsyncAction = nullptr; if ( !m_bInExecuteAsync ) - pImpl->_pEdFileName->GrabFocus(); - // (if m_bInExecuteAsync is true, then the operation was finished within the minimum wait time, - // and to the user, the operation appears to be synchronous) + m_xImpl->m_xEdFileName->grab_focus(); + // (if m_bInExecuteAsync is true, then the operation was finished within the minimum wait time, + // and to the user, the operation appears to be synchronous) } - void SvtFileDialog::RemovablePlaceSelected(bool enable) { - pImpl->_pPlaces->SetDelEnabled( enable ); + m_xImpl->m_xPlaces->SetDelEnabled( enable ); } - void SvtFileDialog::displayIOException( const OUString& _rURL, IOErrorCode _eCode ) { try @@ -1748,42 +1428,39 @@ void SvtFileDialog::displayIOException( const OUString& _rURL, IOErrorCode _eCod } } - -void SvtFileDialog::EnableUI( bool _bEnable ) +void SvtFileDialog::EnableUI(bool bEnable) { - Enable( _bEnable ); + m_xDialog->set_sensitive(bEnable); - if ( _bEnable ) + if (bEnable) { - for ( auto& rxControl : m_aDisabledControls ) + for (auto& rxControl : m_aDisabledControls) { - rxControl->Enable( false ); + rxControl->set_sensitive(false); } } } - -void SvtFileDialog::EnableControl( Control* _pControl, bool _bEnable ) +void SvtFileDialog::EnableControl(weld::Widget* pControl, bool bEnable) { - if ( !_pControl ) + if (!pControl) { SAL_WARN( "fpicker.office", "SvtFileDialog::EnableControl: invalid control!" ); return; } - _pControl->Enable( _bEnable ); + pControl->set_sensitive(bEnable); - if ( _bEnable ) + if (bEnable) { - auto aPos = m_aDisabledControls.find( _pControl ); + auto aPos = m_aDisabledControls.find( pControl ); if ( m_aDisabledControls.end() != aPos ) m_aDisabledControls.erase( aPos ); } else - m_aDisabledControls.insert( _pControl ); + m_aDisabledControls.insert( pControl ); } - bool SvtFileDialog::PrepareExecute() { if (comphelper::LibreOfficeKit::isActive()) @@ -1807,7 +1484,7 @@ bool SvtFileDialog::PrepareExecute() = aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_ONLY ); if ( xResultSet.is() && !xResultSet->next() ) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, FpsResId(STR_SVT_NOREMOVABLEDEVICE))); xBox->run(); @@ -1822,7 +1499,7 @@ bool SvtFileDialog::PrepareExecute() } } - if ( ( pImpl->_nStyle & PickerFlags::SaveAs ) && m_bHasFilename ) + if ( ( m_xImpl->m_nStyle & PickerFlags::SaveAs ) && m_bHasFilename ) // when doing a save-as, we do not want the handler to handle "this file does not exist" messages // - finally we're going to save that file, aren't we? m_aContent.enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST); @@ -1831,46 +1508,46 @@ bool SvtFileDialog::PrepareExecute() // possibly just a filename without a path OUString aFileNameOnly; - if( !_aPath.isEmpty() && (pImpl->_eMode == FILEDLG_MODE_SAVE) - && (_aPath.indexOf(':') == -1) - && (_aPath.indexOf('\\') == -1) - && (_aPath.indexOf('/') == -1)) + if( !m_aPath.isEmpty() && (m_xImpl->m_eMode == FILEDLG_MODE_SAVE) + && (m_aPath.indexOf(':') == -1) + && (m_aPath.indexOf('\\') == -1) + && (m_aPath.indexOf('/') == -1)) { - aFileNameOnly = _aPath; - _aPath.clear(); + aFileNameOnly = m_aPath; + m_aPath.clear(); } // no starting path specified? - if ( _aPath.isEmpty() ) + if ( m_aPath.isEmpty() ) { // then use the standard directory - _aPath = lcl_ensureFinalSlash( pImpl->GetStandardDir() ); + m_aPath = lcl_ensureFinalSlash( m_xImpl->GetStandardDir() ); // attach given filename to path if ( !aFileNameOnly.isEmpty() ) - _aPath += aFileNameOnly; + m_aPath += aFileNameOnly; } - _aPath = implGetInitialURL( _aPath, GetStandardDir() ); + m_aPath = implGetInitialURL( m_aPath, GetStandardDir() ); - if ( pImpl->_nStyle & PickerFlags::SaveAs && !m_bHasFilename ) + if ( m_xImpl->m_nStyle & PickerFlags::SaveAs && !m_bHasFilename ) // when doing a save-as, we do not want the handler to handle "this file does not exist" messages // - finally we're going to save that file, aren't we? m_aContent.enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::E_DOESNOTEXIST); // if applicable show filter - pImpl->InitFilterList(); + m_xImpl->InitFilterList(); // set up initial filter sal_uInt16 nFilterCount = GetFilterCount(); OUString aAll = FpsResId( STR_FILTERNAME_ALL ); - bool bHasAll = pImpl->HasFilterListEntry( aAll ); - if ( pImpl->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) ) + bool bHasAll = m_xImpl->HasFilterListEntry( aAll ); + if ( m_xImpl->GetCurFilter() || nFilterCount == 1 || ( nFilterCount == 2 && bHasAll ) ) { // if applicable set the only filter or the only filter that // does not refer to all files, as the current one - if ( !pImpl->GetCurFilter() ) + if ( !m_xImpl->GetCurFilter() ) { sal_uInt16 nPos = 0; if ( 2 == nFilterCount && bHasAll ) @@ -1882,14 +1559,14 @@ bool SvtFileDialog::PrepareExecute() break; } } - SvtFileDialogFilter_Impl* pNewCurFilter = pImpl->m_aFilter[ nPos ].get(); - assert( pNewCurFilter && "SvtFileDialog::Execute: invalid filter pos!" ); - pImpl->SetCurFilter( pNewCurFilter, pNewCurFilter->GetName() ); + SvtFileDialogFilter_Impl* pNewCurFilter = m_xImpl->m_aFilter[ nPos ].get(); + assert( pNewCurFilter && "SvtFileDialog::run: invalid filter pos!" ); + m_xImpl->SetCurFilter( pNewCurFilter, pNewCurFilter->GetName() ); } // adjust view - pImpl->SelectFilterListEntry( pImpl->GetCurFilter()->GetName() ); - SetDefaultExt( pImpl->GetCurFilter()->GetExtension() ); + m_xImpl->SelectFilterListEntry( m_xImpl->GetCurFilter()->GetName() ); + SetDefaultExt( m_xImpl->GetCurFilter()->GetExtension() ); sal_Int32 nSepPos = GetDefaultExt().indexOf( FILEDIALOG_DEF_EXTSEP ); if ( nSepPos != -1 ) EraseDefaultExt( nSepPos ); @@ -1900,33 +1577,33 @@ bool SvtFileDialog::PrepareExecute() if ( !bHasAll ) { SvtFileDialogFilter_Impl* pAllFilter = implAddFilter( aAll, FILEDIALOG_FILTER_ALL ); - pImpl->InsertFilterListEntry( pAllFilter ); - pImpl->SetCurFilter( pAllFilter, aAll ); + m_xImpl->InsertFilterListEntry( pAllFilter ); + m_xImpl->SetCurFilter( pAllFilter, aAll ); } - pImpl->SelectFilterListEntry( aAll ); + m_xImpl->SelectFilterListEntry( aAll ); } // if applicable isolate filter OUString aFilter; - if ( !IsolateFilterFromPath_Impl( _aPath, aFilter ) ) + if ( !IsolateFilterFromPath_Impl( m_aPath, aFilter ) ) return false; AdjustFilterFlags nNewFilterFlags = adjustFilter( aFilter ); if ( nNewFilterFlags & ( AdjustFilterFlags::NonEmpty | AdjustFilterFlags::UserFilter ) ) { - pImpl->_pEdFileName->SetText( aFilter ); + m_xImpl->m_xEdFileName->set_entry_text( aFilter ); } // create and show instance for set path - INetURLObject aFolderURL( _aPath ); + INetURLObject aFolderURL( m_aPath ); OUString aFileName( aFolderURL.getName( INetURLObject::LAST_SEGMENT, false ) ); sal_Int32 nFileNameLen = aFileName.getLength(); bool bFileToSelect = nFileNameLen != 0; if ( bFileToSelect && aFileName[ nFileNameLen - 1 ] != '/' ) { OUString aDecodedName = aFolderURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); - pImpl->_pEdFileName->SetText( aDecodedName ); + m_xImpl->m_xEdFileName->set_entry_text( aDecodedName ); aFolderURL.removeSegment(); } @@ -1944,22 +1621,18 @@ bool SvtFileDialog::PrepareExecute() OpenURL_Impl( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - _pFileView->Show(); - _pSplitter->Show(); - // if applicable read and set size from ini InitSize(); return true; } - -void SvtFileDialog::executeAsync( ::svt::AsyncPickerAction::Action _eAction, - const OUString& _rURL, const OUString& _rFilter ) +void SvtFileDialog::executeAsync( ::svt::AsyncPickerAction::Action eAction, + const OUString& rURL, const OUString& rFilter ) { SAL_WARN_IF( m_pCurrentAsyncAction.is(), "fpicker.office", "SvtFileDialog::executeAsync: previous async action not yet finished!" ); - m_pCurrentAsyncAction = new AsyncPickerAction( this, _pFileView, _eAction ); + m_pCurrentAsyncAction = new AsyncPickerAction( this, m_xFileView.get(), eAction ); bool bReallyAsync = true; m_aConfiguration.getNodeValue( OUString( "FillAsynchronously" ) ) >>= bReallyAsync; @@ -1970,107 +1643,100 @@ void SvtFileDialog::executeAsync( ::svt::AsyncPickerAction::Action _eAction, m_aConfiguration.getNodeValue( OUString( "Timeout/Max" ) ) >>= nMaxTimeout; m_bInExecuteAsync = true; - m_pCurrentAsyncAction->execute( _rURL, _rFilter, bReallyAsync ? nMinTimeout : -1, nMaxTimeout, GetBlackList() ); + m_pCurrentAsyncAction->execute(rURL, rFilter, bReallyAsync ? nMinTimeout : -1, nMaxTimeout, GetBlackList()); m_bInExecuteAsync = false; } void SvtFileDialog::FileSelect() { - if ( _pFileNotifier ) - _pFileNotifier->notify( FILE_SELECTION_CHANGED, 0 ); + if (m_pFileNotifier) + m_pFileNotifier->notify( FILE_SELECTION_CHANGED, 0 ); } void SvtFileDialog::FilterSelect() { - if ( _pFileNotifier ) - _pFileNotifier->notify( CTRL_STATE_CHANGED, + if (m_pFileNotifier) + m_pFileNotifier->notify( CTRL_STATE_CHANGED, LISTBOX_FILTER ); } -void SvtFileDialog::SetStandardDir( const OUString& rStdDir ) - /* [Description] This method sets the path for the default button. */ - +void SvtFileDialog::SetStandardDir( const OUString& rStdDir ) { INetURLObject aObj( rStdDir ); SAL_WARN_IF( aObj.GetProtocol() == INetProtocol::NotValid, "fpicker.office", "Invalid protocol!" ); aObj.setFinalSlash(); - pImpl->SetStandardDir( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + m_xImpl->SetStandardDir( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); } void SvtFileDialog::SetBlackList( const css::uno::Sequence< OUString >& rBlackList ) { - pImpl->SetBlackList( rBlackList ); + m_xImpl->SetBlackList( rBlackList ); } const css::uno::Sequence< OUString >& SvtFileDialog::GetBlackList() const { - return pImpl->GetBlackList(); + return m_xImpl->GetBlackList(); } -const OUString& SvtFileDialog::GetStandardDir() const - /* [Description] This method returns the standard path. */ - +const OUString& SvtFileDialog::GetStandardDir() const { - return pImpl->GetStandardDir(); + return m_xImpl->GetStandardDir(); } void SvtFileDialog::PrevLevel_Impl() { - _pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); OUString sDummy; executeAsync( AsyncPickerAction::ePrevLevel, sDummy, sDummy ); } - void SvtFileDialog::OpenURL_Impl( const OUString& _rURL ) { - _pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); - executeAsync( AsyncPickerAction::eOpenURL, _rURL, getMostCurrentFilter( pImpl ) ); + executeAsync( AsyncPickerAction::eOpenURL, _rURL, getMostCurrentFilter( m_xImpl ) ); } - -SvtFileDialogFilter_Impl* SvtFileDialog::implAddFilter( const OUString& _rFilter, const OUString& _rType ) +SvtFileDialogFilter_Impl* SvtFileDialog::implAddFilter( const OUString& rFilter, const OUString& _rType ) { - SvtFileDialogFilter_Impl* pNewFilter = new SvtFileDialogFilter_Impl( _rFilter, _rType ); - pImpl->m_aFilter.push_front( std::unique_ptr<SvtFileDialogFilter_Impl>( pNewFilter ) ); + SvtFileDialogFilter_Impl* pNewFilter = new SvtFileDialogFilter_Impl( rFilter, _rType ); + m_xImpl->m_aFilter.push_front( std::unique_ptr<SvtFileDialogFilter_Impl>( pNewFilter ) ); - if ( !pImpl->GetCurFilter() ) - pImpl->SetCurFilter( pNewFilter, _rFilter ); + if ( !m_xImpl->GetCurFilter() ) + m_xImpl->SetCurFilter( pNewFilter, rFilter ); return pNewFilter; } - -void SvtFileDialog::AddFilter( const OUString& _rFilter, const OUString& _rType ) +void SvtFileDialog::AddFilter( const OUString& rFilter, const OUString& _rType ) { - SAL_WARN_IF( IsInExecute(), "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" ); - implAddFilter ( _rFilter, _rType ); + SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" ); + implAddFilter ( rFilter, _rType ); } -void SvtFileDialog::AddFilterGroup( const OUString& _rFilter, const Sequence< StringPair >& _rFilters ) +void SvtFileDialog::AddFilterGroup( const OUString& rFilter, const Sequence< StringPair >& rFilters ) { - SAL_WARN_IF( IsInExecute(), "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" ); + SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::AddFilter: currently executing!" ); - implAddFilter( _rFilter, OUString() ); - const StringPair* pSubFilters = _rFilters.getConstArray(); - const StringPair* pSubFiltersEnd = pSubFilters + _rFilters.getLength(); + implAddFilter( rFilter, OUString() ); + const StringPair* pSubFilters = rFilters.getConstArray(); + const StringPair* pSubFiltersEnd = pSubFilters + rFilters.getLength(); for ( ; pSubFilters != pSubFiltersEnd; ++pSubFilters ) implAddFilter( pSubFilters->First, pSubFilters->Second ); } @@ -2078,28 +1744,27 @@ void SvtFileDialog::AddFilterGroup( const OUString& _rFilter, const Sequence< St void SvtFileDialog::SetCurFilter( const OUString& rFilter ) { - SAL_WARN_IF( IsInExecute(), "fpicker.office", "SvtFileDialog::SetCurFilter: currently executing!" ); + SAL_WARN_IF( m_bIsInExecute, "fpicker.office", "SvtFileDialog::SetCurFilter: currently executing!" ); // look for corresponding filter - sal_uInt16 nPos = pImpl->m_aFilter.size(); + sal_uInt16 nPos = m_xImpl->m_aFilter.size(); while ( nPos-- ) { - SvtFileDialogFilter_Impl* pFilter = pImpl->m_aFilter[ nPos ].get(); + SvtFileDialogFilter_Impl* pFilter = m_xImpl->m_aFilter[ nPos ].get(); if ( pFilter->GetName() == rFilter ) { - pImpl->SetCurFilter( pFilter, rFilter ); + m_xImpl->SetCurFilter( pFilter, rFilter ); break; } } } - OUString SvtFileDialog::GetCurFilter() const { OUString aFilter; - const SvtFileDialogFilter_Impl* pCurrentFilter = pImpl->GetCurFilter(); + const SvtFileDialogFilter_Impl* pCurrentFilter = m_xImpl->GetCurFilter(); if ( pCurrentFilter ) aFilter = pCurrentFilter->GetName(); @@ -2111,66 +1776,56 @@ OUString SvtFileDialog::getCurFilter( ) const return GetCurFilter(); } - sal_uInt16 SvtFileDialog::GetFilterCount() const { - return pImpl->m_aFilter.size(); + return m_xImpl->m_aFilter.size(); } - const OUString& SvtFileDialog::GetFilterName( sal_uInt16 nPos ) const { assert( nPos < GetFilterCount() && "invalid index" ); - return pImpl->m_aFilter[ nPos ]->GetName(); + return m_xImpl->m_aFilter[ nPos ]->GetName(); } - void SvtFileDialog::InitSize() { - if ( pImpl->_aIniKey.isEmpty() ) + if (m_xImpl->m_aIniKey.isEmpty()) return; // initialize from config - SvtViewOptions aDlgOpt( EViewType::Dialog, pImpl->_aIniKey ); + SvtViewOptions aDlgOpt( EViewType::Dialog, m_xImpl->m_aIniKey ); if ( aDlgOpt.Exists() ) { - SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), osl_getThreadTextEncoding())); + m_xDialog->set_window_state(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_UTF8)); Any aUserData = aDlgOpt.GetUserItem( "UserData"); OUString sCfgStr; if ( aUserData >>= sCfgStr ) - _pFileView->SetConfigString( sCfgStr ); + m_xFileView->SetConfigString( sCfgStr ); } } - std::vector<OUString> SvtFileDialog::GetPathList() const { std::vector<OUString> aList; - sal_uLong nCount = _pFileView->GetSelectionCount(); - SvTreeListEntry* pEntry = nCount ? _pFileView->FirstSelected() : nullptr; - if ( ! pEntry ) + m_xFileView->selected_foreach([this, &aList](weld::TreeIter& rCurEntry){ + aList.push_back(m_xFileView->GetURL(rCurEntry)); + return false; + }); + + if (aList.empty()) { - if ( !pImpl->_pEdFileName->GetText().isEmpty() && _bIsInExecute ) - aList.push_back(pImpl->_pEdFileName->GetURL()); + if ( !m_xImpl->m_xEdFileName->get_active_text().isEmpty() && m_bIsInExecute ) + aList.push_back(m_xImpl->m_xEdFileName->GetURL()); else - aList.push_back(_aPath); - } - else - { - while ( pEntry ) - { - aList.push_back(SvtFileView::GetURL(pEntry)); - pEntry = _pFileView->NextSelected( pEntry ); - } + aList.push_back(m_aPath); } return aList; } - bool SvtFileDialog::IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter ) { OUString aReversePath = comphelper::string::reverseString(rPath); @@ -2240,164 +1895,138 @@ bool SvtFileDialog::IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilt return true; } - -void SvtFileDialog::implUpdateImages( ) +IMPL_LINK_NOARG(SvtFileDialog, SizeAllocHdl, const Size&, void) { - // set the appropriate images on the buttons - if ( pImpl->_pBtnUp ) - pImpl->_pBtnUp->SetModeImage( GetButtonImage( BMP_FILEDLG_BTN_UP ) ); - - if ( pImpl->_pBtnNewFolder ) - pImpl->_pBtnNewFolder->SetModeImage( GetButtonImage( BMP_FILEDLG_CREATEFOLDER ) ); + if (m_pFileNotifier) + m_pFileNotifier->notify(DIALOG_SIZE_CHANGED, 0); } - -void SvtFileDialog::DataChanged( const DataChangedEvent& _rDCEvt ) +weld::Widget* SvtFileDialog::getControl( sal_Int16 nControlId, bool bLabelControl ) const { - if ( DataChangedEventType::SETTINGS == _rDCEvt.GetType() ) - implUpdateImages( ); - - Dialog::DataChanged( _rDCEvt ); -} + weld::Widget* pReturn = nullptr; - -void SvtFileDialog::Resize() -{ - Dialog::Resize(); - - if ( IsRollUp() ) - return; - - if ( _pFileNotifier ) - _pFileNotifier->notify( DIALOG_SIZE_CHANGED, 0 ); -} - -Control* SvtFileDialog::getControl( sal_Int16 _nControlId, bool _bLabelControl ) const -{ - Control* pReturn = nullptr; - - switch ( _nControlId ) + switch ( nControlId ) { case CONTROL_FILEVIEW: - pReturn = _bLabelControl ? nullptr : static_cast< Control* >( _pFileView ); + pReturn = bLabelControl ? nullptr : m_xFileView->identifier(); break; case EDIT_FILEURL: - pReturn = _bLabelControl - ? static_cast< Control* >( pImpl->_pFtFileName ) - : static_cast< Control* >( pImpl->_pEdFileName ); + pReturn = bLabelControl + ? static_cast<weld::Widget*>(m_xImpl->m_xFtFileName.get()) + : static_cast<weld::Widget*>(m_xImpl->m_xEdFileName->getWidget()); break; case EDIT_FILEURL_LABEL: - pReturn = pImpl->_pFtFileName; + pReturn = m_xImpl->m_xFtFileName.get(); break; case CHECKBOX_AUTOEXTENSION: - pReturn = pImpl->_pCbAutoExtension; + pReturn = m_xImpl->m_xCbAutoExtension.get(); break; case CHECKBOX_PASSWORD: - pReturn = pImpl->_pCbPassword; + pReturn = m_xImpl->m_xCbPassword.get(); break; case CHECKBOX_GPGENCRYPTION: - pReturn = pImpl->_pCbGPGEncrypt; + pReturn = m_xImpl->m_xCbGPGEncrypt.get(); break; case CHECKBOX_FILTEROPTIONS: - pReturn = pImpl->_pCbOptions; + pReturn = m_xImpl->m_xCbOptions.get(); break; case CHECKBOX_READONLY: - pReturn = _pCbReadOnly; + pReturn = m_xCbReadOnly.get(); break; case CHECKBOX_LINK: - pReturn = _pCbLinkBox; + pReturn = m_xCbLinkBox.get(); break; case CHECKBOX_PREVIEW: - pReturn = _pCbPreviewBox; + pReturn = m_xCbPreviewBox.get(); break; case CHECKBOX_SELECTION: - pReturn = _pCbSelection; + pReturn = m_xCbSelection.get(); break; case LISTBOX_FILTER: - pReturn = _bLabelControl ? pImpl->_pFtFileType : pImpl->GetFilterListControl(); + pReturn = bLabelControl ? m_xImpl->m_xFtFileType.get() : m_xImpl->GetFilterListControl(); break; case LISTBOX_FILTER_LABEL: - pReturn = pImpl->_pFtFileType; + pReturn = m_xImpl->m_xFtFileType.get(); break; case FIXEDTEXT_CURRENTFOLDER: - pReturn = pImpl->_pEdCurrentPath; + pReturn = m_xImpl->m_xEdCurrentPath->getWidget(); break; case LISTBOX_VERSION: - pReturn = _bLabelControl - ? static_cast< Control* >( pImpl->_pFtFileVersion ) - : static_cast< Control* >( pImpl->_pLbFileVersion ); + pReturn = bLabelControl + ? static_cast<weld::Widget*>(m_xImpl->m_xFtFileVersion.get()) + : static_cast<weld::Widget*>(m_xImpl->m_xLbFileVersion.get()); break; case LISTBOX_TEMPLATE: - pReturn = _bLabelControl - ? static_cast< Control* >( pImpl->_pFtTemplates ) - : static_cast< Control* >( pImpl->_pLbTemplates ); + pReturn = bLabelControl + ? static_cast<weld::Widget*>(m_xImpl->m_xFtTemplates.get()) + : static_cast<weld::Widget*>(m_xImpl->m_xLbTemplates.get()); break; case LISTBOX_IMAGE_TEMPLATE: - pReturn = _bLabelControl - ? static_cast< Control* >( pImpl->_pFtImageTemplates ) - : static_cast< Control* >( pImpl->_pLbImageTemplates ); + pReturn = bLabelControl + ? static_cast<weld::Widget*>(m_xImpl->m_xFtImageTemplates.get()) + : static_cast<weld::Widget*>(m_xImpl->m_xLbImageTemplates.get()); break; case LISTBOX_IMAGE_ANCHOR: - pReturn = _bLabelControl - ? static_cast< Control* >( pImpl->_pFtImageAnchor ) - : static_cast< Control* >( pImpl->_pLbImageAnchor ); + pReturn = bLabelControl + ? static_cast<weld::Widget*>(m_xImpl->m_xFtImageAnchor.get()) + : static_cast<weld::Widget*>(m_xImpl->m_xLbImageAnchor.get()); break; case LISTBOX_VERSION_LABEL: - pReturn = pImpl->_pFtFileVersion; + pReturn = m_xImpl->m_xFtFileVersion.get(); break; case LISTBOX_TEMPLATE_LABEL: - pReturn = pImpl->_pFtTemplates; + pReturn = m_xImpl->m_xFtTemplates.get(); break; case LISTBOX_IMAGE_TEMPLATE_LABEL: - pReturn = pImpl->_pFtImageTemplates; + pReturn = m_xImpl->m_xFtImageTemplates.get(); break; case LISTBOX_IMAGE_ANCHOR_LABEL: - pReturn = pImpl->_pFtImageAnchor; + pReturn = m_xImpl->m_xFtImageAnchor.get(); break; case PUSHBUTTON_OK: - pReturn = pImpl->_pBtnFileOpen; + pReturn = m_xImpl->m_xBtnFileOpen.get(); break; case PUSHBUTTON_CANCEL: - pReturn = pImpl->_pBtnCancel; + pReturn = m_xImpl->m_xBtnCancel.get(); break; case PUSHBUTTON_PLAY: - pReturn = _pPbPlay; + pReturn = m_xPbPlay.get(); break; case PUSHBUTTON_HELP: - pReturn = pImpl->_pBtnHelp; + pReturn = m_xImpl->m_xBtnHelp.get(); break; case TOOLBOXBUTOON_LEVEL_UP: - pReturn = pImpl->_pBtnUp; + pReturn = m_xImpl->m_xBtnUp->getWidget(); break; case TOOLBOXBUTOON_NEW_FOLDER: - pReturn = pImpl->_pBtnNewFolder; + pReturn = m_xImpl->m_xBtnNewFolder.get(); break; case LISTBOX_FILTER_SELECTOR: @@ -2410,170 +2039,147 @@ Control* SvtFileDialog::getControl( sal_Int16 _nControlId, bool _bLabelControl ) return pReturn; } - -void SvtFileDialog::enableControl( sal_Int16 _nControlId, bool _bEnable ) +void SvtFileDialog::enableControl(sal_Int16 nControlId, bool bEnable) { - Control* pControl = getControl( _nControlId ); - if ( pControl ) - EnableControl( pControl, _bEnable ); - Control* pLabel = getControl( _nControlId, true ); - if ( pLabel ) - EnableControl( pLabel, _bEnable ); + weld::Widget* pControl = getControl(nControlId); + if (pControl) + EnableControl(pControl, bEnable); + weld::Widget* pLabel = getControl(nControlId, true); + if (pLabel) + EnableControl(pLabel, bEnable); } - void SvtFileDialog::AddControls_Impl( ) { // create the "insert as link" checkbox, if needed - if ( _nPickerFlags & PickerFlags::InsertAsLink ) + if ( m_nPickerFlags & PickerFlags::InsertAsLink ) { - _pCbLinkBox ->SetText( FpsResId( STR_SVT_FILEPICKER_INSERT_AS_LINK ) ); - _pCbLinkBox ->SetHelpId( HID_FILEDLG_LINK_CB ); - _pCbLinkBox->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - _pCbLinkBox->Show(); + m_xCbLinkBox->set_label( FpsResId( STR_SVT_FILEPICKER_INSERT_AS_LINK ) ); + m_xCbLinkBox->set_help_id( HID_FILEDLG_LINK_CB ); + m_xCbLinkBox->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xCbLinkBox->show(); } // create the "show preview" checkbox ( and the preview window, too ), if needed - if ( _nPickerFlags & PickerFlags::ShowPreview ) + if ( m_nPickerFlags & PickerFlags::ShowPreview ) { - pImpl->_aIniKey = "ImportGraphicDialog"; - // because the "<All Formats> (*.bmp,*...)" entry is too wide, - // we need to disable the auto width feature of the filter box - pImpl->DisableFilterBoxAutoWidth(); + m_xImpl->m_aIniKey = "ImportGraphicDialog"; // "preview" - _pCbPreviewBox->SetText( FpsResId( STR_SVT_FILEPICKER_SHOW_PREVIEW ) ); - _pCbPreviewBox->SetHelpId( HID_FILEDLG_PREVIEW_CB ); - _pCbPreviewBox->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - _pCbPreviewBox->Show(); + m_xCbPreviewBox->set_label( FpsResId( STR_SVT_FILEPICKER_SHOW_PREVIEW ) ); + m_xCbPreviewBox->set_help_id( HID_FILEDLG_PREVIEW_CB ); + m_xCbPreviewBox->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xCbPreviewBox->show(); // generate preview window just here - _pPrevWin->SetOutputSizePixel(Size(200, 300)); - _pPrevWin->Show(); - - _pPrevBmp = VclPtr<FixedBitmap>::Create( _pPrevWin, WB_BORDER ); - _pPrevBmp->SetBackground( Wallpaper( COL_WHITE ) ); - _pPrevBmp->SetSizePixel(_pPrevWin->GetSizePixel()); - _pPrevBmp->Show(); - _pPrevBmp->SetAccessibleName(FpsResId(STR_PREVIEW)); + m_aPreviewSize = Size(200, 300); + m_xPrevBmp->set_size_request(m_aPreviewSize.Width(), m_aPreviewSize.Height()); + m_xPrevBmp->connect_size_allocate(LINK(this, SvtFileDialog, PreviewSizeAllocHdl)); + m_xPreviewFrame->show(); + m_xPrevBmp->set_accessible_name(FpsResId(STR_PREVIEW)); } - if ( _nPickerFlags & PickerFlags::AutoExtension ) + if ( m_nPickerFlags & PickerFlags::AutoExtension ) { - pImpl->_pCbAutoExtension->SetText( FpsResId( STR_SVT_FILEPICKER_AUTO_EXTENSION ) ); - pImpl->_pCbAutoExtension->Check(); - pImpl->_pCbAutoExtension->SetClickHdl( LINK( this, SvtFileDialog, AutoExtensionHdl_Impl ) ); - pImpl->_pCbAutoExtension->Show(); + m_xImpl->m_xCbAutoExtension->set_label( FpsResId( STR_SVT_FILEPICKER_AUTO_EXTENSION ) ); + m_xImpl->m_xCbAutoExtension->set_active(true); + m_xImpl->m_xCbAutoExtension->connect_clicked( LINK( this, SvtFileDialog, AutoExtensionHdl_Impl ) ); + m_xImpl->m_xCbAutoExtension->show(); } - if ( _nPickerFlags & PickerFlags::FilterOptions ) + if ( m_nPickerFlags & PickerFlags::FilterOptions ) { - pImpl->_pCbOptions->SetText( FpsResId( STR_SVT_FILEPICKER_FILTER_OPTIONS ) ); - pImpl->_pCbOptions->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - pImpl->_pCbOptions->Show(); + m_xImpl->m_xCbOptions->set_label( FpsResId( STR_SVT_FILEPICKER_FILTER_OPTIONS ) ); + m_xImpl->m_xCbOptions->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xImpl->m_xCbOptions->show(); } - if ( _nPickerFlags & PickerFlags::Selection ) + if ( m_nPickerFlags & PickerFlags::Selection ) { - _pCbSelection->SetText( FpsResId( STR_SVT_FILEPICKER_SELECTION ) ); - _pCbSelection->SetClickHdl( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); - _pCbSelection->Show(); + m_xCbSelection->set_label( FpsResId( STR_SVT_FILEPICKER_SELECTION ) ); + m_xCbSelection->connect_clicked( LINK( this, SvtFileDialog, ClickHdl_Impl ) ); + m_xCbSelection->show(); } - if ( _nPickerFlags & PickerFlags::PlayButton ) + if ( m_nPickerFlags & PickerFlags::PlayButton ) { - _pPbPlay->SetText( FpsResId( STR_SVT_FILEPICKER_PLAY ) ); - _pPbPlay->SetHelpId( HID_FILESAVE_DOPLAY ); - _pPbPlay->SetClickHdl( LINK( this, SvtFileDialog, PlayButtonHdl_Impl ) ); - _pPbPlay->Show(); + m_xPbPlay->set_label( FpsResId( STR_SVT_FILEPICKER_PLAY ) ); + m_xPbPlay->set_help_id( HID_FILESAVE_DOPLAY ); + m_xPbPlay->connect_clicked( LINK( this, SvtFileDialog, PlayButtonHdl_Impl ) ); + m_xPbPlay->show(); } - if ( _nPickerFlags & PickerFlags::ShowVersions ) + if ( m_nPickerFlags & PickerFlags::ShowVersions ) { - pImpl->_pFtFileVersion->SetText( FpsResId( STR_SVT_FILEPICKER_VERSION ) ); - pImpl->_pFtFileVersion->Show(); + m_xImpl->m_xFtFileVersion->set_label( FpsResId( STR_SVT_FILEPICKER_VERSION ) ); + m_xImpl->m_xFtFileVersion->show(); - pImpl->_pLbFileVersion->SetHelpId( HID_FILEOPEN_VERSION ); - pImpl->_pLbFileVersion->Show(); + m_xImpl->m_xLbFileVersion->set_help_id( HID_FILEOPEN_VERSION ); + m_xImpl->m_xLbFileVersion->show(); } - else if ( _nPickerFlags & PickerFlags::Templates ) + else if ( m_nPickerFlags & PickerFlags::Templates ) { - pImpl->_pFtTemplates->SetText( FpsResId( STR_SVT_FILEPICKER_TEMPLATES ) ); - pImpl->_pFtTemplates->Show(); + m_xImpl->m_xFtTemplates->set_label( FpsResId( STR_SVT_FILEPICKER_TEMPLATES ) ); + m_xImpl->m_xFtTemplates->show(); - pImpl->_pLbTemplates->SetHelpId( HID_FILEOPEN_VERSION ); - pImpl->_pLbTemplates->Show(); - // This is strange. During the re-factoring during 96930, I discovered that this help id - // is set in the "Templates mode". This was hidden in the previous implementation. - // Shouldn't this be a more meaningful help id. + m_xImpl->m_xLbTemplates->set_help_id( HID_FILEOPEN_VERSION ); + m_xImpl->m_xLbTemplates->show(); + // This is strange. During the re-factoring during 96930, I discovered that this help id + // is set in the "Templates mode". This was hidden in the previous implementation. + // Shouldn't this be a more meaningful help id. } - else if ( _nPickerFlags & PickerFlags::ImageTemplate ) + else if ( m_nPickerFlags & PickerFlags::ImageTemplate ) { - pImpl->_pFtImageTemplates->SetText( FpsResId( STR_SVT_FILEPICKER_IMAGE_TEMPLATE ) ); - pImpl->_pFtImageTemplates->Show(); + m_xImpl->m_xFtImageTemplates->set_label( FpsResId( STR_SVT_FILEPICKER_IMAGE_TEMPLATE ) ); + m_xImpl->m_xFtImageTemplates->show(); - pImpl->_pLbImageTemplates->SetHelpId( HID_FILEOPEN_IMAGE_TEMPLATE ); - pImpl->_pLbImageTemplates->Show(); + m_xImpl->m_xLbImageTemplates->set_help_id( HID_FILEOPEN_IMAGE_TEMPLATE ); + m_xImpl->m_xLbImageTemplates->show(); } - else if ( _nPickerFlags & PickerFlags::ImageAnchor ) + else if ( m_nPickerFlags & PickerFlags::ImageAnchor ) { - pImpl->_pFtImageAnchor->SetText( FpsResId( STR_SVT_FILEPICKER_IMAGE_ANCHOR ) ); - pImpl->_pFtImageAnchor->Show(); + m_xImpl->m_xFtImageAnchor->set_label( FpsResId( STR_SVT_FILEPICKER_IMAGE_ANCHOR ) ); + m_xImpl->m_xFtImageAnchor->show(); - pImpl->_pLbImageAnchor->SetHelpId( HID_FILEOPEN_IMAGE_ANCHOR ); - pImpl->_pLbImageAnchor->Show(); + m_xImpl->m_xLbImageAnchor->set_help_id( HID_FILEOPEN_IMAGE_ANCHOR ); + m_xImpl->m_xLbImageAnchor->show(); } - pImpl->_pPlaces = VclPtr<PlacesListBox>::Create(_pContainer, this, FpsResId(STR_PLACES_TITLE), WB_BORDER); - pImpl->_pPlaces->SetHelpId("SVT_HID_FILESAVE_PLACES_LISTBOX"); - Size aSize(LogicToPixel(Size(50, 85), MapMode(MapUnit::MapAppFont))); - pImpl->_pPlaces->set_height_request(aSize.Height()); - pImpl->_pPlaces->set_width_request(aSize.Width()); - pImpl->_pPlaces->SetSizePixel(aSize); - pImpl->_pPlaces->Show(); - - sal_Int32 nPosX = pImpl->_pPlaces->GetSizePixel().Width(); - _pSplitter->SetPosPixel(Point(nPosX, 0)); - nPosX += _pSplitter->GetSizePixel().Width(); - _pFileView->SetPosPixel(Point(nPosX, 0)); - - pImpl->_pPlaces->SetAddHdl( LINK ( this, SvtFileDialog, AddPlacePressed_Hdl ) ); - pImpl->_pPlaces->SetDelHdl( LINK ( this, SvtFileDialog, RemovePlacePressed_Hdl ) ); + m_xImpl->m_xPlaces.reset(new PlacesListBox(m_xBuilder->weld_tree_view("places"), + m_xBuilder->weld_button("add"), + m_xBuilder->weld_button("del"), + this)); + m_xImpl->m_xPlaces->set_help_id("SVT_HID_FILESAVE_PLACES_LISTBOX"); + m_xImpl->m_xPlaces->SetAddHdl( LINK ( this, SvtFileDialog, AddPlacePressed_Hdl ) ); + m_xImpl->m_xPlaces->SetDelHdl( LINK ( this, SvtFileDialog, RemovePlacePressed_Hdl ) ); initDefaultPlaces(); } - -sal_Int32 SvtFileDialog::getTargetColorDepth() +IMPL_LINK(SvtFileDialog, PreviewSizeAllocHdl, const Size&, rSize, void) { - if ( _pPrevBmp ) - return _pPrevBmp->GetBitCount(); - else - return 0; + m_aPreviewSize = rSize; } - sal_Int32 SvtFileDialog::getAvailableWidth() { - if ( _pPrevBmp ) - return _pPrevBmp->GetOutputSizePixel().Width(); + if (m_xPrevBmp) + return m_aPreviewSize.Width(); else return 0; } - sal_Int32 SvtFileDialog::getAvailableHeight() { - if ( _pPrevBmp ) - return _pPrevBmp->GetOutputSizePixel().Height(); + if (m_xPrevBmp) + return m_aPreviewSize.Height(); else return 0; } - -void SvtFileDialog::setImage( const Any& rImage ) +void SvtFileDialog::setImage(const Any& rImage) { - if ( ! _pPrevBmp || ! _pPrevBmp->IsVisible() ) + if (!m_xPrevBmp || !m_xPreviewFrame->get_visible()) return; Sequence < sal_Int8 > aBmpSequence; @@ -2586,46 +2192,41 @@ void SvtFileDialog::setImage( const Any& rImage ) StreamMode::READ ); ReadDIBBitmapEx(aBmp, aData); - _pPrevBmp->SetBitmap( aBmp ); + m_xPrevBmp->set_image(Graphic(aBmp).GetXGraphic()); } else { - BitmapEx aEmpty; - _pPrevBmp->SetBitmap( aEmpty ); + m_xPrevBmp->set_image(nullptr); } } - OUString SvtFileDialog::getCurrentFileText( ) const { OUString sReturn; - if ( pImpl && pImpl->_pEdFileName ) - sReturn = pImpl->_pEdFileName->GetText(); + if (m_xImpl && m_xImpl->m_xEdFileName) + sReturn = m_xImpl->m_xEdFileName->get_active_text(); return sReturn; } - -void SvtFileDialog::setCurrentFileText( const OUString& _rText, bool _bSelectAll ) +void SvtFileDialog::setCurrentFileText( const OUString& _rText, bool m_bSelectAll ) { - if ( pImpl && pImpl->_pEdFileName ) + if (m_xImpl && m_xImpl->m_xEdFileName) { - pImpl->_pEdFileName->SetText( _rText ); - if ( _bSelectAll ) - pImpl->_pEdFileName->SetSelection( Selection( 0, _rText.getLength() ) ); + m_xImpl->m_xEdFileName->set_entry_text( _rText ); + if ( m_bSelectAll ) + m_xImpl->m_xEdFileName->select_entry_region(0, -1); } } - bool SvtFileDialog::isAutoExtensionEnabled() const { - return pImpl->_pCbAutoExtension && pImpl->_pCbAutoExtension->IsChecked(); + return m_xImpl->m_xCbAutoExtension && m_xImpl->m_xCbAutoExtension->get_active(); } - bool SvtFileDialog::getShowState() { - if ( _pPrevBmp ) - return _pPrevBmp->IsVisible(); + if (m_xPreviewFrame) + return m_xPreviewFrame->get_visible(); else return false; } @@ -2664,15 +2265,15 @@ bool SvtFileDialog::ContentGetTitle( const OUString& rURL, OUString& rTitle ) return m_aContent.isValid(); } -void SvtFileDialog::appendDefaultExtension(OUString& _rFileName, - const OUString& _rFilterDefaultExtension, - const OUString& _rFilterExtensions) +void SvtFileDialog::appendDefaultExtension(OUString& rFileName, + const OUString& rFilterDefaultExtension, + const OUString& rFilterExtensions) { - const OUString aType(_rFilterExtensions.toAsciiLowerCase()); + const OUString aType(rFilterExtensions.toAsciiLowerCase()); if ( aType != FILEDIALOG_FILTER_ALL ) { - const OUString aTemp(_rFileName.toAsciiLowerCase()); + const OUString aTemp(rFileName.toAsciiLowerCase()); sal_Int32 nPos = 0; do @@ -2687,54 +2288,27 @@ void SvtFileDialog::appendDefaultExtension(OUString& _rFileName, } while (nPos>=0); - _rFileName += "." + _rFilterDefaultExtension; + rFileName += "." + rFilterDefaultExtension; } } void SvtFileDialog::initDefaultPlaces( ) { PlacePtr pRootPlace( new Place( FpsResId(STR_DEFAULT_DIRECTORY), GetStandardDir() ) ); - pImpl->_pPlaces->AppendPlace( pRootPlace ); + m_xImpl->m_xPlaces->AppendPlace( pRootPlace ); // Load from user settings - Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context)); - Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context)); + Sequence< OUString > placesUrlsList(officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_xContext)); + Sequence< OUString > placesNamesList(officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_xContext)); for(sal_Int32 nPlace = 0; nPlace < placesUrlsList.getLength() && nPlace < placesNamesList.getLength(); ++nPlace) { PlacePtr pPlace(new Place(placesNamesList[nPlace], placesUrlsList[nPlace], true)); - pImpl->_pPlaces->AppendPlace(pPlace); + m_xImpl->m_xPlaces->AppendPlace(pPlace); } // Reset the placesList "updated" state - pImpl->_pPlaces->IsUpdated(); -} - -IMPL_LINK_NOARG( SvtFileDialog, Split_Hdl, Splitter*, void ) -{ - sal_Int32 nSplitPos = _pSplitter->GetSplitPosPixel(); - - // Resize the places list - sal_Int32 nPlaceX = pImpl->_pPlaces->GetPosPixel( ).X(); - Size placeSize = pImpl->_pPlaces->GetSizePixel( ); - placeSize.setWidth( nSplitPos - nPlaceX ); - pImpl->_pPlaces->SetSizePixel( placeSize ); - - // Change Pos and size of the fileview - Point fileViewPos = _pFileView->GetPosPixel(); - sal_Int32 nOldX = fileViewPos.X(); - sal_Int32 nNewX = nSplitPos + _pSplitter->GetSizePixel().Width(); - fileViewPos.setX( nNewX ); - Size fileViewSize = _pFileView->GetSizePixel(); - fileViewSize.AdjustWidth( -( nNewX - nOldX ) ); - _pFileView->SetPosSizePixel( fileViewPos, fileViewSize ); - - _pSplitter->SetPosPixel( Point( placeSize.Width(), _pSplitter->GetPosPixel().Y() ) ); -} - -Image SvtFileDialog::GetButtonImage(const OUString& rButtonId) -{ - return Image(StockImage::Yes, rButtonId); + m_xImpl->m_xPlaces->IsUpdated(); } QueryFolderNameDialog::QueryFolderNameDialog(weld::Window* _pParent, |