summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-02-20 18:40:38 +0800
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-04-10 09:33:51 +0200
commitc6d3d0642e0f5d24cab402a8a7c6f81406d044cf (patch)
tree849e29a0ef41b537e3d7038f6542ecf807dd729c
parent8cbf84ed33014339cfc9741c1371cd065110060f (diff)
tdf#115623: invoke openPageSpan / closePageSpan
* For paragraphs or tables whose styles specify style:master-page-name, it indicate starting a new page style and should invoke openPageSpan / closePageSapn properly. * closePageSpan at the end of text body is invoked. Change-Id: Ic85157c9b1a43c94a027b464ad9105e9072afcf7 Reviewed-on: https://gerrit.libreoffice.org/52082 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx55
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/tdf115623-many-pagespans.odtbin0 -> 8591 bytes
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/tdf115623-single-writing-mode.odtbin0 -> 8562 bytes
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/tdf115623-split-by-chapter.odtbin0 -> 9346 bytes
-rw-r--r--writerperfect/source/writer/exp/txtparai.cxx1
-rw-r--r--writerperfect/source/writer/exp/txtstyli.cxx1
-rw-r--r--writerperfect/source/writer/exp/xmlimp.cxx32
-rw-r--r--writerperfect/source/writer/exp/xmlimp.hxx5
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx3
-rw-r--r--writerperfect/source/writer/exp/xmltext.cxx7
-rw-r--r--writerperfect/source/writer/exp/xmltext.hxx1
11 files changed, 105 insertions, 0 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 81d70591a0da..231c63252efd 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -98,6 +98,9 @@ public:
void testPopupAPI();
void testPageSize();
void testSVG();
+ void testTdf115623SingleWritingMode();
+ void testTdf115623SplitByChapter();
+ void testTdf115623ManyPageSpans();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
@@ -144,6 +147,9 @@ public:
CPPUNIT_TEST(testPopupAPI);
CPPUNIT_TEST(testPageSize);
CPPUNIT_TEST(testSVG);
+ CPPUNIT_TEST(testTdf115623SingleWritingMode);
+ CPPUNIT_TEST(testTdf115623SplitByChapter);
+ CPPUNIT_TEST(testTdf115623ManyPageSpans);
CPPUNIT_TEST_SUITE_END();
};
@@ -881,6 +887,55 @@ void EPUBExportTest::testSVG()
assertXPathNSDef(mpXmlDoc, "/svg:svg", "xlink", "http://www.w3.org/1999/xlink");
}
+
+void EPUBExportTest::testTdf115623SingleWritingMode()
+{
+ // Simple page that has single writing mode should work.
+ createDoc("tdf115623-single-writing-mode.odt", {});
+ std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode"));
+}
+
+void EPUBExportTest::testTdf115623SplitByChapter()
+{
+ createDoc("tdf115623-split-by-chapter.odt", {});
+ std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
+ {
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode"));
+ xmlFreeDoc(mpXmlDoc);
+ mpXmlDoc = nullptr;
+ }
+ // Splitted HTML should keep the same writing-mode.
+ {
+ mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode"));
+ }
+}
+
+void EPUBExportTest::testTdf115623ManyPageSpans()
+{
+ createDoc("tdf115623-many-pagespans.odt", {});
+ std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
+ // Two pages should have different writing modes.
+ {
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode"));
+ xmlFreeDoc(mpXmlDoc);
+ mpXmlDoc = nullptr;
+ }
+ {
+ mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml");
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class");
+ CPPUNIT_ASSERT_EQUAL(OUString("horizontal-tb"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode"));
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
}
diff --git a/writerperfect/qa/unit/data/writer/epubexport/tdf115623-many-pagespans.odt b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-many-pagespans.odt
new file mode 100644
index 000000000000..3e7c291aa197
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-many-pagespans.odt
Binary files differ
diff --git a/writerperfect/qa/unit/data/writer/epubexport/tdf115623-single-writing-mode.odt b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-single-writing-mode.odt
new file mode 100644
index 000000000000..4c374a1bd478
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-single-writing-mode.odt
Binary files differ
diff --git a/writerperfect/qa/unit/data/writer/epubexport/tdf115623-split-by-chapter.odt b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-split-by-chapter.odt
new file mode 100644
index 000000000000..ee6d48296ff4
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/tdf115623-split-by-chapter.odt
Binary files differ
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx
index 904c865bf90d..e02e83d5fdbf 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -402,6 +402,7 @@ void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Ref
m_aStyleName = rAttributeValue;
FillStyles(m_aStyleName, mrImport.GetAutomaticParagraphStyles(), mrImport.GetParagraphStyles(), aPropertyList);
FillStyles(m_aStyleName, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), m_aTextPropertyList);
+ mrImport.HandlePageSpan(aPropertyList);
}
else
{
diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx
index 548aa654dcdf..90cc66b9c80b 100644
--- a/writerperfect/source/writer/exp/txtstyli.cxx
+++ b/writerperfect/source/writer/exp/txtstyli.cxx
@@ -296,6 +296,7 @@ void XMLStyleContext::startElement(const OUString &/*rName*/, const css::uno::Re
m_aGraphicPropertyList.insert(sName.getStr(), sValue.getStr());
m_aPageLayoutPropertyList.insert(sName.getStr(), sValue.getStr());
m_aMasterPagePropertyList.insert(sName.getStr(), sValue.getStr());
+ m_aTablePropertyList.insert(sName.getStr(), sValue.getStr());
}
}
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 9ef9afa837c1..5c22a5f911d7 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -339,6 +339,7 @@ void XMLOfficeDocContext::HandleFixedLayoutPage(const FixedLayoutPage &rPage, bo
XMLImport::XMLImport(const uno::Reference<uno::XComponentContext> &xContext, librevenge::RVNGTextInterface &rGenerator, const OUString &rURL, const uno::Sequence<beans::PropertyValue> &rDescriptor, const std::vector<FixedLayoutPage> &rPageMetafiles)
: mrGenerator(rGenerator),
mxContext(xContext),
+ mbIsInPageSpan(false),
mrPageMetafiles(rPageMetafiles)
{
uno::Sequence<beans::PropertyValue> aFilterData;
@@ -595,6 +596,37 @@ void XMLImport::setDocumentLocator(const uno::Reference<xml::sax::XLocator> &/*x
{
}
+void XMLImport::HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList)
+{
+ OUString sMasterPageName;
+ OUString sLayoutName;
+
+ if (rPropertyList["style:master-page-name"])
+ sMasterPageName = OStringToOUString(rPropertyList["style:master-page-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8);
+ else if (!GetIsInPageSpan())
+ sMasterPageName = "Standard";
+
+ if (sMasterPageName.getLength())
+ {
+ librevenge::RVNGPropertyList &rMasterPage = GetMasterStyles()[sMasterPageName];
+ if (rMasterPage["style:page-layout-name"])
+ {
+ sLayoutName = OStringToOUString(rMasterPage["style:page-layout-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8);
+ }
+ }
+
+ if (sLayoutName.getLength())
+ {
+ librevenge::RVNGPropertyList &rPageLayout = GetPageLayouts()[sLayoutName];
+
+ if (GetIsInPageSpan())
+ GetGenerator().closePageSpan();
+
+ GetGenerator().openPageSpan(rPageLayout);
+ SetIsInPageSpan(true);
+ }
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx
index 392eef4956cd..097a96cdcce9 100644
--- a/writerperfect/source/writer/exp/xmlimp.hxx
+++ b/writerperfect/source/writer/exp/xmlimp.hxx
@@ -83,6 +83,7 @@ class XMLImport : public cppu::WeakImplHelper
const css::uno::Reference<css::uno::XComponentContext> &mxContext;
css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory;
OUString maMediaDir;
+ bool mbIsInPageSpan;
const std::vector<FixedLayoutPage> &mrPageMetafiles;
public:
@@ -113,6 +114,10 @@ public:
const std::vector<FixedLayoutPage> &GetPageMetafiles() const;
const css::uno::Reference<css::uno::XComponentContext> &GetComponentContext() const;
+ bool GetIsInPageSpan() const { return mbIsInPageSpan; }
+ void SetIsInPageSpan(bool bSet) { mbIsInPageSpan = bSet; }
+ void HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList);
+
// XDocumentHandler
void SAL_CALL startDocument() override;
void SAL_CALL endDocument() override;
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
index bec52dab0f22..82468e12a91a 100644
--- a/writerperfect/source/writer/exp/xmltbli.cxx
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -205,7 +205,10 @@ void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Re
const OUString &rAttributeValue = xAttribs->getValueByIndex(i);
if (rAttributeName == "table:style-name")
+ {
FillStyles(rAttributeValue, mrImport.GetAutomaticTableStyles(), mrImport.GetTableStyles(), m_aPropertyList);
+ mrImport.HandlePageSpan(m_aPropertyList);
+ }
else
{
OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8);
diff --git a/writerperfect/source/writer/exp/xmltext.cxx b/writerperfect/source/writer/exp/xmltext.cxx
index 3902e15ae839..a6624b1f2115 100644
--- a/writerperfect/source/writer/exp/xmltext.cxx
+++ b/writerperfect/source/writer/exp/xmltext.cxx
@@ -13,6 +13,7 @@
#include "xmltbli.hxx"
#include "XMLSectionContext.hxx"
#include "XMLTextListContext.hxx"
+#include "xmlimp.hxx"
using namespace com::sun::star;
@@ -26,6 +27,12 @@ XMLBodyContentContext::XMLBodyContentContext(XMLImport &rImport)
{
}
+void XMLBodyContentContext::endElement(const OUString &/*rName*/)
+{
+ if (mrImport.GetIsInPageSpan())
+ mrImport.GetGenerator().closePageSpan();
+}
+
rtl::Reference<XMLImportContext> XMLBodyContentContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
return CreateTextChildContext(mrImport, rName);
diff --git a/writerperfect/source/writer/exp/xmltext.hxx b/writerperfect/source/writer/exp/xmltext.hxx
index bce957c4f7e8..1c9a1e131542 100644
--- a/writerperfect/source/writer/exp/xmltext.hxx
+++ b/writerperfect/source/writer/exp/xmltext.hxx
@@ -24,6 +24,7 @@ public:
XMLBodyContentContext(XMLImport &rImport);
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) override;
+ void SAL_CALL endElement(const OUString &rName) override;
};
/// Context factory for body text, section, table cell, etc.