weld SvxNumberFormatTabPage

Change-Id: Ia6e6497d5c9b6c47e34e5cb5b3913d25e73c3a69
Reviewed-on: https://gerrit.libreoffice.org/60944
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index a3ff4a0..6fb600f 100644
--- a/cui/source/inc/numfmt.hxx
+++ b/cui/source/inc/numfmt.hxx
@@ -25,39 +25,37 @@
#include <svx/langbox.hxx>
#include <svx/fontlb.hxx>
#include <tools/color.hxx>
#include <vcl/fixed.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/customweld.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/field.hxx>
#include <vcl/window.hxx>

#include <vcl/weld.hxx>

class SvxNumberFormatShell;
class SvxNumberInfoItem;
class vector;


class SvxNumberPreview : public vcl::Window
class SvxNumberPreview : public weld::CustomWidgetController
{
private:
    OUString        aPrevStr;
    Color           aPrevCol;
    sal_Int32       mnPos;
    sal_Unicode     mnChar;
    void            InitSettings( bool bForeground, bool bBackground );

protected:
    virtual void    Paint( vcl::RenderContext& /*rRenderContext*/, const ::tools::Rectangle& rRect ) override;
    virtual void    StateChanged( StateChangedType nStateChange ) override;
    virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
    virtual void    Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;

public:
    SvxNumberPreview(vcl::Window* pParent);
    SvxNumberPreview();

    void            NotifyChange( const OUString& rPrevStr, const Color* pColor = nullptr );
};

    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
    {
        CustomWidgetController::SetDrawingArea(pDrawingArea);
        pDrawingArea->set_size_request(-1, pDrawingArea->get_text_height() * 3);
    }
};

class SvxNumberFormatTabPage : public SfxTabPage
{
@@ -79,41 +77,9 @@ public:
    virtual DeactivateRC    DeactivatePage  ( SfxItemSet* pSet ) override;

    void                    HideLanguage(bool bFlag=true);
    virtual bool            PreNotify( NotifyEvent& rNEvt ) override;
    virtual void            PageCreated(const SfxAllItemSet& aSet) override;
private:
    SvxNumberFormatTabPage( vcl::Window* pParent,
                            const SfxItemSet& rCoreAttrs );
    VclPtr<FixedText>              m_pFtCategory;
    VclPtr<ListBox>                m_pLbCategory;
    VclPtr<FixedText>              m_pFtFormat;
    VclPtr<ListBox>                m_pLbCurrency;
    VclPtr<SvxFontListBox>         m_pLbFormat;
    VclPtr<FixedText>              m_pFtLanguage;
    VclPtr<SvxLanguageBox>         m_pLbLanguage;
    VclPtr<CheckBox>               m_pCbSourceFormat;
    VclPtr<SvxNumberPreview>       m_pWndPreview;
    VclPtr<FixedText>              m_pFtOptions;
    VclPtr<FixedText>              m_pFtDecimals;
    VclPtr<NumericField>           m_pEdDecimals;
    VclPtr<FixedText>              m_pFtDenominator;
    VclPtr<NumericField>           m_pEdDenominator;
    VclPtr<CheckBox>               m_pBtnNegRed;
    VclPtr<FixedText>              m_pFtLeadZeroes;
    VclPtr<NumericField>           m_pEdLeadZeroes;
    VclPtr<CheckBox>               m_pBtnThousand;
    VclPtr<CheckBox>               m_pBtnEngineering;

    VclPtr<VclContainer>           m_pFormatCodeFrame;
    VclPtr<Edit>                   m_pEdFormat;
    VclPtr<PushButton>             m_pIbAdd;
    VclPtr<PushButton>             m_pIbInfo;
    VclPtr<PushButton>             m_pIbRemove;

    VclPtr<FixedText>              m_pFtComment;
    VclPtr<Edit>                   m_pEdComment;
    Timer                   aResetWinTimer;

    SvxNumberFormatTabPage(TabPageParent pParent, const SfxItemSet& rCoreAttrs);

    std::unique_ptr<SvxNumberInfoItem>    pNumItem;
    std::unique_ptr<SvxNumberFormatShell> pNumFmtShell;
@@ -122,11 +88,39 @@ private:

    bool                bNumItemFlag; ///< for handling with DocShell
    bool                bOneAreaFlag;
    bool                bLegacyAutomaticCurrency;
    short                   nFixedCategory;

    OUString sAutomaticEntry;
    OUString sAutomaticLangEntry;
    OUString sAutomaticCurrencyEntry;

    VclPtr<vcl::Window>            pLastActivWindow;
    SvxNumberPreview m_aWndPreview;
    std::unique_ptr<weld::Label> m_xFtCategory;
    std::unique_ptr<weld::TreeView> m_xLbCategory;
    std::unique_ptr<weld::Label> m_xFtFormat;
    std::unique_ptr<weld::ComboBox> m_xLbCurrency;
    std::unique_ptr<weld::TreeView> m_xLbFormat;
    std::unique_ptr<weld::Label> m_xFtLanguage;
    std::unique_ptr<weld::CheckButton> m_xCbSourceFormat;
    std::unique_ptr<weld::Label> m_xFtOptions;
    std::unique_ptr<weld::Label> m_xFtDecimals;
    std::unique_ptr<weld::SpinButton> m_xEdDecimals;
    std::unique_ptr<weld::Label> m_xFtDenominator;
    std::unique_ptr<weld::SpinButton> m_xEdDenominator;
    std::unique_ptr<weld::CheckButton> m_xBtnNegRed;
    std::unique_ptr<weld::Label> m_xFtLeadZeroes;
    std::unique_ptr<weld::SpinButton> m_xEdLeadZeroes;
    std::unique_ptr<weld::CheckButton> m_xBtnThousand;
    std::unique_ptr<weld::CheckButton> m_xBtnEngineering;
    std::unique_ptr<weld::Widget> m_xFormatCodeFrame;
    std::unique_ptr<weld::Entry> m_xEdFormat;
    std::unique_ptr<weld::Button> m_xIbAdd;
    std::unique_ptr<weld::Button> m_xIbInfo;
    std::unique_ptr<weld::Button> m_xIbRemove;
    std::unique_ptr<weld::Label> m_xFtComment;
    std::unique_ptr<weld::Entry> m_xEdComment;
    std::unique_ptr<LanguageBox> m_xLbLanguage;
    std::unique_ptr<weld::CustomWeld> m_xWndPreview;

    void    Init_Impl();
    void    FillCurrencyBox();
@@ -142,21 +136,27 @@ private:
    void    MakePreviewText( const OUString& rFormat );
    void    ChangePreviewText( sal_uInt16 nPos );
    void    AddAutomaticLanguage_Impl(LanguageType eAutoLang, bool bSelect);
    bool    Click_Impl(PushButton* pIB);
    bool    Click_Impl(weld::Button& rIB);
    // Handler
    DECL_LINK( LostFocusHdl_Impl, Control&, void );
    DECL_LINK( DoubleClickHdl_Impl, SvTreeListBox*, bool );
    DECL_LINK( SelFormatListBoxHdl_Impl, ListBox&, void );
    DECL_LINK( SelFormatTreeListBoxHdl_Impl, SvTreeListBox*, void );
    DECL_LINK( SelFormatClickHdl_Impl, Button*, void );
    void SelFormatHdl_Impl(void*);
    DECL_LINK( ClickHdl_Impl, Button*, void );
    DECL_LINK( EditModifyHdl_Impl, Edit&, void );
    DECL_LINK( OptEditHdl_Impl, Edit&, void );
    DECL_LINK( OptClickHdl_Impl, Button*, void );
    DECL_LINK( TimeHdl_Impl, Timer *, void);
    void EditHdl_Impl(Edit const *);
    void OptHdl_Impl(void const *);
    DECL_LINK(LostFocusHdl_Impl, weld::Widget&, void);
    DECL_LINK(DoubleClickHdl_Impl, weld::TreeView&, void);
    DECL_LINK(SelFormatListBoxHdl_Impl, weld::ComboBox&, void);
    DECL_LINK(SelFormatTreeListBoxHdl_Impl, weld::TreeView&, void);
    DECL_LINK(SelFormatClickHdl_Impl, weld::Button&, void);
    void SelFormatHdl_Impl(weld::Widget*);
    DECL_LINK(ClickHdl_Impl, weld::Button&, void);
    DECL_LINK(EditModifyHdl_Impl, weld::Entry&, void);
    DECL_LINK(OptEditHdl_Impl, weld::SpinButton&, void);
    DECL_LINK(OptClickHdl_Impl, weld::Button&, void);
    DECL_LINK(TimeHdl_Impl, Timer*, void);
    void EditHdl_Impl(const weld::Entry*);
    void OptHdl_Impl(const weld::Widget*);

    // set and get currency, taking into account if the legacy
    // automatic currency entry exists
    void set_active_currency(sal_Int32 nCurCurrencyEntryPos);
    sal_uInt32 get_active_currency() const;

};

