summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-07-25 18:04:53 +0200
committerRegina Henschel <rb.henschel@t-online.de>2021-07-27 01:34:02 +0200
commit67f2a99229101757af4f40118f4d3c83ba38648b (patch)
tree5f7d4fd21813612a44d6015510a055265d4b4641 /writerfilter
parent1dd4a80fa076bedb3a82821517036bad8dd79857 (diff)
tdf#143475 consider Word 2007 rotated image speciality
Usually Word relates effectExtent to a rectangle with swapped width and height, if the object rotation is between 45deg and 135deg. But Word 2007 (=version 12) makes an exception for images (bug?). The patch determines the version from compatibility setting and calculates wrap margins and effectExtent values considering this special feature of Word 2007. I have moved the part for getting the Word version from InteropGrabBag from the local function lcl_getWordCompatibilityMode to DocxExport, because I need it exactly the same way in docxsdrexport.cxx. Change-Id: Icc2f3d0710e29207413fb3810d281a0fd7d82002 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119482 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx31
-rw-r--r--writerfilter/source/dmapper/GraphicImport.hxx1
2 files changed, 32 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 940780ca9705..8ed707c2917f 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -552,6 +552,26 @@ static bool lcl_bHasGroupSlantedChild(const SdrObject* pObj)
return false;
}
+void GraphicImport::lcl_correctWord2007EffectExtent(const sal_Int32 nMSOAngle)
+{
+ // Word versions older than 14 do not swap width and height (see lcl_doMSOWidthHeightSwap)
+ // and therefore generate different effectExtent. We correct them here.
+ sal_Int16 nAngleDeg = (nMSOAngle / 60000) % 180;
+ if (nAngleDeg >= 45 && nAngleDeg < 135)
+ {
+ sal_Int32 nDiff = o3tl::convert((m_pImpl->getXSize() - m_pImpl->getYSize()) / 2.0,
+ o3tl::Length::mm100, o3tl::Length::emu);
+ if (m_pImpl->m_oEffectExtentLeft)
+ *m_pImpl->m_oEffectExtentLeft += nDiff;
+ if (m_pImpl->m_oEffectExtentRight)
+ *m_pImpl->m_oEffectExtentRight += nDiff;
+ if (m_pImpl->m_oEffectExtentTop)
+ *m_pImpl->m_oEffectExtentTop -= nDiff;
+ if (m_pImpl->m_oEffectExtentBottom)
+ *m_pImpl->m_oEffectExtentBottom -= nDiff;
+ }
+}
+
static void lcl_doMSOWidthHeightSwap(awt::Point& rLeftTop, awt::Size& rSize,
const sal_Int32 nMSOAngle)
{
@@ -965,6 +985,17 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
// snap rectangle.
// Margin correction
+
+ // tdf#143475: Word 2007 (vers 12) calculates effectExtent for rotated images
+ // based on the unrotated image without width-height-swap. We correct this to
+ // those values, which would be calculated if width-height-swap was used.
+ if (m_pImpl->rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() < 14
+ && xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")
+ && nOOXAngle != 0)
+ {
+ lcl_correctWord2007EffectExtent(nOOXAngle);
+ }
+
if (m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_INLINE)
{
if (nOOXAngle == 0)
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index bea911eef8bb..7ca4e09ed30d 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -126,6 +126,7 @@ public:
void handleWrapTextValue(sal_uInt32 nVal);
void lcl_expandRectangleByEffectExtent(css::awt::Point& rLeftTop, css::awt::Size& rSize);
+ void lcl_correctWord2007EffectExtent(const sal_Int32 nMSOAngle);
};
typedef tools::SvRef<GraphicImport> GraphicImportPtr;