[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Dec 17 16:16:36 PST 2010


 sc/source/ui/view/viewfun6.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 58eaad24d878fbf08c5fd6762230428bd30f5e83
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Dec 17 19:13:55 2010 -0500

    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.

diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 2aa8aaa..51e0179 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();
 }
 


More information about the Libreoffice-commits mailing list