diff options
author | Eike Rathke <erack@redhat.com> | 2022-05-10 18:39:27 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-11 09:58:10 +0200 |
commit | 8b6ce0459302580a616c657f6aff19e41660dcdf (patch) | |
tree | 30c855cef7687362e1aeff4a375846117a1dafc4 | |
parent | 1ba9f7068e81fbbc59a117a63a63d399561da7e1 (diff) |
Resolves: tdf#132582 Display duration for calculated time values selection
Change-Id: I634cd0fb059ed9c35849b435bcbd178cd84ac2ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134132
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 23689e492feb41a391738586cef04ab82cc21f80)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134069
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/source/ui/view/tabvwsha.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 209f935a729f..39910e32cc39 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -29,6 +29,7 @@ #include <sfx2/viewfrm.hxx> #include <svl/ilstitem.hxx> #include <svl/numformat.hxx> +#include <svl/zformat.hxx> #include <svl/int64item.hxx> #include <svl/srchitem.hxx> #include <svl/srchdefs.hxx> @@ -127,6 +128,17 @@ bool ScTabViewShell::GetFunction( OUString& rFuncStr, FormulaError nErrCode ) { // number format from attributes or formula nNumFmt = rDoc.GetNumberFormat( nPosX, nPosY, nTab ); + // If the number format is time (without date) and the + // result is not within 24 hours, use a duration + // format. Summing date+time doesn't make much sense + // otherwise but we also don't want to display duration + // for a single date+time value. + if (nVal < 0.0 || nVal >= 1.0) + { + const SvNumberformat* pFormat = pFormatter->GetEntry(nNumFmt); + if (pFormat && (pFormat->GetType() == SvNumFormatType::TIME)) + nNumFmt = pFormatter->GetTimeFormat( nVal, pFormat->GetLanguage(), true); + } } OUString aValStr; |