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

weld ScSimpleRefDlg

Change-Id: I36fe5a0790b2f7a43b9e4d8def9ef3a224d4d546
Reviewed-on: https://gerrit.libreoffice.org/70549
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 37aa4f0d
......@@ -142,6 +142,18 @@ public:
xEntry->select_region(0, -1);
}
void SetSelection(const Selection& rSelection)
{
xEntry->select_region(rSelection.Min(), rSelection.Max());
}
Selection GetSelection() const
{
int nStartPos, nEndPos;
xEntry->get_selection_bounds(nStartPos, nEndPos);
return Selection(nStartPos, nEndPos);
}
weld::Label* GetLabelWidgetForShrinkMode()
{
return pLabelWidget;
......
......@@ -180,7 +180,10 @@ class ScSimpleRefDlgWrapper: public SfxChildWindow
SfxBindings*,
SfxChildWinInfo* );
SFX_DECL_CHILDWINDOW_WITHID(Class);
static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId,
SfxBindings *pBindings, SfxChildWinInfo* pInfo);
static void RegisterChildWindow(bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE);
static sal_uInt16 GetChildWindowId();
static void SetDefaultPosSize(Point aPos, Size aSize);
void SetRefString(const OUString& rStr);
......
......@@ -25,7 +25,7 @@
class ScDocument;
class ScSimpleRefDlg: public ScAnyRefDlg
class ScSimpleRefDlg: public ScAnyRefDlgController
{
private:
Link<const OUString*,void> aCloseHdl;
......@@ -33,13 +33,6 @@ private:
Link<const OUString&,void> aAbortedHdl;
Link<const OUString&,void> aChangeHdl;
VclPtr<FixedText> m_pFtAssign;
VclPtr<formula::RefEdit> m_pEdAssign;
VclPtr<formula::RefButton> m_pRbAssign;
VclPtr<OKButton> m_pBtnOk;
VclPtr<CancelButton> m_pBtnCancel;
ScRange theCurArea;
bool bCloseFlag;
bool bAutoReOpen;
......@@ -47,30 +40,34 @@ private:
bool bSingleCell;
bool bMultiSelection;
std::unique_ptr<weld::Label> m_xFtAssign;
std::unique_ptr<formula::WeldRefEdit> m_xEdAssign;
std::unique_ptr<formula::WeldRefButton> m_xRbAssign;
std::unique_ptr<weld::Button> m_xBtnOk;
std::unique_ptr<weld::Button> m_xBtnCancel;
void Init();
DECL_LINK( CancelBtnHdl, Button*, void );
DECL_LINK( OkBtnHdl, Button*, void );
DECL_LINK( CancelBtnHdl, weld::Button&, void );
DECL_LINK( OkBtnHdl, weld::Button&, void );
protected:
virtual void RefInputDone( bool bForced = false ) override;
public:
ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent);
ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent);
virtual ~ScSimpleRefDlg() override;
virtual void dispose() override;
virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override;
virtual bool IsRefInputMode() const override;
virtual void SetActive() override;
virtual bool Close() override;
virtual void Close() override;
void StartRefInput();
void SetRefString(const OUString &rStr);
virtual void FillInfo(SfxChildWinInfo&) const override;
void SetCloseHdl( const Link<const OUString*,void>& rLink );
void SetUnoLinks( const Link<const OUString&,void>& rDone, const Link<const OUString&,void>& rAbort,
......
......@@ -21,23 +21,20 @@
#include <document.hxx>
#include <simpref.hxx>
ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent)
: ScAnyRefDlg(pB, pCW, pParent, "SimpleRefDialog", "modules/scalc/ui/simplerefdialog.ui")
,
bAutoReOpen ( true ),
bCloseOnButtonUp( false ),
bSingleCell ( false ),
bMultiSelection ( false )
{
get(m_pFtAssign, "area");
get(m_pEdAssign, "assign");
m_pEdAssign->SetReferences(this, m_pFtAssign);
get(m_pRbAssign, "assignref");
m_pRbAssign->SetReferences(this, m_pEdAssign);
get(m_pBtnOk, "ok");
get(m_pBtnCancel, "cancel");
ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent)
: ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/simplerefdialog.ui", "SimpleRefDialog")
, bAutoReOpen(true)
, bCloseOnButtonUp(false)
, bSingleCell(false)
, bMultiSelection(false)
, m_xFtAssign(m_xBuilder->weld_label("area"))
, m_xEdAssign(new formula::WeldRefEdit(m_xBuilder->weld_entry("assign")))
, m_xRbAssign(new formula::WeldRefButton(m_xBuilder->weld_button("assignref")))
, m_xBtnOk(m_xBuilder->weld_button("ok"))
, m_xBtnCancel(m_xBuilder->weld_button("cancel"))
{
m_xEdAssign->SetReferences(this, m_xFtAssign.get());
m_xRbAssign->SetReferences(this, m_xEdAssign.get());
// in order to keep the Strings with the FixedTexts in the resource:
Init();
......@@ -45,36 +42,19 @@ ScSimpleRefDlg::ScSimpleRefDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window
}
ScSimpleRefDlg::~ScSimpleRefDlg()
{
disposeOnce();
}
void ScSimpleRefDlg::dispose()
{
SetDispatcherLock( false ); // deactivate modal mode
m_pFtAssign.clear();
m_pEdAssign.clear();
m_pRbAssign.clear();
m_pBtnOk.clear();
m_pBtnCancel.clear();
ScAnyRefDlg::dispose();
}
void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const
{
ScAnyRefDlg::FillInfo(rWinInfo);
rWinInfo.bVisible=bAutoReOpen;
}
void ScSimpleRefDlg::SetRefString(const OUString &rStr)
{
m_pEdAssign->SetText(rStr);
m_xEdAssign->SetText(rStr);
}
void ScSimpleRefDlg::Init()
{
m_pBtnOk->SetClickHdl ( LINK( this, ScSimpleRefDlg, OkBtnHdl ) );
m_pBtnCancel->SetClickHdl ( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) );
m_xBtnOk->connect_clicked( LINK( this, ScSimpleRefDlg, OkBtnHdl ) );
m_xBtnCancel->connect_clicked( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) );
bCloseFlag=false;
}
......@@ -82,10 +62,10 @@ void ScSimpleRefDlg::Init()
// shown as the new selection in the reference field.
void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
{
if ( m_pEdAssign->IsEnabled() )
if (m_xEdAssign->GetWidget()->get_sensitive())
{
if ( rRef.aStart != rRef.aEnd )
RefInputStart(m_pEdAssign);
RefInputStart(m_xEdAssign.get());
theCurArea = rRef;
OUString aRefStr;
......@@ -99,30 +79,29 @@ void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
if ( bMultiSelection )
{
OUString aVal = m_pEdAssign->GetText();
Selection aSel = m_pEdAssign->GetSelection();
OUString aVal = m_xEdAssign->GetText();
Selection aSel = m_xEdAssign->GetSelection();
aSel.Justify();
aVal = aVal.replaceAt( aSel.Min(), aSel.Len(), aRefStr );
Selection aNewSel( aSel.Min(), aSel.Min()+aRefStr.getLength() );
m_pEdAssign->SetRefString( aVal );
m_pEdAssign->SetSelection( aNewSel );
m_xEdAssign->SetRefString( aVal );
m_xEdAssign->SetSelection( aNewSel );
}
else
m_pEdAssign->SetRefString( aRefStr );
m_xEdAssign->SetRefString( aRefStr );
aChangeHdl.Call( aRefStr );
}
}
bool ScSimpleRefDlg::Close()
void ScSimpleRefDlg::Close()
{
CancelBtnHdl(m_pBtnCancel);
return true;
CancelBtnHdl(*m_xBtnCancel);
}
void ScSimpleRefDlg::SetActive()
{
m_pEdAssign->GrabFocus();
m_xEdAssign->GrabFocus();
// no NameModifyHdl. Otherwise ranges could not be altered
// (after marking the reference, the old field content would be shown)
......@@ -162,36 +141,36 @@ void ScSimpleRefDlg::StartRefInput()
if ( bMultiSelection )
{
// initially select the whole string, so it gets replaced by default
m_pEdAssign->SetSelection( Selection( 0, m_pEdAssign->GetText().getLength() ) );
m_xEdAssign->SelectAll();
}
m_pRbAssign->DoRef();
m_xRbAssign->DoRef();
bCloseFlag = true;
}
void ScSimpleRefDlg::RefInputDone( bool bForced)
{
ScAnyRefDlg::RefInputDone(bForced);
ScAnyRefDlgController::RefInputDone(bForced);
if ( (bForced || bCloseOnButtonUp) && bCloseFlag )
OkBtnHdl(m_pBtnOk);
OkBtnHdl(*m_xBtnOk);
}
// Handler:
IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, Button*, void)
IMPL_LINK_NOARG(ScSimpleRefDlg, OkBtnHdl, weld::Button&, void)
{
bAutoReOpen=false;
OUString aResult=m_pEdAssign->GetText();
OUString aResult=m_xEdAssign->GetText();
aCloseHdl.Call(&aResult);
Link<const OUString&,void> aUnoLink = aDoneHdl; // stack var because this is deleted in DoClose
DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
aUnoLink.Call( aResult );
}
IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl, Button*, void)
IMPL_LINK_NOARG(ScSimpleRefDlg, CancelBtnHdl, weld::Button&, void)
{
bAutoReOpen=false;
OUString aResult=m_pEdAssign->GetText();
OUString aResult=m_xEdAssign->GetText();
aCloseHdl.Call(nullptr);
Link<const OUString&,void> aUnoLink = aAbortedHdl; // stack var because this is deleted in DoClose
DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
......
......@@ -48,7 +48,7 @@ SFX_IMPL_MODELESSDIALOG_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNA
SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT )
SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
SFX_IMPL_CHILDWINDOW_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF )
SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
......@@ -183,12 +183,12 @@ ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( vcl::Window* pParentP,
pInfo->aSize.setHeight(nScSimpleRefHeight );
pInfo->aSize.setWidth(nScSimpleRefWidth );
}
SetWindow(nullptr);
SetController(nullptr);
if(bAutoReOpen && pViewShell)
SetWindow( pViewShell->CreateRefDialog( p, this, pInfo, pParentP, WID_SIMPLE_REF) );
if (bAutoReOpen && pViewShell)
SetController(pViewShell->CreateRefDialogController(p, this, pInfo, pParentP->GetFrameWeld(), WID_SIMPLE_REF));
if (!GetWindow())
if (!GetController())
{
SC_MOD()->SetRefDialog( nId, false );
}
......@@ -210,42 +210,47 @@ void ScSimpleRefDlgWrapper::SetAutoReOpen(bool bFlag)
void ScSimpleRefDlgWrapper::SetRefString(const OUString& rStr)
{
if(GetWindow())
auto xDlgController = GetController();
if (xDlgController)
{
static_cast<ScSimpleRefDlg*>(GetWindow())->SetRefString(rStr);
static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetRefString(rStr);
}
}
void ScSimpleRefDlgWrapper::SetCloseHdl( const Link<const OUString*,void>& rLink )
{
if(GetWindow())
auto xDlgController = GetController();
if (xDlgController)
{
static_cast<ScSimpleRefDlg*>(GetWindow())->SetCloseHdl( rLink );
static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetCloseHdl(rLink);
}
}
void ScSimpleRefDlgWrapper::SetUnoLinks( const Link<const OUString&,void>& rDone,
const Link<const OUString&,void>& rAbort, const Link<const OUString&,void>& rChange )
{
if(GetWindow())
auto xDlgController = GetController();
if (xDlgController)
{
static_cast<ScSimpleRefDlg*>(GetWindow())->SetUnoLinks( rDone, rAbort, rChange );
static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetUnoLinks( rDone, rAbort, rChange );
}
}
void ScSimpleRefDlgWrapper::SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection )
{
if(GetWindow())
auto xDlgController = GetController();
if (xDlgController)
{
static_cast<ScSimpleRefDlg*>(GetWindow())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
}
}
void ScSimpleRefDlgWrapper::StartRefInput()
{
if(GetWindow())
auto xDlgController = GetController();
if (xDlgController)
{
static_cast<ScSimpleRefDlg*>(GetWindow())->StartRefInput();
static_cast<ScSimpleRefDlg*>(xDlgController.get())->StartRefInput();
}
}
......
......@@ -365,16 +365,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
}
break;
case WID_SIMPLE_REF:
{
// dialog checks, what is in the cell
ScViewData& rViewData = GetViewData();
rViewData.SetRefTabNo( rViewData.GetTabNo() );
pResult = VclPtr<ScSimpleRefDlg>::Create( pB, pCW, pParent );
}
break;
case WID_CONDFRMT_REF:
{
bool bFound = false;
......@@ -484,6 +474,15 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont
case SID_FOURIER_ANALYSIS_DIALOG:
xResult.reset(new ScFourierAnalysisDialog(pB, pCW, pParent, &GetViewData()));
break;
case WID_SIMPLE_REF:
{
// dialog checks, what is in the cell
ScViewData& rViewData = GetViewData();
rViewData.SetRefTabNo( rViewData.GetTabNo() );
xResult.reset(new ScSimpleRefDlg(pB, pCW, pParent));
break;
}
case FID_DEFINE_NAME:
{
if (!mbInSwitch)
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="SimpleRefDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="simplerefdialog|SimpleRefDialog">Set range</property>
<property name="resizable">False</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel" id="area">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="simplerefdialog|area">Area:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">assign</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="foruilo-RefEdit" id="assign">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="width_chars">50</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="foruilo-RefButton" id="assignref">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
......@@ -123,6 +75,59 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel" id="area">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="simplerefdialog|area">Area:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">assign</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="assign">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="width_chars">50</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="assignref">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
......
......@@ -219,6 +219,7 @@ sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkSpinButton[@id='leftindent:0pt'] m
sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkSpinButton[@id='leftindent:0pt'] labelled-by-and-mnemonic
sc/uiconfig/scalc/ui/sidebaralignment.ui://GtkLabel[@id='orientationlabel'] orphan-label
sc/uiconfig/scalc/ui/sidebaralignment.ui://VclComboBoxNumeric[@id='orientationdegrees:0degrees'] missing-label-for
sc/uiconfig/scalc/ui/simplerefdialog.ui://GtkButton[@id='assignref'] button-no-label
sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='targetlabel'] orphan-label
sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='result'] orphan-label
sc/uiconfig/scalc/ui/solverdlg.ui://GtkLabel[@id='changelabel'] orphan-label
......
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