diff options
author | Khaled Hosny <khaled@libreoffice.org> | 2023-08-24 16:30:43 +0300 |
---|---|---|
committer | خالد حسني <khaled@libreoffice.org> | 2023-08-25 08:56:21 +0200 |
commit | 900ce2fa32ae1726f64fc6959010650e93854ab3 (patch) | |
tree | 968cf349888dda71419b67ae1da701f91d0a2508 /starmath | |
parent | b0652124dc92d5f62cef19f63a98aa8b68f5a850 (diff) |
tdf#101174: Add the ability to change math font in Math
The math font (default is OpenSymbol) can now be changed from the fonts
dialog like other fonts (variables, numbers, etc).
Change-Id: I57f416173abf7bef8bb66b5e5e393dd928e30652
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156053
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/cfgitem.hxx | 2 | ||||
-rw-r--r-- | starmath/inc/dialog.hxx | 1 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 9 | ||||
-rw-r--r-- | starmath/source/unomodel.cxx | 12 | ||||
-rw-r--r-- | starmath/uiconfig/smath/ui/fonttypedialog.ui | 61 |
5 files changed, 73 insertions, 12 deletions
diff --git a/starmath/inc/cfgitem.hxx b/starmath/inc/cfgitem.hxx index 607f92d4e1b0..c81e9d086aed 100644 --- a/starmath/inc/cfgitem.hxx +++ b/starmath/inc/cfgitem.hxx @@ -102,7 +102,7 @@ class SmMathConfig final : public utl::ConfigItem, public SfxBroadcaster std::unique_ptr<SmSymbolManager> pSymbolMgr; bool bIsOtherModified; bool bIsFormatModified; - SmFontPickList vFontPickList[7]; + SmFontPickList vFontPickList[8]; sal_Int32 m_nCommitLock = 0; SmMathConfig(const SmMathConfig&) = delete; diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index a595917d450d..f8fa5a9d66fa 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -131,6 +131,7 @@ class SmFontTypeDialog final : public weld::GenericDialogController { VclPtr<OutputDevice> pFontListDev; + std::unique_ptr<SmFontPickListBox> m_xMathFont; std::unique_ptr<SmFontPickListBox> m_xVariableFont; std::unique_ptr<SmFontPickListBox> m_xFunctionFont; std::unique_ptr<SmFontPickListBox> m_xNumberFont; diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 03bbc60da66a..7d8a837be77f 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -430,7 +430,9 @@ IMPL_LINK(SmFontTypeDialog, MenuSelectHdl, const OUString&, rIdent, void) SmFontPickListBox *pActiveListBox; bool bHideCheckboxes = false; - if (rIdent == "variables") + if (rIdent == "math") + pActiveListBox = m_xMathFont.get(); + else if (rIdent == "variables") pActiveListBox = m_xVariableFont.get(); else if (rIdent == "functions") pActiveListBox = m_xFunctionFont.get(); @@ -481,6 +483,7 @@ IMPL_LINK_NOARG(SmFontTypeDialog, DefaultButtonClickHdl, weld::Button&, void) SmFontTypeDialog::SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice) : GenericDialogController(pParent, "modules/smath/ui/fonttypedialog.ui", "FontsDialog") , pFontListDev(pFntListDevice) + , m_xMathFont(new SmFontPickListBox(m_xBuilder->weld_combo_box("mathCB"))) , m_xVariableFont(new SmFontPickListBox(m_xBuilder->weld_combo_box("variableCB"))) , m_xFunctionFont(new SmFontPickListBox(m_xBuilder->weld_combo_box("functionCB"))) , m_xNumberFont(new SmFontPickListBox(m_xBuilder->weld_combo_box("numberCB"))) @@ -503,6 +506,7 @@ void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat) { SmModule *pp = SM_MOD(); + *m_xMathFont = pp->GetConfig()->GetFontPickList(FNT_MATH); *m_xVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE); *m_xFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION); *m_xNumberFont = pp->GetConfig()->GetFontPickList(FNT_NUMBER); @@ -511,6 +515,7 @@ void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat) *m_xSansFont = pp->GetConfig()->GetFontPickList(FNT_SANS); *m_xFixedFont = pp->GetConfig()->GetFontPickList(FNT_FIXED); + m_xMathFont->Insert( rFormat.GetFont(FNT_MATH) ); m_xVariableFont->Insert( rFormat.GetFont(FNT_VARIABLE) ); m_xFunctionFont->Insert( rFormat.GetFont(FNT_FUNCTION) ); m_xNumberFont->Insert( rFormat.GetFont(FNT_NUMBER) ); @@ -525,6 +530,7 @@ void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const { SmModule *pp = SM_MOD(); + pp->GetConfig()->GetFontPickList(FNT_MATH) = *m_xMathFont; pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = *m_xVariableFont; pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = *m_xFunctionFont; pp->GetConfig()->GetFontPickList(FNT_NUMBER) = *m_xNumberFont; @@ -533,6 +539,7 @@ void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const pp->GetConfig()->GetFontPickList(FNT_SANS) = *m_xSansFont; pp->GetConfig()->GetFontPickList(FNT_FIXED) = *m_xFixedFont; + rFormat.SetFont( FNT_MATH, m_xMathFont->Get() ); rFormat.SetFont( FNT_VARIABLE, m_xVariableFont->Get() ); rFormat.SetFont( FNT_FUNCTION, m_xFunctionFont->Get() ); rFormat.SetFont( FNT_NUMBER, m_xNumberFont->Get() ); diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index f2f8abfb50e2..5857c3832579 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -157,6 +157,7 @@ namespace { enum SmModelPropertyHandles { HANDLE_FORMULA, + HANDLE_FONT_NAME_MATH, HANDLE_FONT_NAME_VARIABLES, HANDLE_FONT_NAME_FUNCTIONS, HANDLE_FONT_NAME_NUMBERS, @@ -170,6 +171,8 @@ enum SmModelPropertyHandles HANDLE_CUSTOM_FONT_SANS_WEIGHT, HANDLE_CUSTOM_FONT_SERIF_POSTURE, HANDLE_CUSTOM_FONT_SERIF_WEIGHT, + HANDLE_FONT_MATH_POSTURE, + HANDLE_FONT_MATH_WEIGHT, HANDLE_FONT_VARIABLES_POSTURE, HANDLE_FONT_VARIABLES_WEIGHT, HANDLE_FONT_FUNCTIONS_POSTURE, @@ -244,7 +247,10 @@ static const rtl::Reference<PropertySetInfo> & lcl_createModelPropertyInfo () { OUString("FontFixedIsItalic") , HANDLE_CUSTOM_FONT_FIXED_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FIXED }, { OUString("FontFunctionsIsBold") , HANDLE_FONT_FUNCTIONS_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FUNCTION }, { OUString("FontFunctionsIsItalic") , HANDLE_FONT_FUNCTIONS_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FUNCTION }, + { OUString("FontMathIsBold") , HANDLE_FONT_MATH_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_MATH }, + { OUString("FontMathIsItalic") , HANDLE_FONT_MATH_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_MATH }, { OUString("FontNameFunctions") , HANDLE_FONT_NAME_FUNCTIONS , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_FUNCTION }, + { OUString("FontNameMath") , HANDLE_FONT_NAME_MATH , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_MATH }, { OUString("FontNameNumbers") , HANDLE_FONT_NAME_NUMBERS , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_NUMBER }, { OUString("FontNameText") , HANDLE_FONT_NAME_TEXT , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_TEXT }, { OUString("FontNameVariables") , HANDLE_FONT_NAME_VARIABLES , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_VARIABLE }, @@ -415,6 +421,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* pDocSh->SetText(aText); } break; + case HANDLE_FONT_NAME_MATH : case HANDLE_FONT_NAME_VARIABLES : case HANDLE_FONT_NAME_FUNCTIONS : case HANDLE_FONT_NAME_NUMBERS : @@ -442,6 +449,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* case HANDLE_CUSTOM_FONT_FIXED_POSTURE: case HANDLE_CUSTOM_FONT_SANS_POSTURE : case HANDLE_CUSTOM_FONT_SERIF_POSTURE: + case HANDLE_FONT_MATH_POSTURE : case HANDLE_FONT_VARIABLES_POSTURE : case HANDLE_FONT_FUNCTIONS_POSTURE : case HANDLE_FONT_NUMBERS_POSTURE : @@ -458,6 +466,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* case HANDLE_CUSTOM_FONT_FIXED_WEIGHT : case HANDLE_CUSTOM_FONT_SANS_WEIGHT : case HANDLE_CUSTOM_FONT_SERIF_WEIGHT : + case HANDLE_FONT_MATH_WEIGHT : case HANDLE_FONT_VARIABLES_WEIGHT : case HANDLE_FONT_FUNCTIONS_WEIGHT : case HANDLE_FONT_NUMBERS_WEIGHT : @@ -688,6 +697,7 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu case HANDLE_FORMULA: *pValue <<= pDocSh->GetText(); break; + case HANDLE_FONT_NAME_MATH : case HANDLE_FONT_NAME_VARIABLES : case HANDLE_FONT_NAME_FUNCTIONS : case HANDLE_FONT_NAME_NUMBERS : @@ -703,6 +713,7 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu case HANDLE_CUSTOM_FONT_FIXED_POSTURE: case HANDLE_CUSTOM_FONT_SANS_POSTURE : case HANDLE_CUSTOM_FONT_SERIF_POSTURE: + case HANDLE_FONT_MATH_POSTURE : case HANDLE_FONT_VARIABLES_POSTURE : case HANDLE_FONT_FUNCTIONS_POSTURE : case HANDLE_FONT_NUMBERS_POSTURE : @@ -715,6 +726,7 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu case HANDLE_CUSTOM_FONT_FIXED_WEIGHT : case HANDLE_CUSTOM_FONT_SANS_WEIGHT : case HANDLE_CUSTOM_FONT_SERIF_WEIGHT : + case HANDLE_FONT_MATH_WEIGHT : case HANDLE_FONT_VARIABLES_WEIGHT : case HANDLE_FONT_FUNCTIONS_WEIGHT : case HANDLE_FONT_NUMBERS_WEIGHT : diff --git a/starmath/uiconfig/smath/ui/fonttypedialog.ui b/starmath/uiconfig/smath/ui/fonttypedialog.ui index e79ee4bf366a..7825c9290607 100644 --- a/starmath/uiconfig/smath/ui/fonttypedialog.ui +++ b/starmath/uiconfig/smath/ui/fonttypedialog.ui @@ -1,11 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> +<!-- Generated with glade 3.40.0 --> <interface domain="sm"> <requires lib="gtk+" version="3.20"/> <object class="GtkMenu" id="menu1"> <property name="visible">True</property> <property name="can-focus">False</property> <child> + <object class="GtkMenuItem" id="math"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="fonttypedialog|menuitem0">_Math</property> + <property name="use-underline">True</property> + </object> + </child> + <child> <object class="GtkMenuItem" id="variables"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -192,7 +200,7 @@ <property name="label-xalign">0</property> <property name="shadow-type">none</property> <child> - <!-- n-columns=2 n-rows=4 --> + <!-- n-columns=2 n-rows=5 --> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -201,6 +209,23 @@ <property name="row-spacing">6</property> <property name="column-spacing">12</property> <child> + <object class="GtkLabel" id="label0"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="fonttypedialog|label1">_Math:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">mathCB</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="normal"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -214,7 +239,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">0</property> + <property name="top-attach">1</property> </packing> </child> <child> @@ -231,7 +256,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">1</property> + <property name="top-attach">2</property> </packing> </child> <child> @@ -248,7 +273,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">2</property> + <property name="top-attach">3</property> </packing> </child> <child> @@ -265,7 +290,23 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">3</property> + <property name="top-attach">4</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="mathCB"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="mathCB-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="fonttypedialog|extended_tip|mathCB">You can select the font for the math symbols in your formula.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> </packing> </child> <child> @@ -281,7 +322,7 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">0</property> + <property name="top-attach">1</property> </packing> </child> <child> @@ -297,7 +338,7 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">1</property> + <property name="top-attach">2</property> </packing> </child> <child> @@ -313,7 +354,7 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">2</property> + <property name="top-attach">3</property> </packing> </child> <child> @@ -329,7 +370,7 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">3</property> + <property name="top-attach">4</property> </packing> </child> </object> |