[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - 2 commits - include/svtools include/vcl svtools/source svx/source vcl/inc vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 4 11:22:21 UTC 2021


 include/svtools/editbrowsebox.hxx     |   12 +++
 include/vcl/weld.hxx                  |    3 
 svtools/source/brwbox/ebbcontrols.cxx |    4 +
 svx/source/fmcomp/gridcell.cxx        |   52 +++++++-------
 svx/source/inc/gridcell.hxx           |   19 -----
 vcl/inc/salvtables.hxx                |    2 
 vcl/source/app/salvtables.cxx         |   12 ++-
 vcl/unx/gtk3/gtkinst.cxx              |  121 ++++++++++++++++++++++++++++++++++
 8 files changed, 182 insertions(+), 43 deletions(-)

New commits:
commit ec8d0ae23eea3dcba97c7f78aa9ca0e6cec0bda9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 1 15:49:45 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 4 13:21:58 2021 +0200

    tdf#141633 use OutputDevice::DrawText for multiline text too
    
    m_bFastPaint is only false for the multiline text, where it then tries
    to use a textview widget to render the text onto the OutputDevice while
    for simpleline text it just uses OutputDevice::DrawText.
    
    This isn't working particuarly well anymore for print output and
    DrawText can be used with flags of DrawTextFlags::Top |
    DrawTextFlags::MultiLine | DrawTextFlags::WordBreak to render text
    equivalently to the multiple line textview which seems a saner approach.
    
    includes...
    
    Related: tdf#141633 use IsMultiLineEdit instead of !IsSimpleEdit
    
    seeing as the meaning of not simple is multi line editing instead
    of something more exotic like more complex formatted text
    
    Change-Id: Ic08834eed31b35ce16ba34bbbf8ff111d1a67da0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122952
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    
    Change-Id: I3c96f837aaeba82ebf5956ab2ba35210c978f255
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123042
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    Tested-by: Jenkins

diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index e1cf6d4e0570..5090df2372b3 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -1027,7 +1027,7 @@ void DbLimitedLengthField::implSetEffectiveMaxTextLen(sal_Int32 nMaxLen)
 
 DbTextField::DbTextField(DbGridColumn& _rColumn)
             :DbLimitedLengthField(_rColumn)
-            ,m_bIsSimpleEdit( true )
+            ,m_bIsMultiLineEdit(false)
 {
 }
 
@@ -1060,7 +1060,7 @@ void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCur
                              "caught an exception while determining the multi-line capabilities!");
     }
 
-    m_bIsSimpleEdit = !bIsMultiLine;
+    m_bIsMultiLineEdit = bIsMultiLine;
     if ( bIsMultiLine )
     {
         auto xEditControl = VclPtr<MultiLineTextCell>::Create(&rParent);
@@ -3562,7 +3562,7 @@ void FmXDataCell::UpdateFromColumn()
 
 FmXTextCell::FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
     :FmXDataCell( pColumn, std::move(pControl) )
-    ,m_bFastPaint( true )
+    ,m_bIsMultiLineText(false)
 {
 }
 
@@ -3572,13 +3572,7 @@ void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
                         const Reference< css::sdb::XColumn >& _rxField,
                         const Reference< XNumberFormatter >& xFormatter)
 {
-    if ( !m_bFastPaint )
-    {
-        FmXDataCell::PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
-        return;
-    }
-
-    DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::VCenter;
+    DrawTextFlags nStyle = DrawTextFlags::Clip;
     if ( ( rDev.GetOutDevType() == OUTDEV_WINDOW ) && !rDev.GetOwnerWindow()->IsEnabled() )
         nStyle |= DrawTextFlags::Disable;
 
@@ -3594,6 +3588,11 @@ void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
             nStyle |= DrawTextFlags::Left;
     }
 
