[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa sw/source
Caolán McNamara
caolanm at redhat.com
Thu Apr 30 01:39:23 PDT 2015
sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 12 ++++-
sw/source/filter/ww8/wrtw8esh.cxx | 38 +++++++++++++++---
sw/source/filter/ww8/wrtww8.hxx | 2
4 files changed, 43 insertions(+), 9 deletions(-)
New commits:
commit 4a4dadc12777db78de60f64773f4737dd604419a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Apr 23 13:47:29 2015 +0100
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 at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt b/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt
new file mode 100644
index 0000000..22b8a55
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/duplicate-east-asia.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 733434e..20e3a00 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 a2dd8ee..b93aa4f 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 c725847..d058107 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);
More information about the Libreoffice-commits
mailing list