[Libreoffice-commits] core.git: editeng/source include/editeng starmath/inc starmath/source
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 14 01:24:09 UTC 2019
editeng/source/editeng/editeng.cxx | 10 +++++++++
editeng/source/editeng/impedit.hxx | 4 +++
editeng/source/editeng/impedit2.cxx | 1
editeng/source/editeng/impedit3.cxx | 4 ++-
include/editeng/editeng.hxx | 2 +
starmath/inc/document.hxx | 3 +-
starmath/inc/edit.hxx | 2 -
starmath/source/document.cxx | 27 ++++++++++++++++--------
starmath/source/edit.cxx | 40 ++++++++++++++----------------------
starmath/source/smmod.cxx | 3 --
10 files changed, 56 insertions(+), 40 deletions(-)
New commits:
commit ea191cf9807d0b0725fbc4831053a26ba71c2328
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Sun May 12 13:19:56 2019 +0000
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue May 14 03:23:20 2019 +0200
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 at gmail.com>
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 458f71b34d3f..5faf9eb9f3f3 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -183,6 +183,16 @@ Color const & EditEngine::GetBackgroundColor() const
return pImpEditEngine->GetBackgroundColor();
}
+void EditEngine::SetTextColor( const Color& rColor )
+{
+ pImpEditEngine->SetTextColor( rColor );
+}
+
+Color const & EditEngine::GetTextColor() const
+{
+ return pImpEditEngine->GetTextColor();
+}
+
Color EditEngine::GetAutoColor() const
{
return pImpEditEngine->GetAutoColor();
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 9f0e27909515..987281ef89e4 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -463,6 +463,7 @@ private:
EditSelectionEngine aSelEngine;
Color maBackgroundColor;
+ Color maTextColor;
sal_uInt16 nStretchX;
sal_uInt16 nStretchY;
@@ -678,6 +679,9 @@ private:
void SetBackgroundColor( const Color& rColor ) { maBackgroundColor = rColor; }
const Color& GetBackgroundColor() const { return maBackgroundColor; }
+ void SetTextColor( const Color& rColor ) { maTextColor = rColor; }
+ const Color& GetTextColor() const { return maTextColor; }
+
long CalcVertLineSpacing(Point& rStartPos) const;
Color GetAutoColor() const;
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 6b4b8da61b2e..0d1d3b399f93 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -124,6 +124,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
eDefLanguage = LANGUAGE_DONTKNOW;
maBackgroundColor = COL_AUTO;
+ maTextColor = COL_AUTO;
nAsianCompressionMode = CharCompressType::NONE;
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index ec3e10cf1290..0cdee12d70ae 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4418,7 +4418,9 @@ Reference < i18n::XExtendedInputSequenceChecker > const & ImpEditEngine::ImplGet
Color ImpEditEngine::GetAutoColor() const
{
- Color aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
+ Color aColor = GetTextColor();
+ if ( aColor == COL_AUTO )
+ aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
if ( GetBackgroundColor() != COL_AUTO )
{
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index f585ce8b5796..dfb39a0b8e94 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -216,6 +216,8 @@ public:
void SetBackgroundColor( const Color& rColor );
Color const & GetBackgroundColor() const;
+ void SetTextColor( const Color& rColor );
+ Color const & GetTextColor() const;
Color GetAutoColor() const;
void EnableAutoColor( bool b );
void ForceAutoColor( bool b );
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 );
}
More information about the Libreoffice-commits
mailing list