diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-04-23 13:47:29 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-04-30 08:36:54 +0000 |
commit | 4a4dadc12777db78de60f64773f4737dd604419a (patch) | |
tree | bebd4cae94773b6082fe74cf1d448c4a525b2ca2 | |
parent | 9ad420fba51ee539ecf4a6cedc224e1025632f5f (diff) |
Resolves: tdf#85769 fix duplicate attribute export to docx...
with ooo69297-4.odt
(cherry picked from commit 870a7ee60ab01246ad8d9beae5705f59c6b73cbf)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
Change-Id: I193099d7fffc160f0198e3d42d5d6fd5835c79cf
Reviewed-on: https://gerrit.libreoffice.org/15572
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 733434ed8e84..20e3a00a3309 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -99,10 +99,18 @@ DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx") assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" ); } +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 a2dd8eee7741..b93aa4f63c97 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1162,9 +1162,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; @@ -1274,7 +1295,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() ) @@ -1288,9 +1309,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 c72584787293..d0581079190e 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1477,7 +1477,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); |