diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-07 20:01:38 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-08 17:51:00 +0100 |
commit | ec1b9bfd9b444fcd3a3559ce1281b08afce19362 (patch) | |
tree | f81479e8a4ba4c6eb648fb5aa59fa957c3996e93 | |
parent | b2385830711ec700956869ace7670edd845a50df (diff) |
ooxml: fix export of empty date controls
The text contained in the <sdtContent> tag acts both as a help message
to the user and as the actual data; for example, Word 2010 is able to
set the date of the control from the text in the content if the
w:fullDate attribute in <date> tag is not set. For that reason we
should not use the sdtContent as the "HelpText" property of the
control in any case, only when it is empty.
The name of the parameter rDefaultText was modified to reflect that
string does not represent any default text, only the content of the
<sdtContent> tag.
Change-Id: Ic10334a949969ec8c7c3e25f73fb937a50ee0f7f
TODO: is it worth to internationalize the help text?
-rw-r--r-- | writerfilter/source/dmapper/SdtHelper.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SdtHelper.hxx | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index 1e1aa4c6dd88..ababd53a4db3 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -91,11 +91,11 @@ void SdtHelper::createDropDownControl() m_aDropDownItems.clear(); } -void SdtHelper::createDateControl(OUString& rDefaultText) +void SdtHelper::createDateControl(OUString& rContentText) { uno::Reference<awt::XControlModel> xControlModel(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.form.component.DateField"), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); - xPropertySet->setPropertyValue("HelpText", uno::makeAny(rDefaultText)); + xPropertySet->setPropertyValue("Dropdown", uno::makeAny(sal_True)); xPropertySet->setPropertyValue("DateFormat", uno::makeAny(*m_oDateFormat)); m_oDateFormat.reset(); @@ -106,10 +106,13 @@ void SdtHelper::createDateControl(OUString& rDefaultText) { utl::extractDate(aDateTime, aDate); xPropertySet->setPropertyValue("Date", uno::makeAny(aDate)); + xPropertySet->setPropertyValue("HelpText", uno::makeAny(OUString("Click here to enter a date"))); } + else + xPropertySet->setPropertyValue("HelpText", uno::makeAny(rContentText)); std::vector<OUString> aItems; - createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), rDefaultText, aItems), xControlModel); + createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), rContentText, aItems), xControlModel); } void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControlModel> xControlModel) diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index f58f00807fe4..65a736b6b0e9 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -74,7 +74,7 @@ public: /// Create drop-down control from w:sdt's w:dropDownList. void createDropDownControl(); /// Create date control from w:sdt's w:date. - void createDateControl(OUString& rDefaultText); + void createDateControl(OUString& rContentText); }; } // namespace dmapper |