Kaydet (Commit) c2cd8772 authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Andras Timar

sw: DOCX export: fix exporting of hyperlink inside ruby

The problem is that the hints are iterated in order of start position,
and if there is a hyperlink inside a ruby then its end position will be
reached after the end position of the ruby due to the sort order, which
leads to overlapping XML elements.

So for any given position, first export the end positions, then the
start positions.

Change-Id: I2db28d7a36e4e34fbd394b3a69fe4549ee905250
Example: fdo82849-1.docx
(cherry picked from commit e5ae9bed)
üst d23cb4ee
......@@ -1198,6 +1198,39 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
{
m_rExport.m_aCurrentCharPropStarts.push( nPos );
const sal_Int32* pEnd;
// first process ends of attributes with extent
for (size_t i = 0; i < pTextAttrs->GetEndCount(); ++i)
{
const SwTextAttr* pHt = pTextAttrs->GetEnd(i);
const SfxPoolItem* pItem = &pHt->GetAttr();
switch ( pItem->Which() )
{
case RES_TXTATR_INETFMT:
pEnd = pHt->End();
if (nPos == *pEnd && nPos != pHt->GetStart())
{
if (m_rExport.AttrOutput().EndURL(nPos == rNd.Len()))
--nRet;
}
break;
case RES_TXTATR_REFMARK:
pEnd = pHt->End();
if (nullptr != pEnd && nPos == *pEnd && nPos != pHt->GetStart())
{
OutSwFormatRefMark(*static_cast<const SwFormatRefMark*>(pItem), false);
--nRet;
}
break;
case RES_TXTATR_CJK_RUBY:
pEnd = pHt->End();
if (nPos == *pEnd && nPos != pHt->GetStart())
{
m_rExport.AttrOutput().EndRuby();
--nRet;
}
break;
}
}
for ( size_t i = 0; i < pTextAttrs->Count(); ++i )
{
const SwTextAttr* pHt = (*pTextAttrs)[i];
......@@ -1212,8 +1245,8 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
++nRet;
}
pEnd = pHt->End();
if (nPos == *pEnd )
{
if (nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty must be handled here
if (m_rExport.AttrOutput().EndURL(nPos == rNd.Len()))
--nRet;
}
......@@ -1225,8 +1258,8 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
++nRet;
}
pEnd = pHt->End();
if (nullptr != pEnd && nPos == *pEnd)
{
if (nullptr != pEnd && nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty TODO: is this possible or would empty one have pEnd null?
OutSwFormatRefMark( *static_cast< const SwFormatRefMark* >( pItem ), false );
--nRet;
}
......@@ -1242,8 +1275,8 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
++nRet;
}
pEnd = pHt->End();
if (nPos == *pEnd)
{
if (nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty must be handled here
m_rExport.AttrOutput().EndRuby();
--nRet;
}
......
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