summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/wrtw8nds.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-11-29 10:09:10 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2023-01-03 15:01:05 +0000
commit87e82f80e87bb4a216ea83383864d494f3e92eea (patch)
tree1c965c840a9144300a56aab951924f67581b5888 /sw/source/filter/ww8/wrtw8nds.cxx
parent8a96d90a890812d49ee4f3c45b99aa0110b94d69 (diff)
docx: export symbol characters correctly
Previously we had: after save: <w:t></w:t> original content: <w:sym w:font="Wingdings" w:char="F0E0"/> This patch checks if paragraph has symbol font used and exports content using w:sym mark in that case Change-Id: I74f4bb0d249cbf5dfc930e931f7d91bd0d2e9821 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143455 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144949 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8nds.cxx')
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx31
1 files changed, 28 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 8b2f09d88023..3b6f4c2b47ed 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2224,6 +2224,25 @@ bool MSWordExportBase::NeedTextNodeSplit( const SwTextNode& rNd, SwSoftPageBreak
return pList.size() > 2 && NeedSectionBreak( rNd );
}
+namespace {
+OUString lcl_GetSymbolFont(SwAttrPool& rPool, const SwTextNode* pTextNode, int nStart, int nEnd)
+{
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONT> aSet( rPool );
+ if ( pTextNode && pTextNode->GetParaAttr(aSet, nStart, nEnd) )
+ {
+ SfxPoolItem const* pPoolItem = aSet.GetItem(RES_CHRATR_FONT);
+ if (pPoolItem)
+ {
+ const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pPoolItem);
+ if (pFontItem->GetCharSet() == RTL_TEXTENCODING_SYMBOL)
+ return pFontItem->GetFamilyName();
+ }
+ }
+
+ return OUString();
+}
+}
+
void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
SAL_INFO( "sw.ww8", "<OutWW8_SwTextNode>" );
@@ -2447,6 +2466,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
bool bTextAtr = aAttrIter.IsTextAttr( nCurrentPos );
nOpenAttrWithRange += aAttrIter.OutAttrWithRange( rNode, nCurrentPos );
+ OUString aSymbolFont;
sal_Int32 nLen = nNextAttr - nCurrentPos;
if ( !bTextAtr && nLen )
{
@@ -2613,12 +2633,13 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
assert(0 <= nLen);
OUString aSnippet( aAttrIter.GetSnippet( aStr, nCurrentPos + ofs, nLen ) );
+ const SwTextNode* pTextNode( rNode.GetTextNode() );
if ( ( m_nTextTyp == TXT_EDN || m_nTextTyp == TXT_FTN ) && nCurrentPos == 0 && nLen > 0 )
{
// Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
sal_Int32 nFirstLineIndent=0;
SfxItemSetFixed<RES_LR_SPACE, RES_LR_SPACE> aSet( m_rDoc.GetAttrPool() );
- const SwTextNode* pTextNode( rNode.GetTextNode() );
+
if ( pTextNode && pTextNode->GetAttr(aSet) )
{
const SvxLRSpaceItem* pLRSpace = aSet.GetItem<SvxLRSpaceItem>(RES_LR_SPACE);
@@ -2632,6 +2653,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
m_bAddFootnoteTab = false;
}
+ aSymbolFont = lcl_GetSymbolFont(m_rDoc.GetAttrPool(), pTextNode, nCurrentPos + ofs, nCurrentPos + ofs + nLen);
+
if ( bPostponeWritingText && ( FLY_POSTPONED != nStateOfFlyFrame ) )
{
aSavedSnippet = aSnippet ;
@@ -2639,7 +2662,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
else
{
bPostponeWritingText = false ;
- AttrOutput().RunText( aSnippet, eChrSet );
+ AttrOutput().RunText( aSnippet, eChrSet, aSymbolFont );
}
if (ofs == 1 && nNextAttr == nEnd)
@@ -2764,6 +2787,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().WritePostitFieldReference();
+ aSymbolFont = lcl_GetSymbolFont(m_rDoc.GetAttrPool(), &rNode, nCurrentPos, nCurrentPos + nLen);
+
if (bPostponeWritingText)
{
if (FLY_PROCESSED == nStateOfFlyFrame || FLY_NONE == nStateOfFlyFrame)
@@ -2785,7 +2810,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
// OutAttr may have introduced new comments, so write them out now
AttrOutput().WritePostitFieldReference();
}
- AttrOutput().RunText( aSavedSnippet, eChrSet );
+ AttrOutput().RunText( aSavedSnippet, eChrSet, aSymbolFont );
AttrOutput().EndRun(&rNode, nCurrentPos, nLen, nNextAttr == nEnd);
}
else