sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 ++++ writerfilter/source/dmapper/DomainMapper.cxx | 25 ++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-)
New commits: commit d71cf6390a89ea6a4fab724e3a7996f28ca33661 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Fri Oct 4 15:20:26 2019 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Nov 6 11:30:28 2019 +0100 tdf#99602 writerfilter: import subscript into character style and superscripts (aka escapements, but who knows that term). This isn't perfect, but I just fixed about 4 subscript bugs under much simpler conditions. Doing this completely compatibly with MS Word would be several magnitudes of order more difficult, since WORD works in absolute amounts (much easier to deal with) and LO works in relative percentages. Normally, the default auto settings make subscripts look the best anyway, so this should be a pretty good solution. Change-Id: Iefdc8ad55988d96ddbbba4701795a4f7a61b1521 Reviewed-on: https://gerrit.libreoffice.org/80219 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript.docx b/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript.docx new file mode 100644 index 000000000000..a88c122eeba3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf99602_charStyleSubscript.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 5d483792f83c..0be5f82136ed 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> +#include <editeng/escapementitem.hxx> #include <editeng/frmdiritem.hxx> #include <IDocumentSettingAccess.hxx> #include <xmloff/odffields.hxx> @@ -244,6 +245,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf99602_subscript_charStyleSize, "tdf99602_subscri CPPUNIT_ASSERT_DOUBLES_EQUAL( -25.f, getProperty<float>(getRun(xPara, 2, "Subscript"), "CharEscapement"), 0); } +DECLARE_OOXMLEXPORT_TEST(testTdf99602_charStyleSubscript, "tdf99602_charStyleSubscript.docx") +{ + uno::Reference<text::XTextRange> xPara = getParagraph(1); + // The word "Base" should not be subscripted. + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.f, getProperty<float>(getRun(xPara, 1, "Base"), "CharEscapement"), 0); + // The word "Subscript" should be 48pt, automatically subscripted, and automatic propertioned. + CPPUNIT_ASSERT_EQUAL( sal_Int16(DFLT_ESC_AUTO_SUB), getProperty<sal_Int16>(getRun(xPara, 2, "Subscript"), "CharEscapement") ); + CPPUNIT_ASSERT_EQUAL( sal_Int16(DFLT_ESC_PROP), getProperty<sal_Int16>(getRun(xPara, 2), "CharEscapementHeight") ); +} + DECLARE_OOXMLEXPORT_TEST(testTdf124637_sectionMargin, "tdf124637_sectionMargin.docx") { uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c44dcefb0abd..37bb2fb4f5eb 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1711,9 +1711,28 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) break; case NS_ooxml::LN_EG_RPrBase_position: // The spec says 0 is the same as the lack of the value, so don't parse that. - // FIXME: StyleSheets don't currently process deferredCharacterProperties - so position is lost in charStyles - if ( nIntValue && !IsStyleSheetImport() ) - m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue )); + if ( nIntValue ) + { + if ( !IsStyleSheetImport() ) + m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue )); + else + { + // DON'T FIXME: Truly calculating this for Character Styles will be tricky, + // because it depends on the final fontsize - regardless of + // where it is set. So at the style level, + // the escapement value would need to be grabbagged. + // At appendText time the final fontsize needs to be determined, and then + // the escapement can be calculated from the grabbag'd half-point value + // and directly applied. Yuck. + // It seems best to just treat charstyle escapement like + // pre-commit e70df84352d3670508a4666c97df44f82c1ce934 + // which just assigned default values and ignored the actual/given escapement. + sal_Int16 nEscapement = nIntValue > 0 ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB; + sal_Int8 nProp = DFLT_ESC_PROP; + rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( nEscapement ) ); + rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) ); + } + } break; case NS_ooxml::LN_EG_RPrBase_spacing: { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits