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

Change-Id: I2a6d0a7d2382dfbc2f0ab04f150653c9b17bbfd1
This commit is contained in:
Ravindra Vidhate 2014-05-21 14:54:35 +05:30 committed by Miklos Vajna
parent c5547beb47
commit 8555c24e06
3 changed files with 21 additions and 1 deletions

Binary file not shown.

View File

@ -3446,6 +3446,17 @@ DECLARE_OOXMLEXPORT_TEST(testfdo78886, "fdo78886.docx")
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[2]/w:tr[1]/w:tc[1]/w:p[1]/w:hyperlink[1]/w:r[2]/w:fldChar[1]", 0); assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[2]/w:tr[1]/w:tc[1]/w:p[1]/w:hyperlink[1]/w:r[2]/w:fldChar[1]", 0);
} }
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(testFdo78651, "fdo78651.docx") DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx")
{ {
xmlDocPtr pXmlDoc = parseExport("word/document.xml"); xmlDocPtr pXmlDoc = parseExport("word/document.xml");

View File

@ -1726,6 +1726,8 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
if ( m_pRedlineData && m_pRedlineData->GetType() == nsRedlineType_t::REDLINE_DELETE ) if ( m_pRedlineData && m_pRedlineData->GetType() == nsRedlineType_t::REDLINE_DELETE )
nTextToken = XML_delText; nTextToken = XML_delText;
sal_Unicode prevUnicode = *pBegin;
for ( const sal_Unicode *pIt = pBegin; pIt < pEnd; ++pIt ) for ( const sal_Unicode *pIt = pBegin; pIt < pEnd; ++pIt )
{ {
switch ( *pIt ) switch ( *pIt )
@ -1733,20 +1735,26 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
case 0x09: // tab case 0x09: // tab
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_tab, FSEND ); m_pSerializer->singleElementNS( XML_w, XML_tab, FSEND );
prevUnicode = *pIt;
break; break;
case 0x0b: // line 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 ); m_pSerializer->singleElementNS( XML_w, XML_br, FSEND );
prevUnicode = *pIt;
}
} }
break; break;
case 0x1E: //non-breaking hyphen case 0x1E: //non-breaking hyphen
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_noBreakHyphen, FSEND ); m_pSerializer->singleElementNS( XML_w, XML_noBreakHyphen, FSEND );
prevUnicode = *pIt;
break; break;
case 0x1F: //soft (on demand) hyphen case 0x1F: //soft (on demand) hyphen
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
m_pSerializer->singleElementNS( XML_w, XML_softHyphen, FSEND ); m_pSerializer->singleElementNS( XML_w, XML_softHyphen, FSEND );
prevUnicode = *pIt;
break; break;
default: default:
if ( *pIt < 0x0020 ) // filter out the control codes if ( *pIt < 0x0020 ) // filter out the control codes
@ -1754,6 +1762,7 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh
impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt );
OSL_TRACE( "Ignored control code %x in a text run.", *pIt ); OSL_TRACE( "Ignored control code %x in a text run.", *pIt );
} }
prevUnicode = *pIt;
break; break;
} }
} }