summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-11-19 13:22:12 +0100
committerStephan Bergmann <sbergman@redhat.com>2023-11-19 15:23:17 +0100
commite4d8f186d07aa1999e16abff3381e37b8764e964 (patch)
treed042418674d11c06f4efd3344875c75b14106093
parent694763542e32b1e6354f919526751677945f1cd9 (diff)
Extended loplugin:ostr: writerperfect
Change-Id: Ib942f7725e224b7c4beaca4cd4d86b83f60cd3f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159664 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx236
1 files changed, 125 insertions, 111 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index f667213288bf..86e7a4502ed3 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -149,7 +149,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMimetype)
SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ);
SvMemoryStream aMemoryStream;
aMemoryStream.WriteStream(aFileStream);
- OString aExpected("application/epub+zip");
+ OString aExpected("application/epub+zip"_ostr);
CPPUNIT_ASSERT(aMemoryStream.GetSize() > static_cast<sal_uInt64>(aExpected.getLength()) + 38);
OString aActual(static_cast<const char*>(aMemoryStream.GetData()) + 38, aExpected.getLength());
@@ -158,11 +158,11 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMimetype)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// Default is EPUB3.
- assertXPath(mpXmlDoc, "/opf:package", "version", "3.0");
+ assertXPath(mpXmlDoc, "/opf:package"_ostr, "version"_ostr, "3.0");
// This was just "libepubgen/x.y.z", i.e. the LO version was missing.
- OUString aGenerator
- = getXPath(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@name='generator']", "content");
+ OUString aGenerator = getXPath(
+ mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@name='generator']"_ostr, "content"_ostr);
CPPUNIT_ASSERT(aGenerator.startsWith(utl::DocInfoHelper::GetGeneratorString()));
uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponentContext->getServiceManager(),
@@ -186,7 +186,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEPUB2)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// This was 3.0, EPUBVersion filter option was ignored and we always emitted EPUB3.
- assertXPath(mpXmlDoc, "/opf:package", "version", "2.0");
+ assertXPath(mpXmlDoc, "/opf:package"_ostr, "version"_ostr, "2.0");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEPUBFixedLayout)
@@ -199,7 +199,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEPUBFixedLayout)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// This was missing, EPUBLayoutMethod filter option was ignored and we always emitted reflowable layout.
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']",
+ assertXPathContent(mpXmlDoc,
+ "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']"_ostr,
"pre-paginated");
}
@@ -211,7 +212,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEPUBFixedLayoutOption)
// This failed, fixed layout was only working via the FilterData map.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']",
+ assertXPathContent(mpXmlDoc,
+ "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']"_ostr,
"pre-paginated");
}
@@ -232,8 +234,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEPUBFixedLayoutImplicitBreak)
// document.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/toc.xhtml");
// This was 'Page 1' instead.
- assertXPathContent(mpXmlDoc, "//xhtml:li[1]/xhtml:a", "First chapter");
- assertXPathContent(mpXmlDoc, "//xhtml:li[2]/xhtml:a", "Second chapter");
+ assertXPathContent(mpXmlDoc, "//xhtml:li[1]/xhtml:a"_ostr, "First chapter");
+ assertXPathContent(mpXmlDoc, "//xhtml:li[2]/xhtml:a"_ostr, "Second chapter");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPageBreakSplit)
@@ -256,11 +258,11 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSpanAutostyle)
createDoc(u"span-autostyle.fodt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]", "class", "span0");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]"_ostr, "class"_ostr, "span0");
// This failed, it was still span1, i.e. the bold and the italic formatting
// did not differ.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class", "span1");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[3]", "class", "span2");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]"_ostr, "class"_ostr, "span1");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[3]"_ostr, "class"_ostr, "span2");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testParaAutostyleCharProps)
@@ -269,8 +271,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testParaAutostyleCharProps)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This failed, para-level char props were not exported.
- assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span", "class", "span0");
- assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "class", "span1");
+ assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span"_ostr, "class"_ostr, "span0");
+ assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span"_ostr, "class"_ostr, "span1");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMeta)
@@ -279,17 +281,18 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMeta)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// This was "Unknown Author", <meta:initial-creator> was not handled.
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "A U Thor");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "Title");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "hu");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']",
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator"_ostr, "A U Thor");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title"_ostr, "Title");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language"_ostr, "hu");
+ assertXPathContent(mpXmlDoc,
+ "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']"_ostr,
"2017-09-27T09:51:19Z");
// Make sure that cover image next to the source document is picked up.
- assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']",
- "properties", "cover-image");
- assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']",
- "media-type", "image/png");
+ assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']"_ostr,
+ "properties"_ostr, "cover-image");
+ assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']"_ostr,
+ "media-type"_ostr, "image/png");
CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.png"));
}
@@ -299,12 +302,15 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMetaXMP)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// These were the libepubgen default values, metadata from a matching .xmp file was not picked up.
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier",
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier"_ostr,
"deadbeef-e394-4cd6-9b83-7172794612e5");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "unknown title from xmp");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "unknown author from xmp");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "nl");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']",
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title"_ostr,
+ "unknown title from xmp");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator"_ostr,
+ "unknown author from xmp");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language"_ostr, "nl");
+ assertXPathContent(mpXmlDoc,
+ "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']"_ostr,
"2016-11-20T17:16:07Z");
}
@@ -320,12 +326,15 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testMetaAPI)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
// These were values from XMP (deadbeef, etc.), not from API.
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier",
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier"_ostr,
"deadc0de-e394-4cd6-9b83-7172794612e5");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "unknown title from api");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "unknown author from api");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "hu");
- assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']",
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title"_ostr,
+ "unknown title from api");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator"_ostr,
+ "unknown author from api");
+ assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language"_ostr, "hu");
+ assertXPathContent(mpXmlDoc,
+ "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']"_ostr,
"2015-11-20T17:16:07Z");
}
@@ -339,10 +348,10 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testCoverImage)
// Make sure that the explicitly set cover image is used.
// This failed, as the image was not part of the package.
- assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']",
- "properties", "cover-image");
- assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']",
- "media-type", "image/png");
+ assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']"_ostr,
+ "properties"_ostr, "cover-image");
+ assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']"_ostr,
+ "media-type"_ostr, "image/png");
CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.png"));
}
@@ -351,14 +360,14 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testParaNamedstyle)
createDoc(u"para-namedstyle.fodt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPath(mpXmlDoc, "//xhtml:p[1]", "class", "para0");
+ assertXPath(mpXmlDoc, "//xhtml:p[1]"_ostr, "class"_ostr, "para0");
// This failed, paragraph properties from style were not exported.
- assertXPath(mpXmlDoc, "//xhtml:p[2]", "class", "para1");
+ assertXPath(mpXmlDoc, "//xhtml:p[2]"_ostr, "class"_ostr, "para1");
// Test character properties from named paragraph style.
- assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span", "class", "span0");
+ assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span"_ostr, "class"_ostr, "span0");
// This failed, character properties from paragraph style were not exported.
- assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "class", "span1");
+ assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span"_ostr, "class"_ostr, "span1");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testCharNamedstyle)
@@ -368,9 +377,9 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testCharNamedstyle)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// Test character properties from named text style.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]", "class", "span0");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]"_ostr, "class"_ostr, "span0");
// This failed, character properties from text style were not exported.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class", "span1");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]"_ostr, "class"_ostr, "span1");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testNamedStyleInheritance)
@@ -380,7 +389,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testNamedStyleInheritance)
// Find the CSS rule for the blue text.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aBlue = getXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span[2]", "class");
+ OUString aBlue = getXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span[2]"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("#0000ff"), EPUBExportTest::getCss(aCssDoc, aBlue, u"color"));
// This failed, the span only had the properties from its style, but not
@@ -397,10 +406,10 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testNestedSpan)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
// This crashed, span had no content.
- assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "red");
+ assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:span[2]"_ostr, "red");
// Check formatting of nested span.
- OUString aRed = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class");
+ OUString aRed = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]"_ostr, "class"_ostr);
// This failed, direct formatting on top of named style was lost.
CPPUNIT_ASSERT_EQUAL(OUString("#ff0000"), EPUBExportTest::getCss(aCssDoc, aRed, u"color"));
CPPUNIT_ASSERT_EQUAL(OUString("'Liberation Mono'"),
@@ -413,9 +422,9 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLineBreak)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This was 0, line break was not handled.
- assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span/xhtml:br", 1);
+ assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span/xhtml:br"_ostr, 1);
// This was 0, line break inside span was not handled.
- assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span/xhtml:br", 1);
+ assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span/xhtml:br"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEscape)
@@ -424,12 +433,12 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testEscape)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This was lost.
- assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[1]", OUString::fromUtf8("\xc2\xa0"));
+ assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[1]"_ostr, OUString::fromUtf8("\xc2\xa0"));
// Make sure escaping happens only once.
- assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a&b");
+ assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]"_ostr, "a&b");
// This was also lost.
assertXPathContent(
- mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]",
+ mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]"_ostr,
OUString::fromUtf8("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2"
"\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0 "));
}
@@ -441,7 +450,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testParaCharProps)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
// Check formatting of the middle span.
- OUString aMiddle = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class");
+ OUString aMiddle = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("italic"),
EPUBExportTest::getCss(aCssDoc, aMiddle, u"font-style"));
// Direct para formatting was lost, only direct char formatting was
@@ -456,7 +465,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSection)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This was "After.", i.e. in-section content was ignored.
- assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "In section.");
+ assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span"_ostr, "In section.");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testList)
@@ -465,9 +474,9 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testList)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This was "C", i.e. in-list content was ignored.
- assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "B");
+ assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span"_ostr, "B");
// Test nested list content.
- assertXPathContent(mpXmlDoc, "//xhtml:p[6]/xhtml:span", "F");
+ assertXPathContent(mpXmlDoc, "//xhtml:p[6]/xhtml:span"_ostr, "F");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImage)
@@ -475,7 +484,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImage)
createDoc(u"image.fodt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:img"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImageBorder)
@@ -485,7 +494,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImageBorder)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:img", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:img"_ostr, "class"_ostr);
// This failed, image had no border.
CPPUNIT_ASSERT_EQUAL(OUString("0.99pt dashed #ed1c24"),
EPUBExportTest::getCss(aCssDoc, aClass, u"border"));
@@ -497,7 +506,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImageNospan)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// Image outside a span was lost.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:img"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTable)
@@ -505,7 +514,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTable)
createDoc(u"table.fodt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr/xhtml:td", 4);
+ assertXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr/xhtml:td"_ostr, 4);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableRowSpan)
@@ -514,7 +523,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableRowSpan)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This failed, row span wasn't exported.
- assertXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "rowspan", "2");
+ assertXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]"_ostr, "rowspan"_ostr,
+ "2");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableCellBorder)
@@ -524,8 +534,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableCellBorder)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aClass
- = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]"_ostr,
+ "class"_ostr);
// This failed, cell border wasn't exported.
CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"),
EPUBExportTest::getCss(aCssDoc, aClass, u"border-left"));
@@ -537,12 +547,12 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableCellWidth)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aClass1
- = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class");
- OUString aClass2
- = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[2]", "class");
- OUString aClass3
- = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[3]", "class");
+ OUString aClass1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]"_ostr,
+ "class"_ostr);
+ OUString aClass2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[2]"_ostr,
+ "class"_ostr);
+ OUString aClass3 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[3]"_ostr,
+ "class"_ostr);
// These failed, all widths were 0.
CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, u"width").toDouble(),
EPUBExportTest::getCss(aCssDoc, aClass1, u"width").toDouble());
@@ -556,8 +566,10 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableRowHeight)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aClass1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]", "class");
- OUString aClass2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[2]", "class");
+ OUString aClass1
+ = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]"_ostr, "class"_ostr);
+ OUString aClass2
+ = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[2]"_ostr, "class"_ostr);
// These failed, both heights were 0.
CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, u"height").toDouble(),
EPUBExportTest::getCss(aCssDoc, aClass1, u"height").toDouble());
@@ -568,8 +580,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLink)
createDoc(u"link.fodt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "https://libreoffice.org/");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "https://libreoffice.org/");
+ assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span"_ostr, "https://libreoffice.org/");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a"_ostr, "href"_ostr, "https://libreoffice.org/");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkInvalid)
@@ -578,7 +590,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkInvalid)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This was 1, invalid relative link was not filtered out.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", 0);
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a"_ostr, 0);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkCharFormat)
@@ -587,8 +599,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkCharFormat)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// <span> was lost, link text having a char format was missing.
- assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "https://libreoffice.org/");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "https://libreoffice.org/");
+ assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span"_ostr, "https://libreoffice.org/");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a"_ostr, "href"_ostr, "https://libreoffice.org/");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkNamedCharFormat)
@@ -599,10 +611,10 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testLinkNamedCharFormat)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
// This failed, there was no span inside the hyperlink.
- assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "http://libreoffice.org");
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "http://libreoffice.org/");
+ assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span"_ostr, "http://libreoffice.org");
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a"_ostr, "href"_ostr, "http://libreoffice.org/");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("#ff0000"), EPUBExportTest::getCss(aCssDoc, aClass, u"color"));
}
@@ -613,7 +625,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTableWidth)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:table", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:table"_ostr, "class"_ostr);
// This failed, relative total width of table was lost.
CPPUNIT_ASSERT_EQUAL(OUString("50%"), EPUBExportTest::getCss(aCssDoc, aClass, u"width"));
}
@@ -626,14 +638,14 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTextBox)
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
// This failed, image with caption was lost.
- assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1");
+ assertXPath(mpXmlDoc, "//xhtml:img"_ostr, "class"_ostr, "frame1");
// Expected spans:
// 1) break after the image
// 2) "Illustration "
// 3) The sequence field, this was missing (was ": foo" instead).
- assertXPathContent(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]", "1");
+ assertXPathContent(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]"_ostr, "1");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]"_ostr, "class"_ostr);
// This failed, the 3rd span was not italic.
CPPUNIT_ASSERT_EQUAL(OUString("italic"),
EPUBExportTest::getCss(aCssDoc, aClass, u"font-style"));
@@ -652,8 +664,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testFontEmbedding)
.startsWith("'SketchFlow Print"));
// librevenge:mime-type
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/content.opf");
- assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='fonts/font0001.otf']",
- "media-type", "application/vnd.ms-opentype");
+ assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='fonts/font0001.otf']"_ostr,
+ "media-type"_ostr, "application/vnd.ms-opentype");
// office:binary-data
CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/fonts/font0001.otf"));
// librevenge:font-style
@@ -671,7 +683,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testImageLink)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// This failed, image was missing.
- assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:img"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testFootnote)
@@ -680,8 +692,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testFootnote)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// These were missing, footnote was lost.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:sup/xhtml:a", "type", "noteref");
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside", "type", "footnote");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:sup/xhtml:a"_ostr, "type"_ostr, "noteref");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside"_ostr, "type"_ostr, "footnote");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopup)
@@ -690,18 +702,19 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopup)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// Test image popup anchor.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a", "type", "noteref");
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a"_ostr, "type"_ostr, "noteref");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img"_ostr, 1);
// Test image popup content.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]", "type", "footnote");
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]"_ostr, "type"_ostr, "footnote");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]/xhtml:img"_ostr, 1);
// Test text popup anchor.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[2]/xhtml:span/xhtml:a", "type", "noteref");
- assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p[2]/xhtml:span/xhtml:a", "link");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[2]/xhtml:span/xhtml:a"_ostr, "type"_ostr,
+ "noteref");
+ assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p[2]/xhtml:span/xhtml:a"_ostr, "link");
// Test text popup content.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[2]", "type", "footnote");
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[2]/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[2]"_ostr, "type"_ostr, "footnote");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[2]/xhtml:img"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopupMedia)
@@ -712,8 +725,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopupMedia)
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// Test image popup anchor. This failed, number of XPath nodes was 0.
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a", "type", "noteref");
- assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img", 1);
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a"_ostr, "type"_ostr, "noteref");
+ assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopupAPI)
@@ -726,10 +739,11 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPopupAPI)
// We have a non-empty anchor image.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- OUString aAnchor = getXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img", "src");
+ OUString aAnchor
+ = getXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img"_ostr, "src"_ostr);
CPPUNIT_ASSERT(!aAnchor.isEmpty());
// We have a non-empty popup image.
- OUString aData = getXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]/xhtml:img", "src");
+ OUString aData = getXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[1]/xhtml:img"_ostr, "src"_ostr);
CPPUNIT_ASSERT(!aData.isEmpty());
// The anchor is different from the popup image.
CPPUNIT_ASSERT(aAnchor != aData);
@@ -745,13 +759,13 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPageSize)
// This failed, viewport was empty, so page size was lost.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// 21,59cm x 27.94cm (letter).
- assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content",
- "width=816, height=1056");
+ assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']"_ostr,
+ "content"_ostr, "width=816, height=1056");
mpXmlDoc = parseExport("OEBPS/images/image0001.svg");
// This was 288mm, logic->logic conversion input was a pixel value.
- assertXPath(mpXmlDoc, "/svg:svg", "width", "216mm");
- assertXPath(mpXmlDoc, "/svg:svg", "height", "279mm");
+ assertXPath(mpXmlDoc, "/svg:svg"_ostr, "width"_ostr, "216mm");
+ assertXPath(mpXmlDoc, "/svg:svg"_ostr, "height"_ostr, "279mm");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSVG)
@@ -768,7 +782,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSVG)
SvMemoryStream aMemoryStream;
aMemoryStream.WriteStream(*pStream);
- OString aExpected("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<svg");
+ OString aExpected("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<svg"_ostr);
CPPUNIT_ASSERT(aMemoryStream.GetSize() > o3tl::make_unsigned(aExpected.getLength()));
// This failed, there was a '<!DOCTYPE' line between the xml and the svg
@@ -779,7 +793,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSVG)
// This failed, we used the xlink attribute namespace, but we did not
// define its URL.
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/images/image0001.svg");
- assertXPathNSDef(mpXmlDoc, "/svg:svg", u"xlink", u"http://www.w3.org/1999/xlink");
+ assertXPathNSDef(mpXmlDoc, "/svg:svg"_ostr, u"xlink", u"http://www.w3.org/1999/xlink");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623SingleWritingMode)
@@ -788,7 +802,7 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623SingleWritingMode)
createDoc(u"tdf115623-single-writing-mode.odt", {});
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"),
EPUBExportTest::getCss(aCssDoc, aClass, u"writing-mode"));
}
@@ -799,14 +813,14 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623SplitByChapter)
std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
{
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"),
EPUBExportTest::getCss(aCssDoc, aClass, u"writing-mode"));
}
// Split HTML should keep the same writing-mode.
{
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"),
EPUBExportTest::getCss(aCssDoc, aClass, u"writing-mode"));
}
@@ -819,13 +833,13 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623ManyPageSpans)
// Two pages should have different writing modes.
{
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"),
EPUBExportTest::getCss(aCssDoc, aClass, u"writing-mode"));
}
{
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml");
- OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body"_ostr, "class"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("horizontal-tb"),
EPUBExportTest::getCss(aCssDoc, aClass, u"writing-mode"));
}
@@ -835,8 +849,8 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSimpleRuby)
{
createDoc(u"simple-ruby.odt", {});
xmlDocUniquePtr mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
- assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:span", "base text");
- assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:rt", "ruby text");
+ assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:span"_ostr, "base text");
+ assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:rt"_ostr, "ruby text");
}
CPPUNIT_TEST_FIXTURE(EPUBExportTest, testAbi11105)