diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-12 13:19:56 +0000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-05-14 03:23:20 +0200 |
commit | ea191cf9807d0b0725fbc4831053a26ba71c2328 (patch) | |
tree | 024439b27c65e0dd8e324ccebb6c26757186e12a /starmath | |
parent | Switch everyone to stricter GetColorError (diff) | |
download | core-ea191cf9807d0b0725fbc4831053a26ba71c2328.tar.gz core-ea191cf9807d0b0725fbc4831053a26ba71c2328.zip |
tdf#90297 use field colors for math's edit engine
This adds a maTextColor to the EditEngine, which will override
the default AutoColor.
There is also a NOCOLORS mode and I thought about using it
instead, but it defaults to COL_BLACK and overriding this seems
wrong.
Since the EditEngine does the whole drawing and now has the
explicit FieldColor() and FieldTextColor() for background and
text, my guess is we don't need an ApplySettings implementation.
Change-Id: I6c2ecc843a3e07de98f97c86fc00a3b83cb78d97
Reviewed-on: https://gerrit.libreoffice.org/72197
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/document.hxx | 3 | ||||
-rw-r--r-- | starmath/inc/edit.hxx | 2 | ||||
-rw-r--r-- | starmath/source/document.cxx | 27 | ||||
-rw-r--r-- | starmath/source/edit.cxx | 40 | ||||
-rw-r--r-- | starmath/source/smmod.cxx | 3 |
5 files changed, 36 insertions, 39 deletions
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 311cece64cdb..ec4b016f12b9 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -75,7 +75,6 @@ public: OutputDevice* GetRefDev() { return pRefDev.get(); } }; -void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool, const SvtLinguOptions &rOpt); class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener { @@ -215,6 +214,8 @@ public: oox::drawingml::DocumentType documentType); void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding); void readFormulaOoxml( oox::formulaimport::XmlStream& stream ); + + void UpdateEditEngineDefaultFonts(); }; #endif diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx index 41d070eacef3..858360b32e87 100644 --- a/starmath/inc/edit.hxx +++ b/starmath/inc/edit.hxx @@ -117,8 +117,6 @@ public: void Flush(); void DeleteEditView(); - void ApplyColorConfigValues(const svtools::ColorConfig& rColorCfg); - bool HandleWheelCommands(const CommandEvent& rCEvt); bool IsInlineEditEnabled(); void StartCursorMove(); diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 58a4c073bb09..965702e1d5a4 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -275,8 +275,12 @@ void SmDocShell::ArrangeFormula() maAccText.clear(); } -void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool, const SvtLinguOptions &rOpt) +void SmDocShell::UpdateEditEngineDefaultFonts() { + assert(mpEditEngineItemPool); + if (!mpEditEngineItemPool) + return; + // set fonts to be used struct FontDta { LanguageType const nFallbackLang; @@ -295,9 +299,10 @@ void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool, const SvtLinguO { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE, DefaultFontType::CTL_TEXT, EE_CHAR_FONTINFO_CTL } }; - aTable[0].nLang = rOpt.nDefaultLanguage; - aTable[1].nLang = rOpt.nDefaultLanguage_CJK; - aTable[2].nLang = rOpt.nDefaultLanguage_CTL; + + aTable[0].nLang = maLinguOptions.nDefaultLanguage; + aTable[1].nLang = maLinguOptions.nDefaultLanguage_CJK; + aTable[2].nLang = maLinguOptions.nDefaultLanguage_CTL; for (FontDta & rFntDta : aTable) { @@ -305,7 +310,7 @@ void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool, const SvtLinguO rFntDta.nFallbackLang : rFntDta.nLang; vcl::Font aFont = OutputDevice::GetDefaultFont( rFntDta.nFontType, nLang, GetDefaultFontFlags::OnlyOne ); - rEditEngineItemPool.SetPoolDefaultItem( + mpEditEngineItemPool->SetPoolDefaultItem( SvxFontItem( aFont.GetFamilyType(), aFont.GetFamilyName(), aFont.GetStyleName(), aFont.GetPitch(), aFont.GetCharSet(), rFntDta.nFontInfoId ) ); @@ -316,11 +321,11 @@ void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool, const SvtLinguO Application::GetDefaultDevice()->LogicToPixel( Size( 0, 11 ), MapMode( MapUnit::MapPoint ) ).Height(), 100, EE_CHAR_FONTHEIGHT ); - rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt ); + mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CJK ); - rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt ); + mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CTL ); - rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt ); + mpEditEngineItemPool->SetPoolDefaultItem( aFontHeigt ); } EditEngine& SmDocShell::GetEditEngine() @@ -333,7 +338,7 @@ EditEngine& SmDocShell::GetEditEngine() mpEditEngineItemPool = EditEngine::CreatePool(); - SetEditEngineDefaultFonts(*mpEditEngineItemPool, maLinguOptions); + UpdateEditEngineDefaultFonts(); mpEditEngine.reset( new EditEngine( mpEditEngineItemPool ) ); @@ -343,6 +348,10 @@ EditEngine& SmDocShell::GetEditEngine() mpEditEngine->SetDefTab( sal_uInt16( Application::GetDefaultDevice()->GetTextWidth("XXXX")) ); + const StyleSettings& rStyleSettings = Application::GetDefaultDevice()->GetSettings().GetStyleSettings(); + mpEditEngine->SetTextColor(rStyleSettings.GetFieldTextColor()); + mpEditEngine->SetBackgroundColor(rStyleSettings.GetFieldColor()); + mpEditEngine->SetControlWord( (mpEditEngine->GetControlWord() | EEControlBits::AUTOINDENTING) & EEControlBits(~EEControlBits::UNDOATTRIBS) & diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index b16b67409943..76c10fe6536d 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -86,8 +86,6 @@ SmEditWindow::SmEditWindow( SmCmdBoxWindow &rMyCmdBoxWin ) : // Even RTL languages don't use RTL for math EnableRTL( false ); - ApplyColorConfigValues( SM_MOD()->GetColorConfig() ); - // compare DataChanged SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); @@ -190,25 +188,15 @@ EditEngine * SmEditWindow::GetEditEngine() return pEditEng; } -void SmEditWindow::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg ) -{ - // Note: SetBackground still done in SmEditWindow::DataChanged - SetTextColor( rColorCfg.GetColorValue(svtools::FONTCOLOR).nColor ); - Invalidate(); -} - -void SmEditWindow::DataChanged( const DataChangedEvent& ) +void SmEditWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - const StyleSettings aSettings( GetSettings().GetStyleSettings() ); - - // FIXME RenderContext + Window::DataChanged( rDCEvt ); - ApplyColorConfigValues( SM_MOD()->GetColorConfig() ); - SetBackground( aSettings.GetWindowColor() ); - - // edit fields in other Applications use this font instead of - // the application font thus we use this one too - SetPointFont(*this, aSettings.GetFieldFont() /*aSettings.GetAppFont()*/); + if (!((rDCEvt.GetType() == DataChangedEventType::FONTS) || + (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || + ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)))) + return; EditEngine *pEditEngine = GetEditEngine(); SmDocShell *pDoc = GetDoc(); @@ -218,10 +206,13 @@ void SmEditWindow::DataChanged( const DataChangedEvent& ) //! //! see also SmDocShell::GetEditEngine() ! //! + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - pEditEngine->SetDefTab(sal_uInt16(GetTextWidth("XXXX"))); + pDoc->UpdateEditEngineDefaultFonts(); - SetEditEngineDefaultFonts(pDoc->GetEditEngineItemPool(), pDoc->GetLinguOptions()); + pEditEngine->SetDefTab(sal_uInt16(GetTextWidth("XXXX"))); + pEditEngine->SetTextColor(rStyleSettings.GetFieldTextColor()); + pEditEngine->SetBackgroundColor(rStyleSettings.GetFieldColor()); // forces new settings to be used // unfortunately this resets the whole edit engine @@ -229,10 +220,12 @@ void SmEditWindow::DataChanged( const DataChangedEvent& ) OUString aTxt( pEditEngine->GetText() ); pEditEngine->Clear(); //incorrect font size pEditEngine->SetText( aTxt ); + + AdjustScrollBars(); + Resize(); } - AdjustScrollBars(); - Resize(); + Invalidate(); } IMPL_LINK_NOARG( SmEditWindow, ModifyTimerHdl, Timer *, void ) @@ -349,7 +342,6 @@ void SmEditWindow::Command(const CommandEvent& rCEvt) } } - bool SmEditWindow::HandleWheelCommands( const CommandEvent &rCEvt ) { bool bCommandHandled = false; // true if the CommandEvent needs not diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index cec24592c43e..041190181abf 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -143,9 +143,6 @@ void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg ) { SmViewShell *pSmView = static_cast<SmViewShell *>(pViewShell); pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg ); - SmEditWindow *pEditWin = pSmView->GetEditWindow(); - if (pEditWin) - pEditWin->ApplyColorConfigValues( rColorCfg ); } pViewShell = SfxViewShell::GetNext( *pViewShell ); } |