summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config_host/config_features.h.in5
-rw-r--r--configure.ac20
-rw-r--r--sc/qa/unit/helper/qahelper.cxx67
3 files changed, 91 insertions, 1 deletions
diff --git a/config_host/config_features.h.in b/config_host/config_features.h.in
index 0f63f26a7c32..6a46e1c3dc09 100644
--- a/config_host/config_features.h.in
+++ b/config_host/config_features.h.in
@@ -120,4 +120,9 @@
*/
#define HAVE_FT_FACE_GETCHARVARIANTINDEX 0
+/*
+ * Whether to use validation on files.
+ */
+#define HAVE_EXPORT_VALIDATION 0
+
#endif
diff --git a/configure.ac b/configure.ac
index 4d980716d9ae..bf2d03c046ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1835,6 +1835,15 @@ AC_ARG_WITH(ant-home,
],
,)
+AC_ARG_WITH(export-validation,
+ AS_HELP_STRING([--with-export-validation],
+ [If you want the exported files to be validated. Right now limited to OOXML files in calc export tests.
+ Note: You need an executable script officeotron that takes the path to the file.])
+ [
+ Usage: --with-export-validation
+ ],
+,)
+
AC_ARG_WITH(junit,
AS_HELP_STRING([--with-junit],
[Specifies the JUnit 4 jar file to use for JUnit-based tests.
@@ -2558,6 +2567,17 @@ dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) suppor
dnl ENABLE_JAVA="" indicate no Java support at all
dnl ===================================================================
+dnl Export file validation
+dnl ===================================================================
+AC_MSG_CHECKING([whether to enable export file validation])
+if test "with_export_validation" != "no"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_EXPORT_VALIDATION)
+else
+ AC_MSG_RESULT([no])
+fi
+
+dnl ===================================================================
dnl Test the Solaris compiler version
dnl ===================================================================
if test "$_os" = "SunOS"; then
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index b875265e16c8..35f5bc92f369 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -587,6 +587,66 @@ void ScBootstrapFixture::createCSVPath(const OUString& aFileBase, OUString& rCSV
rCSVPath = aBuffer.makeStringAndClear();
}
+namespace validation {
+
+enum ScValidationFormat
+{
+ OOXML
+};
+
+}
+
+#if HAVE_EXPORT_VALIDATION
+
+namespace {
+
+void validate(const utl::TempFile& rTempFile, validation::ScValidationFormat eFormat)
+{
+ OUString aValidator;
+ if( eFormat == validation::OOXML )
+ {
+ aValidator = "officeotron ";
+ }
+ else
+ return;
+
+ utl::TempFile aOutput;
+ aOutput.EnableKillingFile();
+ OUString aOutputFile = aOutput.GetFileName();
+ OUString aInputFile = rTempFile.GetFileName();
+ OUString aCommand = aValidator + aInputFile + " > " + aOutputFile;
+
+ system(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8).getStr());
+
+ std::string aContent;
+ loadFile(aOutputFile, aContent);
+ OString aContentString(aContent.c_str());
+ OUString aContentOUString = OStringToOUString(aContentString, RTL_TEXTENCODING_UTF8);
+
+ if( eFormat == validation::OOXML && !aContentOUString.isEmpty() )
+ {
+ // check for validation errors here
+ sal_Int32 nIndex = aContentOUString.lastIndexOf("Grand total of errors in submitted package: ");
+ if(nIndex == -1)
+ {
+ SAL_WARN("sc", "no summery line");
+ }
+ else
+ {
+ sal_Int32 nStartOfNumber = nIndex + std::strlen("Grand total of errors in submitted package: ");
+ OUString aNumber = aContentOUString.copy(nStartOfNumber);
+ sal_Int32 nErrors = aNumber.toInt32();
+ OString aMsg("validation error in OOXML export: Errors: ");
+ aMsg = aMsg + OString::number(nErrors);
+ CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), nErrors == 0);
+ }
+ }
+}
+
+}
+
+#endif
+
ScDocShellRef ScBootstrapFixture::saveAndReload(
ScDocShell* pShell, const OUString &rFilter,
const OUString &rUserData, const OUString& rTypeName, sal_uLong nFormatType)
@@ -613,7 +673,12 @@ ScDocShellRef ScBootstrapFixture::saveAndReload(
if (nFormatType == ODS_FORMAT_TYPE)
nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
- return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormatType, nFormat );
+ ScDocShellRef xDocSh = load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormatType, nFormat );
+#if HAVE_EXPORT_VALIDATION
+ if(nFormatType == XLSX_FORMAT_TYPE)
+ validate(aTempFile, validation::OOXML);
+#endif
+ return xDocSh;
}
ScDocShellRef ScBootstrapFixture::saveAndReload( ScDocShell* pShell, sal_Int32 nFormat )