summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2021-11-16 12:51:37 +0100
committerLászló Németh <nemeth@numbertext.org>2021-11-24 14:38:14 +0100
commit98fedbc8501b53a199afa4a879707bf89a7f84e5 (patch)
tree42b49fd2711e6ca594fbf6161fe9f761d1b3d1fe
parentbf0e6dbaf3cb288f08bb2d0226d73a0c20f0e154 (diff)
tdf#124781 PPTX export: fix superscript and subscript positions
"Raise/lower by" character settings were saved incorrectly when the automatic checkbox is checked. Change-Id: Ia7260504cde85e14867936c83eaf8735142e2c53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125302 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--oox/source/export/drawingml.cxx27
-rw-r--r--sd/qa/unit/data/odp/tdf124781.odpbin0 -> 11833 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx19
3 files changed, 41 insertions, 5 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3371c04eac8e..af96b14f1ac6 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -121,6 +121,7 @@
#include <editeng/unonames.hxx>
#include <editeng/unoprnms.hxx>
#include <editeng/flditem.hxx>
+#include <editeng/escapementitem.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svdomedia.hxx>
#include <svx/unoapi.hxx>
@@ -1906,6 +1907,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
sal_Int32 nSize = 1800;
sal_Int32 nCharEscapement = 0;
sal_Int32 nCharKerning = 0;
+ sal_Int32 nCharEscapementHeight = 0;
if ( nElement == XML_endParaRPr && rbOverridingCharHeight )
{
@@ -2059,12 +2061,27 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
&& eState == beans::PropertyState_DIRECT_VALUE)
mAny >>= nCharEscapement;
- if (nCharEscapement
- && (GetPropertyAndState(rXPropSet, rXPropState, "CharEscapementHeight", eState)
- && eState == beans::PropertyState_DIRECT_VALUE))
- {
- sal_uInt32 nCharEscapementHeight = 0;
+ if (GetPropertyAndState(rXPropSet, rXPropState, "CharEscapementHeight", eState)
+ && eState == beans::PropertyState_DIRECT_VALUE)
mAny >>= nCharEscapementHeight;
+
+ if (DFLT_ESC_AUTO_SUPER == nCharEscapement)
+ {
+ // Raised by the differences between the ascenders (ascent = baseline to top of highest letter).
+ // The ascent is generally about 80% of the total font height.
+ // That is why DFLT_ESC_PROP (58) leads to 33% (DFLT_ESC_SUPER)
+ nCharEscapement = .8 * (100 - nCharEscapementHeight);
+ }
+ else if (DFLT_ESC_AUTO_SUB == nCharEscapement)
+ {
+ // Lowered by the differences between the descenders (descent = baseline to bottom of lowest letter).
+ // The descent is generally about 20% of the total font height.
+ // That is why DFLT_ESC_PROP (58) leads to 8% (DFLT_ESC_SUB)
+ nCharEscapement = .2 * -(100 - nCharEscapementHeight);
+ }
+
+ if (nCharEscapement && nCharEscapementHeight)
+ {
nSize = (nSize * nCharEscapementHeight) / 100;
// MSO uses default ~58% size
nSize = (nSize / 0.58);
diff --git a/sd/qa/unit/data/odp/tdf124781.odp b/sd/qa/unit/data/odp/tdf124781.odp
new file mode 100644
index 000000000000..199287db51d3
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf124781.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index a1512615ed8f..52b580a95e05 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
class SdOOXMLExportTest1 : public SdModelTestBaseXML
{
public:
+ void testTdf124781();
void testTdf144914();
void testTdf124232();
void testTdf143624();
@@ -126,6 +127,7 @@ public:
CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
+ CPPUNIT_TEST(testTdf124781);
CPPUNIT_TEST(testTdf144914);
CPPUNIT_TEST(testTdf124232);
CPPUNIT_TEST(testTdf143624);
@@ -218,6 +220,23 @@ void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal, sal_uInt32 nId
}
+void SdOOXMLExportTest1::testTdf124781()
+{
+ sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf124781.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ xmlDocUniquePtr pXmlDoc1 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[1]/a:r[2]/a:rPr", "baseline",
+ "33000");
+
+ xmlDocUniquePtr pXmlDoc2 = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc2, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[2]/a:r[2]/a:rPr", "baseline",
+ "-8000");
+}
+
void SdOOXMLExportTest1::testTdf144914()
{
sd::DrawDocShellRef xDocShRef