Kaydet (Commit) 870a7ee6 authored tarafından Caolán McNamara's avatar Caolán McNamara

fix duplicate attribute export to docx with ooo69297-4.odt

Change-Id: I193099d7fffc160f0198e3d42d5d6fd5835c79cf
üst c3452e67
...@@ -106,10 +106,18 @@ DECLARE_OOXMLEXPORT_TEST(testDecimalNumberingNoLeveltext, "decimal-numbering-no- ...@@ -106,10 +106,18 @@ DECLARE_OOXMLEXPORT_TEST(testDecimalNumberingNoLeveltext, "decimal-numbering-no-
assertXPath (pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val", ""); 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") DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx")
{ {
/* File getting crash while saving in LO. /* File crashing while saving in LO.
* Checking if document.xml file is getting created after fix * Check if document.xml file is created after fix
*/ */
xmlDocPtr pXmlDoc = parseExport("word/document.xml"); xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc) if (!pXmlDoc)
......
...@@ -1169,9 +1169,30 @@ void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt) ...@@ -1169,9 +1169,30 @@ void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt)
void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos ) 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; const SwModify* pOldMod = m_rExport.pOutFmtNode;
m_rExport.pOutFmtNode = 0; m_rExport.pOutFmtNode = 0;
...@@ -1281,7 +1302,7 @@ const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const ...@@ -1281,7 +1302,7 @@ const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const
return *pRet; 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 )); SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
if( aSet.Count() ) if( aSet.Count() )
...@@ -1295,9 +1316,14 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr) ...@@ -1295,9 +1316,14 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr)
const SfxItemPool* pSrcPool = pEditPool, const SfxItemPool* pSrcPool = pEditPool,
* pDstPool = &m_rExport.pDoc->GetAttrPool(); * pDstPool = &m_rExport.pDoc->GetAttrPool();
do { do
sal_uInt16 nWhich = pItem->Which(), {
nSlotId = pSrcPool->GetSlotId( nWhich ); sal_uInt16 nWhich = pItem->Which();
if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != pWhichsToIgnore->end())
continue;
sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
if ( nSlotId && nWhich != nSlotId && if ( nSlotId && nWhich != nSlotId &&
0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) && 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
......
...@@ -1452,7 +1452,7 @@ public: ...@@ -1452,7 +1452,7 @@ public:
MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj, MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj,
sal_uInt8 nType ); sal_uInt8 nType );
void NextPara( sal_Int32 nPar ); 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); void OutEEField(const SfxPoolItem& rHt);
bool IsTxtAttr(sal_Int32 nSwPos); bool IsTxtAttr(sal_Int32 nSwPos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment