summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-12-01 10:57:35 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-12-01 16:31:20 +0100
commit01283fe86cc523f1bed38bdfc5fbcb1694972169 (patch)
treeb4b75f7cd02f619c99bdf5892d0bd96e51db2041 /writerperfect
parent89e7a00080aadeba08ee649877b2507dc312f9f8 (diff)
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/45646 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx19
-rw-r--r--writerperfect/source/writer/EPUBExportFilter.cxx11
2 files changed, 26 insertions, 4 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index a9c3db57c299..ac6e25efc2ae 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -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");
- aMediaDescriptor["FilterData"] <<= rFilterData;
+ 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(
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx
index 8ebf5994aedc..627d5a4af18f 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -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")