office-gobmx/sc/qa/extras/htmlexporttest.cxx
Svante Schubert 2d9f739ccf tdf#155244 filter: XHTML export: Making ODF style IDs unique for ...
... HTML/CSS by adding a prefix (the @style:family with '-' as glue character)
to their style name.

Disabled debug output for style:family-name in XSL

add text:a to text family

... and add a unit test.

Change-Id: Ie846f5ea2a872872f38036aff59d29c8f530ed32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152749
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-06-09 15:12:40 +02:00

81 lines
2.5 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 <string_view>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <test/htmltesttools.hxx>
#include <test/unoapixml_test.hxx>
#include <comphelper/processfactory.hxx>
using namespace css::uno;
using namespace css::lang;
using namespace css::frame;
using namespace utl;
class ScHTMLExportTest : public UnoApiXmlTest, public HtmlTestTools
{
public:
ScHTMLExportTest()
: UnoApiXmlTest("/sc/qa/extras/testdocuments/")
{}
void testHtmlSkipImage()
{
loadFromURL(u"BaseForHTMLExport.ods");
save("HTML (StarCalc)");
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/table/tr/td/img", 1);
setFilterOptions("SkipImages");
save("HTML (StarCalc)");
pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/table/tr/td/img", 0);
}
void testTdf155244()
{
loadFromURL(u"default-styles.ods");
save("XHTML Calc File");
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", "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"));
}
CPPUNIT_TEST_SUITE(ScHTMLExportTest);
CPPUNIT_TEST(testHtmlSkipImage);
CPPUNIT_TEST(testTdf155244);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(ScHTMLExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */