svx/source/unodraw/unoprov.cxx | 1 sw/qa/extras/ooxmlexport/data/combobox-control.docx |binary sw/qa/extras/ooxmlexport/data/date-control.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 25 ++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 76 +++++++++++++++++++- writerfilter/source/dmapper/DomainMapper.cxx | 18 +--- writerfilter/source/dmapper/SdtHelper.cxx | 44 ++++++++++- writerfilter/source/dmapper/SdtHelper.hxx | 11 ++ writerfilter/source/ooxml/model.xml | 1 9 files changed, 153 insertions(+), 23 deletions(-)
New commits: commit 554a0ca639504a2fc6ac99555df161ad3fe636bc Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Mar 10 19:36:04 2014 +0100 ooxml: export combo box controls Export combo box controls as <sdt> elements. Added unit test. Change-Id: I9eda25101240ec61f78ede0f0462d3ab8e77b09b diff --git a/sw/qa/extras/ooxmlexport/data/combobox-control.docx b/sw/qa/extras/ooxmlexport/data/combobox-control.docx new file mode 100644 index 0000000..180aaca Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/combobox-control.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 6175b87..632a73d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2975,6 +2975,27 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year)); } +DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo"); + + // check imported control + uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text")); + + uno::Sequence<OUString> aItems = getProperty<uno::Sequence<OUString>>(xControl->getControl(), "StringItemList"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength())); + CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]); + CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 65f3676..7b34920 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3685,6 +3685,42 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) m_pSerializer->endElementNS(XML_w, XML_sdt); } + else if (xInfo->supportsService("com.sun.star.form.component.ComboBox")) + { + // gather component properties + + uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); + OUString sText = xPropertySet->getPropertyValue("Text").get<OUString>(); + uno::Sequence<OUString> aItems = xPropertySet->getPropertyValue("StringItemList").get<uno::Sequence<OUString>>(); + + // output component + + m_pSerializer->startElementNS(XML_w, XML_sdt, FSEND); + m_pSerializer->startElementNS(XML_w, XML_sdtPr, FSEND); + + m_pSerializer->startElementNS(XML_w, XML_dropDownList, FSEND); + + for (sal_Int32 i=0; i < aItems.getLength(); ++i) + { + m_pSerializer->singleElementNS(XML_w, XML_listItem, + FSNS(XML_w, XML_displayText), + rtl::OUStringToOString( aItems[i], RTL_TEXTENCODING_UTF8 ).getStr(), + FSNS(XML_w, XML_value), + rtl::OUStringToOString( aItems[i], RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND); + } + + m_pSerializer->endElementNS(XML_w, XML_dropDownList); + m_pSerializer->endElementNS(XML_w, XML_sdtPr); + + m_pSerializer->startElementNS(XML_w, XML_sdtContent, FSEND); + m_pSerializer->startElementNS(XML_w, XML_r, FSEND); + RunText(sText); + m_pSerializer->endElementNS(XML_w, XML_r); + m_pSerializer->endElementNS(XML_w, XML_sdtContent); + + m_pSerializer->endElementNS(XML_w, XML_sdt); + } } } } commit c483e0eeb896b0719f27156e922c102312d98753 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Mar 10 14:22:55 2014 +0100 ooxml: preserve locale attribute in date controls It is stored in the shape grab bag on import and saved back on export. Defaults to "en-US" if not present in the bag. Added a check for this attribute in the unit test. Change-Id: Ib9c74f120628dbfc5e035500424cbad8caed53fe diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 957dfbe..6175b87 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2964,6 +2964,7 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx") return; assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z"); assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES"); assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "miércoles, 05 de marzo de 2014"); // check imported control diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a233c23..65f3676 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3601,12 +3601,15 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) Date aOriginalDate(Date::EMPTY); OUString sOriginalContent, sDateFormat; + OUString sLocale("en-US"); uno::Sequence<beans::PropertyValue> aGrabBag; uno::Reference<beans::XPropertySet> xShapePropertySet(pFormObj->getUnoShape(), uno::UNO_QUERY); if (xShapePropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBag) for (sal_Int32 i=0; i < aGrabBag.getLength(); ++i) if (aGrabBag[i].Name == "DateFormat") aGrabBag[i].Value >>= sDateFormat; + else if (aGrabBag[i].Name == "Locale") + aGrabBag[i].Value >>= sLocale; else if (aGrabBag[i].Name == "OriginalContent") aGrabBag[i].Value >>= sOriginalContent; else if (aGrabBag[i].Name == "OriginalDate") @@ -3661,7 +3664,8 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) rtl::OUStringToOString( sDateFormat, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND); m_pSerializer->singleElementNS(XML_w, XML_lid, - FSNS(XML_w, XML_val), "en-US", //TODO: hardwired + FSNS(XML_w, XML_val), + rtl::OUStringToOString( sLocale, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND); m_pSerializer->singleElementNS(XML_w, XML_storeMappedDataAs, FSNS(XML_w, XML_val), "dateTime", diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index a3dee04..c5f761f 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2223,6 +2223,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) m_pImpl->m_pSdtHelper->getDateFormat().append(sStringValue); } break; + case NS_ooxml::LN_CT_SdtDate_lid: + { + m_pImpl->m_pSdtHelper->getLocale().append(sStringValue); + } + break; case NS_ooxml::LN_EG_SectPrContents_pgNumType: { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index 29ccf47..164712f 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -122,13 +122,15 @@ void SdtHelper::createDateControl(OUString& rContentText) xPropertySet->setPropertyValue("HelpText", uno::makeAny(rContentText)); // append date format to grab bag - uno::Sequence<beans::PropertyValue> aGrabBag(3); + uno::Sequence<beans::PropertyValue> aGrabBag(4); aGrabBag[0].Name = "OriginalDate"; aGrabBag[0].Value = uno::makeAny(aDate); aGrabBag[1].Name = "OriginalContent"; aGrabBag[1].Value = uno::makeAny(rContentText); aGrabBag[2].Name = "DateFormat"; aGrabBag[2].Value = uno::makeAny(sDateFormat); + aGrabBag[3].Name = "Locale"; + aGrabBag[3].Value = uno::makeAny(m_sLocale.makeStringAndClear()); std::vector<OUString> aItems; createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), rContentText, aItems), xControlModel, aGrabBag); @@ -176,6 +178,11 @@ OUStringBuffer& SdtHelper::getDateFormat() return m_sDateFormat; } +OUStringBuffer& SdtHelper::getLocale() +{ + return m_sLocale; +} + bool SdtHelper::hasElements() { return m_bHasElements; diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index 8d89dea..7d9f9cb 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -55,6 +55,8 @@ class SdtHelper OUStringBuffer m_sDate; /// Date format string as it comes from the ooxml document. OUStringBuffer m_sDateFormat; + /// Locale string as it comes from the ooxml document. + OUStringBuffer m_sLocale; bool m_bHasElements; @@ -70,6 +72,7 @@ public: OUStringBuffer& getSdtTexts(); OUStringBuffer& getDate(); OUStringBuffer& getDateFormat(); + OUStringBuffer& getLocale(); /// If createControlShape() was ever called. bool hasElements(); diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index e0d3bb4..ec54c2b 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -24569,6 +24569,7 @@ <resource name="CT_SdtDate" resource="Properties" tag="field"> <attribute name="fullDate" tokenid="ooxml:CT_SdtDate_fullDate"/> <element name="dateFormat" tokenid="ooxml:CT_SdtDate_dateFormat"/> + <element name="lid" tokenid="ooxml:CT_SdtDate_lid"/> </resource> <resource name="CT_SdtListItem" resource="Properties" tag="field"> <attribute name="displayText" tokenid="ooxml:CT_SdtListItem_displayText"/> commit e172825b535da17c1a1d70ee1caebf43c933f39a Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Mar 10 17:53:44 2014 +0100 ooxml: preserve dateFormat for unchanged date controls When saving a date control in a docx document, we were overwriting its date format with "dd/MM/yyyy" because it's tricky to support all the possible combinations. Nonetheless, there is no need to overwrite it if the date in the control remains unchanged during edition. We preserve the original date of the control, its date format and the formatted date string on import, and we compare the date in the control with the original one on export to check if we can write the old values or we have to re-generate them. Only in case the date has changed the format will be reset to "dd/MM/yyyy". We had to add an InteropGrabBag field to the XControlShape because it didn't have one, unlike other shapes. Unit tests were modified to check that the dateFormat field is preserved unchanged. Change-Id: I01e5c990e90ff190b5a6d7ea3853e049ff24ef0a diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index 986c290..da19e34 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -618,6 +618,7 @@ SfxItemPropertyMapEntry const * ImplGetSvxControlShapePropertyMap() // #i112587# { OUString(UNO_NAME_MISC_OBJ_PRINTABLE), SDRATTR_OBJPRINTABLE , ::getBooleanCppuType(), 0, 0}, { OUString("Visible"), SDRATTR_OBJVISIBLE , ::getBooleanCppuType(), 0, 0}, + { OUString(UNO_NAME_MISC_OBJ_INTEROPGRABBAG), OWN_ATTR_INTEROPGRABBAG, ::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0), 0, 0}, { OUString(), 0, css::uno::Type(), 0, 0 } }; diff --git a/sw/qa/extras/ooxmlexport/data/date-control.docx b/sw/qa/extras/ooxmlexport/data/date-control.docx index 0563d56..fdf2299 100644 Binary files a/sw/qa/extras/ooxmlexport/data/date-control.docx and b/sw/qa/extras/ooxmlexport/data/date-control.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 80189af..957dfbe 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2963,7 +2963,8 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx") if (!pXmlDoc) return; assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z"); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "05/03/2014"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "miércoles, 05 de marzo de 2014"); // check imported control uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2949271..a233c23 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3599,6 +3599,25 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) { // gather component properties + Date aOriginalDate(Date::EMPTY); + OUString sOriginalContent, sDateFormat; + uno::Sequence<beans::PropertyValue> aGrabBag; + uno::Reference<beans::XPropertySet> xShapePropertySet(pFormObj->getUnoShape(), uno::UNO_QUERY); + if (xShapePropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBag) + for (sal_Int32 i=0; i < aGrabBag.getLength(); ++i) + if (aGrabBag[i].Name == "DateFormat") + aGrabBag[i].Value >>= sDateFormat; + else if (aGrabBag[i].Name == "OriginalContent") + aGrabBag[i].Value >>= sOriginalContent; + else if (aGrabBag[i].Name == "OriginalDate") + { + css::util::Date aUNODate; + aGrabBag[i].Value >>= aUNODate; + aOriginalDate.SetDay(aUNODate.Day); + aOriginalDate.SetMonth(aUNODate.Month); + aOriginalDate.SetYear(aUNODate.Year); + } + uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); OString sDate; @@ -3610,7 +3629,17 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) bHasDate = true; Date aDate(aUNODate.Day, aUNODate.Month, aUNODate.Year); sDate = DateToOString(aDate); - aContentText = OUString::createFromAscii(DateToDDMMYYYYOString(aDate).getStr()); + + if (aOriginalDate == aDate) + { + aContentText = sOriginalContent; + // sDateFormat was extracted from the grab bag + } + else + { + aContentText = OUString::createFromAscii(DateToDDMMYYYYOString(aDate).getStr()); + sDateFormat = "dd/MM/yyyy"; + } } else aContentText = xPropertySet->getPropertyValue("HelpText").get<OUString>(); @@ -3628,7 +3657,8 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) m_pSerializer->startElementNS(XML_w, XML_date, FSEND); m_pSerializer->singleElementNS(XML_w, XML_dateFormat, - FSNS(XML_w, XML_val), "dd/MM/yyyy", //TODO: hardwired + FSNS(XML_w, XML_val), + rtl::OUStringToOString( sDateFormat, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND); m_pSerializer->singleElementNS(XML_w, XML_lid, FSNS(XML_w, XML_val), "en-US", //TODO: hardwired diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index 63b726a..29ccf47 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -12,6 +12,7 @@ #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/text/VertOrientation.hpp> +#include <editeng/unoprnms.hxx> #include <vcl/outdev.hxx> #include <vcl/svapp.hxx> #include <unotools/datetime.hxx> @@ -120,12 +121,26 @@ void SdtHelper::createDateControl(OUString& rContentText) else xPropertySet->setPropertyValue("HelpText", uno::makeAny(rContentText)); + // append date format to grab bag + uno::Sequence<beans::PropertyValue> aGrabBag(3); + aGrabBag[0].Name = "OriginalDate"; + aGrabBag[0].Value = uno::makeAny(aDate); + aGrabBag[1].Name = "OriginalContent"; + aGrabBag[1].Value = uno::makeAny(rContentText); + aGrabBag[2].Name = "DateFormat"; + aGrabBag[2].Value = uno::makeAny(sDateFormat); + std::vector<OUString> aItems; - createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), rContentText, aItems), xControlModel); + createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), rContentText, aItems), xControlModel, aGrabBag); } void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControlModel> xControlModel) { + createControlShape(aSize, xControlModel, uno::Sequence<beans::PropertyValue>()); +} + +void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControlModel> xControlModel, uno::Sequence<beans::PropertyValue> rGrabBag) +{ uno::Reference<drawing::XControlShape> xControlShape(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY); xControlShape->setSize(aSize); xControlShape->setControl(xControlModel); @@ -133,6 +148,9 @@ void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControl uno::Reference<beans::XPropertySet> xPropertySet(xControlShape, uno::UNO_QUERY); xPropertySet->setPropertyValue("VertOrient", uno::makeAny(text::VertOrientation::CENTER)); + if(rGrabBag.hasElements()) + xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG, uno::makeAny(rGrabBag)); + uno::Reference<text::XTextContent> xTextContent(xControlShape, uno::UNO_QUERY); m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence< beans::PropertyValue >()); m_bHasElements = true; diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index e91d9b7..8d89dea 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -60,6 +60,8 @@ class SdtHelper /// Create and append the drawing::XControlShape, containing the various models. void createControlShape(com::sun::star::awt::Size aSize, com::sun::star::uno::Reference<com::sun::star::awt::XControlModel>); + void createControlShape(com::sun::star::awt::Size aSize, com::sun::star::uno::Reference<com::sun::star::awt::XControlModel>, + com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> rGrabBag); public: SdtHelper(DomainMapper_Impl& rDM_Impl); virtual ~SdtHelper(); commit e8e4ba0b68f717b19e4766bcaf4d14486bb11c8b Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Mon Mar 10 17:50:19 2014 +0100 writerfilter: DateFormat member in SdtHelper as a string. Change the type of DateFormat member of SdtHelper class to a string, and move some logic from DomainMapper to SdtHelper. The string will be useful to improve the date control exporter later. Change-Id: I0da05a59e15143027f1c5805466e9f465d7ac069 diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c7e6344..a3dee04 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2220,16 +2220,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) break; case NS_ooxml::LN_CT_SdtDate_dateFormat: { - // See com/sun/star/awt/UnoControlDateFieldModel.idl, DateFormat; sadly there are no constants for this. - if (sStringValue == "M/d/yyyy" || sStringValue == "M.d.yyyy") - // Approximate with MM.dd.yyy - m_pImpl->m_pSdtHelper->getDateFormat().reset(8); - else - { - // Set default format, so at least the date picker is created. - m_pImpl->m_pSdtHelper->getDateFormat().reset(0); - SAL_WARN("writerfilter", "unhandled w:dateFormat value"); - } + m_pImpl->m_pSdtHelper->getDateFormat().append(sStringValue); } break; case NS_ooxml::LN_EG_SectPrContents_pgNumType: @@ -2608,7 +2599,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) m_pImpl->m_pSdtHelper->getSdtTexts().append(sText); return; } - else if (m_pImpl->m_pSdtHelper->getDateFormat()) + else if (!m_pImpl->m_pSdtHelper->getDateFormat().isEmpty()) { /* * Here we assume w:sdt only contains a single text token. We need to diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index ababd53..63b726a 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -97,8 +97,17 @@ void SdtHelper::createDateControl(OUString& rContentText) uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); xPropertySet->setPropertyValue("Dropdown", uno::makeAny(sal_True)); - xPropertySet->setPropertyValue("DateFormat", uno::makeAny(*m_oDateFormat)); - m_oDateFormat.reset(); + + // See com/sun/star/awt/UnoControlDateFieldModel.idl, DateFormat; sadly there are no constants + sal_Int16 nDateFormat = 0; + OUString sDateFormat = m_sDateFormat.makeStringAndClear(); + if (sDateFormat == "M/d/yyyy" || sDateFormat == "M.d.yyyy") + // Approximate with MM.dd.yyy + nDateFormat = 8; + else + // Set default format, so at least the date picker is created. + SAL_WARN("writerfilter", "unhandled w:dateFormat value"); + xPropertySet->setPropertyValue("DateFormat", uno::makeAny(nDateFormat)); util::Date aDate; util::DateTime aDateTime; @@ -144,9 +153,9 @@ OUStringBuffer& SdtHelper::getDate() return m_sDate; } -boost::optional<sal_Int16>& SdtHelper::getDateFormat() +OUStringBuffer& SdtHelper::getDateFormat() { - return m_oDateFormat; + return m_sDateFormat; } bool SdtHelper::hasElements() diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index 65a736b..e91d9b7 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -53,8 +53,8 @@ class SdtHelper OUStringBuffer m_aSdtTexts; /// Date ISO string contained in the w:date element, used by the date control. OUStringBuffer m_sDate; - /// Date format, see com/sun/star/awt/UnoControlDateFieldModel.idl - boost::optional<sal_Int16> m_oDateFormat; + /// Date format string as it comes from the ooxml document. + OUStringBuffer m_sDateFormat; bool m_bHasElements; @@ -67,7 +67,7 @@ public: std::vector<OUString>& getDropDownItems(); OUStringBuffer& getSdtTexts(); OUStringBuffer& getDate(); - boost::optional<sal_Int16>& getDateFormat(); + OUStringBuffer& getDateFormat(); /// If createControlShape() was ever called. bool hasElements();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits