diff options
author | Sarper Akdemir <q.sarperakdemir@gmail.com> | 2020-02-03 00:47:57 +0300 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-03-25 22:22:50 +0100 |
commit | 8cd7543bab7a281646211f439895bbdf9240a64a (patch) | |
tree | 3d2b8269d81e83dd6efb3408221aacb96aa7864c | |
parent | 313081c0703c66918e95640c74cd57312a1e8bba (diff) |
tdf#127113: Allow to fill any two numeric fields in Fill Series dialog
Added m_nSelectHeight and m_nSelectWidth to ScFillSeriesDlg
class for deriving missing box if other two boxes are full.
CheckValues() mimics behaviour of previous check functions with
added functionality of calculating missing start or increment values
(end value was already handled in previous check functions) in linear
fill mode if it is possible to calculate them from other two values.
Change-Id: If30d96f1b5f7e1bb88f473d7c0c5c2802ba6f225
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87841
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/inc/scabstdlg.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/filldlg.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/filldlg.cxx | 88 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 5 |
6 files changed, 54 insertions, 55 deletions
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index a4282b7a7bda..0b15c4f5aea4 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -434,6 +434,8 @@ public: const OUString& aStartStr, double fStep, double fMax, + SCSIZE nSelectHeight, + SCSIZE nSelectWidth, sal_uInt16 nPossDir) = 0; virtual VclPtr<AbstractScGroupDlg> CreateAbstractScGroupDlg(weld::Window* pParent, bool bUnGroup = false) = 0; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 71ec37385c0d..613f5711a470 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -1014,9 +1014,11 @@ VclPtr<AbstractScFillSeriesDlg> ScAbstractDialogFactory_Impl::CreateScFillSeries const OUString& aStartStr, double fStep, double fMax, + const SCSIZE nSelectHeight, + const SCSIZE nSelectWidth, sal_uInt16 nPossDir) { - return VclPtr<AbstractScFillSeriesDlg_Impl>::Create(std::make_unique<ScFillSeriesDlg>(pParent, rDocument,eFillDir, eFillCmd,eFillDateCmd, aStartStr,fStep,fMax,nPossDir)); + return VclPtr<AbstractScFillSeriesDlg_Impl>::Create(std::make_unique<ScFillSeriesDlg>(pParent, rDocument,eFillDir, eFillCmd,eFillDateCmd, aStartStr,fStep,fMax,nSelectHeight,nSelectWidth,nPossDir)); } VclPtr<AbstractScGroupDlg> ScAbstractDialogFactory_Impl::CreateAbstractScGroupDlg(weld::Window* pParent, bool bUnGroup) diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 1c5b0cbe8da3..527a81e6e2d1 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -700,6 +700,8 @@ public: const OUString& aStartStr, double fStep, double fMax, + SCSIZE nSelectHeight, + SCSIZE nSelectWidth, sal_uInt16 nPossDir) override; virtual VclPtr<AbstractScGroupDlg> CreateAbstractScGroupDlg(weld::Window* pParent, bool bUnGroup = false) override; diff --git a/sc/source/ui/inc/filldlg.hxx b/sc/source/ui/inc/filldlg.hxx index afa1527b84d9..6c7688920181 100644 --- a/sc/source/ui/inc/filldlg.hxx +++ b/sc/source/ui/inc/filldlg.hxx @@ -36,6 +36,8 @@ public: const OUString& aStartStr, double fStep, double fMax, + SCSIZE nSelectHeight, + SCSIZE nSelectWidth, sal_uInt16 nPossDir ); virtual ~ScFillSeriesDlg() override; @@ -61,6 +63,8 @@ private: double fStartVal; double fIncrement; double fEndVal; + const SCSIZE m_nSelectHeight; + const SCSIZE m_nSelectWidth; std::unique_ptr<weld::Label> m_xFtStartVal; std::unique_ptr<weld::Entry> m_xEdStartVal; @@ -89,9 +93,7 @@ private: std::unique_ptr<weld::Button> m_xBtnOk; void Init( sal_uInt16 nPossDir ); - bool CheckStartVal(); - bool CheckIncrementVal(); - bool CheckEndVal(); + weld::Entry* CheckValues(); DECL_LINK(OKHdl, weld::Button&, void); DECL_LINK(DisableHdl, weld::ToggleButton&, void); diff --git a/sc/source/ui/miscdlgs/filldlg.cxx b/sc/source/ui/miscdlgs/filldlg.cxx index 6bc71de946e1..6fb1934c0929 100644 --- a/sc/source/ui/miscdlgs/filldlg.cxx +++ b/sc/source/ui/miscdlgs/filldlg.cxx @@ -38,6 +38,8 @@ ScFillSeriesDlg::ScFillSeriesDlg( weld::Window* pParent, const OUString& aStartStr, double fStep, double fMax, + const SCSIZE nSelectHeight, + const SCSIZE nSelectWidth, sal_uInt16 nPossDir ) : GenericDialogController(pParent, "modules/scalc/ui/filldlg.ui", "FillSeriesDialog") , aStartStrVal(aStartStr) @@ -48,6 +50,8 @@ ScFillSeriesDlg::ScFillSeriesDlg( weld::Window* pParent, , theFillDateCmd(eFillDateCmd) , fIncrement(fStep) , fEndVal(fMax) + , m_nSelectHeight(nSelectHeight) + , m_nSelectWidth(nSelectWidth) , m_xFtStartVal(m_xBuilder->weld_label("startL")) , m_xEdStartVal(m_xBuilder->weld_entry("startValue")) , m_xFtEndVal(m_xBuilder->weld_label("endL")) @@ -174,48 +178,46 @@ void ScFillSeriesDlg::Init( sal_uInt16 nPossDir ) m_xEdEndVal->set_text( aEndTxt ); } -bool ScFillSeriesDlg::CheckStartVal() -{ - bool bValOk = false; - OUString aStr = m_xEdStartVal->get_text(); - - if ( aStr.isEmpty() || m_xBtnAutoFill->get_active()) - { - fStartVal = MAXDOUBLE; - bValOk = true; - } - else - { - sal_uInt32 nKey = 0; - bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fStartVal ); - } - return bValOk; -} - -bool ScFillSeriesDlg::CheckIncrementVal() +weld::Entry* ScFillSeriesDlg::CheckValues() { + OUString aStartStr = m_xEdStartVal->get_text(); + OUString aIncStr = m_xEdIncrement->get_text(); + OUString aEndStr = m_xEdEndVal->get_text(); sal_uInt32 nKey = 0; - OUString aStr = m_xEdIncrement->get_text(); - return rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fIncrement ); -} - -bool ScFillSeriesDlg::CheckEndVal() -{ - bool bValOk = false; - OUString aStr = m_xEdEndVal->get_text(); + // If entry is filled, capture value before handling special cases. + if ( !aStartStr.isEmpty() + && theFillCmd != FILL_AUTO + && !rDoc.GetFormatTable()->IsNumberFormat( aStartStr, nKey, fStartVal ) ) + return m_xEdStartVal.get(); + if ( !aIncStr.isEmpty() + && !rDoc.GetFormatTable()->IsNumberFormat( aIncStr, nKey, fIncrement ) ) + return m_xEdIncrement.get(); + if ( !aEndStr.isEmpty() + && !rDoc.GetFormatTable()->IsNumberFormat( aEndStr, nKey, fEndVal ) ) + return m_xEdEndVal.get(); - if (aStr.isEmpty()) + if ( theFillCmd == FILL_LINEAR && !aEndStr.isEmpty() + && aStartStr.isEmpty() != aIncStr.isEmpty() + && ( ( m_nSelectHeight == 1 ) != ( m_nSelectWidth == 1 ) ) ) { - fEndVal = (fIncrement < 0) ? -MAXDOUBLE : MAXDOUBLE; - bValOk = true; + SCSIZE nStepAmount = ( theFillDir == FILL_TO_BOTTOM || theFillDir == FILL_TO_TOP ) ? + m_nSelectHeight - 1 : m_nSelectWidth - 1 ; + if ( aStartStr.isEmpty() ) + fStartVal = fEndVal - fIncrement * nStepAmount; + if ( aIncStr.isEmpty() ) + fIncrement = (fEndVal - fStartVal) / nStepAmount; } else { - sal_uInt32 nKey = 0; - bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fEndVal ); + if ( aStartStr.isEmpty() || m_xBtnAutoFill->get_active() ) + fStartVal = MAXDOUBLE; + if ( aIncStr.isEmpty() ) + return m_xEdIncrement.get(); + if ( aEndStr.isEmpty() ) + fEndVal = ( fIncrement < 0 ) ? -MAXDOUBLE : MAXDOUBLE; } - return bValOk; + return nullptr; } // Handler: @@ -271,25 +273,11 @@ IMPL_LINK_NOARG(ScFillSeriesDlg, OKHdl, weld::Button&, void) else if ( m_xBtnMonth->get_active() ) theFillDateCmd = FILL_MONTH; else if ( m_xBtnYear->get_active() ) theFillDateCmd = FILL_YEAR; - bool bAllOk = true; - weld::Entry* pEdWrong = nullptr; - if ( !CheckStartVal() ) - { - bAllOk = false; - pEdWrong = m_xEdStartVal.get(); - } - else if ( !CheckIncrementVal() ) + weld::Entry* pEdWrong = CheckValues(); + if ( pEdWrong == nullptr ) { - bAllOk = false; - pEdWrong = m_xEdIncrement.get(); - } - else if ( !CheckEndVal() ) - { - bAllOk = false; - pEdWrong = m_xEdEndVal.get(); - } - if ( bAllOk ) m_xDialog->response(RET_OK); + } else { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 859992e646d9..12335f870ca6 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -629,6 +629,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat ); pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType ); const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat ); + const SCSIZE nSelectHeight = nEndRow - nStartRow + 1; + const SCSIZE nSelectWidth = nEndCol - nStartCol + 1; + if (!pPrivEntry) { OSL_FAIL("Numberformat not found !!!"); @@ -709,7 +712,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) *pDoc, eFillDir, eFillCmd, eFillDateCmd, aStartStr, fIncVal, fMaxVal, - nPossDir)); + nSelectHeight, nSelectWidth, nPossDir)); if ( nStartCol != nEndCol && nStartRow != nEndRow ) { |