basctl/source/basicide/moduldl2.cxx | 4 basctl/source/basicide/moduldlg.cxx | 4 basctl/source/inc/bastype2.hxx | 9 cui/source/customize/CommandCategoryListBox.cxx | 4 cui/source/options/optgdlg.cxx | 2 dbaccess/source/ui/dlg/indexdialog.cxx | 4 fpicker/Library_fps_office.mk | 2 fpicker/UIConfig_fps.mk | 1 fpicker/inc/bitmaps.hlst | 2 fpicker/inc/strings.hrc | 1 fpicker/source/office/OfficeControlAccess.cxx | 296 ++-- fpicker/source/office/OfficeControlAccess.hxx | 59 fpicker/source/office/OfficeFilePicker.cxx | 131 -- fpicker/source/office/OfficeFilePicker.hxx | 4 fpicker/source/office/OfficeFolderPicker.cxx | 30 fpicker/source/office/OfficeFolderPicker.hxx | 2 fpicker/source/office/PlacesListBox.cxx | 183 -- fpicker/source/office/PlacesListBox.hxx | 100 - fpicker/source/office/RemoteFilesDialog.cxx | 795 +++--------- fpicker/source/office/RemoteFilesDialog.hxx | 78 - fpicker/source/office/asyncfilepicker.hxx | 5 fpicker/source/office/autocmpledit.cxx | 41 fpicker/source/office/autocmpledit.hxx | 26 fpicker/source/office/breadcrumb.cxx | 164 -- fpicker/source/office/breadcrumb.hxx | 62 fpicker/source/office/commonpicker.cxx | 107 - fpicker/source/office/commonpicker.hxx | 8 fpicker/source/office/contentenumeration.hxx | 6 fpicker/source/office/fileview.cxx | 1204 ++++++++---------- fpicker/source/office/fileview.hxx | 53 fpicker/source/office/foldertree.cxx | 110 - fpicker/source/office/foldertree.hxx | 26 fpicker/source/office/fpdialogbase.hxx | 11 fpicker/source/office/iodlg.cxx | 1568 ++++++++---------------- fpicker/source/office/iodlg.hxx | 131 -- fpicker/source/office/iodlgimp.cxx | 186 -- fpicker/source/office/iodlgimp.hxx | 232 +-- fpicker/source/office/pickercallbacks.hxx | 14 fpicker/uiconfig/ui/breadcrumb.ui | 32 fpicker/uiconfig/ui/explorerfiledialog.ui | 498 ++++++- fpicker/uiconfig/ui/remotefilesdialog.ui | 319 ++++ include/svtools/imagemgr.hxx | 1 include/svtools/inettbc.hxx | 10 include/svtools/strings.hrc | 11 include/vcl/treelistbox.hxx | 1 include/vcl/weld.hxx | 95 + solenv/clang-format/blacklist | 8 solenv/sanitizers/ui/fps.suppr | 9 svtools/source/control/inettbc.cxx | 39 svtools/source/misc/imagemgr.cxx | 17 sw/source/ui/frmdlg/frmpage.cxx | 2 vcl/Library_vcl.mk | 2 vcl/inc/iconview.hxx | 2 vcl/inc/treeglue.hxx | 24 vcl/source/app/salvtables.cxx | 313 ++++ vcl/source/treelist/iconview.cxx | 15 vcl/source/treelist/iconviewimpl.cxx | 4 vcl/source/window/builder.cxx | 24 vcl/unx/gtk3/gtk3gtkinst.cxx | 496 +++++++ 59 files changed, 4005 insertions(+), 3582 deletions(-)
New commits: commit 09e3d45cdc5c739e5246388a83ccfc6d76bf66e9 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Oct 21 14:20:12 2019 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Oct 29 13:58:47 2019 +0100 weld fpicker cluster Change-Id: I6566263809ff0032388a0b56571f0cf7428058d7 Reviewed-on: https://gerrit.libreoffice.org/81334 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 2673658205b7..c2633699b66a 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -228,8 +228,8 @@ LibPage::LibPage(weld::Container* pParent, OrganizeDialog* pDialog) m_xBasicsBox->connect_changed( LINK( this, LibPage, BasicSelectHdl ) ); - m_xLibBox->connect_editing_started( LINK( this, LibPage, EditingEntryHdl ) ); - m_xLibBox->connect_editing_done( LINK( this, LibPage, EditedEntryHdl ) ); + m_xLibBox->connect_editing(LINK(this, LibPage, EditingEntryHdl), + LINK(this, LibPage, EditedEntryHdl)); FillListBox(); m_xBasicsBox->set_active(0); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index fb1d72e2d161..0812647911f0 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -557,8 +557,8 @@ ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMod m_xDropTarget.reset(new SbTreeListBoxDropTarget(*m_xBasicBox)); - m_xBasicBox->connect_editing_started( LINK( this, ObjectPage, EditingEntryHdl ) ); - m_xBasicBox->connect_editing_done( LINK( this, ObjectPage, EditedEntryHdl ) ); + m_xBasicBox->connect_editing(LINK(this, ObjectPage, EditingEntryHdl), + LINK(this, ObjectPage, EditedEntryHdl)); m_xBasicBox->SetMode( nMode ); m_xBasicBox->ScanAllEntries(); diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx index 88c303e3f5d1..d6abc4414453 100644 --- a/basctl/source/inc/bastype2.hxx +++ b/basctl/source/inc/bastype2.hxx @@ -320,13 +320,10 @@ public: float get_approximate_digit_width() const { return m_xControl->get_approximate_digit_width(); } int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); } int get_iter_index_in_parent(const weld::TreeIter& rIter) const { return m_xControl->get_iter_index_in_parent(rIter); } - void connect_editing_started(const Link<const weld::TreeIter&, bool>& rLink) + void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink, + const Link<const std::pair<const weld::TreeIter&, OUString>&, bool>& rEndLink) { - m_xControl->connect_editing_started(rLink); - } - void connect_editing_done(const Link<const std::pair<const weld::TreeIter&, OUString>&, bool>& rLink) - { - m_xControl->connect_editing_done(rLink); + m_xControl->connect_editing(rStartLink, rEndLink); } void make_sorted() { m_xControl->make_sorted(); }; diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx index 1df6422db190..a5c572e6a935 100644 --- a/cui/source/customize/CommandCategoryListBox.cxx +++ b/cui/source/customize/CommandCategoryListBox.cxx @@ -137,7 +137,7 @@ void CommandCategoryListBox::Init( } // Separate the "All commands"category from the actual categories - m_xControl->append_separator(); + m_xControl->append_separator(""); typedef std::pair<OUString, sal_Int16> str_id; std::vector<str_id> aCategories; @@ -180,7 +180,7 @@ void CommandCategoryListBox::Init( } // Separate regular commands from styles and macros - m_xControl->append_separator(); + m_xControl->append_separator(""); // Add macros category m_aGroupInfo.push_back( diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 3c039792ec57..3079b2c92c2c 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -667,7 +667,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p m_xIconStyleLB->append_text(entryForAuto); // separate auto and other icon themes - m_xIconStyleLB->append_separator(); + m_xIconStyleLB->append_separator(""); for (auto const& installIconTheme : mInstalledIconThemes) m_xIconStyleLB->append_text(installIconTheme.GetDisplayName()); diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx index 072c507e4da7..a4e75d116ac9 100644 --- a/dbaccess/source/ui/dlg/indexdialog.cxx +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -98,8 +98,8 @@ namespace dbaui m_xActions->connect_clicked(LINK(this, DbaIndexDialog, OnIndexAction)); m_xIndexList->connect_changed(LINK(this, DbaIndexDialog, OnIndexSelected)); - m_xIndexList->connect_editing_started(LINK(this, DbaIndexDialog, OnEntryEditing)); - m_xIndexList->connect_editing_done(LINK(this, DbaIndexDialog, OnEntryEdited)); + m_xIndexList->connect_editing(LINK(this, DbaIndexDialog, OnEntryEditing), + LINK(this, DbaIndexDialog, OnEntryEdited)); m_xFields->SetSizePixel(Size(nWidth, 100)); m_xFields->Init(_rFieldNames, ::dbtools::getBooleanDataSourceSetting( m_xConnection, "AddIndexAppendix" )); diff --git a/fpicker/Library_fps_office.mk b/fpicker/Library_fps_office.mk index eff3f5ebe84f..3aec0b66906e 100644 --- a/fpicker/Library_fps_office.mk +++ b/fpicker/Library_fps_office.mk @@ -52,8 +52,6 @@ $(eval $(call gb_Library_add_exception_objects,fps_office,\ fpicker/source/office/fpinteraction \ fpicker/source/office/fpsmartcontent \ fpicker/source/office/fps_office \ - fpicker/source/office/iconview \ - fpicker/source/office/iconviewimpl \ fpicker/source/office/iodlg \ fpicker/source/office/iodlgimp \ fpicker/source/office/OfficeControlAccess \ diff --git a/fpicker/UIConfig_fps.mk b/fpicker/UIConfig_fps.mk index ee8fea50d663..2c179b296481 100644 --- a/fpicker/UIConfig_fps.mk +++ b/fpicker/UIConfig_fps.mk @@ -10,6 +10,7 @@ $(eval $(call gb_UIConfig_UIConfig,fps)) $(eval $(call gb_UIConfig_add_uifiles,fps,\ + fpicker/uiconfig/ui/breadcrumb \ fpicker/uiconfig/ui/explorerfiledialog \ fpicker/uiconfig/ui/foldernamedialog \ fpicker/uiconfig/ui/remotefilesdialog \ diff --git a/fpicker/inc/bitmaps.hlst b/fpicker/inc/bitmaps.hlst index 878058154fb6..4951ead796f0 100644 --- a/fpicker/inc/bitmaps.hlst +++ b/fpicker/inc/bitmaps.hlst @@ -11,8 +11,6 @@ #define INCLUDED_FPICKER_INC_BITMAPS_HRC #define RID_BMP_FOLDER_OPEN "res/folderop.png" -#define BMP_FILEDLG_BTN_UP "res/fp010.png" -#define BMP_FILEDLG_CREATEFOLDER "fpicker/res/fp014.png" #define BMP_FILEDLG_PLACE_LOCAL "fpicker/res/fp015.png" #define BMP_FILEDLG_PLACE_REMOTE "fpicker/res/fp016.png" #define RID_BMP_FOLDER "svtools/res/folder.png" diff --git a/fpicker/inc/strings.hrc b/fpicker/inc/strings.hrc index 05acac0935fc..b175069c05da 100644 --- a/fpicker/inc/strings.hrc +++ b/fpicker/inc/strings.hrc @@ -30,7 +30,6 @@ #define STR_BUTTONSELECT NC_("STR_BUTTONSELECT", "~Select") #define STR_PREVIEW NC_("STR_PREVIEW", "File Preview") #define STR_DEFAULT_DIRECTORY NC_("STR_DEFAULT_DIRECTORY", "My Documents") -#define STR_PLACES_TITLE NC_("STR_PLACES_TITLE", "Places") #define RID_FILEOPEN_NOTEXISTENTFILE NC_("RID_FILEOPEN_NOTEXISTENTFILE", "The file $name$ does not exist.\nMake sure you have entered the correct file name.") #define STR_SVT_NEW_FOLDER NC_("STR_SVT_NEW_FOLDER", "Folder") #define STR_SVT_NOREMOVABLEDEVICE NC_("STR_SVT_NOREMOVABLEDEVICE", "No removable storage device detected.\nMake sure it is plugged in properly and try again.") diff --git a/fpicker/source/office/OfficeControlAccess.cxx b/fpicker/source/office/OfficeControlAccess.cxx index 073d0268a9be..256839897f83 100644 --- a/fpicker/source/office/OfficeControlAccess.cxx +++ b/fpicker/source/office/OfficeControlAccess.cxx @@ -101,22 +101,19 @@ namespace svt { "VersionListLabel", LISTBOX_VERSION_LABEL, PROPERTY_FLAGS_COMMON | PropFlags::Text } }; - static const sal_Int32 s_nControlCount = SAL_N_ELEMENTS( aDescriptions ); static ControlDescIterator s_pControls = aDescriptions; static ControlDescIterator s_pControlsEnd = aDescriptions + s_nControlCount; - struct ControlDescriptionLookup { - bool operator()( const ControlDescription& _rDesc1, const ControlDescription& _rDesc2 ) + bool operator()( const ControlDescription& rDesc1, const ControlDescription& rDesc2 ) { - return strcmp(_rDesc1.pControlName, _rDesc2.pControlName) < 0; + return strcmp(rDesc1.pControlName, rDesc2.pControlName) < 0; } }; - struct ControlProperty { const sal_Char* pPropertyName; @@ -125,7 +122,6 @@ namespace svt typedef const ControlProperty* ControlPropertyIterator; - static const ControlProperty aProperties[] = { { "Text", PropFlags::Text }, { "Enabled", PropFlags::Enabled }, @@ -137,7 +133,6 @@ namespace svt { "Checked", PropFlags::Checked } }; - static const int s_nPropertyCount = SAL_N_ELEMENTS( aProperties ); static ControlPropertyIterator s_pProperties = aProperties; @@ -166,38 +161,48 @@ namespace svt } } - - OControlAccess::OControlAccess( IFilePickerController* _pController, SvtFileView* _pFileView ) - :m_pFilePickerController( _pController ) - ,m_pFileView( _pFileView ) + OControlAccess::OControlAccess(IFilePickerController* pController, SvtFileView* pFileView) + : m_pFilePickerController(pController) + , m_pFileView(pFileView) { DBG_ASSERT( m_pFilePickerController, "OControlAccess::OControlAccess: invalid control locator!" ); } + bool OControlAccess::IsFileViewWidget(weld::Widget const * pControl) const + { + if (!pControl) + return false; + if (!m_pFileView) + return false; + return pControl == m_pFileView->identifier(); + } - void OControlAccess::setHelpURL( vcl::Window* _pControl, const OUString& sHelpURL, bool _bFileView ) + void OControlAccess::setHelpURL(weld::Widget* pControl, const OUString& sHelpURL) { OUString sHelpID( sHelpURL ); INetURLObject aHID( sHelpURL ); - if ( aHID.GetProtocol() == INetProtocol::Hid ) - sHelpID = aHID.GetURLPath(); + if (aHID.GetProtocol() == INetProtocol::Hid) + sHelpID = aHID.GetURLPath(); // URLs should always be UTF8 encoded and escaped OString sID( OUStringToOString( sHelpID, RTL_TEXTENCODING_UTF8 ) ); - if ( _bFileView ) + if (IsFileViewWidget(pControl)) + { // the file view "overrides" the SetHelpId - static_cast< SvtFileView* >( _pControl )->SetHelpId( sID ); + m_pFileView->set_help_id(sID); + } else - _pControl->SetHelpId( sID ); + pControl->set_help_id(sID); } - - OUString OControlAccess::getHelpURL( vcl::Window const * _pControl, bool _bFileView ) + OUString OControlAccess::getHelpURL(weld::Widget const * pControl) const { - OString aHelpId = _pControl->GetHelpId(); - if ( _bFileView ) + OString aHelpId = pControl->get_help_id(); + if (IsFileViewWidget(pControl)) + { // the file view "overrides" the SetHelpId - aHelpId = static_cast< SvtFileView const * >( _pControl )->GetHelpId( ); + aHelpId = m_pFileView->get_help_id(); + } OUString sHelpURL; OUString aTmp( OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ) ); @@ -208,17 +213,16 @@ namespace svt return sHelpURL; } - - Any OControlAccess::getControlProperty( const OUString& _rControlName, const OUString& _rControlProperty ) + Any OControlAccess::getControlProperty( const OUString& rControlName, const OUString& rControlProperty ) { // look up the control sal_Int16 nControlId = -1; PropFlags nPropertyMask = PropFlags::NONE; - Control* pControl = implGetControl( _rControlName, &nControlId, &nPropertyMask ); + weld::Widget* pControl = implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid // look up the property - ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( _rControlProperty ) ); + ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) // it's a completely unknown property lcl_throwIllegalArgumentException(); @@ -230,12 +234,11 @@ namespace svt return implGetControlProperty( pControl, aPropDesc->nPropertyId ); } - - Control* OControlAccess::implGetControl( const OUString& _rControlName, sal_Int16* _pId, PropFlags* _pPropertyMask ) const + weld::Widget* OControlAccess::implGetControl( const OUString& rControlName, sal_Int16* _pId, PropFlags* _pPropertyMask ) const { - Control* pControl = nullptr; + weld::Widget* pControl = nullptr; ControlDescription tmpDesc; - OString aControlName = OUStringToOString( _rControlName, RTL_TEXTENCODING_UTF8 ); + OString aControlName = OUStringToOString( rControlName, RTL_TEXTENCODING_UTF8 ); tmpDesc.pControlName = aControlName.getStr(); // translate the name into an id @@ -259,24 +262,22 @@ namespace svt return pControl; } - - void OControlAccess::setControlProperty( const OUString& _rControlName, const OUString& _rControlProperty, const css::uno::Any& _rValue ) + void OControlAccess::setControlProperty( const OUString& rControlName, const OUString& rControlProperty, const css::uno::Any& rValue ) { // look up the control sal_Int16 nControlId = -1; - Control* pControl = implGetControl( _rControlName, &nControlId ); + weld::Widget* pControl = implGetControl( rControlName, &nControlId ); // will throw an IllegalArgumentException if the name is not valid // look up the property - ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( _rControlProperty ) ); + ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) lcl_throwIllegalArgumentException(); // set the property - implSetControlProperty( nControlId, pControl, aPropDesc->nPropertyId, _rValue, false ); + implSetControlProperty( nControlId, pControl, aPropDesc->nPropertyId, rValue, false ); } - Sequence< OUString > OControlAccess::getSupportedControls( ) const { Sequence< OUString > aControls( s_nControlCount ); @@ -293,12 +294,11 @@ namespace svt return aControls; } - - Sequence< OUString > OControlAccess::getSupportedControlProperties( const OUString& _rControlName ) + Sequence< OUString > OControlAccess::getSupportedControlProperties( const OUString& rControlName ) { sal_Int16 nControlId = -1; PropFlags nPropertyMask = PropFlags::NONE; - implGetControl( _rControlName, &nControlId, &nPropertyMask ); + implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid // fill in the property names @@ -313,26 +313,24 @@ namespace svt return aProps; } - - bool OControlAccess::isControlSupported( const OUString& _rControlName ) + bool OControlAccess::isControlSupported( const OUString& rControlName ) { ControlDescription tmpDesc; - OString aControlName = OUStringToOString(_rControlName, RTL_TEXTENCODING_UTF8); + OString aControlName = OUStringToOString(rControlName, RTL_TEXTENCODING_UTF8); tmpDesc.pControlName = aControlName.getStr(); return ::std::binary_search( s_pControls, s_pControlsEnd, tmpDesc, ControlDescriptionLookup() ); } - - bool OControlAccess::isControlPropertySupported( const OUString& _rControlName, const OUString& _rControlProperty ) + bool OControlAccess::isControlPropertySupported( const OUString& rControlName, const OUString& rControlProperty ) { // look up the control sal_Int16 nControlId = -1; PropFlags nPropertyMask = PropFlags::NONE; - implGetControl( _rControlName, &nControlId, &nPropertyMask ); + implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid // look up the property - ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( _rControlProperty ) ); + ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) // it's a property which is completely unknown return false; @@ -340,21 +338,20 @@ namespace svt return bool( aPropDesc->nPropertyId & nPropertyMask ); } - - void OControlAccess::setValue( sal_Int16 _nControlId, sal_Int16 _nControlAction, const Any& _rValue ) + void OControlAccess::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const Any& rValue ) { - Control* pControl = m_pFilePickerController->getControl( _nControlId ); + weld::Widget* pControl = m_pFilePickerController->getControl( nControlId ); DBG_ASSERT( pControl, "OControlAccess::SetValue: don't have this control in the current mode!" ); if ( pControl ) { PropFlags nPropertyId = PropFlags::Unknown; - if ( ControlActions::SET_HELP_URL == _nControlAction ) + if ( ControlActions::SET_HELP_URL == nControlAction ) { nPropertyId = PropFlags::HelpUrl; } else { - switch ( _nControlId ) + switch ( nControlId ) { case CHECKBOX_AUTOEXTENSION: case CHECKBOX_PASSWORD: @@ -374,41 +371,41 @@ namespace svt case LISTBOX_TEMPLATE: case LISTBOX_IMAGE_TEMPLATE: case LISTBOX_IMAGE_ANCHOR: - if ( ControlActions::SET_SELECT_ITEM == _nControlAction ) + if ( ControlActions::SET_SELECT_ITEM == nControlAction ) { nPropertyId = PropFlags::SelectedItemIndex; } else { - DBG_ASSERT( WindowType::LISTBOX == pControl->GetType(), "OControlAccess::SetValue: implGetControl returned nonsense!" ); - implDoListboxAction( static_cast< ListBox* >( pControl ), _nControlAction, _rValue ); + weld::ComboBox* pComboBox = dynamic_cast<weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::SetValue: implGetControl returned nonsense!"); + implDoListboxAction(pComboBox, nControlAction, rValue); } break; } } if ( PropFlags::Unknown != nPropertyId ) - implSetControlProperty( _nControlId, pControl, nPropertyId, _rValue ); + implSetControlProperty( nControlId, pControl, nPropertyId, rValue ); } } - - Any OControlAccess::getValue( sal_Int16 _nControlId, sal_Int16 _nControlAction ) const + Any OControlAccess::getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) const { Any aRet; - Control* pControl = m_pFilePickerController->getControl( _nControlId ); + weld::Widget* pControl = m_pFilePickerController->getControl( nControlId ); DBG_ASSERT( pControl, "OControlAccess::GetValue: don't have this control in the current mode!" ); if ( pControl ) { PropFlags nPropertyId = PropFlags::Unknown; - if ( ControlActions::SET_HELP_URL == _nControlAction ) + if ( ControlActions::SET_HELP_URL == nControlAction ) { nPropertyId = PropFlags::HelpUrl; } else { - switch ( _nControlId ) + switch ( nControlId ) { case CHECKBOX_AUTOEXTENSION: case CHECKBOX_PASSWORD: @@ -422,7 +419,7 @@ namespace svt break; case LISTBOX_FILTER: - if ( ControlActions::GET_SELECTED_ITEM == _nControlAction ) + if ( ControlActions::GET_SELECTED_ITEM == nControlAction ) { aRet <<= m_pFilePickerController->getCurFilter(); } @@ -436,7 +433,7 @@ namespace svt case LISTBOX_TEMPLATE: case LISTBOX_IMAGE_TEMPLATE: case LISTBOX_IMAGE_ANCHOR: - switch ( _nControlAction ) + switch ( nControlAction ) { case ControlActions::GET_SELECTED_ITEM: nPropertyId = PropFlags::SelectedItem; @@ -462,57 +459,47 @@ namespace svt return aRet; } - void OControlAccess::setLabel( sal_Int16 nId, const OUString &rLabel ) { - Control* pControl = m_pFilePickerController->getControl( nId, true ); - DBG_ASSERT( pControl, "OControlAccess::GetValue: don't have this control in the current mode!" ); - if ( pControl ) - pControl->SetText( rLabel ); + weld::Label* pControl = dynamic_cast<weld::Label*>(m_pFilePickerController->getControl(nId, true)); + assert(pControl && "OControlAccess::GetValue: don't have this control in the current mode!"); + pControl->set_label(rLabel); } - OUString OControlAccess::getLabel( sal_Int16 nId ) const { - OUString sLabel; - - Control* pControl = m_pFilePickerController->getControl( nId, true ); - DBG_ASSERT( pControl, "OControlAccess::GetValue: don't have this control in the current mode!" ); - if ( pControl ) - sLabel = pControl->GetText(); - - return sLabel; + weld::Label* pControl = dynamic_cast<weld::Label*>(m_pFilePickerController->getControl(nId, true)); + assert(pControl && "OControlAccess::GetValue: don't have this control in the current mode!"); + return pControl->get_label(); } - - void OControlAccess::enableControl( sal_Int16 _nId, bool _bEnable ) + void OControlAccess::enableControl(sal_Int16 nId, bool bEnable) { - m_pFilePickerController->enableControl( _nId, _bEnable ); + m_pFilePickerController->enableControl(nId, bEnable); } - - void OControlAccess::implDoListboxAction( ListBox* _pListbox, sal_Int16 _nControlAction, const Any& _rValue ) + void OControlAccess::implDoListboxAction(weld::ComboBox* pListbox, sal_Int16 nControlAction, const Any& rValue) { - switch ( _nControlAction ) + switch ( nControlAction ) { case ControlActions::ADD_ITEM: { OUString aEntry; - _rValue >>= aEntry; + rValue >>= aEntry; if ( !aEntry.isEmpty() ) - _pListbox->InsertEntry( aEntry ); + pListbox->append_text( aEntry ); } break; case ControlActions::ADD_ITEMS: { Sequence < OUString > aTemplateList; - _rValue >>= aTemplateList; + rValue >>= aTemplateList; if ( aTemplateList.hasElements() ) { for ( long i=0; i < aTemplateList.getLength(); i++ ) - _pListbox->InsertEntry( aTemplateList[i] ); + pListbox->append_text( aTemplateList[i] ); } } break; @@ -520,13 +507,13 @@ namespace svt case ControlActions::DELETE_ITEM: { sal_Int32 nPos = 0; - if ( _rValue >>= nPos ) - _pListbox->RemoveEntry( nPos ); + if ( rValue >>= nPos ) + pListbox->remove( nPos ); } break; case ControlActions::DELETE_ITEMS: - _pListbox->Clear(); + pListbox->clear(); break; default: @@ -534,16 +521,15 @@ namespace svt } } - - void OControlAccess::implSetControlProperty( sal_Int16 _nControlId, Control* _pControl, PropFlags _nProperty, const Any& _rValue, bool _bIgnoreIllegalArgument ) + void OControlAccess::implSetControlProperty( sal_Int16 nControlId, weld::Widget* pControl, PropFlags _nProperty, const Any& rValue, bool _bIgnoreIllegalArgument ) { - if ( !_pControl ) - _pControl = m_pFilePickerController->getControl( _nControlId ); - DBG_ASSERT( _pControl, "OControlAccess::implSetControlProperty: invalid argument, this will crash!" ); - if ( !_pControl ) + if ( !pControl ) + pControl = m_pFilePickerController->getControl( nControlId ); + DBG_ASSERT( pControl, "OControlAccess::implSetControlProperty: invalid argument, this will crash!" ); + if ( !pControl ) return; - DBG_ASSERT( _pControl == m_pFilePickerController->getControl( _nControlId ), + DBG_ASSERT( pControl == m_pFilePickerController->getControl( nControlId ), "OControlAccess::implSetControlProperty: inconsistent parameters!" ); switch ( _nProperty ) @@ -551,9 +537,11 @@ namespace svt case PropFlags::Text: { OUString sText; - if ( _rValue >>= sText ) + if (rValue >>= sText) { - _pControl->SetText( sText ); + weld::Label* pLabel = dynamic_cast<weld::Label*>(pControl); + assert(pLabel); + pLabel->set_label(sText); } else if ( !_bIgnoreIllegalArgument ) { @@ -565,9 +553,9 @@ namespace svt case PropFlags::Enabled: { bool bEnabled = false; - if ( _rValue >>= bEnabled ) + if ( rValue >>= bEnabled ) { - m_pFilePickerController->enableControl( _nControlId, bEnabled ); + m_pFilePickerController->enableControl( nControlId, bEnabled ); } else if ( !_bIgnoreIllegalArgument ) { @@ -579,9 +567,9 @@ namespace svt case PropFlags::Visible: { bool bVisible = false; - if ( _rValue >>= bVisible ) + if ( rValue >>= bVisible ) { - _pControl->Show( bVisible ); + pControl->set_visible( bVisible ); } else if ( !_bIgnoreIllegalArgument ) { @@ -593,9 +581,9 @@ namespace svt case PropFlags::HelpUrl: { OUString sHelpURL; - if ( _rValue >>= sHelpURL ) + if ( rValue >>= sHelpURL ) { - setHelpURL( _pControl, sHelpURL, m_pFileView == _pControl ); + setHelpURL(pControl, sHelpURL); } else if ( !_bIgnoreIllegalArgument ) { @@ -606,19 +594,19 @@ namespace svt case PropFlags::ListItems: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implSetControlProperty: invalid control/property combination!" ); + weld::ComboBox* pComboBox = dynamic_cast<weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implSetControlProperty: invalid control/property combination!"); Sequence< OUString > aItems; - if ( _rValue >>= aItems ) + if ( rValue >>= aItems ) { // remove all previous items - static_cast< ListBox* >( _pControl )->Clear(); + pComboBox->clear(); // add the new ones - for ( auto const & item : std::as_const(aItems) ) + for (auto const & item : std::as_const(aItems)) { - static_cast< ListBox* >( _pControl )->InsertEntry( item ); + pComboBox->append_text(item); } } @@ -631,13 +619,13 @@ namespace svt case PropFlags::SelectedItem: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implSetControlProperty: invalid control/property combination!" ); + weld::ComboBox* pComboBox = dynamic_cast<weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implSetControlProperty: invalid control/property combination!"); OUString sSelected; - if ( _rValue >>= sSelected ) + if ( rValue >>= sSelected ) { - static_cast< ListBox* >( _pControl )->SelectEntry( sSelected ); + pComboBox->set_active_text(sSelected); } else if ( !_bIgnoreIllegalArgument ) { @@ -648,13 +636,13 @@ namespace svt case PropFlags::SelectedItemIndex: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implSetControlProperty: invalid control/property combination!" ); + weld::ComboBox* pComboBox = dynamic_cast<weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implSetControlProperty: invalid control/property combination!"); sal_Int32 nPos = 0; - if ( _rValue >>= nPos ) + if ( rValue >>= nPos ) { - static_cast< ListBox* >( _pControl )->SelectEntryPos( nPos ); + pComboBox->set_active(nPos); } else if ( !_bIgnoreIllegalArgument ) { @@ -665,13 +653,13 @@ namespace svt case PropFlags::Checked: { - DBG_ASSERT( WindowType::CHECKBOX == _pControl->GetType(), - "OControlAccess::implSetControlProperty: invalid control/property combination!" ); + weld::ToggleButton* pToggleButton = dynamic_cast<weld::ToggleButton*>(pControl); + assert(pToggleButton && "OControlAccess::implSetControlProperty: invalid control/property combination!"); bool bChecked = false; - if ( _rValue >>= bChecked ) + if ( rValue >>= bChecked ) { - static_cast< CheckBox* >( _pControl )->Check( bChecked ); + pToggleButton->set_active(bChecked); } else if ( !_bIgnoreIllegalArgument ) { @@ -685,76 +673,80 @@ namespace svt } } - - Any OControlAccess::implGetControlProperty( Control const * _pControl, PropFlags _nProperty ) const + Any OControlAccess::implGetControlProperty( weld::Widget const * pControl, PropFlags _nProperty ) const { - DBG_ASSERT( _pControl, "OControlAccess::implGetControlProperty: invalid argument, this will crash!" ); + assert(pControl && "OControlAccess::implGetControlProperty: invalid argument, this will crash!"); Any aReturn; switch ( _nProperty ) { case PropFlags::Text: - aReturn <<= _pControl->GetText(); + { + const weld::Label* pLabel = dynamic_cast<const weld::Label*>(pControl); + assert(pLabel); + aReturn <<= pLabel->get_label(); break; - + } case PropFlags::Enabled: - aReturn <<= _pControl->IsEnabled(); + aReturn <<= pControl->get_sensitive(); break; case PropFlags::Visible: - aReturn <<= _pControl->IsVisible(); + aReturn <<= pControl->get_visible(); break; case PropFlags::HelpUrl: - aReturn <<= getHelpURL( _pControl, m_pFileView == _pControl ); + aReturn <<= getHelpURL(pControl); break; case PropFlags::ListItems: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implGetControlProperty: invalid control/property combination!" ); + const weld::ComboBox* pComboBox = dynamic_cast<const weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implGetControlProperty: invalid control/property combination!"); - Sequence< OUString > aItems( static_cast< ListBox const * >( _pControl )->GetEntryCount() ); + Sequence< OUString > aItems(pComboBox->get_count()); OUString* pItems = aItems.getArray(); - for ( sal_Int32 i=0; i<static_cast< ListBox const * >( _pControl )->GetEntryCount(); ++i ) - *pItems++ = static_cast< ListBox const * >( _pControl )->GetEntry( i ); + for (sal_Int32 i = 0; i < pComboBox->get_count(); ++i) + *pItems++ = pComboBox->get_text(i); aReturn <<= aItems; + break; } - break; case PropFlags::SelectedItem: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implGetControlProperty: invalid control/property combination!" ); + const weld::ComboBox* pComboBox = dynamic_cast<const weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implGetControlProperty: invalid control/property combination!"); - sal_Int32 nSelected = static_cast< ListBox const * >( _pControl )->GetSelectedEntryPos(); + sal_Int32 nSelected = pComboBox->get_active(); OUString sSelected; - if ( LISTBOX_ENTRY_NOTFOUND != nSelected ) - sSelected = static_cast< ListBox const * >( _pControl )->GetSelectedEntry(); + if (nSelected != -1) + sSelected = pComboBox->get_active_text(); aReturn <<= sSelected; + break; } - break; case PropFlags::SelectedItemIndex: { - DBG_ASSERT( WindowType::LISTBOX == _pControl->GetType(), - "OControlAccess::implGetControlProperty: invalid control/property combination!" ); + const weld::ComboBox* pComboBox = dynamic_cast<const weld::ComboBox*>(pControl); + assert(pComboBox && "OControlAccess::implGetControlProperty: invalid control/property combination!"); - sal_Int32 nSelected = static_cast< ListBox const * >( _pControl )->GetSelectedEntryPos(); - if ( LISTBOX_ENTRY_NOTFOUND != nSelected ) - aReturn <<= static_cast< ListBox const * >( _pControl )->GetSelectedEntryPos(); + sal_Int32 nSelected = pComboBox->get_active(); + if (nSelected != -1) + aReturn <<= nSelected; else aReturn <<= sal_Int32(-1); + break; } - break; case PropFlags::Checked: - DBG_ASSERT( WindowType::CHECKBOX == _pControl->GetType(), - "OControlAccess::implGetControlProperty: invalid control/property combination!" ); + { + const weld::ToggleButton* pToggleButton = dynamic_cast<const weld::ToggleButton*>(pControl); + assert(pToggleButton && "OControlAccess::implGetControlProperty: invalid control/property combination!"); - aReturn <<= static_cast< CheckBox const * >( _pControl )->IsChecked( ); + aReturn <<= pToggleButton->get_active(); break; + } default: OSL_FAIL( "OControlAccess::implGetControlProperty: invalid property id!" ); @@ -762,8 +754,6 @@ namespace svt return aReturn; } - } // namespace svt - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/OfficeControlAccess.hxx b/fpicker/source/office/OfficeControlAccess.hxx index 0f857cb08f78..e66baae3d37c 100644 --- a/fpicker/source/office/OfficeControlAccess.hxx +++ b/fpicker/source/office/OfficeControlAccess.hxx @@ -25,7 +25,6 @@ #include "pickercallbacks.hxx" #include <o3tl/typed_flags_set.hxx> - enum class PropFlags { Unknown = -1, // used as an error sentinel NONE = 0x0000, @@ -62,66 +61,68 @@ namespace svt class OControlAccess { IFilePickerController* m_pFilePickerController; - VclPtr<SvtFileView> m_pFileView; + SvtFileView* m_pFileView; public: - OControlAccess( IFilePickerController* _pController, SvtFileView* _pFileView ); + OControlAccess( IFilePickerController* pController, SvtFileView* pFileView ); // XControlAccess implementation - void setControlProperty( const OUString& _rControlName, const OUString& _rControlProperty, const css::uno::Any& _rValue ); - css::uno::Any getControlProperty( const OUString& _rControlName, const OUString& _rControlProperty ); + void setControlProperty( const OUString& rControlName, const OUString& rControlProperty, const css::uno::Any& rValue ); + css::uno::Any getControlProperty( const OUString& rControlName, const OUString& rControlProperty ); // XControlInformation implementation css::uno::Sequence< OUString > getSupportedControls( ) const; - css::uno::Sequence< OUString > getSupportedControlProperties( const OUString& _rControlName ); - static bool isControlSupported( const OUString& _rControlName ); - bool isControlPropertySupported( const OUString& _rControlName, const OUString& _rControlProperty ); + css::uno::Sequence< OUString > getSupportedControlProperties( const OUString& rControlName ); + static bool isControlSupported( const OUString& rControlName ); + bool isControlPropertySupported( const OUString& rControlName, const OUString& rControlProperty ); // XFilePickerControlAccess - void setValue( sal_Int16 _nId, sal_Int16 _nCtrlAction, const css::uno::Any& _rValue ); - css::uno::Any getValue( sal_Int16 _nId, sal_Int16 _nCtrlAction ) const; - void setLabel( sal_Int16 _nId, const OUString& _rValue ); - OUString getLabel( sal_Int16 _nId ) const; - void enableControl( sal_Int16 _nId, bool _bEnable ); + void setValue( sal_Int16 nId, sal_Int16 nCtrlAction, const css::uno::Any& rValue ); + css::uno::Any getValue( sal_Int16 nId, sal_Int16 nCtrlAction ) const; + void setLabel( sal_Int16 nId, const OUString& rValue ); + OUString getLabel( sal_Int16 nId ) const; + void enableControl( sal_Int16 nId, bool bEnable ); - static void setHelpURL( vcl::Window* _pControl, const OUString& _rURL, bool _bFileView ); - static OUString getHelpURL( vcl::Window const * _pControl, bool _bFileView ); + void setHelpURL(weld::Widget* pControl, const OUString& rURL); + OUString getHelpURL(weld::Widget const* pControl) const; private: /** implements the various methods for setting properties on controls - @param _nControlId + @param nControlId the id of the control - @param _pControl - the affected control. Must be the same as referred by <arg>_nControlId</arg>, or NULL. - @param _nProperty + @param pControl + the affected control. Must be the same as referred by <arg>nControlId</arg>, or NULL. + @param nProperty the property to set See PropFlags::* - @param _rValue + @param rValue the value to set - @param _bIgnoreIllegalArgument + @param bIgnoreIllegalArgument if <FALSE/>, an exception will be thrown if the given value is of improper type */ void implSetControlProperty( - sal_Int16 _nControlId, - Control* _pControl, PropFlags _nProperty, const css::uno::Any& _rValue, - bool _bIgnoreIllegalArgument = true ); + sal_Int16 nControlId, + weld::Widget* pControl, PropFlags nProperty, const css::uno::Any& rValue, + bool bIgnoreIllegalArgument = true ); - Control* implGetControl( const OUString& _rControlName, sal_Int16* _pId, PropFlags* _pPropertyMask = nullptr ) const; + weld::Widget* implGetControl( const OUString& rControlName, sal_Int16* pId, PropFlags* pPropertyMask = nullptr ) const; /** implements the various methods for retrieving properties from controls - @param _pControl + @param pControl the affected control @PRECOND not <NULL/> - @param _nProperty + @param nProperty the property to retrieve See PropFlags::* @return */ - css::uno::Any implGetControlProperty( Control const * _pControl, PropFlags _nProperty ) const; + css::uno::Any implGetControlProperty( weld::Widget const * pControl, PropFlags nProperty ) const; + + bool IsFileViewWidget(weld::Widget const * pControl) const; - static void implDoListboxAction( ListBox* _pListbox, sal_Int16 _nCtrlAction, const css::uno::Any& _rValue ); + static void implDoListboxAction(weld::ComboBox* pListbox, sal_Int16 nCtrlAction, const css::uno::Any& rValue); }; diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index ab5d0e3b435e..db7ac9d2bd60 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -149,28 +149,28 @@ void SvtFilePicker::prepareExecute() if ( !m_aDefaultName.isEmpty() ) { aPath.insertName( m_aDefaultName ); - getDialog()->SetHasFilename( true ); + m_xDlg->SetHasFilename( true ); } - getDialog()->SetPath( aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + m_xDlg->SetPath( aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); isFileSet = true; } if ( !isFileSet && !m_aDefaultName.isEmpty() ) { - getDialog()->SetPath( m_aDefaultName ); - getDialog()->SetHasFilename( true ); + m_xDlg->SetPath( m_aDefaultName ); + m_xDlg->SetHasFilename( true ); } } else { // set the default standard dir INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); - getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + m_xDlg->SetPath( aStdDirObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); } // set the control values and set the control labels, too if ( m_pElemList && !m_pElemList->empty() ) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); for (auto const& elem : *m_pElemList) { @@ -193,17 +193,19 @@ void SvtFilePicker::prepareExecute() UnoFilterList aSubFilters; elem.getSubFilters( aSubFilters ); - getDialog()->AddFilterGroup( elem.getTitle(), aSubFilters ); - } + m_xDlg->AddFilterGroup( elem.getTitle(), aSubFilters ); + } else + { // it's a single filter - getDialog()->AddFilter( elem.getTitle(), elem.getFilter() ); + m_xDlg->AddFilter( elem.getTitle(), elem.getFilter() ); + } } } // set the default filter if ( !m_aCurrentFilter.isEmpty() ) - getDialog()->SetCurFilter( m_aCurrentFilter ); + m_xDlg->SetCurFilter( m_aCurrentFilter ); } @@ -413,30 +415,28 @@ SvtFilePicker::~SvtFilePicker() { } - sal_Int16 SvtFilePicker::implExecutePicker( ) { - getDialog()->SetFileCallback( this ); + m_xDlg->SetFileCallback( this ); prepareExecute(); - getDialog()->EnableAutocompletion(); + m_xDlg->EnableAutocompletion(); // now we are ready to execute the dialog - sal_Int16 nRet = getDialog()->Execute(); + sal_Int16 nRet = m_xDlg->run(); // the execution of the dialog yields, so it is possible the at this point the window or the dialog is closed - if ( getDialog() ) - getDialog()->SetFileCallback( nullptr ); + if (m_xDlg) + m_xDlg->SetFileCallback( nullptr ); return nRet; } - -VclPtr<SvtFileDialog_Base> SvtFilePicker::implCreateDialog( vcl::Window* _pParent ) +std::unique_ptr<SvtFileDialog_Base> SvtFilePicker::implCreateDialog( weld::Window* pParent ) { PickerFlags nBits = getPickerFlags(); - VclPtrInstance<SvtFileDialog> dialog( _pParent, nBits ); + auto dialog = std::make_unique<SvtFileDialog>(pParent, nBits); // Set StandardDir if present if ( !m_aStandardDir.isEmpty()) @@ -475,38 +475,31 @@ void SAL_CALL SvtFilePicker::setTitle( const OUString& _rTitle ) OCommonPicker::setTitle( _rTitle ); } - sal_Int16 SAL_CALL SvtFilePicker::execute( ) { return OCommonPicker::execute(); } - // XAsynchronousExecutableDialog functions - - void SAL_CALL SvtFilePicker::setDialogTitle( const OUString& _rTitle ) { setTitle( _rTitle ); } - void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< css::ui::dialogs::XDialogClosedListener >& xListener ) { m_xDlgClosedListener = xListener; prepareDialog(); prepareExecute(); - SvtFileDialog_Base* pDialog = getDialog(); - pDialog->EnableAutocompletion(); - pDialog->StartExecuteAsync([this](sal_Int32 nResult){ + m_xDlg->EnableAutocompletion(); + if (!m_xDlg->PrepareExecute()) + return; + weld::DialogController::runAsync(m_xDlg, [this](sal_Int32 nResult){ DialogClosedHdl(nResult); }); } - // XFilePicker functions - - void SAL_CALL SvtFilePicker::setMultiSelectionMode( sal_Bool bMode ) { checkAlive(); @@ -536,15 +529,15 @@ OUString SAL_CALL SvtFilePicker::getDisplayDirectory() checkAlive(); SolarMutexGuard aGuard; - if ( getDialog() ) + if (m_xDlg) { - OUString aPath = getDialog()->GetPath(); + OUString aPath = m_xDlg->GetPath(); if( m_aOldHideDirectory == aPath ) return m_aOldDisplayDirectory; m_aOldHideDirectory = aPath; - if( !getDialog()->ContentIsFolder( aPath ) ) + if( !m_xDlg->ContentIsFolder( aPath ) ) { INetURLObject aFolder( aPath ); aFolder.CutLastName(); @@ -562,13 +555,13 @@ Sequence< OUString > SAL_CALL SvtFilePicker::getSelectedFiles() checkAlive(); SolarMutexGuard aGuard; - if ( ! getDialog() ) + if (!m_xDlg) { Sequence< OUString > aEmpty; return aEmpty; } - return comphelper::containerToSequence(getDialog()->GetPathList()); + return comphelper::containerToSequence(m_xDlg->GetPathList()); } Sequence< OUString > SAL_CALL SvtFilePicker::getFiles() @@ -590,9 +583,9 @@ void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID, checkAlive(); SolarMutexGuard aGuard; - if ( getDialog() ) + if (m_xDlg) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); aAccess.setValue( nElementID, nControlAction, rValue ); } else @@ -632,9 +625,9 @@ Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAc Any aAny; // execute() called? - if ( getDialog() ) + if (m_xDlg) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); aAny = aAccess.getValue( nElementID, nControlAction ); } else if ( m_pElemList ) @@ -660,9 +653,9 @@ void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const OUString& rValu checkAlive(); SolarMutexGuard aGuard; - if ( getDialog() ) + if (m_xDlg) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); aAccess.setLabel( nLabelID, rValue ); } else @@ -698,9 +691,9 @@ OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID ) SolarMutexGuard aGuard; OUString aLabel; - if ( getDialog() ) + if (m_xDlg) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess(m_xDlg.get(), m_xDlg->GetView()); aLabel = aAccess.getLabel( nLabelID ); } else if ( m_pElemList ) @@ -725,9 +718,9 @@ void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnab checkAlive(); SolarMutexGuard aGuard; - if ( getDialog() ) + if (m_xDlg) { - ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); + ::svt::OControlAccess aAccess(m_xDlg.get(), m_xDlg->GetView()); aAccess.enableControl( nElementID, bEnable ); } else @@ -776,10 +769,7 @@ void SAL_CALL SvtFilePicker::removeFilePickerListener( const Reference< XFilePic m_xListener.clear(); } - // XFilePreview functions - - Sequence< sal_Int16 > SAL_CALL SvtFilePicker::getSupportedImageFormats() { checkAlive(); @@ -792,21 +782,11 @@ Sequence< sal_Int16 > SAL_CALL SvtFilePicker::getSupportedImageFormats() return aFormats; } - sal_Int32 SAL_CALL SvtFilePicker::getTargetColorDepth() { - checkAlive(); - - SolarMutexGuard aGuard; - sal_Int32 nDepth = 0; - - if ( getDialog() ) - nDepth = getDialog()->getTargetColorDepth(); - - return nDepth; + return 0; } - sal_Int32 SAL_CALL SvtFilePicker::getAvailableWidth() { checkAlive(); @@ -814,13 +794,12 @@ sal_Int32 SAL_CALL SvtFilePicker::getAvailableWidth() SolarMutexGuard aGuard; sal_Int32 nWidth = 0; - if ( getDialog() ) - nWidth = getDialog()->getAvailableWidth(); + if (m_xDlg) + nWidth = m_xDlg->getAvailableWidth(); return nWidth; } - sal_Int32 SAL_CALL SvtFilePicker::getAvailableHeight() { checkAlive(); @@ -828,23 +807,21 @@ sal_Int32 SAL_CALL SvtFilePicker::getAvailableHeight() SolarMutexGuard aGuard; sal_Int32 nHeight = 0; - if ( getDialog() ) - nHeight = getDialog()->getAvailableHeight(); + if (m_xDlg) + nHeight = m_xDlg->getAvailableHeight(); return nHeight; } - -void SAL_CALL SvtFilePicker::setImage( sal_Int16 /*aImageFormat*/, const Any& rImage ) +void SAL_CALL SvtFilePicker::setImage(sal_Int16 /*aImageFormat*/, const Any& rImage) { checkAlive(); SolarMutexGuard aGuard; - if ( getDialog() ) - getDialog()->setImage( rImage ); + if (m_xDlg) + m_xDlg->setImage(rImage); } - sal_Bool SAL_CALL SvtFilePicker::setShowState( sal_Bool ) { checkAlive(); @@ -852,7 +829,7 @@ sal_Bool SAL_CALL SvtFilePicker::setShowState( sal_Bool ) SolarMutexGuard aGuard; bool bRet = false; - if ( getDialog() ) + if (m_xDlg) { // #97633 for the system filedialog it's // useful to make the preview switchable @@ -880,8 +857,8 @@ sal_Bool SAL_CALL SvtFilePicker::getShowState() SolarMutexGuard aGuard; bool bRet = false; - if ( getDialog() ) - bRet = getDialog()->getShowState(); + if (m_xDlg) + bRet = m_xDlg->getShowState(); return bRet; } @@ -946,8 +923,8 @@ void SAL_CALL SvtFilePicker::setCurrentFilter( const OUString& aTitle ) m_aCurrentFilter = aTitle; - if ( getDialog() ) - getDialog()->SetCurFilter( aTitle ); + if (m_xDlg) + m_xDlg->SetCurFilter( aTitle ); } @@ -956,7 +933,7 @@ OUString SAL_CALL SvtFilePicker::getCurrentFilter() checkAlive(); SolarMutexGuard aGuard; - OUString aFilter = getDialog() ? getDialog()->GetCurFilter() : + OUString aFilter = m_xDlg ? m_xDlg->GetCurFilter() : m_aCurrentFilter; return aFilter; } @@ -1091,11 +1068,11 @@ SvtRemoteFilePicker::SvtRemoteFilePicker() { } -VclPtr<SvtFileDialog_Base> SvtRemoteFilePicker::implCreateDialog( vcl::Window* _pParent ) +std::unique_ptr<SvtFileDialog_Base> SvtRemoteFilePicker::implCreateDialog(weld::Window* pParent) { PickerFlags nBits = getPickerFlags(); - VclPtrInstance<RemoteFilesDialog> dialog( _pParent, nBits); + auto dialog = std::make_unique<RemoteFilesDialog>(pParent, nBits); // Set StandardDir if present if ( !m_aStandardDir.isEmpty()) diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx index 678ad35197f4..e682581c5372 100644 --- a/fpicker/source/office/OfficeFilePicker.hxx +++ b/fpicker/source/office/OfficeFilePicker.hxx @@ -203,7 +203,7 @@ protected: // OCommonPicker overridables - virtual VclPtr<SvtFileDialog_Base> implCreateDialog( vcl::Window* _pParent ) override; + virtual std::unique_ptr<SvtFileDialog_Base> implCreateDialog( weld::Window* pParent ) override; virtual sal_Int16 implExecutePicker( ) override; virtual bool implHandleInitializationArgument( const OUString& _rName, @@ -231,7 +231,7 @@ class SvtRemoteFilePicker : public SvtFilePicker public: SvtRemoteFilePicker(); - virtual VclPtr<SvtFileDialog_Base> implCreateDialog( vcl::Window* _pParent ) override; + virtual std::unique_ptr<SvtFileDialog_Base> implCreateDialog( weld::Window* pParent ) override; // disambiguate XInterface diff --git a/fpicker/source/office/OfficeFolderPicker.cxx b/fpicker/source/office/OfficeFolderPicker.cxx index 398fbe3a3932..db06eb421c76 100644 --- a/fpicker/source/office/OfficeFolderPicker.cxx +++ b/fpicker/source/office/OfficeFolderPicker.cxx @@ -59,16 +59,18 @@ void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< css::ui::dial m_xListener = xListener; prepareDialog(); prepareExecute(); - SvtFileDialog_Base* pDialog = getDialog(); - pDialog->EnableAutocompletion(); - pDialog->StartExecuteAsync([this](sal_Int32 nResult){ + + m_xDlg->EnableAutocompletion(); + if (!m_xDlg->PrepareExecute()) + return; + weld::DialogController::runAsync(m_xDlg, [this](sal_Int32 nResult){ DialogClosedHdl(nResult); }); } -VclPtr<SvtFileDialog_Base> SvtFolderPicker::implCreateDialog( vcl::Window* _pParent ) +std::unique_ptr<SvtFileDialog_Base> SvtFolderPicker::implCreateDialog( weld::Window* pParent ) { - return VclPtr<SvtFileDialog>::Create( _pParent, PickerFlags::PathDialog ); + return std::make_unique<SvtFileDialog>(pParent, PickerFlags::PathDialog); } sal_Int16 SvtFolderPicker::implExecutePicker( ) @@ -76,22 +78,20 @@ sal_Int16 SvtFolderPicker::implExecutePicker( ) prepareExecute(); // now we are ready to execute the dialog - getDialog()->EnableAutocompletion( false ); - sal_Int16 nRet = getDialog()->Execute(); - - return nRet; + m_xDlg->EnableAutocompletion( false ); + return m_xDlg->run(); } void SvtFolderPicker::prepareExecute() { // set the default directory if ( !m_aDisplayDirectory.isEmpty() ) - getDialog()->SetPath( m_aDisplayDirectory ); + m_xDlg->SetPath( m_aDisplayDirectory ); else { // set the default standard dir INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() ); - getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::DecodeMechanism::NONE) ); + m_xDlg->SetPath( aStdDirObj.GetMainURL( INetURLObject::DecodeMechanism::NONE) ); } } @@ -113,10 +113,10 @@ void SAL_CALL SvtFolderPicker::setDisplayDirectory( const OUString& aDirectory ) OUString SAL_CALL SvtFolderPicker::getDisplayDirectory() { - if ( ! getDialog() ) + if (!m_xDlg) return m_aDisplayDirectory; - std::vector<OUString> aPathList(getDialog()->GetPathList()); + std::vector<OUString> aPathList(m_xDlg->GetPathList()); if(!aPathList.empty()) return aPathList[0]; @@ -126,10 +126,10 @@ OUString SAL_CALL SvtFolderPicker::getDisplayDirectory() OUString SAL_CALL SvtFolderPicker::getDirectory() { - if ( ! getDialog() ) + if (!m_xDlg) return m_aDisplayDirectory; - std::vector<OUString> aPathList(getDialog()->GetPathList()); + std::vector<OUString> aPathList(m_xDlg->GetPathList()); if(!aPathList.empty()) return aPathList[0]; diff --git a/fpicker/source/office/OfficeFolderPicker.hxx b/fpicker/source/office/OfficeFolderPicker.hxx index e4408df314db..a9f3606b1050 100644 --- a/fpicker/source/office/OfficeFolderPicker.hxx +++ b/fpicker/source/office/OfficeFolderPicker.hxx @@ -93,7 +93,7 @@ protected: // OCommonPicker overridables - virtual VclPtr<SvtFileDialog_Base> implCreateDialog( vcl::Window* _pParent ) override; + virtual std::unique_ptr<SvtFileDialog_Base> implCreateDialog( weld::Window* pParent ) override; virtual sal_Int16 implExecutePicker( ) override; }; diff --git a/fpicker/source/office/PlacesListBox.cxx b/fpicker/source/office/PlacesListBox.cxx index da318d6030a5..f500e9a608cc 100644 --- a/fpicker/source/office/PlacesListBox.cxx +++ b/fpicker/source/office/PlacesListBox.cxx @@ -14,96 +14,36 @@ #include <vcl/event.hxx> #include <bitmaps.hlst> -#define COLUMN_NAME 1 - - -PlacesListBox_Impl::PlacesListBox_Impl( PlacesListBox* pParent, const OUString& rTitle ) : - SvHeaderTabListBox( pParent, WB_TABSTOP | WB_NOINITIALSELECTION ), - mpHeaderBar( nullptr ), - mpParent( pParent ) -{ - Size aBoxSize = pParent->GetSizePixel( ); - mpHeaderBar = VclPtr<HeaderBar>::Create( pParent, WB_BUTTONSTYLE | WB_BOTTOMBORDER ); - mpHeaderBar->SetPosSizePixel( Point( 0, 0 ), Size( 600, 16 ) ); - - long aTabPositions[] = { 20, 600 }; - SetTabs( SAL_N_ELEMENTS(aTabPositions), aTabPositions, MapUnit::MapPixel ); - mpHeaderBar->InsertItem( COLUMN_NAME, rTitle, 600, HeaderBarItemBits::LEFT ); - - Size aHeadSize = mpHeaderBar->GetSizePixel(); - SetPosSizePixel( Point( 0, aHeadSize.getHeight() ), - Size( aBoxSize.getWidth(), aBoxSize.getHeight() - aHeadSize.getHeight() ) ); - - InitHeaderBar( mpHeaderBar ); - - Show( ); - mpHeaderBar->Show(); -} - -PlacesListBox_Impl::~PlacesListBox_Impl( ) -{ - disposeOnce(); -} - -void PlacesListBox_Impl::dispose() -{ - mpHeaderBar.disposeAndClear(); - mpParent.clear(); - SvHeaderTabListBox::dispose(); -} - -void PlacesListBox_Impl::MouseButtonUp( const MouseEvent& rMEvt ) -{ - SvHeaderTabListBox::MouseButtonUp( rMEvt ); - mpParent->updateView( ); -} - -PlacesListBox::PlacesListBox( vcl::Window* pParent, SvtFileDialog* pFileDlg, const OUString& rTitle, WinBits nBits ) : - Control( pParent, nBits ), - maPlaces( ), - mpDlg( pFileDlg ), - mpImpl( nullptr ), - mpAddBtn( ), - mpDelBtn( ), - mnNbEditables( 0 ), - mbUpdated( false ), - mbSelectionChanged( false ) -{ - mpImpl = VclPtr<PlacesListBox_Impl>::Create( this, rTitle ); - - mpImpl->SetSelectHdl( LINK( this, PlacesListBox, Selection ) ); - mpImpl->SetDoubleClickHdl( LINK( this, PlacesListBox, DoubleClick ) ) ; - - mpAddBtn.reset( VclPtr<ImageButton>::Create( this, 0 ) ); - mpAddBtn->SetText( "+" ); - mpAddBtn->SetPosSizePixel( Point( 0, 0 ), Size( 22, 22 ) ); - mpAddBtn->Show(); - - mpDelBtn.reset( VclPtr<ImageButton>::Create( this, 0 ) ); - mpDelBtn->SetText( "-" ); - mpDelBtn->SetPosSizePixel( Point( 0, 0 ), Size( 22, 22 ) ); - mpDelBtn->Show(); +PlacesListBox::PlacesListBox(std::unique_ptr<weld::TreeView> xControl, + std::unique_ptr<weld::Button> xAdd, + std::unique_ptr<weld::Button> xDel, + SvtFileDialog* pFileDlg) + : maPlaces( ) + , mpDlg(pFileDlg) + , mxImpl(std::move(xControl)) + , mxAddBtn(std::move(xAdd)) + , mxDelBtn(std::move(xDel)) + , mnNbEditables(0) + , mbUpdated( false ) + , mbSelectionChanged( false ) +{ + Size aSize(mxImpl->get_approximate_digit_width() * 18, + mxImpl->get_height_rows(9)); + mxImpl->set_size_request(aSize.Width(), aSize.Height()); + + mxImpl->connect_changed( LINK( this, PlacesListBox, Selection ) ); + mxImpl->connect_row_activated( LINK( this, PlacesListBox, DoubleClick ) ) ; } PlacesListBox::~PlacesListBox( ) { - disposeOnce(); -} - -void PlacesListBox::dispose() -{ - mpImpl.disposeAndClear(); - mpAddBtn.disposeAndClear(); - mpDelBtn.disposeAndClear(); - mpDlg.clear(); - Control::dispose(); } void PlacesListBox::AppendPlace( const PlacePtr& pPlace ) { maPlaces.push_back( pPlace ); - mpImpl->InsertEntry( pPlace->GetName( ), - getEntryIcon( pPlace ), getEntryIcon( pPlace ) ); + mxImpl->append_text(pPlace->GetName()); + mxImpl->set_image(maPlaces.size() - 1, getEntryIcon(pPlace)); if(pPlace->IsEditable()) { ++mnNbEditables; @@ -111,7 +51,6 @@ void PlacesListBox::AppendPlace( const PlacePtr& pPlace ) } } - bool PlacesListBox::IsUpdated() { if(mbUpdated) { mbUpdated = false; @@ -120,7 +59,6 @@ bool PlacesListBox::IsUpdated() { return false; } - void PlacesListBox::RemovePlace( sal_uInt16 nPos ) { if ( nPos < maPlaces.size() ) @@ -130,88 +68,61 @@ void PlacesListBox::RemovePlace( sal_uInt16 nPos ) mbUpdated = true; } maPlaces.erase( maPlaces.begin() + nPos ); - SvTreeListEntry* pEntry = mpImpl->GetEntry( nPos ); - mpImpl->RemoveEntry( pEntry ); + mxImpl->remove(nPos); } } void PlacesListBox::RemoveSelectedPlace() { - RemovePlace(mpImpl->GetCurrRow()); + RemovePlace(mxImpl->get_cursor_index()); } -void PlacesListBox::SetAddHdl( const Link<Button*,void>& rHdl ) +void PlacesListBox::SetAddHdl( const Link<weld::Button&,void>& rHdl ) { - mpAddBtn->SetClickHdl( rHdl ); + mxAddBtn->connect_clicked( rHdl ); } -void PlacesListBox::SetDelHdl( const Link<Button*,void>& rHdl ) +void PlacesListBox::SetDelHdl( const Link<weld::Button&,void>& rHdl ) { - mpDelBtn->SetClickHdl( rHdl ); + mxDelBtn->connect_clicked( rHdl ); } void PlacesListBox::SetDelEnabled( bool enabled ) { - mpDelBtn->Enable( enabled ); -} - -void PlacesListBox::SetSizePixel( const Size& rNewSize ) -{ - Control::SetSizePixel( rNewSize ); - Size aListSize( rNewSize ); - aListSize.AdjustHeight( -(26 + 18) ); - mpImpl->SetSizePixel( aListSize ); - - sal_Int32 nBtnY = rNewSize.Height() - 26; - mpAddBtn->SetPosPixel( Point( 3, nBtnY ) ); - mpDelBtn->SetPosPixel( Point( 6 + 24, nBtnY ) ); -} - -bool PlacesListBox::EventNotify( NotifyEvent& rNEvt ) -{ - if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); - const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode(); - - if( rCode.GetCode() == KEY_RETURN ) - { - mbSelectionChanged = true; - updateView(); - return true; - } - } - return Control::EventNotify(rNEvt); + mxDelBtn->set_sensitive( enabled ); } -Image PlacesListBox::getEntryIcon( const PlacePtr& pPlace ) +OUString PlacesListBox::getEntryIcon( const PlacePtr& pPlace ) { - Image theImage = SvtFileDialog::GetButtonImage( BMP_FILEDLG_PLACE_LOCAL ); + OUString theImage = BMP_FILEDLG_PLACE_LOCAL; if ( !pPlace->IsLocal( ) ) - theImage = SvtFileDialog::GetButtonImage( BMP_FILEDLG_PLACE_REMOTE ); + theImage = BMP_FILEDLG_PLACE_REMOTE; return theImage; } -IMPL_LINK_NOARG( PlacesListBox, Selection, SvTreeListBox*, void ) +IMPL_LINK_NOARG( PlacesListBox, Selection, weld::TreeView&, void ) { - sal_uInt32 nSelected = mpImpl->GetCurrRow(); + sal_uInt32 nSelected = mxImpl->get_cursor_index(); PlacePtr pPlace = maPlaces[nSelected]; mbSelectionChanged = true; - if(pPlace->IsEditable()) + if (pPlace->IsEditable()) mpDlg->RemovablePlaceSelected(); else mpDlg->RemovablePlaceSelected(false); + + updateView(); } -IMPL_LINK_NOARG( PlacesListBox, DoubleClick, SvTreeListBox*, bool ) +IMPL_LINK_NOARG( PlacesListBox, DoubleClick, weld::TreeView&, bool ) { - sal_uInt16 nSelected = mpImpl->GetCurrRow(); + sal_uInt16 nSelected = mxImpl->get_cursor_index(); PlacePtr pPlace = maPlaces[nSelected]; if ( pPlace->IsEditable() && !pPlace->IsLocal( ) ) { - PlaceEditDialog aDlg(mpDlg->GetFrameWeld(), pPlace); + PlaceEditDialog aDlg(mpDlg->getDialog(), pPlace); short aRetCode = aDlg.run(); - switch(aRetCode) { + switch (aRetCode) + { case RET_OK : { pPlace->SetName ( aDlg.GetServerName() ); @@ -228,18 +139,14 @@ IMPL_LINK_NOARG( PlacesListBox, DoubleClick, SvTreeListBox*, bool ) break; }; } - return false; + return true; } void PlacesListBox::updateView( ) { - if ( mbSelectionChanged ) - { - mbSelectionChanged = false; - sal_uInt32 nSelected = mpImpl->GetCurrRow(); - PlacePtr pPlace = maPlaces[nSelected]; - mpDlg->OpenURL_Impl( pPlace->GetUrl( ) ); - } + sal_uInt32 nSelected = mxImpl->get_cursor_index(); + PlacePtr pPlace = maPlaces[nSelected]; + mpDlg->OpenURL_Impl( pPlace->GetUrl( ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/PlacesListBox.hxx b/fpicker/source/office/PlacesListBox.hxx index 81a11f0e8123..151a0d1d4a01 100644 --- a/fpicker/source/office/PlacesListBox.hxx +++ b/fpicker/source/office/PlacesListBox.hxx @@ -12,72 +12,60 @@ #include "iodlg.hxx" #include <svtools/place.hxx> -#include <vcl/svtabbx.hxx> +#include <vcl/weld.hxx> #include <memory> #include <vector> -typedef std::shared_ptr< Place > PlacePtr; +typedef std::shared_ptr<Place> PlacePtr; class PlacesListBox; -class PlacesListBox_Impl : public SvHeaderTabListBox -{ - private: - VclPtr<HeaderBar> mpHeaderBar; - VclPtr<PlacesListBox> mpParent; - - public: - PlacesListBox_Impl( PlacesListBox* pParent, const OUString& rTitle ); - virtual ~PlacesListBox_Impl( ) override; - virtual void dispose() override; - - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; -}; /** ListBox to handle Places. */ -class PlacesListBox : public Control +class PlacesListBox { - private: - std::vector< PlacePtr > maPlaces; - VclPtr<SvtFileDialog> mpDlg; - VclPtr<PlacesListBox_Impl> mpImpl; - VclPtr<PushButton> mpAddBtn; - VclPtr<PushButton> mpDelBtn; - sal_Int32 mnNbEditables; - bool mbUpdated; - bool mbSelectionChanged; - - public: - PlacesListBox( vcl::Window* pParent, SvtFileDialog* pFileDlg, const OUString& rTitle, WinBits nBits ); - virtual ~PlacesListBox( ) override; - virtual void dispose() override; - - void AppendPlace( const PlacePtr& pPlace ); - void RemovePlace( sal_uInt16 nPos ); - void RemoveSelectedPlace(); - sal_Int32 GetNbEditablePlaces() const { return mnNbEditables;} - bool IsUpdated(); - const std::vector<PlacePtr>& GetPlaces() const { return maPlaces;} - - void SetAddHdl( const Link<Button*,void>& rHdl ); - void SetDelHdl( const Link<Button*,void>& rHdl ); - void SetDelEnabled( bool enabled ); - void SetSizePixel( const Size& rNewSize ) override; - void updateView( ); - - const VclPtr<PushButton>& GetAddButton() const { return mpAddBtn; } - const VclPtr<PushButton>& GetDeleteButton() const { return mpDelBtn; } - const VclPtr<PlacesListBox_Impl>& GetPlacesListBox() const { return mpImpl; } - - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - - private: - - static Image getEntryIcon( const PlacePtr& pPlace ); - - DECL_LINK( Selection, SvTreeListBox*, void ); - DECL_LINK( DoubleClick, SvTreeListBox*, bool ); +private: + std::vector<PlacePtr> maPlaces; + SvtFileDialog* mpDlg; + std::unique_ptr<weld::TreeView> mxImpl; + std::unique_ptr<weld::Button> mxAddBtn; + std::unique_ptr<weld::Button> mxDelBtn; + sal_Int32 mnNbEditables; + bool mbUpdated; + bool mbSelectionChanged; + +public: + PlacesListBox(std::unique_ptr<weld::TreeView> xTreeView, + std::unique_ptr<weld::Button> xAddBtn, + std::unique_ptr<weld::Button> xDelBtn, + SvtFileDialog* pFileDlg); + ~PlacesListBox(); + + void AppendPlace( const PlacePtr& pPlace ); + void RemovePlace( sal_uInt16 nPos ); + void RemoveSelectedPlace(); + sal_Int32 GetNbEditablePlaces() const { return mnNbEditables;} + bool IsUpdated(); + const std::vector<PlacePtr>& GetPlaces() const { return maPlaces;} + + void SetAddHdl( const Link<weld::Button&,void>& rHdl ); + void SetDelHdl( const Link<weld::Button&,void>& rHdl ); + void SetDelEnabled( bool enabled ); + void updateView( ); + + void set_help_id(const OString& rHelpId) { mxImpl->set_help_id(rHelpId); } + + const weld::Button& GetAddButton() const { return *mxAddBtn; } + const weld::Button& GetDeleteButton() const { return *mxDelBtn; } + weld::TreeView& GetPlacesListBox() { return *mxImpl; } + +private: + + static OUString getEntryIcon(const PlacePtr& pPlace); + + DECL_LINK( Selection, weld::TreeView&, void ); + DECL_LINK( DoubleClick, weld::TreeView&, bool ); }; #endif diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index 97aa44706a6d..a795338581f4 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -22,7 +22,6 @@ #include <svtools/PlaceEditDialog.hxx> #include <tools/debug.hxx> #include <ucbhelper/commandenvironment.hxx> -#include <vcl/dialog.hxx> #include <vcl/errinf.hxx> #include <vcl/lstbox.hxx> #include <vcl/treelistentry.hxx> @@ -30,183 +29,25 @@ #include <vcl/ptrstyle.hxx> #include <officecfg/Office/Common.hxx> -class FileViewContainer : public vcl::Window -{ - enum FocusState - { - Prev = 0, - TreeView, - FileView, - Next, - FocusCount - }; - - private: - VclPtr< SvtFileView > m_pFileView; - VclPtr< FolderTree > m_pTreeView; - VclPtr< Splitter > m_pSplitter; - - int m_nCurrentFocus; - VclPtr<vcl::Window> m_pFocusWidgets[FocusState::FocusCount]; - - public: - explicit FileViewContainer( vcl::Window *pParent ) - : Window( pParent, WB_TABSTOP ) - , m_pFileView( nullptr ) - , m_pTreeView( nullptr ) - , m_pSplitter( nullptr ) - , m_nCurrentFocus( 0 ) - { - } - - virtual ~FileViewContainer() override - { - disposeOnce(); - } - - virtual void dispose() override - { - m_pFileView.clear(); - m_pTreeView.clear(); - m_pSplitter.clear(); - vcl::Window::dispose(); - } - - void init( SvtFileView* pFileView, - Splitter* pSplitter, - FolderTree* pTreeView, - vcl::Window* pPrevSibling, - vcl::Window* pNextSibling ) - { - m_pFileView = pFileView; - m_pTreeView = pTreeView; - m_pSplitter = pSplitter; - m_pFocusWidgets[FocusState::Prev] = pPrevSibling; - m_pFocusWidgets[FocusState::TreeView] = pTreeView; - m_pFocusWidgets[FocusState::FileView] = pFileView; - m_pFocusWidgets[FocusState::Next] = pNextSibling; - } - - virtual void Resize() override - { - Window::Resize(); - - if( !m_pFileView || !m_pTreeView ) - return; - - Size aSize = GetSizePixel(); - Point aPos( m_pFileView->GetPosPixel() ); - Size aNewSize( aSize.Width() - aPos.X(), aSize.Height() ); - - m_pFileView->SetSizePixel( aNewSize ); - - // Resize the Splitter to fit the height - Size splitterNewSize = m_pSplitter->GetSizePixel(); - splitterNewSize.setHeight( aSize.Height() ); - m_pSplitter->SetSizePixel( splitterNewSize ); - sal_Int32 nMinX = m_pTreeView->GetPosPixel().X(); - sal_Int32 nMaxX = m_pFileView->GetPosPixel().X() + m_pFileView->GetSizePixel().Width() - nMinX; - m_pSplitter->SetDragRectPixel( tools::Rectangle( Point( nMinX, 0 ), Size( nMaxX, aSize.Width() ) ) ); - - // Resize the tree list box to fit the height of the FileView - Size placesNewSize( m_pTreeView->GetSizePixel() ); - placesNewSize.setHeight( aSize.Height() ); - m_pTreeView->SetSizePixel( placesNewSize ); - } - - void changeFocus( bool bReverse ) - { - if( !m_pFileView || !m_pTreeView ) - 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( !m_pFileView || !m_pTreeView ) - return; - - GetFocusFlags aFlags = GetGetFocusFlags(); - - if( aFlags & GetFocusFlags::Forward ) - m_nCurrentFocus = FocusState::TreeView; - 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); - } -}; - -RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, PickerFlags nBits ) - : SvtFileDialog_Base( pParent, "RemoteFilesDialog", "fps/ui/remotefilesdialog.ui" ) +RemoteFilesDialog::RemoteFilesDialog( weld::Window* pParent, PickerFlags nBits ) + : SvtFileDialog_Base( pParent, "fps/ui/remotefilesdialog.ui", "RemoteFilesDialog" ) , m_xContext( comphelper::getProcessComponentContext() ) , m_xMasterPasswd( PasswordContainer::create( m_xContext ) ) , m_nWidth( 0 ) , m_nHeight( 0 ) - , m_pSplitter( nullptr ) - , m_pFileView( nullptr ) - , m_pContainer( nullptr ) - , m_pAddMenu( nullptr ) + , m_bIsInExecute( false ) + , m_xCancel_btn(m_xBuilder->weld_button("cancel")) + , m_xAddService_bar(m_xBuilder->weld_toolbar("add_service_bar")) + , m_xAddService_menu(m_xBuilder->weld_menu("service_edit_menu")) + , m_xServices_lb(m_xBuilder->weld_combo_box("services_lb")) + , m_xPathContainer(m_xBuilder->weld_container("breadcrumb_container")) + , m_xNewFolder(m_xBuilder->weld_button("new_folder")) + , m_xListView_btn(m_xBuilder->weld_toggle_button("list_view")) + , m_xIconView_btn(m_xBuilder->weld_toggle_button("icon_view")) + , m_xFilter_lb(m_xBuilder->weld_combo_box("filter_lb")) + , m_xName_ed(new AutocompleteEdit(m_xBuilder->weld_entry("filename"))) { - get( m_pCancel_btn, "cancel" ); - get( m_pAddService_btn, "add_service_btn" ); - get( m_pServices_lb, "services_lb" ); - get( m_pFilter_lb, "filter_lb" ); - get( m_pNewFolder, "new_folder" ); - get( m_pListView_btn, "list_view" ); - get( m_pIconView_btn, "icon_view" ); + m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get()); m_eMode = ( nBits & PickerFlags::SaveAs ) ? REMOTEDLG_MODE_SAVE : REMOTEDLG_MODE_OPEN; m_eType = ( nBits & PickerFlags::PathDialog ) ? REMOTEDLG_TYPE_PATHDLG : REMOTEDLG_TYPE_FILEDLG; @@ -214,124 +55,94 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, PickerFlags nBits ) m_bIsUpdated = false; m_bIsConnected = false; m_bServiceChanged = false; - m_nCurrentFilter = LISTBOX_ENTRY_NOTFOUND; + m_nCurrentFilter = -1; - m_pName_ed = VclPtr< AutocompleteEdit >::Create( get< vcl::Window >( "filename_container" ) ); - m_pName_ed->Show(); + m_xName_ed->show(); - m_pFilter_lb->Enable( false ); - m_pName_ed->Enable( false ); - m_pNewFolder->Enable( false ); + // limit width due to super wide strings that may end up here + m_xFilter_lb->set_size_request(m_xFilter_lb->get_approximate_digit_width() * 60, -1); + + m_xFilter_lb->set_sensitive(false); + m_xName_ed->set_sensitive(false); + m_xNewFolder->set_sensitive(false); if( m_eMode == REMOTEDLG_MODE_OPEN ) { - get( m_pOk_btn, "open" ); + m_xOk_btn = m_xBuilder->weld_button("open"); - m_pNewFolder->Hide(); + m_xNewFolder->hide(); } else { - get( m_pOk_btn, "save" ); - - m_pNewFolder->SetModeImage(Image(StockImage::Yes, BMP_FILEDLG_CREATEFOLDER)); - m_pNewFolder->SetClickHdl( LINK( this, RemoteFilesDialog, NewFolderHdl ) ); + m_xOk_btn = m_xBuilder->weld_button("save"); + m_xNewFolder->connect_clicked( LINK( this, RemoteFilesDialog, NewFolderHdl ) ); } - m_pIconView_btn->SetClickHdl( LINK( this, RemoteFilesDialog, IconViewHdl ) ); - m_pListView_btn->SetClickHdl( LINK( this, RemoteFilesDialog, ListViewHdl ) ); + m_xListView_btn->set_active(true); + m_xIconView_btn->connect_clicked( LINK( this, RemoteFilesDialog, IconViewHdl ) ); + m_xListView_btn->connect_clicked( LINK( this, RemoteFilesDialog, ListViewHdl ) ); - m_pOk_btn->Show(); - m_pOk_btn->Enable( false ); + m_xOk_btn->show(); + m_xOk_btn->set_sensitive(false); - m_pOk_btn->SetClickHdl( LINK( this, RemoteFilesDialog, OkHdl ) ); - m_pCancel_btn->SetClickHdl( LINK( this, RemoteFilesDialog, CancelHdl ) ); + m_xOk_btn->connect_clicked( LINK( this, RemoteFilesDialog, OkHdl ) ); + m_xCancel_btn->connect_clicked( LINK( this, RemoteFilesDialog, CancelHdl ) ); m_sRootLabel = FpsResId( STR_SVT_ROOTLABEL ); - m_pPath = VclPtr<Breadcrumb>::Create( get< vcl::Window >( "breadcrumb_container" ) ); - m_pPath->set_hexpand( true ); - m_pPath->SetClickHdl( LINK( this, RemoteFilesDialog, SelectBreadcrumbHdl ) ); - m_pPath->SetMode( SvtBreadcrumbMode::ALL_VISITED ); - m_pPath->Show(); - - m_pContainer = VclPtr< FileViewContainer >::Create( get< vcl::Window >("container") ); - - m_pContainer->set_hexpand( true ); - m_pContainer->set_vexpand( true ); - - m_pFileView = VclPtr< SvtFileView >::Create( m_pContainer, WB_BORDER | WB_TABSTOP, - REMOTEDLG_TYPE_PATHDLG == m_eType, - bMultiselection, false ); - - m_pFileView->Show(); - m_pFileView->EnableAutoResize(); - m_pFileView->SetDoubleClickHdl( LINK( this, RemoteFilesDialog, DoubleClickHdl ) ); - m_pFileView->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectHdl ) ); - m_pFileView->EnableDelete( true ); - - m_pSplitter = VclPtr< Splitter >::Create( m_pContainer, WB_HSCROLL ); - m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ) ); - m_pSplitter->SetSplitHdl( LINK( this, RemoteFilesDialog, SplitHdl ) ); - m_pSplitter->Show(); - - m_pTreeView = VclPtr< FolderTree >::Create( m_pContainer, WB_BORDER ); - Size aSize( 150, 200 ); - m_pTreeView->set_height_request( aSize.Height() ); - m_pTreeView->set_width_request( aSize.Width() ); - m_pTreeView->SetSizePixel( aSize ); - m_pTreeView->Show(); - - m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) ); - - sal_Int32 nPosX = m_pTreeView->GetSizePixel().Width(); - m_pSplitter->SetPosPixel( Point( nPosX, 0 ) ); - nPosX += m_pSplitter->GetSizePixel().Width(); - m_pFileView->SetPosPixel( Point( nPosX, 0 ) ); - - m_pContainer->init( m_pFileView, m_pSplitter, m_pTreeView, m_pAddService_btn, m_pFilter_lb ); - m_pContainer->Show(); - m_pContainer->Enable( false ); + m_xPath.reset(new Breadcrumb(m_xPathContainer.get())); + m_xPath->connect_clicked( LINK( this, RemoteFilesDialog, SelectBreadcrumbHdl ) ); + m_xPath->SetMode( SvtBreadcrumbMode::ALL_VISITED ); + + m_xContainer = m_xBuilder->weld_container("container"); + m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 82, -1); + + m_xFileView.reset(new SvtFileView(m_xDialog.get(), + m_xBuilder->weld_tree_view("fileview"), + m_xBuilder->weld_icon_view("iconview"), + REMOTEDLG_TYPE_PATHDLG == m_eType, + bMultiselection, false)); + + m_xFileView->SetDoubleClickHdl( LINK( this, RemoteFilesDialog, DoubleClickHdl ) ); + m_xFileView->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectHdl ) ); + m_xFileView->EnableDelete( true ); + + m_xTreeView.reset(new FolderTree(m_xBuilder->weld_tree_view("foldertree"), m_xDialog.get())); + m_xTreeView->connect_changed(LINK(this, RemoteFilesDialog, TreeSelectHdl)); + + m_xContainer->set_sensitive(false); m_sIniKey = "RemoteFilesDialog"; InitSize(); - m_pName_ed->SetGetFocusHdl( LINK( this, RemoteFilesDialog, FileNameGetFocusHdl ) ); - m_pName_ed->SetModifyHdl( LINK( this, RemoteFilesDialog, FileNameModifyHdl ) ); - - m_pAddService_btn->SetDelayMenu(true); - m_pAddService_btn->SetDropDown(PushButtonDropdownStyle::SplitMenuButton); + m_xName_ed->connect_focus_in(LINK(this, RemoteFilesDialog, FileNameGetFocusHdl)); + m_xName_ed->connect_changed(LINK(this, RemoteFilesDialog, FileNameModifyHdl)); - m_pAddMenu = m_pAddService_btn->GetPopupMenu(); - m_pAddService_btn->SetClickHdl( LINK( this, RemoteFilesDialog, AddServiceHdl ) ); - m_pAddService_btn->SetSelectHdl( LINK( this, RemoteFilesDialog, EditServiceMenuHdl ) ); + m_xAddService_bar->connect_clicked(LINK( this, RemoteFilesDialog, AddServiceHdl)); + m_xAddService_menu->connect_activate(LINK(this, RemoteFilesDialog, EditServiceMenuHdl)); FillServicesListbox(); - m_pServices_lb->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectServiceHdl ) ); + m_xServices_lb->connect_changed( LINK( this, RemoteFilesDialog, SelectServiceHdl ) ); - m_pFilter_lb->SetSelectHdl( LINK( this, RemoteFilesDialog, SelectFilterHdl ) ); + m_xFilter_lb->connect_changed( LINK( this, RemoteFilesDialog, SelectFilterHdl ) ); } RemoteFilesDialog::~RemoteFilesDialog() { - disposeOnce(); -} - -void RemoteFilesDialog::dispose() -{ - m_pFileView->SetSelectHdl( Link<SvTreeListBox*,void>() ); + m_xFileView->SetSelectHdl(Link<SvtFileView*,void>()); // save window state if( !m_sIniKey.isEmpty() ) { SvtViewOptions aDlgOpt( EViewType::Dialog, m_sIniKey ); - aDlgOpt.SetWindowState( OStringToOUString( GetWindowState(), osl_getThreadTextEncoding() ) ); + aDlgOpt.SetWindowState(OStringToOUString(m_xDialog->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_UTF8)); - Size aSize( GetSizePixel() ); + Size aSize(m_xDialog->get_size()); OUString sSize = OUString::number( aSize.Width() ) + "|"; sSize = sSize + OUString::number( aSize.Height() ) + "|"; - OUString sUserData = m_pFileView->GetConfigString(); + OUString sUserData = m_xFileView->GetConfigString(); aDlgOpt.SetUserItem( "UserData", makeAny( sSize + sUserData ) ); } @@ -359,68 +170,27 @@ void RemoteFilesDialog::dispose() } batch->commit(); - - m_pTreeView.disposeAndClear(); - m_pFileView.disposeAndClear(); - m_pSplitter.disposeAndClear(); - m_pContainer.disposeAndClear(); - m_pPath.disposeAndClear(); - - m_pOk_btn.clear(); - m_pCancel_btn.clear(); - m_pAddService_btn.clear(); - m_pServices_lb.clear(); - m_pFilter_lb.clear(); - m_pName_ed.disposeAndClear(); - m_pNewFolder.clear(); - m_pIconView_btn.clear(); - m_pListView_btn.clear(); - m_pAddMenu.clear(); - - Dialog::dispose(); } -void RemoteFilesDialog::Resize() +short RemoteFilesDialog::run() { - Dialog::Resize(); - - if( m_pFileView && m_pContainer ) + if (m_xServices_lb->get_count() > 0) { - Size aSize = m_pContainer->GetSizePixel(); - m_pFileView->SetSizePixel( aSize ); + m_xDialog->show(); + SelectServiceHdl(*m_xServices_lb); } - Invalidate(InvalidateFlags::Update); -} - -short RemoteFilesDialog::Execute() -{ - if( m_pServices_lb->GetEntryCount() > 0 ) - { - Show(); - SelectServiceHdl( *m_pServices_lb ); - } - if( !m_bIsConnected ) + if (!m_bIsConnected) { - m_pServices_lb->SetNoSelection(); - m_pAddService_btn->SetPopupMenu( nullptr ); + m_xServices_lb->set_active(-1); + m_xAddService_bar->set_item_menu("add_service_btn", nullptr); } - short nRet = SvtFileDialog_Base::Execute(); - + m_bIsInExecute = true; + short nRet = SvtFileDialog_Base::run(); + m_bIsInExecute = false; return nRet; } -void RemoteFilesDialog::Show() -{ - SvtFileDialog_Base::Show(); - - if( m_nWidth > 0 && m_nHeight > 0 ) - { - Size aSize( m_nWidth, m_nHeight ); - SetSizePixel( aSize ); - } -} - static OUString lcl_GetServiceType( const ServicePtr& pService ) { INetProtocol aProtocol = pService->GetUrlObject().GetProtocol(); @@ -466,7 +236,7 @@ void RemoteFilesDialog::InitSize() 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; @@ -480,16 +250,14 @@ void RemoteFilesDialog::InitSize() return; m_nWidth = sCfgStr.copy(0, nPos1++).toInt32(); m_nHeight = sCfgStr.copy(nPos1, nPos2-nPos1).toInt32(); - m_pFileView->SetConfigString( sCfgStr.copy(nPos2+1) ); + m_xFileView->SetConfigString( sCfgStr.copy(nPos2+1) ); } } - else - m_pFileView->SetConfigString( "" ); } void RemoteFilesDialog::FillServicesListbox() { - m_pServices_lb->Clear(); + m_xServices_lb->clear(); m_aServices.clear(); // Load from user settings @@ -517,31 +285,32 @@ void RemoteFilesDialog::FillServicesListbox() if( placesUrlsList[nPlace] == m_sLastServiceUrl ) nPos = i; - m_pServices_lb->InsertEntry( sPrefix + placesNamesList[nPlace] ); + m_xServices_lb->append_text(sPrefix + placesNamesList[nPlace]); i++; } } - if( m_pServices_lb->GetEntryCount() > 0 ) + if (m_xServices_lb->get_count() > 0) { - m_pServices_lb->SelectEntryPos( nPos ); - m_pAddService_btn->SetPopupMenu( m_pAddMenu ); + m_xServices_lb->set_active(nPos); + m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get()); } else - m_pAddService_btn->SetPopupMenu( nullptr ); + m_xAddService_bar->set_item_menu("add_service_btn", nullptr); EnableControls(); } int RemoteFilesDialog::GetSelectedServicePos() { - int nSelected = m_pServices_lb->GetSelectedEntryPos(); + if( m_aServices.empty() ) + return -1; + int nPos = 0; int i = -1; - if( m_aServices.empty() ) - return -1; + int nSelected = m_xServices_lb->get_active(); int nServices = static_cast<int>(m_aServices.size()); while( nPos < nServices ) @@ -561,94 +330,85 @@ void RemoteFilesDialog::AddFilter( const OUString& rFilter, const OUString& rTyp { OUString sName = rFilter; - if ( rType.isEmpty() ) - sName = "------------------------------------------"; - m_aFilters.emplace_back( rFilter, rType ); - m_pFilter_lb->InsertEntry( sName ); + if (rType.isEmpty()) + m_xFilter_lb->append_separator(""); + else + m_xFilter_lb->append_text(sName); - if( m_pFilter_lb->GetSelectedEntryPos() == LISTBOX_ENTRY_NOTFOUND ) - m_pFilter_lb->SelectEntryPos( 0 ); + if (m_xFilter_lb->get_active() == -1) + m_xFilter_lb->set_active(0); } - void RemoteFilesDialog::OpenURL( OUString const & sURL ) { - if( m_pFileView ) + if( m_xFileView ) { - m_pTreeView->EndSelection(); DisableControls(); - EnableChildPointerOverwrite( true ); - SetPointer( PointerStyle::Wait ); - Invalidate(InvalidateFlags::Update); + auto xWait = std::make_unique<weld::WaitObject>(m_xDialog.get()); if( !sURL.isEmpty() ) { OUString sFilter = FILEDIALOG_FILTER_ALL; - if( m_nCurrentFilter != LISTBOX_ENTRY_NOTFOUND ) + if( m_nCurrentFilter != -1) { sFilter = m_aFilters[m_nCurrentFilter].second; } - m_pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); DBG_ASSERT( !m_pCurrentAsyncAction.is(), "SvtFileDialog::executeAsync: previous async action not yet finished!" ); - m_pCurrentAsyncAction = new AsyncPickerAction( this, m_pFileView, AsyncPickerAction::Action::eOpenURL ); + m_pCurrentAsyncAction = new AsyncPickerAction( this, m_xFileView.get(), AsyncPickerAction::Action::eOpenURL ); // -1 timeout - sync m_pCurrentAsyncAction->execute( sURL, sFilter, -1, -1, GetBlackList() ); if( m_eMode != REMOTEDLG_MODE_SAVE ) - m_pName_ed->SetText( "" ); + m_xName_ed->set_text( "" ); - m_pFileView->GrabFocus(); + m_xFileView->grab_focus(); } else { - SetPointer( PointerStyle::Arrow ); - EnableChildPointerOverwrite( false ); + xWait.reset(); // content doesn't exist ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTS ); EnableControls(); - return; } - - SetPointer( PointerStyle::Arrow ); - EnableChildPointerOverwrite( false ); } } void RemoteFilesDialog::AddFileExtension() { - if( m_nCurrentFilter != LISTBOX_ENTRY_NOTFOUND ) + if (m_nCurrentFilter != -1) { OUString sExt = m_aFilters[m_nCurrentFilter].second; - OUString sFileName = m_pName_ed->GetText(); + OUString sFileName = m_xName_ed->get_text(); sal_Int32 nDotPos = sFileName.lastIndexOf( '.' ); if ( nDotPos == -1 ) { sFileName += sExt.copy( 1 ); // without '*' - m_pName_ed->SetText( sFileName ); + m_xName_ed->set_text( sFileName ); } } } void RemoteFilesDialog::EnableControls() { - if( m_pServices_lb->GetEntryCount() > 0 ) + if (m_xServices_lb->get_count() > 0) { - m_pServices_lb->Enable(); + m_xServices_lb->set_sensitive(true); - if( m_pServices_lb->GetSelectedEntryCount() ) + if (m_xServices_lb->get_active() != -1) { - m_pAddMenu->EnableItem( "change_password", false ); + m_xAddService_menu->set_sensitive("change_password", false); try { @@ -664,7 +424,7 @@ void RemoteFilesDialog::EnableControls() if( aURLEntries.UserList.hasElements() ) { - m_pAddMenu->EnableItem( "change_password" ); + m_xAddService_menu->set_sensitive("change_password", true); } } } @@ -674,50 +434,48 @@ void RemoteFilesDialog::EnableControls() } } else - m_pServices_lb->Enable( false ); + m_xServices_lb->set_sensitive(false); if( m_bIsConnected ) { - m_pFilter_lb->Enable(); - m_pName_ed->Enable(); - m_pContainer->Enable(); - m_pNewFolder->Enable(); + m_xFilter_lb->set_sensitive(true); + m_xName_ed->set_sensitive(true); + m_xContainer->set_sensitive(true); + m_xNewFolder->set_sensitive(true); - if( !m_pName_ed->GetText().isEmpty() ) - m_pOk_btn->Enable(); + if (!m_xName_ed->get_text().isEmpty()) + m_xOk_btn->set_sensitive(true); else - m_pOk_btn->Enable( false ); + m_xOk_btn->set_sensitive(false); } else { - m_pFilter_lb->Enable( false ); - m_pName_ed->Enable( false ); - m_pContainer->Enable( false ); - m_pNewFolder->Enable( false ); - m_pOk_btn->Enable( false ); + m_xFilter_lb->set_sensitive(false); + m_xName_ed->set_sensitive(false); + m_xContainer->set_sensitive(false); + m_xNewFolder->set_sensitive(false); + m_xOk_btn->set_sensitive(false); } - m_pPath->EnableFields( true ); - m_pAddService_btn->Enable(); - - Invalidate(InvalidateFlags::Update); + m_xPath->EnableFields( true ); + m_xAddService_bar->set_sensitive(true); } void RemoteFilesDialog::DisableControls() { - m_pServices_lb->Enable( false ); - m_pFilter_lb->Enable( false ); - m_pAddService_btn->Enable( false ); - m_pName_ed->Enable( false ); - m_pContainer->Enable( false ); - m_pOk_btn->Enable( false ); - m_pPath->EnableFields( false ); - - m_pCancel_btn->Enable(); + m_xServices_lb->set_sensitive(false); + m_xFilter_lb->set_sensitive(false); + m_xAddService_bar->set_sensitive(false); + m_xName_ed->set_sensitive(false); + m_xContainer->set_sensitive(false); + m_xOk_btn->set_sensitive(false); + m_xPath->EnableFields( false ); + + m_xCancel_btn->set_sensitive(true); } -void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUser - , const OUString& rPassword, bool bPersistent ) +void RemoteFilesDialog::SavePassword(const OUString& rURL, const OUString& rUser, + const OUString& rPassword, bool bPersistent) { if( rURL.isEmpty() || rUser.isEmpty() || rPassword.isEmpty() ) return; @@ -745,19 +503,21 @@ void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUse {} } -IMPL_LINK_NOARG ( RemoteFilesDialog, IconViewHdl, Button*, void ) +IMPL_LINK_NOARG ( RemoteFilesDialog, IconViewHdl, weld::Button&, void ) { - m_pFileView->SetViewMode( eIcon ); + m_xListView_btn->set_active(false); + m_xFileView->SetViewMode( eIcon ); } -IMPL_LINK_NOARG ( RemoteFilesDialog, ListViewHdl, Button*, void ) +IMPL_LINK_NOARG ( RemoteFilesDialog, ListViewHdl, weld::Button&, void ) { - m_pFileView->SetViewMode( eDetailedList ); + m_xIconView_btn->set_active(false); + m_xFileView->SetViewMode( eDetailedList ); } -IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, Button*, void ) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
