summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-09-21 18:41:17 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-09-21 22:33:12 +0200
commit275aebc5085cd4b0fd3d045ef1ec65c99e1d5b56 (patch)
treed7167d059c4eca421d8a692f330bc7e003ee946a /test
parent03467e12660a61c467e4947681e827435c3beaea (diff)
tdf#163064: pic element is required here, after all
In commit cf15306ccf49da290b391517e2c5dd22a4f1be45 (ERROR: Invalid content was found starting with element 'p:pic'., 2014-12-22), the pic element inside the oleObj element was only alloswed for the old revision of ECMA-736 export, because that was considered invalid by officeotron. However, as of ECMA-376-1:2016, this element is mandatory; CT_OleObject definition in Annex A has: <xsd:element name="pic" type="CT_Picture" minOccurs="1" maxOccurs="1"/> and Annex L (Primer) has L.7.2.5 "Embeddings in a PresentationML Document" saying: The oleObj element shall have a pic child element that (optionally) contains the image data to be used in place of loading the actual object data. The omission of this in the export is the reason of tdf#163064. So here I filter out the error from the validation results, which is not ideal (I have no way to know if the found pic is really in the oleObj, or somewhere else), but a lesser evil, compared to required exclusion of all tests that export OLE objects. Change-Id: Ia73a49da7347e8ff22c626e211b55ba1e0625070 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173761 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'test')
-rw-r--r--test/source/bootstrapfixture.cxx58
1 files changed, 56 insertions, 2 deletions
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index 891af3c6f640..4cf04adf3db3 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -138,6 +138,59 @@ OString loadFile(const OUString& rURL)
return aContent;
}
+constexpr std::u16string_view grand_total = u"Grand total of errors in submitted package: ";
+
+OUString filterOut(const OUString& s, std::u16string_view excludedSubstr)
+{
+ OUString result = s;
+ for (;;)
+ {
+ sal_Int32 pos = result.indexOf(excludedSubstr);
+ if (pos < 0)
+ break;
+ sal_Int32 start = result.lastIndexOf('\n', pos);
+ if (!result.match("ERROR", start + 1))
+ return s; // unexpected string format
+ sal_Int32 end = result.indexOf('\n', pos);
+ result = result.replaceAt(start, end - start, u""_ustr);
+ pos = result.lastIndexOf(grand_total);
+ if (pos < 0)
+ return s; // unexpected string format
+ start = end = pos + grand_total.size();
+ while (end < result.getLength() && rtl::isAsciiDigit(result[end]))
+ ++end;
+ std::u16string_view aNumber = result.subView(start, end - start);
+ sal_Int32 nErrors = o3tl::toInt32(aNumber) - 1;
+ result = result.replaceAt(start, end - start, OUString::number(nErrors));
+ }
+ return result;
+}
+
+OUString filterValidationResults(const OUString& s)
+{
+ OUString result = s;
+ // In ECMA-376-1 Second Edition, 2008, there is the following restriction for oleObj:
+ //
+ // <xsd:choice minOccurs="1" maxOccurs="1">
+ // <xsd:element name="embed" type="CT_OleObjectEmbed"/>
+ // <xsd:element name="link" type="CT_OleObjectLink"/>
+ // <xsd:element name="pic" type="CT_Picture"/>
+ // </xsd:choice>
+ //
+ // This makes simultaneous use of embed (or link) and pic impossible. This was obviously a
+ // mistake; and the following editions of standard fixed it: e.g., in ECMA-376-1:2016, that
+ // rule is
+ //
+ // <xsd:choice minOccurs="1" maxOccurs="1">
+ // <xsd:element name="embed" type="CT_OleObjectEmbed"/>
+ // <xsd:element name="link" type="CT_OleObjectLink"/>
+ // </xsd:choice>
+ // <xsd:element name="pic" type="CT_Picture" minOccurs="1" maxOccurs="1"/>
+ //
+ // But officeotron only knows the old version...
+ result = filterOut(result, u"Invalid content was found starting with element 'p:pic'. No child element is expected at this point.");
+ return result;
+}
}
#endif
@@ -213,15 +266,16 @@ void test::BootstrapFixture::validate(const OUString& rPath, test::ValidationFor
if( eFormat == test::OOXML && !aContentOUString.isEmpty() )
{
+ aContentOUString = filterValidationResults(aContentOUString);
// check for validation errors here
- sal_Int32 nIndex = aContentOUString.lastIndexOf("Grand total of errors in submitted package: ");
+ sal_Int32 nIndex = aContentOUString.lastIndexOf(grand_total);
if(nIndex == -1)
{
SAL_WARN("test", "no summary line");
}
else
{
- sal_Int32 nStartOfNumber = nIndex + std::strlen("Grand total of errors in submitted package: ");
+ sal_Int32 nStartOfNumber = nIndex + grand_total.size();
std::u16string_view aNumber = aContentOUString.subView(nStartOfNumber);
sal_Int32 nErrors = o3tl::toInt32(aNumber);
OString aMsg = "validation error in OOXML export: Errors: " + OString::number(nErrors);