+    if (!m_bIsMultiLineText)
+        nStyle |= DrawTextFlags::VCenter;
+    else
+        nStyle |= DrawTextFlags::Top | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak;
+
     try
     {
         const Color* pColor = nullptr;
@@ -3627,8 +3626,7 @@ FmXEditCell::FmXEditCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl>
     {
 
         m_pEditImplementation = pTextField->GetEditImplementation();
-        if ( !pTextField->IsSimpleEdit() )
-            m_bFastPaint = false;
+        m_bIsMultiLineText = pTextField->IsMultiLineEdit();
     }
     else
     {
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 2e9564d8c5ad..bacb9055ec38 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -380,7 +380,7 @@ class DbTextField : public DbLimitedLengthField
 {
     std::unique_ptr<::svt::IEditImplementation> m_pEdit;
     std::unique_ptr<::svt::IEditImplementation> m_pPainterImplementation;
-    bool                    m_bIsSimpleEdit;
+    bool                    m_bIsMultiLineEdit;
 
 protected:
     virtual ~DbTextField( ) override;
@@ -389,7 +389,7 @@ public:
     DbTextField(DbGridColumn& _rColumn);
 
     ::svt::IEditImplementation* GetEditImplementation() { return m_pEdit.get(); }
-    bool                    IsSimpleEdit() const { return m_bIsSimpleEdit; }
+    bool IsMultiLineEdit() const { return m_bIsMultiLineEdit; }
 
     virtual void Init( BrowserDataWin& rParent, const css::uno::Reference< css::sdbc::XRowSet >& xCursor ) override;
     virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, const Color** ppColor = nullptr) override;
@@ -819,20 +819,7 @@ protected:
 class FmXTextCell : public FmXDataCell
 {
 protected:
-    /** determines whether the text of this cell can be painted directly, without
-        using the painter control
-
-        If this is <TRUE/>, the <member>PaintCell</member> method will simply use the text as returned
-        by <member>GetText</member>, and draw it onto the device passed to <member>PaintFieldToCell</member>,
-        while respecting the current alignment settings.
-
-        If this is <FALSE/>, the <member>PaintFieldToCell</member> request will be forwarded to the painter
-        control (<member>m_pPainter</member>). This is more expensive, but the only option
-        if your painting involves more that a simple DrawText.
-
-        This member is <TRUE/> by default, and can be modified by derived classes.
-    */
-    bool    m_bFastPaint;
+    bool    m_bIsMultiLineText;
 
 public:
     FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
commit feb1cdd5bcbdf8dfe350551ab84d89a43d6fde8c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 29 15:13:28 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 4 13:21:44 2021 +0200

    tdf#141633 set correct font sizes in tableview child widgets
    
    Change-Id: Ic96a0ad8203bf3903546c0c2f07d96254ca01e4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122832
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 61050c6d7b8bceef2704eba0bfe4473ee75e669d)
    
    contains...
    
    Related: tdf#141633 PointFont gets overwritten by ControlFont
    
    Change-Id: I26ffffe7917d109ddc61fd2d2646db0988937c7c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122827
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 4e2306a5e336e2b43759c9712535626d0f2c168f)
    
    Related: tdf#141633 support setting a custom font for TextView
    
    Change-Id: I4c27a21c5c682fc73c37594749627e4cc7c0822d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122833
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 4d445ac9aa43b3399a579e3dbb1aac94507c9520)
    
    tdf#141633 multiple line entry font size/zoom not taking effect
    
    The "sample db" example (Mockup.odb) has multiline entries used in its
    "Journal Entry" column. Those are painted by taking snapshots of a
    never-really-shown textview widget.  But the textview is always drawn
    using its original default font size and changing the page zoom and/or
    font size had no effect on the size of text in the "Journal Entry"
    column.
    
    explicitly emit style_updated to get the GtkTextView to sync its font
    size from the css changed by the set_font
    
    Change-Id: Ic7d644b13c28f30a2c646b9d4098ea6e7f0dab81
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122889
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 36d5e26549b273118cea8969c43ef5ad3845f8df)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123041
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index c012414ded51..a758d1142a88 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -172,6 +172,8 @@ namespace svt
 
         virtual bool ProcessKey(const KeyEvent& rKEvt);
 
+        virtual void SetPointFont(const vcl::Font& rFont);
+
         // chain after the FocusInHdl
         void SetFocusInHdl(const Link<LinkParamNone*,void>& rHdl)
         {
@@ -224,6 +226,11 @@ namespace svt
             m_pEntry->set_editable(!bReadOnly);
         }
 
+        virtual void SetPointFont(const vcl::Font& rFont) override
+        {
+            m_pEntry->set_font(rFont);
+        }
+
         virtual void dispose() override;
 
         weld::Entry& get_widget() { return *m_pEntry; }
