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?
This commit is contained in:
Jacobo Aragunde Pérez
2014-03-07 20:01:38 +01:00
parent b238583071
commit ec1b9bfd9b
2 changed files with 7 additions and 4 deletions

View File

@@ -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)

View File

@@ -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