diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2022-03-21 17:12:12 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-22 09:38:07 +0100 |
commit | 24b5490cb0fd8de19415509fbf452874669106ad (patch) | |
tree | 9e34facd04af0f1918822fdd1cfafa038a6adbc5 /writerfilter/source | |
parent | 3076b4f009cd1ba8c7f71454436001def34d9bd0 (diff) |
tdf#104390: rtf import: init default font for entire state stack
If first document element is buried deep in destinations and thus
deep in state stack (m_aStates) initialization of default font
is very local and will be lost after closing these destinations.
So let's initialize entire states stack with default font if none
is provided istead of initialization just a top element.
Change-Id: I966c282f43b84baece909a4c3cd359cbcd317e63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131906
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/source')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 75d6ae193ffc..bceea94c5980 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -396,16 +396,22 @@ void RTFDocumentImpl::checkFirstRun() assert(!m_bNeedSect || m_bFirstRunException); setNeedSect(true); // first call that succeeds - // set the requested default font, if there are none + // set the requested default font, if there are none for each state in stack RTFValue::Pointer_t pFont = getNestedAttribute(m_aDefaultState.getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii); - RTFValue::Pointer_t pCurrentFont - = getNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, - NS_ooxml::LN_CT_Fonts_ascii); - if (pFont && !pCurrentFont) - putNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, - NS_ooxml::LN_CT_Fonts_ascii, pFont); + if (!pFont) + return; + + for (size_t i = 0; i < m_aStates.size(); i++) + { + RTFValue::Pointer_t pCurrentFont + = getNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii); + if (!pCurrentFont) + putNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii, pFont); + } } void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; } |