diff options
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Math.xcs | 18 | ||||
-rw-r--r-- | starmath/Library_sm.mk | 1 | ||||
-rw-r--r-- | starmath/inc/cfgitem.hxx | 2 | ||||
-rw-r--r-- | starmath/inc/document.hxx | 5 | ||||
-rw-r--r-- | starmath/inc/smediteng.hxx | 60 | ||||
-rw-r--r-- | starmath/inc/starmath.hrc | 1 | ||||
-rw-r--r-- | starmath/source/cfgitem.cxx | 33 | ||||
-rw-r--r-- | starmath/source/document.cxx | 84 | ||||
-rw-r--r-- | starmath/source/edit.cxx | 14 | ||||
-rw-r--r-- | starmath/source/smediteng.cxx | 155 |
10 files changed, 291 insertions, 82 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Math.xcs b/officecfg/registry/schema/org/openoffice/Office/Math.xcs index ec19a94ec591..c94616300276 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Math.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Math.xcs @@ -309,6 +309,24 @@ </info> <value>true</value> </prop> + <prop oor:name="SmEditWindowZoomFactor" oor:type="xs:short" oor:nillable="false"> + <info> + <desc>Specifies the zoom factor for SmEditWindow. [UNIT=%]</desc> + </info> + <constraints> + <minInclusive oor:value="10"> + <info> + <desc>Specifies the minimum value allowed</desc> + </info> + </minInclusive> + <maxInclusive oor:value="1000"> + <info> + <desc>Specifies the maximum value allowed.</desc> + </info> + </maxInclusive> + </constraints> + <value>100</value> + </prop> <prop oor:name="DefaultSmSyntaxVersion" oor:type="xs:short" oor:nillable="false"> <info> <desc>Specifies which SmParser to use</desc> diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index d5d3657f2120..297cca650684 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -75,6 +75,7 @@ $(eval $(call gb_Library_add_exception_objects,sm,\ starmath/source/dialog \ starmath/source/document \ starmath/source/edit \ + starmath/source/smediteng \ starmath/source/format \ starmath/source/mathtype \ starmath/source/node \ diff --git a/starmath/inc/cfgitem.hxx b/starmath/inc/cfgitem.hxx index 9e1438b68c38..6342d740c35c 100644 --- a/starmath/inc/cfgitem.hxx +++ b/starmath/inc/cfgitem.hxx @@ -162,6 +162,8 @@ public: void SetPrintSize(SmPrintSize eSize); sal_uInt16 GetPrintZoomFactor() const; void SetPrintZoomFactor(sal_uInt16 nVal); + sal_uInt16 GetSmEditWindowZoomFactor() const; + void SetSmEditWindowZoomFactor(sal_uInt16 nVal); bool IsSaveOnlyUsedSymbols() const; void SetSaveOnlyUsedSymbols(bool bVal); diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 2c3a9183bf87..588a8d93f1b0 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -58,6 +58,7 @@ namespace oox::formulaimport { class XmlStream; } class SmDocShell; class EditEngine; +class SmEditEngine; class SmPrinterAccess { @@ -82,7 +83,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener SvtLinguOptions maLinguOptions; std::unique_ptr<SmTableNode> mpTree; rtl::Reference<SfxItemPool> mpEditEngineItemPool; - std::unique_ptr<EditEngine> mpEditEngine; + std::unique_ptr<SmEditEngine> mpEditEngine; VclPtr<SfxPrinter> mpPrinter; //q.v. comment to SmPrinter Access! VclPtr<Printer> mpTmpPrinter; //ditto sal_uInt16 mnModifyCount; @@ -210,7 +211,7 @@ public: void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding); void readFormulaOoxml( oox::formulaimport::XmlStream& stream ); - void UpdateEditEngineDefaultFonts(const Color& aTextColor); + void UpdateEditEngineDefaultFonts(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/smediteng.hxx b/starmath/inc/smediteng.hxx new file mode 100644 index 000000000000..c3d3d576467e --- /dev/null +++ b/starmath/inc/smediteng.hxx @@ -0,0 +1,60 @@ +/* This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <editeng/editeng.hxx> +#include <editeng/fontitem.hxx> +#include <unotools/lingucfg.hxx> + +class SmEditEngine : public EditEngine +{ +public: + SmEditEngine(SfxItemPool* pItemPool); + SmEditEngine(const SmEditEngine&) = delete; + +public: + /** + * Runs checkZoom and if true runs updateZoom + */ + void executeZoom(EditView* pEditView = nullptr); + + /** + * Sets up default font parameters for the item pool. + */ + static void setSmItemPool(SfxItemPool* mpItemPool, const SvtLinguOptions& maLangOptions); + + // Deal with text scaling +private: + sal_Int32 m_nOldZoom; + sal_Int32 m_nNewZoom; + sal_Int32 m_nDefaultFontSize; + + /** + * Checks if the zoom of smeditwindow has changed. + * m_nNewZoom is updated. + * @return zoom has changed + */ + bool checkZoom(); + + /** + * Updates the zoom of smeditwindow. + * m_nOldZoom is set to m_nNewZoom. + */ + + void updateZoom(); + + // Gather information for more complex tasks +private: + ESelection m_aAllSelection; + + /** + * Finds the ESelection wich contains all the text. + */ + void updateAllESelection(); +}; +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index 5001b29b0f51..c566783156ca 100644 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -67,6 +67,7 @@ #define SID_SAVE_ONLY_USED_SYMBOLS (SID_SMA_START + 125) #define SID_ELEMENTSDOCKINGWINDOW (SID_SMA_START + 126) #define SID_AUTO_CLOSE_BRACKETS (SID_SMA_START + 127) +#define SID_SMEDITWINDOWZOOM (SID_SMA_START + 129) #define SID_DEFAULT_SM_SYNTAX_VERSION (SID_SMA_START + 130) /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index b4c950233ac4..9b86a972a877 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -121,6 +121,7 @@ struct SmCfgOther { SmPrintSize ePrintSize; sal_uInt16 nPrintZoomFactor; + sal_uInt16 nSmEditWindowZoomFactor; sal_uInt16 nSmSyntaxVersion; bool bPrintTitle; bool bPrintFormulaText; @@ -140,6 +141,7 @@ constexpr sal_uInt16 nDefaultSmSyntaxVersion(5); SmCfgOther::SmCfgOther() : ePrintSize(PRINT_SIZE_NORMAL) , nPrintZoomFactor(100) + , nSmEditWindowZoomFactor(100) // Defaulted as 5 so I have time to code the parser 6 , nSmSyntaxVersion(nDefaultSmSyntaxVersion) , bPrintTitle(true) @@ -746,6 +748,8 @@ void SmMathConfig::LoadOther() pOther->bPrintFormulaText = officecfg::Office::Math::Print::FormulaText::get(); pOther->bPrintFrame = officecfg::Office::Math::Print::Frame::get(); pOther->ePrintSize = static_cast<SmPrintSize>(officecfg::Office::Math::Print::Size::get()); + pOther->nSmEditWindowZoomFactor = officecfg::Office::Math::Misc::SmEditWindowZoomFactor::get(); + pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::get(); pOther->nPrintZoomFactor = officecfg::Office::Math::Print::ZoomFactor::get(); pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::get(); pOther->bIsAutoCloseBrackets = officecfg::Office::Math::Misc::AutoCloseBrackets::get(); @@ -770,6 +774,7 @@ void SmMathConfig::SaveOther() officecfg::Office::Math::Print::Frame::set(pOther->bPrintFrame, batch); officecfg::Office::Math::Print::Size::set(pOther->ePrintSize, batch); officecfg::Office::Math::Print::ZoomFactor::set(pOther->nPrintZoomFactor, batch); + officecfg::Office::Math::Misc::SmEditWindowZoomFactor::set(pOther->nSmEditWindowZoomFactor, batch); officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::set(pOther->bIsSaveOnlyUsedSymbols, batch); officecfg::Office::Math::Misc::AutoCloseBrackets::set(pOther->bIsAutoCloseBrackets, batch); officecfg::Office::Math::Misc::DefaultSmSyntaxVersion::set(pOther->nSmSyntaxVersion, batch); @@ -1058,6 +1063,28 @@ void SmMathConfig::SetPrintZoomFactor( sal_uInt16 nVal ) } +sal_uInt16 SmMathConfig::GetSmEditWindowZoomFactor() const +{ + sal_uInt16 smzoomfactor; + if (!pOther) + const_cast<SmMathConfig*>(this)->LoadOther(); + smzoomfactor = pOther->nSmEditWindowZoomFactor; + return smzoomfactor < 10 || smzoomfactor > 1000 ? 100 : smzoomfactor; +} + + +void SmMathConfig::SetSmEditWindowZoomFactor( sal_uInt16 nVal ) +{ + if (!pOther) + LoadOther(); + if (nVal != pOther->nSmEditWindowZoomFactor) + { + pOther->nSmEditWindowZoomFactor = nVal; + SetOtherModified( true ); + } +} + + void SmMathConfig::SetOtherIfNotEqual( bool &rbItem, bool bNewVal ) { if (bNewVal != rbItem) @@ -1231,6 +1258,10 @@ void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet) { nU16 = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); SetPrintZoomFactor( nU16 ); } + if (rSet.GetItemState(SID_SMEDITWINDOWZOOM, true, &pItem) == SfxItemState::SET) + { nU16 = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); + SetSmEditWindowZoomFactor( nU16 ); + } if (rSet.GetItemState(SID_PRINTTITLE, true, &pItem) == SfxItemState::SET) { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue(); SetPrintTitle( bVal ); @@ -1286,6 +1317,8 @@ void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const sal::static_int_cast<sal_uInt16>(GetPrintSize()))); rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM), GetPrintZoomFactor())); + rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_SMEDITWINDOWZOOM), + GetSmEditWindowZoomFactor())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText())); diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 09078d11f94d..ccf07fb6127b 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -47,7 +47,6 @@ #include <svl/stritem.hxx> #include <svl/undo.hxx> #include <svl/whiter.hxx> -#include <editeng/editeng.hxx> #include <editeng/editstat.hxx> #include <editeng/eeitem.hxx> #include <editeng/fhgtitem.hxx> @@ -84,6 +83,7 @@ #include <utility> #include <oox/mathml/export.hxx> #include <ElementsDockingWindow.hxx> +#include <smediteng.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -291,58 +291,9 @@ void SmDocShell::ArrangeFormula() maAccText.clear(); } -void SmDocShell::UpdateEditEngineDefaultFonts(const Color& aTextColor) +void SmDocShell::UpdateEditEngineDefaultFonts() { - assert(mpEditEngineItemPool); - if (!mpEditEngineItemPool) - return; - - // set fonts to be used - struct FontDta { - LanguageType nFallbackLang; - LanguageType nLang; - DefaultFontType nFontType; - sal_uInt16 nFontInfoId; - } aTable[3] = - { - // info to get western font to be used - { LANGUAGE_ENGLISH_US, LANGUAGE_NONE, - DefaultFontType::FIXED, EE_CHAR_FONTINFO }, - // info to get CJK font to be used - { LANGUAGE_JAPANESE, LANGUAGE_NONE, - DefaultFontType::CJK_TEXT, EE_CHAR_FONTINFO_CJK }, - // info to get CTL font to be used - { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE, - DefaultFontType::CTL_TEXT, EE_CHAR_FONTINFO_CTL } - }; - - aTable[0].nLang = maLinguOptions.nDefaultLanguage; - aTable[1].nLang = maLinguOptions.nDefaultLanguage_CJK; - aTable[2].nLang = maLinguOptions.nDefaultLanguage_CTL; - - for (const FontDta & rFntDta : aTable) - { - LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ? - rFntDta.nFallbackLang : rFntDta.nLang; - vcl::Font aFont = OutputDevice::GetDefaultFont( - rFntDta.nFontType, nLang, GetDefaultFontFlags::OnlyOne ); - aFont.SetColor(aTextColor); - mpEditEngineItemPool->SetPoolDefaultItem( - SvxFontItem( aFont.GetFamilyType(), aFont.GetFamilyName(), - aFont.GetStyleName(), aFont.GetPitch(), aFont.GetCharSet(), - rFntDta.nFontInfoId ) ); - } - - // set font heights - SvxFontHeightItem aFontHeigt( - Application::GetDefaultDevice()->LogicToPixel( - Size( 0, 11 ), MapMode( MapUnit::MapPoint ) ).Height(), 100, - EE_CHAR_FONTHEIGHT ); - mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); - aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CJK ); - mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); - aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CTL ); - mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); + SmEditEngine::setSmItemPool(mpEditEngineItemPool.get(), maLinguOptions); } EditEngine& SmDocShell::GetEditEngine() @@ -352,32 +303,9 @@ EditEngine& SmDocShell::GetEditEngine() //! //! see also SmEditWindow::DataChanged ! //! - mpEditEngineItemPool = EditEngine::CreatePool(); - - const StyleSettings& rStyleSettings = Application::GetDefaultDevice()->GetSettings().GetStyleSettings(); - UpdateEditEngineDefaultFonts(rStyleSettings.GetFieldTextColor()); - - mpEditEngine.reset( new EditEngine( mpEditEngineItemPool.get() ) ); - - mpEditEngine->SetAddExtLeading(true); - - mpEditEngine->EnableUndo( true ); - mpEditEngine->SetDefTab( sal_uInt16( - Application::GetDefaultDevice()->GetTextWidth("XXXX")) ); - - mpEditEngine->SetBackgroundColor(rStyleSettings.GetFieldColor()); - - mpEditEngine->SetControlWord( - (mpEditEngine->GetControlWord() | EEControlBits::AUTOINDENTING) & - EEControlBits(~EEControlBits::UNDOATTRIBS) & - EEControlBits(~EEControlBits::PASTESPECIAL) ); - - mpEditEngine->SetWordDelimiters(" .=+-*/(){}[];\""); - mpEditEngine->SetRefMapMode(MapMode(MapUnit::MapPixel)); - - mpEditEngine->SetPaperSize( Size( 800, 0 ) ); - + SmEditEngine::setSmItemPool(mpEditEngineItemPool.get(), maLinguOptions); + mpEditEngine.reset( new SmEditEngine( mpEditEngineItemPool.get() ) ); mpEditEngine->EraseVirtualDevice(); // set initial text if the document already has some... @@ -385,9 +313,7 @@ EditEngine& SmDocShell::GetEditEngine() OUString aTxt( GetText() ); if (!aTxt.isEmpty()) mpEditEngine->SetText( aTxt ); - mpEditEngine->ClearModifyFlag(); - } return *mpEditEngine; } diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 53115b6c093e..373d3e8349d7 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -39,6 +39,7 @@ #include <view.hxx> #include <document.hxx> #include <cfgitem.hxx> +#include <smediteng.hxx> #include "accessibility.hxx" using namespace com::sun::star::accessibility; @@ -118,6 +119,10 @@ void SmEditTextWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) pEditEngine->SetStatusEventHdl(LINK(this, SmEditTextWindow, EditStatusHdl)); InitAccessible(); + + //Apply zoom to smeditwindow text + if(GetEditView()) + static_cast<SmEditEngine*>(GetEditEngine())->executeZoom(GetEditView()); } SmEditWindow::SmEditWindow(SmCmdBoxWindow &rMyCmdBoxWin, weld::Builder& rBuilder) @@ -190,7 +195,7 @@ void SmEditTextWindow::StyleUpdated() //! const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - pDoc->UpdateEditEngineDefaultFonts(rStyleSettings.GetFieldTextColor()); + pDoc->UpdateEditEngineDefaultFonts(); pEditEngine->SetBackgroundColor(rStyleSettings.GetFieldColor()); pEditEngine->SetDefTab(sal_uInt16(GetTextWidth("XXXX"))); @@ -203,6 +208,9 @@ void SmEditTextWindow::StyleUpdated() Resize(); } + + // Apply zoom to smeditwindow text + static_cast<SmEditEngine*>(GetEditEngine())->executeZoom(GetEditView()); } IMPL_LINK_NOARG(SmEditTextWindow, ModifyTimerHdl, Timer *, void) @@ -522,6 +530,8 @@ void SmEditTextWindow::SetText(const OUString& rText) // math tasks aModifyIdle.Start(); + // Apply zoom to smeditwindow text + static_cast<SmEditEngine*>(pEditView->GetEditEngine())->executeZoom(pEditView); pEditView->SetSelection(eSelection); } @@ -704,6 +714,8 @@ void SmEditTextWindow::UpdateStatus(bool bSetDocModified) SmDocShell* pDoc = bSetDocModified ? mrEditWindow.GetDoc() : nullptr; if (pDoc) pDoc->SetModified(); + + static_cast<SmEditEngine*>(GetEditEngine())->executeZoom(GetEditView()); } void SmEditWindow::Cut() diff --git a/starmath/source/smediteng.cxx b/starmath/source/smediteng.cxx new file mode 100644 index 000000000000..b782d5abc77b --- /dev/null +++ b/starmath/source/smediteng.cxx @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include <smediteng.hxx> +#include <smmod.hxx> +#include <cfgitem.hxx> + +#include <svx/weldeditview.hxx> +#include <vcl/settings.hxx> +#include <sfx2/viewfrm.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <svl/itemset.hxx> + +SmEditEngine::SmEditEngine(SfxItemPool* pItemPool) + : EditEngine(pItemPool) + , m_nOldZoom(100) + , m_nNewZoom(100) + , m_nDefaultFontSize(0) + , m_aAllSelection(0, 0, 0, 0) +{ + SetText(u""); + + // Add external text leading + SetAddExtLeading(true); + + // Allow to undo changes ( Ctrl + z ) + EnableUndo(true); + + // Length in pixel of a tabulation + SetDefTab(sal_uInt16(Application::GetDefaultDevice()->GetTextWidth("XXXX"))); + + // Set default background color by theme + SetBackgroundColor( + Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetFieldColor()); + + // Control words + SetControlWord((GetControlWord() | EEControlBits::AUTOINDENTING) + & EEControlBits(~EEControlBits::UNDOATTRIBS) + & EEControlBits(~EEControlBits::PASTESPECIAL)); + + // Word delimiters for auto word selection by double click + SetWordDelimiters(" .=+-*/(){}[];\""); + + // Default mapping mode + SetRefMapMode(MapMode(MapUnit::MapPixel)); + + // Default size of the box + SetPaperSize(Size(1000, 0)); +} + +bool SmEditEngine::checkZoom() +{ + return m_nOldZoom != (m_nNewZoom = SM_MOD()->GetConfig()->GetSmEditWindowZoomFactor()); +} + +void SmEditEngine::executeZoom(EditView* pEditView) +{ + if (checkZoom()) + { + updateZoom(); + if (pEditView) + { + FormatAndUpdate(pEditView); + pEditView->SetSelection(pEditView->GetSelection()); + } + } +} + +void SmEditEngine::updateZoom() +{ + // In first run get font size as base to scale + if (m_nDefaultFontSize == 0) + { + SfxItemSet sfxatts = GetAttribs(0, 0, 0, GetAttribsFlags::CHARATTRIBS); + const SvxFontHeightItem* sfxattsh = sfxatts.GetItem(EE_CHAR_FONTHEIGHT); + m_nDefaultFontSize = sfxattsh->GetHeight(); + } + + // Now we calculate the new font size + sal_Int32 nNewFontSize = m_nDefaultFontSize * m_nNewZoom / 100; + + // We apply the new font size to all the text + updateAllESelection(); // Update length of the text + SfxItemSet aSet = GetEmptyItemSet(); + aSet.Put(SvxFontHeightItem(nNewFontSize, 100, EE_CHAR_FONTHEIGHT)); + QuickSetAttribs(aSet, m_aAllSelection); + + // We don't forget to equalize the zoomvalues + m_nOldZoom = m_nNewZoom; +} + +void SmEditEngine::updateAllESelection() +{ + sal_Int32 paracount = GetParagraphCount(); + m_aAllSelection.nEndPara = paracount > 0 ? paracount - 1 : 0; + sal_Int32 textlength = GetTextLen(m_aAllSelection.nEndPara); + m_aAllSelection.nEndPos = textlength > 0 ? textlength : 0; +} + +void SmEditEngine::setSmItemPool(SfxItemPool* mpItemPool, const SvtLinguOptions& maLangOptions) +{ + // Set fonts to be used + struct FontData + { + LanguageType nFallbackLang; + LanguageType nLang; + DefaultFontType nFontType; + sal_uInt16 nFontInfoId; + }; + + FontData aFontDataTable[3] + = { // info to get western font to be used + { LANGUAGE_ENGLISH_US, maLangOptions.nDefaultLanguage, DefaultFontType::FIXED, + EE_CHAR_FONTINFO }, + // info to get CJK font to be used + { LANGUAGE_JAPANESE, maLangOptions.nDefaultLanguage_CJK, DefaultFontType::CJK_TEXT, + EE_CHAR_FONTINFO_CJK }, + // info to get CTL font to be used + { LANGUAGE_ARABIC_SAUDI_ARABIA, maLangOptions.nDefaultLanguage_CTL, + DefaultFontType::CTL_TEXT, EE_CHAR_FONTINFO_CTL } + }; + + // Text color + auto aDefaultDevice = Application::GetDefaultDevice(); + Color aTextColor = aDefaultDevice->GetSettings().GetStyleSettings().GetFieldTextColor(); + for (const FontData& aFontData : aFontDataTable) + { + LanguageType nLang + = (LANGUAGE_NONE == aFontData.nLang) ? aFontData.nFallbackLang : aFontData.nLang; + vcl::Font aFont = OutputDevice::GetDefaultFont(aFontData.nFontType, nLang, + GetDefaultFontFlags::OnlyOne); + aFont.SetColor(aTextColor); + mpItemPool->SetPoolDefaultItem(SvxFontItem(aFont.GetFamilyType(), aFont.GetFamilyName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet(), aFontData.nFontInfoId)); + } + + // Set font heights + SvxFontHeightItem aFontHeigt( + aDefaultDevice->LogicToPixel(Size(0, 11), MapMode(MapUnit::MapPoint)).Height(), 100, + EE_CHAR_FONTHEIGHT); + mpItemPool->SetPoolDefaultItem(aFontHeigt); + aFontHeigt.SetWhich(EE_CHAR_FONTHEIGHT_CJK); + mpItemPool->SetPoolDefaultItem(aFontHeigt); + aFontHeigt.SetWhich(EE_CHAR_FONTHEIGHT_CTL); + mpItemPool->SetPoolDefaultItem(aFontHeigt); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |