summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-04-27 15:12:00 +0200
committerGabor Kelemen <kelemeng@ubuntu.com>2023-07-24 18:56:40 +0200
commit2295c2b17cd7b4648f7d0842929be18125c0edab (patch)
tree9b1d1b2aa4ee53193ed2a0c38220177dae9121e2
parent9d68c794d67259a38de1465090f6f1e7fb588d62 (diff)
sw, forms: some hacks to nerf time-fields so convwatch works better
This is useful for PDF-based layout-comparison regression testing where date/time fields were updated upon PDF export and create lots of false positives. Hopefully these can be eliminated this way, at least from text documents. To test: Download https://bugs.documentfoundation.org/attachment.cgi?id=48452 from tdf#38703 and export it with: STABLE_FIELDS_HACK=1 instdir/program/swriter --convert-to pdf DeleteStackSample.odt The date and time fields are now reset to 30/12/1899 00:00:00 Change-Id: Ic89111615074adb50f16a605f920f9a89c437dfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/24442 Tested-by: Jenkins Tested-by: Gabor Kelemen <kelemeng@ubuntu.com> Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
-rw-r--r--forms/source/xforms/xpathlib/xpathlib.cxx7
-rw-r--r--sw/source/core/fields/docufld.cxx7
-rw-r--r--sw/source/core/fields/flddat.cxx10
3 files changed, 20 insertions, 4 deletions
diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx
index e2f0a10eba58..ffae5a59ca34 100644
--- a/forms/source/xforms/xpathlib/xpathlib.cxx
+++ b/forms/source/xforms/xpathlib/xpathlib.cxx
@@ -277,8 +277,11 @@ void xforms_nowFunction(xmlXPathParserContextPtr ctxt, int /*nargs*/)
be omitted or, if present, the time zone must be Coordinated Universal tools::Time (UTC)
indicated by a "Z".
*/
- DateTime aDateTime( DateTime::SYSTEM );
- OString aDateTimeString = makeDateTimeString(aDateTime);
+ OString aDateTimeString;
+ if (std::getenv("STABLE_FIELDS_HACK"))
+ aDateTimeString = makeDateTimeString(DateTime(DateTime::EMPTY));
+ else
+ aDateTimeString = makeDateTimeString(DateTime(DateTime::SYSTEM));
xmlChar *pString = static_cast<xmlChar*>(xmlMalloc(aDateTimeString.getLength()+1));
strncpy(reinterpret_cast<char*>(pString), aDateTimeString.getStr(), aDateTimeString.getLength());
pString[aDateTimeString.getLength()] = 0;
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 97156636ef60..4c3f928ec910 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -945,8 +945,11 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
else if( nSub == DI_PRINT )
{
aName = xDocProps->getPrintedBy();
- uDT = xDocProps->getPrintDate();
- aDate = DateTime(uDT);
+ if ( !std::getenv("STABLE_FIELDS_HACK") )
+ {
+ uDT = xDocProps->getPrintDate();
+ aDate = DateTime(uDT);
+ }
}
else
break;
diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx
index 3dcaf848f417..264b7538f967 100644
--- a/sw/source/core/fields/flddat.cxx
+++ b/sw/source/core/fields/flddat.cxx
@@ -63,6 +63,11 @@ SwDateTimeField::SwDateTimeField(SwDateTimeFieldType* pInitType, sal_uInt16 nSub
OUString SwDateTimeField::ExpandImpl(SwRootFrame const*const) const
{
+ if (getenv("STABLE_FIELDS_HACK"))
+ {
+ const_cast<SwDateTimeField*>(this)->m_nSubType |= FIXEDFLD; //HACK
+ }
+
double fVal;
if (!(IsFixed()))
@@ -131,6 +136,11 @@ double SwDateTimeField::GetDateTime(SwDoc& rDoc, const DateTime& rDT)
double SwDateTimeField::GetValue() const
{
+ if (getenv("STABLE_FIELDS_HACK"))
+ {
+ const_cast<SwDateTimeField*>(this)->m_nSubType |= FIXEDFLD; //HACK
+ }
+
if (IsFixed())
return SwValueField::GetValue();
else