summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtfdocumentimpl.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-02-26 21:17:59 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-02-27 09:10:10 +0100
commit59363e639b67a8acbd6da240635de47921b2c955 (patch)
tree60d08c8f643275cf5fef45b6d0acfbd3de4693ea /writerfilter/source/rtftok/rtfdocumentimpl.cxx
parent61e4c00eee8c5d07a29cf7ec97bad653e3e8f8ce (diff)
tdf#115715 RTF import: ignore zero para indents in styles without parents
The only reason the DOCX equivalent of the bugdoc was imported correctly is that these default zero margins are simply missing from the DOCX markup, suggesting Word ignores them. We now do the same, this way the stripped down document's 3 paragraphs all have different margins as expected. (Also rework the testTdf112211_2 testcase to test the original problem better: I verified that the layout is unchanged before/after this patch.) Change-Id: I88d56c27c19e070e983c3392f99bca96597cd56e Reviewed-on: https://gerrit.libreoffice.org/50391 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 44b671de27bc..a499234f1d80 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -103,7 +103,7 @@ void putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, const RTFValue::Pointer
putNestedAttribute(rSprms, nParent, nId, pValue, eOverwrite, false);
}
-static RTFValue::Pointer_t lcl_getNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId)
+RTFValue::Pointer_t getNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId)
{
RTFValue::Pointer_t pParent = rSprms.find(nParent);
if (!pParent)
@@ -368,11 +368,11 @@ void RTFDocumentImpl::checkFirstRun()
// set the requested default font, if there are none
RTFValue::Pointer_t pFont
- = lcl_getNestedAttribute(m_aDefaultState.aCharacterSprms,
- NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii);
+ = getNestedAttribute(m_aDefaultState.aCharacterSprms, NS_ooxml::LN_EG_RPrBase_rFonts,
+ NS_ooxml::LN_CT_Fonts_ascii);
RTFValue::Pointer_t pCurrentFont
- = lcl_getNestedAttribute(m_aStates.top().aCharacterSprms,
- NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii);
+ = getNestedAttribute(m_aStates.top().aCharacterSprms, NS_ooxml::LN_EG_RPrBase_rFonts,
+ NS_ooxml::LN_CT_Fonts_ascii);
if (pFont && !pCurrentFont)
putNestedAttribute(m_aStates.top().aCharacterSprms, NS_ooxml::LN_EG_RPrBase_rFonts,
NS_ooxml::LN_CT_Fonts_ascii, pFont);
@@ -1937,6 +1937,26 @@ RTFError RTFDocumentImpl::pushState()
writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::createStyleProperties()
{
+ int nBasedOn = 0;
+ RTFValue::Pointer_t pBasedOn = m_aStates.top().aTableSprms.find(NS_ooxml::LN_CT_Style_basedOn);
+ if (pBasedOn)
+ nBasedOn = pBasedOn->getInt();
+ if (nBasedOn == 0)
+ {
+ // No parent style, then mimic what Word does: ignore attributes which
+ // would set a margin as formatting, but with a default value.
+ for (const auto& nId :
+ { NS_ooxml::LN_CT_Ind_firstLine, NS_ooxml::LN_CT_Ind_left, NS_ooxml::LN_CT_Ind_right,
+ NS_ooxml::LN_CT_Ind_start, NS_ooxml::LN_CT_Ind_end })
+ {
+ RTFValue::Pointer_t pValue = getNestedAttribute(m_aStates.top().aParagraphSprms,
+ NS_ooxml::LN_CT_PPrBase_ind, nId);
+ if (pValue && pValue->getInt() == 0)
+ eraseNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind,
+ nId);
+ }
+ }
+
RTFValue::Pointer_t pParaProps = std::make_shared<RTFValue>(
m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms);
RTFValue::Pointer_t pCharProps = std::make_shared<RTFValue>(