summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-10-04 18:15:55 -0400
committerKohei Yoshida <kyoshida@novell.com>2010-10-04 18:15:55 -0400
commitb91b8e9098cdbdfac414ebb0e036edc962056ce8 (patch)
tree5c955157b4d0d16a1405fe16476bfc5399a47943
parentf7e2c840aa9d243cf0dee58713e71de895b292ce (diff)
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.
-rw-r--r--sc/inc/globstr.hrc5
-rw-r--r--sc/inc/sc.hrc4
-rw-r--r--sc/sdi/cellsh.sdi2
-rw-r--r--sc/sdi/scalc.sdi51
-rw-r--r--sc/source/ui/inc/viewfunc.hxx2
-rw-r--r--sc/source/ui/src/globstr.src8
-rw-r--r--sc/source/ui/view/cellsh1.cxx8
-rw-r--r--sc/source/ui/view/viewfun6.cxx26
8 files changed, 104 insertions, 2 deletions
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index de416413be31..0773504b6097 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 4d4c94d32d04..5264651b3859 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 714314472328..3e35a77d9723 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 e72b3e33ddf7..d2d425c7b646 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 05a168606f46..301c3e5663f7 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 6c15762bda6a..2fd50d5f97f3 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 90caf6607080..2fd7fbee2542 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 f00c0bcde688..eaa55f50a0e2 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 )