#endif
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 8ca7322..68e25cd 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -292,10 +292,10 @@ SvxCharNamePage::SvxCharNamePage(TabPageParent pParent, const SfxItemSet& rInSet
        std::unique_ptr<weld::EntryTreeView> xWestFontStyleLB = m_xBuilder->weld_entry_tree_view("stylegrid", "weststyle-nocjk", "weststylelb-nocjk");
        std::unique_ptr<weld::EntryTreeView> xWestFontSizeLB = m_xBuilder->weld_entry_tree_view("sizegrid", "westsize-nocjk", "westsizelb-nocjk");

        // 8 lines in the treeview
        xWestFontNameLB->set_height_request_by_rows(8);
        xWestFontStyleLB->set_height_request_by_rows(8);
        xWestFontSizeLB->set_height_request_by_rows(8);
        // 7 lines in the treeview
        xWestFontNameLB->set_height_request_by_rows(7);
        xWestFontStyleLB->set_height_request_by_rows(7);
        xWestFontSizeLB->set_height_request_by_rows(7);

        m_xWestFontNameLB = std::move(xWestFontNameLB);
        m_xWestFontStyleLB.reset(new SvtFontStyleBox(std::move(xWestFontStyleLB)));
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index dad69bc..2dd0e98 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -77,21 +77,12 @@ const sal_uInt16 SvxNumberFormatTabPage::pRanges[] =
#*
#************************************************************************/

SvxNumberPreview::SvxNumberPreview(vcl::Window* pParent)
    : Window(pParent, WB_BORDER)
    , mnPos(-1)
SvxNumberPreview::SvxNumberPreview()
    : mnPos(-1)
    , mnChar(0x0)
{
    vcl::Font aFont( GetFont() );
    aFont.SetTransparent( true );
    aFont.SetColor( Application::GetSettings().GetStyleSettings().GetFieldColor() );
    SetFont( aFont );
    InitSettings( true, true );
    SetBorderStyle( WindowBorderStyle::MONO );
}

VCL_BUILDER_FACTORY(SvxNumberPreview)

/*************************************************************************
#*  Method:        NotifyChange
#*------------------------------------------------------------------------
@@ -131,7 +122,6 @@ void SvxNumberPreview::NotifyChange( const OUString& rPrevStr,
    Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
    aPrevCol = pColor ? *pColor : aWindowTextColor;
    Invalidate();
    Update();
}

/*************************************************************************
@@ -147,11 +137,19 @@ void SvxNumberPreview::NotifyChange( const OUString& rPrevStr,

void SvxNumberPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
{
    rRenderContext.Push(PushFlags::ALL);

    svtools::ColorConfig aColorConfig;
    rRenderContext.SetTextColor(aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor);
    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    rRenderContext.SetBackground(rStyleSettings.GetWindowColor());

    vcl::Font aDrawFont = rRenderContext.GetFont();
    Size aSzWnd(GetOutputSizePixel());
    OUString aTmpStr( aPrevStr );
    long nLeadSpace = (aSzWnd.Width() - rRenderContext.GetTextWidth(aTmpStr)) / 2;

    aDrawFont.SetTransparent(true);
    aDrawFont.SetColor(aPrevCol);
    rRenderContext.SetFont(aDrawFont);

@@ -172,104 +170,64 @@ void SvxNumberPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::
    Point aPosText = Point((mnPos != -1) ? 0 : nLeadSpace,
                           (aSzWnd.Height() - GetTextHeight()) / 2);
    rRenderContext.DrawText(aPosText, aTmpStr);
}

void SvxNumberPreview::InitSettings( bool bForeground, bool bBackground )
{
    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();

    if ( bForeground )
    {
        svtools::ColorConfig aColorConfig;
        Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );

        if ( IsControlForeground() )
            aTextColor = GetControlForeground();
        SetTextColor( aTextColor );
    }

    if ( bBackground )
    {
        if ( IsControlBackground() )
            SetBackground( GetControlBackground() );
        else
            SetBackground( rStyleSettings.GetWindowColor() );
    }
    Invalidate();
}


void SvxNumberPreview::StateChanged( StateChangedType nType )
{
    if ( nType == StateChangedType::ControlForeground )
        InitSettings( true, false );
    else if ( nType == StateChangedType::ControlBackground )
        InitSettings( false, true );

    Window::StateChanged( nType );
}


void SvxNumberPreview::DataChanged( const DataChangedEvent& rDCEvt )
{
    Window::DataChanged( rDCEvt );

    if ( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
        InitSettings( true, true );
    rRenderContext.Pop();
}

// class SvxNumberFormatTabPage ------------------------------------------

#define REMOVE_DONTKNOW() \
    if ( !m_pFtLanguage->IsEnabled() )                                     \
    {                                                                   \
        m_pFtLanguage->Enable();                                          \
        m_pLbLanguage->Enable();                                          \
        m_pLbLanguage->SelectLanguage( pNumFmtShell->GetCurLanguage() );  \
    if (!m_xFtLanguage->get_sensitive())                              \
    {                                                                 \
        m_xFtLanguage->set_sensitive(true);                           \
        m_xLbLanguage->set_sensitive(true);                           \
        m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage()); \
    }

#define HDL(hdl) LINK( this, SvxNumberFormatTabPage, hdl )

SvxNumberFormatTabPage::SvxNumberFormatTabPage(vcl::Window* pParent,
SvxNumberFormatTabPage::SvxNumberFormatTabPage(TabPageParent pParent,
    const SfxItemSet& rCoreAttrs)
    : SfxTabPage(pParent, "NumberingFormatPage",
        "cui/ui/numberingformatpage.ui", &rCoreAttrs)
    : SfxTabPage(pParent, "cui/ui/numberingformatpage.ui", "NumberingFormatPage", &rCoreAttrs)
    , nInitFormat(ULONG_MAX)
    , sAutomaticEntry(CuiResId(RID_SVXSTR_AUTO_ENTRY))
    , pLastActivWindow(nullptr)
    , bLegacyAutomaticCurrency(false)
    , sAutomaticLangEntry(CuiResId(RID_SVXSTR_AUTO_ENTRY))
    , m_xFtCategory(m_xBuilder->weld_label("categoryft"))
    , m_xLbCategory(m_xBuilder->weld_tree_view("categorylb"))
    , m_xFtFormat(m_xBuilder->weld_label("formatft"))
    , m_xLbCurrency(m_xBuilder->weld_combo_box("currencylb"))
    , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb"))
    , m_xFtLanguage(m_xBuilder->weld_label("languageft"))
    , m_xCbSourceFormat(m_xBuilder->weld_check_button("sourceformat"))
    , m_xFtOptions(m_xBuilder->weld_label("optionsft"))
    , m_xFtDecimals(m_xBuilder->weld_label("decimalsft"))
    , m_xEdDecimals(m_xBuilder->weld_spin_button("decimalsed"))
    , m_xFtDenominator(m_xBuilder->weld_label("denominatorft"))
    , m_xEdDenominator(m_xBuilder->weld_spin_button("denominatored"))
    , m_xBtnNegRed(m_xBuilder->weld_check_button("negnumred"))
    , m_xFtLeadZeroes(m_xBuilder->weld_label("leadzerosft"))
    , m_xEdLeadZeroes(m_xBuilder->weld_spin_button("leadzerosed"))
    , m_xBtnThousand(m_xBuilder->weld_check_button("thousands"))
    , m_xBtnEngineering(m_xBuilder->weld_check_button("engineering"))
    , m_xFormatCodeFrame(m_xBuilder->weld_widget("formatcode"))
    , m_xEdFormat(m_xBuilder->weld_entry("formatted"))
    , m_xIbAdd(m_xBuilder->weld_button("add"))
    , m_xIbInfo(m_xBuilder->weld_button("edit"))
    , m_xIbRemove(m_xBuilder->weld_button("delete"))
    , m_xFtComment(m_xBuilder->weld_label("commentft"))
    , m_xEdComment(m_xBuilder->weld_entry("commented"))
    , m_xLbLanguage(new LanguageBox(m_xBuilder->weld_combo_box("languagelb")))
    , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview))
{
    get(m_pFtCategory, "categoryft");
    get(m_pLbCategory, "categorylb");
    get(m_pFtFormat, "formatft");
    get(m_pLbCurrency, "currencylb");
    get(m_pLbFormat, "formatlb");
    long nWidth = approximate_char_width() * 26;
    m_pLbFormat->set_width_request(nWidth);
    m_pLbCurrency->set_width_request(nWidth);
    get(m_pFtLanguage, "languageft");
    get(m_pLbLanguage, "languagelb");
    get(m_pCbSourceFormat, "sourceformat");
    get(m_pWndPreview, "preview");
    get(m_pFtOptions, "optionsft");
    get(m_pFtDecimals, "decimalsft");
    get(m_pEdDecimals, "decimalsed");
    get(m_pFtDenominator, "denominatorft");
    get(m_pEdDenominator, "denominatored");
    get(m_pBtnNegRed, "negnumred");
    get(m_pFtLeadZeroes, "leadzerosft");
    get(m_pEdLeadZeroes, "leadzerosed");
    get(m_pBtnThousand, "thousands");
    get(m_pBtnEngineering, "engineering");
    get(m_pFormatCodeFrame, "formatcode");
    get(m_pEdFormat, "formatted");
    get(m_pIbAdd, "add");
    get(m_pIbInfo, "edit");
    get(m_pIbRemove, "delete");
    get(m_pFtComment, "commentft");
    get(m_pEdComment, "commented");
    auto nWidth = approximate_char_width() * 26;
    m_xLbCategory->set_size_request(nWidth, m_xLbCategory->get_height_rows(7));
    m_xLbFormat->set_size_request(nWidth, m_xLbFormat->get_height_rows(5));
    m_xLbCurrency->set_size_request(1, -1);  // width of 1, so real width will be that of its LbFormat sibling
    m_xWndPreview->set_size_request(GetTextHeight()*3, -1);

    m_pLbCategory->SetDropDownLineCount(8);
    m_pWndPreview->set_height_request(GetTextHeight()*3);
    // Initially remove the "Automatically" entry.
    m_xLbCurrency->set_active(-1); // First ensure that nothing is selected.
    sAutomaticCurrencyEntry = m_xLbCurrency->get_text(0);
    m_xLbCurrency->remove(0);

    Init_Impl();
    SetExchangeSupport(); // this page needs ExchangeSupport
@@ -281,38 +239,12 @@ SvxNumberFormatTabPage::~SvxNumberFormatTabPage()
    disposeOnce();
}


void SvxNumberFormatTabPage::dispose()
{
    pNumFmtShell.reset();
    pNumItem.reset();
    m_pFtCategory.clear();
    m_pLbCategory.clear();
    m_pFtFormat.clear();
    m_pLbCurrency.clear();
    m_pLbFormat.clear();
    m_pFtLanguage.clear();
    m_pLbLanguage.clear();
    m_pCbSourceFormat.clear();
    m_pWndPreview.clear();
    m_pFtOptions.clear();
    m_pFtDecimals.clear();
    m_pEdDecimals.clear();
    m_pFtDenominator.clear();
    m_pEdDenominator.clear();
    m_pBtnNegRed.clear();
    m_pFtLeadZeroes.clear();
    m_pEdLeadZeroes.clear();
    m_pBtnThousand.clear();
    m_pBtnEngineering.clear();
    m_pFormatCodeFrame.clear();
    m_pEdFormat.clear();
    m_pIbAdd.clear();
    m_pIbInfo.clear();
    m_pIbRemove.clear();
    m_pFtComment.clear();
    m_pEdComment.clear();
    pLastActivWindow.clear();
    m_xWndPreview.reset();
    m_xLbLanguage.reset();
    SfxTabPage::dispose();
}

@@ -321,57 +253,67 @@ void SvxNumberFormatTabPage::Init_Impl()
    bNumItemFlag=true;
    bOneAreaFlag=false;

    m_pIbAdd->Enable(false );
    m_pIbRemove->Enable(false );
    m_pIbInfo->Enable(false );
    m_xIbAdd->set_sensitive(false );
    m_xIbRemove->set_sensitive(false );
    m_xIbInfo->set_sensitive(false );

    m_pEdComment->SetText(m_pLbCategory->GetEntry(1));    // string for user defined
    m_xEdComment->set_text(m_xLbCategory->get_text(1));    // string for user defined

    m_pEdComment->Hide();
    m_xEdComment->hide();

    m_pCbSourceFormat->Check( false );
    m_pCbSourceFormat->Disable();
    m_pCbSourceFormat->Hide();
    m_xCbSourceFormat->set_active( false );
    m_xCbSourceFormat->set_sensitive(false);
    m_xCbSourceFormat->hide();

    Link<ListBox&,void> aLink2 = LINK( this, SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl );
    Link<weld::TreeView&,void> aLink2 = LINK(this, SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl);
    Link<weld::ComboBox&,void> aLink3 = LINK(this, SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl);
    m_xLbCategory->connect_changed(aLink2);
    m_xLbCategory->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xLbFormat->connect_changed(aLink2);
    m_xLbFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xLbLanguage->connect_changed(aLink3);
    m_xLbLanguage->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xLbCurrency->connect_changed(aLink3);
    m_xLbCurrency->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xCbSourceFormat->connect_clicked(LINK(this, SvxNumberFormatTabPage, SelFormatClickHdl_Impl));
    m_xCbSourceFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));

    m_pLbCategory->SetSelectHdl( aLink2 );
    m_pLbFormat->SetSelectHdl( LINK( this, SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl ) );
    m_pLbLanguage->SetSelectHdl( aLink2 );
    m_pLbCurrency->SetSelectHdl( aLink2 );
    m_pCbSourceFormat->SetClickHdl( LINK( this, SvxNumberFormatTabPage, SelFormatClickHdl_Impl ) );
    Link<weld::SpinButton&,void> aLink = LINK( this, SvxNumberFormatTabPage, OptEditHdl_Impl );

    Link<Edit&,void> aLink = LINK( this, SvxNumberFormatTabPage, OptEditHdl_Impl );
    m_xEdDecimals->connect_value_changed(aLink);
    m_xEdDecimals->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xEdDenominator->connect_value_changed(aLink);
    m_xEdDenominator->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xEdLeadZeroes->connect_value_changed(aLink);
    m_xEdLeadZeroes->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));

    m_pEdDecimals->SetModifyHdl( aLink );
    m_pEdDenominator->SetModifyHdl( aLink );
    m_pEdLeadZeroes->SetModifyHdl( aLink );

    m_pBtnNegRed->SetClickHdl( LINK( this, SvxNumberFormatTabPage, OptClickHdl_Impl ) );
    m_pBtnThousand->SetClickHdl( LINK( this, SvxNumberFormatTabPage, OptClickHdl_Impl ) );
    m_pBtnEngineering->SetClickHdl( LINK( this, SvxNumberFormatTabPage, OptClickHdl_Impl ) );
    m_pLbFormat->SetDoubleClickHdl( HDL( DoubleClickHdl_Impl ) );
    m_pEdFormat->SetModifyHdl( HDL( EditModifyHdl_Impl ) );
    m_pIbAdd->SetClickHdl( HDL( ClickHdl_Impl ) );
    m_pIbRemove->SetClickHdl( HDL( ClickHdl_Impl ) );
    m_pIbInfo->SetClickHdl( HDL( ClickHdl_Impl ) );
    m_xBtnNegRed->connect_clicked(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
    m_xBtnNegRed->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xBtnThousand->connect_clicked(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
    m_xBtnThousand->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xBtnEngineering->connect_clicked(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
    m_xBtnEngineering->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xLbFormat->connect_row_activated(HDL(DoubleClickHdl_Impl));
    m_xEdFormat->connect_changed(HDL(EditModifyHdl_Impl));
    m_xEdFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xIbAdd->connect_clicked(HDL(ClickHdl_Impl));
    m_xIbAdd->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xIbRemove->connect_clicked(HDL(ClickHdl_Impl));
    m_xIbRemove->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
    m_xIbInfo->connect_clicked(HDL(ClickHdl_Impl));
    UpdateThousandEngineeringCheckBox();
    UpdateDecimalsDenominatorEditBox();

    m_pEdComment->SetLoseFocusHdl( LINK( this, SvxNumberFormatTabPage, LostFocusHdl_Impl) );
    aResetWinTimer.SetInvokeHandler(LINK( this, SvxNumberFormatTabPage, TimeHdl_Impl));
    aResetWinTimer.SetTimeout( 10);

    // initialize language ListBox

    m_pLbLanguage->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false);
    m_pLbLanguage->InsertLanguage( LANGUAGE_SYSTEM );
    m_xLbLanguage->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false);
    m_xLbLanguage->InsertLanguage( LANGUAGE_SYSTEM );
}

VclPtr<SfxTabPage> SvxNumberFormatTabPage::Create( TabPageParent pParent,
                                                   const SfxItemSet* rAttrSet )
{
    return VclPtr<SvxNumberFormatTabPage>::Create( pParent.pParent, *rAttrSet );
    return VclPtr<SvxNumberFormatTabPage>::Create(pParent, *rAttrSet);
}


@@ -387,6 +329,29 @@ VclPtr<SfxTabPage> SvxNumberFormatTabPage::Create( TabPageParent pParent,
#*
#************************************************************************/

void SvxNumberFormatTabPage::set_active_currency(sal_Int32 nPos)
{
    static_assert(SELPOS_NONE == -1, "SELPOS_NONE was -1 at time of writing");
    if (nPos == 0 && !bLegacyAutomaticCurrency)
    {
        // Insert "Automatically" if currently used so it is selectable.
        m_xLbCurrency->insert_text(0, sAutomaticCurrencyEntry);
        bLegacyAutomaticCurrency = true;
    }
    if (nPos != -1 && !bLegacyAutomaticCurrency)
        --nPos;
    m_xLbCurrency->set_active(nPos);
}

sal_uInt32 SvxNumberFormatTabPage::get_active_currency() const
{
    static_assert(SELPOS_NONE == -1, "SELPOS_NONE was -1 at time of writing");
    sal_Int32 nCurrencyPos = m_xLbCurrency->get_active();
    if (nCurrencyPos != -1 && !bLegacyAutomaticCurrency)
        ++nCurrencyPos;
    return nCurrencyPos;
}

void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
{
    const SfxUInt32Item*        pValFmtAttr     = nullptr;
@@ -459,18 +424,18 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
        const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(
                      GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE ));
        if ( pBoolItem )
            m_pCbSourceFormat->Check( pBoolItem->GetValue() );
            m_xCbSourceFormat->set_active(pBoolItem->GetValue());
        else
            m_pCbSourceFormat->Check( false );
        m_pCbSourceFormat->Enable();
        m_pCbSourceFormat->Show();
            m_xCbSourceFormat->set_active( false );
        m_xCbSourceFormat->set_sensitive(true);
        m_xCbSourceFormat->show();
    }
    else
    {
        bool bInit = false;     // set to sal_True for debug test
        m_pCbSourceFormat->Check( bInit );
        m_pCbSourceFormat->Enable( bInit );
        m_pCbSourceFormat->Show( bInit );
        m_xCbSourceFormat->set_active( bInit );
        m_xCbSourceFormat->set_sensitive( bInit );
        m_xCbSourceFormat->show( bInit );
    }

    // pNumItem must have been set from outside!
