diff options
author | Eike Rathke <erack@redhat.com> | 2022-05-10 18:39:27 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-05-11 00:26:01 +0200 |
commit | 23689e492feb41a391738586cef04ab82cc21f80 (patch) | |
tree | 75fb31c4922b6e21588eb23da53d7c002c131f2d /sc | |
parent | 52ebc944cf9c45ad6dc7f925c685472dfb7fc3e6 (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
Diffstat (limited to 'sc')
-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 393a59cc4d42..7d57d26534fe 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; |