sc/inc/globalnames.hxx | 2 ++ sc/source/core/data/dbdocutl.cxx | 7 +++---- sc/source/core/data/dpgroup.cxx | 5 ++--- sc/source/core/data/dputil.cxx | 5 ++--- sc/source/core/tool/interpr2.cxx | 13 ++++++------- sc/source/filter/orcus/interface.cxx | 5 ++--- sc/source/ui/view/viewfun6.cxx | 6 ++---- 7 files changed, 19 insertions(+), 24 deletions(-)
New commits: commit 7c7e3f7e6a76e733be0dfe74c55e35c67774fbe9 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Apr 10 15:14:02 2013 -0400 Centralize D_TIMEFACTOR as DATE_TIME_FACTOR. It was about time. Change-Id: I87225be540c22b3031c6aee3f3fd9d26795abef8 diff --git a/sc/inc/globalnames.hxx b/sc/inc/globalnames.hxx index 4fee471..b388a7c 100644 --- a/sc/inc/globalnames.hxx +++ b/sc/inc/globalnames.hxx @@ -36,6 +36,8 @@ #define TEXTWIDTH_DIRTY 0xffff +#define DATE_TIME_FACTOR 86400.0 + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx index fcdfab5..eb244f7 100644 --- a/sc/source/core/data/dbdocutl.cxx +++ b/sc/source/core/data/dbdocutl.cxx @@ -26,11 +26,10 @@ #include "document.hxx" #include "formula/errorcodes.hxx" #include "stringutil.hxx" +#include "globalnames.hxx" using namespace ::com::sun::star; -#define D_TIMEFACTOR 86400.0 - // ---------------------------------------------------------------------------- ScDatabaseDocUtil::StrData::StrData() : @@ -111,7 +110,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB util::Time aTime = xRow->getTime(nRowPos); nVal = ( aTime.Hours * 3600 + aTime.Minutes * 60 + - aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR; + aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / DATE_TIME_FACTOR; bEmptyFlag = xRow->wasNull(); bValue = sal_True; } @@ -127,7 +126,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nVal = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - *pFormTable->GetNullDate() ) + ( aStamp.Hours * 3600 + aStamp.Minutes * 60 + - aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR; + aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / DATE_TIME_FACTOR; bEmptyFlag = xRow->wasNull(); bValue = sal_True; } diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx index bc2e132..5368523 100644 --- a/sc/source/core/data/dpgroup.cxx +++ b/sc/source/core/data/dpgroup.cxx @@ -27,6 +27,7 @@ #include "dpobject.hxx" #include "dpglobal.hxx" #include "dputil.hxx" +#include "globalnames.hxx" #include <rtl/math.hxx> @@ -48,8 +49,6 @@ using ::com::sun::star::uno::UNO_QUERY_THROW; using ::std::vector; using ::boost::shared_ptr; -#define D_TIMEFACTOR 86400.0 - const sal_uInt16 SC_DP_LEAPYEAR = 1648; // arbitrary leap year for date calculations class ScDPGroupNumFilter : public ScDPFilteredCache::FilterBase @@ -155,7 +154,7 @@ bool ScDPGroupDateFilter::match( const ScDPItemData & rCellData ) const // (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded) double time = rCellData.GetValue() - approxFloor(rCellData.GetValue()); - long seconds = static_cast<long>(approxFloor(time*D_TIMEFACTOR + 0.5)); + long seconds = static_cast<long>(approxFloor(time*DATE_TIME_FACTOR + 0.5)); switch (nGroupType) { diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx index a842d7d..bbf0489 100644 --- a/sc/source/core/data/dputil.cxx +++ b/sc/source/core/data/dputil.cxx @@ -30,6 +30,7 @@ #include "global.hxx" #include "dpitemdata.hxx" #include "dpnumgroupinfo.hxx" +#include "globalnames.hxx" #include "comphelper/string.hxx" #include "unotools/localedatawrapper.hxx" @@ -40,8 +41,6 @@ #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> #include <com/sun/star/i18n/CalendarDisplayIndex.hpp> -#define D_TIMEFACTOR 86400.0 - using namespace com::sun::star; namespace { @@ -314,7 +313,7 @@ sal_Int32 ScDPUtil::getDatePartValue( // (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded) double fTime = fValue - rtl::math::approxFloor(fValue); - long nSeconds = (long)rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5); + long nSeconds = (long)rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5); switch (nDatePart) { diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 883a2e9..ad4daa7 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -43,14 +43,13 @@ #include "dpobject.hxx" #include "postit.hxx" #include "tokenarray.hxx" +#include "globalnames.hxx" #include <string.h> #include <math.h> using namespace formula; -// STATIC DATA ----------------------------------------------------------- -#define D_TIMEFACTOR 86400.0 #define SCdEpsilon 1.0E-7 //----------------------------------------------------------------------------- @@ -117,7 +116,7 @@ void ScInterpreter::ScGetActTime() double nTime = ((double)aActTime.Get100Sec() / 100 + (double)(aActTime.GetSec() + (aActTime.GetMin() * 60) + - (aActTime.GetHour() * 3600))) / D_TIMEFACTOR; + (aActTime.GetHour() * 3600))) / DATE_TIME_FACTOR; PushDouble( (double) nDiff + nTime ); } @@ -150,7 +149,7 @@ void ScInterpreter::ScGetMin() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetMin" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg - long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) % 3600; + long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % 3600; PushDouble( (double) (nVal/60) ); } @@ -159,7 +158,7 @@ void ScInterpreter::ScGetSec() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetSec" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg - long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) % 60; + long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % 60; PushDouble( (double) nVal ); } @@ -168,7 +167,7 @@ void ScInterpreter::ScGetHour() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetHour" ); double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg - long nVal = (long)::rtl::math::approxFloor(fTime*D_TIMEFACTOR+0.5) / 3600; + long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) / 3600; PushDouble((double) nVal); } @@ -289,7 +288,7 @@ void ScInterpreter::ScGetTime() double nSec = GetDouble(); double nMin = GetDouble(); double nHour = GetDouble(); - double fTime = fmod( (nHour * 3600) + (nMin * 60) + nSec, D_TIMEFACTOR) / D_TIMEFACTOR; + double fTime = fmod( (nHour * 3600) + (nMin * 60) + nSec, DATE_TIME_FACTOR) / DATE_TIME_FACTOR; if (fTime < 0) PushIllegalArgument(); else diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 06d03ba..e843467 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -14,12 +14,11 @@ #include "rangenam.hxx" #include "tokenarray.hxx" #include "stringutil.hxx" +#include "globalnames.hxx" #include "formula/token.hxx" #include "tools/datetime.hxx" -#define D_TIMEFACTOR 86400.0 - using orcus::spreadsheet::row_t; using orcus::spreadsheet::col_t; using orcus::spreadsheet::formula_grammar_t; @@ -169,7 +168,7 @@ void ScOrcusSheet::set_date_time( aTime.GetMin() * 60.0 + aTime.GetHour() * 3600.0; - fTime /= D_TIMEFACTOR; + fTime /= DATE_TIME_FACTOR; mrDoc.SetValue(col, row, mnTab, nDateDiff + fTime); } diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx index 37376e4..ec0f6d4 100644 --- a/sc/source/ui/view/viewfun6.cxx +++ b/sc/source/ui/view/viewfun6.cxx @@ -43,14 +43,12 @@ #include "formulacell.hxx" #include "markdata.hxx" #include "drawview.hxx" +#include "globalnames.hxx" #include <vector> using ::std::vector; -#define D_TIMEFACTOR 86400.0 - - void ScViewFunc::DetectiveAddPred() { ScDocShell* pDocSh = GetViewData()->GetDocShell(); @@ -255,7 +253,7 @@ void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr) double fTime = aActTime.Get100Sec() / 100.0 + aActTime.GetSec() + (aActTime.GetMin() * 60.0) + (aActTime.GetHour() * 3600.0); - fTime /= D_TIMEFACTOR; + fTime /= DATE_TIME_FACTOR; pUndoMgr->EnterListAction(rUndoStr, rUndoStr); pDocSh->GetDocFunc().SetValueCell(aCurPos, fDate+fTime, true); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits