summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-13 19:23:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-14 15:54:08 +0200
commitc3bca577807d7cbd93ce8c66aab8798de45bef16 (patch)
treec320c4ae892ea79f7353486ebde03c667d03368a /sc/source/ui/dbgui
parent6154489314d2f2bf9cb99b72f15c79dd48a1da14 (diff)
weld ScConsolidateDlg
Change-Id: I7d52aea1917503a37cdc7d1ae16d7d2377397f30 Reviewed-on: https://gerrit.libreoffice.org/70714 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/consdlg.cxx415
1 files changed, 195 insertions, 220 deletions
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
index c2138dd89ffe..127d18dfde66 100644
--- a/sc/source/ui/dbgui/consdlg.cxx
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -64,77 +64,48 @@ public:
OUString aStrArea;
};
-ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent,
- const SfxItemSet& rArgSet )
-
- : ScAnyRefDlg ( pB, pCW, pParent, "ConsolidateDialog" , "modules/scalc/ui/consolidatedialog.ui" ),
- aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
- theConsData ( static_cast<const ScConsolidateItem&>(
- rArgSet.Get( rArgSet.GetPool()->
- GetWhich( SID_CONSOLIDATE ) )
- ).GetData() ),
- rViewData ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
- GetViewData() ),
- pDoc ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
- GetViewData().GetDocument() ),
- pRangeUtil ( new ScRangeUtil ),
- nAreaDataCount ( 0 ),
- nWhichCons ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) ),
- bDlgLostFocus ( false )
+ScConsolidateDlg::ScConsolidateDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
+ const SfxItemSet& rArgSet)
+
+ : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/consolidatedialog.ui", "ConsolidateDialog")
+ , aStrUndefined ( ScResId( SCSTR_UNDEFINED ) )
+ , theConsData ( static_cast<const ScConsolidateItem&>(
+ rArgSet.Get( rArgSet.GetPool()->
+ GetWhich( SID_CONSOLIDATE ) )
+ ).GetData() )
+ , rViewData ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
+ GetViewData() )
+ , pDoc ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
+ GetViewData().GetDocument() )
+ , pRangeUtil ( new ScRangeUtil )
+ , nAreaDataCount ( 0 )
+ , nWhichCons ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) )
+ , bDlgLostFocus ( false )
+ , m_xLbFunc(m_xBuilder->weld_combo_box("func"))
+ , m_xLbConsAreas(m_xBuilder->weld_tree_view("consareas"))
+ , m_xLbDataArea(m_xBuilder->weld_combo_box("lbdataarea"))
+ , m_xEdDataArea(new formula::WeldRefEdit(m_xBuilder->weld_entry("eddataarea")))
+ , m_xRbDataArea(new formula::WeldRefButton(m_xBuilder->weld_button("rbdataarea")))
+ , m_xLbDestArea(m_xBuilder->weld_combo_box("lbdestarea"))
+ , m_xEdDestArea(new formula::WeldRefEdit(m_xBuilder->weld_entry("eddestarea")))
+ , m_xRbDestArea(new formula::WeldRefButton(m_xBuilder->weld_button("rbdestarea")))
+ , m_xExpander(m_xBuilder->weld_expander("more"))
+ , m_xBtnByRow(m_xBuilder->weld_check_button("byrow"))
+ , m_xBtnByCol(m_xBuilder->weld_check_button("bycol"))
+ , m_xBtnRefs(m_xBuilder->weld_check_button("refs"))
+ , m_xBtnOk(m_xBuilder->weld_button("ok"))
+ , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
+ , m_xBtnAdd(m_xBuilder->weld_button("add"))
+ , m_xBtnRemove(m_xBuilder->weld_button("delete"))
+ , m_xDataFT(m_xBuilder->weld_label("ftdataarea"))
+ , m_xDestFT(m_xBuilder->weld_label("ftdestarea"))
{
- get(pLbFunc,"func");
- get(pLbConsAreas,"consareas");
-
- get(pLbDataArea,"lbdataarea");
- get(pEdDataArea,"eddataarea");
- get(pRbDataArea,"rbdataarea");
-
- pRefInputEdit = pEdDataArea;
-
- get(pLbDestArea,"lbdestarea");
- get(pEdDestArea,"eddestarea");
- get(pRbDestArea,"rbdestarea");
-
- get(pExpander,"more");
- get(pBtnByRow,"byrow");
- get(pBtnByCol,"bycol");
- get(pBtnRefs,"refs");
-
- get(pBtnOk,"ok");
- get(pBtnCancel,"cancel");
- get(pBtnAdd,"add");
- get(pBtnRemove,"delete");
-
+ m_pRefInputEdit = m_xEdDataArea.get();
Init();
}
ScConsolidateDlg::~ScConsolidateDlg()
{
- disposeOnce();
-}
-
-void ScConsolidateDlg::dispose()
-{
- pAreaData.reset();
- pRangeUtil.reset();
- pLbFunc.clear();
- pLbConsAreas.clear();
- pLbDataArea.clear();
- pEdDataArea.clear();
- pRbDataArea.clear();
- pLbDestArea.clear();
- pEdDestArea.clear();
- pRbDestArea.clear();
- pExpander.clear();
- pBtnByRow.clear();
- pBtnByCol.clear();
- pBtnRefs.clear();
- pBtnOk.clear();
- pBtnCancel.clear();
- pBtnAdd.clear();
- pBtnRemove.clear();
- pRefInputEdit.clear();
- ScAnyRefDlg::dispose();
}
void ScConsolidateDlg::Init()
@@ -144,43 +115,46 @@ void ScConsolidateDlg::Init()
OUString aStr;
sal_uInt16 i=0;
- pRbDataArea->SetReferences(this, pEdDataArea);
- pEdDataArea->SetReferences(this, get<FixedText>("ftdataarea"));
- pRbDestArea->SetReferences(this, pEdDestArea);
- pEdDestArea->SetReferences(this, get<FixedText>("ftdestarea"));
-
- pEdDataArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
- pEdDestArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
- pLbDataArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
- pLbDestArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
- pEdDataArea ->SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
- pEdDestArea ->SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
- pLbConsAreas->SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
- pLbDataArea ->SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
- pLbDestArea ->SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
- pBtnOk ->SetClickHdl ( LINK( this, ScConsolidateDlg, OkHdl ) );
- pBtnCancel ->SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
- pBtnAdd ->SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
- pBtnRemove ->SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
-
- pBtnAdd->Disable();
- pBtnRemove->Disable();
-
- pBtnByRow->Check( theConsData.bByRow );
- pBtnByCol->Check( theConsData.bByCol );
- pBtnRefs->Check( theConsData.bReferenceData );
-
- pLbFunc->SelectEntryPos( FuncToLbPos( theConsData.eFunction ) );
-
- // Hack: pLbConsAreas used to be MultiLB. We don't have VCL builder equivalent
- // of it yet. So enable selecting multiple items here
- pLbConsAreas->EnableMultiSelection( true );
-
- pLbConsAreas->set_width_request(pLbConsAreas->approximate_char_width() * 16);
- pLbConsAreas->SetDropDownLineCount(5);
+ m_xRbDataArea->SetReferences(this, m_xEdDataArea.get());
+ m_xEdDataArea->SetReferences(this, m_xDataFT.get());
+ m_xRbDestArea->SetReferences(this, m_xEdDestArea.get());
+ m_xEdDestArea->SetReferences(this, m_xDestFT.get());
+
+ m_xEdDataArea->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetEditFocusHdl ) );
+ m_xEdDestArea->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetEditFocusHdl ) );
+ m_xEdDataArea->SetLoseFocusHdl( LINK( this, ScConsolidateDlg, LoseEditFocusHdl ) );
+ m_xEdDestArea->SetLoseFocusHdl( LINK( this, ScConsolidateDlg, LoseEditFocusHdl ) );
+ m_xRbDataArea->SetLoseFocusHdl( LINK( this, ScConsolidateDlg, LoseButtonFocusHdl ) );
+ m_xRbDestArea->SetLoseFocusHdl( LINK( this, ScConsolidateDlg, LoseButtonFocusHdl ) );
+ m_xLbDataArea->connect_focus_in( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ m_xLbDestArea->connect_focus_in( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ m_xLbDataArea->connect_focus_out( LINK( this, ScConsolidateDlg, LoseFocusHdl ) );
+ m_xLbDestArea->connect_focus_out( LINK( this, ScConsolidateDlg, LoseFocusHdl ) );
+ m_xEdDataArea->SetModifyHdl( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ m_xEdDestArea->SetModifyHdl( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ m_xLbConsAreas->connect_changed( LINK( this, ScConsolidateDlg, SelectTVHdl ) );
+ m_xLbDataArea->connect_changed( LINK( this, ScConsolidateDlg, SelectCBHdl ) );
+ m_xLbDestArea->connect_changed( LINK( this, ScConsolidateDlg, SelectCBHdl ) );
+ m_xBtnOk->connect_clicked( LINK( this, ScConsolidateDlg, OkHdl ) );
+ m_xBtnCancel->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ m_xBtnAdd->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ m_xBtnRemove->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
+
+ m_xBtnAdd->set_sensitive(false);
+ m_xBtnRemove->set_sensitive(false);
+
+ m_xBtnByRow->set_active( theConsData.bByRow );
+ m_xBtnByCol->set_active( theConsData.bByCol );
+ m_xBtnRefs->set_active( theConsData.bReferenceData );
+
+ m_xLbFunc->set_active( FuncToLbPos( theConsData.eFunction ) );
+
+ m_xLbConsAreas->set_selection_mode(SelectionMode::Multiple);
+ m_xLbConsAreas->set_size_request(m_xLbConsAreas->get_approximate_digit_width() * 16,
+ m_xLbConsAreas->get_height_rows(5));
// read consolidation areas
- pLbConsAreas->Clear();
+ m_xLbConsAreas->clear();
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
for ( i=0; i<theConsData.nDataAreaCount; i++ )
{
@@ -190,7 +164,7 @@ void ScConsolidateDlg::Init()
aStr = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format(
ScRefFlags::RANGE_ABS_3D, pDoc, eConv );
- pLbConsAreas->InsertEntry( aStr );
+ m_xLbConsAreas->append_text(aStr);
}
}
@@ -198,10 +172,10 @@ void ScConsolidateDlg::Init()
{
aStr = ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
).Format( ScRefFlags::ADDR_ABS_3D, pDoc, eConv );
- pEdDestArea->SetText( aStr );
+ m_xEdDestArea->SetText( aStr );
}
else
- pEdDestArea->SetText(OUString());
+ m_xEdDestArea->SetText(OUString());
// Use the ScAreaData helper class to save those range names from the
// RangeNames and database ranges that appear in the ListBoxes.
@@ -230,23 +204,23 @@ void ScConsolidateDlg::Init()
}
FillAreaLists();
- ModifyHdl( *pEdDestArea );
- pLbDataArea->SelectEntryPos( 0 );
- pEdDataArea->SetText(OUString());
- pEdDataArea->GrabFocus();
+ ModifyHdl( *m_xEdDestArea );
+ m_xLbDataArea->set_active( 0 );
+ m_xEdDataArea->SetText(OUString());
+ m_xEdDataArea->GrabFocus();
//aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
//@BugID 54702 enable/disable only in base class
- //SFX_APPWINDOW->Enable();
+ //SFX_APPWINDOW->set_sensitive(true);
}
void ScConsolidateDlg::FillAreaLists()
{
- pLbDataArea->Clear();
- pLbDestArea->Clear();
- pLbDataArea->InsertEntry( aStrUndefined );
- pLbDestArea->InsertEntry( aStrUndefined );
+ m_xLbDataArea->clear();
+ m_xLbDestArea->clear();
+ m_xLbDataArea->append_text( aStrUndefined );
+ m_xLbDestArea->append_text( aStrUndefined );
if ( pRangeUtil && pAreaData && (nAreaDataCount > 0) )
{
@@ -254,10 +228,8 @@ void ScConsolidateDlg::FillAreaLists()
(i<nAreaDataCount) && (!pAreaData[i].aStrName.isEmpty());
i++ )
{
- pLbDataArea->InsertEntry( pAreaData[i].aStrName, i+1 );
-
-// if ( !pAreaData[i].bIsDbArea )
- pLbDestArea->InsertEntry( pAreaData[i].aStrName, i+1 );
+ m_xLbDataArea->append_text(pAreaData[i].aStrName);
+ m_xLbDestArea->append_text(pAreaData[i].aStrName);
}
}
}
@@ -267,10 +239,10 @@ void ScConsolidateDlg::FillAreaLists()
void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
{
- if ( pRefInputEdit )
+ if ( m_pRefInputEdit )
{
if ( rRef.aStart != rRef.aEnd )
- RefInputStart( pRefInputEdit );
+ RefInputStart( m_pRefInputEdit );
OUString aStr;
ScRefFlags nFmt = ScRefFlags::RANGE_ABS_3D; //!!! nCurTab is still missing
@@ -279,19 +251,19 @@ void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
nFmt |= ScRefFlags::TAB2_3D;
- if ( pRefInputEdit == pEdDataArea)
+ if ( m_pRefInputEdit == m_xEdDataArea.get())
aStr = rRef.Format(nFmt, pDocP, eConv);
- else if ( pRefInputEdit == pEdDestArea )
+ else if ( m_pRefInputEdit == m_xEdDestArea.get() )
aStr = rRef.aStart.Format(nFmt, pDocP, eConv);
- pRefInputEdit->SetRefString( aStr );
- ModifyHdl( *pRefInputEdit );
+ m_pRefInputEdit->SetRefString( aStr );
+ ModifyHdl( *m_pRefInputEdit );
}
}
-bool ScConsolidateDlg::Close()
+void ScConsolidateDlg::Close()
{
- return DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
+ DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
}
void ScConsolidateDlg::SetActive()
@@ -300,27 +272,37 @@ void ScConsolidateDlg::SetActive()
{
bDlgLostFocus = false;
- if ( pRefInputEdit )
+ if ( m_pRefInputEdit )
{
- pRefInputEdit->GrabFocus();
- ModifyHdl( *pRefInputEdit );
+ m_pRefInputEdit->GrabFocus();
+ ModifyHdl( *m_pRefInputEdit );
}
}
else
- GrabFocus();
+ m_xDialog->grab_focus();
RefInputDone();
}
-void ScConsolidateDlg::Deactivate()
+IMPL_LINK_NOARG(ScConsolidateDlg, LoseFocusHdl, weld::Widget&, void)
+{
+ bDlgLostFocus = !m_xDialog->has_toplevel_focus();
+}
+
+IMPL_LINK_NOARG(ScConsolidateDlg, LoseEditFocusHdl, formula::WeldRefEdit&, void)
+{
+ bDlgLostFocus = !m_xDialog->has_toplevel_focus();
+}
+
+IMPL_LINK_NOARG(ScConsolidateDlg, LoseButtonFocusHdl, formula::WeldRefButton&, void)
{
- bDlgLostFocus = true;
+ bDlgLostFocus = !m_xDialog->has_toplevel_focus();
}
-bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
+bool ScConsolidateDlg::VerifyEdit( formula::WeldRefEdit* pEd )
{
if ( !pRangeUtil || !pDoc ||
- ((pEd != pEdDataArea) && (pEd != pEdDestArea)) )
+ ((pEd != m_xEdDataArea.get()) && (pEd != m_xEdDestArea.get())) )
return false;
SCTAB nTab = rViewData.GetTabNo();
@@ -328,12 +310,12 @@ bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
OUString theCompleteStr;
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- if ( pEd == pEdDataArea )
+ if ( pEd == m_xEdDataArea.get() )
{
bEditOk = ScRangeUtil::IsAbsArea( pEd->GetText(), pDoc,
nTab, &theCompleteStr, nullptr, nullptr, eConv );
}
- else if ( pEd == pEdDestArea )
+ else if ( pEd == m_xEdDestArea.get() )
{
OUString aPosStr;
@@ -350,32 +332,28 @@ bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
// Handler:
-IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control&, rControl, void )
+IMPL_LINK( ScConsolidateDlg, GetEditFocusHdl, formula::WeldRefEdit&, rControl, void )
{
- if ( &rControl ==static_cast<Control*>(pEdDataArea) ||
- &rControl ==static_cast<Control*>(pEdDestArea))
- {
- pRefInputEdit = static_cast<formula::RefEdit*>(&rControl);
- }
- else if(&rControl ==static_cast<Control*>(pLbDataArea) )
- {
- pRefInputEdit = pEdDataArea;
- }
- else if(&rControl ==static_cast<Control*>(pLbDestArea) )
- {
- pRefInputEdit = pEdDestArea;
- }
+ m_pRefInputEdit = &rControl;
}
-IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, Button*, void)
+IMPL_LINK( ScConsolidateDlg, GetFocusHdl, weld::Widget&, rControl, void )
{
- const sal_Int32 nDataAreaCount = pLbConsAreas->GetEntryCount();
+ if (&rControl == m_xLbDataArea.get())
+ m_pRefInputEdit = m_xEdDataArea.get();
+ else if (&rControl == m_xLbDestArea.get())
+ m_pRefInputEdit = m_xEdDestArea.get();
+}
+
+IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, weld::Button&, void)
+{
+ const sal_Int32 nDataAreaCount = m_xLbConsAreas->n_children();
if ( nDataAreaCount > 0 )
{
ScRefAddress aDestAddress;
SCTAB nTab = rViewData.GetTabNo();
- OUString aDestPosStr( pEdDestArea->GetText() );
+ OUString aDestPosStr( m_xEdDestArea->GetText() );
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
if ( ScRangeUtil::IsAbsPos( aDestPosStr, pDoc, nTab, nullptr, &aDestAddress, eConv ) )
@@ -385,17 +363,17 @@ IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, Button*, void)
for ( sal_Int32 i=0; i<nDataAreaCount; ++i )
{
- ScRangeUtil::MakeArea( pLbConsAreas->GetEntry( i ),
- pDataAreas[i], pDoc, nTab, eConv );
+ ScRangeUtil::MakeArea(m_xLbConsAreas->get_text(i),
+ pDataAreas[i], pDoc, nTab, eConv);
}
theOutParam.nCol = aDestAddress.Col();
theOutParam.nRow = aDestAddress.Row();
theOutParam.nTab = aDestAddress.Tab();
- theOutParam.eFunction = LbPosToFunc( pLbFunc->GetSelectedEntryPos() );
- theOutParam.bByCol = pBtnByCol->IsChecked();
- theOutParam.bByRow = pBtnByRow->IsChecked();
- theOutParam.bReferenceData = pBtnRefs->IsChecked();
+ theOutParam.eFunction = LbPosToFunc( m_xLbFunc->get_active() );
+ theOutParam.bByCol = m_xBtnByCol->get_active();
+ theOutParam.bByRow = m_xBtnByRow->get_active();
+ theOutParam.bReferenceData = m_xBtnRefs->get_active();
theOutParam.SetAreas( std::move(pDataAreas), nDataAreaCount );
ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
@@ -405,27 +383,27 @@ IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, Button*, void)
GetBindings().GetDispatcher()->ExecuteList(SID_CONSOLIDATE,
SfxCallMode::SLOT | SfxCallMode::RECORD,
{ &aOutItem });
- Close();
+ response(RET_OK);
}
else
{
- INFOBOX(GetFrameWeld(), STR_INVALID_TABREF);
- pEdDestArea->GrabFocus();
+ INFOBOX(m_xDialog.get(), STR_INVALID_TABREF);
+ m_xEdDestArea->GrabFocus();
}
}
else
- Close(); // no area defined -> Cancel
+ response(RET_CANCEL); // no area defined -> Cancel
}
-IMPL_LINK( ScConsolidateDlg, ClickHdl, Button*, pBtn, void )
+IMPL_LINK( ScConsolidateDlg, ClickHdl, weld::Button&, rBtn, void )
{
- if ( pBtn == pBtnCancel )
- Close();
- else if ( pBtn == pBtnAdd )
+ if ( &rBtn == m_xBtnCancel.get() )
+ response(RET_CANCEL);
+ else if ( &rBtn == m_xBtnAdd.get() )
{
- if ( !pEdDataArea->GetText().isEmpty() )
+ if ( !m_xEdDataArea->GetText().isEmpty() )
{
- OUString aNewEntry( pEdDataArea->GetText() );
+ OUString aNewEntry( m_xEdDataArea->GetText() );
std::unique_ptr<ScArea[]> ppAreas;
sal_uInt16 nAreaCount = 0;
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
@@ -443,93 +421,90 @@ IMPL_LINK( ScConsolidateDlg, ClickHdl, Button*, pBtn, void )
rArea.nColEnd, rArea.nRowEnd, rArea.nTab
).Format(ScRefFlags::RANGE_ABS_3D, pDoc, eConv);
- if ( pLbConsAreas->GetEntryPos( aNewArea )
- == LISTBOX_ENTRY_NOTFOUND )
+ if (m_xLbConsAreas->find_text(aNewArea) == -1)
{
- pLbConsAreas->InsertEntry( aNewArea );
+ m_xLbConsAreas->append_text( aNewArea );
}
}
}
- else if ( VerifyEdit( pEdDataArea ) )
+ else if ( VerifyEdit( m_xEdDataArea.get() ) )
{
- OUString aNewArea( pEdDataArea->GetText() );
+ OUString aNewArea( m_xEdDataArea->GetText() );
- if ( pLbConsAreas->GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND )
- pLbConsAreas->InsertEntry( aNewArea );
+ if (m_xLbConsAreas->find_text(aNewArea) == -1)
+ m_xLbConsAreas->append_text(aNewArea);
else
- INFOBOX(GetFrameWeld(), STR_AREA_ALREADY_INSERTED);
+ INFOBOX(m_xDialog.get(), STR_AREA_ALREADY_INSERTED);
}
else
{
- INFOBOX(GetFrameWeld(), STR_INVALID_TABREF);
- pEdDataArea->GrabFocus();
+ INFOBOX(m_xDialog.get(), STR_INVALID_TABREF);
+ m_xEdDataArea->GrabFocus();
}
}
}
- else if ( pBtn == pBtnRemove )
+ else if ( &rBtn == m_xBtnRemove.get() )
{
- while ( pLbConsAreas->GetSelectedEntryCount() )
- pLbConsAreas->RemoveEntry( pLbConsAreas->GetSelectedEntryPos() );
- pBtnRemove->Disable();
+ std::vector<int> aSelectedRows(m_xLbConsAreas->get_selected_rows());
+ std::sort(aSelectedRows.begin(), aSelectedRows.end());
+ for (auto it = aSelectedRows.rbegin(); it != aSelectedRows.rend(); ++it)
+ m_xLbConsAreas->remove(*it);
+ m_xBtnRemove->set_sensitive(false);
}
}
-IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox&, rLb, void )
+IMPL_LINK( ScConsolidateDlg, SelectTVHdl, weld::TreeView&, rLb, void )
{
- if ( &rLb == pLbConsAreas )
- {
- if ( pLbConsAreas->GetSelectedEntryCount() > 0 )
- pBtnRemove->Enable();
- else
- pBtnRemove->Disable();
- }
- else if ( (&rLb == pLbDataArea) || (&rLb == pLbDestArea) )
- {
- Edit* pEd = (&rLb == pLbDataArea) ? pEdDataArea : pEdDestArea;
- const sal_Int32 nSelPos = rLb.GetSelectedEntryPos();
+ if (rLb.get_selected_index() != -1)
+ m_xBtnRemove->set_sensitive(true);
+ else
+ m_xBtnRemove->set_sensitive(false);
+}
+
+IMPL_LINK( ScConsolidateDlg, SelectCBHdl, weld::ComboBox&, rLb, void )
+{
+ formula::WeldRefEdit* pEd = (&rLb == m_xLbDataArea.get()) ? m_xEdDataArea.get() : m_xEdDestArea.get();
+ const sal_Int32 nSelPos = rLb.get_active();
- if ( pRangeUtil
- && (nSelPos > 0)
- && (nAreaDataCount > 0)
- && (pAreaData != nullptr) )
+ if ( pRangeUtil
+ && (nSelPos > 0)
+ && (nAreaDataCount > 0)
+ && (pAreaData != nullptr) )
+ {
+ if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
{
- if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
- {
- OUString aString( pAreaData[nSelPos-1].aStrArea );
+ OUString aString( pAreaData[nSelPos-1].aStrArea );
- if ( &rLb == pLbDestArea )
- ScRangeUtil::CutPosString( aString, aString );
+ if ( &rLb == m_xLbDestArea.get() )
+ ScRangeUtil::CutPosString( aString, aString );
- pEd->SetText( aString );
+ pEd->SetText( aString );
- if ( pEd == pEdDataArea )
- pBtnAdd->Enable();
- }
- }
- else
- {
- pEd->SetText( EMPTY_OUSTRING );
- if ( pEd == pEdDataArea )
- pBtnAdd->Enable();
+ if ( pEd == m_xEdDataArea.get() )
+ m_xBtnAdd->set_sensitive(true);
}
}
+ else
+ {
+ pEd->SetText( EMPTY_OUSTRING );
+ if ( pEd == m_xEdDataArea.get() )
+ m_xBtnAdd->set_sensitive(true);
+ }
}
-IMPL_LINK( ScConsolidateDlg, ModifyHdl, Edit&, rEd, void )
+IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::WeldRefEdit&, rEd, void )
{
- if ( &rEd == pEdDataArea )
+ if ( &rEd == m_xEdDataArea.get() )
{
OUString aAreaStr( rEd.GetText() );
if ( !aAreaStr.isEmpty() )
- {
- pBtnAdd->Enable();
- }
+ m_xBtnAdd->set_sensitive(true);
else
- pBtnAdd->Disable();
+ m_xBtnAdd->set_sensitive(false);
}
- else if ( &rEd == pEdDestArea )
+ else if ( &rEd == m_xEdDestArea.get() )
{
- pLbDestArea->SelectEntryPos(0);
+ m_xLbDestArea->set_active(0);
}
}