From 966dc7f2cf500bb529394e1865e2cc6e5b264ab0 Mon Sep 17 00:00:00 2001 From: Mark Hung Date: Thu, 30 May 2019 22:59:29 +0800 Subject: EPUB export: fix not properly paired openPageSpan Fix the test case converting abi11105.abw to EPUB file. ( the attachment at ) soffice.bin: .../sax/source/expatwrap/saxwriter.cxx:1184: virtual void (anonymous namespace)::SAXWriter::endElement(const rtl::OUString &): Assertion `aName == m_pSaxWriterHelper->m_DebugStartedElements.top()' failed. We used to invoke handlePageSpan when starting a paragraph or a table element that has master-page-name defined in the referred style, and invoke closePageSpan when XMLBodyContentContext. Limit the handling of page span to top-level paragraph or tables so that it doesn't messed up in the nested ( paragraph that changed it's page style in a table cell ) case. Change-Id: Ic8637663aaa7506ced9758bd7ccd7233309e8557 Reviewed-on: https://gerrit.libreoffice.org/73214 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- writerperfect/qa/unit/EPUBExportTest.cxx | 7 + .../qa/unit/data/writer/epubexport/abi11105.abw | 200 +++++++++++++++++++++ writerperfect/source/writer/exp/txtparai.cxx | 6 +- writerperfect/source/writer/exp/txtparai.hxx | 5 +- writerperfect/source/writer/exp/xmltbli.cxx | 6 +- writerperfect/source/writer/exp/xmltbli.hxx | 5 +- writerperfect/source/writer/exp/xmltext.cxx | 9 +- writerperfect/source/writer/exp/xmltext.hxx | 3 +- 8 files changed, 230 insertions(+), 11 deletions(-) create mode 100644 writerperfect/qa/unit/data/writer/epubexport/abi11105.abw (limited to 'writerperfect') diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 00f989f15f8b..c004c658b57a 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -877,6 +877,13 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testSimpleRuby) assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:span", "base text"); assertXPathContent(mpXmlDoc, "//xhtml:body/xhtml:p/xhtml:ruby/xhtml:rt", "ruby text"); } + +CPPUNIT_TEST_FIXTURE(EPUBExportTest, testAbi11105) +{ + // This crashed because the paragraph style "P5" which had a master-page-name + // appeared in a table cell messed up page spans. + createDoc("abi11105.abw", {}); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/data/writer/epubexport/abi11105.abw b/writerperfect/qa/unit/data/writer/epubexport/abi11105.abw new file mode 100644 index 000000000000..cbb32694022b --- /dev/null +++ b/writerperfect/qa/unit/data/writer/epubexport/abi11105.abw @@ -0,0 +1,200 @@ + + + + + + + + + + + +application/x-abiword +AbiWord + + + + + + + + + + + + + + +
+ + +

Evan Rinehart

+

P.O. Box 21456

+

Baton Rouge, LA 70894

+

(985) 806 4063

+

evanrinehart@gmail.com

+
+ +

+
+ +

+

+
+ +

Work Experience

+
+ +

+
+ +

RageComm

+

Aug 2007 -

+

+
+ +

Programmer

+

Researching and implementing advanced graphics techniques using shaders; providing general support.

+
+ +

LSU Student Technical Application Resource Training

+

Aug 2006 - May 2007

+

+
+ +

Software Trainer

+

Taught classes in MATLAB, Mathematica, web design, and Linux system administration.

+
+ +

LSU Department of Electrical and Computer Engineering

+

Jan 2006 - May 2007

+

+
+ +

Engineering Tutor

+

Tutored engineering students in circuits, digital logic, electronics, and software engineering.

+
+ +

LSU Department of Mathematics

+

Aug 2005 - May 2006

+

+
+ +

Software Trainer / Math Tutor

+

Assisted students enrolled in computer-based college algebra program.

+
+ +

LSU School of Veterinary Medicine

+

Jun 2004 - Aug 2005

+

+
+ +

Entry-Level Network Technician

+

Installed and maintained network hardware throughout hospital and research facility.

+
+
+

+ + +

Education

+
+ +

Bachelor of Science in Electrical Engineering

+

Louisiana State University, 2007

+
+ +

Concentration in Computer Engineering

+

Minor in Physics

+

Minor in Computer Science

+

Major GPA: 3.24

+

+
+ +

Bachelor of Science in Mathematics

+

Louisiana State University, Expected 2008

+
+ +

Concentration in Pure Math

+

Major GPA: 3.44

+
+
+

+ + +

Former Supervisors

+
+ +

Mark Rabalais

+

Instructor

+

LSU Department of Electrical and Computer Engineering

+
+ +

+

Phone: (225) 578 5200

+

Email: mrabal@lsu.edu

+
+ +

Melissa Brocato

+

Director

+

LSU Student Technical Application Resource Training

+
+ +

+

Phone: (225) 578 4526

+

Email: mbrocato@lsu.edu

+
+
+

+ + +

Skills

+
+ +

+
+ +

Languages

+
+ +

C, C++, Java, Perl, Python, Lua, Cg, Others

+
+ +

Server Software

+
+ +

Apache, BIND, CVS / SVN, DHCP, MySQL, Others

+
+ +

Operating Systems

+
+ +

Linux, OpenBSD, OpenSolaris, Windows XP / Server 2003, Others

+
+ +

WWW

+
+ +

HTML, XHTML, CSS, PHP

+
+ +

Network

+
+ +

iptables, packetfilter, IPv6, SMB / CIFS, BSD sockets

+
+ +

Linux

+
+ +

bash, dpkg, rpm, portage, pthreads, kernel configuration, X window system

+
+ +

Engineering

+
+ +

Electronics, Logic Design, Computer Architecture, Communications Technology

+
+
+

+
+
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx index 7ab5171fad01..65f521c6a20f 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.cxx @@ -503,8 +503,9 @@ void XMLHyperlinkContext::characters(const OUString& rChars) GetImport().GetGenerator().closeSpan(); } -XMLParaContext::XMLParaContext(XMLImport& rImport) +XMLParaContext::XMLParaContext(XMLImport& rImport, bool bTopLevel) : XMLImportContext(rImport) + , m_bTopLevel(bTopLevel) { } @@ -535,7 +536,8 @@ void XMLParaContext::startElement( GetImport().GetParagraphStyles(), aPropertyList); FillStyles(m_aStyleName, GetImport().GetAutomaticTextStyles(), GetImport().GetTextStyles(), m_aTextPropertyList); - GetImport().HandlePageSpan(aPropertyList); + if (m_bTopLevel) + GetImport().HandlePageSpan(aPropertyList); } else { diff --git a/writerperfect/source/writer/exp/txtparai.hxx b/writerperfect/source/writer/exp/txtparai.hxx index b87a5762b7a3..561be4f0a115 100644 --- a/writerperfect/source/writer/exp/txtparai.hxx +++ b/writerperfect/source/writer/exp/txtparai.hxx @@ -24,7 +24,7 @@ namespace exp class XMLParaContext : public XMLImportContext { public: - XMLParaContext(XMLImport& rImport); + XMLParaContext(XMLImport& rImport, bool bTopLevel = false); rtl::Reference CreateChildContext( const OUString& rName, @@ -40,6 +40,9 @@ private: OUString m_aStyleName; /// List of properties spans should inherit from this paragraph. librevenge::RVNGPropertyList m_aTextPropertyList; + /// If the context is a direct child of XMLBodyContentContext. + /// Only direct child of XMLBodyContentContext has to handle page span. + bool m_bTopLevel; }; /// Shared child context factory for paragraph and span contexts. diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx index a54210ad147f..a96582ecc3f9 100644 --- a/writerperfect/source/writer/exp/xmltbli.cxx +++ b/writerperfect/source/writer/exp/xmltbli.cxx @@ -184,8 +184,9 @@ int XMLTableRowContext::GetColumn() const { return m_nColumn; } void XMLTableRowContext::SetColumn(int nColumn) { m_nColumn = nColumn; } -XMLTableContext::XMLTableContext(XMLImport& rImport) +XMLTableContext::XMLTableContext(XMLImport& rImport, bool bTopLevel) : XMLImportContext(rImport) + , m_bTopLevel(bTopLevel) { } @@ -224,7 +225,8 @@ void XMLTableContext::startElement( { FillStyles(rAttributeValue, GetImport().GetAutomaticTableStyles(), GetImport().GetTableStyles(), m_aPropertyList); - GetImport().HandlePageSpan(m_aPropertyList); + if (m_bTopLevel) + GetImport().HandlePageSpan(m_aPropertyList); } else { diff --git a/writerperfect/source/writer/exp/xmltbli.hxx b/writerperfect/source/writer/exp/xmltbli.hxx index 6b7d7b267cbe..dff4dda2f988 100644 --- a/writerperfect/source/writer/exp/xmltbli.hxx +++ b/writerperfect/source/writer/exp/xmltbli.hxx @@ -22,7 +22,7 @@ namespace exp class XMLTableContext : public XMLImportContext { public: - XMLTableContext(XMLImport& rImport); + XMLTableContext(XMLImport& rImport, bool bTopLevel = false); rtl::Reference CreateChildContext(const OUString& rName, @@ -35,6 +35,9 @@ public: private: bool m_bTableOpened = false; + /// If the context is a direct child of XMLBodyContentContext. + /// Only direct child of XMLBodyContentContext has to handle page span. + bool m_bTopLevel; librevenge::RVNGPropertyList m_aPropertyList; librevenge::RVNGPropertyListVector m_aColumns; }; diff --git a/writerperfect/source/writer/exp/xmltext.cxx b/writerperfect/source/writer/exp/xmltext.cxx index 8177be04b573..d976ebdbf846 100644 --- a/writerperfect/source/writer/exp/xmltext.cxx +++ b/writerperfect/source/writer/exp/xmltext.cxx @@ -35,17 +35,18 @@ void XMLBodyContentContext::endElement(const OUString& /*rName*/) rtl::Reference XMLBodyContentContext::CreateChildContext( const OUString& rName, const css::uno::Reference& /*xAttribs*/) { - return CreateTextChildContext(GetImport(), rName); + return CreateTextChildContext(GetImport(), rName, true); } -rtl::Reference CreateTextChildContext(XMLImport& rImport, const OUString& rName) +rtl::Reference CreateTextChildContext(XMLImport& rImport, const OUString& rName, + bool bTopLevel) { if (rName == "text:p" || rName == "text:h") - return new XMLParaContext(rImport); + return new XMLParaContext(rImport, bTopLevel); if (rName == "text:section") return new XMLSectionContext(rImport); if (rName == "table:table") - return new XMLTableContext(rImport); + return new XMLTableContext(rImport, bTopLevel); if (rName == "text:list") return new XMLTextListContext(rImport); return nullptr; diff --git a/writerperfect/source/writer/exp/xmltext.hxx b/writerperfect/source/writer/exp/xmltext.hxx index b635176ce4ce..756a7ddbcb64 100644 --- a/writerperfect/source/writer/exp/xmltext.hxx +++ b/writerperfect/source/writer/exp/xmltext.hxx @@ -29,7 +29,8 @@ public: }; /// Context factory for body text, section, table cell, etc. -rtl::Reference CreateTextChildContext(XMLImport& rImport, const OUString& rName); +rtl::Reference CreateTextChildContext(XMLImport& rImport, const OUString& rName, + bool bTopLevel = false); } // namespace exp } // namespace writerperfect -- cgit v1.2.3