diff options
author | Pallavi Jadhav <pallavi.jadhav@synerzip.com> | 2014-01-28 11:42:53 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-25 10:13:55 +0100 |
commit | 01826dc12550e7a4204034f7876c593726525b54 (patch) | |
tree | 68e04dae604422e84f59c14ece1d4c4b59cdbaf5 | |
parent | 59e45c373fc037aa97432102067bdacc8fca6446 (diff) |
fdo#74105 : Prservation of Numbered lists-Starting with Value '0'
Issue :
- DOCX containing Numbered lists- Strating with
value '0' is not preserved after RT.
- LO exports document with Numbered lists starting
from '1' instead of '0'.
- LO "Import" and "Export" need fixes.
- If LO will imports correctly, export will get
correct value.
Implentation :
- Added code at Import and Export side.
- Added Export Unit test case to check that
<w:start> is not present in numbering.xml
for 0th level.
NOTE : <w:start> is optional. If not mentioned
Numbered lists starts from '0'.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7710
Change-Id: I30910c41fd188f30a1723cf8e07be5ea1cde1be0
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/FDO74105.docx | bin | 0 -> 13804 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 13 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.cxx | 12 |
4 files changed, 36 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/FDO74105.docx b/sw/qa/extras/ooxmlexport/data/FDO74105.docx Binary files differnew file mode 100644 index 000000000000..4299cf9c210e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/FDO74105.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d7692ac44da0..7b7c9047106b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3498,6 +3498,21 @@ DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx") CPPUNIT_ASSERT_EQUAL(2, nImageFiles); } +DECLARE_OOXMLEXPORT_TEST(testNumberedLists_StartingWithZero, "FDO74105.docx") +{ + /* Issue : Numbered lists Starting with value '0' is not preserved after RT. + * In numbering.xml, an XML tag <w:start> is optional. If not mentioned, + * the Numbered list should start from 0. + * Problem was LO was writing <w:start> for all levels 0-8 with default value "1". + */ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + + // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">. + assertXPath(pXmlDoc, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 6414d042cd23..77a0aedea165 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4434,10 +4434,15 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel, FSNS( XML_w, XML_ilvl ), OString::number( nLevel ).getStr(), FSEND ); - // start with the nStart value - m_pSerializer->singleElementNS( XML_w, XML_start, - FSNS( XML_w, XML_val ), OString::number( nStart ).getStr(), - FSEND ); + // start with the nStart value. Do not write w:start if Numbered Lists + // starts from zero.As it's an optional parameter. + // refer ECMA 376 Second edition Part-1 + if(!(0 == nLevel && 0 == nStart)) + { + m_pSerializer->singleElementNS( XML_w, XML_start, + FSNS( XML_w, XML_val ), OString::number( nStart ).getStr(), + FSEND ); + } // format OString aFmt( impl_NumberingType( nNumberingType ) ); diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index 60582c863bc4..98d9c44c6f26 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -829,6 +829,7 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal ) void ListsManager::lcl_sprm( Sprm& rSprm ) { + static bool bIsStartVisited = false; //fill the attributes of the style sheet sal_uInt32 nSprmId = rSprm.getId(); if( m_pCurrentDefinition.get() || @@ -952,11 +953,22 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) } break; case NS_ooxml::LN_CT_Lvl_start: + if (m_pCurrentDefinition->GetCurrentLevel().get()) + m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue ); + bIsStartVisited = true; + break; case NS_ooxml::LN_CT_Lvl_numFmt: case NS_ooxml::LN_CT_Lvl_isLgl: case NS_ooxml::LN_CT_Lvl_legacy: if (m_pCurrentDefinition->GetCurrentLevel().get()) + { m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue ); + if( false == bIsStartVisited ) + { + m_pCurrentDefinition->GetCurrentLevel( )->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 ); + bIsStartVisited = true; + } + } break; case NS_ooxml::LN_CT_Lvl_suff: { |