28#include <document.hxx>
44 VclMessageType::Info, VclButtonsType::Ok,
57 void Set(
const OUString& rName,
const OUString& rArea )
70 :
ScAnyRefDlgController(pB, pCW, pParent,
"modules/scalc/ui/consolidatedialog.ui",
"ConsolidateDialog")
71 , aStrUndefined (
ScResId( SCSTR_UNDEFINED ) )
73 rArgSet.
Get( rArgSet.GetPool()->
79 GetViewData().GetDocument() )
80 , nAreaDataCount ( 0 )
81 , nWhichCons ( rArgSet.GetPool()->
GetWhich( SID_CONSOLIDATE ) )
82 , bDlgLostFocus ( false )
83 , m_xLbFunc(m_xBuilder->weld_combo_box(
"func"))
84 , m_xLbConsAreas(m_xBuilder->weld_tree_view(
"consareas"))
85 , m_xLbDataArea(m_xBuilder->weld_combo_box(
"lbdataarea"))
86 , m_xEdDataArea(new
formula::RefEdit(m_xBuilder->weld_entry(
"eddataarea")))
87 , m_xRbDataArea(new
formula::RefButton(m_xBuilder->weld_button(
"rbdataarea")))
88 , m_xLbDestArea(m_xBuilder->weld_combo_box(
"lbdestarea"))
89 , m_xEdDestArea(new
formula::RefEdit(m_xBuilder->weld_entry(
"eddestarea")))
90 , m_xRbDestArea(new
formula::RefButton(m_xBuilder->weld_button(
"rbdestarea")))
91 , m_xBtnByRow(m_xBuilder->weld_check_button(
"byrow"))
92 , m_xBtnByCol(m_xBuilder->weld_check_button(
"bycol"))
93 , m_xBtnRefs(m_xBuilder->weld_check_button(
"refs"))
94 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
95 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
96 , m_xBtnAdd(m_xBuilder->weld_button(
"add"))
97 , m_xBtnRemove(m_xBuilder->weld_button(
"delete"))
98 , m_xDataFT(m_xBuilder->weld_label(
"ftdataarea"))
99 , m_xDestFT(m_xBuilder->weld_label(
"ftdestarea"))
175 size_t nRangeCount = pRangeNames ? pRangeNames->
size() : 0;
189 while ( aIter.
Next( aStrName, aRange ) )
192 pAreaData[nAt++].Set( aStrName, aStrArea );
256 DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
288 bool bEditOk =
false;
289 OUString theCompleteStr;
295 nTab, &theCompleteStr,
nullptr,
nullptr, eConv );
303 nTab, &theCompleteStr,
nullptr, eConv );
307 pEd->
SetText( theCompleteStr );
316 m_pRefInputEdit = &rControl;
321 if (&rControl == m_xLbDataArea.get())
322 m_pRefInputEdit = m_xEdDataArea.get();
323 else if (&rControl == m_xLbDestArea.get())
324 m_pRefInputEdit = m_xEdDestArea.get();
329 const sal_Int32 nDataAreaCount = m_xLbConsAreas->n_children();
331 if ( nDataAreaCount > 0 )
334 SCTAB nTab = rViewData.GetTabNo();
335 OUString aDestPosStr( m_xEdDestArea->GetText() );
341 std::unique_ptr<ScArea[]> pDataAreas(
new ScArea[nDataAreaCount]);
343 for ( sal_Int32
i=0;
i<nDataAreaCount; ++
i )
346 pDataAreas[
i], rDoc, nTab, eConv);
349 theOutParam.
nCol = aDestAddress.
Col();
350 theOutParam.
nRow = aDestAddress.
Row();
351 theOutParam.
nTab = aDestAddress.
Tab();
352 theOutParam.
eFunction = LbPosToFunc( m_xLbFunc->get_active() );
353 theOutParam.
bByCol = m_xBtnByCol->get_active();
354 theOutParam.
bByRow = m_xBtnByRow->get_active();
356 theOutParam.
SetAreas( std::move(pDataAreas), nDataAreaCount );
360 SetDispatcherLock(
false );
363 SfxCallMode::SLOT | SfxCallMode::RECORD,
370 m_xEdDestArea->GrabFocus();
379 if ( &rBtn == m_xBtnCancel.get() )
381 else if ( &rBtn == m_xBtnAdd.get() )
383 if ( !m_xEdDataArea->GetText().isEmpty() )
385 OUString aNewEntry( m_xEdDataArea->GetText() );
386 std::unique_ptr<ScArea[]> ppAreas;
387 sal_uInt16 nAreaCount = 0;
396 for ( sal_uInt16
i=0;
i<nAreaCount;
i++ )
398 const ScArea& rArea = ppAreas[
i];
403 if (m_xLbConsAreas->find_text(aNewArea) == -1)
405 m_xLbConsAreas->append_text( aNewArea );
409 else if ( VerifyEdit( m_xEdDataArea.get() ) )
411 OUString aNewArea( m_xEdDataArea->GetText() );
413 if (m_xLbConsAreas->find_text(aNewArea) == -1)
414 m_xLbConsAreas->append_text(aNewArea);
421 m_xEdDataArea->GrabFocus();
425 else if ( &rBtn == m_xBtnRemove.get() )
427 std::vector<int> aSelectedRows(m_xLbConsAreas->get_selected_rows());
428 std::sort(aSelectedRows.begin(), aSelectedRows.end());
429 for (
auto it = aSelectedRows.rbegin(); it != aSelectedRows.rend(); ++it)
430 m_xLbConsAreas->remove(*it);
431 m_xBtnRemove->set_sensitive(
false);
437 if (rLb.get_selected_index() != -1)
438 m_xBtnRemove->set_sensitive(
true);
440 m_xBtnRemove->set_sensitive(
false);
445 formula::RefEdit* pEd = (&rLb == m_xLbDataArea.get()) ? m_xEdDataArea.get() : m_xEdDestArea.get();
446 const sal_Int32 nSelPos = rLb.get_active();
449 && (nAreaDataCount > 0)
450 && (pAreaData !=
nullptr) )
454 OUString aString( pAreaData[nSelPos-1].aStrArea );
456 if ( &rLb == m_xLbDestArea.get() )
461 if ( pEd == m_xEdDataArea.get() )
462 m_xBtnAdd->set_sensitive(
true);
468 if ( pEd == m_xEdDataArea.get() )
469 m_xBtnAdd->set_sensitive(
true);
475 if ( &rEd == m_xEdDataArea.get() )
477 OUString aAreaStr( rEd.GetText() );
478 if ( !aAreaStr.isEmpty() )
479 m_xBtnAdd->set_sensitive(
true);
481 m_xBtnAdd->set_sensitive(
false);
483 else if ( &rEd == m_xEdDestArea.get() )
485 m_xLbDestArea->set_active(0);
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
void Set(const OUString &rName, const OUString &rArea)
bool Next(OUString &rName, ScRange &rRange)
std::unique_ptr< weld::ComboBox > m_xLbDataArea
std::unique_ptr< weld::CheckButton > m_xBtnRefs
virtual void Deactivate() override
std::unique_ptr< ScAreaData[]> pAreaData
static sal_Int32 FuncToLbPos(ScSubTotalFunc eFunc)
std::unique_ptr< weld::Button > m_xBtnOk
virtual ~ScConsolidateDlg() override
std::unique_ptr< weld::Button > m_xBtnRemove
std::unique_ptr< weld::TreeView > m_xLbConsAreas
std::unique_ptr< formula::RefEdit > m_xEdDestArea
static ScSubTotalFunc LbPosToFunc(sal_Int32 nPos)
std::unique_ptr< weld::CheckButton > m_xBtnByRow
std::unique_ptr< weld::Button > m_xBtnAdd
std::unique_ptr< weld::CheckButton > m_xBtnByCol
std::unique_ptr< formula::RefButton > m_xRbDataArea
virtual void SetActive() override
ScConsolidateDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, const SfxItemSet &rArgSet)
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
std::unique_ptr< weld::ComboBox > m_xLbDestArea
std::unique_ptr< weld::Button > m_xBtnCancel
ScConsolidateParam theConsData
std::unique_ptr< weld::Label > m_xDataFT
virtual void Close() override
formula::RefEdit * m_pRefInputEdit
std::unique_ptr< formula::RefEdit > m_xEdDataArea
std::unique_ptr< formula::RefButton > m_xRbDestArea
std::unique_ptr< weld::Label > m_xDestFT
bool VerifyEdit(formula::RefEdit *pEd)
std::unique_ptr< weld::ComboBox > m_xLbFunc
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC SCTAB GetTableCount() const
SC_DLLPUBLIC size_t size() const
static bool IsAbsArea(const OUString &rAreaStr, const ScDocument &rDoc, SCTAB nTab, OUString *pCompleteStr, ScRefAddress *pStartPos=nullptr, ScRefAddress *pEndPos=nullptr, ScAddress::Details const &rDetails=ScAddress::detailsOOOa1)
static bool IsAbsTabArea(const OUString &rAreaStr, const ScDocument *pDoc, std::unique_ptr< ScArea[]> *ppAreas, sal_uInt16 *pAreaCount, bool bAcceptCellRef=false, ScAddress::Details const &rDetails=ScAddress::detailsOOOa1)
static bool IsAbsPos(const OUString &rPosStr, const ScDocument &rDoc, SCTAB nTab, OUString *pCompleteStr, ScRefAddress *pPosTripel=nullptr, ScAddress::Details const &rDetails=ScAddress::detailsOOOa1)
static bool MakeArea(const OUString &rAreaStr, ScArea &rArea, const ScDocument &rDoc, SCTAB nTab, ScAddress::Details const &rDetails)
static void CutPosString(const OUString &theAreaStr, OUString &thePosStr)
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
virtual void RefInputDone(bool bForced=false) override
bool DoClose(sal_uInt16 nId)
SfxDispatcher * GetDispatcher() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
IMPL_LINK(ScConsolidateDlg, GetEditFocusHdl, formula::RefEdit &, rControl, void)
IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, weld::Button &, void)
virtual SfxBindings & GetBindings() override
#define LINK(Instance, Class, Member)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString ScResId(TranslateId aId)
sal_uInt16 nDataAreaCount
std::unique_ptr< ScArea[]> pDataAreas
void SetAreas(std::unique_ptr< ScArea[]> pAreas, sal_uInt16 nCount)