[ooo-build-commit] .: sc/inc sc/sdi sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Oct 4 15:26:42 PDT 2010


 sc/inc/globstr.hrc             |    5 ++--
 sc/inc/sc.hrc                  |    4 +++
 sc/sdi/cellsh.sdi              |    2 +
 sc/sdi/scalc.sdi               |   51 +++++++++++++++++++++++++++++++++++++++++
 sc/source/ui/inc/viewfunc.hxx  |    2 +
 sc/source/ui/src/globstr.src   |    8 ++++++
 sc/source/ui/view/cellsh1.cxx  |    8 ++++++
 sc/source/ui/view/viewfun6.cxx |   26 ++++++++++++++++++++
 8 files changed, 104 insertions(+), 2 deletions(-)

New commits:
commit a942680c9c876b9d5f17b6f9c94a67c1762ac3b9
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Oct 4 18:15:55 2010 -0400

    Ported calc-insert-current-time-sc.diff from ooo-build.
    
    This enables quick insertion of current date and time into current
    cell, via command.  By default, these commands are bound to
    
    * Ctrl-';'
    * Ctrl-Shift-';'
    
    respectively.

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 74494b1..6f7cf24 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -570,13 +570,14 @@
 #define STR_STYLE_FAMILY_PAGE       434
 
 #define STR_ERR_DATAPILOTSOURCE		435
-#define STR_PIVOT_FIRSTROWEMPTYERR      436
+#define STR_PIVOT_FIRSTROWEMPTYERR  436
 #define STR_PIVOT_ONLYONEROWERR		437
 
 #define STR_UNDO_SET_TAB_BG_COLOR       438
 #define STR_UNDO_SET_MULTI_TAB_BG_COLOR 439
+#define STR_UNDO_INSERT_CURRENT_TIME    440
 
-#define STR_COUNT                       440
+#define STR_COUNT                       441
 
 #endif
 
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index df6ba2e..3eabf42 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -1669,6 +1669,10 @@
 #define RID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 2)
 #define HID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 3)
 
+// Insert current date and time to cell via command
+#define SID_INSERT_CURRENT_DATE     (SC_OOO_BUILD_START + 4)
+#define SID_INSERT_CURRENT_TIME     (SC_OOO_BUILD_START + 5)
+
 #endif
 
 
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 957c3d1..c5677d0 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -114,6 +114,8 @@ interface CellSelection
     SID_DETECTIVE_REFRESH	[ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
     SID_DETECTIVE_MARK_PRED	[ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
     SID_DETECTIVE_MARK_SUCC	[ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
+    SID_INSERT_CURRENT_DATE     [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
+    SID_INSERT_CURRENT_TIME     [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
     FID_INS_ROW				[ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
     FID_INS_COLUMN			[ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
     FID_INS_CELLSDOWN		[ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 50ddc46..4e56491 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -7877,6 +7877,57 @@ SfxVoidItem MarkDependents SID_DETECTIVE_MARK_SUCC
     ToolBoxConfig = FALSE,
     GroupId = GID_OPTIONS;
 ]
+
+//--------------------------------------------------------------------------
+SfxVoidItem InsertCurrentDate SID_INSERT_CURRENT_DATE
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_OPTIONS;
+]
+
+//--------------------------------------------------------------------------
+SfxVoidItem InsertCurrentTime SID_INSERT_CURRENT_TIME
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_OPTIONS;
+]
+
 //--------------------------------------------------------------------------
 SfxVoidItem SetTabBgColor FID_TAB_MENU_SET_TAB_BG_COLOR
 (SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR)
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index f60cb46..398b56e 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -328,6 +328,8 @@ public:
     void            DetectiveMarkPred();
     void            DetectiveMarkSucc();
 
+    void            InsertCurrentTime(short nCellFmt, const ::rtl::OUString& rUndoStr);
+
     void			ShowNote( bool bShow = true );
     inline void		HideNote() { ShowNote( false ); }
     void			EditNote();
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 37f0d31..c769258 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1738,5 +1738,13 @@ Resource RID_GLOBSTR
     {
         Text [ en-US ] = "DataPilot table needs at least two rows of data to create or refresh." ;
     };
+    String STR_UNDO_INSERT_CURRENT_DATE
+    {
+        Text [ en-US ] = "Insert Current Date";
+    };
+    String STR_UNDO_INSERT_CURRENT_TIME
+    {
+        Text [ en-US ] = "Insert Current Time";
+    };
 };
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 4c4f624..ce49f12 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1526,6 +1526,14 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         case SID_DETECTIVE_MARK_SUCC:
             pTabViewShell->DetectiveMarkSucc();
             break;
+        case SID_INSERT_CURRENT_DATE:
+            pTabViewShell->InsertCurrentTime(
+                NUMBERFORMAT_DATE, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE));
+            break;
+        case SID_INSERT_CURRENT_TIME:
+            pTabViewShell->InsertCurrentTime(
+                NUMBERFORMAT_TIME, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME));
+            break;
 
         case SID_SPELL_DIALOG:
 //           pTabViewShell->DoSpellingChecker();
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index ce62dd0..c63909e 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -34,6 +34,7 @@
 #include <sfx2/dispatch.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/sound.hxx>
+#include "svl/zforlist.hxx"
 
 #include "viewfunc.hxx"
 #include "detfunc.hxx"
@@ -49,12 +50,16 @@
 #include "fusel.hxx"
 #include "reftokenhelper.hxx"
 #include "externalrefmgr.hxx"
+#include "cell.hxx"
 
 #include <vector>
 
+using ::rtl::OUString;
 using ::rtl::OUStringBuffer;
 using ::std::vector;
 
+#define D_TIMEFACTOR              86400.0
+
 //==================================================================
 
 void ScViewFunc::DetectiveAddPred()
@@ -274,6 +279,27 @@ void ScViewFunc::DetectiveMarkSucc()
     MarkAndJumpToRanges(aDestRanges);
 }
 
+void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr)
+{
+    ScViewData* pViewData = GetViewData();
+    ScAddress aCurPos = pViewData->GetCurPos();
+    ScDocShell* pDocSh = pViewData->GetDocShell();
+    ScDocument* pDoc = pDocSh->GetDocument();
+    SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+    SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+    Date aActDate;
+    double fDate = aActDate - *pFormatter->GetNullDate();
+    Time aActTime;
+    double fTime =
+        aActTime.Get100Sec() / 100.0 + aActTime.GetSec() +
+        (aActTime.GetMin() * 60.0) + (aActTime.GetHour() * 3600.0);
+    fTime /= D_TIMEFACTOR;
+    pUndoMgr->EnterListAction(rUndoStr, rUndoStr);
+    pDocSh->GetDocFunc().PutCell(aCurPos, new ScValueCell(fDate+fTime), false);
+    SetNumberFormat(nCellFmt);
+    pUndoMgr->LeaveListAction();
+}
+
 //---------------------------------------------------------------------------
 
 void ScViewFunc::ShowNote( bool bShow )


More information about the ooo-build-commit mailing list