@@ -539,21 +504,14 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
                                   aFmtEntryList, aPrevString, pDummy );

    if (nCatLbSelPos==CAT_CURRENCY)
    {
        sal_Int32 nPos = pNumFmtShell->GetCurrencySymbol();
        if (nPos == 0)
            // Enable "Automatically" if currently used so it is selectable.
            m_pLbCurrency->SetEntryFlags( nPos, ListBoxEntryFlags::NONE );

        m_pLbCurrency->SelectEntryPos(nPos);
    }
        set_active_currency(pNumFmtShell->GetCurrencySymbol());

    nFixedCategory=nCatLbSelPos;
    if(bOneAreaFlag)
    {
        OUString sFixedCategory = m_pLbCategory->GetEntry(nFixedCategory);
        m_pLbCategory->Clear();
        m_pLbCategory->InsertEntry(sFixedCategory);
        OUString sFixedCategory = m_xLbCategory->get_text(nFixedCategory);
        m_xLbCategory->clear();
        m_xLbCategory->append_text(sFixedCategory);
        SetCategory(0);
    }
    else
@@ -569,22 +527,22 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
    // LanguageType no_NO.
    if ( eLangType == LANGUAGE_NORWEGIAN )
    {
        m_pLbLanguage->RemoveLanguage( eLangType );    // in case we're already called
        m_pLbLanguage->InsertLanguage( eLangType );
        m_xLbLanguage->remove_id(eLangType);    // in case we're already called
        m_xLbLanguage->InsertLanguage( eLangType );
    }
    m_pLbLanguage->SelectLanguage( eLangType );
    m_xLbLanguage->set_active_id(eLangType);
    if(pAutoEntryAttr)
        AddAutomaticLanguage_Impl(eLangType, pAutoEntryAttr->GetValue());
    UpdateFormatListBox_Impl(false,true);

//! This spoils everything because it rematches currency formats based on
//! the selected m_pLbCurrency entry instead of the current format.
//! the selected m_xLbCurrency entry instead of the current format.
//! Besides that everything seems to be initialized by now, so why call it?
//  SelFormatHdl_Impl( m_pLbCategory );
//  SelFormatHdl_Impl(m_xLbCategory.get());

    if ( pValFmtAttr )
    {
        EditHdl_Impl(m_pEdFormat); // UpdateOptions_Impl() as a side effect
        EditHdl_Impl(m_xEdFormat.get()); // UpdateOptions_Impl() as a side effect
    }
    else    // DONT_KNOW
    {
@@ -592,7 +550,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
        Obstructing();
    }

    if ( m_pCbSourceFormat->IsChecked() )
    if ( m_xCbSourceFormat->get_active() )
    {
        // everything disabled except SourceFormat checkbox
        EnableBySourceFormat_Impl();
@@ -612,38 +570,38 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
#************************************************************************/
void SvxNumberFormatTabPage::Obstructing()
{
    m_pLbFormat->SetNoSelection();
    m_pLbLanguage->SetNoSelection();
    m_pFtLanguage->Disable();
    m_pLbLanguage->Disable();
    m_xLbFormat->select(-1);
    m_xLbLanguage->set_active(-1);
    m_xFtLanguage->set_sensitive(false);
    m_xLbLanguage->set_sensitive(false);

    m_pIbAdd->Enable(false );
    m_pIbRemove->Enable(false );
    m_pIbInfo->Enable(false );
    m_xIbAdd->set_sensitive(false );
    m_xIbRemove->set_sensitive(false );
    m_xIbInfo->set_sensitive(false );

    m_pBtnNegRed->Disable();
    m_pBtnThousand->Disable();
    m_pBtnEngineering->Disable();
    m_pFtLeadZeroes->Disable();
    m_pFtDecimals->Disable();
    m_pFtDenominator->Disable();
    m_pEdLeadZeroes->Disable();
    m_pEdDecimals->Disable();
    m_pEdDenominator->Disable();
    m_pFtOptions->Disable();
    m_pEdDecimals->SetText( OUString() );
    m_pEdLeadZeroes->SetText( OUString() );
    m_pBtnNegRed->Check( false );
    m_pBtnThousand->Check( false );
    m_pBtnEngineering->Check( false );
    m_pWndPreview->NotifyChange( OUString() );
    m_xBtnNegRed->set_sensitive(false);
    m_xBtnThousand->set_sensitive(false);
    m_xBtnEngineering->set_sensitive(false);
    m_xFtLeadZeroes->set_sensitive(false);
    m_xFtDecimals->set_sensitive(false);
    m_xFtDenominator->set_sensitive(false);
    m_xEdLeadZeroes->set_sensitive(false);
    m_xEdDecimals->set_sensitive(false);
    m_xEdDenominator->set_sensitive(false);
    m_xFtOptions->set_sensitive(false);
    m_xEdDecimals->set_text( OUString() );
    m_xEdLeadZeroes->set_text( OUString() );
    m_xBtnNegRed->set_active( false );
    m_xBtnThousand->set_active( false );
    m_xBtnEngineering->set_active( false );
    m_aWndPreview.NotifyChange( OUString() );

    m_pLbCategory->SelectEntryPos( 0 );
    m_pEdFormat->SetText( OUString() );
    m_pFtComment->SetText( OUString() );
    m_pEdComment->SetText(m_pLbCategory->GetEntry(1));  // string for user defined
    m_xLbCategory->select(0);
    m_xEdFormat->set_text( OUString() );
    m_xFtComment->set_label( OUString() );
    m_xEdComment->set_text(m_xLbCategory->get_text(1));  // string for user defined

    m_pEdFormat->GrabFocus();
    m_xEdFormat->grab_focus();
}


@@ -653,28 +611,27 @@ void SvxNumberFormatTabPage::Obstructing()
#************************************************************************/
void SvxNumberFormatTabPage::EnableBySourceFormat_Impl()
{
    bool bEnable = !m_pCbSourceFormat->IsChecked();
    bool bEnable = !m_xCbSourceFormat->get_active();
    if ( !bEnable )
        m_pCbSourceFormat->GrabFocus();
    m_pFtCategory->Enable( bEnable );
    m_pLbCategory->Enable( bEnable );
    m_pFtFormat->Enable( bEnable );
    m_pLbCurrency->Enable( bEnable );
    m_pLbFormat->Enable( bEnable );
    m_pFtLanguage->Enable( bEnable );
    m_pLbLanguage->Enable( bEnable );
    m_pFtDecimals->Enable( bEnable );
    m_pEdDecimals->Enable( bEnable );
    m_pFtDenominator->Enable( bEnable );
    m_pEdDenominator->Enable( bEnable );
    m_pFtLeadZeroes->Enable( bEnable );
    m_pEdLeadZeroes->Enable( bEnable );
    m_pBtnNegRed->Enable( bEnable );
    m_pBtnThousand->Enable( bEnable );
    m_pBtnEngineering->Enable( bEnable );
    m_pFtOptions->Enable( bEnable );
    m_pFormatCodeFrame->Enable( bEnable );
    m_pLbFormat->Invalidate(); // #i43322#
        m_xCbSourceFormat->grab_focus();
    m_xFtCategory->set_sensitive( bEnable );
    m_xLbCategory->set_sensitive( bEnable );
    m_xFtFormat->set_sensitive( bEnable );
    m_xLbCurrency->set_sensitive( bEnable );
    m_xLbFormat->set_sensitive( bEnable );
    m_xFtLanguage->set_sensitive( bEnable );
    m_xLbLanguage->set_sensitive( bEnable );
    m_xFtDecimals->set_sensitive( bEnable );
    m_xEdDecimals->set_sensitive( bEnable );
    m_xFtDenominator->set_sensitive( bEnable );
    m_xEdDenominator->set_sensitive( bEnable );
    m_xFtLeadZeroes->set_sensitive( bEnable );
    m_xEdLeadZeroes->set_sensitive( bEnable );
    m_xBtnNegRed->set_sensitive( bEnable );
    m_xBtnThousand->set_sensitive( bEnable );
    m_xBtnEngineering->set_sensitive( bEnable );
    m_xFtOptions->set_sensitive( bEnable );
    m_xFormatCodeFrame->set_sensitive( bEnable );
}


@@ -691,8 +648,8 @@ void SvxNumberFormatTabPage::EnableBySourceFormat_Impl()

void SvxNumberFormatTabPage::HideLanguage(bool bFlag)
{
    m_pFtLanguage->Show(!bFlag);
    m_pLbLanguage->Show(!bFlag);
    m_xFtLanguage->show(!bFlag);
    m_xLbLanguage->show(!bFlag);
}

/*************************************************************************
@@ -710,7 +667,7 @@ void SvxNumberFormatTabPage::HideLanguage(bool bFlag)

bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
{
    bool bDataChanged   = m_pFtLanguage->IsEnabled() || m_pCbSourceFormat->IsEnabled();
    bool bDataChanged   = m_xFtLanguage->get_sensitive() || m_xCbSourceFormat->get_sensitive();
    if ( bDataChanged )
    {
        const SfxItemSet& rMyItemSet = GetItemSet();
@@ -719,15 +676,15 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )

        // OK chosen - Is format code input entered already taken over?
        // If not, simulate Add. Upon syntax error ignore input and prevent Put.
        OUString    aFormat = m_pEdFormat->GetText();
        OUString    aFormat = m_xEdFormat->get_text();
        sal_uInt32 nCurKey = pNumFmtShell->GetCurNumFmtKey();

        if ( m_pIbAdd->IsEnabled() || pNumFmtShell->IsTmpCurrencyFormat(aFormat) )
        if ( m_xIbAdd->get_sensitive() || pNumFmtShell->IsTmpCurrencyFormat(aFormat) )
        {   // #79599# It is not sufficient to just add the format code (or
            // delete it in case of bOneAreaFlag and resulting category change).
            // Upon switching tab pages we need all settings to be consistent
            // in case this page will be redisplayed later.
            bDataChanged = Click_Impl(m_pIbAdd);
            bDataChanged = Click_Impl(*m_xIbAdd);
            nCurKey = pNumFmtShell->GetCurNumFmtKey();
        }
        else if(nCurKey == NUMKEY_UNDEFINED)
@@ -781,26 +738,26 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )

        // Whether source format is to be taken or not:

        if ( m_pCbSourceFormat->IsEnabled() )
        if ( m_xCbSourceFormat->get_sensitive() )
        {
            sal_uInt16 _nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE );
            SfxItemState _eItemState = rMyItemSet.GetItemState( _nWhich, false );
            const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(
                        GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE ));
            bool bOld = pBoolItem && pBoolItem->GetValue();
            rCoreAttrs->Put( SfxBoolItem( _nWhich, m_pCbSourceFormat->IsChecked() ) );
            rCoreAttrs->Put( SfxBoolItem( _nWhich, m_xCbSourceFormat->get_active() ) );
            if ( !bDataChanged )
                bDataChanged = (bOld != m_pCbSourceFormat->IsChecked() ||
                bDataChanged = (bOld != m_xCbSourceFormat->get_active() ||
                    _eItemState != SfxItemState::SET);
        }

        // FillItemSet is only called on OK, here we can notify the
        // NumberFormatShell that all new user defined formats are valid.
        pNumFmtShell->ValidateNewEntries();
        if(m_pLbLanguage->IsVisible() &&
                LISTBOX_ENTRY_NOTFOUND != m_pLbLanguage->GetEntryPos(sAutomaticEntry))
        if(m_xLbLanguage->get_visible() &&
                m_xLbLanguage->find_text(sAutomaticLangEntry) != -1)
                rCoreAttrs->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO,
                    m_pLbLanguage->GetSelectedEntry() == sAutomaticEntry));
                    m_xLbLanguage->get_active_text() == sAutomaticLangEntry));
    }

    return bDataChanged;
@@ -818,23 +775,22 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<OUString>& rEnt
{
    OUString    aEntry;
    OUString    aTmpString;
    vcl::Font   aFont=m_pLbCategory->GetFont();
    size_t      i = 0;
    short       nTmpCatPos;

    m_pLbFormat->Clear();
    m_pLbFormat->SetUpdateMode( false );

    if( rEntries.empty() )
    m_xLbFormat->clear();
    if (rEntries.empty())
        return;

    m_xLbFormat->freeze();

    if(bOneAreaFlag)
    {
        nTmpCatPos=nFixedCategory;
    }
    else
    {
        nTmpCatPos=m_pLbCategory->GetSelectedEntryPos();
        nTmpCatPos=m_xLbCategory->get_selected_index();
    }

    switch (nTmpCatPos)
@@ -847,7 +803,7 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<OUString>& rEnt
                                    aTmpString=aEntry;
                                else
                                    aTmpString = pNumFmtShell->GetStandardName();
                                m_pLbFormat->InsertFontEntry( aTmpString, aFont );
                                m_xLbFormat->append_text(aTmpString);
                                break;

        default:                break;
@@ -863,16 +819,17 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<OUString>& rEnt
            {
                Color* pPreviewColor = nullptr;
                OUString aPreviewString( GetExpColorString( pPreviewColor, aEntry, aPrivCat ) );
                vcl::Font aEntryFont( m_pLbFormat->GetFont() );
                m_pLbFormat->InsertFontEntry( aPreviewString, aEntryFont, pPreviewColor );
                m_xLbFormat->append_text(aPreviewString);
                if (pPreviewColor)
                    m_xLbFormat->set_font_color(m_xLbFormat->n_children() -1, *pPreviewColor);
            }
            else
            {
                m_pLbFormat->InsertFontEntry(aEntry,aFont);
                m_xLbFormat->append_text(aEntry);
            }
        }
    }
    m_pLbFormat->SetUpdateMode( true );
    m_xLbFormat->thaw();
    rEntries.clear();
}

@@ -890,14 +847,14 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<OUString>& rEnt

void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_False*/ )
{
    OUString    theFormat           = m_pEdFormat->GetText();
    sal_Int32   nCurCategory        = m_pLbCategory->GetSelectedEntryPos();
    OUString    theFormat           = m_xEdFormat->get_text();
    sal_Int32   nCurCategory        = m_xLbCategory->get_selected_index();
    sal_uInt16  nCategory           = static_cast<sal_uInt16>(nCurCategory);
    sal_uInt16  nDecimals           = 0;
    sal_uInt16  nZeroes             = 0;
    bool        bNegRed             = false;
    bool        bThousand           = false;
    sal_Int32   nCurrencyPos        =m_pLbCurrency->GetSelectedEntryPos();
    sal_Int32   nCurrencyPos        = get_active_currency();

    if(bOneAreaFlag)
        nCurCategory=nFixedCategory;
@@ -913,13 +870,12 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa
        sal_uInt16 nTstPos=pNumFmtShell->FindCurrencyFormat(theFormat);
        if(nCurrencyPos!=static_cast<sal_Int32>(nTstPos) && nTstPos!=sal_uInt16(-1))
        {
            m_pLbCurrency->SelectEntryPos(nTstPos);
            set_active_currency(nTstPos);
            pNumFmtShell->SetCurrencySymbol(nTstPos);
            bDoIt=true;
        }
    }


    if ( nCategory != nCurCategory || bDoIt)
    {
        if ( bCheckCatChange )
@@ -932,12 +888,12 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa
            UpdateFormatListBox_Impl( true, false );
        }
    }
    else if ( m_pLbFormat->GetEntryCount() > 0 )
    else if ( m_xLbFormat->n_children() > 0 )
    {
        sal_uInt32 nCurEntryKey=NUMKEY_UNDEFINED;
        if(!pNumFmtShell->FindEntry( m_pEdFormat->GetText(),&nCurEntryKey))
        if(!pNumFmtShell->FindEntry( m_xEdFormat->get_text(),&nCurEntryKey))
        {
            m_pLbFormat->SetNoSelection();
            m_xLbFormat->select(-1);
        }
    }
    if(bOneAreaFlag)
