Kaydet (Commit) ce31d3cd authored tarafından Caolán McNamara's avatar Caolán McNamara

weld ScDPSubtotalDlg

Change-Id: I33403031421a9f372c240cddea320591ac72bfc2
Reviewed-on: https://gerrit.libreoffice.org/67878
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst dfdd717c
......@@ -476,11 +476,11 @@ public:
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData ) = 0;
virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg( vcl::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields ) = 0;
virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg(weld::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields) = 0;
virtual VclPtr<AbstractScDPNumGroupDlg> CreateScDPNumGroupDlg(weld::Window* pParent,
const ScDPNumGroupInfo& rInfo) = 0;
......
......@@ -167,7 +167,11 @@ short AbstractScNamePasteDlg_Impl::Execute()
IMPL_ABSTDLG_BASE(AbstractScPivotFilterDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPFunctionDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPSubtotalDlg_Impl);
short AbstractScDPSubtotalDlg_Impl::Execute()
{
return m_xDlg->run();
}
short AbstractScDPNumGroupDlg_Impl::Execute()
{
......@@ -615,12 +619,12 @@ css::sheet::DataPilotFieldReference AbstractScDPFunctionDlg_Impl::GetFieldRef()
PivotFunc AbstractScDPSubtotalDlg_Impl::GetFuncMask() const
{
return pDlg->GetFuncMask();
return m_xDlg->GetFuncMask();
}
void AbstractScDPSubtotalDlg_Impl::FillLabelData( ScDPLabelData& rLabelData ) const
{
pDlg->FillLabelData( rLabelData );
m_xDlg->FillLabelData( rLabelData );
}
ScDPNumGroupInfo AbstractScDPNumGroupDlg_Impl::GetGroupInfo() const
......@@ -915,14 +919,13 @@ VclPtr<AbstractScDPFunctionDlg> ScAbstractDialogFactory_Impl::CreateScDPFunction
return VclPtr<AbstractScDPFunctionDlg_Impl>::Create( pDlg );
}
VclPtr<AbstractScDPSubtotalDlg> ScAbstractDialogFactory_Impl::CreateScDPSubtotalDlg ( vcl::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields )
VclPtr<AbstractScDPSubtotalDlg> ScAbstractDialogFactory_Impl::CreateScDPSubtotalDlg(weld::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields)
{
VclPtr<ScDPSubtotalDlg> pDlg = VclPtr<ScDPSubtotalDlg>::Create( pParent, rDPObj, rLabelData, rFuncData, rDataFields, true/*bEnableLayout*/ );
return VclPtr<AbstractScDPSubtotalDlg_Impl>::Create( pDlg );
return VclPtr<AbstractScDPSubtotalDlg_Impl>::Create(std::make_unique<ScDPSubtotalDlg>(pParent, rDPObj, rLabelData, rFuncData, rDataFields, true/*bEnableLayout*/));
}
VclPtr<AbstractScDPNumGroupDlg> ScAbstractDialogFactory_Impl::CreateScDPNumGroupDlg(weld::Window* pParent, const ScDPNumGroupInfo& rInfo)
......
......@@ -399,7 +399,13 @@ class AbstractScDPFunctionDlg_Impl : public AbstractScDPFunctionDlg
class AbstractScDPSubtotalDlg_Impl : public AbstractScDPSubtotalDlg
{
DECL_ABSTDLG_BASE( AbstractScDPSubtotalDlg_Impl, ScDPSubtotalDlg)
std::unique_ptr<ScDPSubtotalDlg> m_xDlg;
public:
explicit AbstractScDPSubtotalDlg_Impl(std::unique_ptr<ScDPSubtotalDlg> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
virtual PivotFunc GetFuncMask() const override;
virtual void FillLabelData( ScDPLabelData& rLabelData ) const override;
};
......@@ -664,11 +670,11 @@ public:
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData ) override;
virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg( vcl::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields ) override;
virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg(weld::Window* pParent,
ScDPObject& rDPObj,
const ScDPLabelData& rLabelData,
const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields ) override;
virtual VclPtr<AbstractScDPNumGroupDlg> CreateScDPNumGroupDlg(weld::Window* pParent,
const ScDPNumGroupInfo& rInfo) override;
......
......@@ -57,7 +57,7 @@ bool ScPivotLayoutTreeList::DoubleClickHdl()
mpParent->PushDataFieldNames(aDataFieldNames);
ScopedVclPtr<AbstractScDPSubtotalDlg> pDialog(
pFactory->CreateScDPSubtotalDlg(this, mpParent->maPivotTableObject, rCurrentLabelData, rCurrentFunctionData, aDataFieldNames));
pFactory->CreateScDPSubtotalDlg(GetFrameWeld(), mpParent->maPivotTableObject, rCurrentLabelData, rCurrentFunctionData, aDataFieldNames));
if (pDialog->Execute() == RET_OK)
{
......
......@@ -203,6 +203,48 @@ void ScDPFunctionListBox::FillFunctionNames()
assert(GetEntryCount() == SAL_N_ELEMENTS(spnFunctions));
}
DPFunctionListBox::DPFunctionListBox(std::unique_ptr<weld::TreeView> xControl)
: m_xControl(std::move(xControl))
{
FillFunctionNames();
}
void DPFunctionListBox::SetSelection( PivotFunc nFuncMask )
{
if( (nFuncMask == PivotFunc::NONE) || (nFuncMask == PivotFunc::Auto) )
m_xControl->unselect_all();
else
{
for( sal_Int32 nEntry = 0, nCount = m_xControl->n_children(); nEntry < nCount; ++nEntry )
{
if (bool(nFuncMask & spnFunctions[ nEntry ]))
m_xControl->select(nEntry);
else
m_xControl->unselect(nEntry);
}
}
}
PivotFunc DPFunctionListBox::GetSelection() const
{
PivotFunc nFuncMask = PivotFunc::NONE;
std::vector<int> aRows = m_xControl->get_selected_rows();
for (int nSel : aRows)
nFuncMask |= spnFunctions[nSel];
return nFuncMask;
}
void DPFunctionListBox::FillFunctionNames()
{
OSL_ENSURE( !m_xControl->n_children(), "ScDPMultiFuncListBox::FillFunctionNames - do not add texts to resource" );
m_xControl->clear();
m_xControl->freeze();
for (size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(SCSTR_DPFUNCLISTBOX); ++nIndex)
m_xControl->append_text(ScResId(SCSTR_DPFUNCLISTBOX[nIndex]));
m_xControl->thaw();
assert(m_xControl->n_children() == SAL_N_ELEMENTS(spnFunctions));
}
ScDPFunctionDlg::ScDPFunctionDlg(
vcl::Window* pParent, const ScDPLabelDataVector& rLabelVec,
const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData)
......@@ -433,56 +475,40 @@ IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, ListBox&, void)
mpBtnOk->Click();
}
ScDPSubtotalDlg::ScDPSubtotalDlg( vcl::Window* pParent, ScDPObject& rDPObj,
ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Window* pParent, ScDPObject& rDPObj,
const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields, bool bEnableLayout )
: ModalDialog(pParent, "PivotFieldDialog",
"modules/scalc/ui/pivotfielddialog.ui")
const ScDPNameVec& rDataFields, bool bEnableLayout)
: GenericDialogController(pParent, "modules/scalc/ui/pivotfielddialog.ui", "PivotFieldDialog")
, mrDPObj(rDPObj)
, mrDataFields(rDataFields)
, maLabelData(rLabelData)
, mbEnableLayout(bEnableLayout)
, mxRbNone(m_xBuilder->weld_radio_button("none"))
, mxRbAuto(m_xBuilder->weld_radio_button("auto"))
, mxRbUser(m_xBuilder->weld_radio_button("user"))
, mxLbFunc(new DPFunctionListBox(m_xBuilder->weld_tree_view("functions")))
, mxFtName(m_xBuilder->weld_label("name"))
, mxCbShowAll(m_xBuilder->weld_check_button("showall"))
, mxBtnOk(m_xBuilder->weld_button("ok"))
, mxBtnOptions(m_xBuilder->weld_button("options"))
{
get(mpBtnOk, "ok");
get(mpBtnOptions, "options");
get(mpCbShowAll, "showall");
get(mpFtName, "name");
get(mpLbFunc, "functions");
mpLbFunc->EnableMultiSelection(true);
mpLbFunc->set_height_request(mpLbFunc->GetTextHeight() * 8);
get(mpRbNone, "none");
get(mpRbAuto, "auto");
get(mpRbUser, "user");
Init( rLabelData, rFuncData );
mxLbFunc->set_selection_mode(SelectionMode::Multiple);
mxLbFunc->set_size_request(-1, mxLbFunc->get_height_rows(8));
Init(rLabelData, rFuncData);
}
ScDPSubtotalDlg::~ScDPSubtotalDlg()
{
disposeOnce();
}
void ScDPSubtotalDlg::dispose()
{
mpRbNone.clear();
mpRbAuto.clear();
mpRbUser.clear();
mpLbFunc.clear();
mpFtName.clear();
mpCbShowAll.clear();
mpBtnOk.clear();
mpBtnOptions.clear();
ModalDialog::dispose();
}
PivotFunc ScDPSubtotalDlg::GetFuncMask() const
{
PivotFunc nFuncMask = PivotFunc::NONE;
if( mpRbAuto->IsChecked() )
if (mxRbAuto->get_active())
nFuncMask = PivotFunc::Auto;
else if( mpRbUser->IsChecked() )
nFuncMask = mpLbFunc->GetSelection();
else if (mxRbUser->get_active())
nFuncMask = mxLbFunc->GetSelection();
return nFuncMask;
}
......@@ -491,7 +517,7 @@ void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
{
rLabelData.mnFuncMask = GetFuncMask();
rLabelData.mnUsedHier = maLabelData.mnUsedHier;
rLabelData.mbShowAll = mpCbShowAll->IsChecked();
rLabelData.mbShowAll = mxCbShowAll->get_active();
rLabelData.maMembers = maLabelData.maMembers;
rLabelData.maSortInfo = maLabelData.maSortInfo;
rLabelData.maLayoutInfo = maLabelData.maLayoutInfo;
......@@ -502,49 +528,49 @@ void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData )
{
// field name
mpFtName->SetText(rLabelData.getDisplayName());
mxFtName->set_label(rLabelData.getDisplayName());
// radio buttons
mpRbNone->SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
mpRbAuto->SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
mpRbUser->SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
mxRbNone->connect_clicked( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
mxRbAuto->connect_clicked( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
mxRbUser->connect_clicked( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
RadioButton* pRBtn = nullptr;
weld::RadioButton* pRBtn = nullptr;
switch( rFuncData.mnFuncMask )
{
case PivotFunc::NONE: pRBtn = mpRbNone; break;
case PivotFunc::Auto: pRBtn = mpRbAuto; break;
default: pRBtn = mpRbUser;
case PivotFunc::NONE: pRBtn = mxRbNone.get(); break;
case PivotFunc::Auto: pRBtn = mxRbAuto.get(); break;
default: pRBtn = mxRbUser.get();
}
pRBtn->Check();
RadioClickHdl( pRBtn );
pRBtn->set_active(true);
RadioClickHdl(*pRBtn);
// list box
mpLbFunc->SetSelection( rFuncData.mnFuncMask );
mpLbFunc->SetDoubleClickHdl( LINK( this, ScDPSubtotalDlg, DblClickHdl ) );
mxLbFunc->SetSelection( rFuncData.mnFuncMask );
mxLbFunc->connect_row_activated( LINK( this, ScDPSubtotalDlg, DblClickHdl ) );
// show all
mpCbShowAll->Check( rLabelData.mbShowAll );
mxCbShowAll->set_active( rLabelData.mbShowAll );
// options
mpBtnOptions->SetClickHdl( LINK( this, ScDPSubtotalDlg, ClickHdl ) );
mxBtnOptions->connect_clicked( LINK( this, ScDPSubtotalDlg, ClickHdl ) );
}
IMPL_LINK( ScDPSubtotalDlg, RadioClickHdl, Button*, pBtn, void )
IMPL_LINK(ScDPSubtotalDlg, RadioClickHdl, weld::Button&, rBtn, void)
{
mpLbFunc->Enable( pBtn == mpRbUser );
mxLbFunc->set_sensitive(&rBtn == mxRbUser.get());
}
IMPL_LINK_NOARG(ScDPSubtotalDlg, DblClickHdl, ListBox&, void)
IMPL_LINK_NOARG(ScDPSubtotalDlg, DblClickHdl, weld::TreeView&, void)
{
mpBtnOk->Click();
m_xDialog->response(RET_OK);
}
IMPL_LINK( ScDPSubtotalDlg, ClickHdl, Button*, pBtn, void )
IMPL_LINK(ScDPSubtotalDlg, ClickHdl, weld::Button&, rBtn, void)
{
if (pBtn == mpBtnOptions)
if (&rBtn == mxBtnOptions.get())
{
ScDPSubtotalOptDlg aDlg(GetFrameWeld(), mrDPObj, maLabelData, mrDataFields, mbEnableLayout);
ScDPSubtotalOptDlg aDlg(m_xDialog.get(), mrDPObj, maLabelData, mrDataFields, mbEnableLayout);
if (aDlg.run() == RET_OK)
aDlg.FillLabelData(maLabelData);
}
......
......@@ -53,6 +53,25 @@ private:
void FillFunctionNames();
};
class DPFunctionListBox
{
public:
DPFunctionListBox(std::unique_ptr<weld::TreeView> xControl);
void SetSelection( PivotFunc nFuncMask );
PivotFunc GetSelection() const;
void set_sensitive(bool sensitive) { m_xControl->set_sensitive(sensitive); }
void set_selection_mode(SelectionMode eMode) { m_xControl->set_selection_mode(eMode); }
void connect_row_activated(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_row_activated(rLink); }
int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); }
void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); }
private:
std::unique_ptr<weld::TreeView> m_xControl;
void FillFunctionNames();
};
class ScDPFunctionDlg : public ModalDialog
{
typedef std::unordered_map< OUString, OUString > NameMapType;
......@@ -95,14 +114,13 @@ private:
bool mbEmptyItem; /// true = Empty base item in listbox.
};
class ScDPSubtotalDlg : public ModalDialog
class ScDPSubtotalDlg : public weld::GenericDialogController
{
public:
explicit ScDPSubtotalDlg( vcl::Window* pParent, ScDPObject& rDPObj,
explicit ScDPSubtotalDlg(weld::Window* pParent, ScDPObject& rDPObj,
const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields, bool bEnableLayout );
const ScDPNameVec& rDataFields, bool bEnableLayout);
virtual ~ScDPSubtotalDlg() override;
virtual void dispose() override;
PivotFunc GetFuncMask() const;
void FillLabelData( ScDPLabelData& rLabelData ) const;
......@@ -110,25 +128,25 @@ public:
private:
void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
DECL_LINK( DblClickHdl, ListBox&, void );
DECL_LINK( RadioClickHdl, Button*, void );
DECL_LINK( ClickHdl, Button*, void );
DECL_LINK( DblClickHdl, weld::TreeView&, void );
DECL_LINK( RadioClickHdl, weld::Button&, void );
DECL_LINK( ClickHdl, weld::Button&, void );
private:
VclPtr<RadioButton> mpRbNone;
VclPtr<RadioButton> mpRbAuto;
VclPtr<RadioButton> mpRbUser;
VclPtr<ScDPFunctionListBox> mpLbFunc;
VclPtr<FixedText> mpFtName;
VclPtr<CheckBox> mpCbShowAll;
VclPtr<OKButton> mpBtnOk;
VclPtr<PushButton> mpBtnOptions;
ScDPObject& mrDPObj; /// The DataPilot object (for member names).
const ScDPNameVec& mrDataFields; /// The list of all data field names.
ScDPLabelData maLabelData; /// Cache for sub dialog.
bool mbEnableLayout; /// true = Enable Layout mode controls.
std::unique_ptr<weld::RadioButton> mxRbNone;
std::unique_ptr<weld::RadioButton> mxRbAuto;
std::unique_ptr<weld::RadioButton> mxRbUser;
std::unique_ptr<DPFunctionListBox> mxLbFunc;
std::unique_ptr<weld::Label> mxFtName;
std::unique_ptr<weld::CheckButton> mxCbShowAll;
std::unique_ptr<weld::Button> mxBtnOk;
std::unique_ptr<weld::Button> mxBtnOptions;
};
class ScDPSubtotalOptDlg : public weld::GenericDialogController
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment