diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-04-23 13:47:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-04-23 14:04:51 +0100 |
commit | 870a7ee60ab01246ad8d9beae5705f59c6b73cbf (patch) | |
tree | 7933f2c7336ad81662a8ed7e0c03aa0df3c42c78 | |
parent | c3452e6702172b47874e8977a48715f2a74bfe12 (diff) |
fix duplicate attribute export to docx with ooo69297-4.odt
Change-Id: I193099d7fffc160f0198e3d42d5d6fd5835c79cf
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt | bin | 0 -> 9514 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 38 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 2 |
4 files changed, 43 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt b/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt Binary files differnew file mode 100644 index 000000000000..22b8a554f878 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 80c9c708beb9..6964c90a07aa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -106,10 +106,18 @@ DECLARE_OOXMLEXPORT_TEST(testDecimalNumberingNoLeveltext, "decimal-numbering-no- assertXPath (pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val", ""); } +DECLARE_OOXMLEXPORT_TEST(testNoDuplicateAttributeExport, "duplicate-east-asia.odt") +{ + // File asserting while saving in LO. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; +} + DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx") { - /* File getting crash while saving in LO. - * Checking if document.xml file is getting created after fix + /* File crashing while saving in LO. + * Check if document.xml file is created after fix */ xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 97131c0dbf32..b73061557310 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1169,9 +1169,30 @@ void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt) void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos ) { - OutParaAttr(true); + //Collect the which ids belong to the run that we will export after + //outputting the underlying paragraph attributes. We will exclude + //writing these from the underlying paragraph attributes to avoid + //duplicate attributes in docx export. Doesn't matter in doc + //export as later props just override earlier ones. + std::set<sal_uInt16> aUsedRunWhichs; + if (!aTxtAtrArr.empty()) + { + for(std::vector<EECharAttrib>::const_iterator i = aTxtAtrArr.begin(); i < aTxtAtrArr.end(); ++i) + { + if (nSwPos >= i->nStart && nSwPos < i->nEnd) + { + sal_uInt16 nWhich = i->pAttr->Which(); + aUsedRunWhichs.insert(nWhich); + } + + if( nSwPos < i->nStart ) + break; + } + } - if(!aTxtAtrArr.empty()) + OutParaAttr(true, &aUsedRunWhichs); + + if (!aTxtAtrArr.empty()) { const SwModify* pOldMod = m_rExport.pOutFmtNode; m_rExport.pOutFmtNode = 0; @@ -1281,7 +1302,7 @@ const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const return *pRet; } -void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr) +void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* pWhichsToIgnore) { SfxItemSet aSet( pEditObj->GetParaAttribs( nPara )); if( aSet.Count() ) @@ -1295,9 +1316,14 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr) const SfxItemPool* pSrcPool = pEditPool, * pDstPool = &m_rExport.pDoc->GetAttrPool(); - do { - sal_uInt16 nWhich = pItem->Which(), - nSlotId = pSrcPool->GetSlotId( nWhich ); + do + { + sal_uInt16 nWhich = pItem->Which(); + + if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != pWhichsToIgnore->end()) + continue; + + sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich); if ( nSlotId && nWhich != nSlotId && 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) && diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 372789beca76..9b367c02ecd0 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1452,7 +1452,7 @@ public: MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj, sal_uInt8 nType ); void NextPara( sal_Int32 nPar ); - void OutParaAttr(bool bCharAttr); + void OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* pWhichsToIgnore = NULL); void OutEEField(const SfxPoolItem& rHt); bool IsTxtAttr(sal_Int32 nSwPos); |