@@ -953,41 +909,41 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa
            {
                sal_uInt16 nIntDigits = pNumFmtShell->GetFormatIntegerDigits(theFormat);
                bThousand = (nIntDigits > 0) && (nIntDigits % 3 == 0);
                m_pBtnEngineering->Enable();
                m_pBtnEngineering->Check( bThousand );
                m_xBtnEngineering->set_sensitive(true);
                m_xBtnEngineering->set_active( bThousand );
            }
            SAL_FALLTHROUGH;
        case CAT_NUMBER:
        case CAT_PERCENT:
        case CAT_CURRENCY:
        case CAT_FRACTION:
            m_pFtOptions->Enable();
            m_xFtOptions->set_sensitive(true);
            if ( nCategory == CAT_FRACTION )
            {
                m_pFtDenominator->Enable();
                m_pEdDenominator->Enable();
                m_xFtDenominator->set_sensitive(true);
                m_xEdDenominator->set_sensitive(true);
            }
            else
            {
                m_pFtDecimals->Enable();
                m_pEdDecimals->Enable();
                m_xFtDecimals->set_sensitive(true);
                m_xEdDecimals->set_sensitive(true);
            }
            m_pFtLeadZeroes->Enable();
            m_pEdLeadZeroes->Enable();
            m_pBtnNegRed->Enable();
            if ( nCategory == CAT_NUMBER && m_pLbFormat->GetSelectedEntryPos() == 0 )
                m_pEdDecimals->SetText( "" ); //General format tdf#44399
            m_xFtLeadZeroes->set_sensitive(true);
            m_xEdLeadZeroes->set_sensitive(true);
            m_xBtnNegRed->set_sensitive(true);
            if ( nCategory == CAT_NUMBER && m_xLbFormat->get_selected_index() == 0 )
                m_xEdDecimals->set_text( "" ); //General format tdf#44399
            else
                if ( nCategory == CAT_FRACTION )
                    m_pEdDenominator->SetText( OUString::number( nDecimals ) );
                    m_xEdDenominator->set_text( OUString::number( nDecimals ) );
                else
                    m_pEdDecimals->SetText( OUString::number( nDecimals ) );
            m_pEdLeadZeroes->SetText( OUString::number( nZeroes ) );
            m_pBtnNegRed->Check( bNegRed );
                    m_xEdDecimals->set_text( OUString::number( nDecimals ) );
            m_xEdLeadZeroes->set_text( OUString::number( nZeroes ) );
            m_xBtnNegRed->set_active( bNegRed );
            if ( nCategory != CAT_SCIENTIFIC )
            {
                m_pBtnThousand->Enable();
                m_pBtnThousand->Check( bThousand );
                m_xBtnThousand->set_sensitive(true);
                m_xBtnThousand->set_active( bThousand );
            }
            break;

@@ -998,21 +954,21 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa
        case CAT_TIME:
        case CAT_BOOLEAN:
        default:
            m_pFtOptions->Disable();
            m_pFtDecimals->Disable();
            m_pEdDecimals->Disable();
            m_pFtDenominator->Disable();
            m_pEdDenominator->Disable();
            m_pFtLeadZeroes->Disable();
            m_pEdLeadZeroes->Disable();
            m_pBtnNegRed->Disable();
            m_pBtnThousand->Disable();
            m_pBtnEngineering->Disable();
            m_pEdDecimals->SetText( OUString::number( 0 ) );
            m_pEdLeadZeroes->SetText( OUString::number( 0 ) );
            m_pBtnNegRed->Check( false );
            m_pBtnThousand->Check( false );
            m_pBtnEngineering->Check( false );
            m_xFtOptions->set_sensitive(false);
            m_xFtDecimals->set_sensitive(false);
            m_xEdDecimals->set_sensitive(false);
            m_xFtDenominator->set_sensitive(false);
            m_xEdDenominator->set_sensitive(false);
            m_xFtLeadZeroes->set_sensitive(false);
            m_xEdLeadZeroes->set_sensitive(false);
            m_xBtnNegRed->set_sensitive(false);
            m_xBtnThousand->set_sensitive(false);
            m_xBtnEngineering->set_sensitive(false);
            m_xEdDecimals->set_text( OUString::number( 0 ) );
            m_xEdLeadZeroes->set_text( OUString::number( 0 ) );
            m_xBtnNegRed->set_active( false );
            m_xBtnThousand->set_active( false );
            m_xBtnEngineering->set_active( false );
    }
}

@@ -1046,22 +1002,22 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
    }
    else
    {
        nTmpCatPos=m_pLbCategory->GetSelectedEntryPos();
        nTmpCatPos=m_xLbCategory->get_selected_index();
    }


    if ( bCat )
    {
        if(nTmpCatPos!=CAT_CURRENCY)
            m_pLbCurrency->Hide();
            m_xLbCurrency->hide();
        else
            m_pLbCurrency->Show();
            m_xLbCurrency->show();

        pNumFmtShell->CategoryChanged( nTmpCatPos,nFmtLbSelPos, aEntryList );
        pNumFmtShell->CategoryChanged(nTmpCatPos,nFmtLbSelPos, aEntryList);
    }
    else
        pNumFmtShell->LanguageChanged( m_pLbLanguage->GetSelectedLanguage(),
                                       nFmtLbSelPos,aEntryList );
        pNumFmtShell->LanguageChanged(m_xLbLanguage->get_active_id(),
                                      nFmtLbSelPos,aEntryList);

    REMOVE_DONTKNOW() // possibly UI-Enable

