Kaydet (Commit) 01283fe8 authored tarafından Miklos Vajna's avatar Miklos Vajna

EPUB export allow requesting fixed layout from cmdline

FilterData is a typed map of options, suitable for UNO API clients, also
that's what the UI uses. OTOH the --convert-to cmdline option can only
set a FilterOptions string, so support that way as well.

--convert-to epub:EPUB:layout=fixed

can be used to trigger this.

Change-Id: I9f429107ae1db3dc4b6ab3b2b75665f096a1a33a
Reviewed-on: https://gerrit.libreoffice.org/45646Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 89e7a000
......@@ -42,6 +42,7 @@ class EPUBExportTest : public test::BootstrapFixture, public unotest::MacrosTest
utl::TempFile maTempFile;
xmlDocPtr mpXmlDoc = nullptr;
uno::Reference<packages::zip::XZipFileAccess2> mxZipFile;
OUString maFilterOptions;
public:
void setUp() override;
......@@ -58,6 +59,7 @@ public:
void testMimetype();
void testEPUB2();
void testEPUBFixedLayout();
void testEPUBFixedLayoutOption();
void testPageBreakSplit();
void testSpanAutostyle();
void testParaAutostyleCharProps();
......@@ -99,6 +101,7 @@ public:
CPPUNIT_TEST(testMimetype);
CPPUNIT_TEST(testEPUB2);
CPPUNIT_TEST(testEPUBFixedLayout);
CPPUNIT_TEST(testEPUBFixedLayoutOption);
CPPUNIT_TEST(testPageBreakSplit);
CPPUNIT_TEST(testSpanAutostyle);
CPPUNIT_TEST(testParaAutostyleCharProps);
......@@ -177,7 +180,10 @@ void EPUBExportTest::createDoc(const OUString &rFile, const uno::Sequence<beans:
maTempFile.EnableKillingFile();
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OUString("EPUB");
if (maFilterOptions.isEmpty())
aMediaDescriptor["FilterData"] <<= rFilterData;
else
aMediaDescriptor["FilterOptions"] <<= maFilterOptions;
xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
mxZipFile = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL());
}
......@@ -310,6 +316,17 @@ void EPUBExportTest::testEPUBFixedLayout()
assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", "pre-paginated");
}
void EPUBExportTest::testEPUBFixedLayoutOption()
{
// Explicitly request fixed layout, this time via FilterOptions.
maFilterOptions = "layout=fixed";
createDoc("hello.fodt", {});
// This failed, fixed layout was only working via the FilterData map.
mpXmlDoc = parseExport("OEBPS/content.opf");
assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", "pre-paginated");
}
void EPUBExportTest::testPageBreakSplit()
{
uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence(
......
......@@ -63,15 +63,20 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe
sal_Int32 nSplitMethod = EPUBExportFilter::GetDefaultSplitMethod();
sal_Int32 nLayoutMethod = EPUBExportFilter::GetDefaultLayoutMethod();
uno::Sequence<beans::PropertyValue> aFilterData;
OUString aFilterOptions;
for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
{
if (rDescriptor[i].Name == "FilterData")
{
rDescriptor[i].Value >>= aFilterData;
break;
}
else if (rDescriptor[i].Name == "FilterOptions")
rDescriptor[i].Value >>= aFilterOptions;
}
#if LIBEPUBGEN_VERSION_SUPPORT
if (aFilterOptions == "layout=fixed")
nLayoutMethod = libepubgen::EPUB_LAYOUT_METHOD_FIXED;
#endif
for (sal_Int32 i = 0; i < aFilterData.getLength(); ++i)
{
if (aFilterData[i].Name == "EPUBVersion")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment