cool#16079: keep the date field in a placeholder
A date/time placeholder saved to PPTX held our own display string "<date/time>" as literal text with no <a:fld> at all, so PowerPoint showed that string where the original showed a date. DrawingML::GetFieldValue has no case for the field kind a header/footer date carries, "DateTime", and with no type name nothing writes the field. Name the type that leaves the format to the reading application, datetime: the field carries no format of its own, the page holds it. PowerPoint writes datetimeFigureOut in such a placeholder, an alias of datetime1 - MS-OI29500 part 1, 21.1.2.2.4 (fld) - which would pin a formatless field to MM/DD/YYYY; that alias is read on import as the datetime1 it stands for, so a slide's own date field keeps its format across a round-trip. Every other datetime* type was understood; the one PowerPoint itself writes was being dropped. The page's own DateTimeFormat is out of reach where the type is chosen, so a footer set to show a time is written as a date. PowerPoint has no per-page format to fall back on either way, and a date beats the literal string this replaces. Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com> Change-Id: Icbd9ac57ed7b2311d5f6570fffad1cd78e4d6bf7 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9192 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 145a37d84dd3b22023c46b6be8577008f36a48b9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210141 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
6aba0cf65f
commit
4bfb5aaa80
@@ -215,7 +215,9 @@ SvxDateFormat TextField::getLODateFormat(std::u16string_view rDateTimeType)
|
||||
if( aDateTimeNum.empty() ) // "datetime"
|
||||
return SvxDateFormat::StdSmall;
|
||||
|
||||
int nDateTimeNum = o3tl::toInt32(aDateTimeNum);
|
||||
// "datetimeFigureOut", which is what PowerPoint writes in a date placeholder, is an alias of
|
||||
// datetime1: MS-OI29500 part 1, 21.1.2.2.4 (fld).
|
||||
int nDateTimeNum = aDateTimeNum == u"FigureOut" ? 1 : o3tl::toInt32(aDateTimeNum);
|
||||
|
||||
switch( nDateTimeNum )
|
||||
{
|
||||
|
||||
@@ -3031,6 +3031,12 @@ OUString DrawingML::GetFieldValue( const css::uno::Reference< css::text::XTextRa
|
||||
rXPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
|
||||
aFieldValue = GetDatetimeTypeFromDate(static_cast<SvxDateFormat>(nNumFmt));
|
||||
}
|
||||
else if(aFieldKind == "DateTime")
|
||||
{
|
||||
// The date/time field of a header/footer area carries no format of its own -
|
||||
// the page holds it - and "datetime" seems a perfect fit (see MS-OI29500).
|
||||
aFieldValue = u"datetime"_ustr;
|
||||
}
|
||||
else if(aFieldKind == "ExtTime")
|
||||
{
|
||||
sal_Int32 nNumFmt = -1;
|
||||
|
||||
Binary file not shown.
@@ -2450,6 +2450,21 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testCool16078_placeholderKeepsItsOutlin
|
||||
assertXPath(pLayout, "//p:sp[p:nvSpPr/p:nvPr/p:ph/@type='pic']/p:spPr/a:prstGeom", 0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testCool16079_dateTimeField)
|
||||
{
|
||||
// Given a deck whose date placeholders hold an automatically updated date:
|
||||
createSdImpressDoc("pptx/master-and-eleven-layouts.pptx");
|
||||
save(TestFilter::PPTX);
|
||||
|
||||
// The placeholder keeps a field. Without the fix it held our own display string as literal
|
||||
// text, so PowerPoint showed "<date/time>" where the original showed a date. The type is the
|
||||
// one that leaves the format to the reader, which is what a field holding none asks for - the
|
||||
// alias PowerPoint writes here stands for a fixed MM/DD/YYYY.
|
||||
xmlDocUniquePtr pLayout = parseExportedLayoutNamed(u"Title Slide");
|
||||
assertXPath(pLayout, "//p:sp[p:nvSpPr/p:nvPr/p:ph/@type='dt']/p:txBody/a:p/a:fld", "type",
|
||||
u"datetime");
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user