diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-06-13 15:02:20 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-06-13 17:14:56 +0200 |
commit | 85f0a5d7bc54dfba75e8d6dd9c905bc1ac31d927 (patch) | |
tree | 39b9b02759d29aafd7f8003686403c8379815570 /sw/source/filter/ww8/docxattributeoutput.cxx | |
parent | 8d18b5af883bb6b56e758801ee730a08bb88a8f5 (diff) |
DOCX filter: improve handling of negative <w:position> in paragraph styles
The bugdoc has a <w:position w:val="-1"> in its Normal paragraph style,
which is almost not visible in Word, but we mapped this to default
subscript text in Writer, leading to very visible bad font height in
practice.
The root of the problem is that <w:position> works with an absolute
offset in half-points, while Writer works in percentages, so the
import/export code can only do a correct mapping in case the font size
is known. This initial mapping was added in commit
e70df84352d3670508a4666c97df44f82c1ce934 (try somewhat harder to read
w:position (bnc#773061), 2012-08-07), and later commit
d71cf6390a89ea6a4fab724e3a7996f28ca33661 (tdf#99602 writerfilter: import
subscript into character style, 2019-10-04) gave up on this for
character styles.
Fix the problem by working with paragraph styles similar to what the
binary DOC filter already does, just assuming that the font height from
the style won't be overwritten, or will be overwritten together with a
matching <w:position>. Do this only for negative <w:position> for now,
as that's good enough for our needs. Do the opposite of this at export
time.
It would be still possible in the future to add native handling for
absolute escapements, and then this mapping would not be needed at all.
Change-Id: I771c7bed27fa2596153aa77c472c91b819fa4cb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152962
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a75682761d84..ba5d14bd8c90 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7791,8 +7791,14 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement ) OString sIss; short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProportionalHeight(); + bool bParaStyle = false; + if (m_rExport.m_bStyDef && m_rExport.m_pCurrentStyle) + { + bParaStyle = m_rExport.m_pCurrentStyle->Which() == RES_TXTFMTCOLL; + } + // Simplify styles to avoid impossible complexity. Import and export as defaults only - if ( m_rExport.m_bStyDef && nEsc ) + if ( m_rExport.m_bStyDef && nEsc && !(bParaStyle && nEsc < 0)) { nProp = DFLT_ESC_PROP; nEsc = (nEsc > 0) ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB; |