summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-29 13:13:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-05-01 15:55:55 +0200
commitf82356d9a1ce1457593a5f42728e2962561328cf (patch)
treeddac3224cc714d92cf80b5b285277c6a0a0e5e08 /sc/source/ui/dbgui
parentd822953cbc1d8814ac9f9eac2107177d37103542 (diff)
weld ScPivotLayoutDialog
Change-Id: I821ee682bf5b65774a609227811365b94ae2063e Reviewed-on: https://gerrit.libreoffice.org/71547 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/PivotLayoutDialog.cxx405
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeList.cxx61
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx129
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListData.cxx84
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx34
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx4
6 files changed, 340 insertions, 377 deletions
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index 9199d8039922..070c75c62714 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -68,96 +68,97 @@ ScRange lclGetRangeForNamedRange(OUString const & aName, const ScDocument* pDocu
}
ScPivotLayoutDialog::ScPivotLayoutDialog(
- SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent,
- ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bNewPivotTable) :
- ScAnyRefDlg (pSfxBindings, pChildWindow, pParent, "PivotTableLayout", "modules/scalc/ui/pivottablelayoutdialog.ui"),
- maPivotTableObject (*pPivotTableObject),
- mpPreviouslyFocusedListBox(nullptr),
- mpViewData (pViewData),
- mpDocument (pViewData->GetDocument()),
- mbNewPivotTable (bNewPivotTable),
- mpActiveEdit (nullptr),
- maAddressDetails (mpDocument->GetAddressConvention(), 0, 0),
- mbDialogLostFocus (false)
-{
- get(mpListBoxField, "listbox-fields");
- get(mpListBoxPage, "listbox-page");
- get(mpListBoxColumn, "listbox-column");
- get(mpListBoxRow, "listbox-row");
- get(mpListBoxData, "listbox-data");
-
- get(mpCheckIgnoreEmptyRows, "check-ignore-empty-rows");
- get(mpCheckTotalColumns, "check-total-columns");
- get(mpCheckAddFilter, "check-add-filter");
- get(mpCheckIdentifyCategories, "check-identify-categories");
- get(mpCheckTotalRows, "check-total-rows");
- get(mpCheckDrillToDetail, "check-drill-to-details");
-
- get(mpBtnOK, "ok");
- get(mpBtnCancel, "cancel");
-
- get(mpSourceRadioNamedRange, "source-radio-named-range");
- get(mpSourceRadioSelection, "source-radio-selection");
- get(mpSourceListBox, "source-list");
- get(mpSourceEdit, "source-edit");
- get(mpSourceButton, "source-button");
-
- get(mpDestinationRadioNewSheet, "destination-radio-new-sheet");
- get(mpDestinationRadioNamedRange, "destination-radio-named-range");
- get(mpDestinationRadioSelection, "destination-radio-selection");
- get(mpDestinationListBox, "destination-list");
- get(mpDestinationEdit, "destination-edit");
- get(mpDestinationButton, "destination-button");
-
+ SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, weld::Window* pParent,
+ ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bNewPivotTable)
+ : ScAnyRefDlgController(pSfxBindings, pChildWindow, pParent, "modules/scalc/ui/pivottablelayoutdialog.ui", "PivotTableLayout")
+ , maPivotTableObject(*pPivotTableObject)
+ , mpPreviouslyFocusedListBox(nullptr)
+ , mpViewData(pViewData)
+ , mpDocument(pViewData->GetDocument())
+ , mbNewPivotTable(bNewPivotTable)
+ , maAddressDetails(mpDocument->GetAddressConvention(), 0, 0)
+ , mbDialogLostFocus(false)
+ , mpActiveEdit(nullptr)
+ , mxListBoxField(new ScPivotLayoutTreeListLabel(m_xBuilder->weld_tree_view("listbox-fields")))
+ , mxListBoxPage(new ScPivotLayoutTreeList(m_xBuilder->weld_tree_view("listbox-page")))
+ , mxListBoxColumn(new ScPivotLayoutTreeList(m_xBuilder->weld_tree_view("listbox-column")))
+ , mxListBoxRow(new ScPivotLayoutTreeList(m_xBuilder->weld_tree_view("listbox-row")))
+ , mxListBoxData(new ScPivotLayoutTreeListData(m_xBuilder->weld_tree_view("listbox-data")))
+ , mxCheckIgnoreEmptyRows(m_xBuilder->weld_check_button("check-ignore-empty-rows"))
+ , mxCheckTotalColumns(m_xBuilder->weld_check_button("check-total-columns"))
+ , mxCheckAddFilter(m_xBuilder->weld_check_button("check-add-filter"))
+ , mxCheckIdentifyCategories(m_xBuilder->weld_check_button("check-identify-categories"))
+ , mxCheckTotalRows(m_xBuilder->weld_check_button("check-total-rows"))
+ , mxCheckDrillToDetail(m_xBuilder->weld_check_button("check-drill-to-details"))
+ , mxSourceRadioNamedRange(m_xBuilder->weld_radio_button("source-radio-named-range"))
+ , mxSourceRadioSelection(m_xBuilder->weld_radio_button("source-radio-selection"))
+ , mxSourceListBox(m_xBuilder->weld_combo_box("source-list"))
+ , mxSourceEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("source-edit")))
+ , mxSourceButton(new formula::WeldRefButton(m_xBuilder->weld_button("source-button")))
+ , mxDestinationRadioNewSheet(m_xBuilder->weld_radio_button("destination-radio-new-sheet"))
+ , mxDestinationRadioNamedRange(m_xBuilder->weld_radio_button("destination-radio-named-range"))
+ , mxDestinationRadioSelection(m_xBuilder->weld_radio_button("destination-radio-selection"))
+ , mxDestinationListBox(m_xBuilder->weld_combo_box("destination-list"))
+ , mxDestinationEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("destination-edit")))
+ , mxDestinationButton(new formula::WeldRefButton(m_xBuilder->weld_button("destination-button")))
+ , mxBtnOK(m_xBuilder->weld_button("ok"))
+ , mxBtnCancel(m_xBuilder->weld_button("cancel"))
+ , mxSourceFrame(m_xBuilder->weld_frame("frame2"))
+ , mxSourceLabel(mxSourceFrame->weld_label_widget())
+ , mxDestFrame(m_xBuilder->weld_frame("frame1"))
+ , mxDestLabel(mxDestFrame->weld_label_widget())
+ , mxOptions(m_xBuilder->weld_expander("options"))
+ , mxMore(m_xBuilder->weld_expander("more"))
+{
// Source UI
- Link<RadioButton&,void> aLink2 = LINK(this, ScPivotLayoutDialog, ToggleSource);
- mpSourceRadioNamedRange->SetToggleHdl(aLink2);
- mpSourceRadioSelection->SetToggleHdl(aLink2);
+ Link<weld::ToggleButton&,void> aLink2 = LINK(this, ScPivotLayoutDialog, ToggleSource);
+ mxSourceRadioNamedRange->connect_toggled(aLink2);
+ mxSourceRadioSelection->connect_toggled(aLink2);
- mpSourceEdit->SetReferences(this, mpSourceRadioSelection);
- mpSourceButton->SetReferences(this, mpSourceEdit);
+ mxSourceEdit->SetReferences(this, mxSourceLabel.get());
+ mxSourceButton->SetReferences(this, mxSourceEdit.get());
- Link<Control&,void> aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
- mpSourceEdit->SetGetFocusHdl(aLink);
- mpSourceButton->SetGetFocusHdl(aLink);
+ Link<formula::WeldRefEdit&,void> aEditLink = LINK(this, ScPivotLayoutDialog, GetEditFocusHandler);
+ mxDestinationEdit->SetGetFocusHdl(aEditLink);
+ mxSourceEdit->SetGetFocusHdl(aEditLink);
- aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
- mpSourceEdit->SetLoseFocusHdl(aLink);
- mpSourceButton->SetLoseFocusHdl(aLink);
+ aEditLink = LINK(this, ScPivotLayoutDialog, LoseEditFocusHandler);
+ mxDestinationEdit->SetLoseFocusHdl(aEditLink);
+ mxSourceEdit->SetLoseFocusHdl(aEditLink);
- mpSourceEdit->SetModifyHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
- mpSourceListBox->SetSelectHdl(LINK(this, ScPivotLayoutDialog, SourceListSelected));
+ mxSourceEdit->SetModifyHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
+ mxSourceListBox->connect_changed(LINK(this, ScPivotLayoutDialog, SourceListSelected));
// Destination UI
aLink2 = LINK(this, ScPivotLayoutDialog, ToggleDestination);
- mpDestinationRadioNewSheet->SetToggleHdl(aLink2);
- mpDestinationRadioNamedRange->SetToggleHdl(aLink2);
- mpDestinationRadioSelection->SetToggleHdl(aLink2);
+ mxDestinationRadioNewSheet->connect_toggled(aLink2);
+ mxDestinationRadioNamedRange->connect_toggled(aLink2);
+ mxDestinationRadioSelection->connect_toggled(aLink2);
- mpDestinationEdit->SetReferences(this, mpDestinationRadioNewSheet);
- mpDestinationButton->SetReferences(this, mpDestinationEdit);
+ mxDestinationEdit->SetReferences(this, mxDestLabel.get());
+ mxDestinationButton->SetReferences(this, mxDestinationEdit.get());
- aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
- mpDestinationEdit->SetGetFocusHdl(aLink);
- mpDestinationButton->SetGetFocusHdl(aLink);
+ Link<formula::WeldRefButton&,void> aButtonLink = LINK(this, ScPivotLayoutDialog, GetButtonFocusHandler);
+ mxSourceButton->SetGetFocusHdl(aButtonLink);
+ mxDestinationButton->SetGetFocusHdl(aButtonLink);
- aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
- mpDestinationEdit->SetLoseFocusHdl(aLink);
- mpDestinationButton->SetLoseFocusHdl(aLink);
+ aButtonLink = LINK(this, ScPivotLayoutDialog, LoseButtonFocusHandler);
+ mxSourceButton->SetLoseFocusHdl(aButtonLink);
+ mxDestinationButton->SetLoseFocusHdl(aButtonLink);
// Buttons
- mpBtnCancel->SetClickHdl(LINK(this, ScPivotLayoutDialog, CancelClicked));
- mpBtnOK->SetClickHdl(LINK(this, ScPivotLayoutDialog, OKClicked));
+ mxBtnCancel->connect_clicked(LINK(this, ScPivotLayoutDialog, CancelClicked));
+ mxBtnOK->connect_clicked(LINK(this, ScPivotLayoutDialog, OKClicked));
// Initialize Data
maPivotTableObject.FillOldParam(maPivotParameters);
maPivotTableObject.FillLabelData(maPivotParameters);
- mpListBoxField->Setup (this);
- mpListBoxPage->Setup (this, ScPivotLayoutTreeList::PAGE_LIST);
- mpListBoxColumn->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST);
- mpListBoxRow->Setup (this, ScPivotLayoutTreeList::ROW_LIST);
- mpListBoxData->Setup (this);
+ mxListBoxField->Setup (this);
+ mxListBoxPage->Setup (this, ScPivotLayoutTreeList::PAGE_LIST);
+ mxListBoxColumn->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST);
+ mxListBoxRow->Setup (this, ScPivotLayoutTreeList::ROW_LIST);
+ mxListBoxData->Setup (this);
FillValuesToListBoxes();
@@ -165,19 +166,19 @@ ScPivotLayoutDialog::ScPivotLayoutDialog(
const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
if (pSaveData == nullptr)
{
- mpCheckAddFilter->Check(false);
- mpCheckDrillToDetail->Check(false);
+ mxCheckAddFilter->set_active(false);
+ mxCheckDrillToDetail->set_active(false);
}
else
{
- mpCheckAddFilter->Check(pSaveData->GetFilterButton());
- mpCheckDrillToDetail->Check(pSaveData->GetDrillDown());
+ mxCheckAddFilter->set_active(pSaveData->GetFilterButton());
+ mxCheckDrillToDetail->set_active(pSaveData->GetDrillDown());
}
- mpCheckIgnoreEmptyRows->Check(maPivotParameters.bIgnoreEmptyRows);
- mpCheckIdentifyCategories->Check(maPivotParameters.bDetectCategories);
- mpCheckTotalColumns->Check(maPivotParameters.bMakeTotalCol);
- mpCheckTotalRows->Check(maPivotParameters.bMakeTotalRow);
+ mxCheckIgnoreEmptyRows->set_active(maPivotParameters.bIgnoreEmptyRows);
+ mxCheckIdentifyCategories->set_active(maPivotParameters.bDetectCategories);
+ mxCheckTotalColumns->set_active(maPivotParameters.bMakeTotalCol);
+ mxCheckTotalRows->set_active(maPivotParameters.bMakeTotalRow);
SetupSource();
SetupDestination();
@@ -185,43 +186,11 @@ ScPivotLayoutDialog::ScPivotLayoutDialog(
ScPivotLayoutDialog::~ScPivotLayoutDialog()
{
- disposeOnce();
-}
-
-void ScPivotLayoutDialog::dispose()
-{
- mpPreviouslyFocusedListBox.clear();
- mpListBoxField.clear();
- mpListBoxPage.clear();
- mpListBoxColumn.clear();
- mpListBoxRow.clear();
- mpListBoxData.clear();
- mpCheckIgnoreEmptyRows.clear();
- mpCheckTotalColumns.clear();
- mpCheckAddFilter.clear();
- mpCheckIdentifyCategories.clear();
- mpCheckTotalRows.clear();
- mpCheckDrillToDetail.clear();
- mpSourceRadioNamedRange.clear();
- mpSourceRadioSelection.clear();
- mpSourceListBox.clear();
- mpSourceEdit.clear();
- mpSourceButton.clear();
- mpDestinationRadioNewSheet.clear();
- mpDestinationRadioNamedRange.clear();
- mpDestinationRadioSelection.clear();
- mpDestinationListBox.clear();
- mpDestinationEdit.clear();
- mpDestinationButton.clear();
- mpBtnOK.clear();
- mpBtnCancel.clear();
- mpActiveEdit.clear();
- ScAnyRefDlg::dispose();
}
void ScPivotLayoutDialog::SetupSource()
{
- mpSourceListBox->Clear();
+ mxSourceListBox->clear();
ScRange aSourceRange;
OUString sSourceNamedRangeName;
@@ -234,21 +203,21 @@ void ScPivotLayoutDialog::SetupSource()
if(!aSourceRange.IsValid())
{
// Source is probably a DB Range
- mpSourceRadioNamedRange->Disable();
- mpSourceRadioSelection->Disable();
+ mxSourceRadioNamedRange->set_sensitive(false);
+ mxSourceRadioSelection->set_sensitive(false);
ToggleSource();
return;
}
else
{
OUString aSourceRangeName = aSourceRange.Format(ScRefFlags::RANGE_ABS_3D, mpDocument, maAddressDetails);
- mpSourceEdit->SetText(aSourceRangeName);
+ mxSourceEdit->SetText(aSourceRangeName);
}
}
else
{
- mpSourceRadioNamedRange->Disable();
- mpSourceRadioSelection->Disable();
+ mxSourceRadioNamedRange->set_sensitive(false);
+ mxSourceRadioSelection->set_sensitive(false);
ToggleSource();
return;
}
@@ -264,7 +233,7 @@ void ScPivotLayoutDialog::SetupSource()
{
if (!aIterator.WasDBName())
{
- mpSourceListBox->InsertEntry(aEachName);
+ mxSourceListBox->append_text(aEachName);
if (aEachRange == aSourceRange)
{
sSourceNamedRangeName = aEachName;
@@ -275,25 +244,25 @@ void ScPivotLayoutDialog::SetupSource()
if (bIsNamedRange)
{
- mpSourceListBox->SelectEntry(sSourceNamedRangeName);
- mpSourceRadioNamedRange->Check();
+ mxSourceListBox->set_active_text(sSourceNamedRangeName);
+ mxSourceRadioNamedRange->set_active(true);
}
else
{
- mpSourceListBox->SelectEntryPos(0);
- mpSourceRadioSelection->Check();
+ mxSourceListBox->set_active(0);
+ mxSourceRadioSelection->set_active(true);
}
// If entries - select first entry, otherwise disable the radio button.
- if (mpSourceListBox->GetEntryCount() <= 0)
- mpSourceRadioNamedRange->Disable();
+ if (mxSourceListBox->get_count() <= 0)
+ mxSourceRadioNamedRange->set_sensitive(false);
ToggleSource();
}
void ScPivotLayoutDialog::SetupDestination()
{
- mpDestinationListBox->Clear();
+ mxDestinationListBox->clear();
// Fill up named ranges
ScAreaNameIterator aIterator(mpDocument);
@@ -304,20 +273,20 @@ void ScPivotLayoutDialog::SetupDestination()
{
if (!aIterator.WasDBName())
{
- mpDestinationListBox->InsertEntry(aName);
+ mxDestinationListBox->append_text(aName);
}
}
// If entries - select first entry, otherwise disable the radio button.
- if (mpDestinationListBox->GetEntryCount() > 0)
- mpDestinationListBox->SelectEntryPos(0);
+ if (mxDestinationListBox->get_count() > 0)
+ mxDestinationListBox->set_active(0);
else
- mpDestinationRadioNamedRange->Disable();
+ mxDestinationRadioNamedRange->set_sensitive(false);
//
if (mbNewPivotTable)
{
- mpDestinationRadioNewSheet->Check();
+ mxDestinationRadioNewSheet->set_active(true);
}
else
{
@@ -325,8 +294,8 @@ void ScPivotLayoutDialog::SetupDestination()
{
ScAddress aAddress(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
OUString aAddressString = aAddress.Format(ScRefFlags::ADDR_ABS_3D, mpDocument, maAddressDetails);
- mpDestinationEdit->SetText(aAddressString);
- mpDestinationRadioSelection->Check();
+ mxDestinationEdit->SetText(aAddressString);
+ mxDestinationRadioSelection->set_active(true);
}
}
@@ -335,11 +304,11 @@ void ScPivotLayoutDialog::SetupDestination()
void ScPivotLayoutDialog::FillValuesToListBoxes()
{
- mpListBoxField->FillLabelFields(maPivotParameters.maLabelArray);
- mpListBoxData->FillDataField(maPivotParameters.maDataFields);
- mpListBoxColumn->FillFields(maPivotParameters.maColFields);
- mpListBoxRow->FillFields(maPivotParameters.maRowFields);
- mpListBoxPage->FillFields(maPivotParameters.maPageFields);
+ mxListBoxField->FillLabelFields(maPivotParameters.maLabelArray);
+ mxListBoxData->FillDataField(maPivotParameters.maDataFields);
+ mxListBoxColumn->FillFields(maPivotParameters.maColFields);
+ mxListBoxRow->FillFields(maPivotParameters.maRowFields);
+ mxListBoxPage->FillFields(maPivotParameters.maPageFields);
}
void ScPivotLayoutDialog::SetActive()
@@ -350,13 +319,13 @@ void ScPivotLayoutDialog::SetActive()
if(mpActiveEdit != nullptr)
{
mpActiveEdit->GrabFocus();
- if (mpActiveEdit == mpSourceEdit)
+ if (mpActiveEdit == mxSourceEdit.get())
UpdateSourceRange();
}
}
else
{
- GrabFocus();
+ m_xDialog->grab_focus();
}
RefInputDone();
@@ -375,13 +344,13 @@ void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocumen
OUString aReferenceString = rReferenceRange.Format(ScRefFlags::RANGE_ABS_3D, pDocument, maAddressDetails);
- if (mpActiveEdit == mpSourceEdit)
+ if (mpActiveEdit == mxSourceEdit.get())
{
- mpSourceEdit->SetRefString(aReferenceString);
+ mxSourceEdit->SetRefString(aReferenceString);
}
- else if (mpActiveEdit == mpDestinationEdit)
+ else if (mpActiveEdit == mxDestinationEdit.get())
{
- mpDestinationEdit->SetRefString(aReferenceString);
+ mxDestinationEdit->SetRefString(aReferenceString);
}
}
@@ -401,17 +370,17 @@ void ScPivotLayoutDialog::ItemInserted(const ScItemValue* pItemValue, ScPivotLay
case ScPivotLayoutTreeList::COLUMN_LIST:
case ScPivotLayoutTreeList::PAGE_LIST:
{
- mpListBoxRow->RemoveEntryForItem(pItemValue);
- mpListBoxColumn->RemoveEntryForItem(pItemValue);
- mpListBoxPage->RemoveEntryForItem(pItemValue);
+ mxListBoxRow->RemoveEntryForItem(pItemValue);
+ mxListBoxColumn->RemoveEntryForItem(pItemValue);
+ mxListBoxPage->RemoveEntryForItem(pItemValue);
}
break;
case ScPivotLayoutTreeList::LABEL_LIST:
{
- mpListBoxRow->RemoveEntryForItem(pItemValue);
- mpListBoxColumn->RemoveEntryForItem(pItemValue);
- mpListBoxPage->RemoveEntryForItem(pItemValue);
- mpListBoxData->RemoveEntryForItem(pItemValue);
+ mxListBoxRow->RemoveEntryForItem(pItemValue);
+ mxListBoxColumn->RemoveEntryForItem(pItemValue);
+ mxListBoxPage->RemoveEntryForItem(pItemValue);
+ mxListBoxData->RemoveEntryForItem(pItemValue);
}
break;
default:
@@ -426,23 +395,23 @@ void ScPivotLayoutDialog::UpdateSourceRange()
ScSheetSourceDesc aSourceSheet = *maPivotTableObject.GetSheetDesc();
- if (mpSourceRadioNamedRange->IsChecked())
+ if (mxSourceRadioNamedRange->get_active())
{
- OUString aEntryString = mpSourceListBox->GetSelectedEntry();
+ OUString aEntryString = mxSourceListBox->get_active_text();
ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, mpDocument);
if (!aSourceRange.IsValid() || aSourceSheet.GetSourceRange() == aSourceRange)
return;
aSourceSheet.SetRangeName(aEntryString);
}
- else if (mpSourceRadioSelection->IsChecked())
+ else if (mxSourceRadioSelection->get_active())
{
- OUString aSourceString = mpSourceEdit->GetText();
+ OUString aSourceString = mxSourceEdit->GetText();
ScRange aSourceRange;
ScRefFlags nResult = aSourceRange.Parse(aSourceString, mpDocument, maAddressDetails);
bool bIsValid = (nResult & ScRefFlags::VALID) == ScRefFlags::VALID; // aSourceString is valid
- mpSourceEdit->SetRefValid(true);
+ mxSourceEdit->SetRefValid(true);
if (bIsValid)
{
@@ -460,7 +429,7 @@ void ScPivotLayoutDialog::UpdateSourceRange()
if (!aSourceRange.IsValid())
{
- mpSourceEdit->SetRefValid(false);
+ mxSourceEdit->SetRefValid(false);
return;
}
@@ -470,7 +439,7 @@ void ScPivotLayoutDialog::UpdateSourceRange()
aSourceSheet.SetSourceRange(aSourceRange);
if (aSourceSheet.CheckSourceRange() != nullptr)
{
- mpSourceEdit->SetRefValid(false);
+ mxSourceEdit->SetRefValid(false);
return;
}
}
@@ -542,32 +511,32 @@ void ScPivotLayoutDialog::ApplyChanges()
void ScPivotLayoutDialog::ApplySaveData(ScDPSaveData& rSaveData)
{
- rSaveData.SetIgnoreEmptyRows(mpCheckIgnoreEmptyRows->IsChecked());
- rSaveData.SetRepeatIfEmpty(mpCheckIdentifyCategories->IsChecked());
- rSaveData.SetColumnGrand(mpCheckTotalColumns->IsChecked());
- rSaveData.SetRowGrand(mpCheckTotalRows->IsChecked());
- rSaveData.SetFilterButton(mpCheckAddFilter->IsChecked());
- rSaveData.SetDrillDown(mpCheckDrillToDetail->IsChecked());
+ rSaveData.SetIgnoreEmptyRows(mxCheckIgnoreEmptyRows->get_active());
+ rSaveData.SetRepeatIfEmpty(mxCheckIdentifyCategories->get_active());
+ rSaveData.SetColumnGrand(mxCheckTotalColumns->get_active());
+ rSaveData.SetRowGrand(mxCheckTotalRows->get_active());
+ rSaveData.SetFilterButton(mxCheckAddFilter->get_active());
+ rSaveData.SetDrillDown(mxCheckDrillToDetail->get_active());
Reference<XDimensionsSupplier> xSource = maPivotTableObject.GetSource();
ScPivotFieldVector aPageFieldVector;
- mpListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
+ mxListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
ScDPObject::ConvertOrientation(rSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aColFieldVector;
- mpListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
+ mxListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
ScDPObject::ConvertOrientation(rSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aRowFieldVector;
- mpListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
+ mxListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
ScDPObject::ConvertOrientation(rSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aDataFieldVector;
- mpListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
+ mxListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
ScDPObject::ConvertOrientation(rSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
xSource, maPivotParameters.maLabelArray,
&aColFieldVector, &aRowFieldVector, &aPageFieldVector);
@@ -611,17 +580,17 @@ bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNe
{
bToNewSheet = false;
- if (mpDestinationRadioNamedRange->IsChecked())
+ if (mxDestinationRadioNamedRange->get_active())
{
- OUString aName = mpDestinationListBox->GetSelectedEntry();
+ OUString aName = mxDestinationListBox->get_active_text();
aDestinationRange = lclGetRangeForNamedRange(aName, mpDocument);
if (!aDestinationRange.IsValid())
return false;
}
- else if (mpDestinationRadioSelection->IsChecked())
+ else if (mxDestinationRadioSelection->get_active())
{
ScAddress aAddress;
- aAddress.Parse(mpDestinationEdit->GetText(), mpDocument, maAddressDetails);
+ aAddress.Parse(mxDestinationEdit->GetText(), mpDocument, maAddressDetails);
aDestinationRange = ScRange(aAddress);
}
else
@@ -634,12 +603,12 @@ bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNe
ScItemValue* ScPivotLayoutDialog::GetItem(SCCOL nColumn)
{
- return mpListBoxField->GetItem(nColumn);
+ return mxListBoxField->GetItem(nColumn);
}
bool ScPivotLayoutDialog::IsDataElement(SCCOL nColumn)
{
- return mpListBoxField->IsDataElement(nColumn);
+ return mxListBoxField->IsDataElement(nColumn);
}
ScDPLabelData& ScPivotLayoutDialog::GetLabelData(SCCOL nColumn)
@@ -649,99 +618,91 @@ ScDPLabelData& ScPivotLayoutDialog::GetLabelData(SCCOL nColumn)
void ScPivotLayoutDialog::PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames)
{
- return mpListBoxData->PushDataFieldNames(rDataFieldNames);
+ mxListBoxData->PushDataFieldNames(rDataFieldNames);
}
-bool ScPivotLayoutDialog::Close()
+void ScPivotLayoutDialog::Close()
{
- return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
+ DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
}
-IMPL_LINK_NOARG( ScPivotLayoutDialog, OKClicked, Button*, void )
+IMPL_LINK_NOARG( ScPivotLayoutDialog, OKClicked, weld::Button&, void )
{
ApplyChanges();
- Close();
+ m_xDialog->response(RET_OK);
+}
+
+IMPL_LINK_NOARG( ScPivotLayoutDialog, CancelClicked, weld::Button&, void )
+{
+ m_xDialog->response(RET_CANCEL);
}
-IMPL_LINK_NOARG( ScPivotLayoutDialog, CancelClicked, Button*, void )
+IMPL_LINK(ScPivotLayoutDialog, GetEditFocusHandler, formula::WeldRefEdit&, rCtrl, void)
{
- Close();
+ mpActiveEdit = &rCtrl;
+ mpActiveEdit->SelectAll();
}
-IMPL_LINK(ScPivotLayoutDialog, GetFocusHandler, Control&, rCtrl, void)
+IMPL_LINK(ScPivotLayoutDialog, GetButtonFocusHandler, formula::WeldRefButton&, rCtrl, void)
{
mpActiveEdit = nullptr;
- if (&rCtrl == static_cast<Control*>(mpSourceEdit) ||
- &rCtrl == static_cast<Control*>(mpSourceButton))
- {
- mpActiveEdit = mpSourceEdit;
- }
- else if (&rCtrl == static_cast<Control*>(mpDestinationEdit) ||
- &rCtrl == static_cast<Control*>(mpDestinationButton))
- {
- mpActiveEdit = mpDestinationEdit;
- }
+ if (&rCtrl == mxSourceButton.get())
+ mpActiveEdit = mxSourceEdit.get();
+ else if (&rCtrl == mxDestinationButton.get())
+ mpActiveEdit = mxDestinationEdit.get();
if (mpActiveEdit)
- mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX));
+ mpActiveEdit->SelectAll();
+}
+
+IMPL_LINK_NOARG(ScPivotLayoutDialog, LoseEditFocusHandler, formula::WeldRefEdit&, void)
+{
+ mbDialogLostFocus = !m_xDialog->has_toplevel_focus();
}
-IMPL_LINK_NOARG(ScPivotLayoutDialog, LoseFocusHandler, Control&, void)
+IMPL_LINK_NOARG(ScPivotLayoutDialog, LoseButtonFocusHandler, formula::WeldRefButton&, void)
{
- mbDialogLostFocus = !IsActive();
+ mbDialogLostFocus = !m_xDialog->has_toplevel_focus();
}
-IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceListSelected, ListBox&, void)
+IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceListSelected, weld::ComboBox&, void)
{
UpdateSourceRange();
}
-IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceEditModified, Edit&, void)
+IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceEditModified, formula::WeldRefEdit&, void)
{
UpdateSourceRange();
}
-IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleSource, RadioButton&, void)
+IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleSource, weld::ToggleButton&, void)
{
ToggleSource();
}
void ScPivotLayoutDialog::ToggleSource()
{
- bool bNamedRange = mpSourceRadioNamedRange->IsChecked();
- bool bSelection = mpSourceRadioSelection->IsChecked();
- mpSourceListBox->Enable(bNamedRange);
- mpSourceButton->Enable(bSelection);
- mpSourceEdit->Enable(bSelection);
+ bool bNamedRange = mxSourceRadioNamedRange->get_active();
+ bool bSelection = mxSourceRadioSelection->get_active();
+ mxSourceListBox->set_sensitive(bNamedRange);
+ mxSourceButton->GetWidget()->set_sensitive(bSelection);
+ mxSourceEdit->GetWidget()->set_sensitive(bSelection);
UpdateSourceRange();
}
-IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleDestination, RadioButton&, void)
+IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleDestination, weld::ToggleButton&, void)
{
ToggleDestination();
}
void ScPivotLayoutDialog::ToggleDestination()
{
- bool bNamedRange = mpDestinationRadioNamedRange->IsChecked();
- bool bSelection = mpDestinationRadioSelection->IsChecked();
- mpDestinationListBox->Enable(bNamedRange);
- mpDestinationButton->Enable(bSelection);
- mpDestinationEdit->Enable(bSelection);
-}
-
-ScPivotLayoutTreeListBase* ScPivotLayoutDialog::FindListBoxFor(const SvTreeListEntry *pEntry)
-{
- if (mpListBoxPage->HasEntry(pEntry))
- return mpListBoxPage.get();
- if (mpListBoxColumn->HasEntry(pEntry))
- return mpListBoxColumn.get();
- if (mpListBoxRow->HasEntry(pEntry))
- return mpListBoxRow.get();
- if (mpListBoxData->HasEntry(pEntry))
- return mpListBoxData.get();
- return nullptr;
+ bool bNamedRange = mxDestinationRadioNamedRange->get_active();
+ bool bSelection = mxDestinationRadioSelection->get_active();
+ mxDestinationListBox->set_sensitive(bNamedRange);
+ mxDestinationButton->GetWidget()->set_sensitive(bSelection);
+ mxDestinationEdit->GetWidget()->set_sensitive(bSelection);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
index 03ea8a98f709..19004643e846 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
@@ -19,17 +19,16 @@
#include <pivot.hxx>
#include <scabstdlg.hxx>
-VCL_BUILDER_FACTORY_ARGS(ScPivotLayoutTreeList,
- WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN)
-
-ScPivotLayoutTreeList::ScPivotLayoutTreeList(vcl::Window* pParent, WinBits nBits) :
- ScPivotLayoutTreeListBase(pParent, nBits)
+ScPivotLayoutTreeList::ScPivotLayoutTreeList(std::unique_ptr<weld::TreeView> xControl)
+ : ScPivotLayoutTreeListBase(std::move(xControl))
{
- SetForceMakeVisible(true);
+ mxControl->connect_key_press(LINK(this, ScPivotLayoutTreeList, KeyInputHdl));
+ mxControl->connect_row_activated(LINK(this, ScPivotLayoutTreeList, DoubleClickHdl));
}
ScPivotLayoutTreeList::~ScPivotLayoutTreeList()
-{}
+{
+}
void ScPivotLayoutTreeList::Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListType eType)
{
@@ -37,17 +36,17 @@ void ScPivotLayoutTreeList::Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListT
meType = eType;
}
-bool ScPivotLayoutTreeList::DoubleClickHdl()
+IMPL_LINK_NOARG(ScPivotLayoutTreeList, DoubleClickHdl, weld::TreeView&, void)
{
- SvTreeListEntry* pEntry = GetCurEntry();
- if (!pEntry)
- return false;
+ int nEntry = mxControl->get_cursor_index();
+ if (nEntry == -1)
+ return;
- ScItemValue* pCurrentItemValue = static_cast<ScItemValue*>(pEntry->GetUserData());
+ ScItemValue* pCurrentItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(nEntry).toInt64());
ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData;
if (mpParent->IsDataElement(rCurrentFunctionData.mnCol))
- return false;
+ return;
SCCOL nCurrentColumn = rCurrentFunctionData.mnCol;
ScDPLabelData& rCurrentLabelData = mpParent->GetLabelData(nCurrentColumn);
@@ -58,20 +57,18 @@ bool ScPivotLayoutTreeList::DoubleClickHdl()
mpParent->PushDataFieldNames(aDataFieldNames);
ScopedVclPtr<AbstractScDPSubtotalDlg> pDialog(
- pFactory->CreateScDPSubtotalDlg(GetFrameWeld(), mpParent->maPivotTableObject, rCurrentLabelData, rCurrentFunctionData, aDataFieldNames));
+ pFactory->CreateScDPSubtotalDlg(mxControl.get(), mpParent->maPivotTableObject, rCurrentLabelData, rCurrentFunctionData, aDataFieldNames));
if (pDialog->Execute() == RET_OK)
{
pDialog->FillLabelData(rCurrentLabelData);
rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
}
-
- return true;
}
void ScPivotLayoutTreeList::FillFields(ScPivotFieldVector& rFieldVector)
{
- Clear();
+ mxControl->clear();
maItemValues.clear();
for (ScPivotField& rField : rFieldVector)
@@ -79,13 +76,14 @@ void ScPivotLayoutTreeList::FillFields(ScPivotFieldVector& rFieldVector)
OUString aLabel = mpParent->GetItem( rField.nCol )->maName;
ScItemValue* pItemValue = new ScItemValue( aLabel, rField.nCol, rField.nFuncMask );
maItemValues.push_back(std::unique_ptr<ScItemValue>(pItemValue));
- InsertEntry(pItemValue->maName, nullptr, false, TREELIST_APPEND, pItemValue);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pItemValue)));
+ mxControl->append(sId, pItemValue->maName);
}
}
-void ScPivotLayoutTreeList::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget)
+void ScPivotLayoutTreeList::InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget)
{
- ScItemValue* pItemValue = static_cast<ScItemValue*>(pSource->GetUserData());
+ ScItemValue* pItemValue = reinterpret_cast<ScItemValue*>(rSource.get_selected_id().toInt64());
ScItemValue* pOriginalItemValue = pItemValue->mpOriginalItemValue;
// Don't allow to add "Data" element to page fields
@@ -94,31 +92,32 @@ void ScPivotLayoutTreeList::InsertEntryForSourceTarget(SvTreeListEntry* pSource,
mpParent->ItemInserted(pOriginalItemValue, meType);
- sal_uLong nPosition = (pTarget == nullptr) ? TREELIST_APPEND : GetModel()->GetAbsPos(pTarget) + 1;
- InsertEntryForItem(pOriginalItemValue, nPosition);
+ InsertEntryForItem(pOriginalItemValue, nTarget);
}
-void ScPivotLayoutTreeList::InsertEntryForItem(const ScItemValue* pItemValue, sal_uLong nPosition)
+void ScPivotLayoutTreeList::InsertEntryForItem(const ScItemValue* pItemValue, int nPosition)
{
ScItemValue *pListItemValue = new ScItemValue(pItemValue);
maItemValues.push_back(std::unique_ptr<ScItemValue>(pListItemValue));
- OUString rName = pListItemValue->maName;
- InsertEntry(rName, nullptr, false, nPosition, pListItemValue);
+ OUString sName = pListItemValue->maName;
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pListItemValue)));
+ mxControl->insert(nullptr, nPosition, &sName, &sId, nullptr, nullptr, nullptr, false, nullptr);
}
-void ScPivotLayoutTreeList::KeyInput(const KeyEvent& rKeyEvent)
+IMPL_LINK(ScPivotLayoutTreeList, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
sal_uInt16 nCode = aCode.GetCode();
if (nCode == KEY_DELETE)
{
- const SvTreeListEntry* pEntry = GetCurEntry();
- if (pEntry)
- GetModel()->Remove(pEntry);
- return;
+ const int nEntry = mxControl->get_cursor_index();
+ if (nEntry != -1)
+ mxControl->remove(nEntry);
+ return true;
}
- SvTreeListBox::KeyInput(rKeyEvent);
+
+ return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index f9fdea939b90..1ca50da20e00 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -14,24 +14,19 @@
#include <vcl/treelistentry.hxx>
-ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(vcl::Window* pParent, WinBits nBits, SvPivotTreeListType eType)
- : SvTreeListBox(pParent, nBits)
+ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(std::unique_ptr<weld::TreeView> xControl, SvPivotTreeListType eType)
+ : mxControl(std::move(xControl))
+ , maDropTargetHelper(*this)
, meType(eType)
, mpParent(nullptr)
{
- SetHighlightRange();
- SetDragDropMode(DragDropMode::CTRL_MOVE | DragDropMode::APP_MOVE | DragDropMode::APP_DROP);
+ mxControl->connect_focus_in(LINK(this, ScPivotLayoutTreeListBase, GetFocusHdl));
+ mxControl->connect_mnemonic_activate(LINK(this, ScPivotLayoutTreeListBase, MnemonicActivateHdl));
+ mxControl->connect_focus_out(LINK(this, ScPivotLayoutTreeListBase, LoseFocusHdl));
}
ScPivotLayoutTreeListBase::~ScPivotLayoutTreeListBase()
{
- disposeOnce();
-}
-
-void ScPivotLayoutTreeListBase::dispose()
-{
- mpParent.clear();
- SvTreeListBox::dispose();
}
void ScPivotLayoutTreeListBase::Setup(ScPivotLayoutDialog* pParent)
@@ -39,50 +34,58 @@ void ScPivotLayoutTreeListBase::Setup(ScPivotLayoutDialog* pParent)
mpParent = pParent;
}
-DragDropMode ScPivotLayoutTreeListBase::NotifyStartDrag(TransferDataContainer& /*aTransferDataContainer*/,
- SvTreeListEntry* /*pEntry*/ )
+ScPivotLayoutTreeDropTarget::ScPivotLayoutTreeDropTarget(ScPivotLayoutTreeListBase& rTreeView)
+ : DropTargetHelper(rTreeView.get_widget().get_drop_target())
+ , m_rTreeView(rTreeView)
{
- return GetDragDropMode();
}
-void ScPivotLayoutTreeListBase::DragFinished(sal_Int8 /*nDropAction*/)
-{}
-
-bool ScPivotLayoutTreeListBase::NotifyAcceptDrop(SvTreeListEntry* /*pEntry*/)
+sal_Int8 ScPivotLayoutTreeDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
{
- return true;
+ // to enable the autoscroll when we're close to the edges
+ weld::TreeView& rWidget = m_rTreeView.get_widget();
+ rWidget.get_dest_row_at_pos(rEvt.maPosPixel, nullptr);
+ return DND_ACTION_MOVE;
}
-TriState ScPivotLayoutTreeListBase::NotifyMoving(SvTreeListEntry* pTarget, SvTreeListEntry* pSource,
- SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
+sal_Int8 ScPivotLayoutTreeDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
{
- InsertEntryForSourceTarget(pSource, pTarget);
- return TRISTATE_FALSE;
+ weld::TreeView& rWidget = m_rTreeView.get_widget();
+ weld::TreeView* pSource = rWidget.get_drag_source();
+ if (!pSource)
+ return DND_ACTION_NONE;
+
+ std::unique_ptr<weld::TreeIter> xTarget(rWidget.make_iterator());
+ int nTargetPos = -1;
+ if (rWidget.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get()))
+ nTargetPos = rWidget.get_iter_index_in_parent(*xTarget);
+ m_rTreeView.InsertEntryForSourceTarget(*pSource, nTargetPos);
+ return DND_ACTION_MOVE;
}
-TriState ScPivotLayoutTreeListBase::NotifyCopying(SvTreeListEntry* /*pTarget*/, SvTreeListEntry* /*pSource*/,
- SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
+bool ScPivotLayoutTreeListBase::HasEntry(const weld::TreeIter& rEntry)
{
- return TRISTATE_FALSE;
-}
+ std::unique_ptr<weld::TreeIter> xEntry(mxControl->make_iterator());
+ if (!mxControl->get_iter_first(*xEntry))
+ return false;
-bool ScPivotLayoutTreeListBase::HasEntry(const SvTreeListEntry* pEntry)
-{
- SvTreeListEntry* pEachEntry;
- for (pEachEntry = First(); pEachEntry != nullptr; pEachEntry = Next(pEachEntry))
+ do
{
- if(pEachEntry == pEntry)
+ if (mxControl->iter_compare(*xEntry, rEntry))
return true;
- }
+ } while (mxControl->iter_next(*xEntry));
+
return false;
}
void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector& rVector)
{
- SvTreeListEntry* pEachEntry;
- for (pEachEntry = First(); pEachEntry != nullptr; pEachEntry = Next(pEachEntry))
+ std::unique_ptr<weld::TreeIter> xEachEntry(mxControl->make_iterator());
+ if (!mxControl->get_iter_first(*xEachEntry))
+ return;
+ do
{
- ScItemValue* pItemValue = static_cast<ScItemValue*>(pEachEntry->GetUserData());
+ ScItemValue* pItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(*xEachEntry).toInt64());
ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
ScPivotField aField;
@@ -92,46 +95,44 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
aField.mnDupCount = rFunctionData.mnDupCount;
aField.maFieldRef = rFunctionData.maFieldRef;
rVector.push_back(aField);
- }
+ } while (mxControl->iter_next(*xEachEntry));
}
-void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(SvTreeListEntry* /*pSource*/, SvTreeListEntry* /*pTarget*/)
-{}
+void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& /*pSource*/, int /*nTarget*/)
+{
+}
void ScPivotLayoutTreeListBase::RemoveEntryForItem(const ScItemValue* pItemValue)
{
- SvTreeListEntry* pEachEntry;
- for (pEachEntry = First(); pEachEntry != nullptr; pEachEntry = Next(pEachEntry))
- {
- ScItemValue* pEachItemValue = static_cast<ScItemValue*>(pEachEntry->GetUserData());
- if (pEachItemValue == pItemValue)
- {
- GetModel()->Remove(pEachEntry);
- return;
- }
- }
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pItemValue)));
+ int nPos = mxControl->find_id(sId);
+ if (nPos == -1)
+ return;
+ mxControl->remove(nPos);
}
-void ScPivotLayoutTreeListBase::GetFocus()
+IMPL_LINK_NOARG(ScPivotLayoutTreeListBase, GetFocusHdl, weld::Widget&, void)
{
- SvTreeListBox::GetFocus();
-
- if (!mpParent || !mpParent->mpPreviouslyFocusedListBox)
+ if (!mpParent)
return;
+ mpParent->mpPreviouslyFocusedListBox = this;
+}
- if (GetGetFocusFlags() & GetFocusFlags::Mnemonic)
- {
- SvTreeListEntry* pEntry = mpParent->mpPreviouslyFocusedListBox->GetCurEntry();
- if (pEntry)
- InsertEntryForSourceTarget(pEntry, nullptr);
- mpParent->mpPreviouslyFocusedListBox->GrabFocus();
- }
+IMPL_LINK_NOARG(ScPivotLayoutTreeListBase, MnemonicActivateHdl, weld::Widget&, bool)
+{
+ if (!mpParent || !mpParent->mpPreviouslyFocusedListBox)
+ return false;
+ weld::TreeView& rSource = mpParent->mpPreviouslyFocusedListBox->get_widget();
+ int nEntry = rSource.get_cursor_index();
+ if (nEntry != -1)
+ InsertEntryForSourceTarget(rSource, -1);
+ return true;
}
-void ScPivotLayoutTreeListBase::LoseFocus()
+IMPL_LINK_NOARG(ScPivotLayoutTreeListBase, LoseFocusHdl, weld::Widget&, void)
{
- SvTreeListBox::LoseFocus();
- if (mpParent)
- mpParent->mpPreviouslyFocusedListBox = this;
+ if (!mpParent)
+ return;
+ mpParent->mpPreviouslyFocusedListBox = nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
index 1fd8aad531f0..0c5b8d8320a2 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -21,9 +21,6 @@
#include <globstr.hrc>
#include <scresid.hxx>
-VCL_BUILDER_FACTORY_ARGS(ScPivotLayoutTreeListData,
- WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN)
-
namespace
{
@@ -66,18 +63,23 @@ OUString lclCreateDataItemName(const PivotFunc nFunctionMask, const OUString& rN
} // anonymous namespace
-ScPivotLayoutTreeListData::ScPivotLayoutTreeListData(vcl::Window* pParent, WinBits nBits) :
- ScPivotLayoutTreeListBase(pParent, nBits, DATA_LIST)
+ScPivotLayoutTreeListData::ScPivotLayoutTreeListData(std::unique_ptr<weld::TreeView> xControl)
+ : ScPivotLayoutTreeListBase(std::move(xControl))
{
- SetForceMakeVisible(true);
+ mxControl->connect_key_press(LINK(this, ScPivotLayoutTreeListData, KeyInputHdl));
+ mxControl->connect_row_activated(LINK(this, ScPivotLayoutTreeListData, DoubleClickHdl));
}
ScPivotLayoutTreeListData::~ScPivotLayoutTreeListData()
{}
-bool ScPivotLayoutTreeListData::DoubleClickHdl()
+IMPL_LINK_NOARG(ScPivotLayoutTreeListData, DoubleClickHdl, weld::TreeView&, void)
{
- ScItemValue* pCurrentItemValue = static_cast<ScItemValue*>(GetCurEntry()->GetUserData());
+ int nEntry = mxControl->get_cursor_index();
+ if (nEntry == -1)
+ return;
+
+ ScItemValue* pCurrentItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(nEntry).toInt64());
ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData;
SCCOL nCurrentColumn = rCurrentFunctionData.mnCol;
@@ -86,7 +88,7 @@ bool ScPivotLayoutTreeListData::DoubleClickHdl()
ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
ScopedVclPtr<AbstractScDPFunctionDlg> pDialog(
- pFactory->CreateScDPFunctionDlg(GetFrameWeld(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData));
+ pFactory->CreateScDPFunctionDlg(mxControl.get(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData));
if (pDialog->Execute() == RET_OK)
{
@@ -104,15 +106,13 @@ bool ScPivotLayoutTreeListData::DoubleClickHdl()
rDFData.maName,
rCurrentFunctionData.mnDupCount);
- SetEntryText(GetCurEntry(), sDataItemName);
+ mxControl->set_text(nEntry, sDataItemName);
}
-
- return true;
}
void ScPivotLayoutTreeListData::FillDataField(ScPivotFieldVector& rDataFields)
{
- Clear();
+ mxControl->clear();
maDataItemValues.clear();
for (ScPivotField& rField : rDataFields)
@@ -139,16 +139,20 @@ void ScPivotLayoutTreeListData::FillDataField(ScPivotFieldVector& rDataFields)
pItemValue->maFunctionData.mnDupCount);
maDataItemValues.push_back(std::unique_ptr<ScItemValue>(pItemValue));
- InsertEntry(sDataItemName, nullptr, false, TREELIST_APPEND, pItemValue);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pItemValue)));
+ mxControl->append(sId, sDataItemName);
}
}
void ScPivotLayoutTreeListData::PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames)
{
- SvTreeListEntry* pLoopEntry;
- for (pLoopEntry = First(); pLoopEntry != nullptr; pLoopEntry = Next(pLoopEntry))
+ std::unique_ptr<weld::TreeIter> xLoopEntry(mxControl->make_iterator());
+ if (!mxControl->get_iter_first(*xLoopEntry))
+ return;
+
+ do
{
- ScItemValue* pEachItemValue = static_cast<ScItemValue*>(pLoopEntry->GetUserData());
+ ScItemValue* pEachItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(*xLoopEntry).toInt64());
SCCOL nColumn = pEachItemValue->maFunctionData.mnCol;
ScDPLabelData& rLabelData = mpParent->GetLabelData(nColumn);
@@ -166,31 +170,30 @@ void ScPivotLayoutTreeListData::PushDataFieldNames(std::vector<ScDPName>& rDataF
}
rDataFieldNames.emplace_back(rLabelData.maName, sLayoutName, rLabelData.mnDupCount);
- }
+ } while (mxControl->iter_next(*xLoopEntry));
}
-void ScPivotLayoutTreeListData::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget)
+void ScPivotLayoutTreeListData::InsertEntryForSourceTarget(weld::TreeView& rSource, int nTarget)
{
- ScItemValue* pItemValue = static_cast<ScItemValue*>(pSource->GetUserData());
+ ScItemValue* pItemValue = reinterpret_cast<ScItemValue*>(rSource.get_selected_id().toInt64());
if (mpParent->IsDataElement(pItemValue->maFunctionData.mnCol))
return;
- if (HasEntry(pSource))
+ if (&rSource == mxControl.get())
{
- OUString rText = GetEntryText(pSource);
- GetModel()->Remove(pSource);
- sal_uLong nPosition = (pTarget == nullptr) ? TREELIST_APPEND : GetModel()->GetAbsPos(pTarget) + 1;
- InsertEntry(rText, nullptr, false, nPosition, pItemValue);
+ OUString sText = mxControl->get_selected_text();
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pItemValue)));
+ mxControl->remove_id(sId);
+ mxControl->insert(nullptr, nTarget, &sText, &sId, nullptr, nullptr, nullptr, false, nullptr);
}
else
{
- sal_uLong nPosition = (pTarget == nullptr) ? TREELIST_APPEND : GetModel()->GetAbsPos(pTarget) + 1;
- InsertEntryForItem(pItemValue->mpOriginalItemValue, nPosition);
+ InsertEntryForItem(pItemValue->mpOriginalItemValue, nTarget);
}
}
-void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition)
+void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, int nPosition)
{
ScItemValue* pDataItemValue = new ScItemValue(pItemValue);
pDataItemValue->mpOriginalItemValue = pItemValue;
@@ -211,7 +214,8 @@ void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_
pDataItemValue->maName,
rFunctionData.mnDupCount);
- InsertEntry(sDataName, nullptr, false, nPosition, pDataItemValue);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDataItemValue)));
+ mxControl->insert(nullptr, nPosition, &sDataName, &sId, nullptr, nullptr, nullptr, false, nullptr);
}
void ScPivotLayoutTreeListData::AdjustDuplicateCount(ScItemValue* pInputItemValue)
@@ -223,10 +227,12 @@ void ScPivotLayoutTreeListData::AdjustDuplicateCount(ScItemValue* pInputItemValu
rInputFunctionData.mnDupCount = 0;
sal_uInt8 nMaxDuplicateCount = 0;
- SvTreeListEntry* pEachEntry;
- for (pEachEntry = First(); pEachEntry != nullptr; pEachEntry = Next(pEachEntry))
+ std::unique_ptr<weld::TreeIter> xEachEntry(mxControl->make_iterator());
+ if (!mxControl->get_iter_first(*xEachEntry))
+ return;
+ do
{
- ScItemValue* pItemValue = static_cast<ScItemValue*>(pEachEntry->GetUserData());
+ ScItemValue* pItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(*xEachEntry).toInt64());
if (pItemValue == pInputItemValue)
continue;
@@ -239,7 +245,7 @@ void ScPivotLayoutTreeListData::AdjustDuplicateCount(ScItemValue* pInputItemValu
if(rFunctionData.mnDupCount > nMaxDuplicateCount)
nMaxDuplicateCount = rFunctionData.mnDupCount;
}
- }
+ } while (mxControl->iter_next(*xEachEntry));
if(bFoundDuplicate)
{
@@ -247,20 +253,20 @@ void ScPivotLayoutTreeListData::AdjustDuplicateCount(ScItemValue* pInputItemValu
}
}
-void ScPivotLayoutTreeListData::KeyInput(const KeyEvent& rKeyEvent)
+IMPL_LINK(ScPivotLayoutTreeListData, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
sal_uInt16 nCode = aCode.GetCode();
if (nCode == KEY_DELETE)
{
- const SvTreeListEntry* pEntry = GetCurEntry();
- if (pEntry)
- GetModel()->Remove(pEntry);
- return;
+ int nEntry = mxControl->get_cursor_index();
+ if (nEntry != -1)
+ mxControl->remove(nEntry);
+ return true;
}
- SvTreeListBox::KeyInput(rKeyEvent);
+ return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
index 82cfc0ec9bd7..d09afc5c759f 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
@@ -18,14 +18,11 @@
#include <vcl/treelistentry.hxx>
#include <pivot.hxx>
-VCL_BUILDER_FACTORY_ARGS(ScPivotLayoutTreeListLabel,
- WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN);
-
-ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(vcl::Window* pParent, WinBits nBits)
- : ScPivotLayoutTreeListBase(pParent, nBits, LABEL_LIST)
+ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(std::unique_ptr<weld::TreeView> xControl)
+ : ScPivotLayoutTreeListBase(std::move(xControl), LABEL_LIST)
, maDataItem(0)
{
- SetForceMakeVisible(true);
+ mxControl->connect_key_press(LINK(this, ScPivotLayoutTreeListLabel, KeyInputHdl));
}
ScPivotLayoutTreeListLabel::~ScPivotLayoutTreeListLabel()
@@ -33,7 +30,7 @@ ScPivotLayoutTreeListLabel::~ScPivotLayoutTreeListLabel()
void ScPivotLayoutTreeListLabel::FillLabelFields(ScDPLabelDataVector& rLabelVector)
{
- Clear();
+ mxControl->clear();
maItemValues.clear();
for (std::unique_ptr<ScDPLabelData> const & pLabelData : rLabelVector)
@@ -47,17 +44,16 @@ void ScPivotLayoutTreeListLabel::FillLabelFields(ScDPLabelDataVector& rLabelVect
if (pLabelData->mnOriginalDim < 0 && !pLabelData->mbDataLayout)
{
- SvTreeListEntry* pEntry = InsertEntry(pLabelData->maName);
- pEntry->SetUserData(pValue);
+ mxControl->append(OUString::number(reinterpret_cast<sal_Int64>(pValue)), pLabelData->maName);
}
}
}
-void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* /*pTarget*/)
+void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(weld::TreeView& rSource, int /*nTarget*/)
{
- ScPivotLayoutTreeListBase *pSourceTree = mpParent->FindListBoxFor(pSource);
- if (pSourceTree)
- pSourceTree->RemoveSelection();
+ if (&rSource == mxControl.get())
+ return;
+ rSource.remove(rSource.get_selected_index());
}
bool ScPivotLayoutTreeListLabel::IsDataElement(SCCOL nColumn)
@@ -72,20 +68,20 @@ ScItemValue* ScPivotLayoutTreeListLabel::GetItem(SCCOL nColumn)
return maItemValues[nColumn].get();
}
-void ScPivotLayoutTreeListLabel::KeyInput(const KeyEvent& rKeyEvent)
+IMPL_LINK(ScPivotLayoutTreeListLabel, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
sal_uInt16 nCode = aCode.GetCode();
if (nCode == KEY_DELETE)
{
- const SvTreeListEntry* pEntry = GetCurEntry();
- if (pEntry)
- GetModel()->Remove(pEntry);
- return;
+ int nEntry = mxControl->get_cursor_index();
+ if (nEntry != -1)
+ mxControl->remove(nEntry);
+ return true;
}
- SvTreeListBox::KeyInput(rKeyEvent);
+ return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 7d93d84c5e5e..a082dbfdd544 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -234,7 +234,7 @@ namespace
}
ScDPFunctionDlg::ScDPFunctionDlg(
- weld::Window* pParent, const ScDPLabelDataVector& rLabelVec,
+ weld::Widget* pParent, const ScDPLabelDataVector& rLabelVec,
const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData)
: GenericDialogController(pParent, "modules/scalc/ui/datafielddialog.ui", "DataFieldDialog")
, mxLbFunc(new ScDPFunctionListBox(m_xBuilder->weld_tree_view("functions")))
@@ -443,7 +443,7 @@ IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, weld::TreeView&, void)
m_xDialog->response(RET_OK);
}
-ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Window* pParent, ScDPObject& rDPObj,
+ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Widget* pParent, ScDPObject& rDPObj,
const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields, bool bEnableLayout)
: GenericDialogController(pParent, "modules/scalc/ui/pivotfielddialog.ui", "PivotFieldDialog")