tdf#99602 writerfilter: export only default subscript in styles

support for subscripts in character styles was added in LO 6.4.

On import, we just assume default values for superscript
and subscript _FOR STYLES_. So exporting should do the same
thing.

What was happening was that - for the non-default,
non-automatic subscript settings - the character style fontsize was
being reduced to the proportional size, but then on import
the reduced fontsize was loaded, as well as the default subscript
settings being applied again, reducing it by another 42%,
so effectively the subscripting was being applied twice.

Yes, defaults-only means that anyone tinkering around with
non-automatic subscripts won't get exact replication - but
trying to emulate LO's percentage based system and Word's
fontsize/distance system is way too complex when styles
are involved. Just note that subscripts/superscripts are used
and let the computer handle it - which generally looks best anyway.

Reviewed-on: https://gerrit.libreoffice.org/84008
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 8f7010eb47119a2428b77f5d79fc8577d9914958)

Change-Id: Idef6a084abff47dcdbe7a340cf74273a7482d430
Reviewed-on: https://gerrit.libreoffice.org/84395
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript2.odt b/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript2.odt
new file mode 100644
index 0000000..a82c815
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript2.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index f2cbdd1..4192349 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -263,6 +263,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf99602_charStyleSubscript, "tdf99602_charStyleSub
    CPPUNIT_ASSERT_EQUAL( sal_Int16(DFLT_ESC_PROP), getProperty<sal_Int16>(getRun(xPara, 2), "CharEscapementHeight") );
}

DECLARE_OOXMLEXPORT_TEST(testTdf99602_charStyleSubscript2, "tdf99602_charStyleSubscript2.odt")
{
    // *_In styles_*, don't let the proportionality/escapement affect the fontsize - otherwise it starts doubling up,
    // so instead just throw away the values and use the default settings instead - meaning fontsize is unaffected.
    // subscript custom: Proprtional size is 80%, lower by 25%.
    uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("subscript custom"), uno::UNO_QUERY);
    float fCharHeight = getProperty<float>(xStyle, "CharHeight");
    // a bug from LO 4.3 means that character styles round-trip with the wrong fontsize (10) instead of 12.
    CPPUNIT_ASSERT_MESSAGE("CharStyle has 12pt font size", 12.f == fCharHeight || 10.f == fCharHeight );
    // subscript larger font: Proportional size is 80%, lowered by DFLT_ESC_SUB_AUTO
    xStyle.set(getStyles("CharacterStyles")->getByName("subscript larger font"), uno::UNO_QUERY);
    fCharHeight = getProperty<float>(xStyle, "CharHeight");
    CPPUNIT_ASSERT_MESSAGE("Auto CharStyle has 12pt font size", 12.f == fCharHeight || 10.f == fCharHeight );
}

DECLARE_OOXMLEXPORT_TEST(testTdf124637_sectionMargin, "tdf124637_sectionMargin.docx")
{
    uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 418477b..7a01c9f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6847,6 +6847,14 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
{
    OString sIss;
    short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProportionalHeight();

    // Simplify styles to avoid impossible complexity. Import and export as defaults only
    if ( m_rExport.m_bStyDef && nEsc )
    {
        nProp = DFLT_ESC_PROP;
        nEsc = (nEsc > 0) ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
    }

    if ( !nEsc )
    {
        sIss = OString( "baseline" );