[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/qa sw/source

Michael Stahl mstahl at redhat.com
Mon Jul 20 12:48:59 PDT 2015


 sw/qa/extras/ooxmlexport/data/rubyhyperlink.fodt |   45 +++++++++++++++++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx        |    5 ++
 sw/source/filter/ww8/docxattributeoutput.cxx     |   10 ++---
 3 files changed, 54 insertions(+), 6 deletions(-)

New commits:
commit d4e89800a477609775152e859623bd3f317d423c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Jul 18 20:59:00 2015 +0200

    sw: DOCX export: *really* fix non-well-formed XML with hyperlink/ruby
    
    Turns out that 84ea33ef9a86f097a248b526554cdc3581c8d725 did not actually
    fix the problem; it was merely good enough to fool the asserts in
    FastSaxSerializer that were not yet adapted to the funky maMarkStack.
    
    The problem is that the StartRuby()/EndRuby() call StartRun()/EndRun()
    and that really messes up the mark stack.  Prevent that by first ending
    the run before starting new one in StartRuby(), and then starting a new
    run after ending the ruby-base one in EndRuby().
    
    The hints handled in SwWW8AttrIter::OutAttrWithRange() are sorted in the
    right way for this to work (i.e. the EndRuby() will be the last call for
    any given position).
    
    This apparently causes an additional <w:r/> empty element to be written,
    not sure if that causes any issues but at least the output is
    well-formed for fdo82849-1.odt.
    
    Change-Id: I28ffd029246310ff0e405b0674aef8e724700d4d
    (cherry picked from commit c2c51fa587523edd6e31a17affffc77645b60dea)
    Reviewed-on: https://gerrit.libreoffice.org/17230
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/sw/qa/extras/ooxmlexport/data/rubyhyperlink.fodt b/sw/qa/extras/ooxmlexport/data/rubyhyperlink.fodt
new file mode 100644
index 0000000..a201d7c
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/rubyhyperlink.fodt
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+
+ <office:font-face-decls>
+  <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit Devanagari'"/>
+  <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
+  <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Source Han Sans CN Normal" svg:font-family="'Source Han Sans CN Normal'" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Normal" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+  <style:style style:name="Internet_20_link" style:display-name="Internet link" style:family="text">
+   <style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/>
+  </style:style>
+
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
+   <style:text-properties officeooo:rsid="001000a5" officeooo:paragraph-rsid="001000a5"/>
+  </style:style>
+  <style:style style:name="Ru1" style:family="ruby">
+   <style:ruby-properties style:ruby-align="left" style:ruby-position="above"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:text>
+   <text:p text:style-name="P1"><text:ruby text:style-name="Ru1"><text:ruby-base>bar</text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby></text:p>
+   <text:p text:style-name="P1">foo<text:ruby text:style-name="Ru1"><text:ruby-base>bar</text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby>baz</text:p>
+   <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">foo</text:a><text:ruby text:style-name="Ru1"><text:ruby-base>bar</text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby>baz</text:p>
+   <text:p text:style-name="P1">foo<text:ruby text:style-name="Ru1"><text:ruby-base><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">bar</text:a></text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby>baz</text:p>
+   <text:p text:style-name="P1">foo<text:ruby text:style-name="Ru1"><text:ruby-base>bar</text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">baz</text:a></text:p>
+   <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">foo</text:a><text:ruby text:style-name="Ru1"><text:ruby-base><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">bar</text:a></text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby>baz</text:p>
+   <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">foo</text:a><text:ruby text:style-name="Ru1"><text:ruby-base>bar</text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">baz</text:a></text:p>
+   <text:p text:style-name="P1">foo<text:ruby text:style-name="Ru1"><text:ruby-base><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">bar</text:a></text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">baz</text:a></text:p>
+   <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">foo</text:a><text:ruby text:style-name="Ru1"><text:ruby-base><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">bar</text:a></text:ruby-base><text:ruby-text>quux</text:ruby-text></text:ruby><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">baz</text:a></text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index ac7ba3c..2af85c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -707,6 +707,11 @@ DECLARE_OOXMLEXPORT_TEST(testAbsolutePositionOffsetValue,"fdo78432.docx")
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testRubyHyperlink, "rubyhyperlink.fodt")
+{
+    // test that export doesn't assert with overlapping ruby / hyperlink attr
+}
+
 DECLARE_OOXMLEXPORT_TEST(testfdo78300,"fdo78300.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 54b511c..022ee0b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2135,12 +2135,9 @@ void DocxAttributeOutput::RawText( const OUString& /*rText*/, bool /*bForceUnico
 void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby )
 {
     OSL_TRACE("TODO DocxAttributeOutput::StartRuby( const SwTextNode& rNode, const SwFormatRuby& rRuby )" );
-    if (m_closeHyperlinkInThisRun)
-    {
-        EndRun(); // end hyperlink before starting ruby to avoid overlap
-        assert(!m_closeHyperlinkInThisRun);
-        assert(!m_closeHyperlinkInPreviousRun);
-    }
+    EndRun(); // end run before starting ruby to avoid nested runs, and overlap
+    assert(!m_closeHyperlinkInThisRun); // check that no hyperlink overlaps ruby
+    assert(!m_closeHyperlinkInPreviousRun);
     m_pSerializer->startElementNS( XML_w, XML_ruby, FSEND );
     m_pSerializer->startElementNS( XML_w, XML_rubyPr, FSEND );
     // hps
@@ -2205,6 +2202,7 @@ void DocxAttributeOutput::EndRuby()
     EndRun( );
     m_pSerializer->endElementNS( XML_w, XML_rubyBase );
     m_pSerializer->endElementNS( XML_w, XML_ruby );
+    StartRun(nullptr); // open Run again so OutputTextNode loop can close it
 }
 
 bool DocxAttributeOutput::AnalyzeURL( const OUString& rUrl, const OUString& rTarget, OUString* pLinkURL, OUString* pMark )


More information about the Libreoffice-commits mailing list