summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-05-07 10:40:44 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-12 12:03:35 +0200
commit1237acf9851f8b12d1ccd929e2aa8b184c06d552 (patch)
treead6b438253aab2311e4ddcf5f75d5834d9d262d5 /writerfilter
parente21ef73de4591c0d8e11920b7c21d7bbfeddc701 (diff)
tdf#132811 DOCX: fix formula alignment – part 2
Formula are aligned inline again, but in the right position, fixing both import and export. This partially reverts commit 8b613c4603047dc24aa9b03fb49f4fe1b65af2a3 (tdf#121525 OOXML import: fix formula alignment). Co-author: Tibor Nagy (NISZ) Change-Id: If5c13db749fe5c3b1aee754b47dabc9fabd7ebb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93631 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper.hxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx44
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx3
4 files changed, 17 insertions, 49 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index e2d497c8a8d4..8eab461992b6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -734,16 +734,19 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_Value_math_ST_Jc_centerGroup:
case NS_ooxml::LN_Value_math_ST_Jc_center:
- m_pImpl->appendStarMath(val, eMathParaJc::CENTER);
+ m_pImpl->appendStarMath(val);
+ m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_CENTER));
break;
case NS_ooxml::LN_Value_math_ST_Jc_left:
- m_pImpl->appendStarMath(val, eMathParaJc::LEFT);
+ m_pImpl->appendStarMath(val);
+ m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_LEFT));
break;
case NS_ooxml::LN_Value_math_ST_Jc_right:
- m_pImpl->appendStarMath(val, eMathParaJc::RIGHT);
+ m_pImpl->appendStarMath(val);
+ m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_RIGHT));
break;
case NS_ooxml::LN_starmath:
- m_pImpl->appendStarMath( val, eMathParaJc::INLINE );
+ m_pImpl->appendStarMath(val);
break;
case NS_ooxml::LN_CT_FramePr_dropCap:
case NS_ooxml::LN_CT_FramePr_lines:
diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx
index 31e5fa705838..c8281f9334ec 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -129,14 +129,6 @@ public:
void HandleRedline( Sprm& rSprm );
- enum eMathParaJc
- {
- INLINE,
- CENTER,
- LEFT,
- RIGHT
- };
-
private:
// Stream
virtual void lcl_startSectionGroup() override;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fde30248f6d1..6d8f0822e7ce 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -99,7 +99,6 @@
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
-
using namespace ::com::sun::star;
using namespace oox;
namespace writerfilter::dmapper{
@@ -2207,7 +2206,7 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const std::share
}
-void DomainMapper_Impl::appendStarMath( const Value& val , sal_uInt8 nAlign)
+void DomainMapper_Impl::appendStarMath( const Value& val )
{
uno::Reference< embed::XEmbeddedObject > formula;
val.getAny() >>= formula;
@@ -2251,41 +2250,8 @@ void DomainMapper_Impl::appendStarMath( const Value& val , sal_uInt8 nAlign)
// mimic the treatment of graphics here... it seems anchoring as character
// gives a better ( visually ) result
appendTextContent(xStarMath, uno::Sequence<beans::PropertyValue>());
- if (nAlign != DomainMapper::eMathParaJc::INLINE)
- {
- xStarMathProperties->setPropertyValue(
- getPropertyName(PROP_ANCHOR_TYPE),
- uno::makeAny(text::TextContentAnchorType_AT_PARAGRAPH));
- switch (nAlign)
- {
- case DomainMapper::eMathParaJc::CENTER:
- xStarMathProperties->setPropertyValue(
- getPropertyName(PROP_HORI_ORIENT),
- uno::makeAny(text::HoriOrientation::CENTER));
- break;
- case DomainMapper::eMathParaJc::LEFT:
- xStarMathProperties->setPropertyValue(
- getPropertyName(PROP_HORI_ORIENT),
- uno::makeAny(text::HoriOrientation::LEFT));
- break;
- case DomainMapper::eMathParaJc::RIGHT:
- xStarMathProperties->setPropertyValue(
- getPropertyName(PROP_HORI_ORIENT),
- uno::makeAny(text::HoriOrientation::RIGHT));
- break;
- default:
- break;
- }
- xStarMathProperties->setPropertyValue(
- "Surround",
- uno::makeAny(text::WrapTextMode_NONE));
- }
- else
- {
- xStarMathProperties->setPropertyValue(
- getPropertyName(PROP_ANCHOR_TYPE),
+ xStarMathProperties->setPropertyValue(getPropertyName(PROP_ANCHOR_TYPE),
uno::makeAny(text::TextContentAnchorType_AS_CHARACTER));
- }
}
catch( const uno::Exception& )
{
@@ -2294,6 +2260,12 @@ void DomainMapper_Impl::appendStarMath( const Value& val , sal_uInt8 nAlign)
}
}
+void DomainMapper_Impl::adjustLastPara(sal_Int8 nAlign)
+{
+ PropertyMapPtr pLastPara = GetTopContextOfType(dmapper::CONTEXT_PARAGRAPH);
+ pLastPara->Insert(PROP_PARA_ADJUST, uno::makeAny(nAlign), true);
+}
+
uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter(
uno::Reference< text::XTextRange > const & xBefore )
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 8f46234a44ba..d9e97d1764db 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -681,7 +681,8 @@ public:
void appendTextPortion( const OUString& rString, const PropertyMapPtr& pPropertyMap );
void appendTextContent(const css::uno::Reference<css::text::XTextContent>&, const css::uno::Sequence<css::beans::PropertyValue>&);
void appendOLE( const OUString& rStreamName, const std::shared_ptr<OLEHandler>& pOleHandler );
- void appendStarMath( const Value& v , sal_uInt8);
+ void appendStarMath( const Value& v);
+ void adjustLastPara(sal_Int8);
css::uno::Reference<css::beans::XPropertySet> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange> const & xBefore);
/// AutoText import: each entry is placed in the separate section