summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-12-01 10:54:51 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-12-01 16:30:04 +0100
commitab7bdd1f91a7e6e25854601cca712488554ab960 (patch)
tree110157779e7bf585c863f981a7095f6f0d3581e4 /writerperfect
parent6af2cd34404ef6b19fb218931de0b42a2731c57f (diff)
EPUB export: initial fixed layout support
This is just the bare minimum that is already a fixed layout and is valid. Change-Id: I64e1216d92125377d7836988586da9ea1d878536 Reviewed-on: https://gerrit.libreoffice.org/45643 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.cxx16
-rw-r--r--writerperfect/source/writer/EPUBExportFilter.cxx15
-rw-r--r--writerperfect/source/writer/EPUBExportFilter.hxx2
3 files changed, 33 insertions, 0 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 335347de60ff..a9692bc2c293 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -57,6 +57,7 @@ public:
void testOutlineLevel();
void testMimetype();
void testEPUB2();
+ void testEPUBFixedLayout();
void testPageBreakSplit();
void testSpanAutostyle();
void testParaAutostyleCharProps();
@@ -96,6 +97,7 @@ public:
CPPUNIT_TEST(testOutlineLevel);
CPPUNIT_TEST(testMimetype);
CPPUNIT_TEST(testEPUB2);
+ CPPUNIT_TEST(testEPUBFixedLayout);
CPPUNIT_TEST(testPageBreakSplit);
CPPUNIT_TEST(testSpanAutostyle);
CPPUNIT_TEST(testParaAutostyleCharProps);
@@ -292,6 +294,20 @@ void EPUBExportTest::testEPUB2()
assertXPath(mpXmlDoc, "/opf:package", "version", "2.0");
}
+void EPUBExportTest::testEPUBFixedLayout()
+{
+ uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence(
+ {
+ // Explicitly request fixed layout.
+ {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))}
+ }));
+ createDoc("hello.fodt", aFilterData);
+
+ 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']", "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 ba9e30d85df9..8ebf5994aedc 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -48,10 +48,20 @@ sal_Int32 EPUBExportFilter::GetDefaultSplitMethod()
return libepubgen::EPUB_SPLIT_METHOD_HEADING;
}
+sal_Int32 EPUBExportFilter::GetDefaultLayoutMethod()
+{
+#if LIBEPUBGEN_VERSION_SUPPORT
+ return libepubgen::EPUB_LAYOUT_METHOD_REFLOWABLE;
+#else
+ return 0;
+#endif
+}
+
sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDescriptor)
{
sal_Int32 nVersion = EPUBExportFilter::GetDefaultVersion();
sal_Int32 nSplitMethod = EPUBExportFilter::GetDefaultSplitMethod();
+ sal_Int32 nLayoutMethod = EPUBExportFilter::GetDefaultLayoutMethod();
uno::Sequence<beans::PropertyValue> aFilterData;
for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
{
@@ -68,6 +78,8 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe
aFilterData[i].Value >>= nVersion;
else if (aFilterData[i].Name == "EPUBSplitMethod")
aFilterData[i].Value >>= nSplitMethod;
+ else if (aFilterData[i].Name == "EPUBLayoutMethod")
+ aFilterData[i].Value >>= nLayoutMethod;
}
// Build the export filter chain: the package has direct access to the ZIP
@@ -79,6 +91,9 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe
, nVersion
#endif
);
+#if LIBEPUBGEN_VERSION_SUPPORT
+ aGenerator.setLayoutMethod(static_cast<libepubgen::EPUBLayoutMethod>(nLayoutMethod));
+#endif
OUString aSourceURL;
uno::Reference<frame::XModel> xSourceModel(mxSourceDocument, uno::UNO_QUERY);
if (xSourceModel.is())
diff --git a/writerperfect/source/writer/EPUBExportFilter.hxx b/writerperfect/source/writer/EPUBExportFilter.hxx
index b423f96175e7..e96b0a84b695 100644
--- a/writerperfect/source/writer/EPUBExportFilter.hxx
+++ b/writerperfect/source/writer/EPUBExportFilter.hxx
@@ -50,6 +50,8 @@ public:
static sal_Int32 GetDefaultVersion();
/// Gives the default split method.
static sal_Int32 GetDefaultSplitMethod();
+ /// Gives the default layout method.
+ static sal_Int32 GetDefaultLayoutMethod();
};
} // namespace writerperfect