summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-05-01 14:27:21 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-05-03 20:28:16 -0400
commitd6d4d00114e267142145f0d6bb80a66dd4bca990 (patch)
tree17d4983876985388bc6bd5d614aa420a2fbb3cbd
parent9af4b611190c14b04460e2554735725b4231b685 (diff)
Support date field in cells.
Change-Id: Iff20eb16bb4a7f700b0a533bc745b92fdce8ac0f
-rw-r--r--sc/inc/fielduno.hxx2
-rw-r--r--sc/inc/unonames.hxx5
-rw-r--r--sc/source/core/tool/editutil.cxx6
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx29
-rw-r--r--sc/source/ui/view/editsh.cxx2
5 files changed, 39 insertions, 5 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 8f83eebd480f..f238cf1f1b70 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -225,6 +225,8 @@ private:
boost::scoped_ptr<SvxFieldData> mpData;
com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
+ bool mbIsDate:1;
+
private:
ScEditFieldObj(); // disabled
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 44f1aea6cbae..5ba1a3b760e5 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -329,6 +329,11 @@
#define SC_UNONAME_TARGET "TargetFrame"
#define SC_UNONAME_URL "URL"
+// date time field
+#define SC_UNONAME_ISDATE "IsDate"
+#define SC_UNONAME_ISFIXED "IsFixed"
+#define SC_UNONAME_DATETIME "DateTime"
+
// conditional format
#define SC_UNONAME_OPERATOR "Operator"
#define SC_UNONAME_FORMULA1 "Formula1"
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index af953e56f87b..19134d724be0 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -752,6 +752,12 @@ String ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
aRet = pField->GetFormatted(*mpDoc->GetFormatTable(), ScGlobal::eLnge);
}
break;
+ case SVX_DATEFIELD:
+ {
+ Date aDate(Date::SYSTEM);
+ aRet = ScGlobal::pLocaleData->getDate(aDate);
+ }
+ break;
default:
aRet = "?";
}
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 9a047665c8bc..693c2c457bde 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -59,6 +59,20 @@ namespace {
// alles ohne Which-ID, Map nur fuer PropertySetInfo
+const SfxItemPropertySet* getExtTimePropertySet()
+{
+ static SfxItemPropertyMapEntry aMapContent[] =
+ {
+ { MAP_CHAR_LEN(SC_UNONAME_DATETIME), 0, &getCppuType((const util::DateTime*)0), 0, 0 },
+ { MAP_CHAR_LEN(SC_UNONAME_ISFIXED), 0, &getBooleanCppuType(), 0, 0 },
+ { MAP_CHAR_LEN(SC_UNONAME_ISDATE), 0, &getBooleanCppuType(), 0, 0 },
+ { MAP_CHAR_LEN(SC_UNONAME_NUMFMT), 0, &getCppuType((const sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aMap(aMapContent);
+ return &aMap;
+}
+
const SfxItemPropertySet* lcl_GetURLPropertySet()
{
static SfxItemPropertyMapEntry aURLPropertyMap_Impl[] =
@@ -691,7 +705,12 @@ SvxFieldData* ScEditFieldObj::getData()
mpData.reset(new SvxTimeField);
break;
case ExtTime:
- mpData.reset(new SvxExtTimeField);
+ {
+ if (mbIsDate)
+ mpData.reset(new SvxDateField);
+ else
+ mpData.reset(new SvxExtTimeField);
+ }
break;
case Title:
mpData.reset(new SvxFileField);
@@ -898,8 +917,7 @@ void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const u
{
if (rName == "IsDate")
{
- // TODO: Find out what to do with this.
- sal_Bool b = rVal.get<sal_Bool>();
+ mbIsDate = rVal.get<sal_Bool>();
}
}
@@ -910,7 +928,7 @@ ScEditFieldObj::ScEditFieldObj(
pPropSet(NULL),
mpEditSource(pEditSrc),
aSelection(rSel),
- meType(eType), mpData(NULL), mpContent(rContent)
+ meType(eType), mpData(NULL), mpContent(rContent), mbIsDate(false)
{
switch (meType)
{
@@ -920,6 +938,9 @@ ScEditFieldObj::ScEditFieldObj(
case URL:
pPropSet = lcl_GetURLPropertySet();
break;
+ case ExtTime:
+ pPropSet = getExtTimePropertySet();
+ break;
default:
pPropSet = lcl_GetHeaderFieldPropertySet();
}
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 197b0041d4ac..a1814030bef5 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -616,7 +616,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
break;
case SID_INSERT_FIELD_TEST:
{
- SvxExtTimeField aField;
+ SvxDateField aField;
SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
pTableView->InsertField(aItem);
}