summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2022-11-02 22:34:16 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2022-11-10 11:22:09 +0100
commit59b44e72f46021c070095a75a0d7e0ae12c43399 (patch)
tree8b2d7bd490fdb6678a8b13d84ccd97210ca48dbf /oox
parentcb566ac3e1439f2afe883aacc30da3d3cb6343ec (diff)
tdf#150966 oox export avoid bottom above top for text area
If bottom and top insets set so that the bottom edge of the resulting text area is above the top edge, then LO and MS Office behave different in how this is rendered. With commit e2169886 insets are converted on import to make rendering in LO similar to MS Office, but the implemented export has some problems, see analysis in bug report. LibreOffice normalizes the resulting text area in case bottom edge is above top edge. So this patch exports the insets so, that MS Office gets a normalized resulting text area and will not apply its special rules. A roundtrip starting with pptx will not regenerate the old values but will produce inset values, which give same rendering in MS Office than in LO. Because the method is different now, the inset values have changed and test testTextDistancesOOXML_Export is adapted. When you compare the result with the screenshot on slide 2, you see that the new method works as well. The old method did not work for exporting an odp file. That is covered by the new unit test. The docx unit test file covers the case, that the export tweak was erroneously triggered. Change-Id: I0091f284d9bdd635dd87ddb9e9b0e415cc0cc51e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142185 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de> (cherry picked from commit 933768ffcd8617942f45481de77e656ded9dcfe2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142265 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 5ee48ff6e338..5df185983ea8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -110,6 +110,7 @@
#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <tools/stream.hxx>
+#include <tools/UnitConversion.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/svapp.hxx>
@@ -3337,21 +3338,27 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
// Transform the text distance values so they are compatible with OOXML insets
if (xShape.is())
{
- sal_Int32 nTextHeight = xShape->getSize().Width;
+ sal_Int32 nTextHeight = xShape->getSize().Height; // Hmm, default
- auto* pCustomShape = dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
+ // CustomShape can have text area different from shape rectangle
+ auto* pCustomShape
+ = dynamic_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape));
if (pCustomShape)
{
- tools::Rectangle aAnchorRect;
- pCustomShape->TakeTextAnchorRect(aAnchorRect);
- nTextHeight = aAnchorRect.GetSize().getHeight();
+ const EnhancedCustomShape2d aCustomShape2d(*pCustomShape);
+ nTextHeight = aCustomShape2d.GetTextRect().getHeight();
+ if (DOCUMENT_DOCX == meDocumentType)
+ nTextHeight = convertTwipToMm100(nTextHeight);
}
if (nTop + nBottom >= nTextHeight)
{
- sal_Int32 nDiff = std::abs(std::min(nTop, nBottom));
- nTop += nDiff;
- nBottom += nDiff;
+ // Effective bottom would be above effective top of text area. LO normalizes the
+ // effective text area in such case implicitely for rendering. MS needs indents so that
+ // the result is the normalized effective text area.
+ std::swap(nTop, nBottom);
+ nTop = nTextHeight - nTop;
+ nBottom = nTextHeight - nBottom;
}
}