summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-09 11:23:48 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-10 21:23:21 +0200
commit3d648f76ac90fe8e28691313d0d4e78a8278e511 (patch)
treef3e0de959d8ddff61a9ff4af79e481bec25aa29d /formula
parent47500ab25b9c5bbeeb6fde3866bdd924948fd88a (diff)
weld ScCorrelationDialog
this is first of the calc dialogs with a range selector, so some temp scaffolding is required during interim case of both welded/unwelded in existence Change-Id: I5480179092da7b56864cef066af781b35f735ebc Reviewed-on: https://gerrit.libreoffice.org/70474 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/ui/dlg/formula.cxx21
-rw-r--r--formula/source/ui/dlg/funcutl.cxx180
2 files changed, 201 insertions, 0 deletions
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 68120f6bbd51..e7c5fede138d 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -77,6 +77,8 @@ class FormulaDlg_Impl
public:
::std::pair<RefButton*, RefEdit*>
RefInputStartBefore( RefEdit* pEdit, RefButton* pButton );
+ static ::std::pair<WeldRefButton*, WeldRefEdit*>
+ RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton );
void RefInputStartAfter();
void RefInputDoneAfter( bool bForced );
bool CalcValue( const OUString& rStrExp, OUString& rStrResult, bool bForceMatrixFormula = false );
@@ -1522,6 +1524,15 @@ void FormulaDlg_Impl::UpdateSelection()
return aPair;
}
+::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg_Impl::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton )
+{
+ assert(!pEdit && !pButton);
+ ::std::pair<WeldRefButton*, WeldRefEdit*> aPair;
+ aPair.first = pButton;
+ aPair.second = pEdit;
+ return aPair;
+}
+
void FormulaDlg_Impl::RefInputStartAfter()
{
m_pRefBtn->SetEndImage();
@@ -1779,6 +1790,11 @@ void FormulaModalDialog::Update()
return m_pImpl->RefInputStartBefore( pEdit, pButton );
}
+::std::pair<WeldRefButton*, WeldRefEdit*> FormulaModalDialog::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton )
+{
+ return formula::FormulaDlg_Impl::RefInputStartBefore(pEdit, pButton);
+}
+
void FormulaModalDialog::RefInputStartAfter()
{
m_pImpl->RefInputStartAfter();
@@ -1868,6 +1884,11 @@ void FormulaDlg::DoEnter()
return m_pImpl->RefInputStartBefore( pEdit, pButton );
}
+::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton )
+{
+ return formula::FormulaDlg_Impl::RefInputStartBefore(pEdit, pButton);
+}
+
void FormulaDlg::RefInputStartAfter()
{
m_pImpl->RefInputStartAfter();
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index 9499992b6b7e..47c3d408d63e 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -517,6 +517,112 @@ IMPL_LINK_NOARG(RefEdit, UpdateHdl, Timer *, void)
pAnyRefDlg->ShowReference( GetText() );
}
+// class RefEdit
+
+WeldRefEdit::WeldRefEdit(std::unique_ptr<weld::Entry> xControl)
+ : xEntry(std::move(xControl))
+ , aIdle("formula RefEdit Idle")
+ , pAnyRefDlg(nullptr)
+ , pLabelWidget(nullptr)
+{
+ xEntry->connect_focus_in(LINK(this, WeldRefEdit, GetFocus));
+ xEntry->connect_focus_out(LINK(this, WeldRefEdit, LoseFocus));
+ xEntry->connect_key_press(LINK(this, WeldRefEdit, KeyInput));
+ xEntry->connect_changed(LINK(this, WeldRefEdit, Modify));
+ aIdle.SetInvokeHandler( LINK( this, WeldRefEdit, UpdateHdl ) );
+}
+
+WeldRefEdit::~WeldRefEdit()
+{
+ aIdle.ClearInvokeHandler();
+ aIdle.Stop();
+}
+
+void WeldRefEdit::SetRefString( const OUString& rStr )
+{
+ // Prevent unwanted side effects by setting only a differing string.
+ // See commit message for reasons.
+ if (xEntry->get_text() != rStr)
+ xEntry->set_text(rStr);
+}
+
+void WeldRefEdit::SetRefValid(bool bValid)
+{
+ xEntry->set_error(!bValid);
+}
+
+void WeldRefEdit::SetText(const OUString& rStr)
+{
+ xEntry->set_text(rStr);
+ UpdateHdl( &aIdle );
+}
+
+void WeldRefEdit::StartUpdateData()
+{
+ aIdle.Start();
+}
+
+void WeldRefEdit::SetReferences(IControlReferenceHandler* pDlg, weld::Label* pLabel)
+{
+ pAnyRefDlg = pDlg;
+ pLabelWidget = pLabel;
+
+ if( pDlg )
+ {
+ aIdle.SetInvokeHandler(LINK(this, WeldRefEdit, UpdateHdl));
+ }
+ else
+ {
+ aIdle.ClearInvokeHandler();
+ aIdle.Stop();
+ }
+}
+
+IMPL_LINK_NOARG(WeldRefEdit, Modify, weld::Entry&, void)
+{
+ maModifyHdl.Call(*this);
+ if (pAnyRefDlg)
+ pAnyRefDlg->HideReference();
+}
+
+IMPL_LINK(WeldRefEdit, KeyInput, const KeyEvent&, rKEvt, bool)
+{
+ const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if (pAnyRefDlg && !rKeyCode.GetModifier() && rKeyCode.GetCode() == KEY_F2)
+ {
+ pAnyRefDlg->ReleaseFocus( this );
+ return true;
+ }
+
+ switch (rKeyCode.GetCode())
+ {
+ case KEY_RETURN:
+ case KEY_ESCAPE:
+ return maActivateHdl.Call(*GetWidget());
+ }
+
+ return false;
+}
+
+IMPL_LINK_NOARG(WeldRefEdit, GetFocus, weld::Widget&, void)
+{
+ maGetFocusHdl.Call(*this);
+ StartUpdateData();
+}
+
+IMPL_LINK_NOARG(WeldRefEdit, LoseFocus, weld::Widget&, void)
+{
+ maLoseFocusHdl.Call(*this);
+ if( pAnyRefDlg )
+ pAnyRefDlg->HideReference();
+}
+
+IMPL_LINK_NOARG(WeldRefEdit, UpdateHdl, Timer *, void)
+{
+ if( pAnyRefDlg )
+ pAnyRefDlg->ShowReference(xEntry->get_text());
+}
+
//class RefButton
RefButton::RefButton( vcl::Window* _pParent, WinBits nStyle ) :
ImageButton(_pParent, nStyle),
@@ -590,6 +696,80 @@ void RefButton::LoseFocus()
pRefEdit->Modify();
}
+//class RefButton
+WeldRefButton::WeldRefButton(std::unique_ptr<weld::Button> xControl)
+ : xButton(std::move(xControl))
+ , pAnyRefDlg( nullptr )
+ , pRefEdit( nullptr )
+{
+ xButton->connect_focus_in(LINK(this, WeldRefButton, GetFocus));
+ xButton->connect_focus_out(LINK(this, WeldRefButton, LoseFocus));
+ xButton->connect_key_press(LINK(this, WeldRefButton, KeyInput));
+ xButton->connect_clicked(LINK(this, WeldRefButton, Click));
+ SetStartImage();
+}
+
+WeldRefButton::~WeldRefButton()
+{
+}
+
+void WeldRefButton::SetStartImage()
+{
+ xButton->set_from_icon_name(RID_BMP_REFBTN1);
+ xButton->set_tooltip_text(ForResId(RID_STR_SHRINK));
+}
+
+void WeldRefButton::SetEndImage()
+{
+ xButton->set_from_icon_name(RID_BMP_REFBTN2);
+ xButton->set_tooltip_text(ForResId(RID_STR_EXPAND));
+}
+
+void WeldRefButton::SetReferences( IControlReferenceHandler* pDlg, WeldRefEdit* pEdit )
+{
+ pAnyRefDlg = pDlg;
+ pRefEdit = pEdit;
+}
+
+IMPL_LINK_NOARG(WeldRefButton, Click, weld::Button&, void)
+{
+ if( pAnyRefDlg )
+ pAnyRefDlg->ToggleCollapsed( pRefEdit, this );
+}
+
+IMPL_LINK(WeldRefButton, KeyInput, const KeyEvent&, rKEvt, bool)
+{
+ const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if (pAnyRefDlg && !rKeyCode.GetModifier() && rKeyCode.GetCode() == KEY_F2)
+ {
+ pAnyRefDlg->ReleaseFocus( pRefEdit );
+ return true;
+ }
+
+ switch (rKeyCode.GetCode())
+ {
+ case KEY_RETURN:
+ case KEY_ESCAPE:
+ return maActivateHdl.Call(*GetWidget());
+ }
+
+ return false;
+}
+
+IMPL_LINK_NOARG(WeldRefButton, GetFocus, weld::Widget&, void)
+{
+ maGetFocusHdl.Call(*this);
+ if (pRefEdit)
+ pRefEdit->StartUpdateData();
+}
+
+IMPL_LINK_NOARG(WeldRefButton, LoseFocus, weld::Widget&, void)
+{
+ maLoseFocusHdl.Call(*this);
+ if (pRefEdit)
+ pRefEdit->DoModify();
+}
+
} // formula
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */