Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sw/qa/extras/htmlexport/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 8 kB image not shown  

Quelle  xhtmlexport.cxx   Sprache: 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 <memory>
#include <swmodeltestbase.hxx>

#include <test/htmltesttools.hxx>

namespace
{
class XHtmlExportTest : public SwModelTestBase, public HtmlTestTools
{
public:
    XHtmlExportTest()
        : SwModelTestBase(u"/sw/qa/extras/odfexport/data/"_ustr, u"XHTML Writer File"_ustr)
    {
    }
};

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testImageEmbedding)
{
    createSwDoc("image-mimetype.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    htmlDocUniquePtr pDoc = parseHtml(maTempFile);
    CPPUNIT_ASSERT(pDoc);

    assertXPath(pDoc, "/html/body", 1);
    assertXPath(pDoc, "/html/body/div[1]/div[1]/img", 1);
    OUString aValue = getXPath(pDoc, "/html/body/div[1]/div[1]/img""src");
    CPPUNIT_ASSERT(aValue.startsWith("data:image/svg+xml;base64"));
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf131812)
{
    createSwDoc("tdf131812.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    CPPUNIT_ASSERT(
        aStream.indexOf(".paragraph-P1{ font-size:12pt; font-family:\'Liberation Serif\'; "
                        "writing-mode:horizontal-tb; direction:rtl; text-align:right ! important;}")
        != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf146264)
{
    createSwDoc("tdf146264.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    sal_Int32 nFirstHello = aStream.indexOf("Hello");
    CPPUNIT_ASSERT(nFirstHello > 0);
    if (nFirstHello > 0)
    {
        sal_Int32 nSecondHello = aStream.indexOf("Hello", nFirstHello + 1);
        constexpr sal_Int32 nMinusOne = -1;
        CPPUNIT_ASSERT_EQUAL(nMinusOne, nSecondHello);
    }
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf167910)
{
    createSwDoc("tdf167910.fodt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    auto para1{ aStream.indexOf("text-decoration:underline;") };
    CPPUNIT_ASSERT(para1 != -1);
    auto para2{ aStream.indexOf("text-decoration:overline;", para1) };
    CPPUNIT_ASSERT(para2 != -1);
    auto para3{ aStream.indexOf("text-decoration:underline overline;", para2) };
    CPPUNIT_ASSERT(para3 != -1);
    // the paragraph 4 is using commond style not automatic style and these
    // are exported after all automatic ones...
    auto para5{ aStream.indexOf("text-decoration:underline;", para3) };
    CPPUNIT_ASSERT(para5 != -1);
    auto para6{ aStream.indexOf("text-decoration: overline;", para5) };
    CPPUNIT_ASSERT(para6 != -1);
    // this one is style overridden by autostyle
    auto para7{ aStream.indexOf("text-decoration:none ! important;", para6) };
    CPPUNIT_ASSERT(para7 != -1);
    auto para4style{ aStream.indexOf(".paragraph-underover", para7) };
    CPPUNIT_ASSERT(para4style != -1);
    auto para4{ aStream.indexOf("text-decoration:underline overline;", para4style) };
    CPPUNIT_ASSERT(para4 != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf118637)
{
    createSwDoc("tdf118637.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    CPPUNIT_ASSERT(aStream.indexOf("The formula  ") != -1);
    CPPUNIT_ASSERT(aStream.indexOf("should be inline.
"
) != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf145361)
{
    createSwDoc("tdf145361.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    // Without the fix in place, this test would have failed with
    // - SfxBaseModel::impl_store <file:///tmp/lu66091ameq.tmp> failed: 0xc10(Error Area:Io Class:Write Code:16)
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    CPPUNIT_ASSERT(
        aStream.indexOf("List entry has
margin-left:0cm\"/>a line break") != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf142483)
{
    createSwDoc("tdf142483.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    CPPUNIT_ASSERT(
        aStream.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
                        "border-left-color:#000000; border-right-style:none; "
                        "border-top-width:thin; border-top-style:solid; border-top-color:#000000; "
                        "border-bottom-width:thin; border-bottom-style:solid; "
                        "border-bottom-color:#000000;")
        != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
                        "border-left-color:#000000; border-right-style:none; "
                        "border-top-style:none; border-bottom-width:thin; "
                        "border-bottom-style:solid; border-bottom-color:#000000;")
        != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf("border-top-width:thin; border-top-style:solid; border-top-color:#000000; "
                        "border-left-width:thin; border-left-style:solid; "
                        "border-left-color:#000000; border-bottom-width:thin; "
                        "border-bottom-style:solid; border-bottom-color:#000000; "
                        "border-right-width:thin; border-right-style:solid; "
                        "border-right-color:#000000; padding:0.0382in;")
        != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
                        "border-left-color:#000000; border-right-width:thin; "
                        "border-right-style:solid; border-right-color:#000000; "
                        "border-top-style:none; border-bottom-width:thin; "
                        "border-bottom-style:solid; border-bottom-color:#000000;")
        != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf107696)
{
    createSwDoc("tdf107696.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    //tdf#111492
    CPPUNIT_ASSERT(aStream.indexOf("span.heading_numbering { margin-right: 0.8rem; }* { margin:0;}")
                   != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf("

paragraph-Heading_20_2\">
                        "id=\"a__Level_2_without_number\">
Level 2 without number

"
)
        != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf(
            "

paragraph-Heading_20_2\">a_3_1_Level_2__number_3_1\">
            "class=\"heading_numbering\">3.1
Level
            "class=\"text-T2\">2, text-T1\">number 3.1

"
)
        != -1);
    CPPUNIT_ASSERT(
        aStream.indexOf(
            "

paragraph-Heading_20_2\">a_3_2_Level_2__number_3_2\">
            "class=\"heading_numbering\">3.2
Level 2,
            "class=\"text-T1\">number 3.2

"
)
        != -1);
}

CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf66305)
{
    createSwDoc("tdf66305.odt");
    setFilterOptions(u"UTF8"_ustr);
    save(mpFilter);
    SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
    CPPUNIT_ASSERT(pStream);
    sal_uInt64 nLength = pStream->TellEnd();
    OString aStream(read_uInt8s_ToOString(*pStream, nLength));
    CPPUNIT_ASSERT(
        aStream.indexOf("

paragraph-P5\">#__RefHeading__82004_486970805\" "
                        "class=\"text-Internet_20_link\">Introduction


                        "class=\"paragraph-P6\"> 

"
)
        != -1);
}

// end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5
C=94 H=93 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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 und die Messung sind noch experimentell.