summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/viewfun6.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-12-17 19:13:55 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-12-17 19:13:55 -0500
commit6489f81606a97bdf07659ad5e3b02c08f9b56c8f (patch)
tree19e5b039e5d47c9461016197dea30c6d7e8757ce /sc/source/ui/view/viewfun6.cxx
parente739007b71c4d6fad239365f9ded4c7116eef414 (diff)
When inserting current date/time, set cell format only when necessary.
When the cell already has date or time format set, don't overwrite it when inserting current date or time.
Diffstat (limited to 'sc/source/ui/view/viewfun6.cxx')
-rw-r--r--sc/source/ui/view/viewfun6.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 49a147bb7b2d..2a3a59cf7a34 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -36,6 +36,7 @@
#include <vcl/msgbox.hxx>
#include <vcl/sound.hxx>
#include "svl/zforlist.hxx"
+#include "svl/zformat.hxx"
#include "viewfunc.hxx"
#include "detfunc.hxx"
@@ -302,7 +303,13 @@ void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr)
fTime /= D_TIMEFACTOR;
pUndoMgr->EnterListAction(rUndoStr, rUndoStr);
pDocSh->GetDocFunc().PutCell(aCurPos, new ScValueCell(fDate+fTime), false);
- SetNumberFormat(nCellFmt);
+
+ // Set the new cell format only when it differs from the current cell
+ // format type.
+ sal_uInt32 nCurNumFormat = pDoc->GetNumberFormat(aCurPos);
+ const SvNumberformat* pEntry = pFormatter->GetEntry(nCurNumFormat);
+ if (!pEntry || !(pEntry->GetType() & nCellFmt))
+ SetNumberFormat(nCellFmt);
pUndoMgr->LeaveListAction();
}