@@ -1071,21 +1027,21 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
        if(bUpdateEdit)
        {
            OUString aFormat=aEntryList[nFmtLbSelPos];
            m_pEdFormat->SetText(aFormat);
            m_pFtComment->SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
            m_xEdFormat->set_text(aFormat);
            m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
        }

        if(!bOneAreaFlag || !bCat)
        {
            FillFormatListBox_Impl( aEntryList );
            m_pLbFormat->SelectEntryPos( nFmtLbSelPos );
            m_xLbFormat->select(nFmtLbSelPos);

            m_pFtComment->SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
            m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
            if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
            {
                if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
                {
                    m_pFtComment->SetText(m_pLbCategory->GetEntry(1));
                    m_xFtComment->set_label(m_xLbCategory->get_text(1));
                }
            }
            ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
@@ -1097,26 +1053,26 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
        FillFormatListBox_Impl( aEntryList );
        if(nFmtLbSelPos != SELPOS_NONE)
        {
            m_pLbFormat->SelectEntryPos( static_cast<sal_uInt16>(nFmtLbSelPos) );
            m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));

            m_pFtComment->SetText(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
            m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
            if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
            {
                if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
                {
                    m_pFtComment->SetText(m_pLbCategory->GetEntry(1));
                    m_xFtComment->set_label(m_xLbCategory->get_text(1));
                }
            }
        }
        else
        {
            m_pLbFormat->SetNoSelection();
            m_xLbFormat->select(-1);
        }

        if ( bUpdateEdit )
        {
            m_pEdFormat->SetText( OUString() );
            m_pWndPreview->NotifyChange( OUString() );
            m_xEdFormat->set_text( OUString() );
            m_aWndPreview.NotifyChange( OUString() );
        }
    }

@@ -1132,9 +1088,9 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl

void SvxNumberFormatTabPage::UpdateThousandEngineeringCheckBox()
{
    bool bIsScientific = m_pLbCategory->GetSelectedEntryPos() == CAT_SCIENTIFIC;
    m_pBtnThousand->Show( !bIsScientific );
    m_pBtnEngineering->Show( bIsScientific );
    bool bIsScientific = m_xLbCategory->get_selected_index() == CAT_SCIENTIFIC;
    m_xBtnThousand->show( !bIsScientific );
    m_xBtnEngineering->show( bIsScientific );
}


@@ -1146,11 +1102,11 @@ void SvxNumberFormatTabPage::UpdateThousandEngineeringCheckBox()

void SvxNumberFormatTabPage::UpdateDecimalsDenominatorEditBox()
{
    bool bIsFraction = m_pLbCategory->GetSelectedEntryPos() == CAT_FRACTION;
    m_pFtDecimals->Show( !bIsFraction );
    m_pEdDecimals->Show( !bIsFraction );
    m_pFtDenominator->Show( bIsFraction );
    m_pEdDenominator->Show( bIsFraction );
    bool bIsFraction = m_xLbCategory->get_selected_index() == CAT_FRACTION;
    m_xFtDecimals->show( !bIsFraction );
    m_xEdDecimals->show( !bIsFraction );
    m_xFtDenominator->show( bIsFraction );
    m_xEdDenominator->show( bIsFraction );
}


@@ -1166,25 +1122,21 @@ void SvxNumberFormatTabPage::UpdateDecimalsDenominatorEditBox()
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, DoubleClickHdl_Impl, SvTreeListBox*, pLb, bool )
IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView&, rLb, void)
{
    if (pLb == m_pLbFormat)
    {
        SelFormatHdl_Impl( pLb );
    SelFormatHdl_Impl(&rLb);

        if ( fnOkHdl.IsSet() )
        {   // temporary solution, should be offered by SfxTabPage
            fnOkHdl.Call( nullptr );
        }
        else
        {
            SfxSingleTabDialog* pParent = dynamic_cast< SfxSingleTabDialog* >( GetParentDialog() );
            OKButton* pOKButton = pParent ? pParent->GetOKButton() : nullptr;
            if ( pOKButton )
                pOKButton->Click();
        }
    if ( fnOkHdl.IsSet() )
    {   // temporary solution, should be offered by SfxTabPage
        fnOkHdl.Call( nullptr );
    }
    return false;
    else
    {
        SfxSingleTabDialog* pParent = dynamic_cast<SfxSingleTabDialog*>(GetParentDialog());
        OKButton* pOKButton = pParent ? pParent->GetOKButton() : nullptr;
        if ( pOKButton )
            pOKButton->Click();
    }
}


@@ -1200,36 +1152,36 @@ IMPL_LINK( SvxNumberFormatTabPage, DoubleClickHdl_Impl, SvTreeListBox*, pLb, boo
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, SelFormatClickHdl_Impl, Button*, pLb, void )
{
    SelFormatHdl_Impl(pLb);
}
IMPL_LINK( SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl, SvTreeListBox*, pLb, void )
{
    SelFormatHdl_Impl(pLb);
}
IMPL_LINK( SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl, ListBox&, rLb, void )
IMPL_LINK(SvxNumberFormatTabPage, SelFormatClickHdl_Impl, weld::Button&, rLb, void)
{
    SelFormatHdl_Impl(&rLb);
}
void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )

IMPL_LINK(SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl, weld::TreeView&, rLb, void)
{
    if (pLb == m_pCbSourceFormat)
    SelFormatHdl_Impl(&rLb);
}

IMPL_LINK(SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl, weld::ComboBox&, rLb, void)
{
    SelFormatHdl_Impl(&rLb);
}

void SvxNumberFormatTabPage::SelFormatHdl_Impl(weld::Widget* pLb)
{
    if (pLb == m_xCbSourceFormat.get())
    {
        EnableBySourceFormat_Impl();    // enable/disable everything else
        if ( m_pCbSourceFormat->IsChecked() )
        if ( m_xCbSourceFormat->get_active() )
            return;   // just disabled everything else

        // Reinit options enable/disable for current selection.

        // Current category may be UserDefined with no format entries defined.
        // And yes, m_pLbFormat is a SvxFontListBox with sal_uLong list positions,
        // implementation returns a TREELIST_ENTRY_NOTFOUND if empty,
        // comparison with sal_Int32 LISTBOX_ENTRY_NOTFOUND wouldn't match.
        if ( m_pLbFormat->GetSelectedEntryPos() == TREELIST_ENTRY_NOTFOUND )
            pLb = m_pLbCategory; // continue with the current category selected
        if (m_xLbFormat->get_selected_index() == -1)
            pLb = m_xLbCategory.get(); // continue with the current category selected
        else
            pLb = m_pLbFormat;   // continue with the current format selected
            pLb = m_xLbFormat.get();   // continue with the current format selected
    }

    sal_Int32 nTmpCatPos;
@@ -1240,20 +1192,16 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )
    }
    else
    {
        nTmpCatPos=m_pLbCategory->GetSelectedEntryPos();
        nTmpCatPos=m_xLbCategory->get_selected_index();
    }

    if (nTmpCatPos==CAT_CURRENCY && pLb == m_pLbCurrency )
    {
        sal_Int32 nCurrencyPos = m_pLbCurrency->GetSelectedEntryPos();
        pNumFmtShell->SetCurrencySymbol(static_cast<sal_uInt32>(nCurrencyPos));
    }

    if (nTmpCatPos==CAT_CURRENCY && pLb == m_xLbCurrency.get())
        pNumFmtShell->SetCurrencySymbol(get_active_currency());

    // Format-ListBox ----------------------------------------------------
    if (pLb == m_pLbFormat)
    if (pLb == m_xLbFormat.get())
    {
        sal_uLong nSelPos = m_pLbFormat->GetSelectedEntryPos();
        sal_uLong nSelPos = m_xLbFormat->get_selected_index();
        short nFmtLbSelPos = static_cast<short>(nSelPos);

        OUString aFormat = pNumFmtShell->GetFormat4Entry(nFmtLbSelPos);
@@ -1263,14 +1211,15 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )
        {
            if(aComment.isEmpty())
            {
                aComment = m_pLbCategory->GetEntry(1);
                aComment = m_xLbCategory->get_text(1);
            }
        }

        if ( !aFormat.isEmpty() )
        {
            if(!m_pEdFormat->HasFocus()) m_pEdFormat->SetText( aFormat );
            m_pFtComment->SetText(aComment);
            if  (!m_xEdFormat->has_focus())
                m_xEdFormat->set_text( aFormat );
            m_xFtComment->set_label(aComment);
            ChangePreviewText( static_cast<sal_uInt16>(nSelPos) );
        }

@@ -1278,18 +1227,18 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )

        if ( pNumFmtShell->FindEntry( aFormat) )
        {
            m_pIbAdd->Enable(false );
            m_xIbAdd->set_sensitive(false );
            bool bIsUserDef=pNumFmtShell->IsUserDefined( aFormat );
            m_pIbRemove->Enable(bIsUserDef);
            m_pIbInfo->Enable(bIsUserDef);
            m_xIbRemove->set_sensitive(bIsUserDef);
            m_xIbInfo->set_sensitive(bIsUserDef);

        }
        else
        {
            m_pIbAdd->Enable();
            m_pIbInfo->Enable();
            m_pIbRemove->Enable(false );
            m_pFtComment->SetText(m_pEdComment->GetText());
            m_xIbAdd->set_sensitive(true);
            m_xIbInfo->set_sensitive(true);
            m_xIbRemove->set_sensitive(false );
            m_xFtComment->set_label(m_xEdComment->get_text());

        }
        UpdateOptions_Impl( false );
@@ -1299,7 +1248,7 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )


    // category-ListBox -------------------------------------------------
    if (pLb == m_pLbCategory || pLb == m_pLbCurrency)
    if (pLb == m_xLbCategory.get() || pLb == m_xLbCurrency.get())
    {
        UpdateFormatListBox_Impl( true, true );
        EditHdl_Impl( nullptr );
@@ -1310,10 +1259,10 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )


    // language/country-ListBox ----------------------------------------------
    if (pLb == m_pLbLanguage)
    if (pLb == m_xLbLanguage->get_widget())
    {
        UpdateFormatListBox_Impl( false, true );
        EditHdl_Impl(m_pEdFormat);
        EditHdl_Impl(m_xEdFormat.get());

        return;
    }
@@ -1321,7 +1270,7 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )


/*************************************************************************
#*  Method:    ClickHdl_Impl, PushButton* pIB
#*  Method:    ClickHdl_Impl, weld::Button& rIB
#*------------------------------------------------------------------------
#*
#*  Class:      SvxNumberFormatTabPage
@@ -1332,21 +1281,22 @@ void SvxNumberFormatTabPage::SelFormatHdl_Impl(void * pLb )
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, Button*, pIB, void)
IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, weld::Button&, rIB, void)
{
    Click_Impl(static_cast<PushButton*>(pIB));
    Click_Impl(rIB);
}
bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)

bool SvxNumberFormatTabPage::Click_Impl(weld::Button& rIB)
{
    sal_uLong       nReturn = 0;
    const sal_uLong nReturnChanged  = 0x1;  // THE boolean return value
    const sal_uLong nReturnAdded    = 0x2;  // temp: format added
    const sal_uLong nReturnOneArea  = 0x4;  // temp: one area but category changed => ignored

    if (pIB == m_pIbAdd)
    if (&rIB == m_xIbAdd.get())
    {   // Also called from FillItemSet() if a temporary currency format has
        // to be added, not only if the Add button is enabled.
        OUString               aFormat = m_pEdFormat->GetText();
        OUString               aFormat = m_xEdFormat->get_text();
        std::vector<OUString> aEntryList;
        std::vector<OUString> a2EntryList;
        sal_uInt16           nCatLbSelPos = 0;
@@ -1360,24 +1310,22 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
        if ( bAdded )
            nReturn |= nReturnChanged | nReturnAdded;

        if (pLastActivWindow == m_pEdComment)
        if (m_xEdComment->get_visible())
        {
            m_pEdFormat->GrabFocus();
            m_pEdComment->Hide();
            m_pFtComment->Show();
            m_pFtComment->SetText(m_pEdComment->GetText());
            m_xEdFormat->grab_focus();
            m_xEdComment->hide();
            m_xFtComment->show();
            m_xFtComment->set_label(m_xEdComment->get_text());
        }

        if ( !nErrPos ) // Syntax ok?
        {
            // May be sorted under a different locale if LCID was parsed.
            if (bAdded)
                m_pLbLanguage->SelectLanguage( pNumFmtShell->GetCurLanguage() );
                m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage());

            if(nCatLbSelPos==CAT_CURRENCY)
            {
                m_pLbCurrency->SelectEntryPos(static_cast<sal_uInt16>(pNumFmtShell->GetCurrencySymbol()));
            }
            if (nCatLbSelPos==CAT_CURRENCY)
                set_active_currency(pNumFmtShell->GetCurrencySymbol());

            if(bOneAreaFlag && (nFixedCategory!=nCatLbSelPos))
            {
@@ -1387,8 +1335,8 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
                                            nFmtLbSelPos,
                                            a2EntryList);
                a2EntryList.clear();
                m_pEdFormat->GrabFocus();
                m_pEdFormat->SetSelection( Selection( 0, SELECTION_MAX ) );
                m_xEdFormat->grab_focus();
                m_xEdFormat->select_region(0, -1);
                nReturn |= nReturnOneArea;
            }
            else
@@ -1402,20 +1350,20 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
                        SetCategory(nCatLbSelPos );

                    FillFormatListBox_Impl( aEntryList );
                    if(m_pEdComment->GetText()!=m_pLbCategory->GetEntry(1))
                    if (m_xEdComment->get_text()!=m_xLbCategory->get_text(1))
                    {
                        pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
                                                    m_pEdComment->GetText());
                                                    m_xEdComment->get_text());
                    }
                    else
                    {
                        pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
                                                        OUString());
                    }
                    m_pLbFormat->SelectEntryPos( static_cast<sal_uInt16>(nFmtLbSelPos) );
                    m_pEdFormat->SetText( aFormat );
                    m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
                    m_xEdFormat->set_text( aFormat );

                    m_pEdComment->SetText(m_pLbCategory->GetEntry(1));    // String for user defined
                    m_xEdComment->set_text(m_xLbCategory->get_text(1));    // String for user defined

                    ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
                }
@@ -1423,18 +1371,18 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
        }
        else // syntax error
        {
            m_pEdFormat->GrabFocus();
            m_pEdFormat->SetSelection( Selection( nErrPos == -1 ? SELECTION_MAX : nErrPos, SELECTION_MAX ) );
            m_xEdFormat->grab_focus();
            m_xEdFormat->select_region(nErrPos == -1 ? m_xEdFormat->get_text().getLength() : nErrPos, -1);
        }
        EditHdl_Impl(m_pEdFormat);
        EditHdl_Impl(m_xEdFormat.get());
        nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));

        aEntryList.clear();
        a2EntryList.clear();
    }
    else if (pIB == m_pIbRemove)
    else if (&rIB == m_xIbRemove.get())
    {
        OUString              aFormat = m_pEdFormat->GetText();
        OUString              aFormat = m_xEdFormat->get_text();
        std::vector<OUString> aEntryList;
        sal_uInt16           nCatLbSelPos = 0;
        short                nFmtLbSelPos = SELPOS_NONE;
@@ -1444,7 +1392,7 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
                                    nFmtLbSelPos,
                                    aEntryList );

        m_pEdComment->SetText(m_pLbCategory->GetEntry(1));
        m_xEdComment->set_text(m_xLbCategory->get_text(1));

        if( nFmtLbSelPos>=0 && static_cast<size_t>(nFmtLbSelPos)<aEntryList.size() )
        {
@@ -1460,35 +1408,35 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
                else
                    SetCategory(nCatLbSelPos );

            m_pLbFormat->SelectEntryPos( static_cast<sal_uInt16>(nFmtLbSelPos) );
            m_pEdFormat->SetText( aFormat );
            m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
            m_xEdFormat->set_text( aFormat );
            ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
        }
        else
        {
            // set to "all/standard"
            SetCategory(0);
            SelFormatHdl_Impl(m_pLbCategory);
            SelFormatHdl_Impl(m_xLbCategory.get());
        }

        EditHdl_Impl(m_pEdFormat);
        EditHdl_Impl(m_xEdFormat.get());

        aEntryList.clear();
    }
    else if (pIB == m_pIbInfo)
    else if (&rIB == m_xIbInfo.get())
    {
        if(!(pLastActivWindow == m_pEdComment))
        if (!m_xEdComment->get_visible())
        {
            m_pEdComment->SetText(m_pFtComment->GetText());
            m_pEdComment->Show();
            m_pFtComment->Hide();
            m_pEdComment->GrabFocus();
            m_xEdComment->set_text(m_xFtComment->get_label());
            m_xEdComment->show();
            m_xFtComment->hide();
            m_xEdComment->grab_focus();
        }
        else
        {
            m_pEdFormat->GrabFocus();
            m_pEdComment->Hide();
            m_pFtComment->Show();
            m_xEdFormat->grab_focus();
            m_xEdComment->hide();
            m_xFtComment->show();
        }
    }

@@ -1508,59 +1456,59 @@ bool SvxNumberFormatTabPage::Click_Impl(PushButton* pIB)
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, EditModifyHdl_Impl, Edit&, rEdit, void )
IMPL_LINK(SvxNumberFormatTabPage, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
{
    EditHdl_Impl(&rEdit);
}
void SvxNumberFormatTabPage::EditHdl_Impl( Edit const * pEdFormat )

void SvxNumberFormatTabPage::EditHdl_Impl(const weld::Entry* pEdFormat)
{
    sal_uInt32 nCurKey = NUMKEY_UNDEFINED;

    if ( m_pEdFormat->GetText().isEmpty() )
    if ( m_xEdFormat->get_text().isEmpty() )
    {
        m_pIbAdd->Enable(false );
        m_pIbRemove->Enable(false );
        m_pIbInfo->Enable(false );
        m_pFtComment->SetText(OUString());
        m_xIbAdd->set_sensitive(false );
        m_xIbRemove->set_sensitive(false );
        m_xIbInfo->set_sensitive(false );
        m_xFtComment->set_label(OUString());
    }
    else
    {
        OUString aFormat = m_pEdFormat->GetText();
        OUString aFormat = m_xEdFormat->get_text();
        MakePreviewText( aFormat );

        if ( pNumFmtShell->FindEntry( aFormat, &nCurKey ) )
        {
            m_pIbAdd->Enable(false );
            m_xIbAdd->set_sensitive(false );
            bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );

            m_pIbRemove->Enable(bUserDef);
            m_pIbInfo->Enable(bUserDef);
            m_xIbRemove->set_sensitive(bUserDef);
            m_xIbInfo->set_sensitive(bUserDef);

            if(bUserDef)
            {
                sal_uInt16 nTmpCurPos=pNumFmtShell->FindCurrencyFormat(aFormat );

                if(nTmpCurPos!=sal_uInt16(-1))
                    m_pLbCurrency->SelectEntryPos(nTmpCurPos);
                if (nTmpCurPos != sal_uInt16(-1))
                    set_active_currency(nTmpCurPos);
            }
            short nPosi=pNumFmtShell->GetListPos4Entry(aFormat);
            if(nPosi>=0)
                m_pLbFormat->SelectEntryPos( static_cast<sal_uInt16>(nPosi));
                m_xLbFormat->select(static_cast<sal_uInt16>(nPosi));

        }
        else
        {

            m_pIbAdd->Enable();
            m_pIbInfo->Enable();
            m_pIbRemove->Enable(false );
            m_xIbAdd->set_sensitive(true);
            m_xIbInfo->set_sensitive(true);
            m_xIbRemove->set_sensitive(false );

            m_pFtComment->SetText(m_pEdComment->GetText());
            m_xFtComment->set_label(m_xEdComment->get_text());

        }
    }

    if ( pEdFormat )
    if (pEdFormat)
    {
        pNumFmtShell->SetCurNumFmtKey( nCurKey );
        UpdateOptions_Impl( true );
@@ -1579,71 +1527,67 @@ void SvxNumberFormatTabPage::EditHdl_Impl( Edit const * pEdFormat )
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, OptClickHdl_Impl, Button*, pOptCtrl, void )
IMPL_LINK(SvxNumberFormatTabPage, OptClickHdl_Impl, weld::Button&, rOptCtrl, void)
{
    OptHdl_Impl(pOptCtrl);
    OptHdl_Impl(&rOptCtrl);
}
IMPL_LINK( SvxNumberFormatTabPage, OptEditHdl_Impl, Edit&, rEdit, void )

IMPL_LINK(SvxNumberFormatTabPage, OptEditHdl_Impl, weld::SpinButton&, rEdit, void)
{
    OptHdl_Impl(&rEdit);
}
void SvxNumberFormatTabPage::OptHdl_Impl( void const * pOptCtrl )

void SvxNumberFormatTabPage::OptHdl_Impl(const weld::Widget* pOptCtrl)
{
    if (   (pOptCtrl == m_pEdLeadZeroes)
        || (pOptCtrl == m_pEdDecimals)
        || (pOptCtrl == m_pEdDenominator)
        || (pOptCtrl == m_pBtnNegRed)
        || (pOptCtrl == m_pBtnThousand)
        || (pOptCtrl == m_pBtnEngineering) )
    if (   pOptCtrl == m_xEdLeadZeroes.get()
        || pOptCtrl == m_xEdDecimals.get()
        || pOptCtrl == m_xEdDenominator.get()
        || pOptCtrl == m_xBtnNegRed.get()
        || pOptCtrl == m_xBtnThousand.get()
        || pOptCtrl == m_xBtnEngineering.get())
    {
        OUString          aFormat;
        bool          bThousand  = ( m_pBtnThousand->IsVisible() && m_pBtnThousand->IsEnabled() && m_pBtnThousand->IsChecked() )
                                || ( m_pBtnEngineering->IsVisible() && m_pBtnEngineering->IsEnabled() && m_pBtnEngineering->IsChecked() );
        bool          bNegRed    =   m_pBtnNegRed->IsEnabled() && m_pBtnNegRed->IsChecked();
        sal_uInt16    nPrecision = (m_pEdDecimals->IsEnabled() && m_pEdDecimals->IsVisible())
                                 ? static_cast<sal_uInt16>(m_pEdDecimals->GetValue())
                                 : ( (m_pEdDenominator->IsEnabled() && m_pEdDenominator->IsVisible())
                                   ? static_cast<sal_uInt16>(m_pEdDenominator->GetValue())
        bool          bThousand  = ( m_xBtnThousand->get_visible() && m_xBtnThousand->get_sensitive() && m_xBtnThousand->get_active() )
                                || ( m_xBtnEngineering->get_visible() && m_xBtnEngineering->get_sensitive() && m_xBtnEngineering->get_active() );
        bool          bNegRed    =   m_xBtnNegRed->get_sensitive() && m_xBtnNegRed->get_active();
        sal_uInt16    nPrecision = (m_xEdDecimals->get_sensitive() && m_xEdDecimals->get_visible())
                                 ? static_cast<sal_uInt16>(m_xEdDecimals->get_value())
                                 : ( (m_xEdDenominator->get_sensitive() && m_xEdDenominator->get_visible())
                                   ? static_cast<sal_uInt16>(m_xEdDenominator->get_value())
                                   : sal_uInt16(0) );
        sal_uInt16    nLeadZeroes = (m_pEdLeadZeroes->IsEnabled())
                                 ? static_cast<sal_uInt16>(m_pEdLeadZeroes->GetValue())
        sal_uInt16    nLeadZeroes = (m_xEdLeadZeroes->get_sensitive())
                                 ? static_cast<sal_uInt16>(m_xEdLeadZeroes->get_value())
                                 : sal_uInt16(0);
        if ( pNumFmtShell->GetStandardName() == m_pEdFormat->GetText() )
        if ( pNumFmtShell->GetStandardName() == m_xEdFormat->get_text() )
        {
            m_pEdDecimals->SetValue( nPrecision );
            m_xEdDecimals->set_value(nPrecision);
        }

        pNumFmtShell->MakeFormat( aFormat,
                                  bThousand, bNegRed,
                                  nPrecision, nLeadZeroes,
                                  static_cast<sal_uInt16>(m_pLbFormat->GetSelectedEntryPos()) );
                                  static_cast<sal_uInt16>(m_xLbFormat->get_selected_index()) );

        m_pEdFormat->SetText( aFormat );
        m_xEdFormat->set_text( aFormat );
        MakePreviewText( aFormat );

        if ( pNumFmtShell->FindEntry( aFormat ) )
        {
            m_pIbAdd->Enable(false );
            m_xIbAdd->set_sensitive(false );
            bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );
            m_pIbRemove->Enable(bUserDef);
            m_pIbInfo->Enable(bUserDef);
            EditHdl_Impl(m_pEdFormat);
            m_xIbRemove->set_sensitive(bUserDef);
            m_xIbInfo->set_sensitive(bUserDef);
            EditHdl_Impl(m_xEdFormat.get());

        }
        else
        {
            EditHdl_Impl( nullptr );
            m_pLbFormat->SetNoSelection();
            m_xLbFormat->select(-1);
        }
    }
}

IMPL_LINK_NOARG(SvxNumberFormatTabPage, TimeHdl_Impl, Timer *, void)
{
    pLastActivWindow=nullptr;
}


/*************************************************************************
#*  Method:    LostFocusHdl_Impl
#*------------------------------------------------------------------------
@@ -1655,22 +1599,18 @@ IMPL_LINK_NOARG(SvxNumberFormatTabPage, TimeHdl_Impl, Timer *, void)
#*
#************************************************************************/

