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 | |
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>
60 files changed, 4005 insertions, 3582 deletions
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 ) +IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, const OString&, void ) { - PlaceEditDialog aDlg(GetFrameWeld()); + PlaceEditDialog aDlg(m_xDialog.get()); aDlg.ShowPasswordControl(); short aRetCode = aDlg.run(); @@ -781,10 +541,10 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, Button*, void ) if(!sPrefix.isEmpty()) sPrefix += ": "; - m_pServices_lb->InsertEntry( sPrefix + newService->GetName() ); - m_pServices_lb->SelectEntryPos( m_pServices_lb->GetEntryCount() - 1 ); - m_pAddService_btn->SetPopupMenu( m_pAddMenu ); - SelectServiceHdl( *m_pServices_lb ); + m_xServices_lb->append_text( sPrefix + newService->GetName() ); + m_xServices_lb->set_active( m_xServices_lb->get_count() - 1 ); + m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get()); + SelectServiceHdl( *m_xServices_lb ); m_bIsUpdated = true; @@ -798,31 +558,31 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl, Button*, void ) }; } -IMPL_LINK_NOARG( RemoteFilesDialog, SelectServiceHdl, ListBox&, void ) +IMPL_LINK_NOARG( RemoteFilesDialog, SelectServiceHdl, weld::ComboBox&, void ) { int nPos = GetSelectedServicePos(); if( nPos >= 0 ) { OUString sURL = m_aServices[nPos]->GetUrl(); - m_pAddService_btn->SetPopupMenu( m_pAddMenu ); + m_xAddService_bar->set_item_menu("add_service_btn", m_xAddService_menu.get()); m_bServiceChanged = true; OpenURL( sURL ); } } -IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void ) +IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, const OString&, rIdent, void ) { - OString sIdent( pButton->GetCurItemIdent() ); - if( sIdent == "edit_service" && m_pServices_lb->GetEntryCount() > 0 ) + OString sIdent(rIdent); + if( sIdent == "edit_service" && m_xServices_lb->get_count() > 0 ) { - unsigned int nSelected = m_pServices_lb->GetSelectedEntryPos(); + int nSelected = m_xServices_lb->get_active(); int nPos = GetSelectedServicePos(); if( nPos >= 0 ) { - PlaceEditDialog aDlg(GetFrameWeld(), m_aServices[nPos]); + PlaceEditDialog aDlg(m_xDialog.get(), m_aServices[nPos]); short aRetCode = aDlg.run(); switch( aRetCode ) @@ -832,15 +592,15 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void ) ServicePtr pEditedService = aDlg.GetPlace(); m_aServices[nPos] = pEditedService; - m_pServices_lb->RemoveEntry( nSelected ); + m_xServices_lb->remove( nSelected ); OUString sPrefix = lcl_GetServiceType( pEditedService ); if(!sPrefix.isEmpty()) sPrefix += ": "; - m_pServices_lb->InsertEntry( sPrefix + pEditedService->GetName(), nSelected ); - m_pServices_lb->SelectEntryPos( nSelected ); + m_xServices_lb->insert_text(nSelected, sPrefix + pEditedService->GetName()); + m_xServices_lb->set_active( nSelected ); m_bIsUpdated = true; break; @@ -855,16 +615,16 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void ) }; } } - if( sIdent == "delete_service" && m_pServices_lb->GetEntryCount() > 0 ) + if( sIdent == "delete_service" && m_xServices_lb->get_count() > 0 ) { - unsigned int nSelected = m_pServices_lb->GetSelectedEntryPos(); + int nSelected = m_xServices_lb->get_active(); int nPos = GetSelectedServicePos(); if( nPos >= 0 ) { OUString sMsg = FpsResId( STR_SVT_DELETESERVICE ); - sMsg = sMsg.replaceFirst( "$servicename$", m_pServices_lb->GetSelectedEntry() ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + sMsg = sMsg.replaceFirst( "$servicename$", m_xServices_lb->get_active_text() ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, sMsg)); if (xBox->run() == RET_YES) { @@ -892,10 +652,10 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void ) {} m_aServices.erase( m_aServices.begin() + nPos ); - m_pServices_lb->RemoveEntry( nSelected ); + m_xServices_lb->remove( nSelected ); - 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); m_bIsUpdated = true; @@ -950,128 +710,81 @@ IMPL_LINK ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, void ) EnableControls(); } -IMPL_LINK_NOARG( RemoteFilesDialog, DoubleClickHdl, SvTreeListBox*, bool ) +IMPL_LINK_NOARG( RemoteFilesDialog, DoubleClickHdl, SvtFileView*, bool ) { - if( m_pFileView->GetSelectionCount() ) + SvtContentEntry* pData = m_xFileView->FirstSelected(); + if (pData) { - SvTreeListEntry* pEntry = m_pFileView->FirstSelected(); - - if( pEntry ) - { - SvtContentEntry* pData = static_cast< SvtContentEntry* >( pEntry->GetUserData() ); - - if( pData ) - { - if( !pData->mbIsFolder ) - { - EndDialog( RET_OK ); - } - else - { - OpenURL( pData->maURL ); - } - } - } + if (!pData->mbIsFolder) + m_xDialog->response(RET_OK); + else + OpenURL(pData->maURL); } - return true; } -IMPL_LINK_NOARG( RemoteFilesDialog, SelectHdl, SvTreeListBox*, void ) +IMPL_LINK_NOARG( RemoteFilesDialog, SelectHdl, SvtFileView*, void ) { - SvTreeListEntry* pEntry = m_pFileView->FirstSelected(); - - if( pEntry ) + SvtContentEntry* pData = m_xFileView->FirstSelected(); + if (pData) { - SvtContentEntry* pData = static_cast< SvtContentEntry* >( pEntry->GetUserData() ); - - if( pData ) + if( ( pData->mbIsFolder && ( m_eType == REMOTEDLG_TYPE_PATHDLG ) ) + || ( !pData->mbIsFolder && ( m_eType == REMOTEDLG_TYPE_FILEDLG ) ) ) { - if( ( pData->mbIsFolder && ( m_eType == REMOTEDLG_TYPE_PATHDLG ) ) - || ( !pData->mbIsFolder && ( m_eType == REMOTEDLG_TYPE_FILEDLG ) ) ) - { - // url must contain user info, because we need this info in recent files entry - // (to fill user field in login box by default) - INetURLObject aURL( pData->maURL ); - INetURLObject aCurrentURL( m_sLastServiceUrl ); - aURL.SetUser( aCurrentURL.GetUser() ); + // url must contain user info, because we need this info in recent files entry + // (to fill user field in login box by default) + INetURLObject aURL( pData->maURL ); + INetURLObject aCurrentURL( m_sLastServiceUrl ); + aURL.SetUser( aCurrentURL.GetUser() ); - m_sPath = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + m_sPath = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - m_pName_ed->SetText( aURL.GetLastName(INetURLObject::DecodeMechanism::WithCharset) ); - } - else + m_xName_ed->set_text( aURL.GetLastName(INetURLObject::DecodeMechanism::WithCharset) ); + } + else + { + if( m_eMode == REMOTEDLG_MODE_OPEN ) { - if( m_eMode == REMOTEDLG_MODE_OPEN ) - { - m_sPath.clear(); - m_pName_ed->SetText( "" ); - } + m_sPath.clear(); + m_xName_ed->set_text( "" ); } - - EnableControls(); } + + EnableControls(); } } -IMPL_LINK_NOARG( RemoteFilesDialog, FileNameGetFocusHdl, Control&, void ) +IMPL_LINK_NOARG(RemoteFilesDialog, FileNameGetFocusHdl, weld::Widget&, void) { - m_pFileView->SetNoSelection(); + m_xFileView->SetNoSelection(); } -IMPL_LINK_NOARG( RemoteFilesDialog, FileNameModifyHdl, Edit&, void ) +IMPL_LINK_NOARG(RemoteFilesDialog, FileNameModifyHdl, weld::Entry&, void) { - m_pFileView->SetNoSelection(); - if( !m_pOk_btn->IsEnabled() ) + m_xFileView->SetNoSelection(); + if (!m_xOk_btn->get_sensitive()) EnableControls(); } -IMPL_LINK_NOARG( RemoteFilesDialog, SplitHdl, Splitter*, void ) +IMPL_LINK_NOARG( RemoteFilesDialog, SelectFilterHdl, weld::ComboBox&, void ) { - sal_Int32 nSplitPos = m_pSplitter->GetSplitPosPixel(); - - // Resize the tree list box - sal_Int32 nPlaceX = m_pTreeView->GetPosPixel().X(); - Size placeSize = m_pTreeView->GetSizePixel(); - placeSize.setWidth( nSplitPos - nPlaceX ); - m_pTreeView->SetSizePixel( placeSize ); - - // Change Pos and size of the fileview - Point fileViewPos = m_pFileView->GetPosPixel(); - sal_Int32 nOldX = fileViewPos.X(); - sal_Int32 nNewX = nSplitPos + m_pSplitter->GetSizePixel().Width(); - fileViewPos.setX( nNewX ); - Size fileViewSize = m_pFileView->GetSizePixel(); - fileViewSize.AdjustWidth( -( nNewX - nOldX ) ); - m_pFileView->SetPosSizePixel( fileViewPos, fileViewSize ); - - m_pSplitter->SetPosPixel( Point( placeSize.Width(), m_pSplitter->GetPosPixel().Y() ) ); -} + int nPos = m_xFilter_lb->get_active(); -IMPL_LINK_NOARG( RemoteFilesDialog, SelectFilterHdl, ListBox&, void ) -{ - unsigned int nPos = m_pFilter_lb->GetSelectedEntryPos(); - - if( nPos != LISTBOX_ENTRY_NOTFOUND && !m_aFilters[nPos].second.isEmpty() ) + if( nPos != -1 && !m_aFilters[nPos].second.isEmpty() ) { m_nCurrentFilter = nPos; - OUString sCurrentURL = m_pFileView->GetViewURL(); + OUString sCurrentURL = m_xFileView->GetViewURL(); if( !sCurrentURL.isEmpty() && m_bIsConnected ) OpenURL( sCurrentURL ); } } -IMPL_LINK( RemoteFilesDialog, TreeSelectHdl, SvTreeListBox *, pBox, void ) +IMPL_LINK(RemoteFilesDialog, TreeSelectHdl, weld::TreeView&, rBox, void) { - OUString* sURL = static_cast< OUString* >( pBox->GetHdlEntry()->GetUserData() ); - - if( sURL ) - { - OpenURL( *sURL ); - m_pFileView->GrabFocus(); - } + OpenURL(rBox.get_selected_id()); + m_xFileView->grab_focus(); } IMPL_LINK ( RemoteFilesDialog, SelectBreadcrumbHdl, Breadcrumb*, pPtr, void ) @@ -1079,21 +792,21 @@ IMPL_LINK ( RemoteFilesDialog, SelectBreadcrumbHdl, Breadcrumb*, pPtr, void ) OpenURL( pPtr->GetHdlURL() ); } -IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, Button*, void ) +IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, weld::Button&, void ) { - m_pFileView->EndInplaceEditing(); + m_xFileView->EndInplaceEditing(); // will be bound after InteractionHandler is enabled SmartContent aContent; aContent.enableDefaultInteractionHandler(); // now it can be bound - aContent.bindTo( m_pFileView->GetViewURL() ); + aContent.bindTo( m_xFileView->GetViewURL() ); if( !aContent.canCreateFolder() ) return; 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 ) @@ -1103,7 +816,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, Button*, void ) OUString aUrl = aContent.createFolder(aDlg.GetName()); if( !aUrl.isEmpty() ) { - m_pFileView->CreatedFolder(aUrl, aDlg.GetName()); + m_xFileView->CreatedFolder(aUrl, aDlg.GetName()); bHandled = true; } } @@ -1112,9 +825,9 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, Button*, void ) } } -IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, Button*, void ) +IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void ) { - OUString sNameNoExt = m_pName_ed->GetText(); + OUString sNameNoExt = m_xName_ed->get_text(); OUString sPathNoExt; // auto extension @@ -1123,12 +836,12 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, Button*, void ) // check if file/path exists - OUString sCurrentPath = m_pFileView->GetViewURL(); - OUString sSelectedItem = m_pFileView->GetCurrentURL(); - OUString sName = m_pName_ed->GetText(); + OUString sCurrentPath = m_xFileView->GetViewURL(); + OUString sSelectedItem = m_xFileView->GetCurrentURL(); + OUString sName = m_xName_ed->get_text(); bool bFileDlg = ( m_eType == REMOTEDLG_TYPE_FILEDLG ); - bool bSelected = ( m_pFileView->GetSelectionCount() > 0 ); + bool bSelected = ( m_xFileView->GetSelectionCount() > 0 ); if( !sCurrentPath.endsWith("/") ) sCurrentPath += "/"; @@ -1167,7 +880,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, Button*, void ) { OUString sMsg = FpsResId( STR_SVT_ALREADYEXISTOVERWRITE ); sMsg = sMsg.replaceFirst( "$filename$", sName ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, sMsg)); if (xBox->run() != RET_YES) return; @@ -1178,10 +891,10 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, Button*, void ) if( ContentIsFolder( sPathNoExt ) ) { OpenURL( sPathNoExt ); - m_pName_ed->SetText( "" ); + m_xName_ed->set_text( "" ); - if( !bSelected ) - m_pName_ed->GrabFocus(); + if (!bSelected) + m_xName_ed->grab_focus(); return; } @@ -1190,10 +903,10 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, Button*, void ) return; } - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG ( RemoteFilesDialog, CancelHdl, Button*, void ) +IMPL_LINK_NOARG ( RemoteFilesDialog, CancelHdl, weld::Button&, void ) { if( m_pCurrentAsyncAction.is() ) { @@ -1202,15 +915,14 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, CancelHdl, Button*, void ) } else { - EndDialog(); + m_xDialog->response(RET_CANCEL); } } // SvtFileDialog_Base - SvtFileView* RemoteFilesDialog::GetView() { - return m_pFileView; + return m_xFileView.get(); } void RemoteFilesDialog::SetHasFilename( bool ) @@ -1220,7 +932,7 @@ void RemoteFilesDialog::SetHasFilename( bool ) void RemoteFilesDialog::SetBlackList( const css::uno::Sequence< OUString >& rBlackList ) { m_aBlackList = rBlackList; - m_pTreeView->SetBlackList( rBlackList ); + m_xTreeView->SetBlackList( rBlackList ); } const css::uno::Sequence< OUString >& RemoteFilesDialog::GetBlackList() const @@ -1247,25 +959,25 @@ void RemoteFilesDialog::SetPath( const OUString& rNewURL ) INetURLObject aUrl( m_sPath ); OUString sFileName = aUrl.GetLastName( INetURLObject::DecodeMechanism::WithCharset ); - m_pName_ed->SetText( sFileName ); + m_xName_ed->set_text( sFileName ); } } OUString RemoteFilesDialog::getCurrentFileText() const { OUString sReturn; - if( m_pName_ed ) - sReturn = m_pName_ed->GetText(); + if( m_xName_ed ) + sReturn = m_xName_ed->get_text(); return sReturn; } void RemoteFilesDialog::setCurrentFileText( const OUString& rText, bool bSelectAll ) { - if( m_pName_ed ) + if (m_xName_ed) { - m_pName_ed->SetText( rText ); + m_xName_ed->set_text(rText); if( bSelectAll ) - m_pName_ed->SetSelection( Selection( 0, rText.getLength() ) ); + m_xName_ed->select_region(0, -1); } } @@ -1284,7 +996,7 @@ OUString RemoteFilesDialog::GetCurFilter() const { OUString sFilter; - if( m_nCurrentFilter != LISTBOX_ENTRY_NOTFOUND ) + if (m_nCurrentFilter != -1) { sFilter = m_aFilters[m_nCurrentFilter].first; } @@ -1299,7 +1011,7 @@ OUString RemoteFilesDialog::getCurFilter( ) const void RemoteFilesDialog::SetCurFilter( const OUString& rFilter ) { - DBG_ASSERT( !IsInExecute(), "SvtFileDialog::SetCurFilter: currently executing!" ); + DBG_ASSERT( !m_bIsInExecute, "SvtFileDialog::SetCurFilter: currently executing!" ); // look for corresponding filter sal_uInt16 nPos = m_aFilters.size(); @@ -1309,7 +1021,7 @@ void RemoteFilesDialog::SetCurFilter( const OUString& rFilter ) if ( m_aFilters[nPos].first == rFilter ) { m_nCurrentFilter = nPos; - m_pFilter_lb->SelectEntryPos( m_nCurrentFilter ); + m_xFilter_lb->set_active( m_nCurrentFilter ); break; } } @@ -1342,29 +1054,27 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) { OUString sURL = m_aServices[nPos]->GetUrl(); - m_pPath->SetRootName( m_sRootLabel ); - m_pTreeView->Clear(); + m_xPath->SetRootName( m_sRootLabel ); + m_xTreeView->clear(); - SvTreeListEntry* pRoot = m_pTreeView->InsertEntry( m_sRootLabel, nullptr, true ); - OUString* sData = new OUString( rURL ); - pRoot->SetUserData( static_cast< void* >( sData ) ); + m_xTreeView->InsertRootEntry(rURL, m_sRootLabel); - m_pName_ed->GrabFocus(); + m_xName_ed->grab_focus(); m_sLastServiceUrl = sURL; m_bServiceChanged = false; } - m_pPath->SetURL( rURL ); + m_xPath->SetURL( rURL ); - m_pTreeView->SetSelectHdl( Link<SvTreeListBox*,void>() ); + m_xTreeView->connect_changed(Link<weld::TreeView&,void>()); // read cached data for this url and fill the tree - const ::std::vector< SvtContentEntry >& rFolders = m_pFileView->GetContent(); + const ::std::vector< SvtContentEntry >& rFolders = m_xFileView->GetContent(); ::std::vector< std::pair< OUString, OUString > > aFolders; - m_pName_ed->ClearEntries(); + m_xName_ed->ClearEntries(); for(const auto & rFolder : rFolders) { @@ -1386,13 +1096,13 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) } // add entries to the autocompletion mechanism - m_pName_ed->AddEntry( sTitle ); + m_xName_ed->AddEntry( sTitle ); } } - m_pTreeView->FillTreeEntry( rURL, aFolders ); + m_xTreeView->FillTreeEntry( rURL, aFolders ); - m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) ); + m_xTreeView->connect_changed( LINK( this, RemoteFilesDialog, TreeSelectHdl ) ); m_bIsConnected = true; EnableControls(); @@ -1411,20 +1121,18 @@ const OUString& RemoteFilesDialog::GetPath() std::vector<OUString> RemoteFilesDialog::GetPathList() const { std::vector<OUString> aList; - sal_uLong nCount = m_pFileView->GetSelectionCount(); - SvTreeListEntry* pEntry = nCount ? m_pFileView->FirstSelected() : nullptr; - while( pEntry ) - { + m_xFileView->selected_foreach([this, &aList](weld::TreeIter& rCurEntry){ // url must contain user info, because we need this info in recent files entry // (to fill user field in login box by default) - INetURLObject aURL( SvtFileView::GetURL( pEntry ) ); + INetURLObject aURL(m_xFileView->GetURL(rCurEntry)); INetURLObject aCurrentURL( m_sLastServiceUrl ); aURL.SetUser( aCurrentURL.GetUser() ); aList.push_back( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - pEntry = m_pFileView->NextSelected( pEntry ); - } + + return false; + }); if( aList.empty() && !m_sPath.isEmpty() ) aList.push_back( m_sPath ); @@ -1489,12 +1197,6 @@ bool RemoteFilesDialog::ContentIsDocument( const OUString& rURL ) return false; } -sal_Int32 RemoteFilesDialog::getTargetColorDepth() -{ - // This dialog doesn't contain preview - return 0; -} - sal_Int32 RemoteFilesDialog::getAvailableWidth() { // This dialog doesn't contain preview @@ -1518,10 +1220,11 @@ bool RemoteFilesDialog::getShowState() return false; } -Control* RemoteFilesDialog::getControl( sal_Int16, bool) const +weld::Widget* RemoteFilesDialog::getControl( sal_Int16, bool) const { return nullptr; } + void RemoteFilesDialog::enableControl( sal_Int16, bool ) { } diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx index ff0a3d6ce3e7..349a3f7d5d64 100644 --- a/fpicker/source/office/RemoteFilesDialog.hxx +++ b/fpicker/source/office/RemoteFilesDialog.hxx @@ -52,18 +52,13 @@ enum SvtRemoteDlgType typedef std::shared_ptr< Place > ServicePtr; -class FileViewContainer; - class RemoteFilesDialog : public SvtFileDialog_Base { public: - RemoteFilesDialog( vcl::Window* pParent, PickerFlags nBits ); + RemoteFilesDialog( weld::Window* pParent, PickerFlags nBits ); virtual ~RemoteFilesDialog() override; - virtual void dispose() override; - virtual void Resize() override; - virtual short Execute() override; - void Show(); + virtual short run() override; // SvtFileDialog_Base @@ -97,7 +92,6 @@ public: virtual void EnableAutocompletion( bool = true) override; - virtual sal_Int32 getTargetColorDepth() override; virtual sal_Int32 getAvailableWidth() override; virtual sal_Int32 getAvailableHeight() override; @@ -105,7 +99,7 @@ public: virtual bool getShowState() override; - virtual Control* getControl( sal_Int16 nControlId, bool bLabelControl = false ) const override; + virtual weld::Widget* getControl( sal_Int16 nControlId, bool bLabelControl = false ) const override; virtual void enableControl( sal_Int16 nControlId, bool bEnable ) override; virtual OUString getCurFilter( ) const override; @@ -123,31 +117,33 @@ private: int m_nWidth; int m_nHeight; + bool m_bIsInExecute; + OUString m_sPath; OUString m_sStdDir; OUString m_sRootLabel; OUString m_sLastServiceUrl; - unsigned int m_nCurrentFilter; + int m_nCurrentFilter; ::rtl::Reference< ::svt::AsyncPickerAction > m_pCurrentAsyncAction; css::uno::Sequence< OUString > m_aBlackList; - VclPtr< PushButton > m_pOk_btn; - VclPtr< CancelButton > m_pCancel_btn; - VclPtr< MenuButton > m_pAddService_btn; - VclPtr< ListBox > m_pServices_lb; - VclPtr< Breadcrumb > m_pPath; - VclPtr< PushButton > m_pNewFolder; - VclPtr< PushButton > m_pListView_btn; - VclPtr< PushButton > m_pIconView_btn; - VclPtr< Splitter > m_pSplitter; - VclPtr< FolderTree > m_pTreeView; - VclPtr< SvtFileView > m_pFileView; - VclPtr< FileViewContainer > m_pContainer; - VclPtr< ListBox > m_pFilter_lb; - VclPtr< AutocompleteEdit > m_pName_ed; - VclPtr<PopupMenu> m_pAddMenu; + std::unique_ptr<weld::Button> m_xOk_btn; + std::unique_ptr<weld::Button> m_xCancel_btn; + std::unique_ptr<weld::Toolbar> m_xAddService_bar; + std::unique_ptr<weld::Menu> m_xAddService_menu; + std::unique_ptr<weld::ComboBox> m_xServices_lb; + std::unique_ptr<weld::Container> m_xPathContainer; + std::unique_ptr<Breadcrumb> m_xPath; + std::unique_ptr<weld::Button> m_xNewFolder; + std::unique_ptr<weld::ToggleButton> m_xListView_btn; + std::unique_ptr<weld::ToggleButton> m_xIconView_btn; + std::unique_ptr<FolderTree> m_xTreeView; + std::unique_ptr<SvtFileView> m_xFileView; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::ComboBox> m_xFilter_lb; + std::unique_ptr<AutocompleteEdit> m_xName_ed; std::vector< ServicePtr > m_aServices; std::vector< std::pair< OUString, OUString > > m_aFilters; @@ -166,33 +162,33 @@ private: void EnableControls(); void DisableControls(); - void SavePassword( const OUString& rURL, const OUString& rUser - , const OUString& rPassword, bool bPersistent ); + void SavePassword(const OUString& rURL, const OUString& rUser, + const OUString& rPassword, bool bPersistent); - DECL_LINK ( AddServiceHdl, Button*, void ); - DECL_LINK ( SelectServiceHdl, ListBox&, void ); - DECL_LINK ( EditServiceMenuHdl, MenuButton *, void ); + DECL_LINK ( AddServiceHdl, const OString&, void ); + DECL_LINK ( SelectServiceHdl, weld::ComboBox&, void ); + DECL_LINK ( EditServiceMenuHdl, const OString&, void ); - DECL_LINK( DoubleClickHdl, SvTreeListBox*, bool ); - DECL_LINK( SelectHdl, SvTreeListBox*, void ); + DECL_LINK( DoubleClickHdl, SvtFileView*, bool ); + DECL_LINK( SelectHdl, SvtFileView*, void ); - DECL_LINK( FileNameGetFocusHdl, Control&, void ); - DECL_LINK( FileNameModifyHdl, Edit&, void ); + DECL_LINK( FileNameGetFocusHdl, weld::Widget&, void ); + DECL_LINK( FileNameModifyHdl, weld::Entry&, void ); DECL_LINK( SplitHdl, Splitter*, void ); - DECL_LINK( SelectFilterHdl, ListBox&, void ); + DECL_LINK( SelectFilterHdl, weld::ComboBox&, void ); - DECL_LINK( TreeSelectHdl, SvTreeListBox*, void ); + DECL_LINK( TreeSelectHdl, weld::TreeView&, void ); DECL_LINK( SelectBreadcrumbHdl, Breadcrumb *, void ); - DECL_LINK( NewFolderHdl, Button*, void ); - DECL_LINK( IconViewHdl, Button*, void ); - DECL_LINK( ListViewHdl, Button*, void ); + DECL_LINK( NewFolderHdl, weld::Button&, void ); + DECL_LINK( IconViewHdl, weld::Button&, void ); + DECL_LINK( ListViewHdl, weld::Button&, void ); - DECL_LINK( OkHdl, Button*, void ); - DECL_LINK( CancelHdl, Button*, void ); + DECL_LINK( OkHdl, weld::Button&, void ); + DECL_LINK( CancelHdl, weld::Button&, void ); }; #endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX diff --git a/fpicker/source/office/asyncfilepicker.hxx b/fpicker/source/office/asyncfilepicker.hxx index 6f4cb427b41e..830577f626d5 100644 --- a/fpicker/source/office/asyncfilepicker.hxx +++ b/fpicker/source/office/asyncfilepicker.hxx @@ -24,7 +24,6 @@ #include <rtl/ustring.hxx> #include <com/sun/star/uno/Sequence.h> #include <salhelper/simplereferenceobject.hxx> -#include <vcl/vclptr.hxx> class SvtFileView; class SvtFileDialog_Base; @@ -47,8 +46,8 @@ namespace svt private: Action m_eAction; - VclPtr<SvtFileView> m_pView; - VclPtr<SvtFileDialog_Base> m_pDialog; + SvtFileView* m_pView; + SvtFileDialog_Base* m_pDialog; OUString m_sURL; OUString m_sFileName; bool m_bRunning; diff --git a/fpicker/source/office/autocmpledit.cxx b/fpicker/source/office/autocmpledit.cxx index d7b5f6359da3..f6dddd0e57fd 100644 --- a/fpicker/source/office/autocmpledit.cxx +++ b/fpicker/source/office/autocmpledit.cxx @@ -11,11 +11,20 @@ #include <vcl/svapp.hxx> #include <vcl/event.hxx> -AutocompleteEdit::AutocompleteEdit( vcl::Window* pParent ) - : Edit( pParent ) - , m_nCurrent( 0 ) +AutocompleteEdit::AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry) + : m_xEntry(std::move(xEntry)) + , m_nCurrent(0) { - SetAutocompleteHdl(LINK(this, AutocompleteEdit, AutoCompleteHdl_Impl)); + m_xEntry->connect_changed(LINK(this, AutocompleteEdit, ChangedHdl)); + + m_aChangedIdle.SetInvokeHandler(LINK(this, AutocompleteEdit, TryAutoComplete)); + m_aChangedIdle.SetDebugName("fpicker::AutocompleteEdit m_aChangedIdle"); +} + +IMPL_LINK_NOARG(AutocompleteEdit, ChangedHdl, weld::Entry&, void) +{ + m_aChangeHdl.Call(*m_xEntry); + m_aChangedIdle.Start(); //launch this to happen on idle after cursor position will have been set } void AutocompleteEdit::AddEntry( const OUString& rEntry ) @@ -29,18 +38,16 @@ void AutocompleteEdit::ClearEntries() m_aMatching.clear(); } -IMPL_LINK_NOARG(AutocompleteEdit, AutoCompleteHdl_Impl, Edit&, void) +IMPL_LINK_NOARG(AutocompleteEdit, TryAutoComplete, Timer *, void) { - if( Application::AnyInput( VclInputFlags::KEYBOARD ) ) - return; - - OUString aCurText = GetText(); - Selection aSelection( GetSelection() ); + OUString aCurText = m_xEntry->get_text(); - if( aSelection.Max() != aCurText.getLength() ) + int nStartPos, nEndPos; + m_xEntry->get_selection_bounds(nStartPos, nEndPos); + if (std::max(nStartPos, nEndPos) != aCurText.getLength()) return; - sal_uInt16 nLen = static_cast<sal_uInt16>(aSelection.Min()); + auto nLen = std::min(nStartPos, nEndPos); aCurText = aCurText.copy( 0, nLen ); if( aCurText.isEmpty() ) return; @@ -50,11 +57,9 @@ IMPL_LINK_NOARG(AutocompleteEdit, AutoCompleteHdl_Impl, Edit&, void) if( Match( aCurText ) ) { m_nCurrent = 0; - SetText( m_aMatching[0] ); - sal_uInt16 nNewLen = m_aMatching[0].getLength(); - - Selection aSel( nLen, nNewLen ); - SetSelection( aSel ); + m_xEntry->set_text(m_aMatching[0]); + auto nNewLen = m_aMatching[0].getLength(); + m_xEntry->select_region(nLen, nNewLen); } } } @@ -77,6 +82,7 @@ bool AutocompleteEdit::Match( const OUString& rText ) return bRet; } +#if 0 bool AutocompleteEdit::PreNotify( NotifyEvent& rNEvt ) { if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) @@ -103,5 +109,6 @@ bool AutocompleteEdit::PreNotify( NotifyEvent& rNEvt ) return Edit::PreNotify( rNEvt ); } +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/autocmpledit.hxx b/fpicker/source/office/autocmpledit.hxx index 89b431ebc9e0..03e05bf559a2 100644 --- a/fpicker/source/office/autocmpledit.hxx +++ b/fpicker/source/office/autocmpledit.hxx @@ -10,22 +10,38 @@ #ifndef INCLUDED_SVTOOLS_AUTOCMPLEDIT_HXX #define INCLUDED_SVTOOLS_AUTOCMPLEDIT_HXX -#include <vcl/edit.hxx> +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> #include <vector> -class AutocompleteEdit : public Edit +class AutocompleteEdit { private: + std::unique_ptr<weld::Entry> m_xEntry; + std::vector< OUString > m_aEntries; std::vector< OUString > m_aMatching; std::vector< OUString >::size_type m_nCurrent; + Idle m_aChangedIdle; + Link<weld::Entry&, void> m_aChangeHdl; + + DECL_LINK(ChangedHdl, weld::Entry&, void); + DECL_LINK(TryAutoComplete, Timer*, void); - DECL_LINK(AutoCompleteHdl_Impl, Edit&, void); bool Match( const OUString& rText ); - bool PreNotify( NotifyEvent& rNEvt ) override; public: - AutocompleteEdit( vcl::Window* pParent ); + AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry); + + void show() { m_xEntry->show(); } + void set_sensitive(bool bSensitive) { m_xEntry->set_sensitive(bSensitive); } + OUString get_text() const { return m_xEntry->get_text(); } + void set_text(const OUString& rText) { m_xEntry->set_text(rText); } + void grab_focus() { m_xEntry->grab_focus(); } + void select_region(int nStartPos, int nEndPos) { m_xEntry->select_region(nStartPos, nEndPos); } + + void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aChangeHdl = rLink; } + void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_xEntry->connect_focus_in(rLink); } void AddEntry( const OUString& rEntry ); void ClearEntries(); diff --git a/fpicker/source/office/breadcrumb.cxx b/fpicker/source/office/breadcrumb.cxx index 039664778056..1216a543a00d 100644 --- a/fpicker/source/office/breadcrumb.cxx +++ b/fpicker/source/office/breadcrumb.cxx @@ -8,76 +8,39 @@ */ #include <tools/urlobj.hxx> -#include <vcl/fixedhyper.hxx> +#include <vcl/svapp.hxx> #include "breadcrumb.hxx" -class CustomLink : public FixedHyperlink -{ -public: - CustomLink( vcl::Window* pParent, WinBits nWinStyle ) - : FixedHyperlink( pParent, nWinStyle ) - { - vcl::Font aFont = GetControlFont( ); - aFont.SetUnderline( LINESTYLE_NONE ); - SetControlFont( aFont ); - } - -protected: - virtual void MouseMove( const MouseEvent& rMEvt ) override - { - // changes the style if the control is enabled - if ( !rMEvt.IsLeaveWindow() && IsEnabled() ) - { - vcl::Font aFont = GetControlFont( ); - aFont.SetUnderline( LINESTYLE_SINGLE ); - SetControlFont( aFont ); - } - else - { - vcl::Font aFont = GetControlFont( ); - aFont.SetUnderline( LINESTYLE_NONE ); - SetControlFont( aFont ); - } - - FixedHyperlink::MouseMove( rMEvt ); - } -}; - -Breadcrumb::Breadcrumb( vcl::Window* pParent ) : VclHBox( pParent ) +Breadcrumb::Breadcrumb(weld::Container* pParent) + : m_pParent(pParent) + , m_nMaxWidth(m_pParent->get_preferred_size().Width()) { + m_pParent->connect_size_allocate(LINK(this, Breadcrumb, SizeAllocHdl)); m_eMode = SvtBreadcrumbMode::ONLY_CURRENT_PATH; - set_spacing( SPACING ); appendField(); // root } -Breadcrumb::~Breadcrumb() +IMPL_LINK(Breadcrumb, SizeAllocHdl, const Size&, rSize, void) { - disposeOnce(); + m_nMaxWidth = rSize.Width(); } -void Breadcrumb::dispose() +Breadcrumb::~Breadcrumb() { - for( std::vector<VclPtr<FixedHyperlink>>::size_type i = 0; i < m_aLinks.size(); i++ ) - { - m_aSeparators[i].disposeAndClear(); - m_aLinks[i].disposeAndClear(); - } - - VclHBox::dispose(); + m_pParent->connect_size_allocate(Link<const Size&, void>()); } void Breadcrumb::EnableFields( bool bEnable ) { - VclHBox::Enable( bEnable ); if( bEnable ) { INetURLObject aURL( m_aCurrentURL ); int nSegments = aURL.getSegmentCount(); - m_aLinks[nSegments]->Enable( false ); + m_aSegments[nSegments]->m_xLink->set_sensitive(false); } } -void Breadcrumb::SetClickHdl( const Link<Breadcrumb*,void>& rLink ) +void Breadcrumb::connect_clicked( const Link<Breadcrumb*,void>& rLink ) { m_aClickHdl = rLink; } @@ -92,13 +55,13 @@ void Breadcrumb::SetRootName( const OUString& rURL ) m_sRootName = rURL; // we changed root - clear all fields - for( std::vector<VclPtr<FixedHyperlink>>::size_type i = 1; i < m_aLinks.size(); i++ ) + for (size_t i = 1; i < m_aSegments.size(); ++i) { - m_aLinks[i]->SetText( "" ); + m_aSegments[i]->m_xLink->set_label(""); - m_aLinks[i]->Hide(); - m_aSeparators[i]->Hide(); - m_aLinks[i]->Enable(); + m_aSegments[i]->m_xLink->hide(); + m_aSegments[i]->m_xSeparator->hide(); + m_aSegments[i]->m_xLink->set_sensitive(true); } } @@ -130,16 +93,16 @@ void Breadcrumb::SetURL( const OUString& rURL ) bool bClear = ( m_eMode == SvtBreadcrumbMode::ONLY_CURRENT_PATH ); // root field - - m_aLinks[0]->SetText( m_sRootName ); - m_aLinks[0]->Enable(); - m_aLinks[0]->SetURL( sRootPath ); + m_aSegments[0]->m_xLink->set_label( m_sRootName ); + m_aSegments[0]->m_xLink->set_sensitive(true); + m_aSegments[0]->m_xLink->set_uri(sRootPath); + m_aUris[m_aSegments[0]->m_xLink.get()] = sRootPath; // fill the other fields for( unsigned int i = 1; i < static_cast<unsigned int>(nSegments) + 1; i++ ) { - if( i >= m_aLinks.size() ) + if( i >= m_aSegments.size() ) appendField(); unsigned int nEnd = sPath.indexOf( '/', nPos + 1 ); @@ -147,37 +110,33 @@ void Breadcrumb::SetURL( const OUString& rURL ) if( m_eMode == SvtBreadcrumbMode::ALL_VISITED ) { - if( m_aLinks[i]->GetText() != sLabel ) + if( m_aSegments[i]->m_xLink->get_label() != sLabel ) bClear = true; } - m_aLinks[i]->SetText( sLabel ); - m_aLinks[i]->SetURL( sRootPath + sPath.copy( 0, nEnd ) ); - m_aLinks[i]->Hide(); - m_aLinks[i]->Enable(); + m_aSegments[i]->m_xLink->set_label( sLabel ); + m_aUris[m_aSegments[i]->m_xLink.get()] = sRootPath + sPath.copy(0, nEnd); + m_aSegments[i]->m_xLink->hide(); + m_aSegments[i]->m_xLink->set_sensitive(true); - m_aSeparators[i]->Hide(); + m_aSegments[i]->m_xSeparator->hide(); nPos = nEnd; } // clear unused fields - - for( std::vector<VclPtr<FixedHyperlink>>::size_type i = nSegments + 1; i < m_aLinks.size(); i++ ) + for (size_t i = nSegments + 1; i < m_aSegments.size(); i++ ) { if( bClear ) - m_aLinks[i]->SetText( "" ); + m_aSegments[i]->m_xLink->set_label( "" ); - m_aLinks[i]->Hide(); - m_aSeparators[i]->Hide(); - m_aLinks[i]->Enable(); + m_aSegments[i]->m_xLink->hide(); + m_aSegments[i]->m_xSeparator->hide(); + m_aSegments[i]->m_xLink->set_sensitive(true); } // show fields - - Resize(); - unsigned int nMaxWidth = GetSizePixel().Width(); - unsigned int nSeparatorWidth = m_aSeparators[0]->GetSizePixel().Width(); + unsigned int nSeparatorWidth = m_aSegments[0]->m_xSeparator->get_preferred_size().Width(); unsigned int nCurrentWidth = 0; unsigned int nLastVisible = nSegments; @@ -195,9 +154,9 @@ void Breadcrumb::SetURL( const OUString& rURL ) { unsigned int nIndex = nSegments - i; - if( showField( nIndex, nMaxWidth - nCurrentWidth ) ) + if( showField( nIndex, m_nMaxWidth - nCurrentWidth ) ) { - nCurrentWidth += m_aLinks[nIndex]->GetSizePixel().Width() + nCurrentWidth += m_aSegments[nIndex]->m_xLink->get_preferred_size().Width() + nSeparatorWidth + 2*SPACING; } else @@ -205,27 +164,27 @@ void Breadcrumb::SetURL( const OUString& rURL ) // label is too long if( nSegments != 0 ) { - m_aLinks[0]->SetText( "..." ); - m_aLinks[0]->Enable( false ); + m_aSegments[0]->m_xLink->set_label("..."); + m_aSegments[0]->m_xLink->set_sensitive(false); } bLeft = false; } } - if( nSegments + i == static_cast<int>(m_aLinks.size()) ) + if( nSegments + i == static_cast<int>(m_aSegments.size()) ) bRight = false; if( i != 0 && bRight ) { unsigned int nIndex = nSegments + i; - if( m_aLinks[nIndex]->GetText().isEmpty() ) + if( m_aSegments[nIndex]->m_xLink->get_label().isEmpty() ) { bRight = false; } - else if( showField( nIndex, nMaxWidth - nCurrentWidth ) ) + else if( showField( nIndex, m_nMaxWidth - nCurrentWidth ) ) { - nCurrentWidth += m_aLinks[nIndex]->GetSizePixel().Width() + nCurrentWidth += m_aSegments[nIndex]->m_xLink->get_preferred_size().Width() + nSeparatorWidth + 3*SPACING; nLastVisible = nIndex; } @@ -239,10 +198,10 @@ void Breadcrumb::SetURL( const OUString& rURL ) } // current dir should be inactive - m_aLinks[nSegments]->Enable( false ); + m_aSegments[nSegments]->m_xLink->set_sensitive(false); // hide last separator - m_aSeparators[nLastVisible]->Hide(); + m_aSegments[nLastVisible]->m_xSeparator->hide(); } void Breadcrumb::SetMode( SvtBreadcrumbMode eMode ) @@ -252,30 +211,29 @@ void Breadcrumb::SetMode( SvtBreadcrumbMode eMode ) void Breadcrumb::appendField() { - m_aLinks.push_back( VclPtr< CustomLink >::Create( this, WB_TABSTOP ) ); - m_aLinks[m_aLinks.size() - 1]->Hide(); - m_aLinks[m_aLinks.size() - 1]->SetClickHdl( LINK( this, Breadcrumb, ClickLinkHdl ) ); - - m_aSeparators.push_back( VclPtr< FixedText >::Create( this ) ); - m_aSeparators[m_aLinks.size() - 1]->SetText( ">" ); - m_aSeparators[m_aLinks.size() - 1]->Hide(); + m_aSegments.emplace_back(std::make_unique<BreadcrumbPath>(m_pParent)); + size_t nIndex = m_aSegments.size() - 1; + m_aSegments[nIndex]->m_xLink->hide(); + m_aSegments[nIndex]->m_xLink->connect_clicked( LINK( this, Breadcrumb, ClickLinkHdl ) ); + m_aSegments[nIndex]->m_xSeparator->set_label( ">" ); + m_aSegments[nIndex]->m_xSeparator->hide(); } bool Breadcrumb::showField( unsigned int nIndex, unsigned int nWidthMax ) { - m_aLinks[nIndex]->Show(); - m_aSeparators[nIndex]->Show(); + m_aSegments[nIndex]->m_xLink->show(); + m_aSegments[nIndex]->m_xSeparator->show(); - unsigned int nSeparatorWidth = m_aSeparators[0]->GetSizePixel().Width(); - unsigned int nWidth = m_aLinks[nIndex]->GetSizePixel().Width() + unsigned int nSeparatorWidth = m_aSegments[0]->m_xSeparator->get_preferred_size().Width(); + unsigned int nWidth = m_aSegments[nIndex]->m_xLink->get_preferred_size().Width() + nSeparatorWidth + 3*SPACING; if( nWidth > nWidthMax ) { if( nIndex != 0 ) { - m_aLinks[nIndex]->Hide(); - m_aSeparators[nIndex]->Hide(); + m_aSegments[nIndex]->m_xLink->hide(); + m_aSegments[nIndex]->m_xSeparator->hide(); } return false; @@ -284,10 +242,18 @@ bool Breadcrumb::showField( unsigned int nIndex, unsigned int nWidthMax ) return true; } -IMPL_LINK( Breadcrumb, ClickLinkHdl, FixedHyperlink&, rLink, void ) +IMPL_LINK( Breadcrumb, ClickLinkHdl, weld::LinkButton&, rLink, void ) { - m_sClickedURL = rLink.GetURL(); + m_sClickedURL = m_aUris[&rLink]; m_aClickHdl.Call( this ); } +BreadcrumbPath::BreadcrumbPath(weld::Container* pContainer) + : m_xBuilder(Application::CreateBuilder(pContainer, "fps/ui/breadcrumb.ui")) + , m_xContainer(m_xBuilder->weld_container("container")) + , m_xLink(m_xBuilder->weld_link_button("link")) + , m_xSeparator(m_xBuilder->weld_label("label")) +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/breadcrumb.hxx b/fpicker/source/office/breadcrumb.hxx index 0fe53c4b821c..784ef32b9391 100644 --- a/fpicker/source/office/breadcrumb.hxx +++ b/fpicker/source/office/breadcrumb.hxx @@ -10,12 +10,10 @@ #ifndef INCLUDED_SVTOOLS_BREADCRUMB_HXX #define INCLUDED_SVTOOLS_BREADCRUMB_HXX -#include <vcl/layout.hxx> - +#include <vcl/weld.hxx> +#include <map> #include <vector> -class FixedHyperlink; - #define SPACING 6 enum SvtBreadcrumbMode @@ -24,40 +22,50 @@ enum SvtBreadcrumbMode ALL_VISITED = 1 }; -class CustomLink; +struct BreadcrumbPath +{ + BreadcrumbPath(weld::Container* pParent); + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::LinkButton> m_xLink; + std::unique_ptr<weld::Label> m_xSeparator; +}; -class Breadcrumb : public VclHBox +class Breadcrumb { - private: - std::vector< VclPtr< CustomLink > > m_aLinks; - std::vector< VclPtr< FixedText > > m_aSeparators; +private: + weld::Container* m_pParent; + int m_nMaxWidth; + + std::vector<std::unique_ptr<BreadcrumbPath>> m_aSegments; + std::map<weld::LinkButton*, OUString> m_aUris; - OUString m_sRootName; - OUString m_sClickedURL; - OUString m_aCurrentURL; + OUString m_sRootName; + OUString m_sClickedURL; + OUString m_aCurrentURL; - SvtBreadcrumbMode m_eMode; + SvtBreadcrumbMode m_eMode; - Link<Breadcrumb*,void> m_aClickHdl; + Link<Breadcrumb*,void> m_aClickHdl; - void appendField(); - bool showField( unsigned int nIndex, unsigned int nWidthMax ); + void appendField(); + bool showField( unsigned int nIndex, unsigned int nWidthMax ); - DECL_LINK( ClickLinkHdl, FixedHyperlink&, void ); + DECL_LINK(SizeAllocHdl, const Size&, void); + DECL_LINK(ClickLinkHdl, weld::LinkButton&, void); - public: - Breadcrumb( vcl::Window* pParent ); - virtual ~Breadcrumb() override; +public: + Breadcrumb(weld::Container* pParent); + ~Breadcrumb(); - void dispose() override; - void EnableFields( bool bEnable ); + void EnableFields( bool bEnable ); - void SetClickHdl( const Link<Breadcrumb*,void>& rLink ); - const OUString& GetHdlURL() const; + void connect_clicked( const Link<Breadcrumb*,void>& rLink ); + const OUString& GetHdlURL() const; - void SetRootName( const OUString& rURL ); - void SetURL( const OUString& rURL ); - void SetMode( SvtBreadcrumbMode eMode ); + void SetRootName( const OUString& rURL ); + void SetURL( const OUString& rURL ); + void SetMode( SvtBreadcrumbMode eMode ); }; #endif diff --git a/fpicker/source/office/commonpicker.cxx b/fpicker/source/office/commonpicker.cxx index b52d4ed2f9ca..2b2413bdc024 100644 --- a/fpicker/source/office/commonpicker.cxx +++ b/fpicker/source/office/commonpicker.cxx @@ -52,7 +52,6 @@ namespace svt OCommonPicker::OCommonPicker() :OCommonPicker_Base( m_aMutex ) ,OPropertyContainer( GetBroadcastHelper() ) - ,m_pDlg( nullptr ) ,m_nCancelEvent( nullptr ) ,m_bExecuting( false ) { @@ -105,7 +104,7 @@ namespace svt { // set the title if ( !m_aTitle.isEmpty() ) - m_pDlg->SetText( m_aTitle ); + m_xDlg->set_title(m_aTitle); } } @@ -121,11 +120,11 @@ namespace svt { ::osl::MutexGuard aOwnGuard( m_aMutex ); - if ( m_bExecuting && m_pDlg ) - m_pDlg->EndDialog(); + if ( m_bExecuting && m_xDlg ) + m_xDlg->response(RET_CANCEL); } - m_pDlg.disposeAndClear(); + m_xDlg.reset(); m_xWindow = nullptr; m_xDialogParent = nullptr; } @@ -137,9 +136,7 @@ namespace svt disposeComponent( m_xParentListenerAdapter ); } - // XEventListener - void SAL_CALL OCommonPicker::disposing( const EventObject& _rSource ) { SolarMutexGuard aGuard; @@ -150,11 +147,16 @@ namespace svt { stopWindowListening(); - if ( !bDialogDying ) // it's the parent which is dying -> delete the dialog - m_pDlg.disposeAndClear(); - else - m_pDlg.clear(); + SAL_WARN_IF(bDialogDying && m_bExecuting, "fpicker.office", "unexpected disposing before response" ); + + // it's the parent which is dying -> delete the dialog + { + ::osl::MutexGuard aOwnGuard(m_aMutex); + if (m_bExecuting && m_xDlg) + m_xDlg->response(RET_CANCEL); + } + m_xDlg.reset(); m_xWindow = nullptr; m_xDialogParent = nullptr; } @@ -164,9 +166,7 @@ namespace svt } } - // property set related methods - ::cppu::IPropertyArrayHelper* OCommonPicker::createArrayHelper( ) const { Sequence< Property > aProps; @@ -174,50 +174,51 @@ namespace svt return new cppu::OPropertyArrayHelper( aProps ); } - ::cppu::IPropertyArrayHelper& SAL_CALL OCommonPicker::getInfoHelper() { return *getArrayHelper(); } - Reference< XPropertySetInfo > SAL_CALL OCommonPicker::getPropertySetInfo( ) { return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); } - - void SAL_CALL OCommonPicker::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) + void SAL_CALL OCommonPicker::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) { - OPropertyContainer::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle, rValue); // if the HelpURL changed, forward this to the dialog - if ( PROPERTY_ID_HELPURL == _nHandle ) - if ( m_pDlg ) - OControlAccess::setHelpURL( m_pDlg, m_sHelpURL, false ); + if (PROPERTY_ID_HELPURL == nHandle && m_xDlg) + { + ::svt::OControlAccess aAccess(m_xDlg.get(), m_xDlg->GetView()); + aAccess.setHelpURL(m_xDlg->getDialog(), m_sHelpURL); + } } - bool OCommonPicker::createPicker() { - if ( !m_pDlg ) + if ( !m_xDlg ) { - m_pDlg.reset( implCreateDialog( VCLUnoHelper::GetWindow( m_xDialogParent ) ) ); - SAL_WARN_IF( !m_pDlg, "fpicker.office", "OCommonPicker::createPicker: invalid dialog returned!" ); + m_xDlg = implCreateDialog(Application::GetFrameWeld(m_xDialogParent)); + SAL_WARN_IF( !m_xDlg, "fpicker.office", "OCommonPicker::createPicker: invalid dialog returned!" ); - if ( m_pDlg ) + if ( m_xDlg ) { + weld::Dialog* pDlg = m_xDlg->getDialog(); + + ::svt::OControlAccess aAccess(m_xDlg.get(), m_xDlg->GetView()); // synchronize the help id of the dialog without help URL property if ( !m_sHelpURL.isEmpty() ) { // somebody already set the help URL while we had no dialog yet - OControlAccess::setHelpURL( m_pDlg, m_sHelpURL, false ); + aAccess.setHelpURL(pDlg, m_sHelpURL); } else { - m_sHelpURL = OControlAccess::getHelpURL( m_pDlg, false ); + m_sHelpURL = aAccess.getHelpURL(pDlg); } - m_xWindow = VCLUnoHelper::GetInterface( m_pDlg ); + m_xWindow = pDlg->GetXWindow(); // add as event listener to the window OSL_ENSURE( m_xWindow.is(), "OCommonPicker::createFileDialog: invalid window component!" ); @@ -227,10 +228,14 @@ namespace svt // the adapter will add itself as listener, and forward notifications } - // _and_ add as event listener to the parent - in case the parent is destroyed - // before we are disposed, our disposal would access dead VCL windows then... - m_xDialogParent = VCLUnoHelper::GetInterface( m_pDlg->GetParent() ); - OSL_ENSURE( m_xDialogParent.is() || !m_pDlg->GetParent(), "OCommonPicker::createFileDialog: invalid window component (the parent this time)!" ); + VclPtr<vcl::Window> xVclDialog(VCLUnoHelper::GetWindow(m_xWindow)); + if (xVclDialog) // this block is quite possibly unnecessary by now + { + // _and_ add as event listener to the parent - in case the parent is destroyed + // before we are disposed, our disposal would access dead VCL windows then... + m_xDialogParent = VCLUnoHelper::GetInterface(xVclDialog->GetParent()); + OSL_ENSURE(m_xDialogParent.is() || !xVclDialog->GetParent(), "OCommonPicker::createFileDialog: invalid window component (the parent this time)!"); + } if ( m_xDialogParent.is() ) { m_xParentListenerAdapter = new OWeakEventListenerAdapter( this, m_xDialogParent ); @@ -239,12 +244,10 @@ namespace svt } } - return nullptr != m_pDlg; + return nullptr != m_xDlg; } - // XControlAccess functions - void SAL_CALL OCommonPicker::setControlProperty( const OUString& aControlName, const OUString& aControlProperty, const Any& aValue ) { checkAlive(); @@ -252,12 +255,11 @@ namespace svt SolarMutexGuard aGuard; if ( createPicker() ) { - ::svt::OControlAccess aAccess( m_pDlg, m_pDlg->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); aAccess.setControlProperty( aControlName, aControlProperty, aValue ); } } - Any SAL_CALL OCommonPicker::getControlProperty( const OUString& aControlName, const OUString& aControlProperty ) { checkAlive(); @@ -265,16 +267,14 @@ namespace svt SolarMutexGuard aGuard; if ( createPicker() ) { - ::svt::OControlAccess aAccess( m_pDlg, m_pDlg->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); return aAccess.getControlProperty( aControlName, aControlProperty ); } return Any(); } - // XControlInformation functions - Sequence< OUString > SAL_CALL OCommonPicker::getSupportedControls( ) { checkAlive(); @@ -282,14 +282,13 @@ namespace svt SolarMutexGuard aGuard; if ( createPicker() ) { - ::svt::OControlAccess aAccess( m_pDlg, m_pDlg->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); return aAccess.getSupportedControls( ); } return Sequence< OUString >(); } - sal_Bool SAL_CALL OCommonPicker::isControlSupported( const OUString& aControlName ) { checkAlive(); @@ -303,7 +302,6 @@ namespace svt return false; } - Sequence< OUString > SAL_CALL OCommonPicker::getSupportedControlProperties( const OUString& aControlName ) { checkAlive(); @@ -311,14 +309,13 @@ namespace svt SolarMutexGuard aGuard; if ( createPicker() ) { - ::svt::OControlAccess aAccess( m_pDlg, m_pDlg->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); return aAccess.getSupportedControlProperties( aControlName ); } return Sequence< OUString >(); } - sal_Bool SAL_CALL OCommonPicker::isControlPropertySupported( const OUString& aControlName, const OUString& aControlProperty ) { checkAlive(); @@ -326,7 +323,7 @@ namespace svt SolarMutexGuard aGuard; if ( createPicker() ) { - ::svt::OControlAccess aAccess( m_pDlg, m_pDlg->GetView() ); + ::svt::OControlAccess aAccess( m_xDlg.get(), m_xDlg->GetView() ); return aAccess.isControlPropertySupported( aControlName, aControlProperty ); } @@ -387,11 +384,10 @@ namespace svt m_nCancelEvent = Application::PostUserEvent( LINK( this, OCommonPicker, OnCancelPicker ) ); } - IMPL_LINK_NOARG(OCommonPicker, OnCancelPicker, void*, void) { // By definition, the solar mutex is locked when we arrive here. Note that this - // is important, as for instance the consistency of m_pDlg depends on this mutex. + // is important, as for instance the consistency of m_xDlg depends on this mutex. ::osl::MutexGuard aGuard( m_aMutex ); m_nCancelEvent = nullptr; @@ -401,14 +397,12 @@ namespace svt // being executed at this time. return; - OSL_ENSURE( getDialog(), "OCommonPicker::OnCancelPicker: executing, but no dialog!" ); - if ( getDialog() ) - getDialog()->EndDialog(); + OSL_ENSURE( m_xDlg, "OCommonPicker::OnCancelPicker: executing, but no dialog!" ); + if (m_xDlg) + m_xDlg->response(RET_CANCEL); } - // XInitialization functions - void SAL_CALL OCommonPicker::initialize( const Sequence< Any >& _rArguments ) { checkAlive(); @@ -462,7 +456,6 @@ namespace svt } } - bool OCommonPicker::implHandleInitializationArgument( const OUString& _rName, const Any& _rValue ) { bool bKnown = true; @@ -470,15 +463,13 @@ namespace svt { m_xDialogParent.clear(); OSL_VERIFY( _rValue >>= m_xDialogParent ); - OSL_ENSURE( VCLUnoHelper::GetWindow( m_xDialogParent ), "OCommonPicker::implHandleInitializationArgument: invalid parent window given!" ); + OSL_ENSURE( m_xDialogParent.is(), "OCommonPicker::implHandleInitializationArgument: invalid parent window given!" ); } else bKnown = false; return bKnown; } - } // namespace svt - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/commonpicker.hxx b/fpicker/source/office/commonpicker.hxx index 1a379a22665f..e4c5e7125f38 100644 --- a/fpicker/source/office/commonpicker.hxx +++ b/fpicker/source/office/commonpicker.hxx @@ -31,10 +31,9 @@ #include <comphelper/proparrhlp.hxx> #include <comphelper/uno3.hxx> #include <tools/link.hxx> -#include <vcl/vclptr.hxx> class SvtFileDialog_Base; -namespace vcl { class Window; } +namespace weld { class Window; } struct ImplSVEvent; namespace svt @@ -61,7 +60,6 @@ namespace svt css::uno::Reference< css::awt::XWindow > m_xWindow; // </properties> - VclPtr<SvtFileDialog_Base> m_pDlg; ImplSVEvent * m_nCancelEvent; bool m_bExecuting; @@ -75,7 +73,7 @@ namespace svt OUString m_aDisplayDirectory; protected: - SvtFileDialog_Base* getDialog() { return m_pDlg; } + std::shared_ptr<SvtFileDialog_Base> m_xDlg; const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; } ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; } @@ -89,7 +87,7 @@ namespace svt // overridables // will be called with locked SolarMutex - virtual VclPtr<SvtFileDialog_Base> implCreateDialog( vcl::Window* _pParent ) = 0; + virtual std::unique_ptr<SvtFileDialog_Base> implCreateDialog( weld::Window* pParent ) = 0; virtual sal_Int16 implExecutePicker( ) = 0; // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ... diff --git a/fpicker/source/office/contentenumeration.hxx b/fpicker/source/office/contentenumeration.hxx index 2b0be7d79a80..bb906ce44514 100644 --- a/fpicker/source/office/contentenumeration.hxx +++ b/fpicker/source/office/contentenumeration.hxx @@ -45,9 +45,11 @@ namespace svt public: OUString maType; OUString maTargetURL; - OUString maDisplayText; + OUString maDisplayName; + OUString maDisplaySize; + OUString maDisplayDate; DateTime maModDate; - Image maImage; + OUString maImage; sal_Int64 maSize; bool mbIsFolder; bool mbIsVolume; diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx index 719ea9232592..442e83276b41 100644 --- a/fpicker/source/office/fileview.cxx +++ b/fpicker/source/office/fileview.cxx @@ -17,55 +17,50 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/treelistbox.hxx> #include <sal/config.h> #include <sal/log.hxx> #include <osl/diagnose.h> -#include <vcl/treelistentry.hxx> #include <svtools/svtresid.hxx> #include <svtools/imagemgr.hxx> #include <svtools/querydelete.hxx> -#include <vcl/event.hxx> -#include <vcl/headbar.hxx> -#include <vcl/svtabbx.hxx> #include <svtools/strings.hrc> #include <bitmaps.hlst> #include <toolkit/helper/vclunohelper.hxx> #include "contentenumeration.hxx" -#include <vcl/AccessibleBrowseBoxObjType.hxx> #include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/ucb/XProgressHandler.hpp> #include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp> -#include <vcl/waitobj.hxx> -#include <vcl/settings.hxx> #include <com/sun/star/ucb/XCommandInfo.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <algorithm> #include <vector> +#include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <ucbhelper/content.hxx> #include <ucbhelper/commandenvironment.hxx> #include <rtl/math.hxx> +#include <o3tl/typed_flags_set.hxx> #include <osl/mutex.hxx> #include <osl/conditn.hxx> #include <salhelper/timer.hxx> -#include <vcl/svapp.hxx> -#include <vcl/dialog.hxx> +#include <svtools/urlfilter.hxx> #include <unotools/collatorwrapper.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/intlwrapper.hxx> #include <unotools/syslocale.hxx> -#include <svtools/urlfilter.hxx> -#include <o3tl/typed_flags_set.hxx> +#include <vcl/svapp.hxx> +#include <vcl/commandevent.hxx> +#include <vcl/event.hxx> +#include <vcl/settings.hxx> +#include <vcl/timer.hxx> #include <memory> #include "fileview.hxx" -#include "iconview.hxx" using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; @@ -85,7 +80,6 @@ using ::svt::FolderDescriptor; #define COLUMN_SIZE 3 #define COLUMN_DATE 4 -#define ROW_HEIGHT 17 // the height of a row has to be a little higher than the bitmap #define QUICK_SEARCH_TIMEOUT 1500 // time in mSec before the quicksearch string will be reset enum class FileViewFlags @@ -120,68 +114,122 @@ namespace } - -class ViewTabListBox_Impl : public SvHeaderTabListBox +class ViewTabListBox_Impl { private: Reference< XCommandEnvironment > mxCmdEnv; - std::unique_ptr<VclBuilder> mxBuilder; - VclPtr<PopupMenu> mxMenu; + std::unique_ptr<weld::TreeView> mxTreeView; + std::unique_ptr<weld::TreeIter> mxScratchIter; ::osl::Mutex maMutex; - VclPtr<HeaderBar> mpHeaderBar; SvtFileView_Impl* mpParent; Timer maResetQuickSearch; OUString maQuickSearchText; OUString const msAccessibleDescText; - OUString const msFolder; - OUString const msFile; sal_uInt32 mnSearchIndex; - bool mbResizeDisabled : 1; - bool mbAutoResize : 1; - bool mbEnableDelete : 1; + bool mbEnableDelete; + bool mbEditing; bool const mbShowHeader; + bool const mbShowType; void DeleteEntries(); void DoQuickSearch( sal_Unicode rChar ); bool Kill( const OUString& rURL ); -protected: - virtual bool DoubleClickHdl() override; - virtual OUString GetAccessibleObjectDescription( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override; - public: - ViewTabListBox_Impl( vcl::Window* pParentWin, SvtFileView_Impl* pParent, FileViewFlags nFlags ); - virtual ~ViewTabListBox_Impl() override; - virtual void dispose() override; + ViewTabListBox_Impl(std::unique_ptr<weld::TreeView> xTreeView, weld::Window* pTopLevel, SvtFileView_Impl* pParent, FileViewFlags nFlags); + virtual ~ViewTabListBox_Impl(); + + std::unique_ptr<weld::TreeIter> make_iterator() const { return mxTreeView->make_iterator(); } + void insert(const OUString &rEntry, const OUString& rId, const OUString& rImage, weld::TreeIter& rIter) + { + mxTreeView->insert(nullptr, -1, &rEntry, &rId, nullptr, nullptr, &rImage, false, &rIter); + } + void append(const OUString& rId, const OUString& rStr, const OUString& rType, const OUString& rSize, const OUString& rDate, const OUString& rImage) + { + mxTreeView->insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, &rImage, false, mxScratchIter.get()); + int nCol = 1; + if (mbShowType) + mxTreeView->set_text(*mxScratchIter, rType, nCol++); + mxTreeView->set_text(*mxScratchIter, rSize, nCol++); + mxTreeView->set_text(*mxScratchIter, rDate, nCol++); + } + + void scroll_to_row(const weld::TreeIter& rIter) { mxTreeView->scroll_to_row(rIter); } + void set_cursor(int nPos) { mxTreeView->set_cursor(nPos); } + void set_cursor(const weld::TreeIter& rIter) { mxTreeView->set_cursor(rIter); } + bool get_cursor(weld::TreeIter* pIter) const { return mxTreeView->get_cursor(pIter); } + bool get_iter_first(weld::TreeIter& rIter) const { return mxTreeView->get_iter_first(rIter); } + bool get_selected(weld::TreeIter* pIter) const { return mxTreeView->get_selected(pIter); } + + OUString get_selected_text() const { return mxTreeView->get_selected_text(); } - virtual void Resize() override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) override; + void unselect_all() { mxTreeView->unselect_all(); } - void ClearAll(); - HeaderBar* GetHeaderBar() const { return mpHeaderBar; } + OUString get_id(const weld::TreeIter& rIter) { return mxTreeView->get_id(rIter); } + + void connect_row_activated(const Link<weld::TreeView&, bool>& rLink) { mxTreeView->connect_row_activated(rLink); } + void connect_changed(const Link<weld::TreeView&, void>& rLink) { mxTreeView->connect_changed(rLink); } + + int n_children() const { return mxTreeView->n_children(); } + + void freeze() { mxTreeView->freeze(); } + void thaw() { mxTreeView->thaw(); } + + void show() { mxTreeView->show(); } + void hide() { mxTreeView->hide(); } + bool get_visible() const { return mxTreeView->get_visible(); } + + int count_selected_rows() const { return mxTreeView->count_selected_rows(); } + + void grab_focus() { mxTreeView->grab_focus(); } + bool has_focus() const { return mxTreeView->has_focus(); } + + void set_help_id(const OString& rHelpId) { mxTreeView->set_help_id(rHelpId); } + OString get_help_id() const { return mxTreeView->get_help_id(); } + + bool IsEditingActive() const { return mbEditing; } + + void end_editing() + { + mxTreeView->end_editing(); + mxTreeView->connect_editing(Link<const weld::TreeIter&, bool>(), Link<const IterString&, bool>()); + mbEditing = false; + } + + void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) + { + mxTreeView->selected_foreach(func); + } + + weld::TreeView* getWidget() const + { + return mxTreeView.get(); + } + + void clear() { mxTreeView->clear(); } - void EnableAutoResize() { mbAutoResize = true; } void EnableDelete( bool bEnable ) { mbEnableDelete = bEnable; } + bool TypeColumnVisible() const { return mbShowType; } const Reference< XCommandEnvironment >& GetCommandEnvironment() const { return mxCmdEnv; } DECL_LINK(ResetQuickSearch_Impl, Timer *, void); + DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(EditingEntryHdl, const weld::TreeIter&, bool); + typedef std::pair<const weld::TreeIter&, OUString> IterString; + DECL_LINK(EditedEntryHdl, const IterString&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - virtual VclPtr<PopupMenu> CreateContextMenu() override; - virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopentry ) override; + void ExecuteContextMenuAction(const OString& rSelectedPopentry); }; - //= SvtFileView_Impl - - class SvtFileView_Impl :public ::svt::IEnumerationResultHandler { protected: - VclPtr<SvtFileView> mpAntiImpl; - Link<SvTreeListBox*,void> m_aSelectHandler; + SvtFileView* m_pAntiImpl; + Link<SvtFileView*,void> m_aSelectHandler; ::rtl::Reference< ::svt::FileViewContentEnumerator > m_xContentEnumerator; @@ -194,12 +242,13 @@ protected: public: - ::std::vector< std::unique_ptr<SortingData_Impl> > maContent; + ::std::vector<std::unique_ptr<SortingData_Impl>> maContent; + ::std::vector<std::unique_ptr<SvtContentEntry>> maEntries; ::osl::Mutex maMutex; - VclPtr<SvTreeListBox> mpCurView; - VclPtr<ViewTabListBox_Impl> mpView; - VclPtr<IconView> mpIconView; + weld::Window* m_pTopLevel; + std::unique_ptr<ViewTabListBox_Impl> mxView; + std::unique_ptr<weld::IconView> mxIconView; sal_uInt16 mnSortColumn; bool mbAscending : 1; bool const mbOnlyFolder : 1; @@ -210,14 +259,20 @@ public: OUString maViewURL; OUString maCurrentFilter; - Image const maFolderImage; + OUString maFolderImage; Link<SvtFileView*,void> maOpenDoneLink; + Link<SvtFileView*,bool> maDoubleClickHandler; + Reference< XCommandEnvironment > mxCmdEnv; - SvtFileView_Impl( SvtFileView* pAntiImpl, Reference < XCommandEnvironment > const & xEnv, - FileViewFlags nFlags, - bool bOnlyFolder ); - virtual ~SvtFileView_Impl(); + SvtFileView_Impl(SvtFileView* pAntiImpl, weld::Window* pTopLevel, + std::unique_ptr<weld::TreeView> xTreeView, + std::unique_ptr<weld::IconView> xIconView, + Reference < XCommandEnvironment > const & xEnv, + FileViewFlags nFlags, + bool bOnlyFolder); + + virtual ~SvtFileView_Impl(); void Clear(); @@ -234,17 +289,17 @@ public: void CancelRunningAsyncAction(); void OpenFolder_Impl(); - static void ReplaceTabWithString( OUString& aValue ); + static OUString ReplaceTabWithString(const OUString& rValue); void CreateDisplayText_Impl(); void SortFolderContent_Impl(); void EntryRemoved( const OUString& rURL ); void EntryRenamed( OUString& rURL, const OUString& rName ); - OUString FolderInserted( const OUString& rURL, + const SortingData_Impl& FolderInserted( const OUString& rURL, const OUString& rTitle ); - sal_uLong GetEntryPos( const OUString& rURL ); + int GetEntryPos( const OUString& rURL ); void SetViewMode( FileViewMode eMode ); @@ -255,17 +310,46 @@ public: const OUString& rTitle, bool bWrapAround ); - void SetSelectHandler( const Link<SvTreeListBox*,void>& _rHdl ); + void SetSelectHandler( const Link<SvtFileView*,void>& rHdl ); + void SetDoubleClickHandler(const Link<SvtFileView*,bool>& rHdl); - void InitSelection(); void ResetCursor(); - inline void EndEditing(); + void EndEditing() + { + if (mxView->IsEditingActive()) + mxView->end_editing(); + } + + void onTimeout(); + + void grab_focus() + { + if (mxView->get_visible()) + mxView->grab_focus(); + else + mxIconView->grab_focus(); + } + + bool has_focus() const + { + return mxView->has_focus() || mxIconView->has_focus(); + } - void onTimeout(); + int GetSortColumn() const + { + sal_uInt16 nOldSortID = mnSortColumn; + // skip "TYPE" + if (!mxView->TypeColumnVisible() && nOldSortID != COLUMN_TITLE) + --nOldSortID; + return nOldSortID - 1; + } protected: - DECL_LINK( SelectionMultiplexer, SvTreeListBox*, void ); + DECL_LINK(ChangedHdl, weld::TreeView&, void); + DECL_LINK(SelectionChangedHdl, weld::IconView&, void); + DECL_LINK(RowActivatedHdl, weld::TreeView&, bool); + DECL_LINK(ItemActivatedHdl, weld::IconView&, bool); // IEnumerationResultHandler overridables virtual void enumerationDone( ::svt::EnumerationResult eResult ) override; @@ -274,13 +358,7 @@ protected: inline void SvtFileView_Impl::EnableDelete( bool bEnable ) { - mpView->EnableDelete( bEnable ); -} - -inline void SvtFileView_Impl::EndEditing() -{ - if ( mpCurView->IsEditingActive() ) - mpCurView->EndEditing(); + mxView->EnableDelete( bEnable ); } namespace @@ -330,80 +408,49 @@ namespace } } -ViewTabListBox_Impl::ViewTabListBox_Impl( vcl::Window* pParentWin, - SvtFileView_Impl* pParent, - FileViewFlags nFlags ) : - - SvHeaderTabListBox( pParentWin, WB_TABSTOP ), - - mpHeaderBar ( nullptr ), - mpParent ( pParent ), - msAccessibleDescText( SvtResId(STR_SVT_ACC_DESC_FILEVIEW) ), - msFolder ( SvtResId(STR_SVT_ACC_DESC_FOLDER) ), - msFile ( SvtResId(STR_SVT_ACC_DESC_FILE) ), - mnSearchIndex ( 0 ), - mbResizeDisabled ( false ), - mbAutoResize ( false ), - mbEnableDelete ( false ), - mbShowHeader ( !(nFlags & FileViewFlags::SHOW_NONE) ) -{ - Size aBoxSize = pParentWin->GetSizePixel(); - mpHeaderBar = VclPtr<HeaderBar>::Create( pParentWin, WB_BUTTONSTYLE | WB_BOTTOMBORDER ); - mpHeaderBar->SetPosSizePixel( Point( 0, 0 ), mpHeaderBar->CalcWindowSizePixel() ); - - HeaderBarItemBits nBits = HeaderBarItemBits::LEFT | HeaderBarItemBits::CLICKABLE; - - long aTabPositions[] = { 20, 180, 320, 400, 600 }; - SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions, MapUnit::MapPixel); - SetTabJustify(2, SvTabJustify::AdjustRight); // column "Size" - - mpHeaderBar->InsertItem(COLUMN_TITLE, SvtResId(STR_SVT_FILEVIEW_COLUMN_TITLE), 180, nBits | HeaderBarItemBits::UPARROW); +ViewTabListBox_Impl::ViewTabListBox_Impl(std::unique_ptr<weld::TreeView> xTreeView, + weld::Window* pTopLevel, + SvtFileView_Impl* pParent, + FileViewFlags nFlags) + : mxTreeView(std::move(xTreeView)) + , mxScratchIter(mxTreeView->make_iterator()) + , mpParent( pParent ) + , mnSearchIndex( 0 ) + , mbEnableDelete( false ) + , mbEditing( false ) + , mbShowHeader( !(nFlags & FileViewFlags::SHOW_NONE) ) + , mbShowType(nFlags & FileViewFlags::SHOW_TYPE) +{ + std::vector<int> aWidths; + aWidths.push_back(180); if (nFlags & FileViewFlags::SHOW_TYPE) - { - mpHeaderBar->InsertItem(COLUMN_TYPE, SvtResId(STR_SVT_FILEVIEW_COLUMN_TYPE), 140, nBits); - } - mpHeaderBar->InsertItem(COLUMN_SIZE, SvtResId(STR_SVT_FILEVIEW_COLUMN_SIZE), 80, nBits); - mpHeaderBar->InsertItem(COLUMN_DATE, SvtResId(STR_SVT_FILEVIEW_COLUMN_DATE), 500, nBits); - - Size aHeadSize = mpHeaderBar->GetSizePixel(); - SetPosSizePixel( Point( 0, aHeadSize.Height() ), - Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) ); - InitHeaderBar( mpHeaderBar ); - SetHighlightRange(); - SetEntryHeight( ROW_HEIGHT ); - if (nFlags & FileViewFlags::MULTISELECTION) - SetSelectionMode( SelectionMode::Multiple ); + aWidths.push_back(140); + aWidths.push_back(80); + mxTreeView->set_column_fixed_widths(aWidths); - Show(); - if( mbShowHeader ) - mpHeaderBar->Show(); + if (nFlags & FileViewFlags::MULTISELECTION) + mxTreeView->set_selection_mode(SelectionMode::Multiple); maResetQuickSearch.SetTimeout( QUICK_SEARCH_TIMEOUT ); maResetQuickSearch.SetInvokeHandler( LINK( this, ViewTabListBox_Impl, ResetQuickSearch_Impl ) ); Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XInteractionHandler > xInteractionHandler( - InteractionHandler::createWithParent(xContext, VCLUnoHelper::GetInterface(GetParentDialog())), UNO_QUERY_THROW ); + InteractionHandler::createWithParent(xContext, pTopLevel->GetXWindow()), UNO_QUERY_THROW); mxCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); - EnableContextMenuHandling(); + mxTreeView->connect_popup_menu(LINK(this, ViewTabListBox_Impl, CommandHdl)); + mxTreeView->connect_key_press(LINK(this, ViewTabListBox_Impl, KeyInputHdl)); } -ViewTabListBox_Impl::~ViewTabListBox_Impl() +IMPL_LINK_NOARG(ViewTabListBox_Impl, EditingEntryHdl, const weld::TreeIter&, bool) { - disposeOnce(); + return mbEditing; } -void ViewTabListBox_Impl::dispose() +ViewTabListBox_Impl::~ViewTabListBox_Impl() { - maResetQuickSearch.Stop(); - - mxMenu.disposeAndClear(); - mxBuilder.reset(); - - mpHeaderBar.disposeAndClear(); - SvHeaderTabListBox::dispose(); } IMPL_LINK_NOARG(ViewTabListBox_Impl, ResetQuickSearch_Impl, Timer *, void) @@ -414,47 +461,17 @@ IMPL_LINK_NOARG(ViewTabListBox_Impl, ResetQuickSearch_Impl, Timer *, void) mnSearchIndex = 0; } - -void ViewTabListBox_Impl::Resize() +IMPL_LINK(ViewTabListBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool) { - SvTabListBox::Resize(); - Size aBoxSize = Control::GetParent()->GetOutputSizePixel(); - - if ( mbResizeDisabled || !aBoxSize.Width() ) - return; - - Size aBarSize; - if ( mbShowHeader ) - { - aBarSize = mpHeaderBar->GetSizePixel(); - aBarSize.setWidth( mbAutoResize ? aBoxSize.Width() : GetSizePixel().Width() ); - mpHeaderBar->SetSizePixel( aBarSize ); - } - - if ( mbAutoResize ) - { - mbResizeDisabled = true; - SetPosSizePixel( Point( 0, aBarSize.Height() ), - Size( aBoxSize.Width(), aBoxSize.Height() - aBarSize.Height() ) ); - mbResizeDisabled = false; - } -} - + if (mbEditing) + return false; -void ViewTabListBox_Impl::KeyInput( const KeyEvent& rKEvt ) -{ bool bHandled = false; const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode(); if ( 0 == rKeyCode.GetModifier() ) { - if ( rKeyCode.GetCode() == KEY_RETURN ) - { - ResetQuickSearch_Impl( nullptr ); - GetDoubleClickHdl().Call( this ); - bHandled = true; - } - else if ( ( rKeyCode.GetCode() == KEY_DELETE ) && + if ( ( rKeyCode.GetCode() == KEY_DELETE ) && mbEnableDelete ) { ResetQuickSearch_Impl( nullptr ); @@ -469,131 +486,125 @@ void ViewTabListBox_Impl::KeyInput( const KeyEvent& rKEvt ) } } - if ( !bHandled ) - { + if (!bHandled) ResetQuickSearch_Impl( nullptr ); - SvHeaderTabListBox::KeyInput( rKEvt ); - } + return bHandled; } - -VclPtr<PopupMenu> ViewTabListBox_Impl::CreateContextMenu() +IMPL_LINK(ViewTabListBox_Impl, CommandHdl, const CommandEvent&, rCEvt, bool) { + if (rCEvt.GetCommand() != CommandEventId::ContextMenu) + return false; + bool bEnableDelete = mbEnableDelete; bool bEnableRename = true; - if ( bEnableDelete || bEnableRename ) - { - sal_Int32 nSelectedEntries = GetSelectionCount(); - bEnableDelete &= nSelectedEntries > 0; - bEnableRename &= nSelectedEntries == 1; - } + int nCount = 0; + mxTreeView->selected_foreach([this, &nCount, &bEnableDelete, &bEnableRename](weld::TreeIter& rEntry){ + ++nCount; - if ( bEnableDelete || bEnableRename ) - { - SvTreeListEntry* pEntry = FirstSelected(); - while ( pEntry ) + ::ucbhelper::Content aCnt; + try + { + OUString aURL(reinterpret_cast<SvtContentEntry*>( + mxTreeView->get_id(rEntry).toInt64())->maURL); + aCnt = ::ucbhelper::Content( aURL, mxCmdEnv, comphelper::getProcessComponentContext() ); + } + catch( Exception const & ) + { + bEnableDelete = bEnableRename = false; + } + + if ( bEnableDelete ) { - ::ucbhelper::Content aCnt; try { - OUString aURL( static_cast< SvtContentEntry * >( - pEntry->GetUserData() )->maURL ); - aCnt = ::ucbhelper::Content( aURL, mxCmdEnv, comphelper::getProcessComponentContext() ); + Reference< XCommandInfo > aCommands = aCnt.getCommands(); + if ( aCommands.is() ) + bEnableDelete = aCommands->hasCommandByName( "delete" ); + else + bEnableDelete = false; } catch( Exception const & ) { - bEnableDelete = bEnableRename = false; + bEnableDelete = false; } + } - if ( bEnableDelete ) + if ( bEnableRename ) + { + try { - try + Reference< XPropertySetInfo > aProps = aCnt.getProperties(); + if ( aProps.is() ) { - Reference< XCommandInfo > aCommands = aCnt.getCommands(); - if ( aCommands.is() ) - bEnableDelete = aCommands->hasCommandByName( "delete" ); - else - bEnableDelete = false; - } - catch( Exception const & ) - { - bEnableDelete = false; + Property aProp = aProps->getPropertyByName("Title"); + bEnableRename + = !( aProp.Attributes & PropertyAttribute::READONLY ); } + else + bEnableRename = false; } - - if ( bEnableRename ) + catch( Exception const & ) { - try - { - Reference< XPropertySetInfo > aProps = aCnt.getProperties(); - if ( aProps.is() ) - { - Property aProp = aProps->getPropertyByName("Title"); - bEnableRename - = !( aProp.Attributes & PropertyAttribute::READONLY ); - } - else - bEnableRename = false; - } - catch( Exception const & ) - { - bEnableRename = false; - } + bEnableRename = false; } - - pEntry = ( bEnableDelete || bEnableRename ) - ? NextSelected( pEntry ) - : nullptr; } - } - if ( bEnableDelete || bEnableRename ) + bool bStop = !bEnableDelete && !bEnableRename; + return bStop; + }); + + if (nCount == 0) + bEnableDelete = false; + if (nCount != 1) + bEnableRename = false; + + if (bEnableDelete || bEnableRename) { - mxMenu.disposeAndClear(); - mxBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svt/ui/fileviewmenu.ui", "")); - mxMenu.set(mxBuilder->get_menu("menu")); - mxMenu->EnableItem(mxMenu->GetItemId("delete"), bEnableDelete); - mxMenu->EnableItem(mxMenu->GetItemId("rename"), bEnableRename); - mxMenu->RemoveDisabledEntries( true, true ); - return mxMenu; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(mxTreeView.get(), "svt/ui/fileviewmenu.ui")); + auto xContextMenu = xBuilder->weld_menu("menu"); + xContextMenu->set_visible("delete", bEnableDelete); + xContextMenu->set_visible("rename", bEnableRename); + OString sCommand(xContextMenu->popup_at_rect(mxTreeView.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); + ExecuteContextMenuAction(sCommand); } - return nullptr; + return true; } -void ViewTabListBox_Impl::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) +void ViewTabListBox_Impl::ExecuteContextMenuAction(const OString& rSelectedPopupEntry) { - if (nSelectedPopupEntry == mxMenu->GetItemId("delete")) + if (rSelectedPopupEntry == "delete") DeleteEntries(); - else if (nSelectedPopupEntry == mxMenu->GetItemId("rename")) - EditEntry( FirstSelected() ); -} + else if (rSelectedPopupEntry == "rename") + { + std::unique_ptr<weld::TreeIter> xEntry = mxTreeView->make_iterator(); + if (mxTreeView->get_selected(xEntry.get())) + { + mbEditing = true; -void ViewTabListBox_Impl::ClearAll() -{ - for ( sal_uLong i = 0; i < GetEntryCount(); ++i ) - delete static_cast<SvtContentEntry*>(GetEntry(i)->GetUserData()); - Clear(); -} + mxTreeView->connect_editing(LINK(this, ViewTabListBox_Impl, EditingEntryHdl), + LINK(this, ViewTabListBox_Impl, EditedEntryHdl)); + mxTreeView->start_editing(*xEntry); + } + } +} void ViewTabListBox_Impl::DeleteEntries() { short eResult = svtools::QUERYDELETE_YES; - SvTreeListEntry* pEntry = FirstSelected(); - OUString aURL; - while ( pEntry ) - { - SvTreeListEntry *pCurEntry = pEntry; - pEntry = NextSelected( pEntry ); - - if ( pCurEntry->GetUserData() ) - aURL = static_cast<SvtContentEntry*>(pCurEntry->GetUserData())->maURL; - - if ( aURL.isEmpty() ) - continue; + mxTreeView->selected_foreach([this, &eResult](weld::TreeIter& rCurEntry){ + OUString aURL; + if (!mxTreeView->get_id(rCurEntry).isEmpty()) + aURL = reinterpret_cast<SvtContentEntry*>(mxTreeView->get_id(rCurEntry).toInt64())->maURL; + if (aURL.isEmpty()) + { + mxTreeView->unselect(rCurEntry); + return false; + } bool canDelete = true; try @@ -611,15 +622,18 @@ void ViewTabListBox_Impl::DeleteEntries() } if (!canDelete) - continue; // process next entry + { + mxTreeView->unselect(rCurEntry); + return false; // process next entry + } if ( eResult != svtools::QUERYDELETE_ALL ) { INetURLObject aObj( aURL ); svtools::QueryDeleteDlg_Impl aDlg( - GetFrameWeld(), aObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset)); + mxTreeView.get(), aObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset)); - if ( GetSelectionCount() > 1 ) + if (mxTreeView->count_selected_rows() > 1) aDlg.EnableAllButton(); eResult = aDlg.run(); @@ -630,22 +644,33 @@ void ViewTabListBox_Impl::DeleteEntries() { if ( Kill( aURL ) ) { - delete static_cast<SvtContentEntry*>(pCurEntry->GetUserData()); - GetModel()->Remove( pCurEntry ); + delete reinterpret_cast<SvtContentEntry*>(mxTreeView->get_id(rCurEntry).toInt64()); mpParent->EntryRemoved( aURL ); } } - } -} + return false; + }); + + mxTreeView->remove_selection(); +} -bool ViewTabListBox_Impl::EditedEntry( SvTreeListEntry* pEntry, - const OUString& rNewText ) +IMPL_LINK(ViewTabListBox_Impl, EditedEntryHdl, const IterString&, rIterString, bool) { + mbEditing = false; + + mxTreeView->connect_editing(Link<const weld::TreeIter&, bool>(), Link<const IterString&, bool>()); + + const weld::TreeIter& rEntry = rIterString.first; + OUString sNewText = rIterString.second; + + if (sNewText.isEmpty()) + return false; + bool bRet = false; OUString aURL; - SvtContentEntry* pData = static_cast<SvtContentEntry*>(pEntry->GetUserData()); + SvtContentEntry* pData = reinterpret_cast<SvtContentEntry*>(mxTreeView->get_id(rEntry).toInt64()); if ( pData ) aURL = pData->maURL; @@ -680,14 +705,14 @@ bool ViewTabListBox_Impl::EditedEntry( SvTreeListEntry* pEntry, if ( canRename ) { Any aValue; - aValue <<= rNewText; + aValue <<= sNewText; aContent.setPropertyValue( aPropName, aValue ); - mpParent->EntryRenamed( aURL, rNewText ); + mpParent->EntryRenamed(aURL, sNewText); if (pData) pData->maURL = aURL; - pEntry->SetUserData( pData ); + mxTreeView->set_id(rEntry, OUString::number(reinterpret_cast<sal_Int64>(pData))); bRet = true; } @@ -699,7 +724,6 @@ bool ViewTabListBox_Impl::EditedEntry( SvTreeListEntry* pEntry, return bRet; } - void ViewTabListBox_Impl::DoQuickSearch( sal_Unicode rChar ) { ::osl::MutexGuard aGuard( maMutex ); @@ -721,64 +745,17 @@ void ViewTabListBox_Impl::DoQuickSearch( sal_Unicode rChar ) bFound = mpParent->SearchNextEntry( mnSearchIndex, maQuickSearchText, true ); } - if ( bFound ) + if (bFound) { - SvTreeListEntry* pEntry = GetEntry( mnSearchIndex ); - if ( pEntry ) - { - SelectAll( false ); - Select( pEntry ); - SetCurEntry( pEntry ); - MakeVisible( pEntry ); - } + mxTreeView->unselect_all(); + mxTreeView->select(mnSearchIndex); + mxTreeView->set_cursor(mnSearchIndex); + mxTreeView->scroll_to_row(mnSearchIndex); } maResetQuickSearch.Start(); } - -bool ViewTabListBox_Impl::DoubleClickHdl() -{ - SvHeaderTabListBox::DoubleClickHdl(); - return false; - // this means "do no additional handling". Especially this means that the SvImpLBox does not - // recognize that the entry at the double click position change after the handler call (which is - // the case if in the handler, our content was replaced) - // If it _would_ recognize this change, it would take this as a reason to select the entry, again - // - which is not what in the case of content replace - // (I really doubt that this behaviour of the SvImpLBox does make any sense at all, but - // who knows ...) -} - -OUString ViewTabListBox_Impl::GetAccessibleObjectDescription( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos ) const -{ - OUString sRet = SvHeaderTabListBox::GetAccessibleObjectDescription( _eType, _nPos ); - if ( ::vcl::BBTYPE_TABLECELL == _eType ) - { - sal_Int32 nRow = -1; - const sal_uInt16 nColumnCount = GetColumnCount(); - if (nColumnCount > 0) - nRow = _nPos / nColumnCount; - SvTreeListEntry* pEntry = GetEntry( nRow ); - if ( pEntry ) - { - SvtContentEntry* pData = static_cast<SvtContentEntry*>(pEntry->GetUserData()); - if ( pData ) - { - const OUString sVar1( "%1" ); - const OUString sVar2( "%2" ); - OUString aText( msAccessibleDescText ); - aText = aText.replaceAll( sVar1, pData->mbIsFolder ? msFolder : msFile ); - aText = aText.replaceAll( sVar2, pData->maURL ); - sRet += aText; - } - } - } - - return sRet; -} - - bool ViewTabListBox_Impl::Kill( const OUString& rContent ) { bool bRet = true; @@ -802,10 +779,10 @@ bool ViewTabListBox_Impl::Kill( const OUString& rContent ) return bRet; } -SvtFileView::SvtFileView( vcl::Window* pParent, WinBits nBits, - bool bOnlyFolder, bool bMultiSelection, bool bShowType ) : - - Control( pParent, nBits ) +SvtFileView::SvtFileView(weld::Window* pTopLevel, + std::unique_ptr<weld::TreeView> xTreeView, + std::unique_ptr<weld::IconView> xIconView, + bool bOnlyFolder, bool bMultiSelection, bool bShowType ) { FileViewFlags nFlags = FileViewFlags::NONE; if ( bMultiSelection ) @@ -815,31 +792,27 @@ SvtFileView::SvtFileView( vcl::Window* pParent, WinBits nBits, Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XInteractionHandler > xInteractionHandler( - InteractionHandler::createWithParent(xContext, VCLUnoHelper::GetInterface(GetParentDialog())), UNO_QUERY_THROW ); + InteractionHandler::createWithParent(xContext, pTopLevel->GetXWindow()), UNO_QUERY_THROW); Reference < XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); - mpImpl.reset( new SvtFileView_Impl( this, xCmdEnv, nFlags, bOnlyFolder ) ); - mpImpl->mpView->ForbidEmptyText(); + mpImpl.reset(new SvtFileView_Impl(this, pTopLevel, std::move(xTreeView), std::move(xIconView), xCmdEnv, nFlags, bOnlyFolder)); - HeaderBar* pHeaderBar = mpImpl->mpView->GetHeaderBar(); - pHeaderBar->SetSelectHdl( LINK( this, SvtFileView, HeaderSelect_Impl ) ); - pHeaderBar->SetEndDragHdl( LINK( this, SvtFileView, HeaderEndDrag_Impl ) ); + weld::TreeView* pView = mpImpl->mxView->getWidget(); + pView->connect_column_clicked(LINK(this, SvtFileView, HeaderSelect_Impl)); } -SvtFileView::~SvtFileView() +void SvtFileView::grab_focus() { - disposeOnce(); + mpImpl->grab_focus(); } -void SvtFileView::dispose() +bool SvtFileView::has_focus() const { - mpImpl.reset(); - Control::dispose(); + return mpImpl->has_focus(); } -Size SvtFileView::GetOptimalSize() const +SvtFileView::~SvtFileView() { - return LogicToPixel(Size(208, 50), MapMode(MapUnit::MapAppFont)); } void SvtFileView::SetViewMode( FileViewMode eMode ) @@ -847,40 +820,54 @@ void SvtFileView::SetViewMode( FileViewMode eMode ) mpImpl->SetViewMode( eMode ); } -OUString SvtFileView::GetURL( SvTreeListEntry const * pEntry ) +OUString SvtFileView::GetURL(const weld::TreeIter& rEntry) const { - OUString aURL; - if ( pEntry && pEntry->GetUserData() ) - aURL = static_cast<SvtContentEntry*>(pEntry->GetUserData())->maURL; - return aURL; + SvtContentEntry* pEntry; + if (mpImpl->mxView->get_visible()) + pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(rEntry).toInt64()); + else + pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(rEntry).toInt64()); + if (pEntry) + return pEntry->maURL; + return OUString(); } - OUString SvtFileView::GetCurrentURL() const { + SvtContentEntry* pEntry = nullptr; OUString aURL; - SvTreeListEntry* pEntry = mpImpl->mpCurView->FirstSelected(); - if ( pEntry && pEntry->GetUserData() ) - aURL = static_cast<SvtContentEntry*>(pEntry->GetUserData())->maURL; + if (mpImpl->mxView->get_visible()) + { + std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); + if (mpImpl->mxView->get_selected(xEntry.get())) + pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry).toInt64()); + } + else + { + std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxIconView->make_iterator(); + if (mpImpl->mxIconView->get_selected(xEntry.get())) + pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry).toInt64()); + } + if (pEntry) + aURL = pEntry->maURL; return aURL; } - void SvtFileView::CreatedFolder( const OUString& rUrl, const OUString& rNewFolder ) { - OUString sEntry = mpImpl->FolderInserted( rUrl, rNewFolder ); + const SortingData_Impl& rEntry = mpImpl->FolderInserted( rUrl, rNewFolder ); - SvTreeListEntry* pEntry = mpImpl->mpView->InsertEntry( sEntry, mpImpl->maFolderImage, mpImpl->maFolderImage ); - SvtContentEntry* pUserData = new SvtContentEntry( rUrl, true ); - pEntry->SetUserData( pUserData ); - mpImpl->mpView->MakeVisible( pEntry ); + mpImpl->maEntries.emplace_back(std::make_unique<SvtContentEntry>(rUrl, true)); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(mpImpl->maEntries.back().get()))); - SvTreeListEntry* pEntry2 = mpImpl->mpIconView->InsertEntry( sEntry.getToken( 0, '\t' ), mpImpl->maFolderImage, mpImpl->maFolderImage ); - SvtContentEntry* pUserData2 = new SvtContentEntry( rUrl, true ); - pEntry2->SetUserData( pUserData2 ); - mpImpl->mpIconView->MakeVisible( pEntry2 ); -} + std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); + mpImpl->mxView->insert(rEntry.maDisplayName, sId, mpImpl->maFolderImage, *xEntry); + mpImpl->mxView->scroll_to_row(*xEntry); + std::unique_ptr<weld::TreeIter> xIconEntry = mpImpl->mxIconView->make_iterator(); + mpImpl->mxIconView->insert(-1, &rEntry.maDisplayName, &sId, &mpImpl->maFolderImage, xIconEntry.get()); + mpImpl->mxIconView->scroll_to_item(*xEntry); +} FileViewResult SvtFileView::PreviousLevel( const FileViewAsyncAction* pAsyncDescriptor ) { @@ -888,12 +875,11 @@ FileViewResult SvtFileView::PreviousLevel( const FileViewAsyncAction* pAsyncDesc OUString sParentURL; if ( GetParentURL( sParentURL ) ) - eResult = Initialize( sParentURL, mpImpl->maCurrentFilter, pAsyncDescriptor, mpBlackList ); + eResult = Initialize( sParentURL, mpImpl->maCurrentFilter, pAsyncDescriptor, maBlackList ); return eResult; } - bool SvtFileView::GetParentURL( OUString& rParentURL ) const { bool bRet = false; @@ -920,42 +906,31 @@ bool SvtFileView::GetParentURL( OUString& rParentURL ) const return bRet; } - -const OString& SvtFileView::GetHelpId( ) const +OString SvtFileView::get_help_id() const { - return mpImpl->mpView->GetHelpId( ); + return mpImpl->mxView->get_help_id(); } - -void SvtFileView::SetHelpId( const OString& rHelpId ) +void SvtFileView::set_help_id(const OString& rHelpId) { - mpImpl->mpView->SetHelpId( rHelpId ); + mpImpl->mxView->set_help_id(rHelpId); } - -void SvtFileView::SetSizePixel( const Size& rNewSize ) +OUString SvtFileView::get_selected_text() const { - Control::SetSizePixel( rNewSize ); - mpImpl->mpView->SetSizePixel( rNewSize ); - mpImpl->mpIconView->SetSizePixel( rNewSize ); + if (mpImpl->mxView->get_visible()) + return mpImpl->mxView->get_selected_text(); + return mpImpl->mxIconView->get_selected_text(); } - -void SvtFileView::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) -{ - SetPosPixel( rNewPos ); - SetSizePixel( rNewSize ); -} - - FileViewResult SvtFileView::Initialize( const OUString& rURL, const OUString& rFilter, const FileViewAsyncAction* pAsyncDescriptor, - const css::uno::Sequence< OUString >& rBlackList ) + const css::uno::Sequence< OUString >& rBlackList ) { - WaitObject aWaitCursor( this ); - mpBlackList = rBlackList; + weld::WaitObject aWaitCursor(mpImpl->m_pTopLevel); + maBlackList = rBlackList; OUString sPushURL( mpImpl->maViewURL ); @@ -984,7 +959,7 @@ FileViewResult SvtFileView::ExecuteFilter( const OUString& rFilter, const FileVi mpImpl->maCurrentFilter = rFilter.toAsciiLowerCase(); mpImpl->Clear(); - FileViewResult eResult = mpImpl->GetFolderContent_Impl( mpImpl->maViewURL, pAsyncDescriptor, mpBlackList ); + FileViewResult eResult = mpImpl->GetFolderContent_Impl(mpImpl->maViewURL, pAsyncDescriptor, maBlackList); OSL_ENSURE( ( eResult != eStillRunning ) || pAsyncDescriptor, "SvtFileView::ExecuteFilter: we told it to read synchronously!" ); return eResult; } @@ -996,51 +971,43 @@ void SvtFileView::CancelRunningAsyncAction() void SvtFileView::SetNoSelection() { - mpImpl->mpCurView->SelectAll( false ); -} - - -void SvtFileView::GetFocus() -{ - Control::GetFocus(); - if ( mpImpl && mpImpl->mpCurView ) - mpImpl->mpCurView->GrabFocus(); + mpImpl->mxView->unselect_all(); + mpImpl->mxIconView->unselect_all(); } - -void SvtFileView::SetSelectHdl( const Link<SvTreeListBox*,void>& rHdl ) +void SvtFileView::SetSelectHdl(const Link<SvtFileView*,void>& rHdl) { - mpImpl->SetSelectHandler( rHdl ); + mpImpl->SetSelectHandler(rHdl); } - -void SvtFileView::SetDoubleClickHdl( const Link<SvTreeListBox*,bool>& rHdl ) +void SvtFileView::SetDoubleClickHdl(const Link<SvtFileView*,bool>& rHdl) { - mpImpl->mpView->SetDoubleClickHdl( rHdl ); - mpImpl->mpIconView->SetDoubleClickHdl( rHdl ); + mpImpl->SetDoubleClickHandler(rHdl); } - sal_uLong SvtFileView::GetSelectionCount() const { - return mpImpl->mpCurView->GetSelectionCount(); + if (mpImpl->mxView->get_visible()) + return mpImpl->mxView->count_selected_rows(); + return mpImpl->mxIconView->count_selected_items(); } - -SvTreeListEntry* SvtFileView::FirstSelected() const +SvtContentEntry* SvtFileView::FirstSelected() const { - return mpImpl->mpCurView->FirstSelected(); -} - - -SvTreeListEntry* SvtFileView::NextSelected( SvTreeListEntry* pEntry ) const -{ - return mpImpl->mpCurView->NextSelected( pEntry ); -} + if (mpImpl->mxView->get_visible()) + { + SvtContentEntry* pRet = nullptr; + std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); + if (mpImpl->mxView->get_selected(xEntry.get())) + pRet = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry).toInt64()); + return pRet; + } -void SvtFileView::EnableAutoResize() -{ - mpImpl->mpView->EnableAutoResize(); + SvtContentEntry* pRet = nullptr; + std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxIconView->make_iterator(); + if (mpImpl->mxIconView->get_selected(xEntry.get())) + pRet = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry).toInt64()); + return pRet; } const OUString& SvtFileView::GetViewURL() const @@ -1063,92 +1030,53 @@ void SvtFileView::EndInplaceEditing() return mpImpl->EndEditing(); } -IMPL_LINK( SvtFileView, HeaderSelect_Impl, HeaderBar*, pBar, void ) +IMPL_LINK(SvtFileView, HeaderSelect_Impl, int, nColumn, void) { - DBG_ASSERT( pBar, "no headerbar" ); - sal_uInt16 nItemID = pBar->GetCurItemId(); - - HeaderBarItemBits nBits; - - // clear the arrow of the recently used column - if ( nItemID != mpImpl->mnSortColumn ) - { - if ( !nItemID ) - { - // first call -> remove arrow from title column, - // because another column is the sort column - nItemID = mpImpl->mnSortColumn; - mpImpl->mnSortColumn = COLUMN_TITLE; - } - nBits = pBar->GetItemBits( mpImpl->mnSortColumn ); - nBits &= ~HeaderBarItemBits( HeaderBarItemBits::UPARROW | HeaderBarItemBits::DOWNARROW ); - pBar->SetItemBits( mpImpl->mnSortColumn, nBits ); - } - - nBits = pBar->GetItemBits( nItemID ); + sal_uInt16 nItemID = nColumn + 1; + // skip "TYPE" + if (!mpImpl->mxView->TypeColumnVisible() && nItemID != COLUMN_TITLE) + ++nItemID; - bool bUp = ( ( nBits & HeaderBarItemBits::UPARROW ) == HeaderBarItemBits::UPARROW ); + weld::TreeView* pView = mpImpl->mxView->getWidget(); + bool bSortAtoZ = mpImpl->mbAscending; - if ( bUp ) + //set new arrow positions in headerbar + if (nItemID != mpImpl->mnSortColumn) { - nBits &= ~HeaderBarItemBits::UPARROW; - nBits |= HeaderBarItemBits::DOWNARROW; + // remove old indicator, new will be created in OpenFolder_Impl + pView->set_sort_indicator(TRISTATE_INDET, mpImpl->GetSortColumn()); } else - { - nBits &= ~HeaderBarItemBits::DOWNARROW; - nBits |= HeaderBarItemBits::UPARROW; - } + bSortAtoZ = !bSortAtoZ; - pBar->SetItemBits( nItemID, nBits ); - mpImpl->Resort_Impl( nItemID, !bUp ); -} - - -IMPL_LINK( SvtFileView, HeaderEndDrag_Impl, HeaderBar*, pBar, void ) -{ - if ( pBar->IsItemMode() ) - return; - - Size aSize; - sal_uInt16 nTabs = pBar->GetItemCount(); - long nTmpSize = 0; - - for ( sal_uInt16 i = 1; i <= nTabs; ++i ) - { - long nWidth = pBar->GetItemSize(i); - aSize.setWidth( nWidth + nTmpSize ); - nTmpSize += nWidth; - mpImpl->mpView->SetTab( i, aSize.Width(), MapUnit::MapPixel ); - } + mpImpl->Resort_Impl(nItemID, bSortAtoZ); } - OUString SvtFileView::GetConfigString() const { - OUString sRet; - HeaderBar* pBar = mpImpl->mpView->GetHeaderBar(); - DBG_ASSERT( pBar, "invalid headerbar" ); - // sort order - sRet += OUString::number( mpImpl->mnSortColumn ) + ";"; - HeaderBarItemBits nBits = pBar->GetItemBits( mpImpl->mnSortColumn ); - bool bUp = ( ( nBits & HeaderBarItemBits::UPARROW ) == HeaderBarItemBits::UPARROW ); + OUString sRet = OUString::number( mpImpl->mnSortColumn ) + ";"; + + bool bUp = mpImpl->mbAscending; sRet += bUp ? OUString("1") : OUString("0"); sRet += ";"; - sal_uInt16 nCount = pBar->GetItemCount(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) + weld::TreeView* pView = mpImpl->mxView->getWidget(); + sal_uInt16 nCount = mpImpl->mxView->TypeColumnVisible() ? 4 : 3; + for (sal_uInt16 i = 0; i < nCount; ++i) { - sal_uInt16 nId = pBar->GetItemId(i); + sal_uInt16 nId = i + 1; + // skip "TYPE" + if (!mpImpl->mxView->TypeColumnVisible() && nId != COLUMN_TITLE) + ++nId; + sRet += OUString::number( nId ) + ";" - + OUString::number( pBar->GetItemSize( nId ) ) + + OUString::number(pView->get_column_width(i)) + ";"; } - sRet = comphelper::string::stripEnd(sRet, ';'); - return sRet; + return comphelper::string::stripEnd(sRet, ';'); } ::std::vector< SvtContentEntry > SvtFileView::GetContent() @@ -1164,84 +1092,69 @@ OUString SvtFileView::GetConfigString() const return aContent; } -void SvtFileView::SetConfigString( const OUString& rCfgStr ) +void SvtFileView::SetConfigString(const OUString& rCfgStr) { - HeaderBar* pBar = mpImpl->mpView->GetHeaderBar(); - DBG_ASSERT( pBar, "invalid headerbar" ); - sal_Int32 nIdx = 0; mpImpl->mnSortColumn = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); - bool bUp = static_cast<bool>(static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32())); - HeaderBarItemBits nBits = pBar->GetItemBits( mpImpl->mnSortColumn ); + mpImpl->mbAscending = static_cast<bool>(static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32())); - if ( bUp ) - { - nBits &= ~HeaderBarItemBits::UPARROW; - nBits |= HeaderBarItemBits::DOWNARROW; - } - else - { - nBits &= ~HeaderBarItemBits::DOWNARROW; - nBits |= HeaderBarItemBits::UPARROW; - } - pBar->SetItemBits( mpImpl->mnSortColumn, nBits ); + std::vector<int> aWidths(mpImpl->mxView->TypeColumnVisible() ? 4 : 3, -1); while ( nIdx != -1 ) { sal_uInt16 nItemId = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); - pBar->SetItemSize( nItemId, rCfgStr.getToken( 0, ';', nIdx ).toInt32() ); - } - HeaderSelect_Impl( pBar ); - HeaderEndDrag_Impl( pBar ); -} + int nWidth = rCfgStr.getToken( 0, ';', nIdx ).toInt32(); + // skip "TYPE" + if (!mpImpl->mxView->TypeColumnVisible() && nItemId != COLUMN_TITLE) + --nItemId; + int nColumn = nItemId - 1; -void SvtFileView::StateChanged( StateChangedType nStateChange ) -{ - if ( nStateChange == StateChangedType::Enable ) - Invalidate(); - Control::StateChanged( nStateChange ); -} + if (nColumn >= 0 && static_cast<unsigned int>(nColumn) < aWidths.size()) + aWidths[nColumn] = nWidth; + } + weld::TreeView* pView = mpImpl->mxView->getWidget(); + pView->set_column_fixed_widths(aWidths); +} // class SvtFileView_Impl - - -SvtFileView_Impl::SvtFileView_Impl( SvtFileView* pAntiImpl, Reference < XCommandEnvironment > const & xEnv, FileViewFlags nFlags, bool bOnlyFolder ) - - :mpAntiImpl ( pAntiImpl ) - ,m_eAsyncActionResult ( ::svt::EnumerationResult::ERROR ) - ,m_bRunningAsyncAction ( false ) - ,m_bAsyncActionCancelled ( false ) - ,mnSortColumn ( COLUMN_TITLE ) - ,mbAscending ( true ) - ,mbOnlyFolder ( bOnlyFolder ) - ,mnSuspendSelectCallback ( 0 ) - ,mbIsFirstResort ( true ) - ,aIntlWrapper ( Application::GetSettings().GetLanguageTag() ) - ,maFolderImage (StockImage::Yes, RID_BMP_FOLDER) - ,mxCmdEnv ( xEnv ) - -{ - mpView = VclPtr<ViewTabListBox_Impl>::Create( mpAntiImpl, this, nFlags ); - mpCurView = mpView; - mpIconView = VclPtr<IconView>::Create( mpAntiImpl, WB_TABSTOP ); - mpIconView->Hide(); - mpView->EnableCellFocus(); +SvtFileView_Impl::SvtFileView_Impl(SvtFileView* pAntiImpl, weld::Window* pTopLevel, + std::unique_ptr<weld::TreeView> xTreeView, + std::unique_ptr<weld::IconView> xIconView, + Reference < XCommandEnvironment > const & xEnv, + FileViewFlags nFlags, bool bOnlyFolder) + : m_pAntiImpl ( pAntiImpl ) + , m_eAsyncActionResult ( ::svt::EnumerationResult::ERROR ) + , m_bRunningAsyncAction ( false ) + , m_bAsyncActionCancelled ( false ) + , m_pTopLevel ( pTopLevel ) + , mxView(new ViewTabListBox_Impl(std::move(xTreeView), pTopLevel, this, nFlags)) + , mxIconView(std::move(xIconView)) + , mnSortColumn ( COLUMN_TITLE ) + , mbAscending ( true ) + , mbOnlyFolder ( bOnlyFolder ) + , mnSuspendSelectCallback ( 0 ) + , mbIsFirstResort ( true ) + , aIntlWrapper ( Application::GetSettings().GetLanguageTag() ) + , maFolderImage (RID_BMP_FOLDER) + , mxCmdEnv ( xEnv ) +{ + weld::TreeView* pWidget = mxView->getWidget(); + + // set the width to something small so its the parent that decides the final + // width + Size aSize(42, pWidget->get_height_rows(7)); + pWidget->set_size_request(aSize.Width(), aSize.Height()); + mxIconView->set_size_request(aSize.Width(), aSize.Height()); } - SvtFileView_Impl::~SvtFileView_Impl() { Clear(); - mpView.disposeAndClear(); - mpCurView.clear(); - mpIconView.disposeAndClear(); - mpAntiImpl.clear(); } - void SvtFileView_Impl::Clear() { ::osl::MutexGuard aGuard( maMutex ); @@ -1249,7 +1162,6 @@ void SvtFileView_Impl::Clear() maContent.clear(); } - FileViewResult SvtFileView_Impl::GetFolderContent_Impl( const OUString& rFolder, const FileViewAsyncAction* pAsyncDescriptor, @@ -1265,7 +1177,6 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( return GetFolderContent_Impl( aFolder, pAsyncDescriptor, rBlackList ); } - FileViewResult SvtFileView_Impl::GetFolderContent_Impl( const FolderDescriptor& _rFolder, const FileViewAsyncAction* pAsyncDescriptor, @@ -1276,7 +1187,7 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( OSL_ENSURE( !m_xContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" ); m_xContentEnumerator.set(new ::svt::FileViewContentEnumerator( - mpView->GetCommandEnvironment(), maContent, maMutex)); + mxView->GetCommandEnvironment(), maContent, maMutex)); // TODO: should we cache and re-use this thread? if ( !pAsyncDescriptor ) @@ -1346,8 +1257,9 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( m_aCurrentAsyncActionHandler = pAsyncDescriptor->aFinishHandler; DBG_ASSERT( m_aCurrentAsyncActionHandler.IsSet(), "SvtFileView_Impl::GetFolderContent_Impl: nobody interested when it's finished?" ); - mpView->ClearAll(); - mpIconView->ClearAll(); + maEntries.clear(); + mxView->clear(); + mxIconView->clear(); return eStillRunning; } @@ -1365,7 +1277,6 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( return eFailure; } - void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) { if ( rFilter.isEmpty() || ( rFilter == ALL_FILES_FILTER ) ) @@ -1395,90 +1306,105 @@ void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) maContent.end()); } - -IMPL_LINK( SvtFileView_Impl, SelectionMultiplexer, SvTreeListBox*, _pSource, void ) +IMPL_LINK_NOARG(SvtFileView_Impl, ChangedHdl, weld::TreeView&, void) { if (!mnSuspendSelectCallback) - m_aSelectHandler.Call( _pSource ); + m_aSelectHandler.Call(m_pAntiImpl); } - -void SvtFileView_Impl::SetSelectHandler( const Link<SvTreeListBox*,void>& _rHdl ) +IMPL_LINK_NOARG(SvtFileView_Impl, SelectionChangedHdl, weld::IconView&, void) { - m_aSelectHandler = _rHdl; + if (!mnSuspendSelectCallback) + m_aSelectHandler.Call(m_pAntiImpl); +} - Link<SvTreeListBox*,void> aMasterHandler; - if ( m_aSelectHandler.IsSet() ) - aMasterHandler = LINK( this, SvtFileView_Impl, SelectionMultiplexer ); +void SvtFileView_Impl::SetSelectHandler(const Link<SvtFileView*,void>& rHdl) +{ + m_aSelectHandler = rHdl; - mpView->SetSelectHdl( aMasterHandler ); - mpIconView->SetSelectHdl( aMasterHandler ); + mxView->connect_changed(LINK(this, SvtFileView_Impl, ChangedHdl)); + mxIconView->connect_selection_changed(LINK(this, SvtFileView_Impl, SelectionChangedHdl)); } +IMPL_LINK_NOARG(SvtFileView_Impl, RowActivatedHdl, weld::TreeView&, bool) +{ + return maDoubleClickHandler.Call(m_pAntiImpl); +} -void SvtFileView_Impl::InitSelection() +IMPL_LINK_NOARG(SvtFileView_Impl, ItemActivatedHdl, weld::IconView&, bool) { - mpCurView->SelectAll( false ); - SvTreeListEntry* pFirst = mpCurView->First(); - if ( pFirst ) - mpCurView->SetCursor( pFirst, true ); + return maDoubleClickHandler.Call(m_pAntiImpl); } +void SvtFileView_Impl::SetDoubleClickHandler(const Link<SvtFileView*,bool>& rHdl) +{ + maDoubleClickHandler = rHdl; + + mxView->connect_row_activated(LINK(this, SvtFileView_Impl, RowActivatedHdl)); + mxIconView->connect_item_activated(LINK(this, SvtFileView_Impl, ItemActivatedHdl)); +} void SvtFileView_Impl::OpenFolder_Impl() { ::osl::MutexGuard aGuard( maMutex ); - mpView->SetUpdateMode( false ); - mpIconView->SetUpdateMode( false ); - mpView->ClearAll(); - mpIconView->ClearAll(); + mxView->freeze(); + mxIconView->freeze(); + maEntries.clear(); + mxView->clear(); + mxIconView->clear(); for (auto const& elem : maContent) { - if ( mbOnlyFolder && ! elem->mbIsFolder ) + if (mbOnlyFolder && !elem->mbIsFolder) continue; // insert entry and set user data - SvTreeListEntry* pEntry = mpView->InsertEntry( elem->maDisplayText, - elem->maImage, - elem->maImage ); - - SvTreeListEntry* pEntry2 = mpIconView->InsertEntry( elem->maDisplayText.getToken( 0, '\t' ), - elem->maImage, elem->maImage ); - - SvtContentEntry* pUserData = new SvtContentEntry( elem->maTargetURL, - elem->mbIsFolder ); - SvtContentEntry* pUserData2 = new SvtContentEntry( elem->maTargetURL, - elem->mbIsFolder ); - - pEntry->SetUserData( pUserData ); - pEntry2->SetUserData( pUserData2 ); + maEntries.emplace_back(std::make_unique<SvtContentEntry>(elem->maTargetURL, elem->mbIsFolder)); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(maEntries.back().get()))); + mxView->append(sId, elem->maDisplayName, elem->maType, elem->maDisplaySize, elem->maDisplayDate, elem->maImage); + mxIconView->append(sId, elem->maDisplayName, elem->maImage); } - InitSelection(); - ++mnSuspendSelectCallback; - mpView->SetUpdateMode( true ); - mpIconView->SetUpdateMode( true ); + mxView->thaw(); + + //set sort indicator + weld::TreeView* pView = mxView->getWidget(); + pView->set_sort_indicator(mbAscending ? TRISTATE_TRUE : TRISTATE_FALSE, GetSortColumn()); + + mxIconView->thaw(); --mnSuspendSelectCallback; ResetCursor(); } - void SvtFileView_Impl::ResetCursor() { - // deselect - SvTreeListEntry* pEntry = mpCurView->FirstSelected(); - if ( pEntry ) - mpCurView->Select( pEntry, false ); - // set cursor to the first entry - mpCurView->SetCursor( mpCurView->First(), true ); - mpCurView->Update(); + if (mxView->get_visible()) + { + // deselect + mxView->unselect_all(); + std::unique_ptr<weld::TreeIter> xFirst = mxView->make_iterator(); + if (mxView->get_iter_first(*xFirst)) + { + // set cursor to the first entry + mxView->set_cursor(*xFirst); + } + } + else + { + // deselect + mxIconView->unselect_all(); + std::unique_ptr<weld::TreeIter> xFirst = mxIconView->make_iterator(); + if (mxIconView->get_iter_first(*xFirst)) + { + // set cursor to the first entry + mxIconView->set_cursor(*xFirst); + } + } } - void SvtFileView_Impl::CancelRunningAsyncAction() { DBG_TESTSOLARMUTEX(); @@ -1551,48 +1477,43 @@ void SvtFileView_Impl::implEnumerationSuccess() SortFolderContent_Impl(); CreateDisplayText_Impl(); OpenFolder_Impl(); - maOpenDoneLink.Call( mpAntiImpl ); + maOpenDoneLink.Call( m_pAntiImpl ); } - -void SvtFileView_Impl::ReplaceTabWithString( OUString& aValue ) +OUString SvtFileView_Impl::ReplaceTabWithString(const OUString& rValue) { OUString const aTab( "\t" ); OUString const aTabString( "%09" ); - sal_Int32 iPos; + sal_Int32 iPos; + OUString aValue(rValue); while ( ( iPos = aValue.indexOf( aTab ) ) >= 0 ) - aValue = aValue.replaceAt( iPos, 1, aTabString ); + aValue = aValue.replaceAt( iPos, 1, aTabString ); + return aValue; } - void SvtFileView_Impl::CreateDisplayText_Impl() { ::osl::MutexGuard aGuard( maMutex ); - OUString const aTab( "\t" ); OUString const aDateSep( ", " ); for (auto const& elem : maContent) { // title, type, size, date - OUString aValue = elem->GetTitle(); - ReplaceTabWithString( aValue ); - aValue += aTab + elem->maType + aTab; + elem->maDisplayName = ReplaceTabWithString(elem->GetTitle()); // folders don't have a size if ( ! elem->mbIsFolder ) - aValue += CreateExactSizeText( elem->maSize ); - aValue += aTab; + elem->maDisplaySize = CreateExactSizeText( elem->maSize ); // set the date, but volumes have no date if ( ! elem->mbIsFolder || ! elem->mbIsVolume ) { SvtSysLocale aSysLocale; const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); - aValue += rLocaleData.getDate( elem->maModDate ) - + aDateSep - + rLocaleData.getTime( elem->maModDate, false ); + elem->maDisplayDate = rLocaleData.getDate( elem->maModDate ) + + aDateSep + + rLocaleData.getTime( elem->maModDate, false ); } - elem->maDisplayText = aValue; // detect image if ( elem->mbIsFolder ) @@ -1600,10 +1521,10 @@ void SvtFileView_Impl::CreateDisplayText_Impl() ::svtools::VolumeInfo aVolInfo( elem->mbIsVolume, elem->mbIsRemote, elem->mbIsRemoveable, elem->mbIsFloppy, elem->mbIsCompactDisc ); - elem->maImage = SvFileInformationManager::GetFolderImage( aVolInfo ); + elem->maImage = SvFileInformationManager::GetFolderImageId(aVolInfo); } else - elem->maImage = SvFileInformationManager::GetFileImage( INetURLObject( elem->maTargetURL ) ); + elem->maImage = SvFileInformationManager::GetFileImageId(INetURLObject(elem->maTargetURL)); } } @@ -1617,12 +1538,14 @@ void SvtFileView_Impl::Resort_Impl( sal_Int16 nColumn, bool bAscending ) return; // reset the quick search index - mpView->ResetQuickSearch_Impl( nullptr ); + mxView->ResetQuickSearch_Impl( nullptr ); + + std::unique_ptr<weld::TreeIter> xEntry(mxView->make_iterator()); + bool bEntry = mxView->get_cursor(xEntry.get()); OUString aEntryURL; - SvTreeListEntry* pEntry = mpView->GetCurEntry(); - if ( pEntry && pEntry->GetUserData() ) - aEntryURL = static_cast<SvtContentEntry*>(pEntry->GetUserData())->maURL; + if (bEntry && !mxView->get_id(*xEntry).isEmpty()) + aEntryURL = reinterpret_cast<SvtContentEntry*>(mxView->get_id(*xEntry).toInt64())->maURL; mnSortColumn = nColumn; mbAscending = bAscending; @@ -1632,13 +1555,11 @@ void SvtFileView_Impl::Resort_Impl( sal_Int16 nColumn, bool bAscending ) if ( !mbIsFirstResort ) { - sal_uLong nPos = GetEntryPos( aEntryURL ); - if ( nPos < mpView->GetEntryCount() ) + int nPos = GetEntryPos( aEntryURL ); + if (nPos != -1 && nPos < mxView->n_children()) { - pEntry = mpView->GetEntry( nPos ); - ++mnSuspendSelectCallback; // #i15668# - mpView->SetCurEntry( pEntry ); + mxView->set_cursor(nPos); --mnSuspendSelectCallback; } } @@ -1646,7 +1567,6 @@ void SvtFileView_Impl::Resort_Impl( sal_Int16 nColumn, bool bAscending ) mbIsFirstResort = false; } - static bool gbAscending = true; static sal_Int16 gnColumn = COLUMN_TITLE; static const CollatorWrapper* pCollatorWrapper = nullptr; @@ -1763,11 +1683,7 @@ void SvtFileView_Impl::EntryRenamed( OUString& rURL, if (aFoundElem != maContent.end()) { (*aFoundElem)->SetNewTitle( rTitle ); - OUString aDisplayText = (*aFoundElem)->maDisplayText; - sal_Int32 nIndex = aDisplayText.indexOf( '\t' ); - - if ( nIndex > 0 ) - (*aFoundElem)->maDisplayText = aDisplayText.replaceAt( 0, nIndex, rTitle ); + (*aFoundElem)->maDisplayName = ReplaceTabWithString(rTitle); INetURLObject aURLObj( rURL ); aURLObj.setName( rTitle, INetURLObject::EncodeMechanism::All ); @@ -1778,8 +1694,7 @@ void SvtFileView_Impl::EntryRenamed( OUString& rURL, } } - -OUString SvtFileView_Impl::FolderInserted( const OUString& rURL, const OUString& rTitle ) +const SortingData_Impl& SvtFileView_Impl::FolderInserted( const OUString& rURL, const OUString& rTitle ) { ::osl::MutexGuard aGuard( maMutex ); @@ -1792,69 +1707,53 @@ OUString SvtFileView_Impl::FolderInserted( const OUString& rURL, const OUString& ::svtools::VolumeInfo aVolInfo; pData->maType = SvFileInformationManager::GetFolderDescription( aVolInfo ); - pData->maImage = SvFileInformationManager::GetFolderImage( aVolInfo ); + pData->maImage = SvFileInformationManager::GetFolderImageId( aVolInfo ); - OUString aValue; - OUString const aTab( "\t" ); OUString const aDateSep( ", " ); // title, type, size, date - aValue = pData->GetTitle(); - ReplaceTabWithString( aValue ); - aValue += aTab + pData->maType + aTab + - // folders don't have a size - aTab; + pData->maDisplayName = ReplaceTabWithString(pData->GetTitle()); // set the date SvtSysLocale aSysLocale; const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); - aValue += rLocaleData.getDate( pData->maModDate ) - + aDateSep - + rLocaleData.getTime( pData->maModDate ); + pData->maDisplayDate = rLocaleData.getDate( pData->maModDate ) + + aDateSep + + rLocaleData.getTime( pData->maModDate ); - pData->maDisplayText = aValue; maContent.push_back( std::move(pData) ); - return aValue; + return *maContent.back(); } - -sal_uLong SvtFileView_Impl::GetEntryPos( const OUString& rURL ) +int SvtFileView_Impl::GetEntryPos(const OUString& rURL) { ::osl::MutexGuard aGuard( maMutex ); auto aFoundElem = std::find_if(maContent.begin(), maContent.end(), [&](const std::unique_ptr<SortingData_Impl> & data) { return data->maTargetURL == rURL; }); - return aFoundElem != maContent.end()?std::distance(maContent.begin(), aFoundElem):0; + return aFoundElem != maContent.end() ? std::distance(maContent.begin(), aFoundElem) : -1; } - void SvtFileView_Impl::SetViewMode( FileViewMode eMode ) { switch ( eMode ) { case eDetailedList: - mpCurView = mpView; - mpView->Show(); - mpView->GetHeaderBar()->Show(); - mpIconView->Hide(); + mxView->show(); + mxIconView->hide(); break; case eIcon: - mpCurView = mpIconView; - mpView->Hide(); - mpView->GetHeaderBar()->Hide(); - mpIconView->Show(); + mxView->hide(); + mxIconView->show(); break; default: - mpCurView = mpView; - mpView->Show(); - mpView->GetHeaderBar()->Show(); - mpIconView->Hide(); + mxView->show(); + mxIconView->hide(); }; } - bool SvtFileView_Impl::SearchNextEntry( sal_uInt32& nIndex, const OUString& rTitle, bool bWrapAround ) { ::osl::MutexGuard aGuard( maMutex ); @@ -1894,4 +1793,17 @@ namespace { } } +void SvtFileView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func) +{ + if (mpImpl->mxView->get_visible()) + mpImpl->mxView->selected_foreach(func); + else + mpImpl->mxIconView->selected_foreach(func); +} + +weld::Widget* SvtFileView::identifier() const +{ + return mpImpl->mxView->getWidget(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/fileview.hxx b/fpicker/source/office/fileview.hxx index 141159ee8719..89b16ec64267 100644 --- a/fpicker/source/office/fileview.hxx +++ b/fpicker/source/office/fileview.hxx @@ -22,6 +22,8 @@ #include <memory> #include <com/sun/star/uno/Sequence.h> #include <vcl/ctrl.hxx> +#include <vcl/errinf.hxx> +#include <vcl/weld.hxx> #include <rtl/ustring.hxx> namespace com :: sun :: star :: ucb { class XContent; } @@ -29,10 +31,7 @@ namespace com :: sun :: star :: ucb { class XContent; } // class SvtFileView ----------------------------------------------------- class SvtFileView_Impl; -class SvTreeListEntry; -class HeaderBar; struct SvtContentEntry; -class SvTreeListBox; /// the result of an action in the FileView enum FileViewResult @@ -62,38 +61,39 @@ struct FileViewAsyncAction } }; -class SvtFileView : public Control +class SvtFileView { private: std::unique_ptr<SvtFileView_Impl> mpImpl; - css::uno::Sequence< OUString > mpBlackList; + css::uno::Sequence<OUString> maBlackList; - DECL_LINK( HeaderSelect_Impl, HeaderBar*, void ); - DECL_LINK( HeaderEndDrag_Impl, HeaderBar*, void ); - -protected: - virtual void GetFocus() override; + DECL_LINK(HeaderSelect_Impl, int, void); public: - SvtFileView( vcl::Window* pParent, WinBits nBits, bool bOnlyFolder, bool bMultiSelection, bool bShowType = true ); - virtual ~SvtFileView() override; - virtual void dispose() override; - - virtual Size GetOptimalSize() const override; + SvtFileView(weld::Window* pTopLevel, + std::unique_ptr<weld::TreeView> xTreeView, + std::unique_ptr<weld::IconView> xIconView, + bool bOnlyFolder, bool bMultiSelection, bool bShowType = true); + virtual ~SvtFileView(); void SetViewMode( FileViewMode eMode ); const OUString& GetViewURL() const; - static OUString GetURL( SvTreeListEntry const * pEntry ); + OUString GetURL(const weld::TreeIter& rEntry) const; OUString GetCurrentURL() const; bool GetParentURL( OUString& _rParentURL ) const; void CreatedFolder( const OUString& rUrl, const OUString& rNewFolder ); - void SetHelpId( const OString& rHelpId ); - const OString& GetHelpId( ) const; - void SetSizePixel( const Size& rNewSize ) override; - virtual void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) override; + void set_help_id(const OString& rHelpId); + OString get_help_id() const; + + void grab_focus(); + bool has_focus() const; + + OUString get_selected_text() const; + + weld::Widget* identifier() const; // just to uniquely identify this widget /** initialize the view with the content of a folder given by URL, and apply an immediate filter @@ -153,14 +153,14 @@ public: void SetNoSelection(); - void SetSelectHdl( const Link<SvTreeListBox*,void>& rHdl ); - void SetDoubleClickHdl( const Link<SvTreeListBox*,bool>& rHdl ); + void SetSelectHdl( const Link<SvtFileView*,void>& rHdl ); + void SetDoubleClickHdl( const Link<SvtFileView*,bool>& rHdl ); void SetOpenDoneHdl( const Link<SvtFileView*,void>& rHdl ); sal_uLong GetSelectionCount() const; - SvTreeListEntry* FirstSelected() const; - SvTreeListEntry* NextSelected( SvTreeListEntry* pEntry ) const; - void EnableAutoResize(); + SvtContentEntry* FirstSelected() const; + + void selected_foreach(const std::function<bool(weld::TreeIter&)>& func); void EnableDelete( bool bEnable ); @@ -171,9 +171,6 @@ public: void EndInplaceEditing(); ::std::vector< SvtContentEntry > GetContent(); - -protected: - virtual void StateChanged( StateChangedType nStateChange ) override; }; // struct SvtContentEntry ------------------------------------------------ diff --git a/fpicker/source/office/foldertree.cxx b/fpicker/source/office/foldertree.cxx index a2cc56aca385..e97411c61fd1 100644 --- a/fpicker/source/office/foldertree.cxx +++ b/fpicker/source/office/foldertree.cxx @@ -11,9 +11,7 @@ #include <toolkit/helper/vclunohelper.hxx> #include <tools/urlobj.hxx> #include <ucbhelper/commandenvironment.hxx> -#include <vcl/dialog.hxx> #include <vcl/treelistentry.hxx> -#include <vcl/ptrstyle.hxx> #include <com/sun/star/task/InteractionHandler.hpp> #include "contentenumeration.hxx" #include "foldertree.hxx" @@ -21,44 +19,51 @@ using namespace ::com::sun::star::task; -FolderTree::FolderTree( vcl::Window* pParent, WinBits nBits ) - : SvTreeListBox( pParent, nBits | WB_SORT | WB_TABSTOP ) +FolderTree::FolderTree(std::unique_ptr<weld::TreeView> xTreeView, weld::Window* pTopLevel) + : m_xTreeView(std::move(xTreeView)) + , m_pTopLevel(pTopLevel) { + m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 24, + m_xTreeView->get_height_rows(7)); + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XInteractionHandler > xInteractionHandler( - InteractionHandler::createWithParent(xContext, VCLUnoHelper::GetInterface(GetParentDialog())), UNO_QUERY_THROW ); + InteractionHandler::createWithParent(xContext, pTopLevel->GetXWindow()), UNO_QUERY_THROW); m_xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ); - Image aFolderImage(StockImage::Yes, RID_BMP_FOLDER); - Image aFolderExpandedImage(StockImage::Yes, RID_BMP_FOLDER_OPEN); - SetDefaultCollapsedEntryBmp( aFolderImage ); - SetDefaultExpandedEntryBmp( aFolderExpandedImage ); + m_xTreeView->connect_expanding(LINK(this, FolderTree, RequestingChildrenHdl)); } -void FolderTree::RequestingChildren( SvTreeListEntry* pEntry ) +IMPL_LINK(FolderTree, RequestingChildrenHdl, const weld::TreeIter&, rEntry, bool) { - EnableChildPointerOverwrite( true ); - SetPointer( PointerStyle::Wait ); - Invalidate(InvalidateFlags::Update); + weld::WaitObject aWait(m_pTopLevel); - FillTreeEntry( pEntry ); + FillTreeEntry(rEntry); - SetPointer( PointerStyle::Arrow ); - EnableChildPointerOverwrite( false ); + return true; } -void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) +void FolderTree::InsertRootEntry(const OUString& rId, const OUString& rRootLabel) { - if( !pEntry ) - return; + std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); + OUString sFolderImage(RID_BMP_FOLDER); + m_xTreeView->insert(nullptr, -1, &rRootLabel, &rId, nullptr, nullptr, + &sFolderImage, true, xEntry.get()); + m_xTreeView->set_cursor(*xEntry); +} - OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); +void FolderTree::FillTreeEntry(const weld::TreeIter& rEntry) +{ + OUString sURL = m_xTreeView->get_id(rEntry); + OUString sFolderImage(RID_BMP_FOLDER); - if( pURL && m_sLastUpdatedDir != *pURL ) + if (m_sLastUpdatedDir != sURL) { - while (SvTreeListEntry* pChild = FirstChild(pEntry)) + while (m_xTreeView->iter_has_child(rEntry)) { - GetModel()->Remove(pChild); + std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator(&rEntry)); + m_xTreeView->iter_children(*xChild); + m_xTreeView->remove(*xChild); } ::std::vector< std::unique_ptr<SortingData_Impl> > aContent; @@ -67,22 +72,19 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) xContentEnumerator(new FileViewContentEnumerator( m_xEnv, aContent, m_aMutex)); - FolderDescriptor aFolder( *pURL ); + FolderDescriptor aFolder(sURL); EnumerationResult eResult = xContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList ); - if ( EnumerationResult::SUCCESS == eResult ) + if (EnumerationResult::SUCCESS == eResult) { for(const auto & i : aContent) { - if( i->mbIsFolder ) - { - SvTreeListEntry* pNewEntry = InsertEntry( i->GetTitle(), pEntry, true ); - - OUString* sData = new OUString( i->maTargetURL ); - pNewEntry->SetUserData( static_cast< void* >( sData ) ); - } + if (!i->mbIsFolder) + continue; + m_xTreeView->insert(&rEntry, -1, &i->GetTitle(), &i->maTargetURL, + nullptr, nullptr, &sFolderImage, true, nullptr); } } } @@ -96,27 +98,30 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) void FolderTree::FillTreeEntry( const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders ) { - SetTreePath( rUrl ); + SetTreePath(rUrl); - SvTreeListEntry* pParent = GetCurEntry(); + std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator()); + bool bParent = m_xTreeView->get_cursor(xParent.get()); - if( !(pParent && !IsExpanded( pParent )) ) + if (!bParent || m_xTreeView->get_row_expanded(*xParent)) return; - while (SvTreeListEntry* pChild = FirstChild(pParent)) + OUString sFolderImage(RID_BMP_FOLDER); + while (m_xTreeView->iter_has_child(*xParent)) { - GetModel()->Remove(pChild); + std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator(xParent.get())); + m_xTreeView->iter_children(*xChild); + m_xTreeView->remove(*xChild); } for (auto const& folder : rFolders) { - SvTreeListEntry* pNewEntry = InsertEntry( folder.first, pParent, true ); - OUString* sData = new OUString( folder.second ); - pNewEntry->SetUserData( static_cast< void* >( sData ) ); + m_xTreeView->insert(xParent.get(), -1, &folder.first, &folder.second, + nullptr, nullptr, &sFolderImage, true, nullptr); } m_sLastUpdatedDir = rUrl; - Expand( pParent ); + m_xTreeView->expand_row(*xParent); } void FolderTree::SetTreePath( OUString const & sUrl ) @@ -126,14 +131,15 @@ void FolderTree::SetTreePath( OUString const & sUrl ) OUString sPath = aUrl.GetURLPath( INetURLObject::DecodeMechanism::WithCharset ); - SvTreeListEntry* pEntry = First(); - bool end = false; + std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); + bool bEntry = m_xTreeView->get_iter_first(*xEntry); + bool bEnd = false; - while( pEntry && !end ) + while (bEntry && !bEnd) { - if( pEntry->GetUserData() ) + if (!m_xTreeView->get_id(*xEntry).isEmpty()) { - OUString sNodeUrl = *static_cast< OUString* >( pEntry->GetUserData() ); + OUString sNodeUrl = m_xTreeView->get_id(*xEntry); INetURLObject aUrlObj( sNodeUrl ); aUrlObj.setFinalSlash(); @@ -142,19 +148,19 @@ void FolderTree::SetTreePath( OUString const & sUrl ) if( sPath == sNodeUrl ) { - Select( pEntry ); - end = true; + m_xTreeView->select(*xEntry); + bEnd = true; } else if( sPath.startsWith( sNodeUrl ) ) { - if( !IsExpanded( pEntry ) ) - Expand( pEntry ); + if (!m_xTreeView->get_row_expanded(*xEntry)) + m_xTreeView->expand_row(*xEntry); - pEntry = FirstChild( pEntry ); + bEntry = m_xTreeView->iter_children(*xEntry); } else { - pEntry = pEntry->NextSibling(); + bEntry = m_xTreeView->iter_next_sibling(*xEntry); } } else diff --git a/fpicker/source/office/foldertree.hxx b/fpicker/source/office/foldertree.hxx index 03710efb2076..7e5e85816c48 100644 --- a/fpicker/source/office/foldertree.hxx +++ b/fpicker/source/office/foldertree.hxx @@ -11,35 +11,39 @@ #define INCLUDED_SVTOOLS_FOLDERTREE_HXX #include <com/sun/star/uno/Sequence.hxx> -#include <tools/wintypes.hxx> -#include <vcl/treelistbox.hxx> +#include <vcl/weld.hxx> namespace com :: sun :: star :: ucb { class XCommandEnvironment; } -class SvTreeListEntry; - using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; using namespace ::svt; -class FolderTree : public SvTreeListBox +class FolderTree { private: + std::unique_ptr<weld::TreeView> m_xTreeView; + weld::Window* m_pTopLevel; Reference< XCommandEnvironment > m_xEnv; ::osl::Mutex m_aMutex; Sequence< OUString > m_aBlackList; OUString m_sLastUpdatedDir; + DECL_LINK(RequestingChildrenHdl, const weld::TreeIter&, bool); + public: - FolderTree( vcl::Window* pParent, WinBits nBits ); + FolderTree(std::unique_ptr<weld::TreeView> xTreeView, weld::Window* pTopLevel); + + void clear() { m_xTreeView->clear(); } - virtual void RequestingChildren( SvTreeListEntry* pEntry ) override; + void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xTreeView->connect_changed(rLink); } - void FillTreeEntry( SvTreeListEntry* pEntry ); - void FillTreeEntry( const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders ); - void SetTreePath( OUString const & sUrl ); - void SetBlackList( const css::uno::Sequence< OUString >& rBlackList ); + void InsertRootEntry(const OUString& rId, const OUString& rRootLabel); + void FillTreeEntry(const weld::TreeIter& rEntry); + void FillTreeEntry(const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders); + void SetTreePath(OUString const & sUrl); + void SetBlackList(const css::uno::Sequence< OUString >& rBlackList); }; #endif diff --git a/fpicker/source/office/fpdialogbase.hxx b/fpicker/source/office/fpdialogbase.hxx index 9db337f286a2..5176e626c861 100644 --- a/fpicker/source/office/fpdialogbase.hxx +++ b/fpicker/source/office/fpdialogbase.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_FPICKER_SOURCE_OFFICE_FPDIALOGBASE_HXX #define INCLUDED_FPICKER_SOURCE_OFFICE_FPDIALOGBASE_HXX -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/beans/StringPair.hpp> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -57,14 +57,16 @@ namespace o3tl { // SvtFileDialog_Base -class SvtFileDialog_Base : public Dialog, public ::svt::IFilePickerController +class SvtFileDialog_Base : public weld::GenericDialogController, public ::svt::IFilePickerController { public: - SvtFileDialog_Base( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription ) - : Dialog(pParent, rID, rUIXMLDescription) + SvtFileDialog_Base(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID) + : weld::GenericDialogController(pParent, rUIXMLDescription, rID) { } + virtual bool PrepareExecute() { return true ; } + virtual SvtFileView* GetView() = 0; virtual void SetHasFilename( bool bHasFilename ) = 0; @@ -94,7 +96,6 @@ public: virtual void EnableAutocompletion( bool _bEnable = true ) = 0; - virtual sal_Int32 getTargetColorDepth() = 0; virtual sal_Int32 getAvailableWidth() = 0; virtual sal_Int32 getAvailableHeight() = 0; 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, diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx index e6adff2657c6..bd5d9225b676 100644 --- a/fpicker/source/office/iodlg.hxx +++ b/fpicker/source/office/iodlg.hxx @@ -44,9 +44,8 @@ class SvTabListBox; class SvtFileView; class SvtFileDialogFilter_Impl; -class SvtURLBox; class SvtExpFileDlg_Impl; -class CustomContainer; +class URLBox; enum class AdjustFilterFlags { NONE = 0x0000, @@ -62,25 +61,24 @@ namespace o3tl { class SvtFileDialog final : public SvtFileDialog_Base { private: - VclPtr<CheckBox> _pCbReadOnly; - VclPtr<CheckBox> _pCbLinkBox; - VclPtr<CheckBox> _pCbPreviewBox; - VclPtr<CheckBox> _pCbSelection; - VclPtr<PushButton> _pPbPlay; - VclPtr<vcl::Window> _pPrevWin; - VclPtr<FixedBitmap> _pPrevBmp; - VclPtr<CustomContainer> _pContainer; - VclPtr<SvtFileView> _pFileView; - VclPtr<Splitter> _pSplitter; - ::svt::IFilePickerListener* _pFileNotifier; - std::unique_ptr<SvtExpFileDlg_Impl> pImpl; - PickerFlags _nPickerFlags; - bool _bIsInExecute : 1; + std::unique_ptr<weld::CheckButton> m_xCbReadOnly; + std::unique_ptr<weld::CheckButton> m_xCbLinkBox; + std::unique_ptr<weld::CheckButton> m_xCbPreviewBox; + std::unique_ptr<weld::CheckButton> m_xCbSelection; + std::unique_ptr<weld::Button> m_xPbPlay; + std::unique_ptr<weld::Widget> m_xPreviewFrame; + std::unique_ptr<weld::Image> m_xPrevBmp; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<SvtFileView> m_xFileView; + ::svt::IFilePickerListener* m_pFileNotifier; + std::unique_ptr<SvtExpFileDlg_Impl> m_xImpl; + Size m_aPreviewSize; + PickerFlags m_nPickerFlags; + bool m_bIsInExecute : 1; ::svt::SmartContent m_aContent; - ::std::set< VclPtr<Control> > - m_aDisabledControls; + ::std::set<weld::Widget*> m_aDisabledControls; ::utl::OConfigurationNode m_aConfiguration; ::rtl::Reference< ::svt::AsyncPickerAction > @@ -88,26 +86,26 @@ private: bool m_bInExecuteAsync; bool m_bHasFilename; css::uno::Reference < css::uno::XComponentContext > - m_context; + m_xContext; - DECL_LINK( FilterSelectHdl_Impl, ListBox&, void ); + DECL_LINK( FilterSelectHdl_Impl, weld::ComboBox&, void ); DECL_LINK( FilterSelectTimerHdl_Impl, Timer*, void ); - DECL_LINK( NewFolderHdl_Impl, Button*, void ); - DECL_LINK( OpenUrlHdl_Impl, SvtURLBox*, void ); - DECL_LINK( OpenClickHdl_Impl, Button*, void ); - DECL_LINK( CancelHdl_Impl, Button*, void ); - DECL_LINK( FileNameGetFocusHdl_Impl, Control&, void ); - DECL_LINK( FileNameModifiedHdl_Impl, Edit&, void ); - - DECL_LINK( URLBoxModifiedHdl_Impl, SvtURLBox*, void ); - DECL_LINK( ConnectToServerPressed_Hdl, Button*, void ); - - DECL_LINK( AddPlacePressed_Hdl, Button*, void ); - DECL_LINK( RemovePlacePressed_Hdl, Button*, void ); - DECL_LINK( Split_Hdl, Splitter*, void ); - - void OpenHdl_Impl(void const * pVoid); - void Init_Impl( PickerFlags nBits ); + DECL_LINK( NewFolderHdl_Impl, weld::Button&, void ); + DECL_LINK( OpenUrlHdl_Impl, weld::ComboBox&, bool ); + DECL_LINK( OpenClickHdl_Impl, weld::Button&, void ); + DECL_LINK( CancelHdl_Impl, weld::Button&, void ); + DECL_LINK( FileNameGetFocusHdl_Impl, weld::Widget&, void ); + DECL_LINK( FileNameModifiedHdl_Impl, weld::ComboBox&, void ); + + DECL_LINK( URLBoxModifiedHdl_Impl, weld::ComboBox&, bool ); + DECL_LINK( ConnectToServerPressed_Hdl, weld::Button&, void ); + + DECL_LINK( AddPlacePressed_Hdl, weld::Button&, void ); + DECL_LINK( RemovePlacePressed_Hdl, weld::Button&, void ); + DECL_LINK( PreviewSizeAllocHdl, const Size&, void); + + void OpenHdl_Impl(void const * pVoid); + /** find a filter with the given wildcard @param _rFilter the wildcard pattern to look for in the filter list @@ -126,24 +124,20 @@ private: void OpenMultiSelection_Impl(); void AddControls_Impl( ); - DECL_LINK( SelectHdl_Impl, SvTreeListBox*, void ); - DECL_LINK( DblClickHdl_Impl, SvTreeListBox*, bool); - DECL_LINK( EntrySelectHdl_Impl, ComboBox&, void); - DECL_LINK( OpenDoneHdl_Impl, SvtFileView*, void ); - DECL_LINK( AutoExtensionHdl_Impl, Button*, void); - DECL_LINK( ClickHdl_Impl, Button*, void ); - DECL_LINK( PlayButtonHdl_Impl, Button*, void); - + DECL_LINK(SelectHdl_Impl, SvtFileView*, void); + DECL_LINK(DblClickHdl_Impl, SvtFileView*, bool); + DECL_LINK(EntrySelectHdl_Impl, weld::ComboBox&, void); + DECL_LINK(OpenDoneHdl_Impl, SvtFileView*, void); + DECL_LINK(AutoExtensionHdl_Impl, weld::Button&, void); + DECL_LINK(ClickHdl_Impl, weld::Button&, void); + DECL_LINK(PlayButtonHdl_Impl, weld::Button&, void); + DECL_LINK(SizeAllocHdl, const Size&, void); // removes a filter with wildcards from the path and returns it static bool IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilter ); - void implUpdateImages( ); - - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - - OUString _aPath; - OUString _aDefExt; + OUString m_aPath; + OUString m_aDefExt; /** enables or disables the complete UI of the file picker, with only offering a cancel button @@ -158,19 +152,17 @@ private: /** enables or disables a control - You are strongly encouraged to prefer this method over pControl->Enable( _bEnable ). See + You are strongly encouraged to prefer this method over pControl->Enable( bEnable ). See <member>EnableUI</member> for details. */ - void EnableControl( Control* _pControl, bool _bEnable ); - bool PrepareExecute(); + void EnableControl(weld::Widget* pControl, bool bEnable); + virtual bool PrepareExecute() override; public: - SvtFileDialog( vcl::Window* _pParent, PickerFlags nBits ); + SvtFileDialog( weld::Window* pParent, PickerFlags nBits ); virtual ~SvtFileDialog() override; - virtual void dispose() override; - virtual short Execute() override; - virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; + virtual short run() override; void FileSelect(); void FilterSelect() override; @@ -193,9 +185,6 @@ public: sal_uInt16 GetFilterCount() const; const OUString& GetFilterName( sal_uInt16 nPos ) const; - virtual void Resize() override; - virtual void DataChanged( const DataChangedEvent& _rDCEvt ) override; - void PrevLevel_Impl(); void OpenURL_Impl( const OUString& rURL ); @@ -205,9 +194,8 @@ public: void UpdateControls( const OUString& rURL ) override; void EnableAutocompletion( bool _bEnable = true ) override; - void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) override { _pFileNotifier = pNotifier; } + void SetFileCallback( ::svt::IFilePickerListener *pNotifier ) override { m_pFileNotifier = pNotifier; } - sal_Int32 getTargetColorDepth() override; sal_Int32 getAvailableWidth() override; sal_Int32 getAvailableHeight() override; void setImage( const css::uno::Any& rImage ) override; @@ -232,8 +220,6 @@ public: inline void EraseDefaultExt( sal_Int32 _nIndex = 0 ); inline const OUString& GetDefaultExt() const; - static Image GetButtonImage(const OUString& rButtonId); - bool ContentIsFolder( const OUString& rURL ) override { return m_aContent.isFolder( rURL ) && m_aContent.isValid(); } bool ContentHasParentFolder( const OUString& rURL ); bool ContentCanMakeFolder( const OUString& rURL ); @@ -242,7 +228,7 @@ public: private: SvtFileDialogFilter_Impl* implAddFilter( const OUString& _rFilter, const OUString& _rType ); - /** updates _pUserFilter with a new filter + /** updates m_xUserFilter with a new filter <p>No checks for necessity are made.</p> */ void createNewUserFilter( const OUString& _rNewFilter ); @@ -250,7 +236,7 @@ private: AdjustFilterFlags adjustFilter( const OUString& _rFilter ); // IFilePickerController, needed by OControlAccess - virtual Control* getControl( sal_Int16 _nControlId, bool _bLabelControl = false ) const override; + virtual weld::Widget* getControl( sal_Int16 nControlId, bool bLabelControl = false ) const override; virtual void enableControl( sal_Int16 _nControlId, bool _bEnable ) override; virtual OUString getCurFilter( ) const override; @@ -286,7 +272,7 @@ private: inline void SvtFileDialog::SetPath( const OUString& rNewURL ) { - _aPath = rNewURL; + m_aPath = rNewURL; } @@ -298,32 +284,31 @@ inline void SvtFileDialog::SetHasFilename( bool bHasFilename ) inline const OUString& SvtFileDialog::GetPath() { - return _aPath; + return m_aPath; } inline void SvtFileDialog::SetDefaultExt( const OUString& rExt ) { - _aDefExt = rExt; + m_aDefExt = rExt; } inline void SvtFileDialog::EraseDefaultExt( sal_Int32 _nIndex ) { - _aDefExt = _aDefExt.copy( 0, _nIndex ); + m_aDefExt = m_aDefExt.copy( 0, _nIndex ); } inline const OUString& SvtFileDialog::GetDefaultExt() const { - return _aDefExt; + return m_aDefExt; } inline SvtFileView* SvtFileDialog::GetView() { - return _pFileView; + return m_xFileView.get(); } - #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLG_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx index d6e841c14c40..fef6a72513f4 100644 --- a/fpicker/source/office/iodlgimp.cxx +++ b/fpicker/source/office/iodlgimp.cxx @@ -34,78 +34,37 @@ using namespace ::com::sun::star::lang; using namespace ::utl; SvtFileDialogFilter_Impl::SvtFileDialogFilter_Impl( const OUString& rName, const OUString& rType ) - :m_aName( rName ) - ,m_aType( rType ) + : m_aName( rName ) + , m_aType( rType ) { m_aType = m_aType.toAsciiLowerCase(); } - SvtFileDialogFilter_Impl::~SvtFileDialogFilter_Impl() { } - -// SvtFileDialogFilterList_Impl - - -//= SvtFileDialogURLSelector -SvtFileDialogURLSelector::SvtFileDialogURLSelector(vcl::Window* _pParent, SvtFileDialog* _pDlg, WinBits nBits, const OUString& rButtonId) - :MenuButton ( _pParent, nBits ) - ,m_pDlg ( _pDlg ) - ,m_pMenu ( VclPtr<PopupMenu>::Create() ) -{ - SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE ); - SetModeImage(SvtFileDialog::GetButtonImage(rButtonId)); - SetDelayMenu(true); - SetDropDown(PushButtonDropdownStyle::Toolbox); -} - - -SvtFileDialogURLSelector::~SvtFileDialogURLSelector() -{ - disposeOnce(); -} - -void SvtFileDialogURLSelector::dispose() -{ - m_pMenu.disposeAndClear(); - m_pDlg.clear(); - MenuButton::dispose(); -} - - -void SvtFileDialogURLSelector::Activate() -{ - m_pMenu->Clear(); - - FillURLMenu( m_pMenu ); - - SetPopupMenu( m_pMenu ); -} - - //= SvtUpButton_Impl - - -SvtUpButton_Impl::SvtUpButton_Impl( vcl::Window *pParent, SvtFileDialog* pDlg, WinBits nBits ) - :SvtFileDialogURLSelector( pParent, pDlg, nBits, BMP_FILEDLG_BTN_UP ) -{ -} - - -SvtUpButton_Impl::~SvtUpButton_Impl() +SvtUpButton_Impl::SvtUpButton_Impl(std::unique_ptr<weld::Toolbar> xToolbar, + std::unique_ptr<weld::Menu> xMenu, + SvtFileDialog* pDlg) + : m_xToolbar(std::move(xToolbar)) + , m_xMenu(std::move(xMenu)) + , m_pDlg(pDlg) { + m_xToolbar->set_item_menu("up_btn", m_xMenu.get()); + m_xToolbar->connect_clicked(LINK(this, SvtUpButton_Impl, ClickHdl)); + m_xMenu->connect_activate(LINK(this, SvtUpButton_Impl, SelectHdl)); } - -void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu ) +void SvtUpButton_Impl::FillURLMenu() { - SvtFileView* pBox = GetDialogParent()->GetView(); + SvtFileView* pBox = m_pDlg->GetView(); sal_uInt16 nItemId = 1; - _aURLs.clear(); + aURLs.clear(); + m_xMenu->clear(); // determine parent levels INetURLObject aObject( pBox->GetViewURL() ); @@ -114,7 +73,7 @@ void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu ) ::svtools::VolumeInfo aVolInfo( true /* volume */, false /* remote */, false /* removable */, false /* floppy */, false /* compact disk */ ); - Image aVolumeImage( SvFileInformationManager::GetFolderImage( aVolInfo ) ); + OUString aVolumeImage( SvFileInformationManager::GetFolderImageId( aVolInfo ) ); while ( nCount >= 1 ) { @@ -122,98 +81,61 @@ void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu ) OUString aParentURL(aObject.GetMainURL(INetURLObject::DecodeMechanism::NONE)); OUString aTitle; - if (!GetDialogParent()->ContentGetTitle(aParentURL, aTitle) || aTitle.isEmpty()) + + if (nCount == 1) // adjust the title of the top level entry (the workspace) + aTitle = SvlResId(STR_SVT_MIMETYPE_CNT_FSYSBOX); + else if (!m_pDlg->ContentGetTitle(aParentURL, aTitle) || aTitle.isEmpty()) aTitle = aObject.getName(); - Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image - ? SvFileInformationManager::GetImage( aObject ) : aVolumeImage; + OUString aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image + ? SvFileInformationManager::GetImageId( aObject ) : aVolumeImage; - _pMenu->InsertItem( nItemId++, aTitle, aImage ); - _aURLs.push_back(aParentURL); + m_xMenu->append(OUString::number(nItemId), aTitle, aImage); + aURLs.push_back(aParentURL); - if ( nCount == 1 ) - { - // adjust the title of the top level entry (the workspace) - _pMenu->SetItemText(--nItemId, SvlResId(STR_SVT_MIMETYPE_CNT_FSYSBOX)); - } + ++nItemId; --nCount; } } -void SvtUpButton_Impl::Select() +IMPL_LINK(SvtUpButton_Impl, SelectHdl, const OString&, rId, void) { - sal_uInt16 nId = GetCurItemId(); - - if ( nId ) + sal_uInt32 nId = rId.toUInt32(); + if (nId) { --nId; - assert( nId <= _aURLs.size() && "SvtUpButton_Impl: wrong index" ); + assert( nId <= aURLs.size() && "SvtUpButton_Impl: wrong index" ); - GetDialogParent()->OpenURL_Impl(_aURLs[nId]); + m_pDlg->OpenURL_Impl(aURLs[nId]); } } -void SvtUpButton_Impl::Click() +IMPL_LINK_NOARG(SvtUpButton_Impl, ClickHdl, const OString&, void) { - GetDialogParent()->PrevLevel_Impl(); -} - -Size SvtUpButton_Impl::GetOptimalSize() const -{ - return LogicToPixel(Size(12, 12), MapMode(MapUnit::MapAppFont)); + m_pDlg->PrevLevel_Impl(); } // SvtExpFileDlg_Impl -SvtExpFileDlg_Impl::SvtExpFileDlg_Impl() : - - _pCurFilter ( nullptr ), - _pFtFileName ( nullptr ), - _pEdFileName ( nullptr ), - _pFtFileVersion ( nullptr ), - _pLbFileVersion ( nullptr ), - _pFtTemplates ( nullptr ), - _pLbTemplates ( nullptr ), - _pFtImageTemplates ( nullptr ), - _pLbImageTemplates ( nullptr ), - _pFtImageAnchor ( nullptr ), - _pLbImageAnchor ( nullptr ), - _pFtFileType ( nullptr ), - _pLbFilter ( nullptr ), - _pBtnFileOpen ( nullptr ), - _pBtnCancel ( nullptr ), - _pBtnHelp ( nullptr ), - _pBtnUp ( nullptr ), - _pBtnNewFolder ( nullptr ), - _pCbPassword ( nullptr ), - _pCbGPGEncrypt ( nullptr ), - _pEdCurrentPath ( nullptr ), - _pCbAutoExtension ( nullptr ), - _pCbOptions ( nullptr ), - _pPlaces ( nullptr ), - _pBtnConnectToServer( nullptr ), - _eMode ( FILEDLG_MODE_OPEN ), - _eDlgType ( FILEDLG_TYPE_FILEDLG ), - _nStyle ( PickerFlags::NONE ), - _bDoubleClick ( false ), - m_bNeedDelayedFilterExecute ( false ), - _bMultiSelection ( false ) +SvtExpFileDlg_Impl::SvtExpFileDlg_Impl() + : m_pCurFilter( nullptr ) + , m_eMode( FILEDLG_MODE_OPEN ) + , m_eDlgType( FILEDLG_TYPE_FILEDLG ) + , m_nStyle( PickerFlags::NONE ) + , m_bDoubleClick( false ) + , m_bNeedDelayedFilterExecute ( false ) + , m_bMultiSelection( false ) { } - SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl() { - _pBtnUp.disposeAndClear(); - _pUserFilter.reset(); - _pPlaces.disposeAndClear(); } - void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir ) { - _aStdDir = _rDir; - if ( _aStdDir.isEmpty() ) - _aStdDir = "file:///"; + m_aStdDir = _rDir; + if (m_aStdDir.isEmpty()) + m_aStdDir = "file:///"; } namespace { @@ -230,29 +152,25 @@ void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl const * pFilter, || ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ), "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" ); - _pCurFilter = pFilter; + m_pCurFilter = pFilter; m_sCurrentFilterDisplayName = rDisplayName; } - -void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc ) +void SvtExpFileDlg_Impl::InsertFilterListEntry(const SvtFileDialogFilter_Impl* pFilterDesc) { - OUString sName = _pFilterDesc->GetName(); - if ( _pFilterDesc->isGroupSeparator() ) - sName = "------------------------------------------"; + // insert and set user data + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pFilterDesc))); + OUString sName = pFilterDesc->GetName(); + if (pFilterDesc->isGroupSeparator()) + m_xLbFilter->append_separator(sId); else - sName = _pFilterDesc->GetName(); - - // insert an set user data - const sal_Int32 nPos = _pLbFilter->InsertEntry( sName ); - _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) ); + m_xLbFilter->append(sId, sName); } - void SvtExpFileDlg_Impl::InitFilterList( ) { // clear the current list - _pLbFilter->Clear(); + m_xLbFilter->clear(); // reinit it sal_uInt16 nPos = m_aFilter.size(); diff --git a/fpicker/source/office/iodlgimp.hxx b/fpicker/source/office/iodlgimp.hxx index 137fd1d56ad1..68af8a3cd36a 100644 --- a/fpicker/source/office/iodlgimp.hxx +++ b/fpicker/source/office/iodlgimp.hxx @@ -76,179 +76,151 @@ enum SvtFileDlgType FILEDLG_TYPE_PATHDLG }; -class SvtFileDialogURLSelector : public MenuButton +class SvtUpButton_Impl { -public: - virtual ~SvtFileDialogURLSelector() override; - virtual void dispose() override; private: - VclPtr<SvtFileDialog> m_pDlg; - VclPtr<PopupMenu> m_pMenu; + std::unique_ptr<weld::Toolbar> m_xToolbar; + std::unique_ptr<weld::Menu> m_xMenu; + SvtFileDialog* m_pDlg; -protected: - SvtFileDialog* GetDialogParent() { return m_pDlg; } + std::vector<OUString> aURLs; - virtual void FillURLMenu( PopupMenu* _pMenu ) = 0; +public: + SvtUpButton_Impl(std::unique_ptr<weld::Toolbar> xToolbar, + std::unique_ptr<weld::Menu> xMenu, + SvtFileDialog* pDlg); - SvtFileDialogURLSelector(vcl::Window* _pParent, SvtFileDialog* _pDlg, WinBits nBits, const OUString& rButtonId); + void set_help_id(const OString& rHelpId) { m_xToolbar->set_help_id(rHelpId); } + void show() { m_xToolbar->show(); } - virtual void Activate() override; -}; + void FillURLMenu(); + + weld::Widget* getWidget() { return m_xToolbar.get(); } -class SvtUpButton_Impl : public SvtFileDialogURLSelector -{ private: - std::vector<OUString> _aURLs; -public: - SvtUpButton_Impl( vcl::Window* pParent, SvtFileDialog* pDlg, WinBits nBits ); - virtual ~SvtUpButton_Impl() override; - -protected: - virtual void FillURLMenu( PopupMenu* _pMenu ) override; - virtual void Select() override; - virtual void Click() override; - virtual Size GetOptimalSize() const override; + DECL_LINK(SelectHdl, const OString&, void); + DECL_LINK(ClickHdl, const OString&, void); }; -class SvtURLBox; +class URLBox; class SvtExpFileDlg_Impl { private: - const SvtFileDialogFilter_Impl* _pCurFilter; - OUString m_sCurrentFilterDisplayName; // may differ from _pCurFilter->GetName in case it is a cached entry + const SvtFileDialogFilter_Impl* m_pCurFilter; + OUString m_sCurrentFilterDisplayName; // may differ from m_pCurFilter->GetName in case it is a cached entry - css::uno::Sequence< OUString > _aBlackList; + css::uno::Sequence< OUString > m_aBlackList; public: SvtFileDialogFilterList_Impl m_aFilter; - std::unique_ptr<SvtFileDialogFilter_Impl> _pUserFilter; + std::unique_ptr<SvtFileDialogFilter_Impl> m_xUserFilter; - VclPtr<FixedText> _pFtFileName; - VclPtr<SvtURLBox> _pEdFileName; + std::unique_ptr<weld::Label> m_xFtFileName; + std::unique_ptr<URLBox> m_xEdFileName; - VclPtr<FixedText> _pFtFileVersion; - VclPtr<ListBox> _pLbFileVersion; + std::unique_ptr<weld::Label> m_xFtFileVersion; + std::unique_ptr<weld::ComboBox> m_xLbFileVersion; - VclPtr<FixedText> _pFtTemplates; - VclPtr<ListBox> _pLbTemplates; + std::unique_ptr<weld::Label> m_xFtTemplates; + std::unique_ptr<weld::ComboBox> m_xLbTemplates; - VclPtr<FixedText> _pFtImageTemplates; - VclPtr<ListBox> _pLbImageTemplates; + std::unique_ptr<weld::Label> m_xFtImageTemplates; + std::unique_ptr<weld::ComboBox> m_xLbImageTemplates; - VclPtr<FixedText> _pFtImageAnchor; - VclPtr<ListBox> _pLbImageAnchor; + std::unique_ptr<weld::Label> m_xFtImageAnchor; + std::unique_ptr<weld::ComboBox> m_xLbImageAnchor; - VclPtr<FixedText> _pFtFileType; - VclPtr<ListBox> _pLbFilter; - VclPtr<PushButton> _pBtnFileOpen; - VclPtr<PushButton> _pBtnCancel; - VclPtr<HelpButton> _pBtnHelp; - VclPtr<SvtUpButton_Impl> _pBtnUp; - VclPtr<PushButton> _pBtnNewFolder; - VclPtr<CheckBox> _pCbPassword; - VclPtr<CheckBox> _pCbGPGEncrypt; - VclPtr<SvtURLBox> _pEdCurrentPath; - VclPtr<CheckBox> _pCbAutoExtension; - VclPtr<CheckBox> _pCbOptions; + std::unique_ptr<weld::Label> m_xFtFileType; + std::unique_ptr<weld::ComboBox> m_xLbFilter; + std::unique_ptr<weld::Button> m_xBtnFileOpen; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnHelp; + std::unique_ptr<SvtUpButton_Impl> m_xBtnUp; + std::unique_ptr<weld::Button> m_xBtnNewFolder; + std::unique_ptr<weld::CheckButton> m_xCbPassword; + std::unique_ptr<weld::CheckButton> m_xCbGPGEncrypt; + std::unique_ptr<URLBox> m_xEdCurrentPath; + std::unique_ptr<weld::CheckButton> m_xCbAutoExtension; + std::unique_ptr<weld::CheckButton> m_xCbOptions; - VclPtr<PlacesListBox> _pPlaces; - VclPtr<PushButton> _pBtnConnectToServer; + std::unique_ptr<PlacesListBox> m_xPlaces; + std::unique_ptr<weld::Button> m_xBtnConnectToServer; - SvtFileDlgMode _eMode; - SvtFileDlgType _eDlgType; - PickerFlags _nStyle; + SvtFileDlgMode m_eMode; + SvtFileDlgType m_eDlgType; + PickerFlags m_nStyle; - OUString _aStdDir; + OUString m_aStdDir; // delay filter when traveling the filterbox - Timer _aFilterTimer; + Idle m_aFilterIdle; // shows OpenHdl_Imp() if the open was triggered by a double click - bool _bDoubleClick; - bool m_bNeedDelayedFilterExecute; + bool m_bDoubleClick; + bool m_bNeedDelayedFilterExecute; // MultiSelection? - bool _bMultiSelection; + bool m_bMultiSelection; // remember sizes - OUString _aIniKey; - - explicit SvtExpFileDlg_Impl(); - ~SvtExpFileDlg_Impl(); + OUString m_aIniKey; + explicit SvtExpFileDlg_Impl(); + ~SvtExpFileDlg_Impl(); - void SetBlackList( const css::uno::Sequence< OUString >& rBlackList ) { _aBlackList = rBlackList; } - const css::uno::Sequence< OUString >& GetBlackList() const { return _aBlackList; } - void SetStandardDir( const OUString& _rDir ); - const OUString& GetStandardDir() const { return _aStdDir; } - void DisableFilterBoxAutoWidth() { _pLbFilter->EnableDDAutoWidth( false ); } + void SetBlackList( const css::uno::Sequence< OUString >& rBlackList ) { m_aBlackList = rBlackList; } + const css::uno::Sequence< OUString >& GetBlackList() const { return m_aBlackList; } + void SetStandardDir( const OUString& rDir ); + const OUString& GetStandardDir() const { return m_aStdDir; } - - // access to the filter listbox only as Control* - we want to maintain the entries/userdata ourself - Control* GetFilterListControl() { return _pLbFilter; } - const Control* GetFilterListControl() const { return _pLbFilter; } - inline void SetFilterListSelectHdl( const Link<ListBox&,void>& _rHandler ); + // access to the filter listbox only as weld::Widget* - we want to maintain the entries/userdata ourself + weld::Widget* GetFilterListControl() { return m_xLbFilter.get(); } + const weld::Widget* GetFilterListControl() const { return m_xLbFilter.get(); } + void SetFilterListSelectHdl(const Link<weld::ComboBox&, void>& rHandler) + { + m_xLbFilter->connect_changed(rHandler); + } // inits the listbox for the filters from the filter list (_pFilter) void InitFilterList( ); - inline bool HasFilterListEntry( const OUString& _rFilterName ); - inline void SelectFilterListEntry( const OUString& _rFilterName ); - inline void SetNoFilterListSelection( ); - void InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc ); - // _pFilterDesc must already have been added to _pFilter - inline SvtFileDialogFilter_Impl* GetSelectedFilterEntry( OUString& /* [out] */ _rDisplayName ) const; - inline bool IsFilterListTravelSelect() const; - - - // access to the current filter via methods only - need to care for consistency between _pCurFilter and m_sCurrentFilterDisplayName - inline const SvtFileDialogFilter_Impl* GetCurFilter( ) const; - inline const OUString& GetCurFilterDisplayName() const; - void SetCurFilter( SvtFileDialogFilter_Impl const * _pFilter, const OUString& _rDisplayName ); + bool HasFilterListEntry( const OUString& rFilterName ) + { + return m_xLbFilter->find_text(rFilterName) != -1; + } + + void SelectFilterListEntry( const OUString& rFilterName ) + { + m_xLbFilter->set_active_text(rFilterName); + } + + void SetNoFilterListSelection( ) + { + m_xLbFilter->set_active(-1); + } + + void InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc ); + // _pFilterDesc must already have been added to _pFilter + SvtFileDialogFilter_Impl* GetSelectedFilterEntry( OUString& rDisplayName ) const + { + rDisplayName = m_xLbFilter->get_active_text(); + return reinterpret_cast<SvtFileDialogFilter_Impl*>(m_xLbFilter->get_active_id().toInt64()); + } + + // access to the current filter via methods only - need to care for consistency between m_pCurFilter and m_sCurrentFilterDisplayName + const SvtFileDialogFilter_Impl* GetCurFilter( ) const + { + return m_pCurFilter; + } + + const OUString& GetCurFilterDisplayName() const + { + return m_sCurrentFilterDisplayName; + } + + void SetCurFilter( SvtFileDialogFilter_Impl const * _pFilter, const OUString& rDisplayName ); }; -inline void SvtExpFileDlg_Impl::SetFilterListSelectHdl( const Link<ListBox&,void>& _rHandler ) -{ - _pLbFilter->SetSelectHdl( _rHandler ); -} - -inline bool SvtExpFileDlg_Impl::HasFilterListEntry( const OUString& _rFilterName ) -{ - return ( LISTBOX_ENTRY_NOTFOUND != _pLbFilter->GetEntryPos( _rFilterName ) ); -} - -inline void SvtExpFileDlg_Impl::SelectFilterListEntry( const OUString& _rFilterName ) -{ - _pLbFilter->SelectEntry( _rFilterName ); -} - -inline void SvtExpFileDlg_Impl::SetNoFilterListSelection( ) -{ - _pLbFilter->SetNoSelection( ); -} - -inline SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetSelectedFilterEntry( OUString& _rDisplayName ) const -{ - _rDisplayName = _pLbFilter->GetSelectedEntry(); - return static_cast< SvtFileDialogFilter_Impl* >( _pLbFilter->GetSelectedEntryData () ); -} - -inline bool SvtExpFileDlg_Impl::IsFilterListTravelSelect() const -{ - return _pLbFilter->IsTravelSelect(); -} - -inline const SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetCurFilter( ) const -{ - return _pCurFilter; -} - -inline const OUString& SvtExpFileDlg_Impl::GetCurFilterDisplayName() const -{ - return m_sCurrentFilterDisplayName; -} - #endif // INCLUDED_FPICKER_SOURCE_OFFICE_IODLGIMP_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/pickercallbacks.hxx b/fpicker/source/office/pickercallbacks.hxx index 115d6fb83017..9c965f7d37f7 100644 --- a/fpicker/source/office/pickercallbacks.hxx +++ b/fpicker/source/office/pickercallbacks.hxx @@ -23,35 +23,29 @@ #include <sal/types.h> #include <rtl/ustring.hxx> -class Control; - +namespace weld { class Widget; } namespace svt { - - class IFilePickerController { public: - virtual Control* getControl( sal_Int16 _nControlId, bool _bLabelControl = false ) const = 0; - virtual void enableControl( sal_Int16 _nControlId, bool _bEnable ) = 0; + virtual weld::Widget* getControl( sal_Int16 nControlId, bool bLabelControl = false ) const = 0; + virtual void enableControl( sal_Int16 nControlId, bool bEnable ) = 0; virtual OUString getCurFilter( ) const = 0; protected: ~IFilePickerController() {} }; - class IFilePickerListener { public: - virtual void notify( sal_Int16 _nEventId, sal_Int16 _nControlId ) = 0; + virtual void notify( sal_Int16 nEventId, sal_Int16 nControlId ) = 0; protected: ~IFilePickerListener() {} }; - - } // namespace svt diff --git a/fpicker/uiconfig/ui/breadcrumb.ui b/fpicker/uiconfig/ui/breadcrumb.ui new file mode 100644 index 000000000000..c41dc620fdf2 --- /dev/null +++ b/fpicker/uiconfig/ui/breadcrumb.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="fps"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkGrid" id="container"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLinkButton" id="link"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> +</interface> diff --git a/fpicker/uiconfig/ui/explorerfiledialog.ui b/fpicker/uiconfig/ui/explorerfiledialog.ui index 16da6c718d6c..54fa3f52e5b0 100644 --- a/fpicker/uiconfig/ui/explorerfiledialog.ui +++ b/fpicker/uiconfig/ui/explorerfiledialog.ui @@ -1,8 +1,58 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface domain="fps"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-add</property> + </object> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-remove</property> + </object> + <object class="GtkImage" id="image4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">fpicker/res/fp014.png</property> + </object> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore2"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore3"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name text2 --> + <column type="gchararray"/> + <!-- column-name text3 --> + <column type="gchararray"/> + <!-- column-name text1 --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="ExplorerFileDialog"> <property name="can_focus">False</property> <property name="hexpand">True</property> @@ -10,6 +60,9 @@ <property name="border_width">6</property> <property name="modal">True</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -55,11 +108,17 @@ <property name="hexpand">True</property> <property name="spacing">6</property> <child> - <object class="svtlo-SvtURLBox" id="current_path"> + <object class="GtkComboBoxText" id="current_path"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> <property name="hexpand">True</property> - <property name="max_width_chars">40</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -75,6 +134,7 @@ <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="explorerfiledialog|connect_to_server|tooltip_text">Connect To Server</property> + <property name="valign">center</property> <child internal-child="accessible"> <object class="AtkObject" id="connect_to_server-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" context="explorerfiledialog|connect_to_server-atkobject">Connect To Server</property> @@ -88,12 +148,38 @@ </packing> </child> <child> - <object class="GtkBox" id="up"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> + <property name="can_focus">True</property> + <property name="valign">center</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <property name="propagate_natural_width">True</property> + <property name="propagate_natural_height">True</property> <child> - <placeholder/> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkToolbar" id="up_bar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuToolButton" id="up_btn"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <property name="icon_name">res/fp010.png</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -110,6 +196,9 @@ <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="explorerfiledialog|new_folder|tooltip_text">Create New Folder</property> + <property name="valign">center</property> + <property name="image">image4</property> + <property name="always_show_image">True</property> <child internal-child="accessible"> <object class="AtkObject" id="new_folder-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" context="explorerfiledialog|new_folder-atkobject">Create New Folder</property> @@ -137,7 +226,260 @@ <property name="vexpand">True</property> <property name="orientation">vertical</property> <child> - <placeholder/> + <object class="GtkPaned"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="places"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_clickable">False</property> + <property name="search_column">1</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn5"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="explorerfiledialog|places">Places</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext6"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderer11"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="spacing">6</property> + <child> + <object class="GtkButton" id="add"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image1</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="del"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image2</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="resize">False</property> + <property name="shrink">True</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="fileview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore3</property> + <property name="search_column">1</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="explorerfiledialog|name">Name</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderer1"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="explorerfiledialog|type">Type</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer5"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="explorerfiledialog|size">Size</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer2"/> + <attributes> + <attribute name="text">3</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="explorerfiledialog|date">Date modified</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer3"/> + <attributes> + <attribute name="text">4</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkIconView" id="iconview"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + <property name="margin">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore2</property> + <child> + <object class="GtkCellRendererPixbuf" id="icon"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="text"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> </object> <packing> @@ -238,7 +580,6 @@ <property name="hexpand">True</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> - <property name="row_homogeneous">True</property> <child> <object class="GtkLabel" id="file_name_label"> <property name="visible">True</property> @@ -258,6 +599,7 @@ <property name="can_focus">False</property> <property name="halign">end</property> <property name="use_underline">True</property> + <property name="mnemonic_widget">shared</property> </object> <packing> <property name="left_attach">0</property> @@ -279,36 +621,42 @@ </packing> </child> <child> - <object class="svtlo-SvtURLBox" id="file_name"> - <property name="visible">True</property> + <object class="GtkComboBoxText" id="shared"> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="max_width_chars">40</property> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="top_attach">2</property> </packing> </child> <child> - <object class="GtkComboBox" id="shared"> + <object class="GtkComboBoxText" id="file_type"> + <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">2</property> + <property name="top_attach">1</property> </packing> </child> <child> - <object class="GtkComboBox" id="file_type"> + <object class="GtkComboBoxText" id="file_name"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + </child> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">1</property> + <property name="top_attach">0</property> </packing> </child> </object> @@ -324,46 +672,6 @@ <property name="hexpand">True</property> <property name="row_spacing">6</property> <child> - <object class="GtkBox" id="box1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="spacing">12</property> - <child> - <object class="GtkCheckButton" id="link"> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="cb_preview"> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> <object class="GtkCheckButton" id="readonly"> <property name="label" translatable="yes" context="explorerfiledialog|readonly">_Read-only</property> <property name="can_focus">True</property> @@ -465,6 +773,46 @@ <property name="top_attach">2</property> </packing> </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkCheckButton" id="link"> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="cb_preview"> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> </object> <packing> <property name="left_attach">0</property> @@ -499,10 +847,30 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkDrawingArea" id="preview"> - <property name="width_request">200</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> + <object class="GtkScrolledWindow" id="previewframe"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + <property name="valign">start</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <property name="propagate_natural_width">True</property> + <property name="propagate_natural_height">True</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkImage" id="preview"> + <property name="width_request">200</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -527,4 +895,8 @@ </object> </child> </object> + <object class="GtkMenu" id="up_menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> </interface> diff --git a/fpicker/uiconfig/ui/remotefilesdialog.ui b/fpicker/uiconfig/ui/remotefilesdialog.ui index 9136176b2eda..93c17f05ba27 100644 --- a/fpicker/uiconfig/ui/remotefilesdialog.ui +++ b/fpicker/uiconfig/ui/remotefilesdialog.ui @@ -12,33 +12,44 @@ <property name="can_focus">False</property> <property name="icon_name">svx/res/gallist.png</property> </object> - <object class="GtkMenu" id="service_edit_menu"> + <object class="GtkImage" id="image3"> <property name="visible">True</property> <property name="can_focus">False</property> - <child> - <object class="GtkMenuItem" id="edit_service"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="remotefilesdialog|edit_service">_Edit service</property> - <property name="use_underline">True</property> - </object> - </child> - <child> - <object class="GtkMenuItem" id="delete_service"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="remotefilesdialog|delete_service">_Delete service</property> - <property name="use_underline">True</property> - </object> - </child> - <child> - <object class="GtkMenuItem" id="change_password"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="remotefilesdialog|change_password">_Change password</property> - <property name="use_underline">True</property> - </object> - </child> + <property name="icon_name">fpicker/res/fp014.png</property> + </object> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore2"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore3"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name text2 --> + <column type="gchararray"/> + <!-- column-name text3 --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> </object> <object class="GtkDialog" id="RemoteFilesDialog"> <property name="can_focus">False</property> @@ -151,6 +162,7 @@ <object class="GtkComboBoxText" id="services_lb"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="valign">center</property> <accessibility> <relation type="labelled-by" target="label1"/> </accessibility> @@ -162,14 +174,38 @@ </packing> </child> <child> - <object class="GtkMenuButton" id="add_service_btn"> - <property name="label" translatable="yes" context="remotefilesdialog|add_service_btn">Add service</property> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="popup">service_edit_menu</property> + <property name="valign">center</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <property name="propagate_natural_width">True</property> + <property name="propagate_natural_height">True</property> <child> - <placeholder/> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkToolbar" id="add_service_bar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuToolButton" id="add_service_btn"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="remotefilesdialog|add_service_btn">Add service</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -207,13 +243,14 @@ </packing> </child> <child> - <object class="GtkButton" id="list_view"> + <object class="GtkToggleButton" id="list_view"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="remotefilesdialog|list_view|tooltip_text">List view</property> <property name="image">image2</property> + <property name="active">True</property> </object> <packing> <property name="expand">False</property> @@ -222,7 +259,7 @@ </packing> </child> <child> - <object class="GtkButton" id="icon_view"> + <object class="GtkToggleButton" id="icon_view"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -246,6 +283,8 @@ <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="remotefilesdialog|new_folder|tooltip_text">Create New Folder</property> <property name="margin_left">6</property> + <property name="image">image3</property> + <property name="always_show_image">True</property> </object> <packing> <property name="expand">False</property> @@ -262,15 +301,182 @@ </child> <child> <object class="GtkBox" id="container"> - <property name="width_request">555</property> - <property name="height_request">200</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="orientation">vertical</property> <child> - <placeholder/> + <object class="GtkPaned"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="foldertree"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn5"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext6"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderer11"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="resize">False</property> + <property name="shrink">True</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="fileview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore3</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection2"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="remotefilesdialog|name">Name</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderer1"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="remotefilesdialog|size">Size</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer2"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="remotefilesdialog|date">Date modified</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer3"/> + <attributes> + <attribute name="text">3</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkIconView" id="iconview"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + <property name="margin">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore2</property> + <property name="pixbuf_column">0</property> + <property name="text_column">1</property> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> </object> <packing> @@ -304,6 +510,8 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes" context="remotefilesdialog|nameLabel">File name</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">filename</property> <property name="xalign">0</property> </object> <packing> @@ -324,13 +532,10 @@ </packing> </child> <child> - <object class="GtkBox" id="filename_container"> + <object class="GtkEntry" id="filename"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <child> - <placeholder/> - </child> + <property name="can_focus">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">1</property> @@ -349,8 +554,36 @@ <action-widgets> <action-widget response="-11">help</action-widget> <action-widget response="-6">cancel</action-widget> - <action-widget response="101">open</action-widget> - <action-widget response="102">save</action-widget> + <action-widget response="-5">open</action-widget> + <action-widget response="-5">save</action-widget> </action-widgets> </object> + <object class="GtkMenu" id="service_edit_menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="edit_service"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="remotefilesdialog|edit_service">_Edit service</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="delete_service"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="remotefilesdialog|delete_service">_Delete service</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="change_password"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="remotefilesdialog|change_password">_Change password</property> + <property name="use_underline">True</property> + </object> + </child> + </object> </interface> diff --git a/include/svtools/imagemgr.hxx b/include/svtools/imagemgr.hxx index 697ab8aeb41c..0eb8b5e96f00 100644 --- a/include/svtools/imagemgr.hxx +++ b/include/svtools/imagemgr.hxx @@ -124,6 +124,7 @@ public: SVT_DLLPUBLIC static OUString GetFileImageId( const INetURLObject& rURL ); SVT_DLLPUBLIC static Image GetFileImage( const INetURLObject& rURL ); SVT_DLLPUBLIC static Image GetImageNoDefault(const INetURLObject& rURL, bool bBig = false, Size const & rPreferredSize = Size()); + SVT_DLLPUBLIC static OUString GetFolderImageId( const svtools::VolumeInfo& rInfo ); SVT_DLLPUBLIC static Image GetFolderImage( const svtools::VolumeInfo& rInfo ); SVT_DLLPUBLIC static OUString GetDescription( const INetURLObject& rObject ); diff --git a/include/svtools/inettbc.hxx b/include/svtools/inettbc.hxx index ff2a674618b8..c6c3b03137dd 100644 --- a/include/svtools/inettbc.hxx +++ b/include/svtools/inettbc.hxx @@ -98,9 +98,12 @@ class SVT_DLLPUBLIC URLBox rtl::Reference< MatchContext_Impl > pCtx; std::unique_ptr<SvtURLBox_Impl> pImpl; INetProtocol eSmartProtocol; + bool bOnlyDirectories : 1; bool bHistoryDisabled : 1; + bool bNoSelection : 1; Link<weld::ComboBox&, void> aChangeHdl; + Link<weld::Widget&, void> aFocusInHdl; Link<weld::Widget&, void> aFocusOutHdl; std::unique_ptr<weld::ComboBox> m_xWidget; @@ -122,16 +125,21 @@ public: void connect_entry_activate(const Link<weld::ComboBox&, bool>& rLink) { m_xWidget->connect_entry_activate(rLink); } void connect_changed(const Link<weld::ComboBox&, void>& rLink) { aChangeHdl = rLink; } void trigger_changed() { aChangeHdl.Call(*m_xWidget); } + void connect_focus_in(const Link<weld::Widget&, void>& rLink) { aFocusInHdl = rLink; } void connect_focus_out(const Link<weld::Widget&, void>& rLink) { aFocusOutHdl = rLink; } void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); } int find_text(const OUString& rStr) const { return m_xWidget->find_text(rStr); } OUString get_active_text() const { return m_xWidget->get_active_text(); } void grab_focus() { m_xWidget->grab_focus(); } void set_sensitive(bool bSensitive) { m_xWidget->set_sensitive(bSensitive); } - void EnableAutocomplete() { m_xWidget->set_entry_completion(true); } + void set_help_id(const OString& rHelpId) { m_xWidget->set_help_id(rHelpId); } + void select_entry_region(int nStartPos, int nEndPos) { m_xWidget->select_entry_region(nStartPos, nEndPos); } + void EnableAutocomplete(bool bEnable = true) { m_xWidget->set_entry_completion(bEnable); } void SetBaseURL( const OUString& rURL ); const OUString& GetBaseURL() const { return aBaseURL; } + void SetOnlyDirectories( bool bDir ); + void SetNoURLSelection( bool bSet ); void SetSmartProtocol( INetProtocol eProt ); INetProtocol GetSmartProtocol() const { return eSmartProtocol; } OUString GetURL(); diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc index a7ddf804c2e3..5b99e51605e3 100644 --- a/include/svtools/strings.hrc +++ b/include/svtools/strings.hrc @@ -103,22 +103,11 @@ #define STR_FURTHER_OBJECT NC_("STR_FURTHER_OBJECT", "Further objects") #define STR_UNKNOWN_SOURCE NC_("STR_UNKNOWN_SOURCE", "Unknown source") -#define STR_SVT_FILEVIEW_COLUMN_TITLE NC_("STR_SVT_FILEVIEW_COLUMN_TITLE", "Name") -#define STR_SVT_FILEVIEW_COLUMN_SIZE NC_("STR_SVT_FILEVIEW_COLUMN_SIZE", "Size") -#define STR_SVT_FILEVIEW_COLUMN_DATE NC_("STR_SVT_FILEVIEW_COLUMN_DATE", "Date modified") -#define STR_SVT_FILEVIEW_COLUMN_TYPE NC_("STR_SVT_FILEVIEW_COLUMN_TYPE", "Type") #define STR_SVT_BYTES NC_("STR_SVT_BYTES", "Bytes") #define STR_SVT_KB NC_("STR_SVT_KB", "KB") #define STR_SVT_MB NC_("STR_SVT_MB", "MB") #define STR_SVT_GB NC_("STR_SVT_GB", "GB") -// descriptions of accessible objects -#define STR_SVT_ACC_DESC_TABLISTBOX NC_("STR_SVT_ACC_DESC_TABLISTBOX", "Row: %1, Column: %2") -#define STR_SVT_ACC_DESC_FILEVIEW NC_("STR_SVT_ACC_DESC_FILEVIEW", ", Type: %1, URL: %2") -#define STR_SVT_ACC_DESC_FOLDER NC_("STR_SVT_ACC_DESC_FOLDER", "Folder") -#define STR_SVT_ACC_DESC_FILE NC_("STR_SVT_ACC_DESC_FILE", "File") -#define STR_SVT_ACC_EMPTY_FIELD NC_("STR_SVT_ACC_EMPTY_FIELD", "Empty Field") - /* * resources for CollatorResource / CollatorResourceData resp. */ diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx index f370d284e59f..847fda6b71d4 100644 --- a/include/vcl/treelistbox.hxx +++ b/include/vcl/treelistbox.hxx @@ -188,6 +188,7 @@ class VCL_DLLPUBLIC SvTreeListBox friend class SvImpLBox; friend class IconViewImpl; friend class TreeControlPeer; + friend class SalInstanceIconView; friend class SalInstanceTreeView; friend class SalInstanceEntryTreeView; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 300cdf04641f..21550aae2b8c 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> +#include <assert.h> #include <memory> #include <vector> @@ -599,8 +600,8 @@ public: { insert(-1, rStr, &rId, nullptr, &rImage); } - virtual void insert_separator(int pos) = 0; - void append_separator() { insert_separator(-1); } + virtual void insert_separator(int pos, const OUString& rId) = 0; + void append_separator(const OUString& rId) { insert_separator(-1, rId); } virtual int get_count() const = 0; virtual void make_sorted() = 0; @@ -911,16 +912,15 @@ public: void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; } - // return true to allow editing, false to disallow - virtual void connect_editing_started(const Link<const TreeIter&, bool>& rLink) - { - m_aEditingStartedHdl = rLink; - } - + // rStartLink returns true to allow editing, false to disallow + // rEndLink returns true to accept the edit, false to reject virtual void - connect_editing_done(const Link<const std::pair<const TreeIter&, OUString>&, bool>& rLink) + connect_editing(const Link<const TreeIter&, bool>& rStartLink, + const Link<const std::pair<const TreeIter&, OUString>&, bool>& rEndLink) { - m_aEditingDoneHdl = rLink; + assert(rStartLink.IsSet() == rEndLink.IsSet() && "should be both on or both off"); + m_aEditingStartedHdl = rStartLink; + m_aEditingDoneHdl = rEndLink; } virtual void start_editing(const weld::TreeIter& rEntry) = 0; @@ -993,6 +993,77 @@ public: using Widget::set_sensitive; }; +class VCL_DLLPUBLIC IconView : virtual public Container +{ +private: + OUString m_sSavedValue; + +protected: + Link<IconView&, void> m_aSelectionChangeHdl; + Link<IconView&, bool> m_aItemActivatedHdl; + + void signal_selection_changed() { m_aSelectionChangeHdl.Call(*this); } + bool signal_item_activated() { return m_aItemActivatedHdl.Call(*this); } + +public: + virtual void insert(int pos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, TreeIter* pRet) + = 0; + + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(-1, &rStr, &rId, &rImage, nullptr); + } + + void connect_selection_changed(const Link<IconView&, void>& rLink) + { + m_aSelectionChangeHdl = rLink; + } + + /* A row is "activated" when the user double clicks a treeview row. It may + also be emitted when a row is selected and Space or Enter is pressed. + + a return of "true" means the activation has been handled, a "false" propagates + the activation to the default handler which expands/collapses the row, if possible. + */ + void connect_item_activated(const Link<IconView&, bool>& rLink) { m_aItemActivatedHdl = rLink; } + + virtual OUString get_selected_id() const = 0; + + virtual void clear() = 0; + + virtual int count_selected_items() const = 0; + + virtual OUString get_selected_text() const = 0; + + //by index + virtual void select(int pos) = 0; + virtual void unselect(int pos) = 0; + + //via iter + virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0; + virtual bool get_selected(TreeIter* pIter) const = 0; + virtual bool get_cursor(TreeIter* pIter) const = 0; + virtual void set_cursor(const TreeIter& rIter) = 0; + virtual bool get_iter_first(TreeIter& rIter) const = 0; + virtual OUString get_id(const TreeIter& rIter) const = 0; + virtual void scroll_to_item(const TreeIter& rIter) = 0; + + // call func on each selected element until func returns true or we run out of elements + virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0; + + //all of them + void select_all() { unselect(-1); } + void unselect_all() { select(-1); } + + // return the number of toplevel nodes + virtual int n_children() const = 0; + + void save_value() { m_sSavedValue = get_selected_text(); } + OUString const& get_saved_value() const { return m_sSavedValue; } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); } +}; + class VCL_DLLPUBLIC Button : virtual public Container { protected: @@ -1334,6 +1405,7 @@ class VCL_DLLPUBLIC Image : virtual public Widget public: virtual void set_from_icon_name(const OUString& rIconName) = 0; virtual void set_image(VirtualDevice* pDevice) = 0; + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0; }; class VCL_DLLPUBLIC Calendar : virtual public Widget @@ -1846,6 +1918,7 @@ public: virtual bool get_item_sensitive(const OString& rIdent) const = 0; virtual void set_item_active(const OString& rIdent, bool bActive) = 0; virtual bool get_item_active(const OString& rIdent) const = 0; + virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) = 0; virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) = 0; virtual void insert_separator(int pos, const OUString& rId) = 0; @@ -1927,6 +2000,8 @@ public: = 0; virtual std::unique_ptr<TreeView> weld_tree_view(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<IconView> weld_icon_view(const OString& id, bool bTakeOwnership = false) + = 0; virtual std::unique_ptr<Label> weld_label(const OString& id, bool bTakeOwnership = false) = 0; virtual std::unique_ptr<TextView> weld_text_view(const OString& id, bool bTakeOwnership = false) = 0; diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 0adda72cfef0..f06f7467c991 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -4982,10 +4982,6 @@ fpicker/source/office/fileview.cxx fpicker/source/office/fileview.hxx fpicker/source/office/foldertree.cxx fpicker/source/office/foldertree.hxx -fpicker/source/office/iconview.cxx -fpicker/source/office/iconview.hxx -fpicker/source/office/iconviewimpl.cxx -fpicker/source/office/iconviewimpl.hxx fpicker/source/office/fpdialogbase.hxx fpicker/source/office/fpinteraction.cxx fpicker/source/office/fpinteraction.hxx @@ -17253,6 +17249,8 @@ vcl/inc/headless/svpprn.hxx vcl/inc/headless/svpvd.hxx vcl/inc/helpwin.hxx vcl/inc/hyperlabel.hxx +vcl/inc/iconview.hxx +vcl/inc/iconviewimpl.hxx vcl/inc/image.h vcl/inc/impanmvw.hxx vcl/inc/impdel.hxx @@ -17915,6 +17913,8 @@ vcl/source/salmain/salmain.cxx vcl/source/toolkit/group.cxx vcl/source/toolkit/morebtn.cxx vcl/source/treelist/headbar.cxx +vcl/source/treelist/iconview.cxx +vcl/source/treelist/iconviewimpl.cxx vcl/source/treelist/imap.cxx vcl/source/treelist/imap2.cxx vcl/source/treelist/imap3.cxx diff --git a/solenv/sanitizers/ui/fps.suppr b/solenv/sanitizers/ui/fps.suppr index 8a800711f228..25be7fbcdf63 100644 --- a/solenv/sanitizers/ui/fps.suppr +++ b/solenv/sanitizers/ui/fps.suppr @@ -1,7 +1,6 @@ -fpicker/uiconfig/ui/explorerfiledialog.ui://svtlo-SvtURLBox[@id='current_path'] no-labelled-by -fpicker/uiconfig/ui/explorerfiledialog.ui://GtkLabel[@id='shared_label'] orphan-label -fpicker/uiconfig/ui/explorerfiledialog.ui://GtkComboBox[@id='shared'] no-labelled-by +fpicker/uiconfig/ui/breadcrumb.ui://GtkLabel[@id='label'] orphan-label fpicker/uiconfig/ui/explorerfiledialog.ui://GtkCheckButton[@id='link'] button-no-label fpicker/uiconfig/ui/explorerfiledialog.ui://GtkCheckButton[@id='cb_preview'] button-no-label -fpicker/uiconfig/ui/explorerfiledialog.ui://GtkDrawingArea[@id='preview'] no-labelled-by -fpicker/uiconfig/ui/remotefilesdialog.ui://GtkLabel[@id='nameLabel'] orphan-label +fpicker/uiconfig/ui/explorerfiledialog.ui://GtkButton[@id='add'] button-no-label +fpicker/uiconfig/ui/explorerfiledialog.ui://GtkButton[@id='del'] button-no-label +fpicker/uiconfig/ui/explorerfiledialog.ui://GtkMenuToolButton[@id='up_btn'] button-no-label diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 0486958c067b..0f68239194ff 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -126,6 +126,8 @@ class MatchContext_Impl: public salhelper::Thread svtools::AsynchronLink aLink; OUString const aText; URLBox* pBox; + bool const bOnlyDirectories; + bool const bNoSelection; osl::Mutex mutex_; bool stopped_; @@ -482,6 +484,8 @@ MatchContext_Impl::MatchContext_Impl(URLBox* pBoxP, const OUString& rText) , aLink( LINK( this, MatchContext_Impl, Select_Impl ) ) , aText( rText ) , pBox( pBoxP ) + , bOnlyDirectories( pBoxP->bOnlyDirectories ) + , bNoSelection( pBoxP->bNoSelection ) , stopped_(false) , commandId_(0) { @@ -587,7 +591,7 @@ IMPL_LINK_NOARG( MatchContext_Impl, Select_Impl, void*, void ) pBox->append_text(completion); } - pBox->EnableAutocomplete(); + pBox->EnableAutocomplete(!bNoSelection); // transfer string lists to listbox and forget them pBox->pImpl->aURLs = aURLs; @@ -682,7 +686,10 @@ void MatchContext_Impl::ReadFolder( const OUString& rURL, try { - uno::Reference< XDynamicResultSet > xDynResultSet = aCnt.createDynamicCursor( aProps, INCLUDE_FOLDERS_AND_DOCUMENTS ); + ResultSetInclude eInclude = INCLUDE_FOLDERS_AND_DOCUMENTS; + if ( bOnlyDirectories ) + eInclude = INCLUDE_FOLDERS_ONLY; + uno::Reference< XDynamicResultSet > xDynResultSet = aCnt.createDynamicCursor( aProps, eInclude ); uno::Reference < XAnyCompareFactory > xCompare; uno::Reference < XSortedDynamicResultSetFactory > xSRSFac = @@ -1240,6 +1247,10 @@ void MatchContext_Impl::doExecute() } } + if ( bOnlyDirectories ) + // don't scan history picklist if only directories are allowed, picklist contains only files + return; + bool bFull = false; INetURLObject aCurObj; @@ -1957,9 +1968,11 @@ IMPL_LINK_NOARG(URLBox, TryAutoComplete, Timer *, void) OUString aCurText = m_xWidget->get_active_text(); int nStartPos, nEndPos; m_xWidget->get_entry_selection_bounds(nStartPos, nEndPos); - if (nEndPos != aCurText.getLength()) + if (std::max(nStartPos, nEndPos) != aCurText.getLength()) return; - aCurText = aCurText.copy(0, nStartPos); + + auto nLen = std::min(nStartPos, nEndPos); + aCurText = aCurText.copy( 0, nLen ); if (!aCurText.isEmpty()) { if (pCtx.is()) @@ -1977,7 +1990,9 @@ IMPL_LINK_NOARG(URLBox, TryAutoComplete, Timer *, void) URLBox::URLBox(std::unique_ptr<weld::ComboBox> pWidget) : eSmartProtocol(INetProtocol::NotValid) - , bHistoryDisabled(false) + , bOnlyDirectories( false ) + , bHistoryDisabled( false ) + , bNoSelection( false ) , m_xWidget(std::move(pWidget)) { //don't grow to fix mega-long urls @@ -2085,11 +2100,11 @@ IMPL_LINK_NOARG(URLBox, ChangedHdl, weld::ComboBox&, void) IMPL_LINK_NOARG(URLBox, FocusInHdl, weld::Widget&, void) { - (void)this; // loplugin:staticmethod #ifndef UNX // pb: don't select automatically on unix #93251# m_xWidget->select_entry_region(0, -1); #endif + aFocusInHdl.Call(*m_xWidget); } IMPL_LINK_NOARG(URLBox, FocusOutHdl, weld::Widget&, void) @@ -2103,6 +2118,18 @@ IMPL_LINK_NOARG(URLBox, FocusOutHdl, weld::Widget&, void) aFocusOutHdl.Call(*m_xWidget); } +void URLBox::SetOnlyDirectories( bool bDir ) +{ + bOnlyDirectories = bDir; + if ( bOnlyDirectories ) + m_xWidget->clear(); +} + +void URLBox::SetNoURLSelection( bool bSet ) +{ + bNoSelection = bSet; +} + OUString URLBox::GetURL() { // wait for end of autocompletion diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index bd16300c5ced..32edd99987cc 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -788,6 +788,23 @@ Image SvFileInformationManager::GetImageNoDefault(const INetURLObject& rObject, return GetImageFromList_Impl(nImage, bBig, rPreferredSize); } +OUString SvFileInformationManager::GetFolderImageId( const svtools::VolumeInfo& rInfo ) +{ + SvImageId nImage = SvImageId::Folder; + DBG_ASSERT( nImage != SvImageId::NONE, "invalid ImageId" ); + + if ( rInfo.m_bIsRemote ) + nImage = SvImageId::NetworkDevice; + else if ( rInfo.m_bIsCompactDisc ) + nImage = SvImageId::CDRomDevice; + else if ( rInfo.m_bIsRemoveable || rInfo.m_bIsFloppy ) + nImage = SvImageId::RemoveableDevice; + else if ( rInfo.m_bIsVolume ) + nImage = SvImageId::FixedDevice; + + return GetImageNameFromList_Impl(nImage, false/*bBig*/); +} + Image SvFileInformationManager::GetFolderImage( const svtools::VolumeInfo& rInfo ) { SvImageId nImage = SvImageId::Folder; diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index c1868985ee9c..3cb80999a5b6 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -451,7 +451,7 @@ static void lcl_InsertVectors(weld::ComboBox& rBox, rBox.append_text(rItem); for(const auto& rItem : rNext) rBox.append_text(rItem); - rBox.append_separator(); + rBox.append_separator(""); //now insert all strings sorted const auto nStartPos = rBox.get_count(); diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 7cb6c270fd59..00b98cdb2929 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -243,6 +243,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/outdev/nativecontrols \ vcl/source/outdev/map \ vcl/source/treelist/headbar \ + vcl/source/treelist/iconview \ + vcl/source/treelist/iconviewimpl \ vcl/source/treelist/imap \ vcl/source/treelist/imap2 \ vcl/source/treelist/imap3 \ diff --git a/fpicker/source/office/iconview.hxx b/vcl/inc/iconview.hxx index 17a9103e9c2f..750f7ec6ebf0 100644 --- a/fpicker/source/office/iconview.hxx +++ b/vcl/inc/iconview.hxx @@ -31,8 +31,6 @@ public: virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nEntryPos ) override; - void ClearAll(); - void PaintEntry( SvTreeListEntry&, long nX, long nY, vcl::RenderContext& rRenderContext); }; diff --git a/fpicker/source/office/iconviewimpl.hxx b/vcl/inc/iconviewimpl.hxx index df11f5952426..df11f5952426 100644 --- a/fpicker/source/office/iconviewimpl.hxx +++ b/vcl/inc/iconviewimpl.hxx diff --git a/vcl/inc/treeglue.hxx b/vcl/inc/treeglue.hxx index 05ebee523af7..d67ce09d6d96 100644 --- a/vcl/inc/treeglue.hxx +++ b/vcl/inc/treeglue.hxx @@ -17,16 +17,40 @@ class LclHeaderTabListBox : public SvHeaderTabListBox { +private: + Link<SvTreeListEntry*, bool> m_aEditingEntryHdl; + Link<std::pair<SvTreeListEntry*, OUString>, bool> m_aEditedEntryHdl; + public: LclHeaderTabListBox(vcl::Window* pParent, WinBits nWinStyle) : SvHeaderTabListBox(pParent, nWinStyle) { } + void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink) + { + m_aEditingEntryHdl = rLink; + } + + void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink) + { + m_aEditedEntryHdl = rLink; + } + virtual DragDropMode NotifyStartDrag(TransferDataContainer&, SvTreeListEntry*) override { return GetDragDropMode(); } + + virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override + { + return m_aEditingEntryHdl.Call(pEntry); + } + + virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override + { + return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText)); + } }; class LclTabListBox : public SvTabListBox diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index ef81c7f91d3c..6b4dcd0a4032 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <officecfg/Office/Common.hxx> +#include <iconview.hxx> #include <salframe.hxx> #include <salinst.hxx> #include <salvd.hxx> @@ -914,6 +915,10 @@ public: auto nInsertPos = pos == -1 ? MENU_APPEND : pos; m_xMenu->InsertSeparator(rId.toUtf8(), nInsertPos); } + PopupMenu* getMenu() const + { + return m_xMenu.get(); + } virtual ~SalInstanceMenu() override { m_xMenu->SetSelectHdl(Link<::Menu*, bool>()); @@ -933,6 +938,7 @@ class SalInstanceToolbar : public SalInstanceWidget, public virtual weld::Toolba private: VclPtr<ToolBox> m_xToolBox; std::map<sal_uInt16, VclPtr<vcl::Window>> m_aFloats; + std::map<sal_uInt16, VclPtr<PopupMenu>> m_aMenus; DECL_LINK(ClickHdl, ToolBox*, void); DECL_LINK(DropdownClick, ToolBox*, void); @@ -963,12 +969,24 @@ public: if (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN) { auto pFloat = m_aFloats[nItemId]; - if (!pFloat) - return; - if (bActive) - vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); - else - vcl::Window::GetDockingManager()->EndPopupMode(pFloat); + if (pFloat) + { + if (bActive) + vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); + else + vcl::Window::GetDockingManager()->EndPopupMode(pFloat); + } + auto pPopup = m_aMenus[nItemId]; + if (pPopup) + { + if (bActive) + { + tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId); + pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown); + } + else + pPopup->EndExecute(); + } } } @@ -985,7 +1003,20 @@ public: if (pFloat) pFloat->EnableDocking(); - m_aFloats[m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))] = pFloat; + sal_uInt16 nId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); + m_aFloats[nId] = pFloat; + m_aMenus[nId] = nullptr; + } + + virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) override + { + SalInstanceMenu* pInstanceMenu = dynamic_cast<SalInstanceMenu*>(pMenu); + + PopupMenu* pPopup = pInstanceMenu? pInstanceMenu->getMenu() : nullptr; + + sal_uInt16 nId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); + m_aMenus[nId] = pPopup; + m_aFloats[nId] = nullptr; } virtual void insert_separator(int pos, const OUString& /*rId*/) override @@ -2961,6 +2992,11 @@ public: { m_xImage->SetImage(createImage(*pDevice)); } + + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + m_xImage->SetImage(::Image(rImage)); + } }; class SalInstanceCalendar : public SalInstanceWidget, public virtual weld::Calendar @@ -3330,6 +3366,8 @@ public: pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl)); pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl)); } + pHeaderBox->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl)); + pHeaderBox->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl)); } else { @@ -3884,16 +3922,11 @@ public: return ::get_text_emphasis(pEntry, col); } - virtual void connect_editing_started(const Link<const weld::TreeIter&, bool>& rLink) override + virtual void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink, + const Link<const std::pair<const weld::TreeIter&, OUString>&, bool>& rEndLink) override { - m_xTreeView->EnableInplaceEditing(true); - weld::TreeView::connect_editing_started(rLink); - } - - virtual void connect_editing_done(const Link<const std::pair<const weld::TreeIter&, OUString>&, bool>& rLink) override - { - m_xTreeView->EnableInplaceEditing(true); - weld::TreeView::connect_editing_done(rLink); + m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet()); + weld::TreeView::connect_editing(rStartLink, rEndLink); } virtual void start_editing(const weld::TreeIter& rIter) override @@ -4633,6 +4666,242 @@ IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, IterString, rIterString, bool) return signal_editing_done(std::pair<const weld::TreeIter&, OUString>(SalInstanceTreeIter(rIterString.first), rIterString.second)); } +class SalInstanceIconView : public SalInstanceContainer, public virtual weld::IconView +{ +private: + // owner for UserData + std::vector<std::unique_ptr<OUString>> m_aUserData; + VclPtr<::IconView> m_xIconView; + + DECL_LINK(SelectHdl, SvTreeListBox*, void); + DECL_LINK(DeSelectHdl, SvTreeListBox*, void); + DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool); + +public: + SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pIconView, pBuilder, bTakeOwnership) + , m_xIconView(pIconView) + { + m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl)); + m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl)); + m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, DoubleClickHdl)); + } + + virtual void freeze() override + { + SalInstanceWidget::freeze(); + m_xIconView->SetUpdateMode(false); + } + + virtual void thaw() override + { + m_xIconView->SetUpdateMode(true); + SalInstanceWidget::thaw(); + } + + virtual void insert(int pos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, weld::TreeIter* pRet) override + { + disable_notify_events(); + auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos; + void* pUserData; + if (pId) + { + m_aUserData.emplace_back(std::make_unique<OUString>(*pId)); + pUserData = m_aUserData.back().get(); + } + else + pUserData = nullptr; + + SvTreeListEntry* pEntry = new SvTreeListEntry; + if (pIconName) + { + Image aImage(createImage(*pIconName)); + pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); + } + else + { + Image aDummy; + pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); + } + if (pStr) + pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr)); + pEntry->SetUserData(pUserData); + m_xIconView->Insert(pEntry, nullptr, nInsertPos); + + if (pRet) + { + SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet); + pVclRetIter->iter = pEntry; + } + + enable_notify_events(); + } + + virtual OUString get_selected_id() const override + { + assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen"); + if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected()) + { + if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData())) + return *pStr; + } + return OUString(); + } + + virtual OUString get_selected_text() const override + { + assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen"); + if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected()) + return m_xIconView->GetEntryText(pEntry); + return OUString(); + } + + virtual int count_selected_items() const override + { + return m_xIconView->GetSelectionCount(); + } + + virtual void select(int pos) override + { + assert(m_xIconView->IsUpdateMode() && "don't select when frozen"); + disable_notify_events(); + if (pos == -1 || (pos == 0 && n_children() == 0)) + m_xIconView->SelectAll(false); + else + { + SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos); + m_xIconView->Select(pEntry, true); + m_xIconView->MakeVisible(pEntry); + } + enable_notify_events(); + } + + virtual void unselect(int pos) override + { + assert(m_xIconView->IsUpdateMode() && "don't select when frozen"); + disable_notify_events(); + if (pos == -1) + m_xIconView->SelectAll(true); + else + { + SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos); + m_xIconView->Select(pEntry, false); + } + enable_notify_events(); + } + + virtual int n_children() const override + { + return m_xIconView->GetModel()->GetChildList(nullptr).size(); + } + + virtual std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig) const override + { + return std::unique_ptr<weld::TreeIter>(new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig))); + } + + virtual bool get_selected(weld::TreeIter* pIter) const override + { + SvTreeListEntry* pEntry = m_xIconView->FirstSelected(); + auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); + if (pVclIter) + pVclIter->iter = pEntry; + return pEntry != nullptr; + } + + virtual bool get_cursor(weld::TreeIter* pIter) const override + { + SvTreeListEntry* pEntry = m_xIconView->GetCurEntry(); + auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter); + if (pVclIter) + pVclIter->iter = pEntry; + return pEntry != nullptr; + } + + virtual void set_cursor(const weld::TreeIter& rIter) override + { + const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); + disable_notify_events(); + m_xIconView->SetCurEntry(rVclIter.iter); + enable_notify_events(); + } + + virtual bool get_iter_first(weld::TreeIter& rIter) const override + { + SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); + rVclIter.iter = m_xIconView->GetEntry(0); + return rVclIter.iter != nullptr; + } + + virtual void scroll_to_item(const weld::TreeIter& rIter) override + { + assert(m_xIconView->IsUpdateMode() && "don't select when frozen"); + disable_notify_events(); + const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); + m_xIconView->MakeVisible(rVclIter.iter); + enable_notify_events(); + } + + virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override + { + SalInstanceTreeIter aVclIter(m_xIconView->FirstSelected()); + while (aVclIter.iter) + { + if (func(aVclIter)) + return; + aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter); + } + } + + virtual OUString get_id(const weld::TreeIter& rIter) const override + { + const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); + const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData()); + if (pStr) + return *pStr; + return OUString(); + } + + virtual void clear() override + { + disable_notify_events(); + m_xIconView->Clear(); + m_aUserData.clear(); + enable_notify_events(); + } + + virtual ~SalInstanceIconView() override + { + m_xIconView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>()); + m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>()); + m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>()); + } +}; + +IMPL_LINK_NOARG(SalInstanceIconView, SelectHdl, SvTreeListBox*, void) +{ + if (notify_events_disabled()) + return; + signal_selection_changed(); +} + +IMPL_LINK_NOARG(SalInstanceIconView, DeSelectHdl, SvTreeListBox*, void) +{ + if (notify_events_disabled()) + return; + if (m_xIconView->GetSelectionMode() == SelectionMode::Single) + return; + signal_selection_changed(); +} + +IMPL_LINK_NOARG(SalInstanceIconView, DoubleClickHdl, SvTreeListBox*, bool) +{ + if (notify_events_disabled()) + return false; + return !signal_item_activated(); +} + class SalInstanceSpinButton : public SalInstanceEntry, public virtual weld::SpinButton { private: @@ -5472,7 +5741,7 @@ public: } } - virtual void insert_separator(int pos) override + virtual void insert_separator(int pos, const OUString& /*rId*/) override { auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos; m_xComboBox->AddSeparator(nInsertPos - 1); @@ -5588,7 +5857,7 @@ public: } } - virtual void insert_separator(int pos) override + virtual void insert_separator(int pos, const OUString& /*rId*/) override { auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos; m_xComboBox->AddSeparator(nInsertPos - 1); @@ -5667,7 +5936,7 @@ public: rEntry.AddEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener)); } - virtual void insert_separator(int /*pos*/) override + virtual void insert_separator(int /*pos*/, const OUString& /*rId*/) override { assert(false); } @@ -6036,6 +6305,12 @@ public: return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, bTakeOwnership) : nullptr; } + virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString &id, bool bTakeOwnership) override + { + IconView* pIconView = m_xBuilder->get<IconView>(id); + return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, bTakeOwnership) : nullptr; + } + virtual std::unique_ptr<weld::Label> weld_label(const OString &id, bool bTakeOwnership) override { Control* pLabel = m_xBuilder->get<Control>(id); diff --git a/fpicker/source/office/iconview.cxx b/vcl/source/treelist/iconview.cxx index b6571b72d1da..5c2e5b2ffed5 100644 --- a/fpicker/source/office/iconview.cxx +++ b/vcl/source/treelist/iconview.cxx @@ -19,12 +19,11 @@ #include <vcl/treelistentry.hxx> #include <vcl/viewdataentry.hxx> -#include "fileview.hxx" -#include "iconview.hxx" -#include "iconviewimpl.hxx" +#include <iconview.hxx> +#include <iconviewimpl.hxx> IconView::IconView( vcl::Window* pParent, WinBits nBits ) -: SvTreeListBox( pParent, nBits ) + : SvTreeListBox( pParent, nBits ) { nColumns = 1; mbCenterAndClipText = true; @@ -74,14 +73,6 @@ tools::Rectangle IconView::GetFocusRect( SvTreeListEntry*, long nEntryPos ) return aRect; } -void IconView::ClearAll() -{ - for ( sal_uLong i = 0; i < GetEntryCount(); ++i ) - delete static_cast<SvtContentEntry*>(GetEntry(i)->GetUserData()); - - Clear(); -} - void IconView::PaintEntry(SvTreeListEntry& rEntry, long nX, long nY, vcl::RenderContext& rRenderContext) { diff --git a/fpicker/source/office/iconviewimpl.cxx b/vcl/source/treelist/iconviewimpl.cxx index ff3bdfcd9e76..9014220d4820 100644 --- a/fpicker/source/office/iconviewimpl.cxx +++ b/vcl/source/treelist/iconviewimpl.cxx @@ -19,8 +19,8 @@ #include <vcl/svapp.hxx> #include <tools/debug.hxx> -#include "iconview.hxx" -#include "iconviewimpl.hxx" +#include <iconview.hxx> +#include <iconviewimpl.hxx> IconViewImpl::IconViewImpl( SvTreeListBox* pTreeListBox, SvTreeList* pTreeList, WinBits nWinStyle ) : SvImpLBox( pTreeListBox, pTreeList, nWinStyle ) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index f6b38a510d5b..67f96160165b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -48,6 +48,7 @@ #include <vcl/slider.hxx> #include <vcl/weld.hxx> #include <vcl/commandinfoprovider.hxx> +#include <iconview.hxx> #include <svdata.hxx> #include <bitmaps.hlst> #include <messagedialog.hxx> @@ -2040,6 +2041,29 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & xWindow = xBox; } } + else if (name == "GtkIconView") + { + assert(rMap.find(OString("model")) != rMap.end() && "GtkIconView must have a model"); + + //window we want to apply the packing props for this GtkIconView to + VclPtr<vcl::Window> xWindowForPackingProps; + extractModel(id, rMap); + WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_HIDESELECTION; + //IconView manages its own scrolling, + vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); + if (pRealParent != pParent) + nWinStyle |= WB_BORDER; + + VclPtr<IconView> xBox = VclPtr<IconView>::Create(pRealParent, nWinStyle); + xWindowForPackingProps = xBox; + + xWindow = xBox; + xBox->SetNoAutoCurEntry(true); + xBox->SetQuickSearch(true); + + if (pRealParent != pParent) + cleanupWidgetOwnScrolling(pParent, xWindowForPackingProps, rMap); + } else if (name == "GtkTreeView") { if (!m_bLegacy) diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 9cc600dc12b5..b72495c13dc4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1907,6 +1907,21 @@ private: bool signal_button(GdkEventButton* pEvent) { + Point aPos(pEvent->x, pEvent->y); + if (SwapForRTL()) + aPos.setX(gtk_widget_get_allocated_width(m_pWidget) - 1 - aPos.X()); + + if (gdk_event_triggers_context_menu(reinterpret_cast<GdkEvent*>(pEvent)) && pEvent->type == GDK_BUTTON_PRESS) + { + //if handled for context menu, stop processing + CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true); + if (signal_popup_menu(aCEvt)) + return true; + } + + if (!m_aMousePressHdl.IsSet() && !m_aMouseReleaseHdl.IsSet()) + return false; + SalEvent nEventType = SalEvent::NONE; switch (pEvent->type) { @@ -1954,19 +1969,6 @@ private: return false; } - Point aPos(pEvent->x, pEvent->y); - - if (SwapForRTL()) - aPos.setX(gtk_widget_get_allocated_width(m_pWidget) - 1 - aPos.X()); - - if (gdk_event_triggers_context_menu(reinterpret_cast<GdkEvent*>(pEvent)) && pEvent->type == GDK_BUTTON_PRESS) - { - //if handled for context menu, stop processing - CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true); - if (signal_popup_menu(aCEvt)) - return true; - } - sal_uInt32 nModCode = GtkSalFrame::GetMouseModCode(pEvent->state); sal_uInt16 nCode = m_nLastMouseButton | (nModCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); MouseEvent aMEvt(aPos, m_nLastMouseClicks, ImplGetMouseButtonMode(m_nLastMouseButton, nModCode), nCode, nCode); @@ -3111,6 +3113,11 @@ public: m_aMap.clear(); } + GtkMenu* getMenu() const + { + return m_pMenu; + } + virtual ~MenuHelper() { for (auto& a : m_aMap) @@ -3305,12 +3312,13 @@ namespace int getButtonPriority(const OString &rType) { - static const size_t N_TYPES = 6; + static const size_t N_TYPES = 7; static const ButtonOrder aDiscardCancelSave[N_TYPES] = { { "/discard", 0 }, { "/cancel", 1 }, { "/no", 2 }, + { "/open", 3 }, { "/save", 3 }, { "/yes", 3 }, { "/ok", 3 } @@ -3318,6 +3326,7 @@ namespace static const ButtonOrder aSaveDiscardCancel[N_TYPES] = { + { "/open", 0 }, { "/save", 0 }, { "/yes", 0 }, { "/ok", 0 }, @@ -6555,6 +6564,8 @@ public: } } + void set_menu(weld::Menu* pMenu); + virtual ~GtkInstanceMenuButton() override { if (m_pMenuHack) @@ -6785,6 +6796,14 @@ public: } }; +void GtkInstanceMenuButton::set_menu(weld::Menu* pMenu) +{ + GtkInstanceMenu* pPopoverWidget = dynamic_cast<GtkInstanceMenu*>(pMenu); + m_pPopover = nullptr; + GtkWidget* pMenuWidget = GTK_WIDGET(pPopoverWidget ? pPopoverWidget->getMenu() : nullptr); + gtk_menu_button_set_popup(m_pMenuButton, pMenuWidget); +} + class GtkInstanceToolbar : public GtkInstanceWidget, public virtual weld::Toolbar { private: @@ -6916,6 +6935,11 @@ public: m_aMenuButtonMap[rIdent]->set_popover(pPopover); } + virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) override + { + m_aMenuButtonMap[rIdent]->set_menu(pMenu); + } + virtual ~GtkInstanceToolbar() override { for (auto& a : m_aMap) @@ -7136,13 +7160,26 @@ public: virtual void set_image(VirtualDevice* pDevice) override { if (gtk_check_version(3, 20, 0) == nullptr) - gtk_image_set_from_surface(m_pImage, get_underlying_cairo_surface(*pDevice)); - else { - GdkPixbuf* pixbuf = getPixbuf(*pDevice); - gtk_image_set_from_pixbuf(m_pImage, pixbuf); - g_object_unref(pixbuf); + if (pDevice) + gtk_image_set_from_surface(m_pImage, get_underlying_cairo_surface(*pDevice)); + else + gtk_image_set_from_surface(m_pImage, nullptr); + return; } + + GdkPixbuf* pixbuf = pDevice ? getPixbuf(*pDevice) : nullptr; + gtk_image_set_from_pixbuf(m_pImage, pixbuf); + if (pixbuf) + g_object_unref(pixbuf); + } + + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + GdkPixbuf* pixbuf = getPixbuf(rImage); + gtk_image_set_from_pixbuf(m_pImage, pixbuf); + if (pixbuf) + g_object_unref(pixbuf); } }; @@ -8032,6 +8069,15 @@ private: pThis->signal_cell_edited(pCell, path, pNewText); } + static void restoreNonEditable(GObject* pCell) + { + if (g_object_get_data(pCell, "g-lo-RestoreNonEditable")) + { + g_object_set(pCell, "editable", false, "editable-set", false, nullptr); + g_object_set_data(pCell, "g-lo-RestoreNonEditable", reinterpret_cast<gpointer>(false)); + } + } + void signal_cell_edited(GtkCellRendererText* pCell, const gchar *path, const gchar* pNewText) { GtkTreePath *tree_path = gtk_tree_path_new_from_string(path); @@ -8047,6 +8093,13 @@ private: void* pData = g_object_get_data(G_OBJECT(pCell), "g-lo-CellIndex"); set(aGtkIter.iter, reinterpret_cast<sal_IntPtr>(pData), sText); } + + restoreNonEditable(G_OBJECT(pCell)); + } + + static void signalCellEditingCanceled(GtkCellRenderer* pCell, gpointer /*widget*/) + { + restoreNonEditable(G_OBJECT(pCell)); } void signal_column_clicked(GtkTreeViewColumn* pClickedColumn) @@ -8202,6 +8255,7 @@ public: m_aWeightMap[nIndex] = -1; m_aSensitiveMap[nIndex] = -1; g_signal_connect(G_OBJECT(pCellRenderer), "editing-started", G_CALLBACK(signalCellEditingStarted), this); + g_signal_connect(G_OBJECT(pCellRenderer), "editing-canceled", G_CALLBACK(signalCellEditingCanceled), this); g_signal_connect(G_OBJECT(pCellRenderer), "edited", G_CALLBACK(signalCellEdited), this); } else if (GTK_IS_CELL_RENDERER_TOGGLE(pCellRenderer)) @@ -9228,7 +9282,6 @@ public: if (!gtk_tree_view_row_expanded(m_pTreeView, path)) gtk_tree_view_expand_to_path(m_pTreeView, path); gtk_tree_path_free(path); - } virtual void collapse_row(const weld::TreeIter& rIter) override @@ -9525,6 +9578,27 @@ public: GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); GtkTreePath* path = gtk_tree_model_get_path(pModel, const_cast<GtkTreeIter*>(&rGtkIter.iter)); + // allow editing of cells which are not usually editable, so we can have double click + // do its usual row-activate but if we explicitly want to edit (remote files dialog) + // we can still do that + GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn)); + for (GList* pRenderer = g_list_first(pRenderers); pRenderer; pRenderer = g_list_next(pRenderer)) + { + GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); + if (GTK_IS_CELL_RENDERER_TEXT(pCellRenderer)) + { + gboolean is_editable(false); + g_object_get(pCellRenderer, "editable", &is_editable, nullptr); + if (!is_editable) + { + g_object_set(pCellRenderer, "editable", true, "editable-set", true, nullptr); + g_object_set_data(G_OBJECT(pCellRenderer), "g-lo-RestoreNonEditable", reinterpret_cast<gpointer>(true)); + break; + } + } + } + g_list_free(pRenderers); + gtk_tree_view_set_cursor(m_pTreeView, path, pColumn, true); gtk_tree_path_free(path); @@ -9614,6 +9688,373 @@ IMPL_LINK_NOARG(GtkInstanceTreeView, async_stop_cell_editing, void*, void) end_editing(); } +class GtkInstanceIconView : public GtkInstanceContainer, public virtual weld::IconView +{ +private: + GtkIconView* m_pIconView; + GtkTreeStore* m_pTreeStore; + std::vector<int> m_aViewColToModelCol; + std::vector<int> m_aModelColToViewCol; + gint m_nTextCol; + gint m_nImageCol; + gint m_nIdCol; + gulong m_nSelectionChangedSignalId; + gulong m_nItemActivatedSignalId; + ImplSVEvent* m_pSelectionChangeEvent; + + DECL_LINK(async_signal_selection_changed, void*, void); + + void launch_signal_selection_changed() + { + //tdf#117991 selection change is sent before the focus change, and focus change + //is what will cause a spinbutton that currently has the focus to set its contents + //as the spin button value. So any LibreOffice callbacks on + //signal-change would happen before the spinbutton value-change occurs. + //To avoid this, send the signal-change to LibreOffice to occur after focus-change + //has been processed + if (m_pSelectionChangeEvent) + Application::RemoveUserEvent(m_pSelectionChangeEvent); + m_pSelectionChangeEvent = Application::PostUserEvent(LINK(this, GtkInstanceIconView, async_signal_selection_changed)); + } + + static void signalSelectionChanged(GtkIconView*, gpointer widget) + { + GtkInstanceIconView* pThis = static_cast<GtkInstanceIconView*>(widget); + pThis->launch_signal_selection_changed(); + } + + void handle_item_activated() + { + if (signal_item_activated()) + return; + } + + static void signalItemActivated(GtkIconView*, GtkTreePath*, gpointer widget) + { + GtkInstanceIconView* pThis = static_cast<GtkInstanceIconView*>(widget); + SolarMutexGuard aGuard; + pThis->handle_item_activated(); + } + + void insert_item(GtkTreeIter& iter, int pos, const OUString* pId, const OUString* pText, const OUString* pIconName) + { + gtk_tree_store_insert_with_values(m_pTreeStore, &iter, nullptr, pos, + m_nTextCol, !pText ? nullptr : OUStringToOString(*pText, RTL_TEXTENCODING_UTF8).getStr(), + m_nIdCol, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(), + -1); + if (pIconName) + { + GdkPixbuf* pixbuf = getPixbuf(*pIconName); + gtk_tree_store_set(m_pTreeStore, &iter, m_nImageCol, pixbuf, -1); + if (pixbuf) + g_object_unref(pixbuf); + } + } + + OUString get(const GtkTreeIter& iter, int col) const + { + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + gchar* pStr; + gtk_tree_model_get(pModel, const_cast<GtkTreeIter*>(&iter), col, &pStr, -1); + OUString sRet(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + g_free(pStr); + return sRet; + } + + bool get_selected_iterator(GtkTreeIter* pIter) const + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't request selection when frozen"); + bool bRet = false; + { + GtkTreeModel* pModel = GTK_TREE_MODEL(m_pTreeStore); + GList* pList = gtk_icon_view_get_selected_items(m_pIconView); + for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem)) + { + if (pIter) + { + GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data); + gtk_tree_model_get_iter(pModel, pIter, path); + } + bRet = true; + break; + } + g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free)); + } + return bRet; + } + +public: + GtkInstanceIconView(GtkIconView* pIconView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pIconView), pBuilder, bTakeOwnership) + , m_pIconView(pIconView) + , m_pTreeStore(GTK_TREE_STORE(gtk_icon_view_get_model(m_pIconView))) + , m_nTextCol(gtk_icon_view_get_text_column(m_pIconView)) + , m_nImageCol(gtk_icon_view_get_pixbuf_column(m_pIconView)) + , m_nSelectionChangedSignalId(g_signal_connect(pIconView, "selection-changed", + G_CALLBACK(signalSelectionChanged), this)) + , m_nItemActivatedSignalId(g_signal_connect(pIconView, "item-activated", G_CALLBACK(signalItemActivated), this)) + , m_pSelectionChangeEvent(nullptr) + { + m_nIdCol = m_nTextCol + 1; + } + + virtual void insert(int pos, const OUString* pText, const OUString* pId, const OUString* pIconName, weld::TreeIter* pRet) override + { + disable_notify_events(); + GtkTreeIter iter; + insert_item(iter, pos, pId, pText, pIconName); + if (pRet) + { + GtkInstanceTreeIter* pGtkRetIter = static_cast<GtkInstanceTreeIter*>(pRet); + pGtkRetIter->iter = iter; + } + enable_notify_events(); + } + + virtual OUString get_selected_id() const override + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't request selection when frozen"); + GtkTreeIter iter; + if (get_selected_iterator(&iter)) + return get(iter, m_nIdCol); + return OUString(); + } + + virtual void clear() override + { + disable_notify_events(); + gtk_tree_store_clear(m_pTreeStore); + enable_notify_events(); + } + + virtual void freeze() override + { + disable_notify_events(); + g_object_ref(m_pTreeStore); + GtkInstanceContainer::freeze(); + gtk_icon_view_set_model(m_pIconView, nullptr); + enable_notify_events(); + } + + virtual void thaw() override + { + disable_notify_events(); + gtk_icon_view_set_model(m_pIconView, GTK_TREE_MODEL(m_pTreeStore)); + GtkInstanceContainer::thaw(); + g_object_unref(m_pTreeStore); + enable_notify_events(); + } + + virtual Size get_size_request() const override + { + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + { + return Size(gtk_scrolled_window_get_min_content_width(GTK_SCROLLED_WINDOW(pParent)), + gtk_scrolled_window_get_min_content_height(GTK_SCROLLED_WINDOW(pParent))); + } + int nWidth, nHeight; + gtk_widget_get_size_request(m_pWidget, &nWidth, &nHeight); + return Size(nWidth, nHeight); + } + + virtual Size get_preferred_size() const override + { + Size aRet(-1, -1); + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + { + aRet = Size(gtk_scrolled_window_get_min_content_width(GTK_SCROLLED_WINDOW(pParent)), + gtk_scrolled_window_get_min_content_height(GTK_SCROLLED_WINDOW(pParent))); + } + GtkRequisition size; + gtk_widget_get_preferred_size(m_pWidget, nullptr, &size); + if (aRet.Width() == -1) + aRet.setWidth(size.width); + if (aRet.Height() == -1) + aRet.setHeight(size.height); + return aRet; + } + + virtual void show() override + { + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + gtk_widget_show(pParent); + gtk_widget_show(m_pWidget); + } + + virtual void hide() override + { + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + if (GTK_IS_SCROLLED_WINDOW(pParent)) + gtk_widget_hide(pParent); + gtk_widget_hide(m_pWidget); + } + + virtual OUString get_selected_text() const override + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't request selection when frozen"); + GtkTreeIter iter; + if (get_selected_iterator(&iter)) + return get(iter, m_nTextCol); + return OUString(); + } + + virtual int count_selected_items() const override + { + GList* pList = gtk_icon_view_get_selected_items(m_pIconView); + int nRet = g_list_length(pList); + g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free)); + return nRet; + } + + virtual void select(int pos) override + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't select when frozen"); + disable_notify_events(); + if (pos == -1 || (pos == 0 && n_children() == 0)) + { + gtk_icon_view_unselect_all(m_pIconView); + } + else + { + GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); + gtk_icon_view_select_path(m_pIconView, path); + gtk_icon_view_scroll_to_path(m_pIconView, path, false, 0, 0); + gtk_tree_path_free(path); + } + enable_notify_events(); + } + + virtual void unselect(int pos) override + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't select when frozen"); + disable_notify_events(); + if (pos == -1 || (pos == 0 && n_children() == 0)) + { + gtk_icon_view_select_all(m_pIconView); + } + else + { + GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); + gtk_icon_view_select_path(m_pIconView, path); + gtk_tree_path_free(path); + } + enable_notify_events(); + } + + virtual bool get_selected(weld::TreeIter* pIter) const override + { + GtkInstanceTreeIter* pGtkIter = static_cast<GtkInstanceTreeIter*>(pIter); + return get_selected_iterator(pGtkIter ? &pGtkIter->iter : nullptr); + } + + virtual bool get_cursor(weld::TreeIter* pIter) const override + { + GtkInstanceTreeIter* pGtkIter = static_cast<GtkInstanceTreeIter*>(pIter); + GtkTreePath* path; + gtk_icon_view_get_cursor(m_pIconView, &path, nullptr); + if (pGtkIter && path) + { + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + gtk_tree_model_get_iter(pModel, &pGtkIter->iter, path); + } + return path != nullptr; + } + + virtual void set_cursor(const weld::TreeIter& rIter) override + { + const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter); + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreePath* path = gtk_tree_model_get_path(pModel, const_cast<GtkTreeIter*>(&rGtkIter.iter)); + gtk_icon_view_set_cursor(m_pIconView, path, nullptr, false); + gtk_tree_path_free(path); + } + + virtual bool get_iter_first(weld::TreeIter& rIter) const override + { + GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + return gtk_tree_model_get_iter_first(pModel, &rGtkIter.iter); + } + + virtual void scroll_to_item(const weld::TreeIter& rIter) override + { + assert(gtk_icon_view_get_model(m_pIconView) && "don't select when frozen"); + disable_notify_events(); + const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter); + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreePath* path = gtk_tree_model_get_path(pModel, const_cast<GtkTreeIter*>(&rGtkIter.iter)); + gtk_icon_view_scroll_to_path(m_pIconView, path, false, 0, 0); + gtk_tree_path_free(path); + enable_notify_events(); + } + + virtual std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig) const override + { + return std::unique_ptr<weld::TreeIter>(new GtkInstanceTreeIter(static_cast<const GtkInstanceTreeIter*>(pOrig))); + } + + virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override + { + GtkInstanceTreeIter aGtkIter(nullptr); + + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GList* pList = gtk_icon_view_get_selected_items(m_pIconView); + for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem)) + { + GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data); + gtk_tree_model_get_iter(pModel, &aGtkIter.iter, path); + if (func(aGtkIter)) + break; + } + g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free)); + } + + virtual int n_children() const override + { + return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_pTreeStore), nullptr); + } + + virtual OUString get_id(const weld::TreeIter& rIter) const override + { + const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter); + return get(rGtkIter.iter, m_nIdCol); + } + + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pIconView, m_nSelectionChangedSignalId); + g_signal_handler_block(m_pIconView, m_nItemActivatedSignalId); + + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::enable_notify_events(); + + g_signal_handler_unblock(m_pIconView, m_nItemActivatedSignalId); + g_signal_handler_unblock(m_pIconView, m_nSelectionChangedSignalId); + } + + virtual ~GtkInstanceIconView() override + { + if (m_pSelectionChangeEvent) + Application::RemoveUserEvent(m_pSelectionChangeEvent); + + g_signal_handler_disconnect(m_pIconView, m_nItemActivatedSignalId); + g_signal_handler_disconnect(m_pIconView, m_nSelectionChangedSignalId); + } +}; + +IMPL_LINK_NOARG(GtkInstanceIconView, async_signal_selection_changed, void*, void) +{ + m_pSelectionChangeEvent = nullptr; + signal_selection_changed(); +} + class GtkInstanceSpinButton : public GtkInstanceEntry, public virtual weld::SpinButton { private: @@ -11118,7 +11559,7 @@ public: bodge_wayland_menu_not_appearing(); } - virtual void insert_separator(int pos) override + virtual void insert_separator(int pos, const OUString& rId) override { disable_notify_events(); GtkTreeIter iter; @@ -11126,7 +11567,7 @@ public: m_aSeparatorRows.push_back(pos); if (!gtk_combo_box_get_row_separator_func(m_pComboBox)) gtk_combo_box_set_row_separator_func(m_pComboBox, separatorFunction, this, nullptr); - insert_row(GTK_LIST_STORE(m_pTreeModel), iter, pos, nullptr, "", nullptr, nullptr); + insert_row(GTK_LIST_STORE(m_pTreeModel), iter, pos, &rId, "", nullptr, nullptr); enable_notify_events(); bodge_wayland_menu_not_appearing(); } @@ -11491,7 +11932,7 @@ public: m_nEntryInsertTextSignalId = g_signal_connect(pWidget, "insert-text", G_CALLBACK(signalEntryInsertText), this); } - virtual void insert_separator(int /*pos*/) override + virtual void insert_separator(int /*pos*/, const OUString& /*rId*/) override { assert(false); } @@ -12262,6 +12703,15 @@ public: return std::make_unique<GtkInstanceTreeView>(pTreeView, this, bTakeOwnership); } + virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString &id, bool bTakeOwnership) override + { + GtkIconView* pIconView = GTK_ICON_VIEW(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pIconView) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pIconView)); + return std::make_unique<GtkInstanceIconView>(pIconView, this, bTakeOwnership); + } + virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) override { GtkContainer* pContainer = GTK_CONTAINER(gtk_builder_get_object(m_pBuilder, containerid.getStr())); |