summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-16 09:05:57 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-03-16 09:42:11 +0100
commitd934cb370b1d660f996ec959fda4bcc6f29902a9 (patch)
treec1335fab930ded9d95d51b95cab7a1930b0f501c /writerfilter
parent5ac7d9e0cb5172e3582b8fa4548913cdcdadc677 (diff)
tdf#138895 DOCX filter: fix handling for effect extent vs line width
Regression from commit a5a836d8c43dc9cebbbf8af39bf0142de603a7c6 (DOCX filter: effect extent should be part of the margin, 2014-12-04), the problem was that effect extent is OK to be added as an extra margin, but line width is part of that effect extent in Word, so Writer margin should not be increased with the line width. The Word behavior seems to be that half of the line width is part of e.g. the top effect extent, then the other half is part of the bottom one (and so on). The bugdoc's case was that a too large margin shifted the last line below the shape, and this tiny half-line-width extra margin handled correctly puts the line back to its correct place. Change-Id: Ic897926f3d79f979ea84aef3dbda49c46b18a3ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112558 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx36
1 files changed, 31 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index cc81850bfc86..1aa0a03082a9 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -810,25 +810,51 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
// Include effect extent in the margin to bring Writer layout closer
// to Word. But do this for non-rotated shapes only, where effect
// extents map to increased margins as-is.
+
+ sal_Int32 nLineWidth{};
+ if (xShapeProps->getPropertySetInfo()->hasPropertyByName("LineWidth"))
+ {
+ xShapeProps->getPropertyValue("LineWidth") >>= nLineWidth;
+ }
+
if (m_pImpl->m_oEffectExtentLeft)
{
- m_pImpl->nLeftMargin += oox::drawingml::convertEmuToHmm(
+ sal_Int32 nLeft = oox::drawingml::convertEmuToHmm(
*m_pImpl->m_oEffectExtentLeft);
+ if (nLeft >= nLineWidth / 2)
+ {
+ nLeft -= nLineWidth / 2;
+ }
+ m_pImpl->nLeftMargin += nLeft;
}
if (m_pImpl->m_oEffectExtentTop)
{
- m_pImpl->nTopMargin += oox::drawingml::convertEmuToHmm(
- *m_pImpl->m_oEffectExtentTop);
+ sal_Int32 nTop = oox::drawingml::convertEmuToHmm(*m_pImpl->m_oEffectExtentTop);
+ if (nTop >= nLineWidth / 2)
+ {
+ nTop -= nLineWidth / 2;
+ }
+ m_pImpl->nTopMargin += nTop;
}
if (m_pImpl->m_oEffectExtentRight)
{
- m_pImpl->nRightMargin += oox::drawingml::convertEmuToHmm(
+ sal_Int32 nRight = oox::drawingml::convertEmuToHmm(
*m_pImpl->m_oEffectExtentRight);
+ if (nRight >= nLineWidth / 2)
+ {
+ nRight -= nLineWidth / 2;
+ }
+ m_pImpl->nRightMargin += nRight;
}
if (m_pImpl->m_oEffectExtentBottom)
{
- m_pImpl->nBottomMargin += oox::drawingml::convertEmuToHmm(
+ sal_Int32 nBottom = oox::drawingml::convertEmuToHmm(
*m_pImpl->m_oEffectExtentBottom);
+ if (nBottom >= nLineWidth / 2)
+ {
+ nBottom -= nLineWidth / 2;
+ }
+ m_pImpl->nBottomMargin += nBottom;
}
}
}