IMPL_LINK( SvxNumberFormatTabPage, LostFocusHdl_Impl, Control&, rControl, void)
IMPL_LINK_NOARG(SvxNumberFormatTabPage, LostFocusHdl_Impl, weld::Widget&, void)
{
    Edit* pEd = static_cast<Edit*>(&rControl);
    if (pEd == m_pEdComment)
    if (!pNumFmtShell)
        return;
    m_xFtComment->set_label(m_xEdComment->get_text());
    m_xEdComment->hide();
    m_xFtComment->show();
    if(!m_xIbAdd->get_sensitive())
    {
        aResetWinTimer.Start();
        m_pFtComment->SetText(m_pEdComment->GetText());
        m_pEdComment->Hide();
        m_pFtComment->Show();
        if(!m_pIbAdd->IsEnabled())
        {
            sal_uInt16  nSelPos = static_cast<sal_uInt16>(m_pLbFormat->GetSelectedEntryPos());
            pNumFmtShell->SetComment4Entry(nSelPos,
                                        m_pEdComment->GetText());
            m_pEdComment->SetText(m_pLbCategory->GetEntry(1));    // String for user defined
        }
        sal_uInt16 nSelPos = m_xLbFormat->get_selected_index();
        pNumFmtShell->SetComment4Entry(nSelPos, m_xEdComment->get_text());
        m_xEdComment->set_text(m_xLbCategory->get_text(1));    // String for user defined
    }
}

@@ -1726,7 +1666,7 @@ void SvxNumberFormatTabPage::MakePreviewText( const OUString& rFormat )
    OUString aPreviewString;
    Color* pPreviewColor = nullptr;
    pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor );
    m_pWndPreview->NotifyChange( aPreviewString, pPreviewColor );
    m_aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
}

void SvxNumberFormatTabPage::ChangePreviewText( sal_uInt16 nPos )
@@ -1734,24 +1674,7 @@ void SvxNumberFormatTabPage::ChangePreviewText( sal_uInt16 nPos )
    OUString aPreviewString;
    Color* pPreviewColor = nullptr;
    pNumFmtShell->FormatChanged( nPos, aPreviewString, pPreviewColor );
    m_pWndPreview->NotifyChange( aPreviewString, pPreviewColor );
}

bool SvxNumberFormatTabPage::PreNotify( NotifyEvent& rNEvt )
{
    if(rNEvt.GetType()==MouseNotifyEvent::LOSEFOCUS)
    {
        if ( rNEvt.GetWindow() == dynamic_cast<const  vcl::Window* >( m_pEdComment.get() ) && !m_pEdComment->IsVisible() )
        {
            pLastActivWindow = nullptr;
        }
        else
        {
            pLastActivWindow = rNEvt.GetWindow();
        }
    }

    return SfxTabPage::PreNotify( rNEvt );
    m_aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
}

void SvxNumberFormatTabPage::FillCurrencyBox()
@@ -1761,23 +1684,22 @@ void SvxNumberFormatTabPage::FillCurrencyBox()
    sal_uInt16  nSelPos=0;
    pNumFmtShell->GetCurrencySymbols(aList, &nSelPos);

    for(std::vector<OUString>::iterator i = aList.begin() + 1;i != aList.end(); ++i)
        m_pLbCurrency->InsertEntry(*i);
    m_xLbCurrency->freeze();
    m_xLbCurrency->clear();
    bLegacyAutomaticCurrency = false;
    for (std::vector<OUString>::iterator i = aList.begin() + 1;i != aList.end(); ++i)
        m_xLbCurrency->append_text(*i);
    m_xLbCurrency->thaw();

    // Initially disable the "Automatically" entry. First ensure that nothing
    // is selected, else if the to be disabled (first) entry was selected it
    // would be sticky when disabled and could not be deselected!
    m_pLbCurrency->SetNoSelection();
    m_pLbCurrency->SetEntryFlags( 0, ListBoxEntryFlags::DisableSelection | ListBoxEntryFlags::DrawDisabled);
    m_pLbCurrency->SelectEntryPos(nSelPos);
    set_active_currency(nSelPos);
}

void SvxNumberFormatTabPage::SetCategory(sal_uInt16 nPos)
{
    sal_uInt16  nCurCategory = m_pLbCategory->GetSelectedEntryPos();
    sal_uInt16 nCurCategory = m_xLbCategory->get_selected_index();
    sal_uInt16 nTmpCatPos;

    if(bOneAreaFlag)
    if (bOneAreaFlag)
    {
        nTmpCatPos=nFixedCategory;
    }
@@ -1786,15 +1708,16 @@ void SvxNumberFormatTabPage::SetCategory(sal_uInt16 nPos)
        nTmpCatPos=nPos;
    }

    if(m_pLbCategory->GetEntryCount()==1 || nCurCategory!=nPos)
    if(m_xLbCategory->n_children()==1 || nCurCategory!=nPos)
    {
        if(nTmpCatPos!=CAT_CURRENCY)
            m_pLbCurrency->Hide();
            m_xLbCurrency->hide();
        else
            m_pLbCurrency->Show();
            m_xLbCurrency->show();
    }
    m_pLbCategory->SelectEntryPos(nPos);
    m_xLbCategory->select(nPos);
}

/* to support Writer text field language handling an
   additional entry needs to be inserted into the ListBox
   which marks a certain language as automatically detected
@@ -1802,11 +1725,10 @@ void SvxNumberFormatTabPage::SetCategory(sal_uInt16 nPos)
*/
void SvxNumberFormatTabPage::AddAutomaticLanguage_Impl(LanguageType eAutoLang, bool bSelect)
{
    m_pLbLanguage->RemoveLanguage(LANGUAGE_SYSTEM);
    const sal_Int32 nPos = m_pLbLanguage->InsertEntry(sAutomaticEntry);
    m_pLbLanguage->SetEntryData(nPos, reinterpret_cast<void*>(static_cast<sal_uInt16>(eAutoLang)));
    if(bSelect)
        m_pLbLanguage->SelectEntryPos(nPos);
    m_xLbLanguage->remove_id(LANGUAGE_SYSTEM);
    m_xLbLanguage->append(eAutoLang, sAutomaticLangEntry);
    if (bSelect)
        m_xLbLanguage->set_active_id(eAutoLang);
}

void SvxNumberFormatTabPage::PageCreated(const SfxAllItemSet& aSet)
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index a4ef2e4..9a902fc 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -97,7 +97,7 @@ SvxColorTabPage::SvxColorTabPage(TabPageParent pParent, const SfxItemSet& rInAtt
    , m_xValSetColorListWin(new weld::CustomWeld(*m_xBuilder, "colorset", *m_xValSetColorList))
    , m_xValSetRecentListWin(new weld::CustomWeld(*m_xBuilder, "recentcolorset", *m_xValSetRecentList))
{
    Size aSize = LogicToPixel(Size(100 , 120), MapMode(MapUnit::MapAppFont));
    Size aSize = LogicToPixel(Size(100 , 80), MapMode(MapUnit::MapAppFont));
    m_xValSetColorList->set_size_request(aSize.Width(), aSize.Height());
    aSize = LogicToPixel(Size(34 , 25), MapMode(MapUnit::MapAppFont));
    m_aCtlPreviewOld.set_size_request(aSize.Width(), aSize.Height());
diff --git a/cui/uiconfig/ui/numberingformatpage.ui b/cui/uiconfig/ui/numberingformatpage.ui
index c5724c2..b0a50e6 100644
--- a/cui/uiconfig/ui/numberingformatpage.ui
+++ b/cui/uiconfig/ui/numberingformatpage.ui
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="upper">20</property>
    <property name="step_increment">1</property>
@@ -13,20 +12,25 @@
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="adjustment3">
    <property name="upper">20</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkImage" id="image1">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">svx/res/nu02.png</property>
    <property name="icon_name">svx/res/nu02.png</property>
  </object>
  <object class="GtkImage" id="image2">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">svx/res/nu01.png</property>
    <property name="icon_name">svx/res/nu01.png</property>
  </object>
  <object class="GtkImage" id="image3">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">svx/res/nu03.png</property>
    <property name="icon_name">svx/res/nu03.png</property>
  </object>
  <object class="GtkListStore" id="liststore1">
    <columns>
@@ -69,20 +73,23 @@
      </row>
    </data>
  </object>
  <object class="GtkListStore" id="liststore2">
  <object class="GtkListStore" id="liststore3">
    <columns>
      <!-- column-name gchararray1 -->
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
      <!-- column-name image -->
      <column type="GdkPixbuf"/>
      <!-- column-name textcolor -->
      <column type="GdkRGBA"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes" context="numberingformatpage|liststore2">Automatically</col>
      </row>
    </data>
  </object>
  <object class="GtkGrid" id="NumberingFormatPage">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="hexpand">True</property>
    <property name="vexpand">True</property>
    <property name="border_width">6</property>
    <property name="row_spacing">6</property>
    <property name="column_spacing">12</property>
@@ -233,10 +240,10 @@
                    <property name="orientation">vertical</property>
                    <property name="spacing">6</property>
                    <child>
                      <object class="GtkSpinButton" id="decimalsed">
                      <object class="GtkSpinButton" id="denominatored">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="adjustment">adjustment2</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -245,10 +252,10 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="denominatored">
                      <object class="GtkSpinButton" id="decimalsed">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="adjustment">adjustment2</property>
                        <property name="adjustment">adjustment1</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -266,7 +273,7 @@
                  <object class="GtkSpinButton" id="leadzerosed">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="adjustment">adjustment1</property>
                    <property name="adjustment">adjustment3</property>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
@@ -282,13 +289,12 @@
                    <property name="orientation">vertical</property>
                    <property name="spacing">6</property>
                    <child>
                      <object class="GtkLabel" id="decimalsft">
                        <property name="visible">True</property>
                      <object class="GtkLabel" id="denominatorft">
                        <property name="can_focus">False</property>
                        <property name="xalign">1</property>
                        <property name="label" translatable="yes" context="numberingformatpage|decimalsft">_Decimal places:</property>
                        <property name="label" translatable="yes" context="numberingformatpage|denominatorft">Den_ominator places:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">decimalsed</property>
                        <property name="mnemonic_widget">denominatored</property>
                        <property name="xalign">1</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -297,13 +303,13 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="denominatorft">
                        <property name="visible">False</property>
                      <object class="GtkLabel" id="decimalsft">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">1</property>
                        <property name="label" translatable="yes" context="numberingformatpage|denominatorft">Den_ominator places:</property>
                        <property name="label" translatable="yes" context="numberingformatpage|decimalsft">_Decimal places:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">denominatored</property>
                        <property name="mnemonic_widget">decimalsed</property>
                        <property name="xalign">1</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -321,10 +327,10 @@
                  <object class="GtkLabel" id="leadzerosft">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="xalign">1</property>
                    <property name="label" translatable="yes" context="numberingformatpage|leadzerosft">Leading _zeroes:</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">leadzerosed</property>
                    <property name="xalign">1</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
@@ -354,9 +360,8 @@
                    <property name="orientation">vertical</property>
                    <property name="spacing">6</property>
                    <child>
                      <object class="GtkCheckButton" id="thousands">
                        <property name="label" translatable="yes" context="numberingformatpage|thousands">_Thousands separator</property>
                        <property name="visible">True</property>
                      <object class="GtkCheckButton" id="engineering">
                        <property name="label" translatable="yes" context="numberingformatpage|engineering">_Engineering notation</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">False</property>
                        <property name="use_underline">True</property>
@@ -370,9 +375,9 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkCheckButton" id="engineering">
                        <property name="label" translatable="yes" context="numberingformatpage|engineering">_Engineering notation</property>
                        <property name="visible">False</property>
                      <object class="GtkCheckButton" id="thousands">
                        <property name="label" translatable="yes" context="numberingformatpage|thousands">_Thousands separator</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">False</property>
                        <property name="use_underline">True</property>
@@ -430,21 +435,37 @@
              <object class="GtkAlignment" id="alignment3">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="vexpand">True</property>
                <property name="top_padding">6</property>
                <child>
                  <object class="GtkScrolledWindow" id="scrolledwindow1">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="vexpand">True</property>
                    <property name="shadow_type">in</property>
                    <child>
                      <object class="GtkTreeView" id="categorylb:border">
                      <object class="GtkTreeView" id="categorylb">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="has_focus">True</property>
                        <property name="vexpand">True</property>
                        <property name="model">liststore1</property>
                        <property name="headers_visible">False</property>
                        <property name="headers_clickable">False</property>
                        <property name="search_column">0</property>
                        <property name="show_expanders">False</property>
                        <child internal-child="selection">
                          <object class="GtkTreeSelection" id="treeview-selection"/>
                          <object class="GtkTreeSelection" id="treeview-selection1"/>
                        </child>
                        <child>
                          <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                            <child>
                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
                              <attributes>
                                <attribute name="text">0</attribute>
                              </attributes>
                            </child>
                          </object>
                        </child>
                      </object>
                    </child>
@@ -458,7 +479,7 @@
                <property name="can_focus">False</property>
                <property name="label" translatable="yes" context="numberingformatpage|categoryft">C_ategory</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">categorylb:border</property>
                <property name="mnemonic_widget">categorylb</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -494,13 +515,51 @@
                    <property name="vexpand">True</property>
                    <property name="row_spacing">6</property>
                    <child>
                      <object class="svxlo-SvxFontListBox" id="formatlb:border">
                      <object class="GtkComboBoxText" id="currencylb">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="valign">start</property>
                        <property name="hexpand">True</property>
                        <items>
                          <item translatable="yes" context="numberingformatpage|liststore2">Automatically</item>
                        </items>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">0</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkScrolledWindow">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <child internal-child="selection">
                          <object class="GtkTreeSelection" id="Font List-selection1"/>
                        <property name="shadow_type">in</property>
                        <child>
                          <object class="GtkTreeView" id="formatlb">
                            <property name="visible">True</property>
                            <property name="can_focus">True</property>
                            <property name="hexpand">True</property>
                            <property name="vexpand">True</property>
                            <property name="model">liststore3</property>
                            <property name="headers_visible">False</property>
                            <property name="headers_clickable">False</property>
                            <property name="search_column">0</property>
                            <property name="show_expanders">False</property>
                            <child internal-child="selection">
                              <object class="GtkTreeSelection" id="treeview-selection2"/>
                            </child>
                            <child>
                              <object class="GtkTreeViewColumn" id="treeviewcolumn2">
                                <child>
                                  <object class="GtkCellRendererText" id="cellrenderertext2"/>
                                  <attributes>
                                    <attribute name="text">0</attribute>
                                    <attribute name="foreground-rgba">3</attribute>
                                  </attributes>
                                </child>
                              </object>
                            </child>
                          </object>
                        </child>
                      </object>
                      <packing>
@@ -508,19 +567,6 @@
                        <property name="top_attach">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBox" id="currencylb">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="valign">start</property>
                        <property name="hexpand">True</property>
                        <property name="model">liststore2</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">0</property>
                      </packing>
                    </child>
                  </object>
                </child>
              </object>
@@ -531,7 +577,6 @@
                <property name="can_focus">False</property>
                <property name="label" translatable="yes" context="numberingformatpage|formatft">Fo_rmat</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">formatlb:border</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -564,7 +609,7 @@
                    <property name="vexpand">True</property>
                    <property name="row_spacing">6</property>
                    <child>
                      <object class="svxcorelo-SvxLanguageBox" id="languagelb">
                      <object class="GtkComboBoxText" id="languagelb">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="valign">start</property>
@@ -575,19 +620,6 @@
                      </packing>
                    </child>
                    <child>
                      <object class="cuilo-SvxNumberPreview" id="preview">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="valign">end</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkCheckButton" id="sourceformat">
                        <property name="label" translatable="yes" context="numberingformatpage|sourceformat">So_urce format</property>
                        <property name="can_focus">True</property>
@@ -602,6 +634,32 @@
                        <property name="top_attach">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkScrolledWindow">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="valign">end</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="shadow_type">in</property>
                        <child>
                          <object class="GtkViewport">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <child>
                              <object class="GtkDrawingArea" id="preview">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                              </object>
                            </child>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">2</property>
                      </packing>
                    </child>
                  </object>
                </child>
              </object>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index c417264..19bef6a 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -191,9 +191,6 @@
    <glade-widget-class title="Gallery Preview" name="svxcorelo-GalleryPreview"
                        generic-name="Gallery Preview" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Number Preview" name="cuilo-SvxNumberPreview"
                        generic-name="Number Preview Window" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview"
                        generic-name="Html Attribute Preview" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
@@ -335,9 +332,6 @@
    <glade-widget-class title="Glossary List" name="swuilo-SwGlossaryGroupTLB"
                        generic-name="Glossary List" parent="GtkTreeView"
                        icon-name="widget-gtk-treeview"/>
    <glade-widget-class title="Font List" name="svxlo-SvxFontListBox"
                        generic-name="Font List" parent="GtkTreeView"
                        icon-name="widget-gtk-treeview"/>
    <glade-widget-class title="Macro Library" name="basctllo-TreeListBox"
                        generic-name="Macro Library List" parent="GtkTreeView"
                        icon-name="widget-gtk-treeview"/>
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index c16c3ac..5d4ae84 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -165,15 +165,24 @@ public:
    sal_Int32           SaveEditedAsEntry();

    void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
    void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_xControl->connect_focus_in(rLink); }
    void save_active_id() { m_eSavedLanguage = get_active_id(); }
    LanguageType get_saved_active_id() const { return m_eSavedLanguage; }
    bool get_active_id_changed_from_saved() const { return m_eSavedLanguage != get_active_id(); }
    void show() { m_xControl->show(); }
    void hide() { m_xControl->hide(); }
    void show(bool bShow) { if (bShow) show(); else hide(); }
    void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
    void set_active(int nPos) { m_xControl->set_active(nPos); }
    int get_active() const { return m_xControl->get_active(); }
    void set_active_id(const LanguageType eLangType);
    OUString get_active_text() const { return m_xControl->get_active_text(); }
    bool get_visible() const { return m_xControl->get_visible(); }
    LanguageType get_active_id() const;
    void remove_id(const LanguageType eLangType);
    void append(const LanguageType eLangType, const OUString& rStr);
    int find_text(const OUString& rStr) const { return m_xControl->find_text(rStr); }
    const weld::ComboBox* get_widget() const { return m_xControl.get(); }
};

