diff options
-rw-r--r-- | offapi/com/sun/star/formula/FormulaProperties.idl | 6 | ||||
-rw-r--r-- | starmath/inc/document.hxx | 2 | ||||
-rw-r--r-- | starmath/inc/format.hxx | 4 | ||||
-rw-r--r-- | starmath/source/cfgitem.cxx | 7 | ||||
-rw-r--r-- | starmath/source/document.cxx | 18 | ||||
-rw-r--r-- | starmath/source/format.cxx | 4 | ||||
-rw-r--r-- | starmath/source/mathml/mathmlexport.cxx | 21 | ||||
-rw-r--r-- | starmath/source/unomodel.cxx | 10 |
8 files changed, 66 insertions, 6 deletions
diff --git a/offapi/com/sun/star/formula/FormulaProperties.idl b/offapi/com/sun/star/formula/FormulaProperties.idl index 204e06f50ba0..79ab4e7244bc 100644 --- a/offapi/com/sun/star/formula/FormulaProperties.idl +++ b/offapi/com/sun/star/formula/FormulaProperties.idl @@ -282,6 +282,12 @@ published service FormulaProperties @since OOo 3.4 */ [property, optional] short BaseLine; + + /** switches into right-to-left layout. + + @since LibreOffice 24.2 + */ + [property, optional] boolean IsRightToLeft; }; diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index bf9477b30f11..45321614385a 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -222,6 +222,8 @@ public: mathml::SmMlIteratorFree(m_pMlElementTree); m_pMlElementTree = pMlElementTree; } + + void SetRightToLeft(bool bRTL); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx index 23dc04d290cf..5845d148e7fa 100644 --- a/starmath/inc/format.hxx +++ b/starmath/inc/format.hxx @@ -98,6 +98,7 @@ class SM_DLLPUBLIC SmFormat final : public SfxBroadcaster SmHorAlign eHorAlign; sal_Int16 nGreekCharStyle; bool bIsTextmode, + bIsRightToLeft, bScaleNormalBrackets; public: @@ -126,6 +127,9 @@ public: bool IsTextmode() const { return bIsTextmode; } void SetTextmode(bool bVal) { bIsTextmode = bVal; } + bool IsRightToLeft() const { return bIsRightToLeft; } + void SetRightToLeft(bool bVal) { bIsRightToLeft = bVal; } + sal_Int16 GetGreekCharStyle() const { return nGreekCharStyle; } void SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; } diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 2146c366cd1e..6e27a0168e8b 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -91,6 +91,7 @@ static Sequence< OUString > lcl_GetFormatPropertyNames() //! see respective load/save routines here return Sequence< OUString > { "StandardFormat/Textmode", + "StandardFormat/RightToLeft", "StandardFormat/GreekCharStyle", "StandardFormat/ScaleNormalBracket", "StandardFormat/HorizontalAlignment", @@ -983,6 +984,10 @@ void SmMathConfig::LoadFormat() if (pVal->hasValue() && (*pVal >>= bTmp)) pFormat->SetTextmode( bTmp ); ++pVal; + // StandardFormat/RightToLeft + if (pVal->hasValue() && (*pVal >>= bTmp)) + pFormat->SetRightToLeft( bTmp ); + ++pVal; // StandardFormat/GreekCharStyle if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetGreekCharStyle( nTmp16 ); @@ -1061,6 +1066,8 @@ void SmMathConfig::SaveFormat() // StandardFormat/Textmode *pValue++ <<= pFormat->IsTextmode(); + // StandardFormat/RightToLeft + *pValue++ <<= pFormat->IsRightToLeft(); // StandardFormat/GreekCharStyle *pValue++ <<= pFormat->GetGreekCharStyle(); // StandardFormat/ScaleNormalBracket diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 5c09cf40d3c0..c0f28ac18190 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -1219,4 +1219,22 @@ bool SmDocShell::WriteAsMathType3( SfxMedium& rMedium ) return aEquation.ConvertFromStarMath( rMedium ); } +void SmDocShell::SetRightToLeft(bool bRTL) +{ + SmFormat aOldFormat = GetFormat(); + if (aOldFormat.IsRightToLeft() == bRTL) + return; + + SmFormat aNewFormat(aOldFormat); + aNewFormat.SetRightToLeft(bRTL); + + SfxUndoManager* pTmpUndoMgr = GetUndoManager(); + if (pTmpUndoMgr) + pTmpUndoMgr->AddUndoAction( + std::make_unique<SmFormatAction>(this, aOldFormat, aNewFormat)); + + SetFormat(aNewFormat); + Repaint(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx index 0ae4c344289f..9440ffb6b1d6 100644 --- a/starmath/source/format.cxx +++ b/starmath/source/format.cxx @@ -25,7 +25,7 @@ SmFormat::SmFormat() { eHorAlign = SmHorAlign::Center; nGreekCharStyle = 0; - bIsTextmode = bScaleNormalBrackets = false; + bIsTextmode = bIsRightToLeft = bScaleNormalBrackets = false; vSize[SIZ_TEXT] = 100; vSize[SIZ_INDEX] = 60; @@ -102,6 +102,7 @@ SmFormat & SmFormat::operator = (const SmFormat &rFormat) SetBaseSize(rFormat.GetBaseSize()); SetHorAlign(rFormat.GetHorAlign()); SetTextmode(rFormat.IsTextmode()); + SetRightToLeft(rFormat.IsRightToLeft()); SetGreekCharStyle(rFormat.GetGreekCharStyle()); SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets()); @@ -126,6 +127,7 @@ bool SmFormat::operator == (const SmFormat &rFormat) const eHorAlign == rFormat.eHorAlign && nGreekCharStyle == rFormat.nGreekCharStyle && bIsTextmode == rFormat.bIsTextmode && + bIsRightToLeft == rFormat.bIsRightToLeft && bScaleNormalBrackets == rFormat.bScaleNormalBrackets; sal_uInt16 i; diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index ed33a16bdbe3..d12b11aafdd5 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -412,13 +412,24 @@ void SmXMLExport::ExportContent_() SmDocShell* pDocShell = pModel ? static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; OSL_ENSURE(pDocShell, "doc shell missing"); - if (pDocShell && !pDocShell->GetFormat().IsTextmode()) + if (pDocShell) { - // If the Math equation is not in text mode, we attach a display="block" - // attribute on the <math> root. We don't do anything if it is in - // text mode, the default display="inline" value will be used. - AddAttribute(XML_NAMESPACE_MATH, XML_DISPLAY, XML_BLOCK); + if (!pDocShell->GetFormat().IsTextmode()) + { + // If the Math equation is not in text mode, we attach a display="block" + // attribute on the <math> root. We don't do anything if it is in + // text mode, the default display="inline" value will be used. + AddAttribute(XML_NAMESPACE_MATH, XML_DISPLAY, XML_BLOCK); + } + if (pDocShell->GetFormat().IsRightToLeft()) + { + // If the Math equation is set right-to-left, we attach a dir="rtl" + // attribute on the <math> root. We don't do anything if it is set + // left-to-right, the default dir="ltr" value will be used. + AddAttribute(XML_NAMESPACE_MATH, XML_DIR, XML_RTL); + } } + SvXMLElementExport aEquation(*this, XML_NAMESPACE_MATH, XML_MATH, true, true); std::unique_ptr<SvXMLElementExport> pSemantics; diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index c3a5bc1ff02d..4e02783b5ebb 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -188,6 +188,7 @@ enum SmModelPropertyHandles HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS, HANDLE_RELATIVE_FONT_HEIGHT_LIMITS, HANDLE_IS_TEXT_MODE, + HANDLE_IS_RIGHT_TO_LEFT, HANDLE_GREEK_CHAR_STYLE, HANDLE_ALIGNMENT, HANDLE_RELATIVE_SPACING, @@ -267,6 +268,7 @@ static const rtl::Reference<PropertySetInfo> & lcl_createModelPropertyInfo () { OUString("Formula") , HANDLE_FORMULA , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, { OUString("IsScaleAllBrackets") , HANDLE_IS_SCALE_ALL_BRACKETS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 }, { OUString("IsTextMode") , HANDLE_IS_TEXT_MODE , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 }, + { OUString("IsRightToLeft") , HANDLE_IS_RIGHT_TO_LEFT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 }, { OUString("GreekCharStyle") , HANDLE_GREEK_CHAR_STYLE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 }, { OUString("LeftMargin") , HANDLE_LEFT_MARGIN , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_LEFTSPACE }, { OUString("PrinterName") , HANDLE_PRINTER_NAME , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, @@ -503,6 +505,10 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* } break; + case HANDLE_IS_RIGHT_TO_LEFT : + aFormat.SetRightToLeft(*o3tl::doAccess<bool>(*pValues)); + break; + case HANDLE_GREEK_CHAR_STYLE : { sal_Int16 nVal = 0; @@ -779,6 +785,10 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu *pValue <<= aFormat.IsTextmode(); break; + case HANDLE_IS_RIGHT_TO_LEFT : + *pValue <<= aFormat.IsRightToLeft(); + break; + case HANDLE_GREEK_CHAR_STYLE : *pValue <<= aFormat.GetGreekCharStyle(); break; |