[Libreoffice-commits] core.git: include/vcl vcl/headless vcl/osx vcl/source vcl/unx vcl/win

Michael Meeks michael.meeks at collabora.com
Thu Nov 16 17:50:49 UTC 2017


 include/vcl/settings.hxx                  |    4 +-
 vcl/headless/svpframe.cxx                 |   11 ++++++
 vcl/osx/salframe.cxx                      |   19 ++---------
 vcl/source/app/settings.cxx               |   19 +++++++++++
 vcl/unx/gtk/salnativewidgets-gtk.cxx      |   12 -------
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx |   10 ------
 vcl/unx/kde4/KDESalFrame.cxx              |   48 +++++++++++-------------------
 vcl/unx/kde5/KDE5SalFrame.cxx             |   12 -------
 vcl/win/window/salframe.cxx               |    9 +----
 9 files changed, 61 insertions(+), 83 deletions(-)

New commits:
commit fc6231f1d1dd2a4e6f678b8221971e09807d8de8
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Nov 11 12:29:26 2017 +0000

    vcl: StyleSettings - start to unwind code duplication.
    
    This should be a pure re-factor, plus:
    
        switch from Serif -> Sans font default for the UI (wow).
        enable larger font size for LOK only
            that avoids a hard to debug svx junit test failure.
    
    Change-Id: Id438026064983ea4907819bab55c4be740954605
    Reviewed-on: https://gerrit.libreoffice.org/44625
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 97d5d8265b99..494e2bb8f24f 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -610,7 +610,9 @@ public:
 
     // Batch setters used by various backends
     void                            BatchSetBackgrounds( const Color &aBackColor,
-                                                         bool bCheckedColorSpecialCase = true);
+                                                         bool bCheckedColorSpecialCase = true );
+    void                            BatchSetFonts( const vcl::Font& aAppFont,
+                                                   const vcl::Font& aLabelFont );
 };
 
 
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index b08c96f06cc7..12fbf88ba63b 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -18,6 +18,8 @@
  */
 
 #include <string.h>
+
+#include <comphelper/lok.hxx>
 #include <vcl/syswin.hxx>
 
 #include <headless/svpframe.hxx>
@@ -411,6 +413,15 @@ void SvpSalFrame::UpdateSettings( AllSettings& rSettings )
     Color aBackgroundColor( 0xec, 0xec, 0xec );
     aStyleSettings.BatchSetBackgrounds( aBackgroundColor, false );
 
+    if (comphelper::LibreOfficeKit::isActive()) // TODO: remove this.
+    {
+        vcl::Font aStdFont( FAMILY_SWISS, Size( 0, 14 ) );
+        aStdFont.SetCharSet( osl_getThreadTextEncoding() );
+        aStdFont.SetWeight( WEIGHT_NORMAL );
+        aStdFont.SetFamilyName( "Liberation Sans" );
+        aStyleSettings.BatchSetFonts( aStdFont, aStdFont );
+    }
+
     rSettings.SetStyleSettings( aStyleSettings );
 }
 
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 2d47dd5e8670..4b96443e72bf 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1168,26 +1168,15 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings )
     aStyleSettings.SetToolbarIconSize( ToolbarIconSize::Large );
 
     // TODO: better mapping of OS X<->LibreOffice font settings
-    aStyleSettings.SetAppFont( aAppFont );
-    aStyleSettings.SetHelpFont( aAppFont );
-    aStyleSettings.SetPushButtonFont( aAppFont );
+    vcl::Font aLabelFont( getFont( [NSFont labelFontOfSize: 0], nDPIY, aAppFont ) );
+    aStyleSettings.BatchSetFonts( aAppFont, aLabelFont );
+    vcl::Font aMenuFont( getFont( [NSFont menuFontOfSize: 0], nDPIY, aAppFont ) );
+    aStyleSettings.SetMenuFont( aMenuFont );
 
     vcl::Font aTitleFont( getFont( [NSFont titleBarFontOfSize: 0], nDPIY, aAppFont ) );
     aStyleSettings.SetTitleFont( aTitleFont );
     aStyleSettings.SetFloatTitleFont( aTitleFont );
 
-    vcl::Font aMenuFont( getFont( [NSFont menuFontOfSize: 0], nDPIY, aAppFont ) );
-    aStyleSettings.SetMenuFont( aMenuFont );
-
-    aStyleSettings.SetToolFont( aAppFont );
-
-    vcl::Font aLabelFont( getFont( [NSFont labelFontOfSize: 0], nDPIY, aAppFont ) );
-    aStyleSettings.SetLabelFont( aLabelFont );
-    aStyleSettings.SetRadioCheckFont( aLabelFont );
-    aStyleSettings.SetFieldFont( aLabelFont );
-    aStyleSettings.SetGroupFont( aLabelFont );
-    aStyleSettings.SetTabFont( aLabelFont );
-    aStyleSettings.SetIconFont( aLabelFont );
 
     Color aHighlightColor( getColor( [NSColor selectedTextBackgroundColor],
                                       aStyleSettings.GetHighlightColor(), mpNSWindow ) );
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 9d739341176f..043f36d750bb 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -680,7 +680,7 @@ void ImplStyleData::SetStandardStyles()
     if (!utl::ConfigManager::IsFuzzing())
         aStdFont.SetFamilyName(utl::DefaultFontConfiguration::get().getUserInterfaceFont(LanguageTag("en")));
     else
-        aStdFont.SetFamilyName("Liberation Serif");
+        aStdFont.SetFamilyName("Liberation Sans");
     maAppFont                   = aStdFont;
     maHelpFont                  = aStdFont;
     maMenuFont                  = aStdFont;
@@ -3130,4 +3130,21 @@ void StyleSettings::BatchSetBackgrounds( const Color &aBackColor,
         SetCheckedColorSpecialCase();
 }
 
+void StyleSettings::BatchSetFonts( const vcl::Font& aAppFont,
+                                   const vcl::Font& aLabelFont )
+{
+    SetAppFont( aAppFont );
+    SetPushButtonFont( aAppFont );
+    SetToolFont( aAppFont );
+    SetHelpFont( aAppFont );
+
+    SetMenuFont( aLabelFont );
+    SetTabFont( aLabelFont );
+    SetLabelFont( aLabelFont );
+    SetRadioCheckFont( aLabelFont );
+    SetFieldFont( aLabelFont );
+    SetGroupFont( aLabelFont );
+    SetIconFont( aLabelFont );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx
index b5639e95ec8e..71cdf74f0ca5 100644
--- a/vcl/unx/gtk/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx
@@ -3984,17 +3984,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     if( aInfo.m_ePitch != PITCH_DONTKNOW )
         aFont.SetPitch( aInfo.m_ePitch );
 
-    aStyleSet.SetAppFont( aFont );
-    aStyleSet.SetHelpFont( aFont );
-    aStyleSet.SetMenuFont( aFont );
-    aStyleSet.SetToolFont( aFont );
-    aStyleSet.SetLabelFont( aFont );
-    aStyleSet.SetRadioCheckFont( aFont );
-    aStyleSet.SetPushButtonFont( aFont );
-    aStyleSet.SetFieldFont( aFont );
-    aStyleSet.SetIconFont( aFont );
-    aStyleSet.SetTabFont( aFont );
-    aStyleSet.SetGroupFont( aFont );
+    aStyleSet.BatchSetFonts( aFont, aFont );
 
     aFont.SetWeight( WEIGHT_BOLD );
     aStyleSet.SetTitleFont( aFont );
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 9229b4e178dc..f37ed7cb93dd 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -2883,15 +2883,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     // UI font
     vcl::Font aFont(getFont(pStyle, rSettings.GetUILanguageTag().getLocale()));
 
-    aStyleSet.SetAppFont( aFont );
-    aStyleSet.SetHelpFont( aFont );
-    aStyleSet.SetMenuFont( aFont );
-    aStyleSet.SetLabelFont( aFont );
-    aStyleSet.SetRadioCheckFont( aFont );
-    aStyleSet.SetPushButtonFont( aFont );
-    aStyleSet.SetFieldFont( aFont );
-    aStyleSet.SetIconFont( aFont );
-    aStyleSet.SetGroupFont( aFont );
+    aStyleSet.BatchSetFonts( aFont, aFont);
 
     aFont.SetWeight( WEIGHT_BOLD );
     aStyleSet.SetTitleFont( aFont );
diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx
index ea46d6e5c247..769e456e8738 100644
--- a/vcl/unx/kde4/KDESalFrame.cxx
+++ b/vcl/unx/kde4/KDESalFrame.cxx
@@ -175,6 +175,19 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
     style.SetActiveTextColor(toColor(pal.color(QPalette::Active, QPalette::WindowText)));
     style.SetDeactiveTextColor(toColor(pal.color(QPalette::Inactive, QPalette::WindowText)));
 
+    // Font
+    vcl::Font aFont = toFont( QApplication::font(), rSettings.GetUILanguageTag().getLocale() );
+    style.BatchSetFonts( aFont, aFont );
+
+    aFont.SetWeight( WEIGHT_BOLD );
+    if( !bSetTitleFont )
+    {
+        style.SetTitleFont( aFont );
+    }
+    style.SetFloatTitleFont( aFont );
+
+    style.SetHelpFont( toFont( QToolTip::font(), rSettings.GetUILanguageTag().getLocale()));
+
     // WM settings
     KConfig *pConfig = KGlobal::config().data();
     if ( pConfig )
@@ -187,9 +200,9 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
             pKey = "titleFont";
             if (aWMGroup.hasKey(pKey))
             {
-                vcl::Font aFont = toFont(aWMGroup.readEntry(pKey, QFont()),
-                                         rSettings.GetUILanguageTag().getLocale());
-                style.SetTitleFont( aFont );
+                vcl::Font aTitleFont = toFont(aWMGroup.readEntry(pKey, QFont()),
+                                              rSettings.GetUILanguageTag().getLocale());
+                style.SetTitleFont( aTitleFont );
                 bSetTitleFont = true;
             }
         }
@@ -204,9 +217,9 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
         pKey = "toolbarFont";
         if (aIconsGroup.hasKey(pKey))
         {
-            vcl::Font aFont = toFont(aIconsGroup.readEntry(pKey, QFont()),
-                                     rSettings.GetUILanguageTag().getLocale());
-            style.SetToolFont( aFont );
+            vcl::Font aToolFont = toFont(aIconsGroup.readEntry(pKey, QFont()),
+                                         rSettings.GetUILanguageTag().getLocale());
+            style.SetToolFont( aToolFont );
         }
     }
 
@@ -269,29 +282,6 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
     style.SetHelpColor( toColor( QToolTip::palette().color( QPalette::Active, QPalette::ToolTipBase )));
     style.SetHelpTextColor( toColor( QToolTip::palette().color( QPalette::Active, QPalette::ToolTipText )));
 
-    // Font
-    vcl::Font aFont = toFont( QApplication::font(), rSettings.GetUILanguageTag().getLocale() );
-
-    style.SetAppFont( aFont );
-
-    style.SetMenuFont( aFont ); // will be changed according to pMenuBar
-    style.SetLabelFont( aFont );
-    style.SetRadioCheckFont( aFont );
-    style.SetPushButtonFont( aFont );
-    style.SetFieldFont( aFont );
-    style.SetIconFont( aFont );
-    style.SetTabFont( aFont );
-    style.SetGroupFont( aFont );
-
-    aFont.SetWeight( WEIGHT_BOLD );
-    if( !bSetTitleFont )
-    {
-        style.SetTitleFont( aFont );
-    }
-    style.SetFloatTitleFont( aFont );
-
-    style.SetHelpFont( toFont( QToolTip::font(), rSettings.GetUILanguageTag().getLocale()));
-
     int flash_time = QApplication::cursorFlashTime();
     style.SetCursorBlinkTime( flash_time != 0 ? flash_time/2 : STYLE_CURSOR_NOBLINKTIME );
 
diff --git a/vcl/unx/kde5/KDE5SalFrame.cxx b/vcl/unx/kde5/KDE5SalFrame.cxx
index 1222260702ef..61b4113fa9d2 100644
--- a/vcl/unx/kde5/KDE5SalFrame.cxx
+++ b/vcl/unx/kde5/KDE5SalFrame.cxx
@@ -258,16 +258,7 @@ void KDE5SalFrame::UpdateSettings( AllSettings& rSettings )
     // Font
     vcl::Font aFont = toFont( QApplication::font(), rSettings.GetUILanguageTag().getLocale() );
 
-    style.SetAppFont( aFont );
-
-    style.SetMenuFont( aFont ); // will be changed according to pMenuBar
-    style.SetLabelFont( aFont );
-    style.SetRadioCheckFont( aFont );
-    style.SetPushButtonFont( aFont );
-    style.SetFieldFont( aFont );
-    style.SetIconFont( aFont );
-    style.SetTabFont( aFont );
-    style.SetGroupFont( aFont );
+    style.BatchSetFonts( aFont, aFont );
 
     aFont.SetWeight( WEIGHT_BOLD );
     if( !bSetTitleFont )
@@ -275,7 +266,6 @@ void KDE5SalFrame::UpdateSettings( AllSettings& rSettings )
         style.SetTitleFont( aFont );
     }
     style.SetFloatTitleFont( aFont );
-
     style.SetHelpFont( toFont( QToolTip::font(), rSettings.GetUILanguageTag().getLocale()));
 
     int flash_time = QApplication::cursorFlashTime();
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 725b02e0f232..83c96b69c15c 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -2749,6 +2749,8 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings )
 
     aStyleSettings.SetToolbarIconSize(ToolbarIconSize::Large);
 
+    aStyleSettings.BatchSetFonts( aAppFont, aAppFont );
+
     aStyleSettings.SetMenuFont( aMenuFont );
     aStyleSettings.SetTitleFont( aTitleFont );
     aStyleSettings.SetFloatTitleFont( aFloatTitleFont );
@@ -2766,12 +2768,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings )
             aAppFont.SetFamilyName( aFontName );
         }
     }
-    aStyleSettings.SetAppFont( aAppFont );
-    aStyleSettings.SetGroupFont( aAppFont );
-    aStyleSettings.SetLabelFont( aAppFont );
-    aStyleSettings.SetRadioCheckFont( aAppFont );
-    aStyleSettings.SetPushButtonFont( aAppFont );
-    aStyleSettings.SetFieldFont( aAppFont );
+
     if ( aAppFont.GetWeight() > WEIGHT_NORMAL )
         aAppFont.SetWeight( WEIGHT_NORMAL );
     aStyleSettings.SetToolFont( aAppFont );


More information about the Libreoffice-commits mailing list