@@ -388,6 +395,11 @@ namespace svt
             m_xWidget->set_editable(!bReadOnly);
         }
 
+        virtual void SetPointFont(const vcl::Font& rFont) override
+        {
+            m_xWidget->set_font(rFont);
+        }
+
         virtual void GetFocus() override;
 
         virtual void dispose() override;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 4546da76b18e..9038351c2715 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -2133,6 +2133,9 @@ public:
         return get_text_height() * nRows;
     }
 
+    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
+    virtual void set_font(const vcl::Font& rFont) = 0;
+
     /*
        Typically you want to avoid the temptation of customizing
        font colors
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 04ba4b489f08..de2cf8ffb021 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -361,6 +361,10 @@ namespace svt
         return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ProcessKey(rKEvt);
     }
 
+    void ControlBase::SetPointFont(const vcl::Font& /*rFont*/)
+    {
+    }
+
     IMPL_LINK(ControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool)
     {
         return ProcessKey(rKEvt);
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 3e5796bb5fb6..e1cf6d4e0570 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -59,6 +59,7 @@
 #include <svx/dialmgr.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <tools/debug.hxx>
+#include <tools/fract.hxx>
 #include <tools/diagnose_ex.h>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
@@ -693,11 +694,11 @@ bool DbCellControl::Commit()
 
 void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat )
 {
-    vcl::Window* pWindows[] = { m_pPainter, m_pWindow };
+    svt::ControlBase* pWindows[] = { m_pPainter, m_pWindow };
 
     if (_eInitWhat & InitWindowFacet::WritingMode)
     {
-        for (vcl::Window* pWindow : pWindows)
+        for (svt::ControlBase* pWindow : pWindows)
         {
             if (pWindow)
                 pWindow->EnableRTL(rParent.IsRTLEnabled());
@@ -706,26 +707,29 @@ void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindo
 
     if (_eInitWhat & InitWindowFacet::Font)
     {
-        for (vcl::Window* pWindow : pWindows)
+        const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+        const Fraction& rZoom = rParent.GetZoom();
+
+        for (svt::ControlBase* pWindow : pWindows)
         {
             if (!pWindow)
                 continue;
 
-            pWindow->SetZoom(rParent.GetZoom());
-
-            const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
             vcl::Font aFont = rStyleSettings.GetFieldFont();
             aFont.SetTransparent(isTransparent());
 
             if (rParent.IsControlFont())
-            {
-                pWindow->SetControlFont(rParent.GetControlFont());
                 aFont.Merge(rParent.GetControlFont());
+
+            if (rZoom.GetNumerator() != rZoom.GetDenominator())
+            {
+                Size aSize = aFont.GetFontSize();
+                aSize.setWidth(std::round(double(aSize.Width() * rZoom)));
+                aSize.setHeight(std::round(double(aSize.Height() * rZoom)));
+                aFont.SetFontSize(aSize);
             }
-            else
-                pWindow->SetControlFont();
 
-            pWindow->SetZoomedPointFont(*pWindow->GetOutDev(), aFont); // FIXME RenderContext
+            pWindow->SetPointFont(aFont);
         }
     }
 
@@ -736,7 +740,7 @@ void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindo
         bool bTextLineColor = rParent.IsTextLineColor();
         Color aTextLineColor(rParent.GetTextLineColor());
 
-        for (vcl::Window* pWindow : pWindows)
+        for (svt::ControlBase* pWindow : pWindows)
         {
             if (pWindow)
             {
@@ -758,7 +762,7 @@ void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindo
     if (rParent.IsControlBackground())
     {
         Color aColor(rParent.GetControlBackground());
-        for (vcl::Window* pWindow : pWindows)
+        for (svt::ControlBase* pWindow : pWindows)
         {
             if (pWindow)
             {
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index d3789a9e75d8..1574a3a144c6 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1298,6 +1298,8 @@ public:
 
     virtual void set_monospace(bool bMonospace) override;
 
+    virtual void set_font(const vcl::Font& rFont) override;
+
     virtual void set_font_color(const Color& rColor) override;
 
     virtual void connect_cursor_position(const Link<TextView&, void>& rLink) override;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 3638db349676..3efdb345e1ea 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3333,6 +3333,7 @@ void SalInstanceEntry::set_message_type(weld::EntryMessageType eType)
 void SalInstanceEntry::set_font(const vcl::Font& rFont)
 {
     m_xEntry->SetPointFont(*m_xEntry->GetOutDev(), rFont);
+    m_xEntry->SetControlFont(rFont);
     m_xEntry->Invalidate();
 }
 
@@ -5808,8 +5809,7 @@ void SalInstanceTextView::set_monospace(bool bMonospace)
     else
         aFont = Application::GetSettings().GetStyleSettings().GetFieldFont();
     aFont.SetFontHeight(aOrigFont.GetFontHeight());
-    m_xTextView->SetFont(aFont);
-    m_xTextView->SetControlFont(aFont);
+    set_font(aFont);
 }
 
 void SalInstanceTextView::set_font_color(const Color& rColor)
@@ -5820,6 +5820,13 @@ void SalInstanceTextView::set_font_color(const Color& rColor)
         m_xTextView->SetControlForeground();
 }
 
+void SalInstanceTextView::set_font(const vcl::Font& rFont)
+{
+    m_xTextView->SetFont(rFont);
+    m_xTextView->SetControlFont(rFont);
+    m_xTextView->Invalidate();
+}
+
 void SalInstanceTextView::connect_cursor_position(const Link<TextView&, void>& rLink)
 {
     assert(!m_aCursorPositionHdl.IsSet());
@@ -6559,6 +6566,7 @@ public:
     {
         Edit& rEntry = m_pEntry->getEntry();
         rEntry.SetPointFont(*rEntry.GetOutDev(), rFont);
+        rEntry.SetControlFont(rFont);
         rEntry.Invalidate();
     }
 
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 213ccfb8624c..f9d079b6b734 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -3214,6 +3214,16 @@ private:
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
+    static void update_style(GtkWidget* pWidget, gpointer pData)
+    {
+        if (GTK_IS_CONTAINER(pWidget))
+            gtk_container_foreach(GTK_CONTAINER(pWidget), update_style, pData);
+        GtkWidgetClass* pWidgetClass = GTK_WIDGET_GET_CLASS(pWidget);
+        pWidgetClass->style_updated(pWidget);
+    }
+#endif
+
 public:
     GtkInstanceWidget(GtkWidget* pWidget, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
         : m_pWidget(pWidget)
@@ -4173,7 +4183,20 @@ public:
         bool bAlreadyMapped = gtk_widget_get_mapped(m_pWidget);
 
         if (!bAlreadyRealized)
+        {
+#if !GTK_CHECK_VERSION(4, 0, 0)
+            /*
+               tdf#141633 The "sample db" example (Mockup.odb) has multiline
+               entries used in its "Journal Entry" column. Those are painted by
+               taking snapshots of a never-really-shown textview widget.
+               Without this style_updated then the textview is always drawn
+               using its original default font size and changing the page zoom
+               has no effect on the size of text in the "Journal Entry" column.
+            */
+            update_style(m_pWidget, nullptr);
+#endif
             gtk_widget_realize(m_pWidget);
+        }
         if (!bAlreadyVisible)
             gtk_widget_show(m_pWidget);
         if (!bAlreadyMapped)
@@ -8573,6 +8596,80 @@ public:
     }
 };
 
+OUString vcl_font_to_css(const vcl::Font& rFont)
+{
+    OUStringBuffer sCSS;
+    sCSS.append("font-family: \"" + rFont.GetFamilyName() + "\"; ");
+    sCSS.append("font-size: " + OUString::number(rFont.GetFontSize().Height()) + "pt; ");
+    switch (rFont.GetItalic())
+    {
+        case ITALIC_NONE:
+            sCSS.append("font-style: normal; ");
+            break;
+        case ITALIC_NORMAL:
+            sCSS.append("font-style: italic; ");
+            break;
+        case ITALIC_OBLIQUE:
+            sCSS.append("font-style: oblique; ");
+            break;
+        default:
+            break;
+    }
+    switch (rFont.GetWeight())
+    {
+        case WEIGHT_ULTRALIGHT:
+            sCSS.append("font-weight: 200; ");
+            break;
+        case WEIGHT_LIGHT:
+            sCSS.append("font-weight: 300; ");
+            break;
+        case WEIGHT_NORMAL:
+            sCSS.append("font-weight: 400; ");
+            break;
+        case WEIGHT_BOLD:
+            sCSS.append("font-weight: 700; ");
+            break;
+        case WEIGHT_ULTRABOLD:
+            sCSS.append("font-weight: 800; ");
+            break;
+        default:
+            break;
+    }
+    switch (rFont.GetWidthType())
+    {
+        case WIDTH_ULTRA_CONDENSED:
+            sCSS.append("font-stretch: ultra-condensed; ");
+            break;
+        case WIDTH_EXTRA_CONDENSED:
+            sCSS.append("font-stretch: extra-condensed; ");
+            break;
+        case WIDTH_CONDENSED:
+            sCSS.append("font-stretch: condensed; ");
+            break;
+        case WIDTH_SEMI_CONDENSED:
+            sCSS.append("font-stretch: semi-condensed; ");
+            break;
+        case WIDTH_NORMAL:
+            sCSS.append("font-stretch: normal; ");
+            break;
+        case WIDTH_SEMI_EXPANDED:
+            sCSS.append("font-stretch: semi-expanded; ");
+            break;
+        case WIDTH_EXPANDED:
+            sCSS.append("font-stretch: expanded; ");
+            break;
+        case WIDTH_EXTRA_EXPANDED:
+            sCSS.append("font-stretch: extra-expanded; ");
+            break;
+        case WIDTH_ULTRA_EXPANDED:
+            sCSS.append("font-stretch: ultra-expanded; ");
+            break;
+        default:
+            break;
+    }
+    return sCSS.toString();
+}
+
 void update_attr_list(PangoAttrList* pAttrList, const vcl::Font& rFont)
 {
     pango_attr_list_change(pAttrList, pango_attr_family_new(OUStringToOString(rFont.GetFamilyName(), RTL_TEXTENCODING_UTF8).getStr()));
@@ -16041,6 +16138,8 @@ private:
     GtkTextBuffer* m_pTextBuffer;
     GtkAdjustment* m_pVAdjustment;
     GtkCssProvider* m_pFgCssProvider;
+    GtkCssProvider* m_pFontCssProvider;
+    std::optional<vcl::Font> m_xFont;
     int m_nMaxTextLength;
     gulong m_nChangedSignalId; // we don't disable/enable this one, it's to implement max-length
     gulong m_nInsertTextSignalId;
@@ -16132,6 +16231,7 @@ public:
         , m_pTextBuffer(gtk_text_view_get_buffer(pTextView))
         , m_pVAdjustment(gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(pTextView)))
         , m_pFgCssProvider(nullptr)
+        , m_pFontCssProvider(nullptr)
         , m_nMaxTextLength(0)
         , m_nChangedSignalId(g_signal_connect(m_pTextBuffer, "changed", G_CALLBACK(signalChanged), this))
         , m_nInsertTextSignalId(g_signal_connect_after(m_pTextBuffer, "insert-text", G_CALLBACK(signalInserText), this))
@@ -16246,6 +16346,27 @@ public:
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
 
+    virtual vcl::Font get_font() override
+    {
+        if (m_xFont)
+            return *m_xFont;
+        return GtkInstanceWidget::get_font();
+    }
+
+    virtual void set_font(const vcl::Font& rFont) override
+    {
+        m_xFont = rFont;
+        GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(m_pTextView));
+        if (m_pFontCssProvider)
+            gtk_style_context_remove_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pFontCssProvider));
+        m_pFontCssProvider = gtk_css_provider_new();
+        OUString aBuffer = "textview { " + vcl_font_to_css(rFont) +  "}";
+        OString aResult = OUStringToOString(aBuffer, RTL_TEXTENCODING_UTF8);
+        css_provider_load_from_data(m_pFontCssProvider, aResult.getStr(), aResult.getLength());
+        gtk_style_context_add_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pFontCssProvider),
+                                       GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    }
+
     virtual void disable_notify_events() override
     {
         g_signal_handler_block(m_pVAdjustment, m_nVAdjustChangedSignalId);


More information about the Libreoffice-commits mailing list