30#include <osl/diagnose.h>
33#include <com/sun/star/beans/PropertyValue.hpp>
37#include <starmath.hrc>
73 "Misc/AutoCloseBrackets",
74 "Misc/DefaultSmSyntaxVersion",
75 "Misc/IgnoreSpacesRight",
76 "Misc/SmEditWindowZoomFactor",
84 "View/ToolboxVisible" };
92 "StandardFormat/Textmode",
93 "StandardFormat/GreekCharStyle",
94 "StandardFormat/ScaleNormalBracket",
95 "StandardFormat/HorizontalAlignment",
96 "StandardFormat/BaseSize",
97 "StandardFormat/TextSize",
98 "StandardFormat/IndexSize",
99 "StandardFormat/FunctionSize",
100 "StandardFormat/OperatorSize",
101 "StandardFormat/LimitsSize",
102 "StandardFormat/Distance/Horizontal",
103 "StandardFormat/Distance/Vertical",
104 "StandardFormat/Distance/Root",
105 "StandardFormat/Distance/SuperScript",
106 "StandardFormat/Distance/SubScript",
107 "StandardFormat/Distance/Numerator",
108 "StandardFormat/Distance/Denominator",
109 "StandardFormat/Distance/Fraction",
110 "StandardFormat/Distance/StrokeWidth",
111 "StandardFormat/Distance/UpperLimit",
112 "StandardFormat/Distance/LowerLimit",
113 "StandardFormat/Distance/BracketSize",
114 "StandardFormat/Distance/BracketSpace",
115 "StandardFormat/Distance/MatrixRow",
116 "StandardFormat/Distance/MatrixColumn",
117 "StandardFormat/Distance/OrnamentSize",
118 "StandardFormat/Distance/OrnamentSpace",
119 "StandardFormat/Distance/OperatorSize",
120 "StandardFormat/Distance/OperatorSpace",
121 "StandardFormat/Distance/LeftSpace",
122 "StandardFormat/Distance/RightSpace",
123 "StandardFormat/Distance/TopSpace",
124 "StandardFormat/Distance/BottomSpace",
125 "StandardFormat/Distance/NormalBracketSize",
126 "StandardFormat/VariableFont",
127 "StandardFormat/FunctionFont",
128 "StandardFormat/NumberFont",
129 "StandardFormat/TextFont",
130 "StandardFormat/SerifFont",
131 "StandardFormat/SansFont",
132 "StandardFormat/FixedFont"
159 , nPrintZoomFactor(100)
160 , nSmEditWindowZoomFactor(100)
164 , bPrintFormulaText(true)
166 , bIsSaveOnlyUsedSymbols(true)
167 , bIsAutoCloseBrackets(true)
168 , bIgnoreSpacesRight(true)
169 , bToolboxVisible(true)
171 , bFormulaCursor(true)
178 , nCharSet(RTL_TEXTENCODING_UNICODE)
188 :
aName(rFont.GetFamilyName())
189 , nCharSet(static_cast<sal_Int16>(rFont.GetCharSet()))
190 , nFamily(static_cast<sal_Int16>(rFont.GetFamilyType()))
191 , nPitch(static_cast<sal_Int16>(rFont.GetPitch()))
192 , nWeight(static_cast<sal_Int16>(rFont.GetWeight()))
193 , nItalic(static_cast<sal_Int16>(rFont.GetItalic()))
223 aId (
std::move(_aId)),
224 aFntFmt (
std::move(_aFntFmt))
249 OSL_ENSURE( !pFntFmt,
"FontFormatId already exists" );
280 for (
const auto & rEntry :
aEntries)
282 if (rEntry.aId == rFntFmtId)
284 pRes = &rEntry.aFntFmt;
306 for (
const auto & rEntry :
aEntries)
308 if (rEntry.aFntFmt == rFntFmt)
322 if (aRes.isEmpty() && bAdd)
345 for (sal_Int32
i = 1;
i <= nCnt + 1; ++
i)
347 OUString aTmpId =
"Id" + OUString::number(
i);
351 OSL_ENSURE(
false,
"failed to create new FontFormatId" );
358 ConfigItem(
"Office.Math")
359 , bIsOtherModified(false)
360 , bIsFormatModified(false)
385 const OUString &rSymbolName,
386 std::u16string_view rBaseNode )
const
389 sal_Int32 nProps = aNames.getLength();
391 OUString aDelim(
"/" );
392 for (
auto& rName : asNonConstRange(aNames))
393 rName = rBaseNode + aDelim + rSymbolName + aDelim + rName;
397 if (!(nProps && aValues.getLength() == nProps))
400 const Any * pValue = aValues.getConstArray();
404 bool bPredefined =
false;
407 sal_Int32 nTmp32 = 0;
411 if (pValue->hasValue() && (*pValue >>= nTmp32))
412 cChar =
static_cast< sal_UCS4 >( nTmp32 );
416 if (pValue->hasValue() && (*pValue >>= aTmpStr))
421 if (pValue->hasValue() && (*pValue >>= bTmp))
426 if (pValue->hasValue() && (*pValue >>= aTmpStr))
429 OSL_ENSURE( pFntFmt,
"unknown FontFormat" );
439 OUString aUiName( rSymbolName );
440 OUString aUiSetName( aSet );
445 OSL_ENSURE( !aTmp.isEmpty(),
"localized symbol-name not found" );
449 OSL_ENSURE( !aTmp.isEmpty(),
"localized symbolset-name not found" );
454 rSymbol =
SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined );
455 if (aUiName != rSymbolName)
460 SAL_WARN(
"starmath",
"symbol read error");
509 const OUString *pNode = aNodes.getConstArray();
510 sal_Int32 nNodes = aNodes.getLength();
512 rSymbols.resize( nNodes );
513 for (
auto& rSymbol : rSymbols)
523 auto nCount = sal::static_int_cast<sal_Int32>(rNewSymbols.size());
526 const OUString *pNames = aNames.getConstArray();
527 sal_Int32 nSymbolProps = aNames.getLength();
530 PropertyValue *
pValues = aValues.getArray();
533 OUString aDelim(
"/" );
534 for (
const SmSym& rSymbol : rNewSymbols)
538 rSymbol.GetExportName() +
541 const OUString *
pName = pNames;
544 pVal->Name = aNodeNameDelim;
545 pVal->Name += *
pName++;
546 pVal->Value <<= rSymbol.GetCharacter();
549 pVal->Name = aNodeNameDelim;
550 pVal->Name += *
pName++;
551 OUString aTmp( rSymbol.GetSymbolSetName() );
552 if (rSymbol.IsPredefined())
554 pVal->Value <<= aTmp;
557 pVal->Name = aNodeNameDelim;
558 pVal->Name += *
pName++;
559 pVal->Value <<= rSymbol.IsPredefined();
564 OSL_ENSURE( !aFntFmtId.isEmpty(),
"FontFormatId not found" );
565 pVal->Name = aNodeNameDelim;
566 pVal->Name += *
pName++;
567 pVal->Value <<= aFntFmtId;
570 OSL_ENSURE( pVal -
pValues == sal::static_int_cast< ptrdiff_t >(
nCount * nSymbolProps),
"properties missing" );
596 for (
const OUString& rNode : aNodes)
608 std::u16string_view rSymbolName, std::u16string_view rBaseNode )
const
611 sal_Int32 nProps = aNames.getLength();
613 OUString aDelim(
"/" );
614 for (
auto& rName : asNonConstRange(aNames))
615 rName = rBaseNode + aDelim + rSymbolName + aDelim + rName;
619 if (!(nProps && aValues.getLength() == nProps))
622 const Any * pValue = aValues.getConstArray();
625 sal_Int16 nTmp16 = 0;
628 if (pValue->hasValue() && (*pValue >>= aTmpStr))
629 rFontFormat.
aName = aTmpStr;
633 if (pValue->hasValue() && (*pValue >>= nTmp16))
638 if (pValue->hasValue() && (*pValue >>= nTmp16))
643 if (pValue->hasValue() && (*pValue >>= nTmp16))
644 rFontFormat.
nPitch = nTmp16;
648 if (pValue->hasValue() && (*pValue >>= nTmp16))
653 if (pValue->hasValue() && (*pValue >>= nTmp16))
659 OSL_ENSURE( bOK,
"read FontFormat failed" );
671 sal_Int32 nSymbolProps = aNames.getLength();
676 PropertyValue *
pValues = aValues.getArray();
679 OUString aDelim(
"/" );
692 const OUString *
pName = aNames.getConstArray();
695 pVal->Name = aNodeNameDelim;
696 pVal->Name += *
pName++;
697 pVal->Value <<= aFntFmt.
aName;
700 pVal->Name = aNodeNameDelim;
701 pVal->Name += *
pName++;
705 pVal->Name = aNodeNameDelim;
706 pVal->Name += *
pName++;
707 pVal->Value <<= aFntFmt.
nFamily;
710 pVal->Name = aNodeNameDelim;
711 pVal->Name += *
pName++;
712 pVal->Value <<= aFntFmt.
nPitch;
715 pVal->Name = aNodeNameDelim;
716 pVal->Name += *
pName++;
717 pVal->Value <<= aFntFmt.
nWeight;
720 pVal->Name = aNodeNameDelim;
721 pVal->Name += *
pName++;
722 pVal->Value <<= aFntFmt.
nItalic;
725 OSL_ENSURE( sal::static_int_cast<size_t>(pVal -
pValues) ==
nCount * nSymbolProps,
"properties missing" );
739 for (
i = 0;
i < rSymbols.size(); ++
i)
752 size_t nCnt = rFntFmtList.
GetCount();
753 std::unique_ptr<SmFontFormat[]> pTmpFormat(
new SmFontFormat[ nCnt ]);
754 std::unique_ptr<OUString[]> pId(
new OUString[ nCnt ]);
756 for (k = 0; k < nCnt; ++k)
761 for (k = 0; k < nCnt; ++k)
778 if (aNames.getLength() != aValues.getLength())
785 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
786 pOther->bIsSaveOnlyUsedSymbols = bTmp;
789 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
790 pOther->bIsAutoCloseBrackets = bTmp;
793 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
794 pOther->nSmSyntaxVersion = nTmp;
797 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
798 pOther->bIgnoreSpacesRight = bTmp;
801 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
802 pOther->nSmEditWindowZoomFactor = nTmp;
805 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
806 pOther->bPrintFormulaText = bTmp;
809 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
810 pOther->bPrintFrame = bTmp;
813 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
817 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
818 pOther->bPrintTitle = bTmp;
821 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
822 pOther->nPrintZoomFactor = nTmp;
825 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
826 pOther->bAutoRedraw = bTmp;
829 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
830 pOther->bFormulaCursor = bTmp;
833 if (
bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
834 pOther->bToolboxVisible = bTmp;
837 OSL_ENSURE(pVal -
pValues == aNames.getLength(),
"property mismatch");
854 *pVal++ <<=
pOther->bIsSaveOnlyUsedSymbols;
856 *pVal++ <<=
pOther->bIsAutoCloseBrackets;
858 *pVal++ <<=
pOther->nSmSyntaxVersion;
860 *pVal++ <<=
pOther->bIgnoreSpacesRight;
862 *pVal++ <<=
pOther->nSmEditWindowZoomFactor;
864 *pVal++ <<=
pOther->bPrintFormulaText;
866 *pVal++ <<=
pOther->bPrintFrame;
868 *pVal++ <<=
static_cast<sal_Int16
>(
pOther->ePrintSize);
870 *pVal++ <<=
pOther->bPrintTitle;
872 *pVal++ <<=
pOther->nPrintZoomFactor;
874 *pVal++ <<=
pOther->bAutoRedraw;
876 *pVal++ <<=
pOther->bFormulaCursor;
878 *pVal++ <<=
pOther->bToolboxVisible;
880 OSL_ENSURE(pVal -
pValues == aNames.getLength(),
"property mismatch");
891 DefaultFontType::SERIF,
892 DefaultFontType::SERIF,
893 DefaultFontType::SERIF,
894 DefaultFontType::SERIF,
895 DefaultFontType::SERIF,
896 DefaultFontType::SANS,
897 DefaultFontType::FIXED
907 DefaultFontType::SERIF,
908 DefaultFontType::SERIF,
909 DefaultFontType::SERIF,
910 DefaultFontType::CJK_TEXT,
911 DefaultFontType::CJK_TEXT,
912 DefaultFontType::CJK_DISPLAY,
913 DefaultFontType::CJK_TEXT
920 DefaultFontType::CTL_TEXT,
921 DefaultFontType::CTL_TEXT,
922 DefaultFontType::CTL_TEXT,
923 DefaultFontType::CTL_TEXT,
924 DefaultFontType::CTL_TEXT,
925 DefaultFontType::CTL_TEXT,
926 DefaultFontType::CTL_TEXT
931OUString lcl_GetDefaultFontName(
LanguageType nLang, sal_uInt16 nIdent )
937 case SvtScriptType::LATIN : pTable = aLatinDefFnts;
break;
938 case SvtScriptType::ASIAN : pTable = aCJKDefFnts;
break;
939 case SvtScriptType::COMPLEX : pTable = aCTLDefFnts;
break;
941 pTable = aLatinDefFnts;
942 SAL_WARN(
"starmath",
"unknown script-type");
960 sal_Int32 nProps = aNames.getLength();
963 if (!(nProps && aValues.getLength() == nProps))
970 sal_Int16 nTmp16 = 0;
974 if (pVal->hasValue() && (*pVal >>= bTmp))
978 if (pVal->hasValue() && (*pVal >>= nTmp16))
979 pFormat->SetGreekCharStyle( nTmp16 );
982 if (pVal->hasValue() && (*pVal >>= bTmp))
983 pFormat->SetScaleNormalBrackets( bTmp );
986 if (pVal->hasValue() && (*pVal >>= nTmp16))
990 if (pVal->hasValue() && (*pVal >>= nTmp16))
997 if (pVal->hasValue() && (*pVal >>= nTmp16))
1004 if (pVal->hasValue() && (*pVal >>= nTmp16))
1013 bool bUseDefaultFont =
true;
1014 if (pVal->hasValue() && (*pVal >>= aTmpStr))
1016 bUseDefaultFont = aTmpStr.isEmpty();
1017 if (bUseDefaultFont)
1025 OSL_ENSURE( pFntFmt,
"unknown FontFormat" );
1033 pFormat->SetFont(
i, aFnt, bUseDefaultFont );
1036 OSL_ENSURE( pVal -
pValues == nProps,
"property mismatch" );
1047 sal_Int32 nProps = aNames.getLength();
1054 *pValue++ <<=
pFormat->IsTextmode();
1056 *pValue++ <<=
pFormat->GetGreekCharStyle();
1058 *pValue++ <<=
pFormat->IsScaleNormalBrackets();
1060 *pValue++ <<=
static_cast<sal_Int16
>(
pFormat->GetHorAlign());
1062 *pValue++ <<=
static_cast<sal_Int16
>(
1067 *pValue++ <<=
static_cast<sal_Int16
>(
pFormat->GetRelSize(
i ));
1070 *pValue++ <<=
static_cast<sal_Int16
>(
pFormat->GetDistance(
i ));
1080 OSL_ENSURE( !aFntFmtId.isEmpty(),
"FontFormatId not found" );
1083 *pValue++ <<= aFntFmtId;
1086 OSL_ENSURE( pValue -
pValues == nProps,
"property mismatch" );
1112 if (bSaveFontFormatList)
1125 return pOther->ePrintSize;
1133 if (eSize !=
pOther->ePrintSize)
1136 pOther->ePrintSize = eSize;
1146 return pOther->nPrintZoomFactor;
1154 if (nVal !=
pOther->nPrintZoomFactor)
1157 pOther->nPrintZoomFactor = nVal;
1165 sal_uInt16 smzoomfactor;
1168 smzoomfactor =
pOther->nSmEditWindowZoomFactor;
1169 return smzoomfactor < 10 || smzoomfactor > 1000 ? 100 : smzoomfactor;
1177 if (nVal !=
pOther->nSmEditWindowZoomFactor)
1180 pOther->nSmEditWindowZoomFactor = nVal;
1188 if (bNewVal != rbItem)
1203 return pOther->bPrintTitle;
1219 return pOther->bPrintFormulaText;
1234 return pOther->bIsSaveOnlyUsedSymbols;
1241 return pOther->bIsAutoCloseBrackets;
1250 return pOther->nSmSyntaxVersion;
1257 return pOther->bPrintFrame;
1288 if (nVal !=
pOther->nSmSyntaxVersion)
1291 pOther->nSmSyntaxVersion = nVal;
1302 return pOther->bIgnoreSpacesRight;
1323 return pOther->bAutoRedraw;
1339 return pOther->bFormulaCursor;
1353 if (std::find(rNames.begin(), rNames.end(),
"Misc/IgnoreSpacesRight") != rNames.end())
1365 { nU16 = pPrintSizeItem->GetValue();
1369 { nU16 = pPrintZoomItem->GetValue();
1373 { nU16 = pPrintZoomItem->GetValue();
1377 { bVal = pPrintTitleItem->GetValue();
1381 { bVal = pPrintTextItem->GetValue();
1385 { bVal = pPrintZoomItem->GetValue();
1389 { bVal = pRedrawItem->GetValue();
1393 { bVal = pSpacesItem->GetValue();
1397 { bVal = pSymbolsItem->GetValue();
1403 bVal = pBracketsItem->GetValue();
1409 nU16 = pSyntaxItem->GetValue();
const PropertyValue * pValues
constexpr OUStringLiteral FONT_FORMAT_LIST
static Sequence< OUString > lcl_GetFontPropertyNames()
static Sequence< OUString > lcl_GetSymbolPropertyNames()
static Sequence< OUString > lcl_GetOtherPropertyNames()
static Sequence< OUString > lcl_GetFormatPropertyNames()
constexpr OUStringLiteral SYMBOL_LIST
constexpr sal_uInt16 nDefaultSmSyntaxVersion(5)
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
LanguageType getLanguageType(bool bResolveSystem=true) const
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
void Broadcast(const SfxHint &rHint)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void StripFontFormatList(const std::vector< SmSym > &rSymbols)
void SetSaveOnlyUsedSymbols(bool bVal)
bool SetOtherIfNotEqual(bool &rbItem, bool bNewVal)
void ReadFontFormat(SmFontFormat &rFontFormat, std::u16string_view rSymbolName, std::u16string_view rBaseNode) const
bool IsPrintFrame() const
void SetDefaultSmSyntaxVersion(sal_uInt16 nVal)
void SetSymbols(const std::vector< SmSym > &rNewSymbols)
SmFontFormatList & GetFontFormatList()
void ItemSetToConfig(const SfxItemSet &rSet)
sal_uInt16 GetSmEditWindowZoomFactor() const
void SetFormatModified(bool bVal)
std::unique_ptr< SmCfgOther > pOther
void ConfigToItemSet(SfxItemSet &rSet) const
const SmFormat & GetStandardFormat() const
bool IsFormatModified() const
bool IsPrintTitle() const
bool IsAutoCloseBrackets() const
virtual void Notify(const css::uno::Sequence< OUString > &rPropertyNames) override
void GetSymbols(std::vector< SmSym > &rSymbols) const
bool IsAutoRedraw() const
bool IsIgnoreSpacesRight() const
void SetAutoRedraw(bool bVal)
void LoadFontFormatList()
virtual void ImplCommit() override
bool IsShowFormulaCursor() const
void SetAutoCloseBrackets(bool bVal)
sal_uInt16 GetPrintZoomFactor() const
void SetPrintFormulaText(bool bVal)
void SetOtherModified(bool bVal)
void SetPrintSize(SmPrintSize eSize)
void ReadSymbol(SmSym &rSymbol, const OUString &rSymbolName, std::u16string_view rBaseNode) const
bool IsPrintFormulaText() const
SmPrintSize GetPrintSize() const
void SetIgnoreSpacesRight(bool bVal)
std::unique_ptr< SmFormat > pFormat
bool IsOtherModified() const
std::unique_ptr< SmFontFormatList > pFontFormatList
std::unique_ptr< SmSymbolManager > pSymbolMgr
SmSymbolManager & GetSymbolManager()
void SetShowFormulaCursor(bool bVal)
void SetPrintFrame(bool bVal)
void SetStandardFormat(const SmFormat &rFormat, bool bSaveFontFormatList=false)
void SetPrintTitle(bool bVal)
bool IsSaveOnlyUsedSymbols() const
void SetPrintZoomFactor(sal_uInt16 nVal)
void SaveFontFormatList()
virtual ~SmMathConfig() override
void SetSmEditWindowZoomFactor(sal_uInt16 nVal)
sal_uInt16 GetDefaultSmSyntaxVersion() const
void SetExportName(const OUString &rName)
static bool PutProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues, bool bAllLocales)
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
static bool ReplaceSetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, const css::uno::Sequence< css::beans::PropertyValue > &rValues, bool bAllLocales)
static css::uno::Sequence< OUString > GetNodeNames(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, ConfigNameFormat eFormat)
void SetFontSize(const Size &)
void SetPitch(FontPitch ePitch)
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
void SetFamily(FontFamily)
void SetCharSet(rtl_TextEncoding)
void SetFamilyName(const OUString &rFamilyName)
virtual OUString GetName() const override
#define SAL_WARN(area, stream)
OUString GetExportSymbolSetName(std::u16string_view rUiName)
OUString GetUiSymbolName(std::u16string_view rExportName)
OUString GetUiSymbolSetName(std::u16string_view rExportName)
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
double getLength(const B2DPolygon &rCandidate)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
bool bIsAutoCloseBrackets
sal_uInt16 nSmEditWindowZoomFactor
sal_uInt16 nPrintZoomFactor
sal_uInt16 nSmSyntaxVersion
bool bIsSaveOnlyUsedSymbols
SmFntFmtListEntry(OUString aId, SmFontFormat rFntFmt)
constexpr OUStringLiteral FONTNAME_MATH
o3tl::Length SmO3tlLengthUnit()