/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// NB. this constructor is called before any tests are run, once for each // test function in a rather non-intuitive way. This is why all the 'real' // heavy lifting is deferred until setUp. setUp and tearDown are interleaved // between the tests as you might expect.
test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
: m_bNeedUCB( bNeedUCB )
, m_bAssertOnDialog( bAssertOnDialog )
{
}
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, std::u16string_view rFilter)
{
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.");
if (rFilter == u"Office Open XML Text")
{ /* While the spec says the core-properties relationship must be * officedocument/2006/relationships/metadata/core-properties * MS Word actually just writes the ECMA-376-1ST EDITION version * for both ECMA_Transitional and ISO_Transitional formats. * * officeotron doesn't care that clause 15.2.12.1 fails on all MSWord-produced output.
*/
result = filterOut(result, u"Entry with MIME type \"application/vnd.openxmlformats-package.core-properties+xml\" has unrecognized relationship type \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" (see ISO/IEC 29500-1:2008, Clause 15.2.12.1)");
}
#if HAVE_EXPORT_VALIDATION
OUString var; if( eFormat == test::OOXML )
{
var = "OFFICEOTRON";
} elseif ( eFormat == test::ODF )
{
var = "ODFVALIDATOR";
} elseif ( eFormat == test::MSBINARY )
{ #if HAVE_BFFVALIDATOR
var = "BFFVALIDATOR"; #else // Binary Format Validator is disabled return; #endif
}
OUString aValidator;
oslProcessError e = osl_getEnvironment(var.pData, &aValidator.pData);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
OUString("cannot get env var " + var).toUtf8().getStr(),
osl_Process_E_None, e);
CPPUNIT_ASSERT_MESSAGE(
OUString("empty get env var " + var).toUtf8().getStr(),
!aValidator.isEmpty());
if (eFormat == test::ODF)
{ // invoke without -e so that we know when something new is written // in loext namespace that isn't yet in the custom schema
aValidator += " -M "
+ m_directories.getPathFromSrc(u"/schema/libreoffice/OpenDocument-v1.4+libreoffice-manifest-schema.rng")
+ " -D "
+ m_directories.getPathFromSrc(u"/schema/libreoffice/OpenDocument-v1.4+libreoffice-dsig-schema.rng")
+ " -O "
+ m_directories.getPathFromSrc(u"/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng")
+ " -m "
+ m_directories.getPathFromSrc(u"/schema/mathml2/mathml2.xsd");
}
#if !defined _WIN32 // For now, this is only needed by some Linux ASan builds, so keep it simply and disable it on // Windows (which doesn't support the relevant shell syntax for (un-)setting environment // variables).
OUString env; if (test::getArgument(u"env", &env)) { autoconst n = env.indexOf('='); if (n == -1) {
aCommand = "unset -v " + env + " && " + aCommand;
} else {
aCommand = env + " " + aCommand;
}
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.