class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index fbc6bbc..a61c1b9 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -180,6 +180,8 @@ public:
    void*               GetEntryData( sal_Int32  nPos ) const;
    void*               GetSelectedEntryData() const { return GetEntryData(GetSelectedEntryPos()); }

    void                SetEntryTextColor(sal_Int32 nPos, const Color* pTextColor);

    /** this methods stores a combination of flags from the
        ListBoxEntryFlags::* defines at the given entry.
        See description of the possible ListBoxEntryFlags::* flags
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index a9f5c1c..1ca91e7 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -327,13 +327,6 @@ public:
        insert(-1, rId, rStr, &rImage);
    }

    virtual int n_children() const = 0;
    virtual void clear() = 0;
    virtual int get_height_rows(int nRows) const = 0;

    virtual void set_selection_mode(bool bMultiple) = 0;
    virtual int count_selected_rows() const = 0;

    void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; }
    void connect_row_activated(const Link<TreeView&, void>& rLink) { m_aRowActivatedHdl = rLink; }

@@ -344,6 +337,7 @@ public:
    virtual void remove(int pos) = 0;
    virtual void set_top_entry(int pos) = 0;
    virtual std::vector<int> get_selected_rows() const = 0;
    virtual void set_font_color(int pos, const Color& rColor) const = 0;

    //by text
    virtual OUString get_text(int pos) const = 0;
@@ -374,6 +368,13 @@ public:
    //all of them
    void select_all() { unselect(-1); }
    void unselect_all() { select(-1); }

    virtual int n_children() const = 0;
    virtual void clear() = 0;
    virtual int get_height_rows(int nRows) const = 0;

    virtual void set_selection_mode(bool bMultiple) = 0;
    virtual int count_selected_rows() const = 0;
};

class VCL_DLLPUBLIC Button : virtual public Container
diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py
index 23f19bf..4ebcfdd 100644
--- a/sc/qa/uitest/calc_tests/formatCells.py
+++ b/sc/qa/uitest/calc_tests/formatCells.py
@@ -75,7 +75,7 @@ class formatCell(UITestCase):
        xformatted = xDialog.getChild("formatted")

        self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number")
        self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "\u202aEnglish (USA)\u202c")
        self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)")
        self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1")
        self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2")
        self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true")
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 7814f443c..a0c7bc7 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -502,6 +502,16 @@ LanguageType LanguageBox::get_active_id() const
        return LANGUAGE_DONTKNOW;
}

void LanguageBox::remove_id(const LanguageType eLangType)
{
    m_xControl->remove_id(OUString::number(static_cast<sal_uInt16>(eLangType)));
}

void LanguageBox::append(const LanguageType eLangType, const OUString& rStr)
{
    m_xControl->append(OUString::number(static_cast<sal_uInt16>(eLangType)), rStr);
}

void LanguageBox::set_active_id(const LanguageType eLangType)
{
    // If the core uses a LangID of an imported MS document and wants to select
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index 44c27b5..5dc4e30 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -47,6 +47,7 @@ struct ImplEntryType
{
    OUString const    maStr;
    SalLayoutGlyphs   maStrGlyphs;
    std::unique_ptr<Color> mxTextColor;
    Image const       maImage;
    void*       mpUserData;
    bool        mbIsSelected;
@@ -133,6 +134,9 @@ public:
    void              SetEntryFlags( sal_Int32  nPos, ListBoxEntryFlags nFlags );
    ListBoxEntryFlags GetEntryFlags( sal_Int32  nPos ) const;

    void            SetEntryTextColor(sal_Int32 nPos, const Color* pColor);
    const Color*    GetEntryTextColor(sal_Int32 nPos) const;

    void            SelectEntry( sal_Int32  nPos, bool bSelect );

    sal_Int32       GetSelectedEntryCount() const;
@@ -424,6 +428,8 @@ public:

    void            SetEntryFlags( sal_Int32  nPos, ListBoxEntryFlags nFlags );

    void            SetEntryTextColor(sal_Int32 nPos, const Color* pTextColor) { maLBWindow->GetEntryList()->SetEntryTextColor(nPos, pTextColor); }

    void            SelectEntry( sal_Int32  nPos, bool bSelect );
    void            SetNoSelection();
    void            ResetCurrentPos()               { maLBWindow->ResetCurrentPos(); }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 10472c2..f329503 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1645,6 +1645,11 @@ public:
        m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
    }

    virtual void set_font_color(int pos, const Color& rColor) const override
    {
        m_xTreeView->SetEntryTextColor(pos, &rColor);
    }

    virtual void remove(int pos) override
    {
        m_xTreeView->RemoveEntry(pos);
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 629d160..4d3cffb 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -367,6 +367,19 @@ void* ImplEntryList::GetEntryData( sal_Int32 nPos ) const
    return pImplEntry ? pImplEntry->mpUserData : nullptr;
}

void ImplEntryList::SetEntryTextColor(sal_Int32 nPos, const Color* pColor)
{
    ImplEntryType* pImplEntry = GetEntry(nPos);
    if (pImplEntry)
        pImplEntry->mxTextColor.reset(pColor ? new Color(*pColor) : nullptr);
}

const Color* ImplEntryList::GetEntryTextColor(sal_Int32 nPos) const
{
    ImplEntryType* pImplEntry = GetEntry(nPos);
    return pImplEntry ? pImplEntry->mxTextColor.get() : nullptr;
}

void ImplEntryList::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
{
    ImplEntryType* pImplEntry = GetEntry( nPos );
@@ -1728,6 +1741,8 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 
        ApplySettings(rRenderContext);
        if (!IsEnabled())
            rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
        else if (const Color* pTextColor = mpEntryList->GetEntryTextColor(nPos))
            rRenderContext.SetTextColor(*pTextColor);
    }
    rRenderContext.SetTextFillColor();

diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index d2e419a..de64575 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -1091,6 +1091,11 @@ void* ListBox::GetEntryData( sal_Int32 nPos ) const
    return mpImplLB->GetEntryList()->GetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
}

void ListBox::SetEntryTextColor(sal_Int32 nPos, const Color* pTextColor)
{
    mpImplLB->SetEntryTextColor(nPos + mpImplLB->GetEntryList()->GetMRUCount(), pTextColor);
}

void ListBox::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
{
    mpImplLB->SetEntryFlags( nPos + mpImplLB->GetEntryList()->GetMRUCount(), nFlags );
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 2ada311..b0bc040 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3761,6 +3761,14 @@ public:
        enable_notify_events();
    }

    virtual void set_font_color(int pos, const Color& rColor) const override
    {
        GtkTreeIter iter;
        gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos);
        GdkRGBA aColor{rColor.GetRed()/255.0, rColor.GetGreen()/255.0, rColor.GetBlue()/255.0, 0};
        gtk_list_store_set(m_pListStore, &iter, 3, &aColor, -1);
    }

    virtual void remove(int pos) override
    {
        disable_notify_events();