Change-Id: I38b80f7bbf93192b7e2e00a426b72b77eb33bf1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210568 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
89 lines
3.0 KiB
C++
89 lines
3.0 KiB
C++
/* -*- 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/.
|
|
*/
|
|
|
|
#include <sal/config.h>
|
|
|
|
#include <comphelper/propertyvalue.hxx>
|
|
#include <test/htmltesttools.hxx>
|
|
#include <test/unoapi_test.hxx>
|
|
|
|
class ScHTMLExportTest : public UnoApiTest, public HtmlTestTools
|
|
{
|
|
public:
|
|
ScHTMLExportTest()
|
|
: UnoApiTest(u"/sc/qa/extras/testdocuments/"_ustr)
|
|
{}
|
|
|
|
void testHtmlSkipImage()
|
|
{
|
|
loadFromFile(u"BaseForHTMLExport.ods");
|
|
save(TestFilter::HTML_CALC);
|
|
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
|
|
CPPUNIT_ASSERT (pDoc);
|
|
|
|
assertXPath(pDoc, "/html/body", 1);
|
|
assertXPath(pDoc, "/html/body/table/tr/td/img", 1);
|
|
|
|
save(TestFilter::HTML_CALC, {
|
|
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"SkipImages"_ustr),
|
|
});
|
|
|
|
pDoc = parseHtml(maTempFile);
|
|
CPPUNIT_ASSERT (pDoc);
|
|
assertXPath(pDoc, "/html/body", 1);
|
|
assertXPath(pDoc, "/html/body/table/tr/td/img", 0);
|
|
}
|
|
|
|
void testTdf155244()
|
|
{
|
|
loadFromFile(u"default-styles.ods");
|
|
save(TestFilter::XHTML_CALC);
|
|
|
|
xmlDocUniquePtr pXmlDoc = parseXml(maTempFile);
|
|
CPPUNIT_ASSERT(pXmlDoc);
|
|
|
|
assertXPath(pXmlDoc, "/xhtml:html", 1);
|
|
// the problem was that there were 2 CSS styles named "Default"
|
|
assertXPath(pXmlDoc, "/xhtml:html/xhtml:body/xhtml:table/xhtml:tr/xhtml:td", "class", u"cell-Default");
|
|
OUString const styles = getXPathContent(pXmlDoc, "/xhtml:html/xhtml:head/xhtml:style");
|
|
CPPUNIT_ASSERT(styles.indexOf(".graphic-Default{ background-color:#729fcf;") != -1);
|
|
CPPUNIT_ASSERT(styles.indexOf(".cell-Default{ font-size:10pt; font-family:'Liberation Sans'; }") != -1);
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), styles.indexOf(".Default"));
|
|
}
|
|
|
|
void testTdf44196_relative_href()
|
|
{
|
|
loadFromFile(u"tdf44196_relative_href.html",
|
|
{
|
|
comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarCalc)"_ustr),
|
|
});
|
|
save(TestFilter::HTML_CALC);
|
|
|
|
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
|
|
CPPUNIT_ASSERT(pDoc);
|
|
|
|
// Without the fix in place, this test would have failed
|
|
// i.e. href attribute would have been turned into an absolute file URL
|
|
CPPUNIT_ASSERT(!getXPath(pDoc, "//a", "href").startsWith("file:"));
|
|
}
|
|
|
|
CPPUNIT_TEST_SUITE(ScHTMLExportTest);
|
|
CPPUNIT_TEST(testHtmlSkipImage);
|
|
CPPUNIT_TEST(testTdf155244);
|
|
CPPUNIT_TEST(testTdf44196_relative_href);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(ScHTMLExportTest);
|
|
|
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|