From cf9f303ff9d8e2c9382d1e09e480f9801d254acd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 15 Oct 2018 15:35:46 +0100 Subject: weld DataSourceTabPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99b7c2ec397829c2f7ceb7ec18ae24195b9781e2 Reviewed-on: https://gerrit.libreoffice.org/61800 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- chart2/Library_chartcontroller.mk | 1 - .../source/controller/dialogs/dlg_DataSource.cxx | 2 +- chart2/source/controller/dialogs/tp_DataSource.cxx | 592 ++++++++++----------- chart2/source/controller/dialogs/tp_DataSource.hxx | 91 ++-- .../controller/dialogs/tp_DataSourceControls.cxx | 44 -- .../controller/dialogs/tp_DataSourceControls.hxx | 56 -- chart2/uiconfig/ui/tp_DataSource.ui | 119 ++++- extras/source/glade/libreoffice-catalog.xml.in | 3 - solenv/bin/native-code.py | 1 - vcl/source/app/salvtables.cxx | 11 +- 10 files changed, 434 insertions(+), 486 deletions(-) delete mode 100644 chart2/source/controller/dialogs/tp_DataSourceControls.cxx delete mode 100644 chart2/source/controller/dialogs/tp_DataSourceControls.hxx diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index ae8535e5fa3c..02c8bcb75774 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -125,7 +125,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/dialogs/tp_AxisPositions \ chart2/source/controller/dialogs/tp_ChartType \ chart2/source/controller/dialogs/tp_DataLabel \ - chart2/source/controller/dialogs/tp_DataSourceControls \ chart2/source/controller/dialogs/tp_DataSource \ chart2/source/controller/dialogs/tp_ErrorBars \ chart2/source/controller/dialogs/tp_LegendPosition \ diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx index 9a182ef19726..76b03043b1dd 100644 --- a/chart2/source/controller/dialogs/dlg_DataSource.cxx +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -138,7 +138,7 @@ DataSourceDialog::DataSourceDialog(vcl::Window * pParent, m_pRangeChooserTabPage = VclPtr::Create(TabPageParent(m_pTabControl), *(m_apDialogModel.get()), m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); - m_pDataSourceTabPage = VclPtr::Create(m_pTabControl, *(m_apDialogModel.get()), + m_pDataSourceTabPage = VclPtr::Create(TabPageParent(m_pTabControl), *(m_apDialogModel.get()), m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); m_pTabControl->InsertPage( TP_RANGECHOOSER, SchResId(STR_PAGE_DATA_RANGE) ); diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index 4919de66e71b..5b1ef9ff44e4 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -24,7 +24,6 @@ #include "ChartTypeTemplateProvider.hxx" #include #include -#include "tp_DataSourceControls.hxx" #include #include #include "DialogModel.hxx" @@ -55,84 +54,72 @@ namespace const OUString lcl_aLabelRole( "label" ); -OUString lcl_GetRoleLBEntry( - const OUString & rRole, const OUString & rRange ) +void lcl_UpdateCurrentRange(weld::TreeView& rOutListBox, const OUString & rRole, + const OUString& rRange) { - OUStringBuffer aEntry( rRole ); - aEntry.append( "\t" ); - aEntry.append( - ::chart::DialogModel::ConvertRoleFromInternalToUI( rRole ) ); - aEntry.append( "\t" ); - aEntry.append( rRange ); - - OUString sFoo = aEntry.makeStringAndClear(); - return sFoo; + int nEntry = rOutListBox.get_selected_index(); + if (nEntry != -1) + { + rOutListBox.set_text(nEntry, ::chart::DialogModel::ConvertRoleFromInternalToUI(rRole), 0); + rOutListBox.set_text(nEntry, rRange, 1); + ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry).toInt64()); + pEntry->m_sRole = rRole; + } } -void lcl_UpdateCurrentRange( - SvTabListBox & rOutListBox, - const OUString & rRole, const OUString & rRange ) +bool lcl_UpdateCurrentSeriesName(weld::TreeView& rOutListBox) { - SvTreeListEntry * pEntry = rOutListBox.FirstSelected(); - if( pEntry ) - rOutListBox.SetEntryText( lcl_GetRoleLBEntry( rRole, rRange ), pEntry ); -} + int nEntry = rOutListBox.get_selected_index(); + if (nEntry == -1) + return false; -bool lcl_UpdateCurrentSeriesName( - SvTreeListBox & rOutListBox ) -{ bool bResult = false; - ::chart::SeriesEntry * pEntry = dynamic_cast< ::chart::SeriesEntry * >( rOutListBox.FirstSelected()); - if( pEntry && - pEntry->m_xDataSeries.is() && - pEntry->m_xChartType.is()) + ::chart::SeriesEntry * pEntry = reinterpret_cast<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry).toInt64()); + if (pEntry->m_xDataSeries.is() && pEntry->m_xChartType.is()) { - OUString aLabel( ::chart::DataSeriesHelper::getDataSeriesLabel( - pEntry->m_xDataSeries, - pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel())); - if( !aLabel.isEmpty()) + OUString aLabel(::chart::DataSeriesHelper::getDataSeriesLabel( + pEntry->m_xDataSeries, + pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel())); + if (!aLabel.isEmpty()) { - rOutListBox.SetEntryText( pEntry, aLabel ); + rOutListBox.set_text(nEntry, aLabel); bResult = true; } } return bResult; } -OUString lcl_GetSelectedRole( const SvTabListBox & rRoleListBox, bool bUITranslated = false ) +OUString lcl_GetSelectedRole(const weld::TreeView& rRoleListBox, bool bUITranslated = false) { OUString aResult; - SvTreeListEntry * pEntry = rRoleListBox.FirstSelected(); - if( pEntry ) - aResult = SvTabListBox::GetEntryText( pEntry, bUITranslated ? 1 : 0 ); + int nEntry = rRoleListBox.get_selected_index(); + if (nEntry != -1) + { + if (bUITranslated) + return rRoleListBox.get_text(nEntry); + ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(rRoleListBox.get_id(nEntry).toInt64()); + return pEntry->m_sRole; + } return aResult; } -OUString lcl_GetSelectedRolesRange( const SvTabListBox & rRoleListBox ) +OUString lcl_GetSelectedRolesRange( const weld::TreeView& rRoleListBox ) { OUString aResult; - SvTreeListEntry * pEntry = rRoleListBox.FirstSelected(); - if( pEntry ) - aResult = SvTabListBox::GetEntryText( pEntry, 2 ); + int nEntry = rRoleListBox.get_selected_index(); + if (nEntry != -1) + aResult = rRoleListBox.get_text(nEntry, 1); return aResult; } -OUString lcl_GetSequenceNameForLabel( ::chart::SeriesEntry const * pEntry ) +OUString lcl_GetSequenceNameForLabel(const ::chart::SeriesEntry* pEntry) { - OUString aResult( "values-y" ); - if( pEntry && - pEntry->m_xChartType.is()) - { + OUString aResult("values-y"); + if (pEntry && pEntry->m_xChartType.is()) aResult = pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel(); - } return aResult; } -static long lcl_pRoleListBoxTabs[] = - { - 0, 0, 75 - }; - void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) { if( pDialog ) @@ -181,94 +168,81 @@ Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( namespace chart { -DataSourceTabPage::DataSourceTabPage( - vcl::Window * pParent, - DialogModel & rDialogModel, - ChartTypeTemplateProvider* pTemplateProvider, - Dialog * pParentDialog, - bool bHideDescription /* = false */ ) : - ::svt::OWizardPage( pParent - ,"tp_DataSource" - ,"modules/schart/ui/tp_DataSource.ui"), - m_pTemplateProvider( pTemplateProvider ), - m_rDialogModel( rDialogModel ), - - m_pCurrentRangeChoosingField( nullptr ), - m_bIsDirty( false ), - m_pParentDialog( pParentDialog ), - m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog )) -{ - - get(m_pFT_CAPTION ,"FT_CAPTION_FOR_WIZARD"); - get(m_pFT_SERIES ,"FT_SERIES"); - - get(m_pLB_SERIES ,"LB_SERIES"); - - get(m_pBTN_ADD ,"BTN_ADD"); - get(m_pBTN_REMOVE ,"BTN_REMOVE"); - get(m_pBTN_UP ,"BTN_UP"); - get(m_pBTN_DOWN ,"BTN_DOWN"); - get(m_pFT_ROLE ,"FT_ROLE"); - get(m_pLB_ROLE ,"LB_ROLE"); - get(m_pFT_RANGE ,"FT_RANGE"); - get(m_pEDT_RANGE ,"EDT_RANGE"); - get(m_pIMB_RANGE_MAIN ,"IMB_RANGE_MAIN"); - get(m_pFT_CATEGORIES ,"FT_CATEGORIES"); - get(m_pFT_DATALABELS ,"FT_DATALABELS"); - get(m_pEDT_CATEGORIES ,"EDT_CATEGORIES"); - get(m_pIMB_RANGE_CAT ,"IMB_RANGE_CAT"); - - m_pFT_CAPTION->Show(!bHideDescription); - - m_aFixedTextRange = m_pFT_RANGE->GetText(); +DataSourceTabPage::DataSourceTabPage(TabPageParent pParent, DialogModel & rDialogModel, + ChartTypeTemplateProvider* pTemplateProvider, + Dialog * pParentDialog, + bool bHideDescription /* = false */) + : ::svt::OWizardPage(pParent, "modules/schart/ui/tp_DataSource.ui", "tp_DataSource") + , m_pTemplateProvider(pTemplateProvider) + , m_rDialogModel(rDialogModel) + , m_pCurrentRangeChoosingField( nullptr ) + , m_bIsDirty( false ) + , m_pParentDialog( pParentDialog ) + , m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog )) + , m_xFT_CAPTION(m_xBuilder->weld_label("FT_CAPTION_FOR_WIZARD")) + , m_xFT_SERIES(m_xBuilder->weld_label("FT_SERIES")) + , m_xLB_SERIES(m_xBuilder->weld_tree_view("LB_SERIES")) + , m_xBTN_ADD(m_xBuilder->weld_button("BTN_ADD")) + , m_xBTN_REMOVE(m_xBuilder->weld_button("BTN_REMOVE")) + , m_xBTN_UP(m_xBuilder->weld_button("BTN_UP")) + , m_xBTN_DOWN(m_xBuilder->weld_button("BTN_DOWN")) + , m_xFT_ROLE(m_xBuilder->weld_label("FT_ROLE")) + , m_xLB_ROLE(m_xBuilder->weld_tree_view("LB_ROLE")) + , m_xFT_RANGE(m_xBuilder->weld_label("FT_RANGE")) + , m_xEDT_RANGE(m_xBuilder->weld_entry("EDT_RANGE")) + , m_xIMB_RANGE_MAIN(m_xBuilder->weld_button("IMB_RANGE_MAIN")) + , m_xFT_CATEGORIES(m_xBuilder->weld_label("FT_CATEGORIES")) + , m_xFT_DATALABELS(m_xBuilder->weld_label("FT_DATALABELS")) + , m_xEDT_CATEGORIES(m_xBuilder->weld_entry("EDT_CATEGORIES")) + , m_xIMB_RANGE_CAT(m_xBuilder->weld_button("IMB_RANGE_CAT")) +{ + m_xLB_SERIES->set_size_request(m_xLB_SERIES->get_approximate_digit_width() * 25, + m_xLB_SERIES->get_height_rows(10)); + m_xLB_ROLE->set_size_request(m_xLB_ROLE->get_approximate_digit_width() * 60, + m_xLB_ROLE->get_height_rows(5)); + m_xFT_CAPTION->show(!bHideDescription); + + m_aFixedTextRange = m_xFT_RANGE->get_label(); SetText( SchResId( STR_OBJECT_DATASERIES_PLURAL ) ); // set handlers - m_pLB_SERIES->SetSelectHdl( LINK( this, DataSourceTabPage, SeriesSelectionChangedHdl )); - - m_pLB_ROLE->SetSelectHdl( LINK( this, DataSourceTabPage, RoleSelectionChangedHdl )); - - m_pIMB_RANGE_MAIN->SetClickHdl( LINK( this, DataSourceTabPage, MainRangeButtonClickedHdl )); - m_pIMB_RANGE_CAT->SetClickHdl( LINK( this, DataSourceTabPage, CategoriesRangeButtonClickedHdl )); - - m_pBTN_ADD->SetClickHdl( LINK( this, DataSourceTabPage, AddButtonClickedHdl )); - m_pBTN_REMOVE->SetClickHdl( LINK( this, DataSourceTabPage, RemoveButtonClickedHdl )); - - m_pBTN_UP->SetClickHdl( LINK( this, DataSourceTabPage, UpButtonClickedHdl )); - m_pBTN_DOWN->SetClickHdl( LINK( this, DataSourceTabPage, DownButtonClickedHdl )); + m_xLB_SERIES->connect_changed(LINK(this, DataSourceTabPage, SeriesSelectionChangedHdl)); + m_xLB_ROLE->connect_changed(LINK(this, DataSourceTabPage, RoleSelectionChangedHdl)); - m_pEDT_RANGE->SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); - m_pEDT_CATEGORIES->SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); - m_pEDT_RANGE->SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); - m_pEDT_CATEGORIES->SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); + m_xIMB_RANGE_MAIN->connect_clicked(LINK(this, DataSourceTabPage, MainRangeButtonClickedHdl)); + m_xIMB_RANGE_CAT->connect_clicked(LINK(this, DataSourceTabPage, CategoriesRangeButtonClickedHdl)); - // #i75179# enable setting the background to a different color - m_pEDT_RANGE->SetForceControlBackground(true); - m_pEDT_CATEGORIES->SetForceControlBackground(true); + m_xBTN_ADD->connect_clicked(LINK(this, DataSourceTabPage, AddButtonClickedHdl)); + m_xBTN_REMOVE->connect_clicked(LINK(this, DataSourceTabPage, RemoveButtonClickedHdl)); - // set symbol font for arrows - // note: StarSymbol is substituted to OpenSymbol for OOo - vcl::Font aSymbolFont( m_pBTN_UP->GetFont()); - aSymbolFont.SetFamilyName( "StarSymbol" ); - m_pBTN_UP->SetControlFont( aSymbolFont ); - m_pBTN_DOWN->SetControlFont( aSymbolFont ); + m_xBTN_UP->connect_clicked(LINK(this, DataSourceTabPage, UpButtonClickedHdl)); + m_xBTN_DOWN->connect_clicked(LINK(this, DataSourceTabPage, DownButtonClickedHdl)); - // set button text - sal_Unicode const cBlackUpPointingTriangle( 0x25b2 ); - sal_Unicode const cBlackDownPointingTriangle( 0x25bc ); - m_pBTN_UP->SetText( OUString( cBlackUpPointingTriangle )); - m_pBTN_DOWN->SetText( OUString( cBlackDownPointingTriangle )); + m_xEDT_RANGE->connect_changed(LINK(this, DataSourceTabPage, RangeModifiedHdl)); + m_xEDT_CATEGORIES->connect_changed(LINK( this, DataSourceTabPage, RangeModifiedHdl)); // init controls - m_pLB_ROLE->SetTabs( SAL_N_ELEMENTS(lcl_pRoleListBoxTabs), lcl_pRoleListBoxTabs ); - m_pLB_ROLE->Show(); + std::vector aWidths; + aWidths.push_back(m_xLB_ROLE->get_approximate_digit_width() * 20); + m_xLB_ROLE->set_column_fixed_widths(aWidths); + m_xLB_ROLE->show(); updateControlsFromDialogModel(); // select first series - if( m_pLB_SERIES->First()) - m_pLB_SERIES->Select( m_pLB_SERIES->First()); - m_pLB_SERIES->GrabFocus(); + if (m_xLB_SERIES->n_children()) + m_xLB_SERIES->select(0); + m_xLB_SERIES->grab_focus(); +} + +void DataSourceTabPage::InsertRoleLBEntry(const OUString& rRole, const OUString& rRange) +{ + m_aEntries.emplace_back(new SeriesEntry); + SeriesEntry* pEntry = m_aEntries.back().get(); + pEntry->m_sRole = rRole; + m_xLB_ROLE->append(OUString::number(reinterpret_cast(pEntry)), + ::chart::DialogModel::ConvertRoleFromInternalToUI(rRole)); + m_xLB_ROLE->set_text(m_xLB_ROLE->n_children() - 1, rRange, 1); } DataSourceTabPage::~DataSourceTabPage() @@ -278,23 +252,6 @@ DataSourceTabPage::~DataSourceTabPage() void DataSourceTabPage::dispose() { - m_pFT_CAPTION.clear(); - m_pFT_SERIES.clear(); - m_pLB_SERIES.clear(); - m_pBTN_ADD.clear(); - m_pBTN_REMOVE.clear(); - m_pBTN_UP.clear(); - m_pBTN_DOWN.clear(); - m_pFT_ROLE.clear(); - m_pLB_ROLE.clear(); - m_pFT_RANGE.clear(); - m_pEDT_RANGE.clear(); - m_pIMB_RANGE_MAIN.clear(); - m_pFT_CATEGORIES.clear(); - m_pFT_DATALABELS.clear(); - m_pEDT_CATEGORIES.clear(); - m_pIMB_RANGE_CAT.clear(); - m_pCurrentRangeChoosingField.clear(); m_pParentDialog.clear(); ::svt::OWizardPage::dispose(); } @@ -332,23 +289,12 @@ bool DataSourceTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReas return false; } -bool DataSourceTabPage::isRangeFieldContentValid( Edit & rEdit ) +bool DataSourceTabPage::isRangeFieldContentValid(weld::Entry& rEdit ) { - OUString aRange( rEdit.GetText()); - bool bIsValid = ( aRange.isEmpty() ) || - m_rDialogModel.getRangeSelectionHelper()->verifyCellRange( aRange ); - - if( bIsValid ) - { - rEdit.SetControlForeground(); - rEdit.SetControlBackground(); - } - else - { - rEdit.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR ); - rEdit.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR ); - } - + OUString aRange(rEdit.get_text()); + bool bIsValid = aRange.isEmpty() || + m_rDialogModel.getRangeSelectionHelper()->verifyCellRange(aRange); + rEdit.set_error(!bIsValid); return bIsValid; } @@ -356,12 +302,12 @@ bool DataSourceTabPage::isValid() { bool bRoleRangeValid = true; bool bCategoriesRangeValid = true; - bool bHasSelectedEntry = (m_pLB_SERIES->FirstSelected() != nullptr); + bool bHasSelectedEntry = (m_xLB_SERIES->get_selected_index() != -1); - if( bHasSelectedEntry ) - bRoleRangeValid = isRangeFieldContentValid( *m_pEDT_RANGE ); - if( m_pEDT_CATEGORIES->IsEnabled() ) - bCategoriesRangeValid = isRangeFieldContentValid( *m_pEDT_CATEGORIES ); + if (bHasSelectedEntry) + bRoleRangeValid = isRangeFieldContentValid(*m_xEDT_RANGE); + if (m_xEDT_CATEGORIES->get_sensitive()) + bCategoriesRangeValid = isRangeFieldContentValid( *m_xEDT_CATEGORIES ); bool bValid = ( bRoleRangeValid && bCategoriesRangeValid ); if( m_pTabPageNotifiable ) @@ -384,35 +330,40 @@ void DataSourceTabPage::updateControlsFromDialogModel() { // series fillSeriesListBox(); - SeriesSelectionChangedHdl( nullptr ); + SeriesSelectionChangedHdl(*m_xLB_SERIES); // categories - m_pEDT_CATEGORIES->SetText( m_rDialogModel.getCategoriesRange() ); + m_xEDT_CATEGORIES->set_text(m_rDialogModel.getCategoriesRange()); updateControlState(); } void DataSourceTabPage::fillSeriesListBox() { - m_pLB_SERIES->SetUpdateMode( false ); + m_xLB_SERIES->freeze(); Reference< XDataSeries > xSelected; - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); - if( pEntry ) - xSelected.set( pEntry->m_xDataSeries ); + SeriesEntry* pEntry = nullptr; + int nEntry = m_xLB_SERIES->get_selected_index(); + if (nEntry != -1) + { + pEntry = reinterpret_cast(m_xLB_SERIES->get_id(nEntry).toInt64()); + xSelected.set(pEntry->m_xDataSeries); + } bool bHasSelectedEntry = (pEntry != nullptr); - SvTreeListEntry * pSelectedEntry = nullptr; - m_pLB_SERIES->Clear(); + int nSelectedEntry = -1; + m_xLB_SERIES->clear(); std::vector< DialogModel::tSeriesWithChartTypeByName > aSeries( m_rDialogModel.getAllDataSeriesWithLabel() ); sal_Int32 nUnnamedSeriesIndex = 1; + nEntry = 0; for (auto const& series : aSeries) { OUString aLabel(series.first); - if( aLabel.isEmpty()) + if (aLabel.isEmpty()) { if( nUnnamedSeriesIndex > 1 ) { @@ -431,34 +382,33 @@ void DataSourceTabPage::fillSeriesListBox() ++nUnnamedSeriesIndex; } - pEntry = dynamic_cast< SeriesEntry * >( - m_pLB_SERIES->InsertEntry( aLabel )); - if( pEntry ) - { - pEntry->m_xDataSeries.set(series.second.first); - pEntry->m_xChartType.set(series.second.second); - if( bHasSelectedEntry && (series.second.first == xSelected)) - pSelectedEntry = pEntry; - } + + m_aEntries.emplace_back(new SeriesEntry); + pEntry = m_aEntries.back().get(); + pEntry->m_xDataSeries.set(series.second.first); + pEntry->m_xChartType.set(series.second.second); + m_xLB_SERIES->append(OUString::number(reinterpret_cast(pEntry)), aLabel); + if (bHasSelectedEntry && series.second.first == xSelected) + nSelectedEntry = nEntry; + ++nEntry; } - if( bHasSelectedEntry && pSelectedEntry ) - m_pLB_SERIES->Select( pSelectedEntry ); + m_xLB_SERIES->thaw(); - m_pLB_SERIES->SetUpdateMode( true ); + if (bHasSelectedEntry && nSelectedEntry != -1) + m_xLB_SERIES->select(nSelectedEntry); } void DataSourceTabPage::fillRoleListBox() { - SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); + int nSeriesEntry = m_xLB_SERIES->get_selected_index(); + SeriesEntry* pSeriesEntry = nullptr; + if (nSeriesEntry != -1) + pSeriesEntry = reinterpret_cast(m_xLB_SERIES->get_id(nSeriesEntry).toInt64()); bool bHasSelectedEntry = (pSeriesEntry != nullptr); - SvTreeListEntry * pRoleEntry = m_pLB_ROLE->FirstSelected(); - sal_uLong nRoleIndex = SAL_MAX_UINT32; - if( pRoleEntry ) - nRoleIndex = m_pLB_ROLE->GetModel()->GetAbsPos( pRoleEntry ); - - if( bHasSelectedEntry ) + int nRoleIndex = m_xLB_ROLE->get_selected_index(); + if (bHasSelectedEntry) { DialogModel::tRolesWithRanges aRoles( DialogModel::getRolesWithRanges( @@ -467,117 +417,116 @@ void DataSourceTabPage::fillRoleListBox() pSeriesEntry->m_xChartType )); // fill role list - m_pLB_ROLE->SetUpdateMode( false ); - m_pLB_ROLE->Clear(); - m_pLB_ROLE->RemoveSelection(); + m_xLB_ROLE->freeze(); + m_xLB_ROLE->clear(); for (auto const& elemRole : aRoles) { - m_pLB_ROLE->InsertEntry( lcl_GetRoleLBEntry(elemRole.first, elemRole.second)); + InsertRoleLBEntry(elemRole.first, elemRole.second); } + m_xLB_ROLE->thaw(); + // series may contain no roles, check listbox size before selecting entries - if( m_pLB_ROLE->GetEntryCount() > 0 ) + if (m_xLB_ROLE->n_children() > 0) { - if( nRoleIndex >= m_pLB_ROLE->GetEntryCount()) + if (nRoleIndex == -1 || nRoleIndex >= m_xLB_ROLE->n_children()) nRoleIndex = 0; - m_pLB_ROLE->Select( m_pLB_ROLE->GetEntry( nRoleIndex )); + m_xLB_ROLE->select(nRoleIndex); } - - m_pLB_ROLE->SetUpdateMode( true ); } } void DataSourceTabPage::updateControlState() { - SvTreeListEntry * pSeriesEntry = m_pLB_SERIES->FirstSelected(); - bool bHasSelectedSeries = (pSeriesEntry != nullptr); + int nSeriesEntry = m_xLB_SERIES->get_selected_index(); + bool bHasSelectedSeries = nSeriesEntry != -1; bool bHasValidRole = false; bool bHasRangeChooser = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); if( bHasSelectedSeries ) { - SvTreeListEntry * pRoleEntry = m_pLB_ROLE->FirstSelected(); - bHasValidRole = (pRoleEntry != nullptr); + int nRoleEntry = m_xLB_ROLE->get_selected_index(); + bHasValidRole = nRoleEntry != -1; } - m_pBTN_ADD->Enable(); - m_pBTN_REMOVE->Enable( bHasSelectedSeries ); + m_xBTN_ADD->set_sensitive(true); + m_xBTN_REMOVE->set_sensitive(bHasSelectedSeries); - m_pBTN_UP->Enable( bHasSelectedSeries && (pSeriesEntry != m_pLB_SERIES->First())); - m_pBTN_DOWN->Enable( bHasSelectedSeries && (pSeriesEntry != m_pLB_SERIES->Last())); + m_xBTN_UP->set_sensitive(bHasSelectedSeries && (nSeriesEntry != 0)); + m_xBTN_DOWN->set_sensitive(bHasSelectedSeries && (nSeriesEntry != m_xLB_SERIES->n_children() - 1)); bool bHasCategories = m_rDialogModel.isCategoryDiagram(); - m_pFT_DATALABELS->Show(!bHasCategories); - m_pFT_CATEGORIES->Show( bHasCategories); + m_xFT_DATALABELS->show(!bHasCategories); + m_xFT_CATEGORIES->show( bHasCategories); bool bShowIB = bHasRangeChooser; - m_pIMB_RANGE_CAT->Show(bShowIB); + m_xIMB_RANGE_CAT->show(bShowIB); - m_pFT_SERIES->Enable(); - m_pLB_SERIES->Enable(); + m_xFT_SERIES->set_sensitive(true); + m_xLB_SERIES->set_sensitive(true); - m_pFT_ROLE->Enable( bHasSelectedSeries ); - m_pLB_ROLE->Enable( bHasSelectedSeries ); + m_xFT_ROLE->set_sensitive(bHasSelectedSeries); + m_xLB_ROLE->set_sensitive(bHasSelectedSeries); - m_pFT_RANGE->Enable( bHasValidRole ); - m_pEDT_RANGE->Enable( bHasValidRole ); + m_xFT_RANGE->set_sensitive(bHasValidRole); + m_xEDT_RANGE->set_sensitive(bHasValidRole); - m_pIMB_RANGE_MAIN->Show(bShowIB); + m_xIMB_RANGE_MAIN->show(bShowIB); isValid(); } -IMPL_LINK_NOARG(DataSourceTabPage, SeriesSelectionChangedHdl, SvTreeListBox*, void) +IMPL_LINK_NOARG(DataSourceTabPage, SeriesSelectionChangedHdl, weld::TreeView&, void) { m_rDialogModel.startControllerLockTimer(); - if( m_pLB_SERIES->FirstSelected()) + if (m_xLB_SERIES->get_selected_index() != -1) { fillRoleListBox(); - RoleSelectionChangedHdl( nullptr ); + RoleSelectionChangedHdl(*m_xLB_ROLE); } updateControlState(); } -IMPL_LINK_NOARG(DataSourceTabPage, RoleSelectionChangedHdl, SvTreeListBox*, void) +IMPL_LINK_NOARG(DataSourceTabPage, RoleSelectionChangedHdl, weld::TreeView&, void) { m_rDialogModel.startControllerLockTimer(); - SvTreeListEntry * pEntry = m_pLB_ROLE->FirstSelected(); - if( pEntry ) + int nEntry = m_xLB_ROLE->get_selected_index(); + if (nEntry != -1) { - OUString aSelectedRoleUI = lcl_GetSelectedRole( *m_pLB_ROLE, true ); - OUString aSelectedRange = lcl_GetSelectedRolesRange( *m_pLB_ROLE ); + OUString aSelectedRoleUI = lcl_GetSelectedRole( *m_xLB_ROLE, true ); + OUString aSelectedRange = lcl_GetSelectedRolesRange( *m_xLB_ROLE ); // replace role in fixed text label const OUString aReplacementStr( "%VALUETYPE" ); sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); if( nIndex != -1 ) { - m_pFT_RANGE->SetText( + m_xFT_RANGE->set_label( m_aFixedTextRange.replaceAt( nIndex, aReplacementStr.getLength(), aSelectedRoleUI )); } - m_pEDT_RANGE->SetText( aSelectedRange ); + m_xEDT_RANGE->set_text(aSelectedRange); isValid(); } } -IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, weld::Button&, void) { OSL_ASSERT( m_pCurrentRangeChoosingField == nullptr ); - m_pCurrentRangeChoosingField = m_pEDT_RANGE; - if( !m_pEDT_RANGE->GetText().isEmpty() && - ! updateModelFromControl( m_pCurrentRangeChoosingField )) + m_pCurrentRangeChoosingField = m_xEDT_RANGE.get(); + if (!m_xEDT_RANGE->get_text().isEmpty() && + !updateModelFromControl( m_pCurrentRangeChoosingField)) return; - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); - bool bHasSelectedEntry = (pEntry != nullptr); + int nEntry = m_xLB_SERIES->get_selected_index(); + bool bHasSelectedEntry = (nEntry != -1); - OUString aSelectedRolesRange = lcl_GetSelectedRolesRange( *m_pLB_ROLE ); + OUString aSelectedRolesRange = lcl_GetSelectedRolesRange(*m_xLB_ROLE); - if( bHasSelectedEntry && (m_pLB_ROLE->FirstSelected() != nullptr)) + if (bHasSelectedEntry && (m_xLB_ROLE->get_selected_index() != -1)) { OUString aUIStr(SchResId(STR_DATA_SELECT_RANGE_FOR_SERIES)); @@ -587,15 +536,15 @@ IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, Button*, void) if( nIndex != -1 ) { aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), - lcl_GetSelectedRole( *m_pLB_ROLE, true )); + lcl_GetSelectedRole( *m_xLB_ROLE, true )); } // replace series name aReplacement = "%SERIESNAME"; nIndex = aUIStr.indexOf( aReplacement ); if( nIndex != -1 ) { - aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), - m_pLB_SERIES->GetEntryText( pEntry )); + aUIStr = aUIStr.replaceAt(nIndex, aReplacement.getLength(), + m_xLB_SERIES->get_text(nEntry)); } lcl_enableRangeChoosing( true, m_pParentDialog ); @@ -605,33 +554,34 @@ IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, Button*, void) m_pCurrentRangeChoosingField = nullptr; } -IMPL_LINK_NOARG(DataSourceTabPage, CategoriesRangeButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, CategoriesRangeButtonClickedHdl, weld::Button&, void) { OSL_ASSERT( m_pCurrentRangeChoosingField == nullptr ); - m_pCurrentRangeChoosingField = m_pEDT_CATEGORIES; - if( !m_pEDT_CATEGORIES->GetText().isEmpty() && + m_pCurrentRangeChoosingField = m_xEDT_CATEGORIES.get(); + if( !m_xEDT_CATEGORIES->get_text().isEmpty() && ! updateModelFromControl( m_pCurrentRangeChoosingField )) return; - OUString aStr( SchResId( m_pFT_CATEGORIES->IsVisible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS )); - lcl_enableRangeChoosing( true, m_pParentDialog ); + OUString aStr(SchResId(m_xFT_CATEGORIES->get_visible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS)); + lcl_enableRangeChoosing(true, m_pParentDialog); m_rDialogModel.getRangeSelectionHelper()->chooseRange( m_rDialogModel.getCategoriesRange(), aStr, *this ); } -IMPL_LINK_NOARG(DataSourceTabPage, AddButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, AddButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); + int nEntry = m_xLB_SERIES->get_selected_index(); Reference< XDataSeries > xSeriesToInsertAfter; Reference< XChartType > xChartTypeForNewSeries; if( m_pTemplateProvider ) m_rDialogModel.setTemplate( m_pTemplateProvider->getCurrentTemplate()); - if( pEntry ) + if (nEntry != -1) { - xSeriesToInsertAfter.set( pEntry->m_xDataSeries ); - xChartTypeForNewSeries.set( pEntry->m_xChartType ); + ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); + xSeriesToInsertAfter.set(pEntry->m_xDataSeries); + xChartTypeForNewSeries.set(pEntry->m_xChartType); } else { @@ -646,99 +596,107 @@ IMPL_LINK_NOARG(DataSourceTabPage, AddButtonClickedHdl, Button*, void) setDirty(); fillSeriesListBox(); - // note the box was cleared and refilled, so pEntry is invalid now - SvTreeListEntry * pSelEntry = m_pLB_SERIES->FirstSelected(); - if( pSelEntry ) + // note the box was cleared and refilled, so nEntry is invalid now + + int nSelEntry = m_xLB_SERIES->get_selected_index(); + if (nSelEntry != -1) { - SvTreeListEntry * pNextEntry = m_pLB_SERIES->Next( pSelEntry ); - if( pNextEntry ) - m_pLB_SERIES->Select( pNextEntry ); + ++nSelEntry; + if (nSelEntry < m_xLB_SERIES->n_children()) + m_xLB_SERIES->select(nSelEntry); } - SeriesSelectionChangedHdl( nullptr ); + SeriesSelectionChangedHdl(*m_xLB_SERIES); } -IMPL_LINK_NOARG(DataSourceTabPage, RemoveButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, RemoveButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); - if( pEntry ) + int nEntry = m_xLB_SERIES->get_selected_index(); + if (nEntry != -1) { + SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); Reference< XDataSeries > xNewSelSeries; - SeriesEntry * pNewSelEntry = dynamic_cast< SeriesEntry * >(m_pLB_SERIES->Next( pEntry )); - if( pNewSelEntry ) - xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); - else - { - pNewSelEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->Prev( pEntry )); - if( pNewSelEntry ) - xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); - } + SeriesEntry * pNewSelEntry = nullptr; + if (nEntry + 1 < m_xLB_SERIES->n_children()) + pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry + 1).toInt64()); + else if (nEntry > 0) + pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry - 1).toInt64()); + if (pNewSelEntry) + xNewSelSeries.set(pNewSelEntry->m_xDataSeries); m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); setDirty(); - m_pLB_SERIES->RemoveSelection(); + m_xLB_SERIES->remove(nEntry); fillSeriesListBox(); // select previous or next series - //@improve: see methods GetModel()->GetAbsPos()/GetEntry() for absolute list positions - if( xNewSelSeries.is()) + if (xNewSelSeries.is()) { - pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->First()); - while( pEntry ) + for (int i = 0; i < m_xLB_SERIES->n_children(); ++i) { - if( pEntry->m_xDataSeries == xNewSelSeries ) + pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(i).toInt64()); + if (pEntry->m_xDataSeries == xNewSelSeries) { - m_pLB_SERIES->Select( pEntry ); + m_xLB_SERIES->select(i); break; } - pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->Next( pEntry )); } } - SeriesSelectionChangedHdl( nullptr ); + SeriesSelectionChangedHdl(*m_xLB_SERIES); } } -IMPL_LINK_NOARG(DataSourceTabPage, UpButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, UpButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); + + int nEntry = m_xLB_SERIES->get_selected_index(); + SeriesEntry* pEntry = nullptr; + if (nEntry != -1) + pEntry = reinterpret_cast(m_xLB_SERIES->get_id(nEntry).toInt64()); + bool bHasSelectedEntry = (pEntry != nullptr); - if( bHasSelectedEntry ) + if (bHasSelectedEntry) { m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_UP ); setDirty(); fillSeriesListBox(); - SeriesSelectionChangedHdl(nullptr); + SeriesSelectionChangedHdl(*m_xLB_SERIES); } } -IMPL_LINK_NOARG(DataSourceTabPage, DownButtonClickedHdl, Button*, void) +IMPL_LINK_NOARG(DataSourceTabPage, DownButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); - SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); + + int nEntry = m_xLB_SERIES->get_selected_index(); + SeriesEntry* pEntry = nullptr; + if (nEntry != -1) + pEntry = reinterpret_cast(m_xLB_SERIES->get_id(nEntry).toInt64()); + bool bHasSelectedEntry = (pEntry != nullptr); - if( bHasSelectedEntry ) + if (bHasSelectedEntry) { m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_DOWN ); setDirty(); fillSeriesListBox(); - SeriesSelectionChangedHdl(nullptr); + SeriesSelectionChangedHdl(*m_xLB_SERIES); } } -IMPL_LINK( DataSourceTabPage, RangeModifiedHdl, Edit&, rEdit, void ) +IMPL_LINK(DataSourceTabPage, RangeModifiedHdl, weld::Entry&, rEdit, void) { // note: isValid sets the color of the edit field if( isRangeFieldContentValid( rEdit )) { setDirty(); updateModelFromControl( &rEdit ); - if( &rEdit == m_pEDT_RANGE ) + if (&rEdit == m_xEDT_RANGE.get()) { - if( ! lcl_UpdateCurrentSeriesName( *m_pLB_SERIES )) + if( ! lcl_UpdateCurrentSeriesName( *m_xLB_SERIES )) fillSeriesListBox(); } } @@ -747,23 +705,6 @@ IMPL_LINK( DataSourceTabPage, RangeModifiedHdl, Edit&, rEdit, void ) isValid(); } -IMPL_LINK( DataSourceTabPage, RangeUpdateDataHdl, Edit&, rEdit, void ) -{ - // note: isValid sets the color of the edit field - if( isRangeFieldContentValid( rEdit )) - { - setDirty(); - updateModelFromControl( &rEdit ); - if( &rEdit == m_pEDT_RANGE ) - { - if( ! lcl_UpdateCurrentSeriesName( *m_pLB_SERIES )) - fillSeriesListBox(); - } - } - // enable/disable OK button - isValid(); -} - void DataSourceTabPage::listeningFinished( const OUString & rNewRange ) { @@ -780,29 +721,29 @@ void DataSourceTabPage::listeningFinished( GrabFocus(); if( m_pCurrentRangeChoosingField ) { - m_pCurrentRangeChoosingField->SetText( aRange ); - m_pCurrentRangeChoosingField->GrabFocus(); + m_pCurrentRangeChoosingField->set_text(aRange); + m_pCurrentRangeChoosingField->grab_focus(); } - if( m_pCurrentRangeChoosingField == m_pEDT_RANGE ) + if (m_pCurrentRangeChoosingField == m_xEDT_RANGE.get()) { - m_pEDT_RANGE->SetText( aRange ); + m_xEDT_RANGE->set_text(aRange); setDirty(); } - else if( m_pCurrentRangeChoosingField == m_pEDT_CATEGORIES ) + else if (m_pCurrentRangeChoosingField == m_xEDT_CATEGORIES.get()) { - m_pEDT_CATEGORIES->SetText( aRange ); + m_xEDT_CATEGORIES->set_text(aRange); setDirty(); } - updateModelFromControl( m_pCurrentRangeChoosingField ); - if( ! lcl_UpdateCurrentSeriesName( *m_pLB_SERIES )) + updateModelFromControl(m_pCurrentRangeChoosingField); + if (!lcl_UpdateCurrentSeriesName(*m_xLB_SERIES)) fillSeriesListBox(); m_pCurrentRangeChoosingField = nullptr; updateControlState(); - lcl_enableRangeChoosing( false, m_pParentDialog ); + lcl_enableRangeChoosing(false, m_pParentDialog); } void DataSourceTabPage::disposingRangeSelection() @@ -810,9 +751,9 @@ void DataSourceTabPage::disposingRangeSelection() m_rDialogModel.getRangeSelectionHelper()->stopRangeListening( false ); } -bool DataSourceTabPage::updateModelFromControl( Edit * pField ) +bool DataSourceTabPage::updateModelFromControl(weld::Entry* pField) { - if( !m_bIsDirty ) + if (!m_bIsDirty) return true; ControllerLockGuardUNO aLockedControllers( m_rDialogModel.getChartModel() ); @@ -822,13 +763,13 @@ bool DataSourceTabPage::updateModelFromControl( Edit * pField ) bool bAll = (pField == nullptr); Reference< data::XDataProvider > xDataProvider( m_rDialogModel.getDataProvider()); - if( bAll || (pField == m_pEDT_CATEGORIES) ) + if (bAll || (pField == m_xEDT_CATEGORIES.get())) { Reference< data::XLabeledDataSequence > xLabeledSeq( m_rDialogModel.getCategories() ); if( xDataProvider.is()) { - OUString aRange( m_pEDT_CATEGORIES->GetText()); - if( !aRange.isEmpty()) + OUString aRange(m_xEDT_CATEGORIES->get_text()); + if (!aRange.isEmpty()) { // create or change categories if( !xLabeledSeq.is()) @@ -855,17 +796,20 @@ bool DataSourceTabPage::updateModelFromControl( Edit * pField ) } } - SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_pLB_SERIES->FirstSelected()); + int nSeriesEntry = m_xLB_SERIES->get_selected_index(); + SeriesEntry* pSeriesEntry = nullptr; + if (nSeriesEntry != -1) + pSeriesEntry = reinterpret_cast(m_xLB_SERIES->get_id(nSeriesEntry).toInt64()); bool bHasSelectedEntry = (pSeriesEntry != nullptr); if( bHasSelectedEntry ) { - if( bAll || (pField == m_pEDT_RANGE) ) + if( bAll || (pField == m_xEDT_RANGE.get()) ) { try { - OUString aSelectedRole = lcl_GetSelectedRole( *m_pLB_ROLE ); - OUString aRange( m_pEDT_RANGE->GetText()); + OUString aSelectedRole = lcl_GetSelectedRole( *m_xLB_ROLE ); + OUString aRange(m_xEDT_RANGE->get_text()); OUString aSequenceRole( aSelectedRole ); bool bIsLabel = (aSequenceRole == lcl_aLabelRole ); OUString aSequenceNameForLabel( lcl_GetSequenceNameForLabel( pSeriesEntry )); @@ -962,7 +906,7 @@ bool DataSourceTabPage::updateModelFromControl( Edit * pField ) } } - lcl_UpdateCurrentRange( *m_pLB_ROLE, aSelectedRole, aRange ); + lcl_UpdateCurrentRange( *m_xLB_ROLE, aSelectedRole, aRange ); } catch( const uno::Exception & ) { diff --git a/chart2/source/controller/dialogs/tp_DataSource.hxx b/chart2/source/controller/dialogs/tp_DataSource.hxx index 5798894621bd..6357a42b437b 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.hxx +++ b/chart2/source/controller/dialogs/tp_DataSource.hxx @@ -27,6 +27,9 @@ #include +namespace com { namespace sun { namespace star { namespace chart2 { class XChartType; } } } } +namespace com { namespace sun { namespace star { namespace chart2 { class XDataSeries; } } } } + namespace chart { class TabPageNotifiable; } namespace chart @@ -35,25 +38,36 @@ namespace chart class ChartTypeTemplateProvider; class DialogModel; +class SeriesEntry +{ +public: + OUString m_sRole; + + /// the corresponding data series + css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; + + /// the chart type that contains the series (via XDataSeriesContainer) + css::uno::Reference< css::chart2::XChartType > m_xChartType; +}; + class DataSourceTabPage final : public ::svt::OWizardPage, public RangeSelectionListenerParent { public: - explicit DataSourceTabPage( - vcl::Window * pParent, - DialogModel & rDialogModel, - ChartTypeTemplateProvider* pTemplateProvider, - Dialog * pParentDialog, - bool bHideDescription = false ); + explicit DataSourceTabPage(TabPageParent pParent, + DialogModel & rDialogModel, + ChartTypeTemplateProvider* pTemplateProvider, + Dialog * pParentDialog, + bool bHideDescription = false); virtual ~DataSourceTabPage() override; - virtual void dispose() override; void commitPage(); private: // OWizardPage virtual void ActivatePage() override; + virtual void dispose() override; virtual bool commitPage( ::svt::WizardTypes::CommitPageReason eReason ) override; //TabPage @@ -61,21 +75,22 @@ private: virtual void initializePage() override; - DECL_LINK( SeriesSelectionChangedHdl, SvTreeListBox*, void ); - DECL_LINK( RoleSelectionChangedHdl, SvTreeListBox*, void ); - DECL_LINK( MainRangeButtonClickedHdl, Button*, void ); - DECL_LINK( CategoriesRangeButtonClickedHdl, Button*, void ); - DECL_LINK( AddButtonClickedHdl, Button*, void ); - DECL_LINK( RemoveButtonClickedHdl, Button*, void ); - DECL_LINK( RangeModifiedHdl, Edit&, void ); - DECL_LINK( RangeUpdateDataHdl, Edit&, void ); - DECL_LINK( UpButtonClickedHdl, Button*, void ); - DECL_LINK( DownButtonClickedHdl, Button*, void ); + DECL_LINK( SeriesSelectionChangedHdl, weld::TreeView&, void ); + DECL_LINK( RoleSelectionChangedHdl, weld::TreeView&, void ); + DECL_LINK( MainRangeButtonClickedHdl, weld::Button&, void ); + DECL_LINK( CategoriesRangeButtonClickedHdl, weld::Button&, void ); + DECL_LINK( AddButtonClickedHdl, weld::Button&, void ); + DECL_LINK( RemoveButtonClickedHdl, weld::Button&, void ); + DECL_LINK( RangeModifiedHdl, weld::Entry&, void ); + DECL_LINK( UpButtonClickedHdl, weld::Button&, void ); + DECL_LINK( DownButtonClickedHdl, weld::Button&, void ); // ____ RangeSelectionListenerParent ____ virtual void listeningFinished( const OUString & rNewRange ) override; virtual void disposingRangeSelection() override; + void InsertRoleLBEntry(const OUString& rRole, const OUString& rRange); + void updateControlState(); /** updates the internal data according to the content of the given edit @@ -85,12 +100,12 @@ private: if the text from the field is a valid format to the internal data was valid */ - bool updateModelFromControl( Edit * pField = nullptr ); + bool updateModelFromControl(weld::Entry* pField = nullptr); /** @return , if the edit field contains a valid range entry. If no XCellRangesAccess can be obtained, is returned. */ - bool isRangeFieldContentValid( Edit & rEdit ); + bool isRangeFieldContentValid(weld::Entry& rEdit); /** @return , if the tab-page is in a consistent (commitable) state */ @@ -102,34 +117,34 @@ private: void fillSeriesListBox(); void fillRoleListBox(); - VclPtr m_pFT_CAPTION; - VclPtr m_pFT_SERIES; - VclPtr m_pLB_SERIES; - VclPtr m_pBTN_ADD; - VclPtr m_pBTN_REMOVE; - VclPtr m_pBTN_UP; - VclPtr m_pBTN_DOWN; - - VclPtr m_pFT_ROLE; - VclPtr m_pLB_ROLE; - VclPtr m_pFT_RANGE; - VclPtr m_pEDT_RANGE; - VclPtr m_pIMB_RANGE_MAIN; - - VclPtr m_pFT_CATEGORIES; - VclPtr m_pFT_DATALABELS;//used for xy charts - VclPtr m_pEDT_CATEGORIES; - VclPtr m_pIMB_RANGE_CAT; + std::vector> m_aEntries; OUString m_aFixedTextRange; ChartTypeTemplateProvider * m_pTemplateProvider; DialogModel & m_rDialogModel; - VclPtr m_pCurrentRangeChoosingField; + weld::Entry* m_pCurrentRangeChoosingField; bool m_bIsDirty; VclPtr m_pParentDialog; TabPageNotifiable * m_pTabPageNotifiable; + + std::unique_ptr m_xFT_CAPTION; + std::unique_ptr m_xFT_SERIES; + std::unique_ptr m_xLB_SERIES; + std::unique_ptr m_xBTN_ADD; + std::unique_ptr m_xBTN_REMOVE; + std::unique_ptr m_xBTN_UP; + std::unique_ptr m_xBTN_DOWN; + std::unique_ptr m_xFT_ROLE; + std::unique_ptr m_xLB_ROLE; + std::unique_ptr m_xFT_RANGE; + std::unique_ptr m_xEDT_RANGE; + std::unique_ptr m_xIMB_RANGE_MAIN; + std::unique_ptr m_xFT_CATEGORIES; + std::unique_ptr m_xFT_DATALABELS;//used for xy charts + std::unique_ptr m_xEDT_CATEGORIES; + std::unique_ptr m_xIMB_RANGE_CAT; }; } // namespace chart diff --git a/chart2/source/controller/dialogs/tp_DataSourceControls.cxx b/chart2/source/controller/dialogs/tp_DataSourceControls.cxx deleted file mode 100644 index cd316517d27f..000000000000 --- a/chart2/source/controller/dialogs/tp_DataSourceControls.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include "tp_DataSourceControls.hxx" - -using namespace ::com::sun::star; - -namespace chart -{ - -SeriesEntry::~SeriesEntry() -{} - -SeriesListBox::SeriesListBox(vcl::Window* pParent, WinBits nStyle) - : SvTreeListBox(pParent, nStyle) -{} - -VCL_BUILDER_FACTORY_CONSTRUCTOR(SeriesListBox, 0) - -SvTreeListEntry* SeriesListBox::CreateEntry() const -{ - return new SeriesEntry; -} - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_DataSourceControls.hxx b/chart2/source/controller/dialogs/tp_DataSourceControls.hxx deleted file mode 100644 index 55e49aebacf7..000000000000 --- a/chart2/source/controller/dialogs/tp_DataSourceControls.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_DATASOURCECONTROLS_HXX -#define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_DATASOURCECONTROLS_HXX - -#include -#include - -namespace com { namespace sun { namespace star { namespace chart2 { class XChartType; } } } } -namespace com { namespace sun { namespace star { namespace chart2 { class XDataSeries; } } } } - -namespace chart -{ - -class SeriesEntry : public ::SvTreeListEntry -{ -public: - virtual ~SeriesEntry() override; - - /// the corresponding data series - css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; - - /// the chart type that contains the series (via XDataSeriesContainer) - css::uno::Reference< css::chart2::XChartType > m_xChartType; -}; - -class SeriesListBox : public ::SvTreeListBox -{ -public: - explicit SeriesListBox(vcl::Window* pParent, WinBits nStyle); - - virtual SvTreeListEntry* CreateEntry() const override; -}; - -} // namespace chart - -// INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_DATASOURCECONTROLS_HXX -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/uiconfig/ui/tp_DataSource.ui b/chart2/uiconfig/ui/tp_DataSource.ui index a6fce7637052..cc7aaa7c70b4 100644 --- a/chart2/uiconfig/ui/tp_DataSource.ui +++ b/chart2/uiconfig/ui/tp_DataSource.ui @@ -1,19 +1,46 @@ - + - + + True + False + gtk-go-up + + + True + False + gtk-go-down + True False Select data range - chart2/res/selectrange.png + chart2/res/selectrange.png True False Select data range - chart2/res/selectrange.png + chart2/res/selectrange.png + + + + + + + + + + + + + + + + + + True @@ -57,7 +84,7 @@ False Data _series: True - LB_SERIES:border + LB_SERIES 0 @@ -67,14 +94,37 @@ - - 200 - 200 + True False + True True - - + in + + + True + True + True + True + liststore1 + False + False + 0 + False + + + + + + + + + 0 + + + + + @@ -108,6 +158,7 @@ True True True + image1 True @@ -139,6 +190,8 @@ True True True + image2 + True Down @@ -178,7 +231,7 @@ False _Data ranges: True - LB_ROLE:border + LB_ROLE 0 @@ -187,15 +240,47 @@ - - 440 - 100 + True - True + False True True - - + in + + + True + True + True + True + liststore2 + False + False + 0 + False + + + + + + + + + 0 + + + + + + + + + + 1 + + + + + diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 629a835e5232..9318e114ef05 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -294,9 +294,6 @@ - diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 39f2172b1890..e0ae0d673b74 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -472,7 +472,6 @@ custom_widgets = [ 'SearchResultsBox', 'SelectionListBox', 'SentenceEditWindow', - 'SeriesListBox', 'SfxAccCfgTabListBox', 'SfxConfigFunctionListBox', 'SfxConfigGroupListBox', diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 44bcd0fadb98..820b78aa0022 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1696,9 +1696,18 @@ public: virtual void set_error(bool bError) override { if (bError) - m_xEntry->SetControlForeground(Color(0xf0, 0, 0)); + { + // #i75179# enable setting the background to a different color + m_xEntry->SetForceControlBackground(true); + m_xEntry->SetControlForeground(COL_WHITE); + m_xEntry->SetControlBackground(0xff6563); + } else + { + m_xEntry->SetForceControlBackground(false); m_xEntry->SetControlForeground(); + m_xEntry->SetControlBackground(); + } } virtual vcl::Font get_font() override -- cgit v1.2.3