From c268527f731fc0764f34ac36c48fd1b6154be80c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 2 Mar 2019 14:18:42 +0000 Subject: weld AddressBookSourceDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3e83c41db04268b7370fdb7370f5b630419c6d4e Reviewed-on: https://gerrit.libreoffice.org/68622 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svtools/source/dialogs/addresstemplate.cxx | 310 ++++++++++------------------- 1 file changed, 110 insertions(+), 200 deletions(-) (limited to 'svtools/source/dialogs') diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 74c200c29c92..56d90626f25b 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -79,10 +79,10 @@ namespace svt namespace { - OUString lcl_getSelectedDataSource( const ComboBox& _dataSourceCombo ) + OUString lcl_getSelectedDataSource( const weld::ComboBox& dataSourceCombo ) { - OUString selectedDataSource = _dataSourceCombo.GetText(); - if ( _dataSourceCombo.GetEntryPos( selectedDataSource ) == LISTBOX_ENTRY_NOTFOUND ) + OUString selectedDataSource = dataSourceCombo.get_active_text(); + if (dataSourceCombo.find_text(selectedDataSource) == -1) { // none of the pre-selected entries -> assume a path to a database document OFileNotation aFileNotation( selectedDataSource, OFileNotation::N_SYSTEM ); @@ -425,8 +425,8 @@ void AssignmentPersistentData::ImplCommit() struct AddressBookSourceDialogData { - std::array, FIELD_PAIRS_VISIBLE*2> pFieldLabels; - std::array, FIELD_PAIRS_VISIBLE*2> pFields; + std::array, FIELD_PAIRS_VISIBLE*2> pFieldLabels; + std::array, FIELD_PAIRS_VISIBLE*2> pFields; /// when working transient, we need the data source Reference< XDataSource > @@ -479,13 +479,10 @@ void AssignmentPersistentData::ImplCommit() AddressBookSourceDialogData & operator= (const AddressBookSourceDialogData &) = delete; }; - // = AddressBookSourceDialog - - - AddressBookSourceDialog::AddressBookSourceDialog(vcl::Window* _pParent, + AddressBookSourceDialog::AddressBookSourceDialog(weld::Window* pParent, const Reference< XComponentContext >& _rxORB ) - : ModalDialog(_pParent, "AddressTemplateDialog", "svt/ui/addresstemplatedialog.ui") + : GenericDialogController(pParent, "svt/ui/addresstemplatedialog.ui", "AddressTemplateDialog") , m_sNoFieldSelection(SvtResId(STR_NO_FIELD_SELECTION)) , m_xORB(_rxORB) , m_pImpl( new AddressBookSourceDialogData ) @@ -493,11 +490,10 @@ void AssignmentPersistentData::ImplCommit() implConstruct(); } - - AddressBookSourceDialog::AddressBookSourceDialog( vcl::Window* _pParent, const Reference< XComponentContext >& _rxORB, + AddressBookSourceDialog::AddressBookSourceDialog(weld::Window* pParent, const Reference< XComponentContext >& _rxORB, const Reference< XDataSource >& _rxTransientDS, const OUString& _rDataSourceName, const OUString& _rTable, const Sequence< AliasProgrammaticPair >& _rMapping ) - : ModalDialog(_pParent, "AddressTemplateDialog", "svt/ui/addresstemplatedialog.ui") + : GenericDialogController(pParent, "svt/ui/addresstemplatedialog.ui", "AddressTemplateDialog") , m_sNoFieldSelection(SvtResId(STR_NO_FIELD_SELECTION)) , m_xORB(_rxORB) , m_pImpl( new AddressBookSourceDialogData( _rxTransientDS, _rDataSourceName, _rTable, _rMapping ) ) @@ -505,26 +501,26 @@ void AssignmentPersistentData::ImplCommit() implConstruct(); } - void AddressBookSourceDialog::implConstruct() { - get(m_pDatasource, "datasource"); - get(m_pAdministrateDatasources, "admin"); - get(m_pTable, "datatable"); - VclScrolledWindow *pScrollWindow = get("scrollwindow"); - pScrollWindow->setUserManagedScrolling(true); - m_pFieldScroller = &pScrollWindow->getVertScrollBar(); + m_xOKButton = m_xBuilder->weld_button("ok"); + m_xDatasource = m_xBuilder->weld_combo_box("datasource"); + m_xAdministrateDatasources = m_xBuilder->weld_button("admin"); + m_xTable = m_xBuilder->weld_combo_box("datatable"); + m_xFieldScroller = m_xBuilder->weld_scrolled_window("scrollwindow"); + m_xFieldScroller->set_user_managed_scrolling(); + m_xGrid = m_xBuilder->weld_widget("grid"); + m_xFieldScroller->set_size_request(-1, m_xGrid->get_preferred_size().Height()); for (sal_Int32 row=0; rowpFieldLabels[row * 2 + column] = get(OString("label") + OString::number(row * 2 + column)); + m_pImpl->pFieldLabels[row * 2 + column] = m_xBuilder->weld_label(OString("label") + OString::number(row * 2 + column)); // the listbox - m_pImpl->pFields[row * 2 + column] = get(OString("box") + OString::number(row * 2 + column)); - m_pImpl->pFields[row * 2 + column]->SetSelectHdl(LINK(this, AddressBookSourceDialog, OnFieldSelect)); - + m_pImpl->pFields[row * 2 + column] = m_xBuilder->weld_combo_box(OString("box") + OString::number(row * 2 + column)); + m_pImpl->pFields[row * 2 + column]->connect_changed(LINK(this, AddressBookSourceDialog, OnFieldSelect)); } } @@ -571,52 +567,51 @@ void AssignmentPersistentData::ImplCommit() m_pImpl->aFieldLabels.push_back( SvtResId( STR_FIELD_USER4)); long nLabelWidth = 0; - long nListBoxWidth = m_pImpl->pFields[0]->approximate_char_width() * 20; + long nListBoxWidth = m_pImpl->pFields[0]->get_approximate_digit_width() * 18; for (auto const& fieldLabel : m_pImpl->aFieldLabels) { - nLabelWidth = std::max(nLabelWidth, FixedText::getTextDimensions(m_pImpl->pFieldLabels[0], fieldLabel, 0x7FFFFFFF).Width()); + m_pImpl->pFieldLabels[0]->set_label(fieldLabel); + nLabelWidth = std::max(nLabelWidth, m_pImpl->pFieldLabels[0]->get_preferred_size().Width()); } for (sal_Int32 row=0; rowpFieldLabels[row * 2 + column]->set_width_request(nLabelWidth); - m_pImpl->pFields[row * 2 + column]->set_width_request(nListBoxWidth); + m_pImpl->pFieldLabels[row * 2 + column]->set_size_request(nLabelWidth, -1); + m_pImpl->pFields[row * 2 + column]->set_size_request(nListBoxWidth, -1); } } - // force a even number of known fields m_pImpl->bOddFieldNumber = (m_pImpl->aFieldLabels.size() % 2) != 0; if (m_pImpl->bOddFieldNumber) - m_pImpl->aFieldLabels.emplace_back( ); + m_pImpl->aFieldLabels.emplace_back(); // limit the scrollbar range accordingly sal_Int32 nOverallFieldPairs = m_pImpl->aFieldLabels.size() / 2; - m_pFieldScroller->SetRange( Range(0, nOverallFieldPairs - FIELD_PAIRS_VISIBLE) ); - m_pFieldScroller->SetLineSize(1); - m_pFieldScroller->SetPageSize(FIELD_PAIRS_VISIBLE); + m_xFieldScroller->vadjustment_configure(0, 0, nOverallFieldPairs, + 1, FIELD_PAIRS_VISIBLE - 1, FIELD_PAIRS_VISIBLE); // reset the current field assignments m_pImpl->aFieldAssignments.resize(m_pImpl->aFieldLabels.size()); - // (empty strings mean "no assignment") + // (empty strings mean "no assignment") // some knittings - m_pFieldScroller->SetScrollHdl(LINK(this, AddressBookSourceDialog, OnFieldScroll)); - m_pAdministrateDatasources->SetClickHdl(LINK(this, AddressBookSourceDialog, OnAdministrateDatasources)); - m_pDatasource->EnableAutocomplete(true); - m_pTable->EnableAutocomplete(true); - m_pTable->SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus)); - m_pDatasource->SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus)); - m_pTable->SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus)); - m_pDatasource->SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus)); - m_pTable->SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect)); - m_pDatasource->SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect)); - get("ok")->SetClickHdl(LINK(this, AddressBookSourceDialog, OnOkClicked)); + m_xFieldScroller->connect_vadjustment_changed(LINK(this, AddressBookSourceDialog, OnFieldScroll)); + m_xAdministrateDatasources->connect_clicked(LINK(this, AddressBookSourceDialog, OnAdministrateDatasources)); + m_xDatasource->set_entry_completion(true); + m_xTable->set_entry_completion(true); + m_xTable->connect_focus_in(LINK(this, AddressBookSourceDialog, OnComboGetFocus)); + m_xDatasource->connect_focus_in(LINK(this, AddressBookSourceDialog, OnComboGetFocus)); + m_xTable->connect_focus_out(LINK(this, AddressBookSourceDialog, OnComboLoseFocus)); + m_xDatasource->connect_focus_out(LINK(this, AddressBookSourceDialog, OnComboLoseFocus)); + m_xTable->connect_changed(LINK(this, AddressBookSourceDialog, OnComboSelect)); + m_xDatasource->connect_changed(LINK(this, AddressBookSourceDialog, OnComboSelect)); + m_xOKButton->connect_clicked(LINK(this, AddressBookSourceDialog, OnOkClicked)); // initialize the field controls resetFields(); - m_pFieldScroller->SetThumbPos(0); + m_xFieldScroller->vadjustment_set_value(0); m_pImpl->nFieldScrollPos = -1; implScrollFields(0, false, false); @@ -630,28 +625,17 @@ void AssignmentPersistentData::ImplCommit() for (sal_Int32 i = 0; iaLogicalFieldNames.push_back(sLogicalFieldNames.getToken(0, ';', nIdx)); - PostUserEvent(LINK(this, AddressBookSourceDialog, OnDelayedInitialize), nullptr, true); - // so the dialog will at least show up before we do the loading of the - // configuration data and the (maybe time consuming) analysis of the data source/table to select - - if ( m_pImpl->bWorkingPersistent ) - return; - - StyleSettings aSystemStyle = GetSettings().GetStyleSettings(); - const ::Color& rNewColor = aSystemStyle.GetDialogColor(); + Application::PostUserEvent(LINK(this, AddressBookSourceDialog, OnDelayedInitialize), nullptr, false); - m_pDatasource->SetReadOnly(); - m_pDatasource->SetBackground( Wallpaper( rNewColor ) ); - m_pDatasource->SetControlBackground( rNewColor ); + // so the dialog will at least show up before we do the loading of the + // configuration data and the (maybe time consuming) analysis of the data source/table to select - m_pTable->SetReadOnly(); - m_pTable->SetBackground( Wallpaper( rNewColor ) ); - m_pTable->SetControlBackground( rNewColor ); + if (m_pImpl->bWorkingPersistent) + return; - m_pAdministrateDatasources->Hide( ); + m_xAdministrateDatasources->hide(); } - void AddressBookSourceDialog::getFieldMapping(Sequence< AliasProgrammaticPair >& _rMapping) const { _rMapping.realloc( m_pImpl->aLogicalFieldNames.size() ); @@ -671,7 +655,6 @@ void AssignmentPersistentData::ImplCommit() _rMapping.realloc( pPair - _rMapping.getArray() ); } - void AddressBookSourceDialog::loadConfiguration() { OUString sName = m_pImpl->pConfigData->getDatasourceName(); @@ -682,8 +665,8 @@ void AssignmentPersistentData::ImplCommit() sName = aFileNotation.get(OFileNotation::N_SYSTEM); } - m_pDatasource->SetText(sName); - m_pTable->SetText(m_pImpl->pConfigData->getCommand()); + m_xDatasource->set_entry_text(sName); + m_xTable->set_entry_text(m_pImpl->pConfigData->getCommand()); // we ignore the CommandType: only tables are supported // the logical names for the fields @@ -698,23 +681,10 @@ void AssignmentPersistentData::ImplCommit() } } - AddressBookSourceDialog::~AddressBookSourceDialog() { - disposeOnce(); } - void AddressBookSourceDialog::dispose() - { - m_pImpl.reset(); - m_pDatasource.clear(); - m_pAdministrateDatasources.clear(); - m_pTable.clear(); - m_pFieldScroller.clear(); - ModalDialog::dispose(); - } - - void AddressBookSourceDialog::initializeDatasources() { if (!m_xDatabaseContext.is()) @@ -731,11 +701,11 @@ void AssignmentPersistentData::ImplCommit() if (!m_xDatabaseContext.is()) { const OUString sContextServiceName("com.sun.star.sdb.DatabaseContext"); - ShowServiceNotAvailableError(GetFrameWeld(), sContextServiceName, false); + ShowServiceNotAvailableError(m_xDialog.get(), sContextServiceName, false); return; } } - m_pDatasource->Clear(); + m_xDatasource->clear(); // fill the datasources listbox Sequence< OUString > aDatasourceNames; @@ -750,46 +720,44 @@ void AssignmentPersistentData::ImplCommit() const OUString* pDatasourceNames = aDatasourceNames.getConstArray(); const OUString* pEnd = pDatasourceNames + aDatasourceNames.getLength(); for (; pDatasourceNames < pEnd; ++pDatasourceNames) - m_pDatasource->InsertEntry(*pDatasourceNames); + m_xDatasource->append_text(*pDatasourceNames); } - - IMPL_LINK(AddressBookSourceDialog, OnFieldScroll, ScrollBar*, _pScrollBar, void) + IMPL_LINK(AddressBookSourceDialog, OnFieldScroll, weld::ScrolledWindow&, rScrollBar, void) { - implScrollFields( _pScrollBar->GetThumbPos(), true, true ); + implScrollFields(rScrollBar.vadjustment_get_value(), true, true); } - void AddressBookSourceDialog::resetTables() { if (!m_xDatabaseContext.is()) return; - WaitObject aWaitCursor(this); + weld::WaitObject aWaitCursor(m_xDialog.get()); // no matter what we do here, we handled the currently selected data source (no matter if successful or not) - m_pDatasource->SaveValue(); + m_xDatasource->save_value(); // create an interaction handler (may be needed for connecting) Reference< XInteractionHandler > xHandler; try { xHandler.set( - InteractionHandler::createWithParent(m_xORB, VCLUnoHelper::GetInterface(this)), + InteractionHandler::createWithParent(m_xORB, m_xDialog->GetXWindow()), UNO_QUERY_THROW ); } catch(const Exception&) { } if (!xHandler.is()) { const OUString sInteractionHandlerServiceName("com.sun.star.task.InteractionHandler"); - ShowServiceNotAvailableError(GetFrameWeld(), sInteractionHandlerServiceName, true); + ShowServiceNotAvailableError(m_xDialog.get(), sInteractionHandlerServiceName, true); return; } // the currently selected table - OUString sOldTable = m_pTable->GetText(); + OUString sOldTable = m_xTable->get_active_text(); - m_pTable->Clear(); + m_xTable->clear(); m_xCurrentDatasourceTables= nullptr; @@ -801,7 +769,7 @@ void AssignmentPersistentData::ImplCommit() Reference< XCompletedConnection > xDS; if ( m_pImpl->bWorkingPersistent ) { - OUString sSelectedDS = lcl_getSelectedDataSource(*m_pDatasource); + OUString sSelectedDS = lcl_getSelectedDataSource(*m_xDatasource); // get the data source the user has chosen and let it build a connection INetURLObject aURL( sSelectedDS ); @@ -852,7 +820,7 @@ void AssignmentPersistentData::ImplCommit() const OUString* pEnd = pTableNames + aTableNames.getLength(); for (;pTableNames != pEnd; ++pTableNames) { - m_pTable->InsertEntry(*pTableNames); + m_xTable->append_text(*pTableNames); if (*pTableNames == sOldTable) bKnowOldTable = true; } @@ -860,20 +828,19 @@ void AssignmentPersistentData::ImplCommit() // set the old table, if the new data source knows a table with this name, too. Else reset the tables edit field. if (!bKnowOldTable) sOldTable.clear(); - m_pTable->SetText(sOldTable); + m_xTable->set_entry_text(sOldTable); resetFields(); } - void AddressBookSourceDialog::resetFields() { - WaitObject aWaitCursor(this); + weld::WaitObject aWaitCursor(m_xDialog.get()); // no matter what we do here, we handled the currently selected table (no matter if successful or not) - m_pDatasource->SaveValue(); + m_xDatasource->save_value(); - OUString sSelectedTable = m_pTable->GetText(); + OUString sSelectedTable = m_xTable->get_active_text(); Sequence< OUString > aColumnNames; try { @@ -911,31 +878,31 @@ void AssignmentPersistentData::ImplCommit() OUString sSaveSelection; for (sal_Int32 i=0; i& pListbox = m_pImpl->pFields[i]; - sSaveSelection = pListbox->GetSelectedEntry(); + weld::ComboBox* pListbox = m_pImpl->pFields[i].get(); + sSaveSelection = pListbox->get_active_text(); - pListbox->Clear(); + pListbox->clear(); // the one entry for "no selection" - pListbox->InsertEntry(m_sNoFieldSelection, 0); + pListbox->append_text(m_sNoFieldSelection); // as it's entry data, set the index of the list box in our array - pListbox->SetEntryData(0, reinterpret_cast(i)); + pListbox->set_id(0, OUString::number(i)); // the field names for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames) - pListbox->InsertEntry(*pColumnNames); + pListbox->append_text(*pColumnNames); if (!aInitialSelection->isEmpty() && (aColumnNameSet.end() != aColumnNameSet.find(*aInitialSelection))) // we can select the entry as specified in our field assignment array - pListbox->SelectEntry(*aInitialSelection); + pListbox->set_active_text(*aInitialSelection); else // try to restore the selection if (aColumnNameSet.end() != aColumnNameSet.find(sSaveSelection)) // the old selection is a valid column name - pListbox->SelectEntry(sSaveSelection); + pListbox->set_active_text(sSaveSelection); else // select the entry - pListbox->SelectEntryPos(0); + pListbox->set_active(0); } // adjust m_pImpl->aFieldAssignments @@ -945,21 +912,20 @@ void AssignmentPersistentData::ImplCommit() fieldAssignment.clear(); } - - IMPL_LINK(AddressBookSourceDialog, OnFieldSelect, ListBox&, _rListbox, void) + IMPL_LINK(AddressBookSourceDialog, OnFieldSelect, weld::ComboBox&, rListbox, void) { // the index of the affected list box in our array - sal_IntPtr nListBoxIndex = reinterpret_cast(_rListbox.GetEntryData(0)); + sal_Int32 nListBoxIndex = rListbox.get_id(0).toInt32(); DBG_ASSERT(nListBoxIndex >= 0 && nListBoxIndex < FIELD_CONTROLS_VISIBLE, "AddressBookSourceDialog::OnFieldScroll: invalid list box entry!"); // update the array where we remember the field selections - if (0 == _rListbox.GetSelectedEntryPos()) + if (0 == rListbox.get_active()) // it's the "no field selection" entry m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex].clear(); else // it's a regular field entry - m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = _rListbox.GetSelectedEntry(); + m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = rListbox.get_active_text(); } @@ -992,20 +958,20 @@ void AssignmentPersistentData::ImplCommit() // loop for (sal_Int32 i=0; iHasChildPathFocus()) + if ((*pLeftListControl)->has_focus()) { nOldFocusRow = i; nOldFocusColumn = 0; } - else if ((*pRightListControl)->HasChildPathFocus()) + else if ((*pRightListControl)->has_focus()) { nOldFocusRow = i; nOldFocusColumn = 1; } // the new texts of the label controls - (*pLeftLabelControl)->SetText(*pLeftColumnLabel); - (*pRightLabelControl)->SetText(*pRightColumnLabel); + (*pLeftLabelControl)->set_label(*pLeftColumnLabel); + (*pRightLabelControl)->set_label(*pRightColumnLabel); // we may have to hide the controls in the right column, if we have no label text for it // (which means we have an odd number of fields, though we forced our internal arrays to @@ -1014,11 +980,11 @@ void AssignmentPersistentData::ImplCommit() // an invisible left hand side column, too. But right now, the left hand side controls are always // visible) bool bHideRightColumn = pRightColumnLabel->isEmpty(); - (*pRightLabelControl)->Show(!bHideRightColumn); - (*pRightListControl)->Show(!bHideRightColumn); + (*pRightLabelControl)->show(!bHideRightColumn); + (*pRightListControl)->show(!bHideRightColumn); // the new selections of the listboxes - implSelectField(*pLeftListControl, *pLeftAssignment); - implSelectField(*pRightListControl, *pRightAssignment); + implSelectField(pLeftListControl->get(), *pLeftAssignment); + implSelectField(pRightListControl->get(), *pRightAssignment); // the index of the last visible list box ++m_pImpl->nLastVisibleListIndex; // the left hand side box is always visible @@ -1050,27 +1016,25 @@ void AssignmentPersistentData::ImplCommit() nNewFocusRow = std::min(nNewFocusRow, sal_Int32(FIELD_PAIRS_VISIBLE - 1), ::std::less< sal_Int32 >()); nNewFocusRow = std::max(nNewFocusRow, sal_Int32(0), ::std::less< sal_Int32 >()); // set the new focus (in the same column) - m_pImpl->pFields[nNewFocusRow * 2 + nOldFocusColumn]->GrabFocus(); + m_pImpl->pFields[nNewFocusRow * 2 + nOldFocusColumn]->grab_focus(); } m_pImpl->nFieldScrollPos = _nPos; if (_bAdjustScrollbar) - m_pFieldScroller->SetThumbPos(m_pImpl->nFieldScrollPos); + m_xFieldScroller->vadjustment_set_value(m_pImpl->nFieldScrollPos); } - - void AddressBookSourceDialog::implSelectField(ListBox* _pBox, const OUString& _rText) + void AddressBookSourceDialog::implSelectField(weld::ComboBox* pBox, const OUString& rText) { - if (!_rText.isEmpty()) + if (!rText.isEmpty()) // a valid field name - _pBox->SelectEntry(_rText); + pBox->set_active_text(rText); else // no selection for this item - _pBox->SelectEntryPos(0); + pBox->set_active(0); } - IMPL_LINK_NOARG(AddressBookSourceDialog, OnDelayedInitialize, void*, void) { // load the initial data from the configuration @@ -1080,46 +1044,41 @@ void AssignmentPersistentData::ImplCommit() if ( !m_pImpl->bWorkingPersistent ) if ( m_pImpl->pFields[0] ) - m_pImpl->pFields[0]->GrabFocus(); + m_pImpl->pFields[0]->grab_focus(); } - - IMPL_LINK(AddressBookSourceDialog, OnComboSelect, ComboBox&, _rBox, void) + IMPL_LINK(AddressBookSourceDialog, OnComboSelect, weld::ComboBox&, rBox, void) { - if (&_rBox == m_pDatasource) + if (&rBox == m_xDatasource.get()) resetTables(); else resetFields(); } - - IMPL_STATIC_LINK( - AddressBookSourceDialog, OnComboGetFocus, Control&, _rBox, void) + IMPL_STATIC_LINK(AddressBookSourceDialog, OnComboGetFocus, weld::Widget&, rBox, void) { - static_cast(_rBox).SaveValue(); + dynamic_cast(rBox).save_value(); } - - IMPL_LINK(AddressBookSourceDialog, OnComboLoseFocus, Control&, rControl, void) + IMPL_LINK(AddressBookSourceDialog, OnComboLoseFocus, weld::Widget&, rControl, void) { - ComboBox* _pBox = static_cast(&rControl); - if ( _pBox->IsValueChangedFromSaved() ) + weld::ComboBox& rBox = dynamic_cast(rControl); + if (rBox.get_value_changed_from_saved()) { - if (_pBox == m_pDatasource) + if (&rBox == m_xDatasource.get()) resetTables(); else resetFields(); } } - - IMPL_LINK_NOARG(AddressBookSourceDialog, OnOkClicked, Button*, void) + IMPL_LINK_NOARG(AddressBookSourceDialog, OnOkClicked, weld::Button&, void) { - OUString sSelectedDS = lcl_getSelectedDataSource(*m_pDatasource); + OUString sSelectedDS = lcl_getSelectedDataSource(*m_xDatasource); if ( m_pImpl->bWorkingPersistent ) { m_pImpl->pConfigData->setDatasourceName(sSelectedDS); - m_pImpl->pConfigData->setCommand(m_pTable->GetText()); + m_pImpl->pConfigData->setCommand(m_xTable->get_active_text()); } // AddressBookSourceDialog::loadConfiguration: inconsistence between field names and field assignments! @@ -1133,23 +1092,21 @@ void AssignmentPersistentData::ImplCommit() ++aAssignment; } - - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } - - IMPL_LINK_NOARG(AddressBookSourceDialog, OnAdministrateDatasources, Button*, void) + IMPL_LINK_NOARG(AddressBookSourceDialog, OnAdministrateDatasources, weld::Button&, void) { // create the dialog object Reference< XExecutableDialog > xAdminDialog; try { - xAdminDialog = AddressBookSourcePilot::createWithParent( m_xORB, VCLUnoHelper::GetInterface(this) ); + xAdminDialog = AddressBookSourcePilot::createWithParent(m_xORB, m_xDialog->GetXWindow()); } catch(const Exception&) { } if (!xAdminDialog.is()) { - ShowServiceNotAvailableError(GetFrameWeld(), "com.sun.star.ui.dialogs.AddressBookSourcePilot", true); + ShowServiceNotAvailableError(m_xDialog.get(), "com.sun.star.ui.dialogs.AddressBookSourcePilot", true); return; } @@ -1170,7 +1127,7 @@ void AssignmentPersistentData::ImplCommit() OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); sName = aFileNotation.get(OFileNotation::N_SYSTEM); } - m_pDatasource->InsertEntry(sName); + m_xDatasource->append_text(sName); m_pImpl->pConfigData.reset( new AssignmentPersistentData ); loadConfiguration(); resetTables(); @@ -1189,53 +1146,6 @@ void AssignmentPersistentData::ImplCommit() // initializeDatasources(); } - bool AddressBookSourceDialog::PreNotify( NotifyEvent& _rNEvt ) - { - if (_rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) - { - const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent(); - sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); - bool bShift = pKeyEvent->GetKeyCode().IsShift(); - bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); - bool bAlt = pKeyEvent->GetKeyCode().IsMod2(); - - if (KEY_TAB == nCode) - { // somebody pressed the tab key - if (!bAlt && !bCtrl && !bShift) - { // it's really the only the key (no modifiers) - if (m_pImpl->pFields[m_pImpl->nLastVisibleListIndex]->HasChildPathFocus()) - // the last of our visible list boxes has the focus - if (m_pImpl->nFieldScrollPos < m_pFieldScroller->GetRangeMax()) - { // we can still scroll down - sal_Int32 nNextFocusList = m_pImpl->nLastVisibleListIndex + 1 - 2; - // -> scroll down - implScrollFields(m_pImpl->nFieldScrollPos + 1, false, true); - // give the left control in the "next" line the focus - m_pImpl->pFields[nNextFocusList]->GrabFocus(); - // return saying "have handled this" - return true; - } - } - else if (!bAlt && !bCtrl && bShift) - { // it's shift-tab - if (m_pImpl->pFields[0]->HasChildPathFocus()) - // our first list box has the focus - if (m_pImpl->nFieldScrollPos > 0) - { // we can still scroll up - // -> scroll up - implScrollFields(m_pImpl->nFieldScrollPos - 1, false, true); - // give the right control in the "previous" line the focus - m_pImpl->pFields[0 - 1 + 2]->GrabFocus(); - // return saying "have handled this" - return true; - } - } - } - } - - return ModalDialog::PreNotify(_rNEvt); - } - } // namespace svt -- cgit