UnoApiTest: drop setFilterOptions

and just pass FilterOptions as a parameter

Change-Id: Ie950bd1565e5e6223b232e723bec75409b96420c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198646
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2026-02-04 14:27:23 +01:00
parent 4fb31ea85f
commit 53d3a02db5
17 changed files with 251 additions and 120 deletions
+3 -3
View File
@@ -147,14 +147,15 @@ public:
void save(TestFilter eFilter, const css::uno::Sequence<css::beans::PropertyValue>& rParams = {},
const char* pPassword = nullptr);
void saveAndReload(TestFilter eFilter, const char* pPassword = nullptr);
void saveAndReload(TestFilter eFilter,
const css::uno::Sequence<css::beans::PropertyValue>& rParams = {},
const char* pPassword = nullptr);
std::unique_ptr<vcl::pdf::PDFiumDocument> parsePDFExport(const OString& rPassword = OString());
void createTempCopy(std::u16string_view fileName);
void skipValidation() { mbSkipValidation = true; }
void setFilterOptions(const OUString& rFilterOptions) { maFilterOptions = rFilterOptions; }
void setImportFilterOptions(const OUString& rFilterOptions)
{
@@ -184,7 +185,6 @@ private:
bool mbSkipValidation;
OUString m_aBaseString;
OUString maFilterOptions;
OUString maImportFilterOptions;
TestFilter meImportFilterName;
+4 -2
View File
@@ -9,6 +9,7 @@
#include <sal/config.h>
#include <comphelper/propertyvalue.hxx>
#include <test/htmltesttools.hxx>
#include <test/unoapixml_test.hxx>
@@ -29,8 +30,9 @@ public:
assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/table/tr/td/img", 1);
setFilterOptions(u"SkipImages"_ustr);
save(TestFilter::HTML_CALC);
save(TestFilter::HTML_CALC, {
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"SkipImages"_ustr),
});
pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT (pDoc);
+2 -2
View File
@@ -240,7 +240,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testPasswordExport)
pDoc->SetValue(0, 0, 0, 1.0);
saveAndReload(aFilterNames[i], /*pPassword*/ "test");
saveAndReload(aFilterNames[i], /*rParams*/ {}, /*pPassword*/ "test");
pDoc = getScDoc();
double aVal = pDoc->GetValue(0, 0, 0);
@@ -258,7 +258,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testTdf134332)
ASSERT_DOUBLES_EQUAL(238.0, pDoc->GetValue(ScAddress(0, 10144, 0)));
saveAndReload(TestFilter::ODS, /*pPassword*/ "test");
saveAndReload(TestFilter::ODS, /*rParams*/ {}, /*pPassword*/ "test");
// Without the fixes in place, it would have failed here
pDoc = getScDoc();
+75 -26
View File
@@ -12,6 +12,7 @@
#include "sdmodeltestbase.hxx"
#include <sdpage.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/scopeguard.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequence.hxx>
@@ -565,7 +566,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport)
{
createSdImpressDoc();
saveAndReload(vFormat[i], /*pPassword*/ "test");
saveAndReload(vFormat[i], /*rParams*/ {}, /*pPassword*/ "test");
}
}
@@ -573,7 +574,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testDrawPasswordExport)
{
createSdDrawDoc();
saveAndReload(TestFilter::ODG, /*pPassword*/ "test");
saveAndReload(TestFilter::ODG, /*rParams*/ {}, /*pPassword*/ "test");
}
CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport)
@@ -1020,9 +1021,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdf)
loadFromFile(u"pdf/sample.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
const SdrPage* pPage = GetPage(1);
@@ -1043,9 +1048,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfTextPos)
loadFromFile(u"pdf/textheight1.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 x = getXPath(pXml, "//textarray[1]", "x").toInt32();
@@ -1074,9 +1083,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfFont)
loadFromFile(u"pdf/differentfonts.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXml = parseLayout();
{
@@ -1113,8 +1126,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfHindi)
loadFromFile(u"pdf/BasicHindi.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
@@ -1140,9 +1157,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfGrayscaleImageUnderInvisibleTe
loadFromFile(u"pdf/GrayscaleImageUnderInvisibleTest.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
uno::Reference<drawing::XShapes> xGroupShape(getShapeFromPage(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xGroupShape.is());
@@ -1187,9 +1208,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfClippedImages)
loadFromFile(u"pdf/ClippedImages.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
uno::Reference<drawing::XShapes> xGroupShape(getShapeFromPage(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xGroupShape.is());
@@ -1217,9 +1242,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfMissingFontVersion)
loadFromFile(u"pdf/ErrareHumanumEst.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
setImportFilterName(TestFilter::FODG);
saveAndReload(TestFilter::FODG);
saveAndReload(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
const SdrPage* pPage = GetPage(1);
@@ -1242,8 +1271,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfEmbeddedFonts)
loadFromFile(u"pdf/sciencejournalsource.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
@@ -1263,8 +1296,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfPatternStroke)
loadFromFile(u"pdf/pattern-stroke.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
@@ -1283,8 +1320,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfPatternFill)
loadFromFile(u"pdf/pattern-fill.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
@@ -1305,8 +1346,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testPdfPageMasterOrientation)
loadFromFile(u"pdf/SampleSlideDeck.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
@@ -1327,8 +1372,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfTextShear)
loadFromFile(u"pdf/textshear.pdf");
setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}");
save(TestFilter::FODG);
save(TestFilter::FODG,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"_ustr),
});
xmlDocUniquePtr pXmlDoc = parseExportedFile();
+76 -36
View File
@@ -161,8 +161,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testExportOfImages)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testExportOfImagesWithSkipImagesEnabled)
{
createSwDoc("textAndImage.docx");
setFilterOptions(u"SkipImages"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"SkipImages"_ustr),
});
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT(pDoc);
@@ -174,8 +176,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testExportOfImagesWithSkipImagesEnabled)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testSkipImagesEmbedded)
{
createSwDoc("skipimage-embedded.doc");
setFilterOptions(u"SkipImages"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"SkipImages"_ustr),
});
// Embedded spreadsheet was exported as image, so content was lost. Make
// sure it's exported as HTML instead.
@@ -193,8 +197,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testSkipImagesEmbedded)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testSkipImagesEmbeddedDocument)
{
createSwDoc("skipimage-embedded-document.docx");
setFilterOptions(u"SkipImages"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"SkipImages"_ustr),
});
// Similar to testSkipImagesEmbedded, but with an embedded Writer object,
// not a Calc one, and this time OOXML, not WW8.
@@ -376,8 +382,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testNormalImageExport)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testEmbedImagesEnabled)
{
createSwDoc("textAndImage.docx");
setFilterOptions(u"EmbedImages"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"EmbedImages"_ustr),
});
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT(pDoc);
@@ -395,8 +403,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testEmbedImagesEnabled)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testXHTML)
{
createSwWebDoc("hello.html");
setFilterOptions(u"XHTML"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"XHTML"_ustr),
});
OString aExpected("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML"_ostr);
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
@@ -416,8 +426,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfParagraph)
setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-p.xhtml");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -468,8 +480,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleData)
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-ole-data.xhtml");
verify();
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
saveAndReload(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
verify();
}
@@ -519,8 +534,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleImg)
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-ole-img.xhtml");
verify();
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
saveAndReload(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
verify();
// "type" attribute was missing for the inner <object> element.
@@ -578,8 +596,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfJpgImg)
setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-jpg-img.xhtml");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -594,8 +614,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfTable)
setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-table.xhtml");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
@@ -617,8 +639,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfTable)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfTable2)
{
createSwDoc("reqif-table2.odt");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -657,8 +681,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfTableHeight)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testXHTMLUseCSS)
{
createSwDoc("xhtml-css.odt");
setFilterOptions(u"XHTML"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"XHTML"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -675,8 +701,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfList)
setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-list.xhtml");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
@@ -720,8 +748,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOle2)
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-ole2.xhtml");
verify();
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
saveAndReload(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
verify();
// Check that the replacement graphic is exported at RTF level.
@@ -764,8 +795,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOle2Odg)
setImportFilterName(TestFilter::HTML_WRITER);
createSwDoc("reqif-ole-odg.xhtml");
verify();
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
saveAndReload(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
verify();
}
@@ -817,8 +851,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTransparentImageReqIf)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testOleNodataReqIf)
{
createSwDoc("reqif-ole-nodata.odt");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// This failed, io::IOException was thrown during the filter() call.
xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
@@ -834,8 +870,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testOleNodataReqIf)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testNoLangReqIf)
{
createSwDoc("reqif-no-lang.odt");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
@@ -878,8 +916,10 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testTdf132739)
CPPUNIT_TEST_FIXTURE(HtmlExportTest, testFieldShadeReqIf)
{
createSwDoc("field-shade-reqif.odt");
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT(pDoc);
+7 -3
View File
@@ -131,9 +131,13 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testJson)
xDrawPageSupplier->getDrawPage()->add(xShape);
// When exporting to HTML, and specifying options as JSON:
setFilterOptions(u"{\"XhtmlNs\":{\"type\":\"string\", \"value\":\"reqif-xhtml\"},"
"\"ShapeDPI\":{\"type\":\"long\",\"value\":\"192\"}}"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(
u"FilterOptions"_ustr,
u"{\"XhtmlNs\":{\"type\":\"string\", \"value\":\"reqif-xhtml\"},"
"\"ShapeDPI\":{\"type\":\"long\",\"value\":\"192\"}}"_ustr),
});
// Then make sure those options are not ignored:
// Without the accompanying fix in place, this test would have failed, as GetPngPath() expects
@@ -207,8 +207,10 @@ void SwHtmlDomExportTest::ParseOle1FromRtfUrl(const OUString& rRtfUrl, SvMemoryS
void SwHtmlDomExportTest::ExportToReqif()
{
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
}
void SwHtmlDomExportTest::ImportFromReqif(const OUString& rUrl)
+38 -18
View File
@@ -11,6 +11,7 @@
#include <swmodeltestbase.hxx>
#include <test/htmltesttools.hxx>
#include <comphelper/propertyvalue.hxx>
namespace
{
@@ -26,8 +27,11 @@ public:
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testImageEmbedding)
{
createSwDoc("image-mimetype.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
htmlDocUniquePtr pDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT(pDoc);
@@ -40,8 +44,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testImageEmbedding)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf131812)
{
createSwDoc("tdf131812.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -55,8 +61,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf131812)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf146264)
{
createSwDoc("tdf146264.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -74,8 +82,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf146264)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf167910)
{
createSwDoc("tdf167910.fodt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -104,8 +114,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf167910)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf118637)
{
createSwDoc("tdf118637.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -117,8 +129,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf118637)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf145361)
{
createSwDoc("tdf145361.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
// 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);
@@ -132,8 +146,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf145361)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf142483)
{
createSwDoc("tdf142483.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -171,8 +187,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf142483)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf107696)
{
createSwDoc("tdf107696.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
@@ -201,8 +219,10 @@ CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf107696)
CPPUNIT_TEST_FIXTURE(XHtmlExportTest, testTdf66305)
{
createSwDoc("tdf66305.odt");
setFilterOptions(u"UTF8"_ustr);
save(TestFilter::XHTML_WRITER);
save(TestFilter::XHTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8"_ustr),
});
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
sal_uInt64 nLength = pStream->TellEnd();
+2 -2
View File
@@ -490,7 +490,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSHA1Correct)
CPPUNIT_ASSERT_EQUAL(1, getPages());
getParagraph(1, u"012"_ustr);
saveAndReload(TestFilter::ODT, sPass);
saveAndReload(TestFilter::ODT, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(1, getPages());
getParagraph(1, u"012"_ustr);
@@ -504,7 +504,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSHA1Wrong)
CPPUNIT_ASSERT_EQUAL(1, getPages());
getParagraph(1, u"012"_ustr);
saveAndReload(TestFilter::ODT, sPass);
saveAndReload(TestFilter::ODT, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(1, getPages());
getParagraph(1, u"012"_ustr);
+1 -1
View File
@@ -293,7 +293,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165115)
{
// Test saving a template file with password protection
createSwDoc();
saveAndReload(TestFilter::OTT, "test");
saveAndReload(TestFilter::OTT, /*rParams*/ {}, /*pPassword*/ "test");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf57317_autoListName)
+4 -4
View File
@@ -26,7 +26,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2007)
// Standard encryption format, AES 128, SHA1
uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString());
saveAndReload(TestFilter::DOCX, sPass);
saveAndReload(TestFilter::DOCX, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString());
}
@@ -36,7 +36,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2010)
createSwDoc("Encrypted_MSO2010_abc.docx", sPass);
// Agile encryption format, AES 128, CBC, SHA1
CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString());
saveAndReload(TestFilter::DOCX, sPass);
saveAndReload(TestFilter::DOCX, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString());
}
@@ -47,7 +47,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2013)
// Agile encryption format, AES 256, CBC, SHA512
uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString());
saveAndReload(TestFilter::DOCX, sPass);
saveAndReload(TestFilter::DOCX, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString());
}
@@ -58,7 +58,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordLOStandard)
// Standard encryption format, AES 128, SHA1
uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString());
saveAndReload(TestFilter::DOCX, sPass);
saveAndReload(TestFilter::DOCX, /*rParams*/ {}, sPass);
CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString());
}
+8 -4
View File
@@ -8,6 +8,7 @@
*/
#include <swmodeltestbase.hxx>
#include <comphelper/propertyvalue.hxx>
namespace
{
@@ -39,8 +40,10 @@ protected:
CPPUNIT_TEST_FIXTURE(TxtEncExportTest, testBulletsNotHidden)
{
createSwDoc("bullets.odt");
setFilterOptions(u"UTF8,,,,"_ustr);
save(TestFilter::TEXT_ENCODED);
save(TestFilter::TEXT_ENCODED, {
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8,,,,"_ustr),
});
OString aData = readExportedFile();
OUString aString = OStringToOUString(
@@ -68,8 +71,9 @@ CPPUNIT_TEST_FIXTURE(TxtEncExportTest, testBulletsNotHidden)
CPPUNIT_TEST_FIXTURE(TxtEncExportTest, testBulletsHidden)
{
createSwDoc("bullets.odt");
setFilterOptions(u"UTF8,,,,,false"_ustr);
save(TestFilter::TEXT_ENCODED);
save(TestFilter::TEXT_ENCODED, {
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"UTF8,,,,,false"_ustr),
});
OString aData = readExportedFile();
OUString aString = OStringToOUString(
+13 -6
View File
@@ -14,6 +14,7 @@
#include <vcl/gdimtf.hxx>
#include <comphelper/propertyvalue.hxx>
#include <docsh.hxx>
#include <fmtfsize.hxx>
#include <frameformats.hxx>
@@ -117,8 +118,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSvmImageExport)
xBodyText->insertTextContent(xCursor, xTextContent, false);
// When exporting to reqif:
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// Then make sure we only export PNG:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
@@ -148,8 +151,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTableCellFloatValueType)
pBoxFormat->GetDoc().SetAttr(aSet, *pBoxFormat);
// When exporting to XHTML:
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// Then make sure that the sdval attribute is omitted, which is not in the XHTML spec:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
@@ -206,8 +211,10 @@ CPPUNIT_TEST_FIXTURE(Test, testCenteredTableCSSExport)
pWrtShell->SetTableAttr(aSet);
// When exporting to XHTML:
setFilterOptions(u"xhtmlns=reqif-xhtml"_ustr);
save(TestFilter::HTML_WRITER);
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// Then make sure that CSS is used to horizontally position the table:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+2 -1
View File
@@ -179,7 +179,8 @@ protected:
/// Get TextFrame by name
css::uno::Reference<css::drawing::XShape> getTextFrameByName(const OUString& aName);
void saveAndReload(TestFilter eFilter, const char* pPassword = nullptr);
void saveAndReload(TestFilter eFilter, const css::uno::Sequence<css::beans::PropertyValue>& rParams = {},
const char* pPassword = nullptr);
/// Get page count.
int getPages() const;
+4 -2
View File
@@ -384,9 +384,11 @@ void SwModelTestBase::loadURL(OUString const& rURL, const char* pPassword)
calcLayout();
}
void SwModelTestBase::saveAndReload(TestFilter eFilter, const char* pPassword)
void SwModelTestBase::saveAndReload(TestFilter eFilter,
const css::uno::Sequence<css::beans::PropertyValue>& rParams,
const char* pPassword)
{
save(eFilter, /*rParams*/ {}, pPassword);
save(eFilter, rParams, pPassword);
loadURL(maTempFile.GetURL(), pPassword);
}
+4 -4
View File
@@ -329,8 +329,6 @@ void UnoApiTest::save(TestFilter eFilter, const uno::Sequence<beans::PropertyVal
if (rParams.hasElements())
aMediaDescriptor.update(rParams);
if (!maFilterOptions.isEmpty())
aMediaDescriptor[u"FilterOptions"_ustr] <<= maFilterOptions;
if (pPassword)
{
@@ -360,9 +358,11 @@ void UnoApiTest::save(TestFilter eFilter, const uno::Sequence<beans::PropertyVal
validate(maTempFile.GetFileName(), eFilter);
}
void UnoApiTest::saveAndReload(TestFilter eFilter, const char* pPassword)
void UnoApiTest::saveAndReload(TestFilter eFilter,
const uno::Sequence<beans::PropertyValue>& rParams,
const char* pPassword)
{
save(eFilter, /*rParams*/ {}, pPassword);
save(eFilter, rParams, pPassword);
loadFromURL(maTempFile.GetURL(), pPassword);
}
+4 -4
View File
@@ -132,7 +132,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODF13)
comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); });
SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
saveAndReload(TestFilter::ODT, "password");
saveAndReload(TestFilter::ODT, /*rParams*/ {}, /*pPassword*/ "password");
xmlDocUniquePtr pXmlDoc = parseExport(u"META-INF/manifest.xml"_ustr);
assertXPath(pXmlDoc, "/manifest:manifest", "version", u"1.3");
@@ -180,7 +180,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODF13)
{
// store it with new wholesome ODF extended encryption - reload
saveAndReload(TestFilter::ODT, "password");
saveAndReload(TestFilter::ODT, /*rParams*/ {}, /*pPassword*/ "password");
// test wholesome ODF extended encryption
xmlDocUniquePtr pXmlDoc = parseExport(u"META-INF/manifest.xml"_ustr);
@@ -252,7 +252,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODFWholesom
{
// store it with new wholesome ODF extended encryption - reload
saveAndReload(TestFilter::ODT, "password");
saveAndReload(TestFilter::ODT, /*rParams*/ {}, /*pPassword*/ "password");
// test wholesome ODF extended encryption
xmlDocUniquePtr pXmlDoc = parseExport(u"META-INF/manifest.xml"_ustr);
@@ -317,7 +317,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODFWholesom
comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); });
SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
saveAndReload(TestFilter::ODT, "password");
saveAndReload(TestFilter::ODT, /*rParams*/ {}, /*pPassword*/ "password");
xmlDocUniquePtr pXmlDoc = parseExport(u"META-INF/manifest.xml"_ustr);
assertXPath(pXmlDoc, "/manifest:manifest", "version", u"1.3");