15#include <document.hxx>
25 , mxVariable1RangeLabel(m_xBuilder->weld_label(
"variable1-range-label"))
26 , mxVariable1RangeEdit(new
formula::RefEdit(m_xBuilder->weld_entry(
"variable1-range-edit")))
27 , mxVariable1RangeButton(new
formula::RefButton(m_xBuilder->weld_button(
"variable1-range-button")))
28 , mxVariable2RangeLabel(m_xBuilder->weld_label(
"variable2-range-label"))
29 , mxVariable2RangeEdit(new
formula::RefEdit(m_xBuilder->weld_entry(
"variable2-range-edit")))
30 , mxVariable2RangeButton(new
formula::RefButton(m_xBuilder->weld_button(
"variable2-range-button")))
31 , mxOutputRangeLabel(m_xBuilder->weld_label(
"output-range-label"))
32 , mxOutputRangeEdit(new
formula::RefEdit(m_xBuilder->weld_entry(
"output-range-edit")))
33 , mxOutputRangeButton(new
formula::RefButton(m_xBuilder->weld_button(
"output-range-button")))
34 , mViewData(rViewData)
35 , mDocument(rViewData.GetDocument())
36 , mVariable1Range(
ScAddress::INITIALIZE_INVALID)
37 , mVariable2Range(
ScAddress::INITIALIZE_INVALID)
38 , mAddressDetails(mDocument.GetAddressConvention(), 0, 0 )
39 , mOutputAddress(
ScAddress::INITIALIZE_INVALID)
40 , mGroupedBy(BY_COLUMN)
41 , mxButtonOk(m_xBuilder->weld_button(
"ok"))
42 , mxButtonCancel(m_xBuilder->weld_button(
"cancel"))
43 , mxGroupByColumnsRadio(m_xBuilder->weld_radio_button(
"groupedby-columns-radio"))
44 , mxGroupByRowsRadio(m_xBuilder->weld_radio_button(
"groupedby-rows-radio"))
45 , mpActiveEdit(nullptr)
46 , mCurrentAddress(rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() )
47 , mDialogLostFocus(false)
108 OUString aCurrentString;
152 if ( rReferenceRange.
aStart != rReferenceRange.
aEnd )
155 OUString aReferenceString;
186 if (&rButton == mxButtonOk.get())
188 CalculateInputAndWriteToOutput();
197 mpActiveEdit =
nullptr;
198 if (&rCtrl == mxVariable1RangeEdit.get())
200 mpActiveEdit = mxVariable1RangeEdit.get();
202 else if (&rCtrl == mxVariable2RangeEdit.get())
204 mpActiveEdit = mxVariable2RangeEdit.get();
206 else if (&rCtrl == mxOutputRangeEdit.get())
208 mpActiveEdit = mxOutputRangeEdit.get();
212 mpActiveEdit->SelectAll();
217 mpActiveEdit =
nullptr;
218 if (&rCtrl == mxVariable1RangeButton.get())
220 mpActiveEdit = mxVariable1RangeEdit.get();
222 else if (&rCtrl == mxVariable2RangeButton.get())
224 mpActiveEdit = mxVariable2RangeEdit.get();
226 else if (&rCtrl == mxOutputRangeButton.get())
228 mpActiveEdit = mxOutputRangeEdit.get();
232 mpActiveEdit->SelectAll();
237 mDialogLostFocus = !
m_xDialog->has_toplevel_focus();
242 mDialogLostFocus = !
m_xDialog->has_toplevel_focus();
247 if (mxGroupByColumnsRadio->get_active())
248 mGroupedBy = BY_COLUMN;
249 else if (mxGroupByRowsRadio->get_active())
252 ValidateDialogInput();
259 if (mpActiveEdit == mxVariable1RangeEdit.get())
262 bool bValid = ParseWithNames( aRangeList, mxVariable1RangeEdit->GetText(), mDocument);
263 const ScRange* pRange = (bValid && aRangeList.
size() == 1) ? &aRangeList[0] :
nullptr;
266 mVariable1Range = *pRange;
268 mxVariable1RangeEdit->StartUpdateData();
275 else if ( mpActiveEdit == mxVariable2RangeEdit.get() )
278 bool bValid = ParseWithNames( aRangeList, mxVariable2RangeEdit->GetText(), mDocument);
279 const ScRange* pRange = (bValid && aRangeList.
size() == 1) ? &aRangeList[0] :
nullptr;
282 mVariable2Range = *pRange;
284 mxVariable2RangeEdit->StartUpdateData();
291 else if ( mpActiveEdit == mxOutputRangeEdit.get() )
294 bool bValid = ParseWithNames( aRangeList, mxOutputRangeEdit->GetText(), mDocument);
295 const ScRange* pRange = (bValid && aRangeList.
size() == 1) ? &aRangeList[0] :
nullptr;
298 mOutputAddress = pRange->
aStart;
303 ScRefFlags nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ?
306 OUString aReferenceString = mOutputAddress.Format(nFormat, &mDocument, mDocument.GetAddressConvention());
307 mxOutputRangeEdit->SetRefString( aReferenceString );
311 mxOutputRangeEdit->StartUpdateData();
320 ValidateDialogInput();
IMPL_LINK_NOARG(ScStatisticsTwoVariableDialog, LoseEditFocusHandler, formula::RefEdit &, void)
IMPL_LINK(ScStatisticsTwoVariableDialog, ButtonClicked, weld::Button &, rButton, void)
Reference< XExecutableDialog > m_xDialog
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
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
std::unique_ptr< formula::RefEdit > mxVariable2RangeEdit
std::unique_ptr< weld::Button > mxButtonCancel
std::unique_ptr< formula::RefEdit > mxVariable1RangeEdit
ScAddress mCurrentAddress
std::unique_ptr< weld::Button > mxButtonOk
std::unique_ptr< formula::RefButton > mxOutputRangeButton
std::unique_ptr< weld::RadioButton > mxGroupByRowsRadio
std::unique_ptr< weld::Label > mxOutputRangeLabel
virtual void SetActive() override
void CalculateInputAndWriteToOutput()
virtual bool InputRangesValid()
std::unique_ptr< formula::RefButton > mxVariable1RangeButton
std::unique_ptr< weld::RadioButton > mxGroupByColumnsRadio
ScAddress::Details const mAddressDetails
void ValidateDialogInput()
virtual ScRange ApplyOutput(ScDocShell *pDocShell)=0
formula::RefEdit * mpActiveEdit
std::unique_ptr< formula::RefEdit > mxOutputRangeEdit
std::unique_ptr< formula::RefButton > mxVariable2RangeButton
virtual ~ScStatisticsTwoVariableDialog() override
virtual TranslateId GetUndoNameId()=0
ScStatisticsTwoVariableDialog(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScViewData &rViewData, const OUString &rUIXMLDescription, const OUString &rID)
void GetRangeFromSelection()
std::unique_ptr< weld::Label > mxVariable1RangeLabel
std::unique_ptr< weld::Label > mxVariable2RangeLabel
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
ScDocShell * GetDocShell() const
ScTabViewShell * GetViewShell() const
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
ViewShellId GetViewShellId() const override
#define LINK(Instance, Class, Member)
OUString ScResId(TranslateId aId)