From 5240022f55b65900112b332a085a6ca652156e30 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 7 Oct 2012 05:58:04 +0200 Subject: change to ref input field for range edit Change-Id: I69eb352869e0bcaa362bb1be6022d30de8c2658c --- sc/source/ui/condformat/condformatdlg.cxx | 35 +++++++++++++++++++++++++++++-- sc/source/ui/inc/condformatdlg.hrc | 1 + sc/source/ui/inc/condformatdlg.hxx | 9 +++++++- sc/source/ui/src/condformatdlg.src | 8 ++++++- 4 files changed, 49 insertions(+), 4 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 6544e1c8f409..eaeb6d15ed7b 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -1120,7 +1120,8 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* p maBtnOk( this, ScResId( BTN_OK ) ), maBtnCancel( this, ScResId( BTN_CANCEL ) ), maFtRange( this, ScResId( FT_RANGE ) ), - maEdRange( this, ScResId( ED_RANGE ) ), + maEdRange( this, this, ScResId( ED_RANGE ) ), + maRbRange( this, ScResId( RB_RANGE ), &maEdRange, this ), maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, rPos, eType ), maPos(rPos), mpDoc(pDoc), @@ -1137,6 +1138,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* p maEdRange.SetModifyHdl( LINK( this, ScCondFormatDlg, EdRangeModifyHdl ) ); maBtnOk.SetClickHdl( LINK( this, ScCondFormatDlg, OkBtnHdl ) ); maBtnCancel.SetClickHdl( LINK( this, ScCondFormatDlg, CancelBtnHdl ) ); + maEdRange.SetGetFocusHdl( LINK( this, ScCondFormatDlg, RangeGetFocusHdl ) ); FreeResource(); maEdRange.SetText(aRangeString); @@ -1148,12 +1150,36 @@ ScCondFormatDlg::~ScCondFormatDlg() void ScCondFormatDlg::SetActive() { + maEdRange.GrabFocus(); + RefInputDone(); +} + +void ScCondFormatDlg::RefInputDone( sal_Bool bForced ) +{ + ScAnyRefDlg::RefInputDone(bForced); +} +sal_Bool ScCondFormatDlg::IsRefInputMode() const +{ + return maEdRange.IsEnabled(); } -void ScCondFormatDlg::SetReference(const ScRange&, ScDocument*) +#define ABS_SREF SCA_VALID \ + | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE +#define ABS_DREF ABS_SREF \ + | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE + +void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*) { + if( maEdRange.IsEnabled() ) + { + if(rRef.aStart != rRef.aEnd) + RefInputStart(&maEdRange); + rtl::OUString aRefStr; + rRef.Format( aRefStr, ABS_DREF, mpDoc, ScAddress::Details(mpDoc->GetAddressConvention(), 0, 0) ); + maEdRange.SetRefString( aRefStr ); + } } ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const @@ -1259,5 +1285,10 @@ IMPL_LINK_NOARG( ScCondFormatDlg, CancelBtnHdl ) return 0; } +IMPL_LINK_NOARG( ScCondFormatDlg, RangeGetFocusHdl ) +{ + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc index 98bf32a707ef..960faec13048 100644 --- a/sc/source/ui/inc/condformatdlg.hrc +++ b/sc/source/ui/inc/condformatdlg.hrc @@ -57,5 +57,6 @@ #define FT_RANGE 32 #define ED_RANGE 33 +#define RB_RANGE 34 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx index 529cd149ab32..7c4cd8115d88 100644 --- a/sc/source/ui/inc/condformatdlg.hxx +++ b/sc/source/ui/inc/condformatdlg.hxx @@ -198,7 +198,8 @@ private: OKButton maBtnOk; CancelButton maBtnCancel; FixedText maFtRange; - Edit maEdRange; + formula::RefEdit maEdRange; + formula::RefButton maRbRange; ScCondFormatList maCondFormList; @@ -210,8 +211,13 @@ private: DECL_LINK( EdRangeModifyHdl, Edit* ); DECL_LINK( OkBtnHdl, void* ); DECL_LINK( CancelBtnHdl, void* ); + DECL_LINK( RangeGetFocusHdl, void* ); virtual sal_Bool Close(); +protected: + + virtual void RefInputDone( sal_Bool bForced = false ); + public: ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pSW, Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, @@ -221,6 +227,7 @@ public: SC_DLLPUBLIC ScConditionalFormat* GetConditionalFormat() const; virtual void SetReference(const ScRange&, ScDocument*); + virtual sal_Bool IsRefInputMode() const; virtual void SetActive(); virtual sal_Bool IsTableLocked() const { return sal_True; } }; diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src index f00052a8d4dd..e7fa731144b9 100644 --- a/sc/source/ui/src/condformatdlg.src +++ b/sc/source/ui/src/condformatdlg.src @@ -77,7 +77,13 @@ ModelessDialog RID_SCDLG_CONDFORMAT Edit ED_RANGE { Pos = MAP_APPFONT( 60, 262 ); - Size = MAP_APPFONT( 200, 14 ); + Size = MAP_APPFONT( 182, 14 ); + Border = TRUE; + }; + ImageButton RB_RANGE + { + Pos = MAP_APPFONT( 245, 262 ); + Size = MAP_APPFONT( 14, 14 ); Border = TRUE; }; }; -- cgit