From 9d370f2bb9f2af1b3acc1531f1e71b0ded36e40f Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 12 Aug 2015 14:29:25 +0200 Subject: move date/time guess work to SvNumberFormatter::GuessDateTimeFormat() Change-Id: I26f7c47f5b3cf4a3c4274832448d9c8076981af0 --- chart2/source/tools/DiagramHelper.cxx | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'chart2') diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 3dcbf4b2b17c..162bdf67169c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1202,38 +1202,9 @@ sal_Int32 DiagramHelper::getDateTimeInputNumberFormat( const Reference< util::XN SAL_WARN("chart2", "DiagramHelper::getDateTimeInputNumberFormat - no SvNumberFormatter"); else { - // Categorize the format according to the implementation of - // SvNumberFormatter::GetEditFormat(), making assumptions about what - // would be time only. - /* TODO: implement a method at SvNumberFormatter that does this and - * call instead, if Chart isn't able transport the proper format of the - * Axis, which of course would be much better.. */ short nType; - if (0.0 <= fNumber && fNumber < 1.0) - { - // Clearly a time. - nType = util::NumberFormat::TIME; - nRet = pNumFormatter->GetFormatIndex( NF_TIME_HHMM, LANGUAGE_SYSTEM); - } - else if (fabs( fNumber) * 24 < 0x7fff) - { - // Assuming time within 32k hours or 3.7 years. - nType = util::NumberFormat::TIME; - nRet = pNumFormatter->GetFormatIndex( NF_TIME_HH_MMSS, LANGUAGE_SYSTEM); - } - else if (rtl::math::approxFloor( fNumber) != fNumber) - { - // Date+Time. - nType = util::NumberFormat::DATETIME; - nRet = pNumFormatter->GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, LANGUAGE_SYSTEM); - } - else - { - // Date only. - nType = util::NumberFormat::DATE; - nRet = pNumFormatter->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM); - } - + // Obtain best matching date, time or datetime format. + nRet = pNumFormatter->GuessDateTimeFormat( nType, fNumber, LANGUAGE_SYSTEM); // Obtain the corresponding edit format. nRet = pNumFormatter->GetEditFormat( fNumber, nRet, nType, LANGUAGE_SYSTEM, NULL); } -- cgit