summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavindra Vidhate <ravindra.vidhate@synerzip.com>2014-05-21 14:54:35 +0530
committerMichael Stahl <mstahl@redhat.com>2014-06-10 18:26:10 +0200
commit637a96d1e7875043c28a93c9a543f33a862497cb (patch)
tree8b4191836cb255d0ae2bdc890b9a6ff83380d4b2
parentb72371aeb34288e40cdd082e387cf54593c8d111 (diff)
fdo#78887 <w:br> tag is not being preserved after export.
When we have <w:br> tag continuous like in the following cases... "Title: Superstition\v\vComposer: Stevie Wonder\v\v" or "\vLyrics: \v" where "\n" is internally replaced by "\v" LO. Before text "\v" or after text multiple "\v" is not preserved. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/9420 (cherry picked from commit 8555c24e069dc00071eaad23c711f1d1375e5afc) Signed-off-by: Michael Stahl <mstahl@redhat.com> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I2a6d0a7d2382dfbc2f0ab04f150653c9b17bbfd1
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo78887.docxbin0 -> 14813 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx11
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx11
3 files changed, 21 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo78887.docx b/sw/qa/extras/ooxmlexport/data/fdo78887.docx
new file mode 100644
index 000000000000..db92fe4ede06
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo78887.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a87ddef92f52..668caa33c4cf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3180,6 +3180,17 @@ DECLARE_OOXMLEXPORT_TEST(testFDO77890 , "fdo77890.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page");
}
+DECLARE_OOXMLEXPORT_TEST(testFDO78887, "fdo78887.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1);
+ assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: ");
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1);
+}
+
DECLARE_OOXMLEXPORT_TEST(testNumberedList,"NumberedList.docx")
{
//fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f16fdf6dcd53..3eba470c7fe7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1680,6 +1680,8 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
if ( m_pRedlineData && m_pRedlineData->GetType() == nsRedlineType_t::REDLINE_DELETE )
nTextToken = XML_delText;
+ sal_Unicode prevUnicode = *pBegin;
+
for ( const sal_Unicode *pIt = pBegin; pIt < pEnd; ++pIt )
{
switch ( *pIt )
@@ -1687,20 +1689,26 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
case 0x09: // tab
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_tab, FSEND );
+ prevUnicode = *pIt;
break;
case 0x0b: // line break
{
- if (impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ))
+ if (impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ) || (prevUnicode == *pIt))
+ {
m_pSerializer->singleElementNS( XML_w, XML_br, FSEND );
+ prevUnicode = *pIt;
+ }
}
break;
case 0x1E: //non-breaking hyphen
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_noBreakHyphen, FSEND );
+ prevUnicode = *pIt;
break;
case 0x1F: //soft (on demand) hyphen
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_softHyphen, FSEND );
+ prevUnicode = *pIt;
break;
default:
if ( *pIt < 0x0020 ) // filter out the control codes
@@ -1708,6 +1716,7 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
OSL_TRACE( "Ignored control code %x in a text run.", *pIt );
}
+ prevUnicode = *pIt;
break;
}
}