weld conditional formatting

Change-Id: Ia9c99a17d5a95d67a412cfde959192c99caa70be
Reviewed-on: https://gerrit.libreoffice.org/71956
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx
index d2788b8..f8fa420 100644
--- a/chart2/source/controller/dialogs/res_ErrorBar.cxx
+++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx
@@ -713,11 +713,11 @@ void ErrorBarResources::isRangeFieldContentValid(weld::Entry& rEdit)

    if( bIsValid || !rEdit.get_sensitive())
    {
        rEdit.set_error(false);
        rEdit.set_message_type(weld::EntryMessageType::Normal);
    }
    else
    {
        rEdit.set_error(true);
        rEdit.set_message_type(weld::EntryMessageType::Error);
    }
}

diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx
index 00963cf..c650e79 100644
--- a/chart2/source/controller/dialogs/tp_DataSource.cxx
+++ b/chart2/source/controller/dialogs/tp_DataSource.cxx
@@ -296,7 +296,7 @@ bool DataSourceTabPage::isRangeFieldContentValid(weld::Entry& rEdit )
    OUString aRange(rEdit.get_text());
    bool bIsValid = aRange.isEmpty() ||
        m_rDialogModel.getRangeSelectionHelper()->verifyCellRange(aRange);
    rEdit.set_error(!bIsValid);
    rEdit.set_message_type(bIsValid ? weld::EntryMessageType::Normal : weld::EntryMessageType::Error);
    return bIsValid;
}

diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
index 6205f9f..a20a12f 100644
--- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx
+++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
@@ -279,16 +279,14 @@ bool RangeChooserTabPage::isValid()

    if( bIsValid )
    {
        m_xED_Range->set_error(false);
        m_xED_Range->set_error(false);
        m_xED_Range->set_message_type(weld::EntryMessageType::Normal);
        if( m_pTabPageNotifiable )
            m_pTabPageNotifiable->setValidPage( this );
        m_aLastValidRangeString = aRange;
    }
    else
    {
        m_xED_Range->set_error(true);
        m_xED_Range->set_error(true);
        m_xED_Range->set_message_type(weld::EntryMessageType::Error);
        if( m_pTabPageNotifiable )
            m_pTabPageNotifiable->setInvalidPage( this );
    }
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 7a450c2..581a3b8 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -277,14 +277,6 @@
                        generic-name="LanguageBox" parent="VclComboBoxText"
                        icon-name="widget-gtk-combobox"/>

    <glade-widget-class title="Reference Button" name="foruilo-RefButton"
                        generic-name="Reference Button" parent="GtkButton"
                        icon-name="widget-gtk-button"/>

    <glade-widget-class title="Reference Edit" name="foruilo-RefEdit"
                        generic-name="Reference Edit" parent="GtkEntry"
                        icon-name="widget-gtk-textentry"/>

    <glade-widget-class title="URL Entry" name="cuilo-SvxHyperURLBox"
                        generic-name="URL Entry" parent="GtkEntry"
                        icon-name="widget-gtk-textentry"/>
@@ -358,10 +350,6 @@
                        generic-name="ClientBox" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>

    <glade-widget-class title="ScCondFormatList" name="sclo-ScCondFormatList"
                        generic-name="CondFormatList" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>

    <glade-widget-class title="IndexFieldsControl" name="dbulo-DbaIndexFieldsControl"
                        generic-name="IndexFieldsControl" parent="GtkTreeView"
                        icon-name="widget-gtk-treeview"/>
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index 8cf4b21..13730ef 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -401,7 +401,7 @@ void WeldRefEdit::SetRefString( const OUString& rStr )

void WeldRefEdit::SetRefValid(bool bValid)
{
    xEntry->set_error(!bValid);
    xEntry->set_message_type(bValid ? weld::EntryMessageType::Normal : weld::EntryMessageType::Error);
}

void WeldRefEdit::SetText(const OUString& rStr)
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 15d5b60..646daa1 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -232,6 +232,9 @@ public:

    virtual VclPtr<VirtualDevice> create_virtual_device() const = 0;

    //make this widget look like a page in a notebook
    virtual void set_stack_background() = 0;

    virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() = 0;

    virtual ~Widget() {}
@@ -448,6 +451,13 @@ struct VCL_DLLPUBLIC ComboBoxEntry
    }
};

enum class EntryMessageType
{
    Normal,
    Warning,
    Error,
};

class VCL_DLLPUBLIC ComboBox : virtual public Container
{
private:
@@ -520,7 +530,7 @@ public:

    //entry related
    virtual bool has_entry() const = 0;
    virtual void set_entry_error(bool bError) = 0;
    virtual void set_entry_message_type(EntryMessageType eType) = 0;
    virtual void set_entry_text(const OUString& rStr) = 0;
    virtual void set_entry_width_chars(int nChars) = 0;
    virtual void set_entry_max_length(int nChars) = 0;
@@ -1036,7 +1046,7 @@ public:
    virtual int get_position() const = 0;
    virtual void set_editable(bool bEditable) = 0;
    virtual bool get_editable() const = 0;
    virtual void set_error(bool bShowError) = 0;
    virtual void set_message_type(EntryMessageType eType) = 0;

    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
    virtual void set_font(const vcl::Font& rFont) = 0;
@@ -1250,7 +1260,10 @@ public:

    //entry related
    virtual bool has_entry() const override { return true; }
    virtual void set_entry_error(bool bError) override { m_xEntry->set_error(bError); }
    virtual void set_entry_message_type(EntryMessageType eType) override
    {
        m_xEntry->set_message_type(eType);
    }
    virtual void set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); }
    virtual void set_entry_width_chars(int nChars) override { m_xEntry->set_width_chars(nChars); }
    virtual void set_entry_max_length(int nChars) override { m_xEntry->set_max_length(nChars); }
@@ -1502,7 +1515,7 @@ public:
    virtual void set_label(const OUString& rText) = 0;
    virtual OUString get_label() const = 0;
    virtual void set_mnemonic_widget(Widget* pTarget) = 0;
    virtual void set_error(bool bShowError) = 0;
    virtual void set_message_type(EntryMessageType eType) = 0;
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
    virtual void set_font(const vcl::Font& rFont) = 0;
};
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index eb89d0c..aa3e6f6 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -381,6 +381,7 @@ public:
    static const ScIconSetMap g_IconSetMap[];
    static const char* getIconSetName( ScIconSetType eType );
    static sal_Int32 getIconSetElements( ScIconSetType eType );
    static OUString getIconName(ScIconSetType eType, sal_Int32 nIndex);
    static BitmapEx& getBitmap(sc::IconSetBitmapMap& rBitmapMap, ScIconSetType eType, sal_Int32 nIndex);

    typedef ScIconSetFormatData::Entries_t::iterator iterator;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 53e9e63..1a932df 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -1383,8 +1383,7 @@ sal_Int32 ScIconSetFormat::getIconSetElements( ScIconSetType eType )
    return 0;
}

BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,
        ScIconSetType const eType, sal_Int32 const nIndex)
OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
{
    OUString sBitmap;

@@ -1399,6 +1398,14 @@ BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,

    assert(!sBitmap.isEmpty());

    return sBitmap;
}

BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,
        ScIconSetType const eType, sal_Int32 const nIndex)
{
    OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));

    std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
    if (itr != rIconSetBitmapMap.end())
        return itr->second;
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 0d05511..07f570b 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -25,42 +25,35 @@
#include <condformatdlgentry.hxx>
#include <condformatdlgitem.hxx>

ScCondFormatList::ScCondFormatList(vcl::Window* pParent, WinBits nStyle)
    : Control(pParent, nStyle | WB_DIALOGCONTROL)
    , mbHasScrollBar(false)
ScCondFormatList::ScCondFormatList(ScCondFormatDlg* pDialogParent,
                                   std::unique_ptr<weld::ScrolledWindow> xWindow,
                                   std::unique_ptr<weld::Container> xGrid)
    : mxScrollWindow(std::move(xWindow))
    , mxGrid(std::move(xGrid))
    , mbFrozen(false)
    , mbNewEntry(false)
    , mpScrollBar(VclPtr<ScrollBar>::Create(this, WB_VERT ))
    , mpDoc(nullptr)
    , mpDialogParent(nullptr)
    , mpDialogParent(pDialogParent)
{
    mpScrollBar->SetScrollHdl( LINK( this, ScCondFormatList, ScrollHdl ) );
    mpScrollBar->EnableDrag();
    SetControlBackground( GetSettings().GetStyleSettings().GetWindowColor() );
    SetBackground(GetControlBackground());
    mxScrollWindow->set_size_request(mxScrollWindow->get_approximate_digit_width() * 85,
                                     mxScrollWindow->get_text_height() * 23);
    mxGrid->set_stack_background();
}

weld::Window* ScCondFormatList::GetFrameWeld()
{
    return mpDialogParent->getDialog();
}

ScCondFormatList::~ScCondFormatList()
{
    disposeOnce();
}

void ScCondFormatList::dispose()
{
    Freeze();
    mpDialogParent.clear();
    mpScrollBar.disposeAndClear();
    for (auto& rxEntry : maEntries)
        rxEntry.disposeAndClear();
    maEntries.clear();
    Control::dispose();
}

void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
void ScCondFormatList::init(ScDocument* pDoc,
        const ScConditionalFormat* pFormat, const ScRangeList& rRanges,
        const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType)
{
    mpDialogParent = pDialogParent;
    mpDoc = pDoc;
    maPos = rPos;
    maRanges = rRanges;
@@ -80,9 +73,9 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
                    {
                        const ScCondFormatEntry* pConditionEntry = static_cast<const ScCondFormatEntry*>( pEntry );
                        if(pConditionEntry->GetOperation() != ScConditionMode::Direct)
                            maEntries.push_back(VclPtr<ScConditionFrmtEntry>::Create( this, mpDoc, pDialogParent, maPos, pConditionEntry ) );
                            maEntries.emplace_back(new ScConditionFrmtEntry( this, mpDoc, mpDialogParent, maPos, pConditionEntry ) );
                        else
                            maEntries.push_back(VclPtr<ScFormulaFrmtEntry>::Create( this, mpDoc, pDialogParent, maPos, pConditionEntry ) );
                            maEntries.emplace_back(new ScFormulaFrmtEntry( this, mpDoc, mpDialogParent, maPos, pConditionEntry ) );

                    }
                    break;
@@ -90,19 +83,19 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
                    {
                        const ScColorScaleFormat* pColorScale = static_cast<const ScColorScaleFormat*>( pEntry );
                        if( pColorScale->size() == 2 )
                            maEntries.push_back(VclPtr<ScColorScale2FrmtEntry>::Create( this, mpDoc, maPos, pColorScale ) );
                            maEntries.emplace_back(new ScColorScale2FrmtEntry( this, mpDoc, maPos, pColorScale ) );
                        else
                            maEntries.push_back(VclPtr<ScColorScale3FrmtEntry>::Create( this, mpDoc, maPos, pColorScale ) );
                            maEntries.emplace_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos, pColorScale ) );
                    }
                    break;
                case ScFormatEntry::Type::Databar:
                    maEntries.push_back(VclPtr<ScDataBarFrmtEntry>::Create( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) );
                    maEntries.emplace_back(new ScDataBarFrmtEntry( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) );
                    break;
                case ScFormatEntry::Type::Iconset:
                    maEntries.push_back(VclPtr<ScIconSetFrmtEntry>::Create( this, mpDoc, maPos, static_cast<const ScIconSetFormat*>( pEntry ) ) );
                    maEntries.emplace_back(new ScIconSetFrmtEntry( this, mpDoc, maPos, static_cast<const ScIconSetFormat*>( pEntry ) ) );
                    break;
                case ScFormatEntry::Type::Date:
                    maEntries.push_back(VclPtr<ScDateFrmtEntry>::Create( this, mpDoc, static_cast<const ScCondDateFormatEntry*>( pEntry ) ) );
                    maEntries.emplace_back(new ScDateFrmtEntry( this, mpDoc, static_cast<const ScCondDateFormatEntry*>( pEntry ) ) );
                    break;
            }
        }
@@ -114,19 +107,19 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
        switch(eType)
        {
            case condformat::dialog::CONDITION:
                maEntries.push_back(VclPtr<ScConditionFrmtEntry>::Create( this, mpDoc, pDialogParent, maPos ));
                maEntries.emplace_back(new ScConditionFrmtEntry( this, mpDoc, mpDialogParent, maPos ));
                break;
            case condformat::dialog::COLORSCALE:
                maEntries.push_back(VclPtr<ScColorScale3FrmtEntry>::Create( this, mpDoc, maPos ));
                maEntries.emplace_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos ));
                break;
            case condformat::dialog::DATABAR:
                maEntries.push_back(VclPtr<ScDataBarFrmtEntry>::Create( this, mpDoc, maPos ));
                maEntries.emplace_back(new ScDataBarFrmtEntry( this, mpDoc, maPos ));
                break;
            case condformat::dialog::ICONSET:
                maEntries.push_back(VclPtr<ScIconSetFrmtEntry>::Create( this, mpDoc, maPos ));
                maEntries.emplace_back(new ScIconSetFrmtEntry( this, mpDoc, maPos ));
                break;
            case condformat::dialog::DATE:
                maEntries.push_back(VclPtr<ScDateFrmtEntry>::Create( this, mpDoc ));
                maEntries.emplace_back(new ScDateFrmtEntry( this, mpDoc ));
                break;
            case condformat::dialog::NONE:
                break;
@@ -149,27 +142,6 @@ void ScCondFormatList::SetRange(const ScRangeList& rRange)
    maRanges = rRange;
}

VCL_BUILDER_FACTORY_CONSTRUCTOR(ScCondFormatList, 0)

Size ScCondFormatList::GetOptimalSize() const
{
    return LogicToPixel(Size(300, 185), MapMode(MapUnit::MapAppFont));
}

void ScCondFormatList::Resize()
{
    Control::Resize();
    RecalcAll();
}

void ScCondFormatList::queue_resize(StateChangedType eReason)
{
    Control::queue_resize(eReason);
    if (!mpDialogParent) //detects that this is during dispose
        return;
    RecalcAll();
}

std::unique_ptr<ScConditionalFormat> ScCondFormatList::GetConditionalFormat() const
{
    if(maEntries.empty())
@@ -204,68 +176,31 @@ void ScCondFormatList::RecalcAll()
    if (mbFrozen)
        return;

    sal_Int32 nTotalHeight = 0;
    sal_Int32 nIndex = 1;
    for (const auto& item : maEntries)
    {
        if (!item)
            continue;
        nTotalHeight += item->GetSizePixel().Height();
        item->SetIndex(nIndex);
        item->set_grid_top_attach(nIndex - 1);
        ++nIndex;
    }

    Size aCtrlSize = GetOutputSize();
    long nSrcBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
    if(nTotalHeight > GetSizePixel().Height())
    {
        mbHasScrollBar = true;
        mpScrollBar->SetPosSizePixel(Point(aCtrlSize.Width() -nSrcBarSize, 0),
                Size(nSrcBarSize, aCtrlSize.Height()) );
        mpScrollBar->SetRangeMax(nTotalHeight);
        mpScrollBar->SetVisibleSize(aCtrlSize.Height());
        mpScrollBar->Show();
    }
    else
    {
        mbHasScrollBar = false;
        mpScrollBar->Hide();
    }

    Point aPoint(0,-1*mpScrollBar->GetThumbPos());
    for (const auto& item : maEntries)
    {
        if (!item)
            continue;
        item->SetPosPixel(aPoint);
        Size aSize = item->GetSizePixel();
        if(mbHasScrollBar)
            aSize.setWidth( aCtrlSize.Width() - nSrcBarSize );
        else
            aSize.setWidth( aCtrlSize.Width() );
        item->SetSizePixel(aSize);

        aPoint.AdjustY(item->GetSizePixel().Height() );
    }
}

void ScCondFormatList::DoScroll(long nDelta)
IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, weld::ComboBox&, rBox, void)
{
    Point aNewPoint = mpScrollBar->GetPosPixel();
    tools::Rectangle aRect(Point(), GetOutputSize());
    aRect.AdjustRight( -(mpScrollBar->GetSizePixel().Width()) );
    Scroll( 0, -nDelta, aRect );
    mpScrollBar->SetPosPixel(aNewPoint);
    Application::PostUserEvent(LINK(this, ScCondFormatList, AfterColFormatTypeHdl), &rBox);
}

IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
IMPL_LINK(ScCondFormatList, AfterColFormatTypeHdl, void*, p, void)
{
    weld::ComboBox* pBox = static_cast<weld::ComboBox*>(p);
    EntryContainer::iterator itr = std::find_if(maEntries.begin(), maEntries.end(),
        [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
        [](const std::unique_ptr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
    if(itr == maEntries.end())
        return;

    sal_Int32 nPos = rBox.GetSelectedEntryPos();
    sal_Int32 nPos = pBox->get_active();
    switch(nPos)
    {
        case 0:
@@ -273,32 +208,28 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScColorScale2FrmtEntry>::Create( this, mpDoc, maPos );
            itr->reset(new ScColorScale2FrmtEntry(this, mpDoc, maPos));
            break;
        case 1:
            if((*itr)->GetType() == condformat::entry::COLORSCALE3)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScColorScale3FrmtEntry>::Create( this, mpDoc, maPos );
            itr->reset(new ScColorScale3FrmtEntry(this, mpDoc, maPos));
            break;
        case 2:
            if((*itr)->GetType() == condformat::entry::DATABAR)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScDataBarFrmtEntry>::Create( this, mpDoc, maPos );
            itr->reset(new ScDataBarFrmtEntry(this, mpDoc, maPos));
            break;
        case 3:
            if((*itr)->GetType() == condformat::entry::ICONSET)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScIconSetFrmtEntry>::Create( this, mpDoc, maPos );
            itr->reset(new ScIconSetFrmtEntry(this, mpDoc, maPos));
            break;
        default:
            break;
@@ -309,24 +240,24 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
    RecalcAll();
}

IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox&, rBox, void)
IMPL_LINK(ScCondFormatList, TypeListHdl, weld::ComboBox&, rBox, void)
{
    //Resolves: fdo#79021 At this point we are still inside the ListBox Select.
    //If we call maEntries.replace here then the pBox will be deleted before it
    //has finished Select and will crash on accessing its deleted this. So Post
    //to do the real work after the Select has completed
    Application::PostUserEvent(LINK(this, ScCondFormatList, AfterTypeListHdl), &rBox, true);
    Application::PostUserEvent(LINK(this, ScCondFormatList, AfterTypeListHdl), &rBox);
}

IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
{
    ListBox* pBox = static_cast<ListBox*>(p);
    weld::ComboBox* pBox = static_cast<weld::ComboBox*>(p);
    EntryContainer::iterator itr = std::find_if(maEntries.begin(), maEntries.end(),
        [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
        [](const std::unique_ptr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
    if(itr == maEntries.end())
        return;

    sal_Int32 nPos = pBox->GetSelectedEntryPos();
    sal_Int32 nPos = pBox->get_active();
    switch(nPos)
    {
        case 0:
@@ -343,8 +274,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
                    return;
            }
            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScColorScale3FrmtEntry>::Create(this, mpDoc, maPos);
            itr->reset(new ScColorScale3FrmtEntry(this, mpDoc, maPos));
            mpDialogParent->InvalidateRefData();
            (*itr)->SetActive();
            break;
@@ -353,8 +283,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
            itr->reset(new ScConditionFrmtEntry(this, mpDoc, mpDialogParent, maPos));
            mpDialogParent->InvalidateRefData();
            (*itr)->SetActive();
            break;
@@ -363,8 +292,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScFormulaFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
            itr->reset(new ScFormulaFrmtEntry(this, mpDoc, mpDialogParent, maPos));
            mpDialogParent->InvalidateRefData();
            (*itr)->SetActive();
            break;
@@ -373,8 +301,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
                return;

            Freeze();
            itr->disposeAndClear();
            *itr = VclPtr<ScDateFrmtEntry>::Create( this, mpDoc );
            itr->reset(new ScDateFrmtEntry( this, mpDoc ));
            mpDialogParent->InvalidateRefData();
            (*itr)->SetActive();
            break;
@@ -384,30 +311,28 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
    RecalcAll();
}

IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, weld::Button&, void )
{
    Freeze();
    VclPtr<ScCondFrmtEntry> pNewEntry = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
    maEntries.push_back( pNewEntry );
    maEntries.emplace_back(new ScConditionFrmtEntry(this, mpDoc, mpDialogParent, maPos));
    for(auto& rxEntry : maEntries)
    {
        rxEntry->SetInactive();
    }
    mpDialogParent->InvalidateRefData();
    pNewEntry->SetActive();
    maEntries.back()->SetActive();
    mpDialogParent->OnSelectionChange(maEntries.size() - 1, maEntries.size());
    Thaw();
    RecalcAll();
}

IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, weld::Button&, void )
{
    Freeze();
    auto itr = std::find_if(maEntries.begin(), maEntries.end(),
        [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
        [](const std::unique_ptr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
    if (itr != maEntries.end())
    {
        itr->disposeAndClear();
        maEntries.erase(itr);
    }
    mpDialogParent->InvalidateRefData();
@@ -416,13 +341,13 @@ IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
    RecalcAll();
}

IMPL_LINK_NOARG(ScCondFormatList, UpBtnHdl, Button*, void)
IMPL_LINK_NOARG(ScCondFormatList, UpBtnHdl, weld::Button&, void)
{
    Freeze();
    size_t index = 0;
    for (size_t i = 0; i < maEntries.size(); i++)
    {
        auto widget = maEntries[i];
        auto& widget = maEntries[i];
        if (widget->IsSelected() && i > 0)
        {
            std::swap(maEntries[i], maEntries[i - 1]);
@@ -436,13 +361,13 @@ IMPL_LINK_NOARG(ScCondFormatList, UpBtnHdl, Button*, void)
    RecalcAll();
}

IMPL_LINK_NOARG(ScCondFormatList, DownBtnHdl, Button*, void)
IMPL_LINK_NOARG(ScCondFormatList, DownBtnHdl, weld::Button&, void)
{
    Freeze();
    size_t index = 0;
    for (size_t i = 0; i < maEntries.size(); i++)
    {
        auto widget = maEntries[i];
        auto& widget = maEntries[i];
        if (widget->IsSelected())
        {
            index = i;
@@ -466,13 +391,10 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void )
        return;

    Freeze();
    //A child has focus, but we will hide that, so regrab to whatever new thing gets
    //shown instead of leaving it stuck in the inaccessible hidden element
    bool bReGrabFocus = HasChildPathFocus();
    size_t index = 0;
    for(size_t i = 0; i < maEntries.size(); i++)
    {
        if (maEntries[i] == &rEntry)
        if (maEntries[i].get() == &rEntry)
        {
            index = i;
        }
@@ -483,37 +405,31 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void )
    rEntry.SetActive();
    Thaw();
    RecalcAll();
    if (bReGrabFocus)
        GrabFocus();
}

IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl, ScrollBar*, void )
{
    DoScroll(mpScrollBar->GetDelta());
}

ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
    vcl::Window* pParent, ScViewData* pViewData,
    weld::Window* pParent, ScViewData* pViewData,
    const ScCondFormatDlgItem* pItem)
        : ScAnyRefDlg(pB, pCW, pParent, "ConditionalFormatDialog",
                        "modules/scalc/ui/conditionalformatdialog.ui")
        : ScAnyRefDlgController(pB, pCW, pParent,
                        "modules/scalc/ui/conditionalformatdialog.ui",
                        "ConditionalFormatDialog")
    , mpViewData(pViewData)
    , mpLastEdit(nullptr)
    , mpDlgItem(static_cast<ScCondFormatDlgItem*>(pItem->Clone()))
    , mpLastEdit(nullptr)
    , mxBtnOk(m_xBuilder->weld_button("ok"))
    , mxBtnAdd(m_xBuilder->weld_button("add"))
    , mxBtnRemove(m_xBuilder->weld_button("delete"))
    , mxBtnUp(m_xBuilder->weld_button("up"))
    , mxBtnDown(m_xBuilder->weld_button("down"))
    , mxBtnCancel(m_xBuilder->weld_button("cancel"))
    , mxFtRange(m_xBuilder->weld_label("ftassign"))
    , mxEdRange(new formula::WeldRefEdit(m_xBuilder->weld_entry("edassign")))
    , mxRbRange(new formula::WeldRefButton(m_xBuilder->weld_button("rbassign")))
    , mxCondFormList(new ScCondFormatList(this, m_xBuilder->weld_scrolled_window("listwindow"),
                                          m_xBuilder->weld_container("list")))
{
    get(mpBtnOk, "ok");
    get(mpBtnAdd, "add");
    get(mpBtnUp, "up");
    get(mpBtnDown, "down");
    get(mpBtnRemove, "delete");
    get(mpBtnCancel, "cancel");

    get(mpFtRange, "ftassign");
    get(mpEdRange, "edassign");
    mpEdRange->SetReferences(this, mpFtRange);

    get(mpRbRange, "rbassign");
    mpRbRange->SetReferences(this, mpEdRange);
    mxEdRange->SetReferences(this, mxFtRange.get());
    mxRbRange->SetReferences(this, mxEdRange.get());

    ScConditionalFormat* pFormat = nullptr;
    mnKey = mpDlgItem->GetIndex();
@@ -545,58 +461,35 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
    }
    maPos = aRange.GetTopLeftCorner();

    get(mpCondFormList, "list");
    mpCondFormList->init(mpViewData->GetDocument(), this, pFormat, aRange, maPos, mpDlgItem->GetDialogType());
    mxCondFormList->init(mpViewData->GetDocument(), pFormat, aRange, maPos, mpDlgItem->GetDialogType());

    // tdf#114603: enable setting the background to a different color;
    // relevant for GTK; see also #i75179#
    mpEdRange->SetForceControlBackground(true);

    mpBtnOk->SetClickHdl(LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
    mpBtnAdd->SetClickHdl( LINK( mpCondFormList, ScCondFormatList, AddBtnHdl ) );
    mpBtnRemove->SetClickHdl( LINK( mpCondFormList, ScCondFormatList, RemoveBtnHdl ) );
    mpBtnUp->SetClickHdl(LINK(mpCondFormList, ScCondFormatList, UpBtnHdl));
    mpBtnDown->SetClickHdl(LINK(mpCondFormList, ScCondFormatList, DownBtnHdl));
    mpBtnCancel->SetClickHdl( LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
    mpEdRange->SetModifyHdl( LINK( this, ScCondFormatDlg, EdRangeModifyHdl ) );
    mpEdRange->SetGetFocusHdl( LINK( this, ScCondFormatDlg, RangeGetFocusHdl ) );
    mxBtnOk->connect_clicked(LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
    mxBtnAdd->connect_clicked( LINK( mxCondFormList.get(), ScCondFormatList, AddBtnHdl ) );
    mxBtnRemove->connect_clicked( LINK( mxCondFormList.get(), ScCondFormatList, RemoveBtnHdl ) );
    mxBtnUp->connect_clicked(LINK(mxCondFormList.get(), ScCondFormatList, UpBtnHdl));
    mxBtnDown->connect_clicked(LINK(mxCondFormList.get(), ScCondFormatList, DownBtnHdl));
    mxBtnCancel->connect_clicked( LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
    mxEdRange->SetModifyHdl( LINK( this, ScCondFormatDlg, EdRangeModifyHdl ) );
    mxEdRange->SetGetFocusHdl( LINK( this, ScCondFormatDlg, RangeGetFocusHdl ) );

    OUString aRangeString;
    aRange.Format(aRangeString, ScRefFlags::VALID, pViewData->GetDocument(),
                    pViewData->GetDocument()->GetAddressConvention());
    mpEdRange->SetText(aRangeString);
    mxEdRange->SetText(aRangeString);

    msBaseTitle = GetText();
    msBaseTitle = m_xDialog->get_title();
    updateTitle();
}

void ScCondFormatDlg::updateTitle()
{
    OUString aTitle = msBaseTitle + " " + mpEdRange->GetText();
    OUString aTitle = msBaseTitle + " " + mxEdRange->GetText();

    SetText(aTitle);
    m_xDialog->set_title(aTitle);
}

ScCondFormatDlg::~ScCondFormatDlg()
{
    disposeOnce();
}

void ScCondFormatDlg::dispose()
{
    mpBtnOk.clear();
    mpBtnAdd.clear();
    mpBtnRemove.clear();
    mpBtnUp.clear();
    mpBtnDown.clear();
    mpBtnCancel.clear();
    mpFtRange.clear();
    mpEdRange.clear();
    mpRbRange.clear();
    mpCondFormList.clear();
    mpLastEdit.clear();

    ScAnyRefDlg::dispose();
}

void ScCondFormatDlg::SetActive()
@@ -604,14 +497,14 @@ void ScCondFormatDlg::SetActive()
    if(mpLastEdit)
        mpLastEdit->GrabFocus();
    else
        mpEdRange->GrabFocus();
        mxEdRange->GrabFocus();

    RefInputDone();
}

void ScCondFormatDlg::RefInputDone( bool bForced )
{
    ScAnyRefDlg::RefInputDone(bForced);
    ScAnyRefDlgController::RefInputDone(bForced);

    // ScAnyRefModalDlg::RefInputDone resets the title back
    // to its original state.
@@ -627,39 +520,39 @@ void ScCondFormatDlg::RefInputDone( bool bForced )

bool ScCondFormatDlg::IsTableLocked() const
{
    return !mpLastEdit || mpLastEdit == mpEdRange;
    return !mpLastEdit || mpLastEdit == mxEdRange.get();
}

bool ScCondFormatDlg::IsRefInputMode() const
{
    return mpEdRange->IsEnabled();
    return mxEdRange->GetWidget()->get_sensitive();
}

void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*)
{
    formula::RefEdit* pEdit = mpLastEdit;
    formula::WeldRefEdit* pEdit = mpLastEdit;
    if (!mpLastEdit)
        pEdit = mpEdRange;
        pEdit = mxEdRange.get();

    if( pEdit->IsEnabled() )
    if (pEdit->GetWidget()->get_sensitive())
    {
        if(rRef.aStart != rRef.aEnd)
            RefInputStart(pEdit);

        ScRefFlags nFlags;
        if (mpLastEdit && mpLastEdit != mpEdRange)
        if (mpLastEdit && mpLastEdit != mxEdRange.get())
            nFlags = ScRefFlags::RANGE_ABS_3D;
        else
            nFlags = ScRefFlags::RANGE_ABS;

        OUString aRefStr(rRef.Format(nFlags, mpViewData->GetDocument(),
            ScAddress::Details(mpViewData->GetDocument()->GetAddressConvention(), 0, 0)));
        if (pEdit != mpEdRange)
        if (pEdit != mxEdRange.get())
        {
            Selection sel = pEdit->GetSelection();
            sel.Justify();            // in case of RtL selection
            sel.Justify();            // in case of RTL selection
            sel.Max() = sel.Min() + aRefStr.getLength();
            pEdit->ReplaceSelected(aRefStr);
            pEdit->GetWidget()->replace_selection(aRefStr);
            pEdit->SetSelection(sel); // to replace it again with next drag event
        }
        else
@@ -670,15 +563,15 @@ void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*)

std::unique_ptr<ScConditionalFormat> ScCondFormatDlg::GetConditionalFormat() const
{
    OUString aRangeStr = mpEdRange->GetText();
    OUString aRangeStr = mxEdRange->GetText();
    if(aRangeStr.isEmpty())
        return nullptr;

    ScRangeList aRange;
    ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
        mpViewData->GetDocument()->GetAddressConvention(), maPos.Tab());
    mpCondFormList->SetRange(aRange);
    std::unique_ptr<ScConditionalFormat> pFormat = mpCondFormList->GetConditionalFormat();
    mxCondFormList->SetRange(aRange);
    std::unique_ptr<ScConditionalFormat> pFormat = mxCondFormList->GetConditionalFormat();

    if((nFlags & ScRefFlags::VALID) && !aRange.empty() && pFormat)
        pFormat->SetRange(aRange);
@@ -695,9 +588,9 @@ void ScCondFormatDlg::InvalidateRefData()

// Close the Conditional Format Dialog
//
bool ScCondFormatDlg::Close()
void ScCondFormatDlg::Close()
{
    return DoClose( ScCondFormatDlgWrapper::GetChildWindowId() );
    DoClose( ScCondFormatDlgWrapper::GetChildWindowId() );
}

// Occurs when the Conditional Format Dialog the OK button is pressed.
@@ -740,7 +633,7 @@ void ScCondFormatDlg::OkPressed()
        GetBindings().GetDispatcher()->Execute( SID_OPENDLG_CONDFRMT_MANAGER,
                                            SfxCallMode::ASYNCHRON );
    }
    Close();
    m_xDialog->response(RET_OK);
}

// Occurs when the Conditional Format Dialog is cancelled.
@@ -755,24 +648,24 @@ void ScCondFormatDlg::CancelPressed()
        GetBindings().GetDispatcher()->Execute( SID_OPENDLG_CONDFRMT_MANAGER,
                                            SfxCallMode::ASYNCHRON );
    }
    Close();
    m_xDialog->response(RET_CANCEL);
}

void ScCondFormatDlg::OnSelectionChange(size_t nIndex, size_t nSize, bool bSelected)
{
    if (nSize <= 1 || !bSelected)
    {
        mpBtnUp->Enable(false);
        mpBtnDown->Enable(false);
        mxBtnUp->set_sensitive(false);
        mxBtnDown->set_sensitive(false);
    }
    else
    {
        mpBtnUp->Enable(nIndex != 0);
        mpBtnDown->Enable(nIndex < nSize - 1);
        mxBtnUp->set_sensitive(nIndex != 0);
        mxBtnDown->set_sensitive(nIndex < nSize - 1);
    }
}

IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit&, rEdit, void )
IMPL_LINK(ScCondFormatDlg, EdRangeModifyHdl, formula::WeldRefEdit&, rEdit, void)
{
    OUString aRangeStr = rEdit.GetText();
    ScRangeList aRange;
@@ -780,28 +673,28 @@ IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit&, rEdit, void )
        mpViewData->GetDocument()->GetAddressConvention());
    if(nFlags & ScRefFlags::VALID)
    {
        rEdit.SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
        mpBtnOk->Enable(true);
        rEdit.GetWidget()->set_message_type(weld::EntryMessageType::Normal);
        mxBtnOk->set_sensitive(true);
    }
    else
    {
        rEdit.SetControlBackground(COL_LIGHTRED);
        mpBtnOk->Enable(false);
        rEdit.GetWidget()->set_message_type(weld::EntryMessageType::Error);
        mxBtnOk->set_sensitive(false);
    }

    updateTitle();
}

IMPL_LINK( ScCondFormatDlg, RangeGetFocusHdl, Control&, rControl, void )
IMPL_LINK(ScCondFormatDlg, RangeGetFocusHdl, formula::WeldRefEdit&, rControl, void)
{
    mpLastEdit = static_cast<formula::RefEdit*>(&rControl);
    mpLastEdit = &rControl;
}

IMPL_LINK( ScCondFormatDlg, BtnPressedHdl, Button*, pBtn, void)
IMPL_LINK( ScCondFormatDlg, BtnPressedHdl, weld::Button&, rBtn, void)
{
    if (pBtn == mpBtnOk)
    if (&rBtn == mxBtnOk.get())
        OkPressed();
    else if (pBtn == mpBtnCancel)
    else if (&rBtn == mxBtnCancel.get())
        CancelPressed();
}

diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 8b1eb6e..2a0e5f5 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -19,6 +19,7 @@

#include <svl/style.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/frame.hxx>
#include <svl/stritem.hxx>
#include <svl/intitem.hxx>
#include <svx/colorbox.hxx>
@@ -37,32 +38,21 @@

#include <set>

ScCondFrmtEntry::ScCondFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos)
    : VclContainer(pParent, WB_CLIPCHILDREN | WB_BORDER | WB_CHILDDLGCTRL)
ScCondFrmtEntry::ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos)
    : mpParent(pParent)
    , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), "modules/scalc/ui/conditionalentry.ui"))
    , mxBorder(mxBuilder->weld_widget("border"))
    , mxGrid(mxBuilder->weld_container("grid"))
    , mxFtCondNr(mxBuilder->weld_label("number"))
    , mxFtCondition(mxBuilder->weld_label("condition"))
    , mbActive(false)
    , maStrCondition(ScResId(SCSTR_CONDITION))
    , mxLbType(mxBuilder->weld_combo_box("type"))
    , mpDoc(pDoc)
    , maPos(rPos)
{
    m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "modules/scalc/ui/conditionalentry.ui"));

    get(maGrid, "grid");
    get(maFtCondNr, "number");
    get(maFtCondition, "condition");
    get(maLbType, "type");

    Color aBack(GetSettings().GetStyleSettings().GetWindowColor());

    SetControlBackground(aBack);
    SetBackground(GetControlBackground());

    maFtCondNr->SetControlBackground(aBack);
    maFtCondNr->SetBackground(maFtCondNr->GetControlBackground());

    maFtCondition->SetControlBackground(aBack);
    maFtCondition->SetBackground(maFtCondition->GetControlBackground());

    maLbType->SetSelectHdl( LINK( pParent, ScCondFormatList, TypeListHdl ) );
    mxLbType->connect_changed(LINK(pParent, ScCondFormatList, TypeListHdl));
    mxGrid->connect_mouse_press(LINK(this, ScCondFrmtEntry, EntrySelectHdl));
    maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );

    Show();
@@ -70,81 +60,43 @@ ScCondFrmtEntry::ScCondFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const S

ScCondFrmtEntry::~ScCondFrmtEntry()
{
    disposeOnce();
    mpParent->GetContainer()->move(mxBorder.get(), nullptr);
}

Size ScCondFrmtEntry::calculateRequisition() const
IMPL_LINK_NOARG(ScCondFrmtEntry, EntrySelectHdl, const MouseEvent&, bool)
{
    return getLayoutRequisition(*maGrid);
}

void ScCondFrmtEntry::setAllocation(const Size &rAllocation)
{
    setLayoutPosSize(*maGrid, Point(0, 0), rAllocation);
}

void ScCondFrmtEntry::dispose()
{
    maFtCondNr.clear();
    maFtCondition.clear();
    maLbType.clear();
    maGrid.clear();
    disposeBuilder();
    VclContainer::dispose();
}

bool ScCondFrmtEntry::EventNotify( NotifyEvent& rNEvt )
{
    if (rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN)
    {
        maClickHdl.Call(*this);
    }
    return VclContainer::EventNotify(rNEvt);
    maClickHdl.Call(*this);
    return false;
}

void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex)
{
    maFtCondNr->SetText(maStrCondition + OUString::number(nIndex));
}

void ScCondFrmtEntry::SetHeight()
{
    const long nMaxHeight = get_preferred_size().Height();
    if (nMaxHeight > 0)
    {
        Size aSize = GetSizePixel();
        const long nPad = LogicToPixel(Size(0, 2), MapMode(MapUnit::MapAppFont)).getHeight();
        aSize.setHeight( nMaxHeight + nPad );
        SetSizePixel(aSize);
    }
    mxFtCondNr->set_label(maStrCondition + OUString::number(nIndex));
}

void ScCondFrmtEntry::Select()
{
    maFtCondition->SetText(OUString());
    maFtCondition->Hide();
    maLbType->Show();
    mxFtCondition->set_label(OUString());
    mxFtCondition->hide();
    mxLbType->show();
    mbActive = true;
    SetHeight();
}

void ScCondFrmtEntry::Deselect()
{
    OUString aCondText = GetExpressionString();
    maFtCondition->SetText(aCondText);
    maFtCondition->Show();
    maLbType->Hide();
    mxFtCondition->set_label(aCondText);
    mxFtCondition->show();
    mxLbType->hide();
    mbActive = false;
    SetHeight();
}

//condition

namespace {

void FillStyleListBox( const ScDocument* pDoc, ListBox& rLbStyle )
void FillStyleListBox( const ScDocument* pDoc, weld::ComboBox& rLbStyle )
{
    rLbStyle.SetSeparatorPos(0);
    std::set<OUString> aStyleNames;
    SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SfxStyleFamily::Para );
    for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
@@ -153,7 +105,7 @@ void FillStyleListBox( const ScDocument* pDoc, ListBox& rLbStyle )
    }
    for(const auto& rStyleName : aStyleNames)
    {
        rLbStyle.InsertEntry( rStyleName );
        rLbStyle.append_text(rStyleName);
    }
}

@@ -186,21 +138,22 @@ const ScConditionMode ScConditionFrmtEntry::mpEntryToCond[ScConditionFrmtEntry::
    ScConditionMode::NotContainsText
};

ScConditionFrmtEntry::ScConditionFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
ScConditionFrmtEntry::ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
        const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxLbCondType(mxBuilder->weld_combo_box("typeis"))
    , mxEdVal1(new formula::WeldRefEdit(mxBuilder->weld_entry("val1")))
    , mxEdVal2(new formula::WeldRefEdit(mxBuilder->weld_entry("val2")))
    , mxFtVal(mxBuilder->weld_label("valueft"))
    , mxFtStyle(mxBuilder->weld_label("styleft"))
    , mxLbStyle(mxBuilder->weld_combo_box("style"))
    , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
    , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
    , mbIsInStyleCreate(false)
{
    get(maLbCondType, "typeis");
    get(maEdVal1, "val1");
    get(maEdVal2, "val2");
    get(maFtVal, "valueft");
    get(maFtStyle, "styleft");
    get(maLbStyle, "style");
    get(maWdPreview, "preview");
    maWdPreview->set_height_request(maLbStyle->get_preferred_size().Height());
    mxWdPreview->set_size_request(-1, mxLbStyle->get_preferred_size().Height());

    maLbType->SelectEntryPos(1);
    mxLbType->set_active(1);

    Init(pDialogParent);

@@ -208,101 +161,86 @@ ScConditionFrmtEntry::ScConditionFrmtEntry(vcl::Window* pParent, ScDocument* pDo

    if(pFormatEntry)
    {
        maLbStyle->SelectEntry(pFormatEntry->GetStyle());
        StyleSelectHdl(*maLbStyle);
        mxLbStyle->set_active_text(pFormatEntry->GetStyle());
        StyleSelectHdl(*mxLbStyle);
        ScConditionMode eMode = pFormatEntry->GetOperation();

        maLbCondType->SelectEntryPos(ConditionModeToEntryPos(eMode));
        mxLbCondType->set_active(ConditionModeToEntryPos(eMode));

        switch(GetNumberEditFields(eMode))
        {
            case 0:
                maEdVal1->Hide();
                maEdVal2->Hide();
                mxEdVal1->GetWidget()->hide();
                mxEdVal2->GetWidget()->hide();
                break;
            case 1:
                maEdVal1->Show();
                maEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
                maEdVal2->Hide();
                OnEdChanged(*maEdVal1);
                mxEdVal1->GetWidget()->show();
                mxEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
                mxEdVal2->GetWidget()->hide();
                OnEdChanged(*mxEdVal1);
                break;
            case 2:
                maEdVal1->Show();
                maEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
                OnEdChanged(*maEdVal1);
                maEdVal2->Show();
                maEdVal2->SetText(pFormatEntry->GetExpression(maPos, 1));
                OnEdChanged(*maEdVal2);
                mxEdVal1->GetWidget()->show();
                mxEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
                OnEdChanged(*mxEdVal1);
                mxEdVal2->GetWidget()->show();
                mxEdVal2->SetText(pFormatEntry->GetExpression(maPos, 1));
                OnEdChanged(*mxEdVal2);
                break;
        }
    }
    else
    {
        maLbCondType->SelectEntryPos(0);
        maEdVal2->Hide();
        maLbStyle->SelectEntryPos(1);
        mxLbCondType->set_active(0);
        mxEdVal2->GetWidget()->hide();
        mxLbStyle->set_active(1);
    }
}

ScConditionFrmtEntry::~ScConditionFrmtEntry()
{
    disposeOnce();
}

void ScConditionFrmtEntry::dispose()
{
    maLbCondType.clear();
    maEdVal1.clear();
    maEdVal2.clear();
    maFtVal.clear();
    maFtStyle.clear();
    maLbStyle.clear();
    maWdPreview.clear();
    ScCondFrmtEntry::dispose();
}

void ScConditionFrmtEntry::Init(ScCondFormatDlg* pDialogParent)
{
    maEdVal1->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
    maEdVal2->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
    mxEdVal1->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
    mxEdVal2->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );

    maEdVal1->SetForceControlBackground(true);
    maEdVal2->SetForceControlBackground(true);
    mxEdVal1->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );
    mxEdVal2->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );

    maEdVal1->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );
    maEdVal2->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );
    FillStyleListBox( mpDoc, *mxLbStyle );
    mxLbStyle->connect_changed( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) );

    FillStyleListBox( mpDoc, *maLbStyle );
    maLbStyle->SetSelectHdl( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) );

    maLbCondType->SetSelectHdl( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) );
    mxLbCondType->connect_changed( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) );
}

ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const
{
    ScConditionMode eMode = EntryPosToConditionMode(maLbCondType->GetSelectedEntryPos());
    OUString aExpr1 = maEdVal1->GetText();
    ScConditionMode eMode = EntryPosToConditionMode(mxLbCondType->get_active());
    OUString aExpr1 = mxEdVal1->GetText();
    OUString aExpr2;
    if (GetNumberEditFields(eMode) == 2)
    {
        aExpr2 = maEdVal2->GetText();
        aExpr2 = mxEdVal2->GetText();
        if (aExpr2.isEmpty())
        {
            return nullptr;
        }
    }

    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle->GetSelectedEntry());
    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, mxLbStyle->get_active_text());
    return pEntry;
}

IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit&, rEdit, void)
IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, formula::WeldRefEdit&, rRefEdit, void)
{
    OUString aFormula = rEdit.GetText();
    weld::Entry& rEdit = *rRefEdit.GetWidget();
    OUString aFormula = rEdit.get_text();

    if( aFormula.isEmpty() )
    {
        maFtVal->SetText(ScResId(STR_ENTER_VALUE));
        mxFtVal->set_label(ScResId(STR_ENTER_VALUE));
        return;
    }

@@ -312,8 +250,8 @@ IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit&, rEdit, void)
    // Error, warn the user
    if( ta->GetCodeError() != FormulaError::NONE || ( ta->GetLen() == 0 ) )
    {
        rEdit.SetControlBackground(COL_LIGHTRED);
        maFtVal->SetText(ScResId(STR_VALID_DEFERROR));
        rEdit.set_message_type(weld::EntryMessageType::Error);
        mxFtVal->set_label(ScResId(STR_VALID_DEFERROR));
        return;
    }

@@ -325,24 +263,24 @@ IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit&, rEdit, void)
        ( ( op == ocBad ) && ( t == formula::svString ) )
      )
    {
        rEdit.SetControlBackground(COL_YELLOW);
        maFtVal->SetText(ScResId(STR_UNQUOTED_STRING));
        rEdit.set_message_type(weld::EntryMessageType::Warning);
        mxFtVal->set_label(ScResId(STR_UNQUOTED_STRING));
        return;
    }

    rEdit.SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
    maFtVal->SetText("");
    rEdit.set_message_type(weld::EntryMessageType::Normal);
    mxFtVal->set_label("");
}

void ScConditionFrmtEntry::Select()
{
    maFtVal->Show();
    mxFtVal->show();
    ScCondFrmtEntry::Select();
}

void ScConditionFrmtEntry::Deselect()
{
    maFtVal->Hide();
    mxFtVal->hide();
    ScCondFrmtEntry::Deselect();
}

@@ -404,7 +342,7 @@ sal_Int32 ScConditionFrmtEntry::GetNumberEditFields( ScConditionMode eMode )

OUString ScConditionFrmtEntry::GetExpressionString()
{
    return ScCondFormatHelper::GetExpression(CONDITION, maLbCondType->GetSelectedEntryPos(), maEdVal1->GetText(), maEdVal2->GetText());
    return ScCondFormatHelper::GetExpression(CONDITION, mxLbCondType->get_active(), mxEdVal1->GetText(), mxEdVal2->GetText());
}

ScFormatEntry* ScConditionFrmtEntry::GetEntry() const
@@ -414,48 +352,46 @@ ScFormatEntry* ScConditionFrmtEntry::GetEntry() const

void ScConditionFrmtEntry::SetActive()
{
    ScConditionMode eMode = EntryPosToConditionMode(maLbCondType->GetSelectedEntryPos());
    maLbCondType->Show();
    ScConditionMode eMode = EntryPosToConditionMode(mxLbCondType->get_active());
    mxLbCondType->show();
    switch(GetNumberEditFields(eMode))
    {
        case 1:
            maEdVal1->Show();
            mxEdVal1->GetWidget()->show();
            break;
        case 2:
            maEdVal1->Show();
            maEdVal2->Show();
            mxEdVal1->GetWidget()->show();
            mxEdVal2->GetWidget()->show();
            break;
    }
    maFtStyle->Show();
    maLbStyle->Show();
    maWdPreview->Show();
    mxFtStyle->show();
    mxLbStyle->show();
    mxWdPreviewWin->show();

    Select();
}

void ScConditionFrmtEntry::SetInactive()
{
    maLbCondType->Hide();
    maEdVal1->Hide();
    maEdVal2->Hide();
    maFtStyle->Hide();
    maLbStyle->Hide();
    maWdPreview->Hide();
    mxLbCondType->hide();
    mxEdVal1->GetWidget()->hide();
    mxEdVal2->GetWidget()->hide();
    mxFtStyle->hide();
    mxLbStyle->hide();
    mxWdPreviewWin->hide();

    Deselect();
}

namespace {

void UpdateStyleList(ListBox& rLbStyle, const ScDocument* pDoc)
void UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument* pDoc)
{
    OUString aSelectedStyle = rLbStyle.GetSelectedEntry();
    for(sal_Int32 i = rLbStyle.GetEntryCount(); i > 1; --i)
    {
        rLbStyle.RemoveEntry(i - 1);
    }
    OUString aSelectedStyle = rLbStyle.get_active_text();
    for (sal_Int32 i = rLbStyle.get_count(); i > 1; --i)
        rLbStyle.remove(i - 1);
    FillStyleListBox(pDoc, rLbStyle);
    rLbStyle.SelectEntry(aSelectedStyle);
    rLbStyle.set_active_text(aSelectedStyle);
}

}
@@ -465,19 +401,21 @@ void ScConditionFrmtEntry::Notify(SfxBroadcaster&, const SfxHint& rHint)
    if(rHint.GetId() == SfxHintId::StyleSheetModified)
    {
        if(!mbIsInStyleCreate)
            UpdateStyleList(*maLbStyle, mpDoc);
            UpdateStyleList(*mxLbStyle, mpDoc);
    }
}

namespace {

void StyleSelect( ListBox& rLbStyle, const ScDocument* pDoc, SvxFontPrevWindow& rWdPreview )
void StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, const ScDocument* pDoc, FontPrevWindow& rWdPreview)
{
    if(rLbStyle.GetSelectedEntryPos() == 0)
    if (rLbStyle.get_active() == 0)
    {
        // call new style dialog
        SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para) );
        SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScResId(STR_STYLENAME_STANDARD) );
        css::uno::Any aAny(pDialogParent->GetXWindow());
        SfxUnoAnyItem aDialogParent( SID_DIALOG_PARENT, aAny );

        // unlock the dispatcher so SID_STYLE_NEW can be executed
        // (SetDispatcherLock would affect all Calc documents)
@@ -491,7 +429,7 @@ void StyleSelect( ListBox& rLbStyle, const ScDocument* pDoc, SvxFontPrevWindow& 
        // The return value (SfxUInt16Item) is ignored, look for new styles instead.
        pDisp->ExecuteList(SID_STYLE_NEW,
            SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
            { &aFamilyItem, &aRefItem });
            { &aFamilyItem, &aRefItem }, { &aDialogParent });

        if (bLocked)
            pDisp->Lock(true);
@@ -502,21 +440,21 @@ void StyleSelect( ListBox& rLbStyle, const ScDocument* pDoc, SvxFontPrevWindow& 
        for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() )
        {
            const OUString& aName = pStyle->GetName();
            if ( rLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND )    // all lists contain the same entries
            if (rLbStyle.find_text(aName) == -1)    // all lists contain the same entries
            {
                for( sal_Int32 i = 1, n = rLbStyle.GetEntryCount(); i <= n && !bFound; ++i)
                for( sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i)
                {
                    OUString aStyleName = ScGlobal::pCharClass->uppercase(rLbStyle.GetEntry(i));
                    OUString aStyleName = ScGlobal::pCharClass->uppercase(rLbStyle.get_text(i));
                    if( i == n )
                    {
                        rLbStyle.InsertEntry(aName);
                        rLbStyle.SelectEntry(aName);
                        rLbStyle.append_text(aName);
                        rLbStyle.set_active_text(aName);
                        bFound = true;
                    }
                    else if( aStyleName > ScGlobal::pCharClass->uppercase(aName) )
                    {
                        rLbStyle.InsertEntry(aName, i);
                        rLbStyle.SelectEntry(aName);
                        rLbStyle.insert_text(i, aName);
                        rLbStyle.set_active_text(aName);
                        bFound = true;
                    }
                }
@@ -524,86 +462,77 @@ void StyleSelect( ListBox& rLbStyle, const ScDocument* pDoc, SvxFontPrevWindow& 
        }
    }

    OUString aStyleName = rLbStyle.GetSelectedEntry();
    OUString aStyleName = rLbStyle.get_active_text();
    SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SfxStyleFamily::Para );
    if(pStyleSheet)
    {
        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
        rWdPreview.Init( rSet );
        rWdPreview.SetFromItemSet(rSet, false);
    }
}

}

IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl, ListBox&, void)
IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl, weld::ComboBox&, void)
{
    mbIsInStyleCreate = true;
    StyleSelect( *maLbStyle, mpDoc, *maWdPreview );
    StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
    mbIsInStyleCreate = false;
}

// formula

ScFormulaFrmtEntry::ScFormulaFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormat )
ScFormulaFrmtEntry::ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxFtStyle(mxBuilder->weld_label("styleft"))
    , mxLbStyle(mxBuilder->weld_combo_box("style"))
    , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
    , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
    , mxEdFormula(new formula::WeldRefEdit(mxBuilder->weld_entry("formula")))
{
    get(maFtStyle, "styleft");
    get(maLbStyle, "style");
    get(maWdPreview, "preview");
    maWdPreview->set_height_request(maLbStyle->get_preferred_size().Height());
    get(maEdFormula, "formula");
    mxWdPreview->set_size_request(-1, mxLbStyle->get_preferred_size().Height());

    Init(pDialogParent);

    maLbType->SelectEntryPos(2);
    mxLbType->set_active(2);

    if(pFormat)
    {
        maEdFormula->SetText(pFormat->GetExpression(rPos, 0, 0, pDoc->GetGrammar()));
        maLbStyle->SelectEntry(pFormat->GetStyle());
        mxEdFormula->SetText(pFormat->GetExpression(rPos, 0, 0, pDoc->GetGrammar()));
        mxLbStyle->set_active_text(pFormat->GetStyle());
    }
    else
    {
        maLbStyle->SelectEntryPos(1);
        mxLbStyle->set_active(1);
    }

    StyleSelectHdl(*maLbStyle);
    StyleSelectHdl(*mxLbStyle);
}

ScFormulaFrmtEntry::~ScFormulaFrmtEntry()
{
    disposeOnce();
}

void ScFormulaFrmtEntry::dispose()
{
    maFtStyle.clear();
    maLbStyle.clear();
    maWdPreview.clear();
    maEdFormula.clear();
    ScCondFrmtEntry::dispose();
}

void ScFormulaFrmtEntry::Init(ScCondFormatDlg* pDialogParent)
{
    maEdFormula->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
    mxEdFormula->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );

    FillStyleListBox( mpDoc, *maLbStyle );
    maLbStyle->SetSelectHdl( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
    FillStyleListBox( mpDoc, *mxLbStyle );
    mxLbStyle->connect_changed( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
}

IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl, ListBox&, void)
IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl, weld::ComboBox&, void)
{
    StyleSelect( *maLbStyle, mpDoc, *maWdPreview );
    StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
}

ScFormatEntry* ScFormulaFrmtEntry::createFormulaEntry() const
{
    OUString aFormula = maEdFormula->GetText();
    OUString aFormula = mxEdFormula->GetText();
    if(aFormula.isEmpty())
        return nullptr;

    ScFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, aFormula, OUString(), mpDoc, maPos, maLbStyle->GetSelectedEntry());
    ScFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, aFormula, OUString(), mpDoc, maPos, mxLbStyle->get_active_text());
    return pEntry;
}

@@ -614,25 +543,25 @@ ScFormatEntry* ScFormulaFrmtEntry::GetEntry() const

OUString ScFormulaFrmtEntry::GetExpressionString()
{
    return ScCondFormatHelper::GetExpression(FORMULA, 0, maEdFormula->GetText());
    return ScCondFormatHelper::GetExpression(FORMULA, 0, mxEdFormula->GetText());
}

void ScFormulaFrmtEntry::SetActive()
{
    maWdPreview->Show();
    maFtStyle->Show();
    maLbStyle->Show();
    maEdFormula->Show();
    mxWdPreviewWin->show();
    mxFtStyle->show();
    mxLbStyle->show();
    mxEdFormula->GetWidget()->show();

    Select();
}

void ScFormulaFrmtEntry::SetInactive()
{
    maWdPreview->Hide();
    maFtStyle->Hide();
    maLbStyle->Hide();
    maEdFormula->Hide();
    mxWdPreviewWin->hide();
    mxFtStyle->hide();
    mxLbStyle->hide();
    mxEdFormula->GetWidget()->hide();

    Deselect();
}
@@ -677,45 +606,37 @@ ScColorScaleEntryType getTypeForId(const OUString& sId)
// Item ids are imported from .ui into OUString* and are referenced by entry data.
// See commit 83cefb5ceb4428d61a5b9fae80d1e673131e9bfe

ScColorScaleEntryType getSelectedType(const ListBox& rListBox)
ScColorScaleEntryType getSelectedType(const weld::ComboBox& rListBox)
{
    const OUString* sId = static_cast<OUString*>(rListBox.GetSelectedEntryData());
    assert(sId
           && "The color scale type entries must have item ids in "
              "sc/uiconfig/scalc/ui/conditionalentry.ui");
    return getTypeForId(*sId);
    return getTypeForId(rListBox.get_active_id());
}

sal_Int32 getEntryPos(const ListBox& rListBox, ScColorScaleEntryType eType)
sal_Int32 getEntryPos(const weld::ComboBox& rListBox, ScColorScaleEntryType eType)
{
    const sal_Int32 nSize = rListBox.GetEntryCount();
    const sal_Int32 nSize = rListBox.get_count();
    for (sal_Int32 i = 0; i < nSize; ++i)
    {
        const OUString* sId = static_cast<OUString*>(rListBox.GetEntryData(i));
        assert(sId
               && "The color scale type entries must have item ids in "
                  "sc/uiconfig/scalc/ui/conditionalentry.ui");
        if (getTypeForId(*sId) == eType)
        if (getTypeForId(rListBox.get_id(i)) == eType)
            return i;
    }
    return -1;
}

void selectType(ListBox& rListBox, ScColorScaleEntryType eType)
void selectType(weld::ComboBox& rListBox, ScColorScaleEntryType eType)
{
    const sal_Int32 nPos = getEntryPos(rListBox, eType);
    if (nPos >= 0)
        rListBox.SelectEntryPos(nPos);
        rListBox.set_active(nPos);
}

void removeType(ListBox& rListBox, ScColorScaleEntryType eType)
void removeType(weld::ComboBox& rListBox, ScColorScaleEntryType eType)
{
    const sal_Int32 nPos = getEntryPos(rListBox, eType);
    if (nPos >= 0)
        rListBox.RemoveEntry(nPos);
        rListBox.remove(nPos);
}

void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, SvxColorListBox& rLbCol, const ScDocument* pDoc )
void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, weld::ComboBox& rLbType, weld::Entry& rEdit, ColorListBox& rLbCol, const ScDocument* pDoc )
{
    // entry Automatic is not available for color scales
    assert(rEntry.GetType() > COLORSCALE_AUTO);
@@ -730,11 +651,11 @@ void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType,
        case COLORSCALE_PERCENT:
            {
                double nVal = rEntry.GetValue();
                rEdit.SetText(convertNumberToString(nVal, pDoc));
                rEdit.set_text(convertNumberToString(nVal, pDoc));
            }
            break;
        case COLORSCALE_FORMULA:
            rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
            rEdit.set_text(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
            break;
        case COLORSCALE_AUTO:
            abort();
@@ -743,7 +664,7 @@ void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType,
    rLbCol.SelectEntry(rEntry.GetColor());
}

void SetColorScaleEntry(ScColorScaleEntry* pEntry, const ListBox& rType, const Edit& rValue,
void SetColorScaleEntry(ScColorScaleEntry* pEntry, const weld::ComboBox& rType, const weld::Entry& rValue,
                        ScDocument* pDoc, const ScAddress& rPos)
{
    ScColorScaleEntryType eType = getSelectedType(rType);
@@ -762,19 +683,19 @@ void SetColorScaleEntry(ScColorScaleEntry* pEntry, const ListBox& rType, const E
                sal_uInt32 nIndex = 0;
                double nVal = 0;
                SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
                (void)pNumberFormatter->IsNumberFormat(rValue.GetText(), nIndex, nVal);
                (void)pNumberFormatter->IsNumberFormat(rValue.get_text(), nIndex, nVal);
                pEntry->SetValue(nVal);
            }
            break;
        case COLORSCALE_FORMULA:
            pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
            pEntry->SetFormula(rValue.get_text(), pDoc, rPos);
            break;
        default:
            break;
    }
}

ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const SvxColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
ScColorScaleEntry* createColorScaleEntry( const weld::ComboBox& rType, const ColorListBox& rColor, const weld::Entry& rValue, ScDocument* pDoc, const ScAddress& rPos )
{
    ScColorScaleEntry* pEntry = new ScColorScaleEntry();

@@ -786,83 +707,67 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const SvxColorLi

}

ScColorScale2FrmtEntry::ScColorScale2FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat )
ScColorScale2FrmtEntry::ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
    , mxLbEntryTypeMin(mxBuilder->weld_combo_box("colscalemin"))
    , mxLbEntryTypeMax(mxBuilder->weld_combo_box("colscalemax"))
    , mxEdMin(mxBuilder->weld_entry("edcolscalemin"))
    , mxEdMax(mxBuilder->weld_entry("edcolscalemax"))
    , mxLbColMin(new ColorListBox(mxBuilder->weld_menu_button("lbcolmin"), pParent->GetFrameWeld()))
    , mxLbColMax(new ColorListBox(mxBuilder->weld_menu_button("lbcolmax"), pParent->GetFrameWeld()))
    , mxFtMin(mxBuilder->weld_label("Label_minimum"))
    , mxFtMax(mxBuilder->weld_label("Label_maximum"))
{
    get(maLbColorFormat, "colorformat");
    get(maLbEntryTypeMin, "colscalemin");
    get(maLbEntryTypeMax, "colscalemax");
    get(maEdMin, "edcolscalemin");
    get(maEdMax, "edcolscalemax");
    get(maLbColMin, "lbcolmin");
    get(maLbColMax, "lbcolmax");
    get(maFtMin, "Label_minimum");
    get(maFtMax, "Label_maximum");

    maFtMin->Show();
    maFtMax->Show();
    mxFtMin->show();
    mxFtMax->show();

    // remove the automatic entry from color scales
    removeType(*maLbEntryTypeMin, COLORSCALE_AUTO);
    removeType(*maLbEntryTypeMax, COLORSCALE_AUTO);
    removeType(*mxLbEntryTypeMin, COLORSCALE_AUTO);
    removeType(*mxLbEntryTypeMax, COLORSCALE_AUTO);
    // "min" selector doesn't need "max" entry, and vice versa
    removeType(*maLbEntryTypeMin, COLORSCALE_MAX);
    removeType(*maLbEntryTypeMax, COLORSCALE_MIN);
    removeType(*mxLbEntryTypeMin, COLORSCALE_MAX);
    removeType(*mxLbEntryTypeMax, COLORSCALE_MIN);

    maLbType->SelectEntryPos(0);
    maLbColorFormat->SelectEntryPos(0);
    mxLbType->set_active(0);
    mxLbColorFormat->set_active(0);
    Init();
    if(pFormat)
    {
        ScColorScaleEntries::const_iterator itr = pFormat->begin();
        SetColorScaleEntryTypes(*itr[0], *maLbEntryTypeMin, *maEdMin, *maLbColMin, pDoc);
        SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMin, *mxEdMin, *mxLbColMin, pDoc);
        ++itr;
        SetColorScaleEntryTypes(*itr[0], *maLbEntryTypeMax, *maEdMax, *maLbColMax, pDoc);
        SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMax, *mxEdMax, *mxLbColMax, pDoc);
    }
    else
    {
        selectType(*maLbEntryTypeMin, COLORSCALE_MIN);
        selectType(*maLbEntryTypeMax, COLORSCALE_MAX);
        selectType(*mxLbEntryTypeMin, COLORSCALE_MIN);
        selectType(*mxLbEntryTypeMax, COLORSCALE_MAX);
    }

    maLbColorFormat->SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );

    EntryTypeHdl(*maLbEntryTypeMin);
    EntryTypeHdl(*maLbEntryTypeMax);
    EntryTypeHdl(*mxLbEntryTypeMin);
    EntryTypeHdl(*mxLbEntryTypeMax);
}

ScColorScale2FrmtEntry::~ScColorScale2FrmtEntry()
{
    disposeOnce();
}

void ScColorScale2FrmtEntry::dispose()
{
    maLbColorFormat.clear();
    maLbEntryTypeMin.clear();
    maLbEntryTypeMax.clear();
    maEdMin.clear();
    maEdMax.clear();
    maLbColMin.clear();
    maLbColMax.clear();
    maFtMin.clear();
    maFtMax.clear();
    ScCondFrmtEntry::dispose();
}

void ScColorScale2FrmtEntry::Init()
{
    maLbEntryTypeMin->SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
    maLbEntryTypeMax->SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
    maLbColMin->SelectEntry(Color(0xFFF685)); // Light Yellow 2
    maLbColMax->SelectEntry(Color(0x65C295)); // Light Green 2
    mxLbEntryTypeMin->connect_changed( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
    mxLbEntryTypeMax->connect_changed( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
    mxLbColMin->SelectEntry(Color(0xFFF685)); // Light Yellow 2
    mxLbColMax->SelectEntry(Color(0x65C295)); // Light Green 2
}

ScFormatEntry* ScColorScale2FrmtEntry::createColorscaleEntry() const
{
    ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
    pColorScale->AddEntry(createColorScaleEntry(*maLbEntryTypeMin, *maLbColMin, *maEdMin, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*maLbEntryTypeMax, *maLbColMax, *maEdMax, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMin, *mxLbColMin, *mxEdMin, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMax, *mxLbColMax, *mxEdMax, mpDoc, maPos));
    return pColorScale;
}

@@ -878,43 +783,43 @@ ScFormatEntry* ScColorScale2FrmtEntry::GetEntry() const

void ScColorScale2FrmtEntry::SetActive()
{
    maLbColorFormat->Show();
    mxLbColorFormat->show();

    maLbEntryTypeMin->Show();
    maLbEntryTypeMax->Show();
    mxLbEntryTypeMin->show();
    mxLbEntryTypeMax->show();

    maEdMin->Show();
    maEdMax->Show();
    mxEdMin->show();
    mxEdMax->show();

    maLbColMin->Show();
    maLbColMax->Show();
    mxLbColMin->show();
    mxLbColMax->show();

    Select();
}

void ScColorScale2FrmtEntry::SetInactive()
{
    maLbColorFormat->Hide();
    mxLbColorFormat->hide();

    maLbEntryTypeMin->Hide();
    maLbEntryTypeMax->Hide();
    mxLbEntryTypeMin->hide();
    mxLbEntryTypeMax->hide();

    maEdMin->Hide();
    maEdMax->Hide();
    mxEdMin->hide();
    mxEdMax->hide();

    maLbColMin->Hide();
    maLbColMax->Hide();
    mxLbColMin->hide();
    mxLbColMax->hide();

    Deselect();
}

IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox&, rBox, void )
IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, weld::ComboBox&, rBox, void )
{
    Edit* pEd = nullptr;
    if (&rBox == maLbEntryTypeMin.get())
        pEd = maEdMin;
    else if (&rBox == maLbEntryTypeMax.get())
        pEd = maEdMax.get();
    weld::Entry* pEd = nullptr;
    if (&rBox == mxLbEntryTypeMin.get())
        pEd = mxEdMin.get();
    else if (&rBox == mxLbEntryTypeMax.get())
        pEd = mxEdMax.get();

    if (!pEd)
        return;
@@ -926,105 +831,86 @@ IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox&, rBox, void )
    }

    if (bEnableEdit)
        pEd->Enable();
        pEd->set_sensitive(true);
    else
        pEd->Disable();
        pEd->set_sensitive(false);
}

ScColorScale3FrmtEntry::ScColorScale3FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat )
ScColorScale3FrmtEntry::ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
    , mxLbEntryTypeMin(mxBuilder->weld_combo_box("colscalemin"))
    , mxLbEntryTypeMiddle(mxBuilder->weld_combo_box("colscalemiddle"))
    , mxLbEntryTypeMax(mxBuilder->weld_combo_box("colscalemax"))
    , mxEdMin(mxBuilder->weld_entry("edcolscalemin"))
    , mxEdMiddle(mxBuilder->weld_entry("edcolscalemiddle"))
    , mxEdMax(mxBuilder->weld_entry("edcolscalemax"))
    , mxLbColMin(new ColorListBox(mxBuilder->weld_menu_button("lbcolmin"), pParent->GetFrameWeld()))
    , mxLbColMiddle(new ColorListBox(mxBuilder->weld_menu_button("lbcolmiddle"), pParent->GetFrameWeld()))
    , mxLbColMax(new ColorListBox(mxBuilder->weld_menu_button("lbcolmax"), pParent->GetFrameWeld()))
    , mxFtMin(mxBuilder->weld_label("Label_minimum"))
    , mxFtMax(mxBuilder->weld_label("Label_maximum"))
{
    get(maLbColorFormat, "colorformat");
    get(maLbEntryTypeMin, "colscalemin");
    get(maLbEntryTypeMiddle, "colscalemiddle");
    get(maLbEntryTypeMax, "colscalemax");
    get(maEdMin, "edcolscalemin");
    get(maEdMiddle, "edcolscalemiddle");
    get(maEdMax, "edcolscalemax");
    get(maLbColMin, "lbcolmin");
    get(maLbColMiddle, "lbcolmiddle");
    get(maLbColMax, "lbcolmax");
    get(maFtMin, "Label_minimum");
    get(maFtMax, "Label_maximum");

    maFtMin->Show();
    maFtMax->Show();
    mxFtMin->show();
    mxFtMax->show();

    // remove the automatic entry from color scales
    removeType(*maLbEntryTypeMin, COLORSCALE_AUTO);
    removeType(*maLbEntryTypeMiddle, COLORSCALE_AUTO);
    removeType(*maLbEntryTypeMax, COLORSCALE_AUTO);
    removeType(*mxLbEntryTypeMin, COLORSCALE_AUTO);
    removeType(*mxLbEntryTypeMiddle, COLORSCALE_AUTO);
    removeType(*mxLbEntryTypeMax, COLORSCALE_AUTO);
    // "min" selector doesn't need "max" entry, and vice versa
    removeType(*maLbEntryTypeMin, COLORSCALE_MAX);
    removeType(*maLbEntryTypeMax, COLORSCALE_MIN);
    maLbColorFormat->SelectEntryPos(1);
    removeType(*mxLbEntryTypeMin, COLORSCALE_MAX);
    removeType(*mxLbEntryTypeMax, COLORSCALE_MIN);
    mxLbColorFormat->set_active(1);

    Init();
    maLbType->SelectEntryPos(0);
    mxLbType->set_active(0);
    if(pFormat)
    {
        ScColorScaleEntries::const_iterator itr = pFormat->begin();
        SetColorScaleEntryTypes(*itr[0], *maLbEntryTypeMin, *maEdMin, *maLbColMin, pDoc);
        SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMin, *mxEdMin, *mxLbColMin, pDoc);
        assert(pFormat->size() == 3);
        ++itr;
        SetColorScaleEntryTypes(*itr[0], *maLbEntryTypeMiddle, *maEdMiddle, *maLbColMiddle, pDoc);
        SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMiddle, *mxEdMiddle, *mxLbColMiddle, pDoc);
        ++itr;
        SetColorScaleEntryTypes(*itr[0], *maLbEntryTypeMax, *maEdMax, *maLbColMax, pDoc);
        SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMax, *mxEdMax, *mxLbColMax, pDoc);
    }
    else
    {
        maLbColorFormat->SelectEntryPos(1);
        selectType(*maLbEntryTypeMin, COLORSCALE_MIN);
        selectType(*maLbEntryTypeMiddle, COLORSCALE_PERCENTILE);
        selectType(*maLbEntryTypeMax, COLORSCALE_MAX);
        maEdMiddle->SetText(OUString::number(50));
        mxLbColorFormat->set_active(1);
        selectType(*mxLbEntryTypeMin, COLORSCALE_MIN);
        selectType(*mxLbEntryTypeMiddle, COLORSCALE_PERCENTILE);
        selectType(*mxLbEntryTypeMax, COLORSCALE_MAX);
        mxEdMiddle->set_text(OUString::number(50));
    }

    maLbColorFormat->SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    EntryTypeHdl(*maLbEntryTypeMin);
    EntryTypeHdl(*maLbEntryTypeMiddle);
    EntryTypeHdl(*maLbEntryTypeMax);
    mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    EntryTypeHdl(*mxLbEntryTypeMin);
    EntryTypeHdl(*mxLbEntryTypeMiddle);
    EntryTypeHdl(*mxLbEntryTypeMax);
}

ScColorScale3FrmtEntry::~ScColorScale3FrmtEntry()
{
    disposeOnce();
}

void ScColorScale3FrmtEntry::dispose()
{
    maLbColorFormat.clear();
    maLbEntryTypeMin.clear();
    maLbEntryTypeMiddle.clear();
    maLbEntryTypeMax.clear();
    maEdMin.clear();
    maEdMiddle.clear();
    maEdMax.clear();
    maLbColMin.clear();
    maLbColMiddle.clear();
    maLbColMax.clear();
    maFtMin.clear();
    maFtMax.clear();
    ScCondFrmtEntry::dispose();
}

void ScColorScale3FrmtEntry::Init()
{
    maLbEntryTypeMin->SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    maLbEntryTypeMax->SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    maLbEntryTypeMiddle->SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    maLbColMin->SelectEntry(COL_LIGHTRED);
    maLbColMiddle->SelectEntry(COL_YELLOW);
    maLbColMax->SelectEntry(Color(0x00CC00));
    mxLbEntryTypeMin->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    mxLbEntryTypeMax->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    mxLbEntryTypeMiddle->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
    mxLbColMin->SelectEntry(COL_LIGHTRED);
    mxLbColMiddle->SelectEntry(COL_YELLOW);
    mxLbColMax->SelectEntry(Color(0x00CC00));
}

ScFormatEntry* ScColorScale3FrmtEntry::createColorscaleEntry() const
{
    ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
    pColorScale->AddEntry(createColorScaleEntry(*maLbEntryTypeMin, *maLbColMin, *maEdMin, mpDoc, maPos));
    if(maLbColorFormat->GetSelectedEntryPos() == 1)
        pColorScale->AddEntry(createColorScaleEntry(*maLbEntryTypeMiddle, *maLbColMiddle, *maEdMiddle, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*maLbEntryTypeMax, *maLbColMax, *maEdMax, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMin, *mxLbColMin, *mxEdMin, mpDoc, maPos));
    if (mxLbColorFormat->get_active() == 1)
        pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMiddle, *mxLbColMiddle, *mxEdMiddle, mpDoc, maPos));
    pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMax, *mxLbColMax, *mxEdMax, mpDoc, maPos));
    return pColorScale;
}

@@ -1040,50 +926,50 @@ ScFormatEntry* ScColorScale3FrmtEntry::GetEntry() const

void ScColorScale3FrmtEntry::SetActive()
{
    maLbColorFormat->Show();
    maLbEntryTypeMin->Show();
    maLbEntryTypeMiddle->Show();
    maLbEntryTypeMax->Show();
    mxLbColorFormat->show();
    mxLbEntryTypeMin->show();
    mxLbEntryTypeMiddle->show();
    mxLbEntryTypeMax->show();

    maEdMin->Show();
    maEdMiddle->Show();
    maEdMax->Show();
    mxEdMin->show();
    mxEdMiddle->show();
    mxEdMax->show();

    maLbColMin->Show();
    maLbColMiddle->Show();
    maLbColMax->Show();
    mxLbColMin->show();
    mxLbColMiddle->show();
    mxLbColMax->show();

    Select();
}

void ScColorScale3FrmtEntry::SetInactive()
{
    maLbColorFormat->Hide();
    mxLbColorFormat->hide();

    maLbEntryTypeMin->Hide();
    maLbEntryTypeMiddle->Hide();
    maLbEntryTypeMax->Hide();
    mxLbEntryTypeMin->hide();
    mxLbEntryTypeMiddle->hide();
    mxLbEntryTypeMax->hide();

    maEdMin->Hide();
    maEdMiddle->Hide();
    maEdMax->Hide();
    mxEdMin->hide();
    mxEdMiddle->hide();
    mxEdMax->hide();

    maLbColMin->Hide();
    maLbColMiddle->Hide();
    maLbColMax->Hide();
    mxLbColMin->hide();
    mxLbColMiddle->hide();
    mxLbColMax->hide();

    Deselect();
}

IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox&, rBox, void )
IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, weld::ComboBox&, rBox, void )
{
    Edit* pEd = nullptr;
    if(&rBox == maLbEntryTypeMin.get())
        pEd = maEdMin.get();
    else if(&rBox == maLbEntryTypeMiddle.get())
        pEd = maEdMiddle.get();
    else if(&rBox == maLbEntryTypeMax.get())
        pEd = maEdMax.get();
    weld::Entry* pEd = nullptr;
    if(&rBox == mxLbEntryTypeMin.get())
        pEd = mxEdMin.get();
    else if(&rBox == mxLbEntryTypeMiddle.get())
        pEd = mxEdMiddle.get();
    else if(&rBox == mxLbEntryTypeMax.get())
        pEd = mxEdMax.get();

    if (!pEd)
        return;
@@ -1095,31 +981,31 @@ IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox&, rBox, void )
    }

    if(bEnableEdit)
        pEd->Enable();
        pEd->set_sensitive(true);
    else
        pEd->Disable();
        pEd->set_sensitive(false);
}

IMPL_LINK_NOARG( ScConditionFrmtEntry, ConditionTypeSelectHdl, ListBox&, void )
IMPL_LINK_NOARG(ScConditionFrmtEntry, ConditionTypeSelectHdl, weld::ComboBox&, void)
{
    sal_Int32 nSelectPos = maLbCondType->GetSelectedEntryPos();
    sal_Int32 nSelectPos = mxLbCondType->get_active();
    ScConditionMode eMode = EntryPosToConditionMode(nSelectPos);
    switch(GetNumberEditFields(eMode))
    {
        case 0:
            maEdVal1->Hide();
            maEdVal2->Hide();
            maFtVal->Hide();
            mxEdVal1->GetWidget()->hide();
            mxEdVal2->GetWidget()->hide();
            mxFtVal->hide();
            break;
        case 1:
            maEdVal1->Show();
            maEdVal2->Hide();
            maFtVal->Show();
            mxEdVal1->GetWidget()->show();
            mxEdVal2->GetWidget()->hide();
            mxFtVal->show();
            break;
        case 2:
            maEdVal1->Show();
            maEdVal2->Show();
            maFtVal->Show();
            mxEdVal1->GetWidget()->show();
            mxEdVal2->GetWidget()->show();
            mxFtVal->show();
            break;
    }
}
@@ -1128,7 +1014,7 @@ IMPL_LINK_NOARG( ScConditionFrmtEntry, ConditionTypeSelectHdl, ListBox&, void )

namespace {

void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, const ScDocument* pDoc )
void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, weld::ComboBox& rLbType, weld::Entry& rEdit, const ScDocument* pDoc )
{
    selectType(rLbType, rEntry.GetType());
    switch(rEntry.GetType())
@@ -1145,72 +1031,57 @@ void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Ed
                SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
                OUString aText;
                pNumberFormatter->GetInputLineString(nVal, 0, aText);
                rEdit.SetText(aText);
                rEdit.set_text(aText);
            }
            break;
        case COLORSCALE_FORMULA:
            rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
            rEdit.set_text(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
            break;
    }
}

}

ScDataBarFrmtEntry::ScDataBarFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat )
ScDataBarFrmtEntry::ScDataBarFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
    , mxLbDataBarMinType(mxBuilder->weld_combo_box("colscalemin"))
    , mxLbDataBarMaxType(mxBuilder->weld_combo_box("colscalemax"))
    , mxEdDataBarMin(mxBuilder->weld_entry("edcolscalemin"))
    , mxEdDataBarMax(mxBuilder->weld_entry("edcolscalemax"))
    , mxBtOptions(mxBuilder->weld_button("options"))
    , mxFtMin(mxBuilder->weld_label("Label_minimum"))
    , mxFtMax(mxBuilder->weld_label("Label_maximum"))
{
    get(maLbColorFormat, "colorformat");
    get(maLbDataBarMinType, "colscalemin");
    get(maLbDataBarMaxType, "colscalemax");
    get(maEdDataBarMin, "edcolscalemin");
    get(maEdDataBarMax, "edcolscalemax");
    get(maBtOptions, "options");
    get(maFtMin, "Label_minimum");
    get(maFtMax, "Label_maximum");

    // "min" selector doesn't need "max" entry, and vice versa
    removeType(*maLbDataBarMinType, COLORSCALE_MAX);
    removeType(*maLbDataBarMaxType, COLORSCALE_MIN);
    removeType(*mxLbDataBarMinType, COLORSCALE_MAX);
    removeType(*mxLbDataBarMaxType, COLORSCALE_MIN);

    maFtMin->Show();
    maFtMax->Show();
    mxFtMin->show();
    mxFtMax->show();

    maLbColorFormat->SelectEntryPos(2);
    maLbType->SelectEntryPos(0);
    mxLbColorFormat->set_active(2);
    mxLbType->set_active(0);
    if(pFormat)
    {
        mpDataBarData.reset(new ScDataBarFormatData(*pFormat->GetDataBarData()));
        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *maLbDataBarMinType, *maEdDataBarMin, pDoc);
        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *maLbDataBarMaxType, *maEdDataBarMax, pDoc);
        DataBarTypeSelectHdl(*maLbDataBarMinType);
        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *mxLbDataBarMinType, *mxEdDataBarMin, pDoc);
        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *mxLbDataBarMaxType, *mxEdDataBarMax, pDoc);
        DataBarTypeSelectHdl(*mxLbDataBarMinType);
    }
    else
    {
        selectType(*maLbDataBarMinType, COLORSCALE_AUTO);
        selectType(*maLbDataBarMaxType, COLORSCALE_AUTO);
        DataBarTypeSelectHdl(*maLbDataBarMinType);
        selectType(*mxLbDataBarMinType, COLORSCALE_AUTO);
        selectType(*mxLbDataBarMaxType, COLORSCALE_AUTO);
        DataBarTypeSelectHdl(*mxLbDataBarMinType);
    }
    Init();

    maLbColorFormat->SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
}

ScDataBarFrmtEntry::~ScDataBarFrmtEntry()
{
    disposeOnce();
}

void ScDataBarFrmtEntry::dispose()
{
    maLbColorFormat.clear();
    maLbDataBarMinType.clear();
    maLbDataBarMaxType.clear();
    maEdDataBarMin.clear();
    maEdDataBarMax.clear();
    maBtOptions.clear();
    maFtMin.clear();
    maFtMax.clear();
    ScCondFrmtEntry::dispose();
}

ScFormatEntry* ScDataBarFrmtEntry::GetEntry() const
@@ -1220,10 +1091,10 @@ ScFormatEntry* ScDataBarFrmtEntry::GetEntry() const

void ScDataBarFrmtEntry::Init()
{
    maLbDataBarMinType->SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
    maLbDataBarMaxType->SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
    mxLbDataBarMinType->connect_changed( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
    mxLbDataBarMaxType->connect_changed( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );

    maBtOptions->SetClickHdl( LINK( this, ScDataBarFrmtEntry, OptionBtnHdl ) );
    mxBtOptions->connect_clicked( LINK( this, ScDataBarFrmtEntry, OptionBtnHdl ) );

    if(!mpDataBarData)
    {
@@ -1238,10 +1109,10 @@ void ScDataBarFrmtEntry::Init()

ScFormatEntry* ScDataBarFrmtEntry::createDatabarEntry() const
{
    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *maLbDataBarMinType,
                       *maEdDataBarMin, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *maLbDataBarMaxType,
                       *maEdDataBarMax, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *mxLbDataBarMinType,
                       *mxEdDataBarMin, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *mxLbDataBarMaxType,
                       *mxEdDataBarMax, mpDoc, maPos);
    ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
    pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData));
    return pDataBar;
@@ -1254,68 +1125,69 @@ OUString ScDataBarFrmtEntry::GetExpressionString()

void ScDataBarFrmtEntry::SetActive()
{
    maLbColorFormat->Show();
    mxLbColorFormat->show();

    maLbDataBarMinType->Show();
    maLbDataBarMaxType->Show();
    maEdDataBarMin->Show();
    maEdDataBarMax->Show();
    maBtOptions->Show();
    mxLbDataBarMinType->show();
    mxLbDataBarMaxType->show();
    mxEdDataBarMin->show();
    mxEdDataBarMax->show();
    mxBtOptions->show();

    Select();
}

void ScDataBarFrmtEntry::SetInactive()
{
    maLbColorFormat->Hide();
    mxLbColorFormat->hide();

    maLbDataBarMinType->Hide();
    maLbDataBarMaxType->Hide();
    maEdDataBarMin->Hide();
    maEdDataBarMax->Hide();
    maBtOptions->Hide();
    mxLbDataBarMinType->hide();
    mxLbDataBarMaxType->hide();
    mxEdDataBarMin->hide();
    mxEdDataBarMax->hide();
    mxBtOptions->hide();

    Deselect();
}

IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl, ListBox&, void )
IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl, weld::ComboBox&, void )
{
    if (getSelectedType(*maLbDataBarMinType) <= COLORSCALE_MAX)
        maEdDataBarMin->Disable();
    if (getSelectedType(*mxLbDataBarMinType) <= COLORSCALE_MAX)
        mxEdDataBarMin->set_sensitive(false);
    else
        maEdDataBarMin->Enable();
        mxEdDataBarMin->set_sensitive(true);

    if (getSelectedType(*maLbDataBarMaxType) <= COLORSCALE_MAX)
        maEdDataBarMax->Disable();
    if (getSelectedType(*mxLbDataBarMaxType) <= COLORSCALE_MAX)
        mxEdDataBarMax->set_sensitive(false);
    else
        maEdDataBarMax->Enable();
        mxEdDataBarMax->set_sensitive(true);
}

IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl, Button*, void )
IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl, weld::Button&, void )
{
    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *maLbDataBarMinType,
                       *maEdDataBarMin, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *maLbDataBarMaxType,
                       *maEdDataBarMax, mpDoc, maPos);
    ScDataBarSettingsDlg aDlg(GetFrameWeld(), *mpDataBarData, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *mxLbDataBarMinType,
                       *mxEdDataBarMin, mpDoc, maPos);
    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *mxLbDataBarMaxType,
                       *mxEdDataBarMax, mpDoc, maPos);
    ScDataBarSettingsDlg aDlg(mpParent->GetFrameWeld(), *mpDataBarData, mpDoc, maPos);
    if (aDlg.run() == RET_OK)
    {
        mpDataBarData.reset(aDlg.GetData());
        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *maLbDataBarMinType, *maEdDataBarMin, mpDoc);
        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *maLbDataBarMaxType, *maEdDataBarMax, mpDoc);
        DataBarTypeSelectHdl(*maLbDataBarMinType);
        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *mxLbDataBarMinType, *mxEdDataBarMin, mpDoc);
        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *mxLbDataBarMaxType, *mxEdDataBarMax, mpDoc);
        DataBarTypeSelectHdl(*mxLbDataBarMinType);
    }
}

ScDateFrmtEntry::ScDateFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat)
ScDateFrmtEntry::ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, ScAddress())
    , mxLbDateEntry(mxBuilder->weld_combo_box("datetype"))
    , mxFtStyle(mxBuilder->weld_label("styleft"))
    , mxLbStyle(mxBuilder->weld_combo_box("style"))
    , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
    , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
    , mbIsInStyleCreate(false)
{
    get(maLbDateEntry, "datetype");
    get(maFtStyle, "styleft");
    get(maLbStyle, "style");
    get(maWdPreview, "preview");
    maWdPreview->set_height_request(maLbStyle->get_preferred_size().Height());
    mxWdPreview->set_size_request(mxLbStyle->get_preferred_size().Height(), -1);

    Init();

@@ -1324,54 +1196,44 @@ ScDateFrmtEntry::ScDateFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const S
    if(pFormat)
    {
        sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType());
        maLbDateEntry->SelectEntryPos(nPos);
        mxLbDateEntry->set_active(nPos);

        maLbStyle->SelectEntry(pFormat->GetStyleName());
        mxLbStyle->set_active_text(pFormat->GetStyleName());
    }

    StyleSelectHdl(*maLbStyle);
    StyleSelectHdl(*mxLbStyle);
}

ScDateFrmtEntry::~ScDateFrmtEntry()
{
    disposeOnce();
}

void ScDateFrmtEntry::dispose()
{
    maLbDateEntry.clear();
    maFtStyle.clear();
    maLbStyle.clear();
    maWdPreview.clear();
    ScCondFrmtEntry::dispose();
}

void ScDateFrmtEntry::Init()
{
    maLbDateEntry->SelectEntryPos(0);
    maLbType->SelectEntryPos(3);
    mxLbDateEntry->set_active(0);
    mxLbType->set_active(3);

    FillStyleListBox( mpDoc, *maLbStyle );
    maLbStyle->SetSelectHdl( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) );
    maLbStyle->SelectEntryPos(1);
    FillStyleListBox( mpDoc, *mxLbStyle );
    mxLbStyle->connect_changed( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) );
    mxLbStyle->set_active(1);
}

void ScDateFrmtEntry::SetActive()
{
    maLbDateEntry->Show();
    maFtStyle->Show();
    maWdPreview->Show();
    maLbStyle->Show();
    mxLbDateEntry->show();
    mxFtStyle->show();
    mxWdPreviewWin->show();
    mxLbStyle->show();

    Select();
}

void ScDateFrmtEntry::SetInactive()
{
    maLbDateEntry->Hide();
    maFtStyle->Hide();
    maWdPreview->Hide();
    maLbStyle->Hide();
    mxLbDateEntry->hide();
    mxFtStyle->hide();
    mxWdPreviewWin->hide();
    mxLbStyle->hide();

    Deselect();
}
@@ -1381,16 +1243,16 @@ void ScDateFrmtEntry::Notify( SfxBroadcaster&, const SfxHint& rHint )
    if(rHint.GetId() == SfxHintId::StyleSheetModified)
    {
        if(!mbIsInStyleCreate)
            UpdateStyleList(*maLbStyle, mpDoc);
            UpdateStyleList(*mxLbStyle, mpDoc);
    }
}

ScFormatEntry* ScDateFrmtEntry::GetEntry() const
{
    ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc);
    condformat::ScCondFormatDateType eType = static_cast<condformat::ScCondFormatDateType>(maLbDateEntry->GetSelectedEntryPos());
    condformat::ScCondFormatDateType eType = static_cast<condformat::ScCondFormatDateType>(mxLbDateEntry->get_active());
    pNewEntry->SetDateType(eType);
    pNewEntry->SetStyleName(maLbStyle->GetSelectedEntry());
    pNewEntry->SetStyleName(mxLbStyle->get_active_text());
    return pNewEntry;
}

@@ -1399,65 +1261,68 @@ OUString ScDateFrmtEntry::GetExpressionString()
    return ScCondFormatHelper::GetExpression(DATE, 0);
}

IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl, ListBox&, void )
IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl, weld::ComboBox&, void )
{
    mbIsInStyleCreate = true;
    StyleSelect( *maLbStyle, mpDoc, *maWdPreview );
    StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
    mbIsInStyleCreate = false;
}

class ScIconSetFrmtDataEntry : public VclContainer
                             , public VclBuilderContainer
class ScIconSetFrmtDataEntry
{
protected:
    std::unique_ptr<weld::Builder> mxBuilder;
private:
    VclPtr<VclGrid> maGrid;
    VclPtr<FixedImage> maImgIcon;
    VclPtr<FixedText> maFtEntry;
    VclPtr<Edit> maEdEntry;
    VclPtr<ListBox> maLbEntryType;
    std::unique_ptr<weld::Container> mxGrid;
    std::unique_ptr<weld::Image> mxImgIcon;
    std::unique_ptr<weld::Label> mxFtEntry;
    std::unique_ptr<weld::Entry> mxEdEntry;
    std::unique_ptr<weld::ComboBox> mxLbEntryType;

public:
    ScIconSetFrmtDataEntry( vcl::Window* pParent, ScIconSetType eType, ScDocument* pDoc,
            sal_Int32 i, const ScColorScaleEntry* pEntry = nullptr );
    virtual ~ScIconSetFrmtDataEntry() override;
    virtual Size calculateRequisition() const override;
    virtual void setAllocation(const Size &rAllocation) override;
    virtual void dispose() override;
    ScIconSetFrmtDataEntry(weld::Container* pParent, ScIconSetType eType, ScDocument* pDoc,
            sal_Int32 i, const ScColorScaleEntry* pEntry = nullptr);
    void Show() { mxGrid->show(); }
    void Hide() { mxGrid->hide(); }
    void set_grid_top_attach(int nTop)
    {
        mxGrid->set_grid_left_attach(0);
        mxGrid->set_grid_top_attach(nTop);
    }

    ScColorScaleEntry* CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const;

    void SetFirstEntry();
};

ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry(vcl::Window* pParent, ScIconSetType eType, ScDocument* pDoc, sal_Int32 i, const ScColorScaleEntry* pEntry)
    : VclContainer(pParent)
ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry(weld::Container* pParent, ScIconSetType eType, ScDocument* pDoc, sal_Int32 i, const ScColorScaleEntry* pEntry)
    : mxBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/conditionaliconset.ui"))
    , mxGrid(mxBuilder->weld_container("ConditionalIconSet"))
    , mxImgIcon(mxBuilder->weld_image("icon"))
    , mxFtEntry(mxBuilder->weld_label("label"))
    , mxEdEntry(mxBuilder->weld_entry("entry"))
    , mxLbEntryType(mxBuilder->weld_combo_box("listbox"))
{
    m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "modules/scalc/ui/conditionaliconset.ui"));
    get(maGrid, "ConditionalIconSet");
    get(maImgIcon, "icon");
    get(maFtEntry, "label");
    get(maEdEntry, "entry");
    get(maLbEntryType, "listbox");
    maImgIcon->SetImage(Image(ScIconSetFormat::getBitmap(pDoc->GetIconSetBitmapMap(), eType, i)));
    mxImgIcon->set_from_icon_name(ScIconSetFormat::getIconName(eType, i));
    if(pEntry)
    {
        switch(pEntry->GetType())
        {
            case COLORSCALE_VALUE:
                maLbEntryType->SelectEntryPos(0);
                maEdEntry->SetText(convertNumberToString(pEntry->GetValue(), pDoc));
                mxLbEntryType->set_active(0);
                mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
                break;
            case COLORSCALE_PERCENTILE:
                maLbEntryType->SelectEntryPos(2);
                maEdEntry->SetText(convertNumberToString(pEntry->GetValue(), pDoc));
                mxLbEntryType->set_active(2);
                mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
                break;
            case COLORSCALE_PERCENT:
                maLbEntryType->SelectEntryPos(1);
                maEdEntry->SetText(convertNumberToString(pEntry->GetValue(), pDoc));
                mxLbEntryType->set_active(1);
                mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
                break;
            case COLORSCALE_FORMULA:
                maLbEntryType->SelectEntryPos(3);
                maEdEntry->SetText(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
                mxLbEntryType->set_active(3);
                mxEdEntry->set_text(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
                break;
            default:
                assert(false);
@@ -1465,44 +1330,14 @@ ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry(vcl::Window* pParent, ScIconSetTy
    }
    else
    {
        maLbEntryType->SelectEntryPos(1);
        mxLbEntryType->set_active(1);
    }
}

Size ScIconSetFrmtDataEntry::calculateRequisition() const
{
    if (!maGrid) //during dispose
        return Size();
    return getLayoutRequisition(*maGrid);
}

void ScIconSetFrmtDataEntry::setAllocation(const Size &rAllocation)
{
    if (!maGrid) //during dispose
        return;
    setLayoutPosSize(*maGrid, Point(0, 0), rAllocation);
}

ScIconSetFrmtDataEntry::~ScIconSetFrmtDataEntry()
{
    disposeOnce();
}

void ScIconSetFrmtDataEntry::dispose()
{
    maImgIcon.clear();
    maFtEntry.clear();
    maEdEntry.clear();
    maLbEntryType.clear();
    maGrid.clear();
    disposeBuilder();
    VclContainer::dispose();
}

ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const
{
    sal_Int32 nPos = maLbEntryType->GetSelectedEntryPos();
    OUString aText = maEdEntry->GetText();
    sal_Int32 nPos = mxLbEntryType->get_active();
    OUString aText = mxEdEntry->get_text();
    ScColorScaleEntry* pEntry = new ScColorScaleEntry();

    sal_uInt32 nIndex = 0;
@@ -1535,88 +1370,71 @@ ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument* pDoc, const S

void ScIconSetFrmtDataEntry::SetFirstEntry()
{
    maEdEntry->Hide();
    maLbEntryType->Hide();
    maFtEntry->Hide();
    maEdEntry->SetText("0");
    maLbEntryType->SelectEntryPos(1);
    mxEdEntry->hide();
    mxLbEntryType->hide();
    mxFtEntry->hide();
    mxEdEntry->set_text("0");
    mxLbEntryType->set_active(1);
}

ScIconSetFrmtEntry::ScIconSetFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat)
ScIconSetFrmtEntry::ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat)
    : ScCondFrmtEntry(pParent, pDoc, rPos)
    , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
    , mxLbIconSetType(mxBuilder->weld_combo_box("iconsettype"))
    , mxIconParent(mxBuilder->weld_container("iconparent"))
{
    get(maLbColorFormat, "colorformat");
    get(maLbIconSetType, "iconsettype");
    get(maIconParent, "iconparent");

    Init();
    maLbColorFormat->SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    mxLbColorFormat->connect_changed(LINK(pParent, ScCondFormatList, ColFormatTypeHdl));

    if(pFormat)
    {
        const ScIconSetFormatData* pIconSetFormatData = pFormat->GetIconSetData();
        ScIconSetType eType = pIconSetFormatData->eIconSetType;
        sal_Int32 nType = static_cast<sal_Int32>(eType);
        maLbIconSetType->SelectEntryPos(nType);
        mxLbIconSetType->set_active(nType);

        for (size_t i = 0, n = pIconSetFormatData->m_Entries.size();
                i < n; ++i)
        {
            maEntries.push_back(VclPtr<ScIconSetFrmtDataEntry>::Create(
                maIconParent, eType, pDoc, i, pIconSetFormatData->m_Entries[i].get()));
            maEntries.emplace_back(new ScIconSetFrmtDataEntry(
                mxIconParent.get(), eType, pDoc, i, pIconSetFormatData->m_Entries[i].get()));
            maEntries[i]->set_grid_top_attach(i);
        }
        maEntries[0]->SetFirstEntry();
    }
    else
        IconSetTypeHdl(*maLbIconSetType);
        IconSetTypeHdl(*mxLbIconSetType);
}

ScIconSetFrmtEntry::~ScIconSetFrmtEntry()
{
    disposeOnce();
}

void ScIconSetFrmtEntry::dispose()
{
    for (auto& rxEntry : maEntries)
        rxEntry.disposeAndClear();
    maEntries.clear();
    maIconParent.clear();
    maLbColorFormat.clear();
    maLbIconSetType.clear();
    ScCondFrmtEntry::dispose();
}

void ScIconSetFrmtEntry::Init()
{
    maLbColorFormat->SelectEntryPos(3);
    maLbType->SelectEntryPos(0);
    maLbIconSetType->SelectEntryPos(0);
    mxLbColorFormat->set_active(3);
    mxLbType->set_active(0);
    mxLbIconSetType->set_active(0);

    maLbIconSetType->SetSelectHdl( LINK( this, ScIconSetFrmtEntry, IconSetTypeHdl ) );
    mxLbIconSetType->connect_changed(LINK(this, ScIconSetFrmtEntry, IconSetTypeHdl));
}

IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl, ListBox&, void )
IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl, weld::ComboBox&, void )
{
    const ScIconSetMap* pMap = ScIconSetFormat::g_IconSetMap;

    sal_Int32 nPos = maLbIconSetType->GetSelectedEntryPos();
    sal_Int32 nPos = mxLbIconSetType->get_active();
    sal_uInt32 nElements = pMap[nPos].nElements;

    for (auto& rxEntry : maEntries)
        rxEntry.disposeAndClear();
    maEntries.clear();

    for(size_t i = 0; i < nElements; ++i)
    {
        maEntries.push_back(VclPtr<ScIconSetFrmtDataEntry>::Create(maIconParent, static_cast<ScIconSetType>(nPos), mpDoc, i));
        maEntries.emplace_back(new ScIconSetFrmtDataEntry(mxIconParent.get(), static_cast<ScIconSetType>(nPos), mpDoc, i));
        maEntries[i]->set_grid_top_attach(i);
        maEntries[i]->Show();
    }
    maEntries[0]->SetFirstEntry();

    SetHeight();
}

OUString ScIconSetFrmtEntry::GetExpressionString()
@@ -1626,8 +1444,8 @@ OUString ScIconSetFrmtEntry::GetExpressionString()

void ScIconSetFrmtEntry::SetActive()
{
    maLbColorFormat->Show();
    maLbIconSetType->Show();
    mxLbColorFormat->show();
    mxLbIconSetType->show();
    for(auto& rxEntry : maEntries)
    {
        rxEntry->Show();
@@ -1638,8 +1456,8 @@ void ScIconSetFrmtEntry::SetActive()

void ScIconSetFrmtEntry::SetInactive()
{
    maLbColorFormat->Hide();
    maLbIconSetType->Hide();
    mxLbColorFormat->hide();
    mxLbIconSetType->hide();
    for(auto& rxEntry : maEntries)
    {
        rxEntry->Hide();
@@ -1653,7 +1471,7 @@ ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const
    ScIconSetFormat* pFormat = new ScIconSetFormat(mpDoc);

    ScIconSetFormatData* pData = new ScIconSetFormatData;
    pData->eIconSetType = static_cast<ScIconSetType>(maLbIconSetType->GetSelectedEntryPos());
    pData->eIconSetType = static_cast<ScIconSetType>(mxLbIconSetType->get_active());
    for(const auto& rxEntry : maEntries)
    {
        pData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(rxEntry->CreateEntry(mpDoc, maPos)));
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index ed1ef66..a2f9bae 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -31,83 +31,82 @@ class ScViewData;

class ScCondFormatDlg;

class ScCondFormatList : public Control
class ScCondFormatList
{
private:
    typedef std::vector<VclPtr<ScCondFrmtEntry>> EntryContainer;
    std::unique_ptr<weld::ScrolledWindow> mxScrollWindow;
    std::unique_ptr<weld::Container> mxGrid;

    typedef std::vector<std::unique_ptr<ScCondFrmtEntry>> EntryContainer;
    EntryContainer maEntries;

    bool mbHasScrollBar;
    bool mbFrozen;
    bool mbNewEntry;
    VclPtr<ScrollBar> mpScrollBar;

    ScDocument* mpDoc;
    ScAddress maPos;
    ScRangeList maRanges;
    VclPtr<ScCondFormatDlg> mpDialogParent;

    void DoScroll(long nDiff);
    ScCondFormatDlg* mpDialogParent;

public:
    ScCondFormatList(vcl::Window* pParent, WinBits nStyle);
    virtual ~ScCondFormatList() override;
    virtual void dispose() override;
    ScCondFormatList(ScCondFormatDlg* pParent,
                     std::unique_ptr<weld::ScrolledWindow> xWindow,
                     std::unique_ptr<weld::Container> xGrid);
    weld::ScrolledWindow* GetWidget() { return mxScrollWindow.get(); }
    weld::Container* GetContainer() { return mxGrid.get(); }
    ~ScCondFormatList();

    void init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScConditionalFormat* pFormat,
    void init(ScDocument* pDoc, const ScConditionalFormat* pFormat,
        const ScRangeList& rRanges, const ScAddress& rPos,
        condformat::dialog::ScCondFormatDialogType eType);

    void SetRange(const ScRangeList& rRange);

    virtual Size GetOptimalSize() const override;
    virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
    virtual void Resize() override;

    std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const;
    weld::Window* GetFrameWeld();
    void Freeze() { mbFrozen = true; }
    void Thaw() { mbFrozen = false; }
    void RecalcAll();

    DECL_LINK( AddBtnHdl, Button*, void );
    DECL_LINK( RemoveBtnHdl, Button*, void );
    DECL_LINK( UpBtnHdl, Button*, void );
    DECL_LINK( DownBtnHdl, Button*, void );
    DECL_LINK( ScrollHdl, ScrollBar*, void );
    DECL_LINK( AddBtnHdl, weld::Button&, void );
    DECL_LINK( RemoveBtnHdl, weld::Button&, void );
    DECL_LINK( UpBtnHdl, weld::Button&, void );
    DECL_LINK( DownBtnHdl, weld::Button&, void );
    DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
    DECL_LINK( EntrySelectHdl, ScCondFrmtEntry&, void );

    DECL_LINK( TypeListHdl, ListBox&, void );
    DECL_LINK( TypeListHdl, weld::ComboBox&, void );
    DECL_LINK( AfterTypeListHdl, void*, void );
    DECL_LINK( ColFormatTypeHdl, ListBox&, void );
    DECL_LINK( ColFormatTypeHdl, weld::ComboBox&, void );
    DECL_LINK( AfterColFormatTypeHdl, void*, void );
};

class ScCondFormatDlg : public ScAnyRefDlg
class ScCondFormatDlg : public ScAnyRefDlgController
{
private:
    VclPtr<PushButton> mpBtnOk;
    VclPtr<PushButton> mpBtnAdd;
    VclPtr<PushButton> mpBtnRemove;
    VclPtr<PushButton> mpBtnUp;
    VclPtr<PushButton> mpBtnDown;
    VclPtr<PushButton> mpBtnCancel;
    VclPtr<FixedText> mpFtRange;
    VclPtr<formula::RefEdit> mpEdRange;
    VclPtr<formula::RefButton> mpRbRange;

    VclPtr<ScCondFormatList> mpCondFormList;
    sal_Int32 mnKey;

    ScAddress maPos;
    ScViewData* mpViewData;

    VclPtr<formula::RefEdit> mpLastEdit;

    std::shared_ptr<ScCondFormatDlgItem> mpDlgItem;

    OUString msBaseTitle;
    void updateTitle();

    DECL_LINK( EdRangeModifyHdl, Edit&, void );
    formula::WeldRefEdit* mpLastEdit;
    std::unique_ptr<weld::Button> mxBtnOk;
    std::unique_ptr<weld::Button> mxBtnAdd;
    std::unique_ptr<weld::Button> mxBtnRemove;
    std::unique_ptr<weld::Button> mxBtnUp;
    std::unique_ptr<weld::Button> mxBtnDown;
    std::unique_ptr<weld::Button> mxBtnCancel;
    std::unique_ptr<weld::Label> mxFtRange;
    std::unique_ptr<formula::WeldRefEdit> mxEdRange;
    std::unique_ptr<formula::WeldRefButton> mxRbRange;
    std::unique_ptr<ScCondFormatList> mxCondFormList;

    void updateTitle();
    DECL_LINK( EdRangeModifyHdl, formula::WeldRefEdit&, void );
protected:

    virtual void RefInputDone( bool bForced = false ) override;
@@ -115,10 +114,9 @@ protected:
    void CancelPressed();

public:
    SC_DLLPUBLIC ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pWindow,
    SC_DLLPUBLIC ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pWindow,
                                 ScViewData* pViewData, const ScCondFormatDlgItem* pDlgItem);
    virtual ~ScCondFormatDlg() override;
    virtual void dispose() override;

    SC_DLLPUBLIC std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const;

@@ -126,13 +124,13 @@ public:
    virtual bool IsRefInputMode() const override;
    virtual void SetActive() override;
    virtual bool IsTableLocked() const override;
    virtual bool Close() override;
    virtual void Close() override;

    void InvalidateRefData();
    void OnSelectionChange(size_t nIndex, size_t nSize, bool bSelected = true);

    DECL_LINK( BtnPressedHdl, Button*, void );
    DECL_LINK( RangeGetFocusHdl, Control&, void );
    DECL_LINK( BtnPressedHdl, weld::Button&, void );
    DECL_LINK( RangeGetFocusHdl, formula::WeldRefEdit&, void );
};

#endif
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index a463605..83ba664 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -15,12 +15,14 @@
#include <vcl/vclptr.hxx>
#include <vcl/builder.hxx>
#include <vcl/layout.hxx>
#include <vcl/weld.hxx>
#include <svl/lstner.hxx>
#include <svx/fntctrl.hxx>

class ScIconSetFrmtDataEntry;
class ScCondFormatDlg;
class SvxColorListBox;
class ScCondFormatList;
class ColorListBox;
class ScColorScaleFormat;
class ScDataBarFormat;
class ScIconSetFormat;
@@ -45,22 +47,27 @@ enum ScCondFrmtEntryType

}

class ScCondFrmtEntry : public VclContainer
                      , public VclBuilderContainer
class ScCondFrmtEntry
{
private:
    bool mbActive;
protected:
    ScCondFormatList* mpParent;
    std::unique_ptr<weld::Builder> mxBuilder;

private:
    //general ui elements
    std::unique_ptr<weld::Widget> mxBorder;
    std::unique_ptr<weld::Container> mxGrid;
    std::unique_ptr<weld::Label> mxFtCondNr;
    std::unique_ptr<weld::Label> mxFtCondition;

    bool mbActive;
    OUString const maStrCondition;
    Link<ScCondFrmtEntry&,void> maClickHdl;

    //general ui elements
    VclPtr<VclContainer> maGrid;
    VclPtr<FixedText> maFtCondNr;
    VclPtr<FixedText> maFtCondition;
    DECL_LINK( EntrySelectHdl, const MouseEvent&, bool );

    OUString const maStrCondition;
protected:
    VclPtr<ListBox> maLbType;
    std::unique_ptr<weld::ComboBox> mxLbType;

    ScDocument* mpDoc;
    ScAddress maPos;
@@ -71,18 +78,20 @@ protected:
    virtual OUString GetExpressionString() = 0;

public:
    ScCondFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos );
    virtual ~ScCondFrmtEntry() override;
    virtual Size calculateRequisition() const override;
    virtual void setAllocation(const Size &rAllocation) override;
    virtual void dispose() override;
    ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos);
    virtual ~ScCondFrmtEntry();

    virtual bool EventNotify( NotifyEvent& rNEvt ) override;
    void Show() { mxGrid->show(); }
    void Hide() { mxGrid->hide(); }

    void set_grid_top_attach(int nAttach) { mxBorder->set_grid_top_attach(nAttach); }
    int get_grid_top_attach() const { return mxBorder->get_grid_top_attach(); }

    Size get_preferred_size() const { return mxBorder->get_preferred_size(); }

    void SetPos(const ScAddress& rPos) { maPos = rPos; };
    bool IsSelected() const { return mbActive;}
    void SetIndex(sal_Int32 nIndex);
    void SetHeight();

    virtual ScFormatEntry* GetEntry() const = 0;
    virtual void SetActive() = 0;
@@ -94,13 +103,15 @@ public:
class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener
{
    //cond format ui elements
    VclPtr<ListBox> maLbCondType;
    VclPtr<formula::RefEdit> maEdVal1;
    VclPtr<formula::RefEdit> maEdVal2;
    VclPtr<FixedText> maFtVal;
    VclPtr<FixedText> maFtStyle;
    VclPtr<ListBox> maLbStyle;
    VclPtr<SvxFontPrevWindow> maWdPreview;
    FontPrevWindow maWdPreview;
    std::unique_ptr<weld::ComboBox> mxLbCondType;
    std::unique_ptr<formula::WeldRefEdit> mxEdVal1;
    std::unique_ptr<formula::WeldRefEdit> mxEdVal2;
    std::unique_ptr<weld::Label> mxFtVal;
    std::unique_ptr<weld::Label> mxFtStyle;
    std::unique_ptr<weld::ComboBox> mxLbStyle;
    std::unique_ptr<weld::Widget> mxWdPreviewWin;
    std::unique_ptr<weld::CustomWeld> mxWdPreview;
    bool mbIsInStyleCreate;

    static const sal_Int32 NUM_COND_ENTRIES = 24;
@@ -111,9 +122,9 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener

    virtual OUString GetExpressionString() override;
    void Init(ScCondFormatDlg* pDialogParent);
    DECL_LINK( StyleSelectHdl, ListBox&, void );
    DECL_LINK( ConditionTypeSelectHdl, ListBox&, void );
    DECL_LINK( OnEdChanged, Edit&, void );
    DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
    DECL_LINK( ConditionTypeSelectHdl, weld::ComboBox&, void );
    DECL_LINK( OnEdChanged, formula::WeldRefEdit&, void );

    // Searches the lookup table for the entry position, given condition mode
    static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode );
@@ -127,10 +138,9 @@ protected:
    virtual void Deselect() override;

public:
    ScConditionFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
            const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr );
    ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
            const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
    virtual ~ScConditionFrmtEntry() override;
    virtual void dispose() override;

    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
@@ -143,21 +153,22 @@ public:

class ScFormulaFrmtEntry : public ScCondFrmtEntry
{
    VclPtr<FixedText> maFtStyle;
    VclPtr<ListBox> maLbStyle;
    VclPtr<SvxFontPrevWindow> maWdPreview;
    VclPtr<formula::RefEdit> maEdFormula;
    FontPrevWindow maWdPreview;
    std::unique_ptr<weld::Label> mxFtStyle;
    std::unique_ptr<weld::ComboBox> mxLbStyle;
    std::unique_ptr<weld::Widget> mxWdPreviewWin;
    std::unique_ptr<weld::CustomWeld> mxWdPreview;
    std::unique_ptr<formula::WeldRefEdit> mxEdFormula;

    ScFormatEntry* createFormulaEntry() const;
    virtual OUString GetExpressionString() override;
    void Init(ScCondFormatDlg* pDialogParent);

    DECL_LINK( StyleSelectHdl, ListBox&, void );
    DECL_LINK(StyleSelectHdl, weld::ComboBox&, void);

public:
    ScFormulaFrmtEntry( vcl::Window* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr );
    ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
    virtual ~ScFormulaFrmtEntry() override;
    virtual void dispose() override;

    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
@@ -169,31 +180,30 @@ class ScColorScale2FrmtEntry : public ScCondFrmtEntry
{

    //color format ui elements
    VclPtr<ListBox> maLbColorFormat;
    std::unique_ptr<weld::ComboBox> mxLbColorFormat;

    //color scale ui elements
    VclPtr<ListBox> maLbEntryTypeMin;
    VclPtr<ListBox> maLbEntryTypeMax;
    std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
    std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;

    VclPtr<Edit> maEdMin;
    VclPtr<Edit> maEdMax;
    std::unique_ptr<weld::Entry> mxEdMin;
    std::unique_ptr<weld::Entry> mxEdMax;

    VclPtr<SvxColorListBox> maLbColMin;
    VclPtr<SvxColorListBox> maLbColMax;
    std::unique_ptr<ColorListBox> mxLbColMin;
    std::unique_ptr<ColorListBox> mxLbColMax;

    VclPtr<FixedText> maFtMin;
    VclPtr<FixedText> maFtMax;
    std::unique_ptr<weld::Label> mxFtMin;
    std::unique_ptr<weld::Label> mxFtMax;

    ScFormatEntry* createColorscaleEntry() const;

    virtual OUString GetExpressionString() override;
    void Init();

    DECL_LINK( EntryTypeHdl, ListBox&, void );
    DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
public:
    ScColorScale2FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr );
    ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
    virtual ~ScColorScale2FrmtEntry() override;
    virtual void dispose() override;
    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
    virtual void SetInactive() override;
@@ -204,34 +214,33 @@ class ScColorScale3FrmtEntry : public ScCondFrmtEntry
{

    //color format ui elements
    VclPtr<ListBox> maLbColorFormat;
    std::unique_ptr<weld::ComboBox> mxLbColorFormat;

    //color scale ui elements
    VclPtr<ListBox> maLbEntryTypeMin;
    VclPtr<ListBox> maLbEntryTypeMiddle;
    VclPtr<ListBox> maLbEntryTypeMax;
    std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
    std::unique_ptr<weld::ComboBox> mxLbEntryTypeMiddle;
    std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;

    VclPtr<Edit> maEdMin;
    VclPtr<Edit> maEdMiddle;
    VclPtr<Edit> maEdMax;
    std::unique_ptr<weld::Entry> mxEdMin;
    std::unique_ptr<weld::Entry> mxEdMiddle;
    std::unique_ptr<weld::Entry> mxEdMax;

    VclPtr<SvxColorListBox> maLbColMin;
    VclPtr<SvxColorListBox> maLbColMiddle;
    VclPtr<SvxColorListBox> maLbColMax;
    std::unique_ptr<ColorListBox> mxLbColMin;
    std::unique_ptr<ColorListBox> mxLbColMiddle;
    std::unique_ptr<ColorListBox> mxLbColMax;

    VclPtr<FixedText> maFtMin;
    VclPtr<FixedText> maFtMax;
    std::unique_ptr<weld::Label> mxFtMin;
    std::unique_ptr<weld::Label> mxFtMax;

    ScFormatEntry* createColorscaleEntry() const;

    virtual OUString GetExpressionString() override;
    void Init();

    DECL_LINK( EntryTypeHdl, ListBox&, void );
    DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
public:
    ScColorScale3FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr );
    ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
    virtual ~ScColorScale3FrmtEntry() override;
    virtual void dispose() override;
    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
    virtual void SetInactive() override;
@@ -241,18 +250,17 @@ public:
class ScDataBarFrmtEntry : public ScCondFrmtEntry
{
    //color format ui elements
    VclPtr<ListBox> maLbColorFormat;
    std::unique_ptr<weld::ComboBox> mxLbColorFormat;

    //data bar ui elements
    VclPtr<ListBox> maLbDataBarMinType;
    VclPtr<ListBox> maLbDataBarMaxType;
    VclPtr<Edit> maEdDataBarMin;
    VclPtr<Edit> maEdDataBarMax;
    std::unique_ptr<weld::ComboBox> mxLbDataBarMinType;
    std::unique_ptr<weld::ComboBox> mxLbDataBarMaxType;
    std::unique_ptr<weld::Entry> mxEdDataBarMin;
    std::unique_ptr<weld::Entry> mxEdDataBarMax;
    std::unique_ptr<weld::Button> mxBtOptions;

    VclPtr<PushButton> maBtOptions;

    VclPtr<FixedText> maFtMin;
    VclPtr<FixedText> maFtMax;
    std::unique_ptr<weld::Label> mxFtMin;
    std::unique_ptr<weld::Label> mxFtMax;

    std::unique_ptr<ScDataBarFormatData> mpDataBarData;

@@ -261,12 +269,11 @@ class ScDataBarFrmtEntry : public ScCondFrmtEntry
    virtual OUString GetExpressionString() override;
    void Init();

    DECL_LINK( OptionBtnHdl, Button*, void );
    DECL_LINK( DataBarTypeSelectHdl, ListBox&, void );
    DECL_LINK( OptionBtnHdl, weld::Button&, void );
    DECL_LINK( DataBarTypeSelectHdl, weld::ComboBox&, void );
public:
    ScDataBarFrmtEntry( vcl::Window* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr );
    ScDataBarFrmtEntry(ScCondFormatList* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr);
    virtual ~ScDataBarFrmtEntry() override;
    virtual void dispose() override;
    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
    virtual void SetInactive() override;
@@ -277,9 +284,8 @@ public:
class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener
{
public:
    ScDateFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr );
    ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr);
    virtual ~ScDateFrmtEntry() override;
    virtual void dispose() override;
    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
    virtual void SetInactive() override;
@@ -293,12 +299,14 @@ protected:
private:
    void Init();

    DECL_LINK( StyleSelectHdl, ListBox&, void );
    DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );

    VclPtr<ListBox> maLbDateEntry;
    VclPtr<FixedText> maFtStyle;
    VclPtr<ListBox> maLbStyle;
    VclPtr<SvxFontPrevWindow> maWdPreview;
    FontPrevWindow maWdPreview;
    std::unique_ptr<weld::ComboBox> mxLbDateEntry;
    std::unique_ptr<weld::Label> mxFtStyle;
    std::unique_ptr<weld::ComboBox> mxLbStyle;
    std::unique_ptr<weld::Widget> mxWdPreviewWin;
    std::unique_ptr<weld::CustomWeld> mxWdPreview;

    bool mbIsInStyleCreate;
};
@@ -306,26 +314,25 @@ private:
class ScIconSetFrmtEntry : public ScCondFrmtEntry
{
    //color format ui elements
    VclPtr<ListBox> maLbColorFormat;
    std::unique_ptr<weld::ComboBox> mxLbColorFormat;

    // icon set ui elements
    VclPtr<ListBox> maLbIconSetType;
    std::unique_ptr<weld::ComboBox> mxLbIconSetType;

    VclPtr<VclContainer> maIconParent;
    std::unique_ptr<weld::Container> mxIconParent;

    typedef std::vector<VclPtr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
    typedef std::vector<std::unique_ptr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
    ScIconSetFrmtDataEntriesType maEntries;

    virtual OUString GetExpressionString() override;

    void Init();

    DECL_LINK( IconSetTypeHdl, ListBox&, void );
    DECL_LINK(IconSetTypeHdl, weld::ComboBox&, void);

public:
    ScIconSetFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr );
    ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr);
    virtual ~ScIconSetFrmtEntry() override;
    virtual void dispose() override;
    virtual ScFormatEntry* GetEntry() const override;
    virtual void SetActive() override;
    virtual void SetInactive() override;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index a572751..1d5ab96 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -325,9 +325,6 @@ public:
    void            DeactivateOle();

    static ScTabViewShell* GetActiveViewShell();
    VclPtr<SfxModelessDialog> CreateRefDialog( SfxBindings* pB, SfxChildWindow* pCW,
                                               const SfxChildWinInfo* pInfo,
                                               vcl::Window* pParent, sal_uInt16 nSlotId );

    std::unique_ptr<SfxModelessDialogController> CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW,
                                                    const SfxChildWinInfo* pInfo,
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 9eda9de..0074088 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -132,7 +132,7 @@ bool ScNameDefDlg::IsNameValid()
    }

    ScRangeData::IsNameValidType eType;
    m_xFtInfo->set_error(false);
    m_xFtInfo->set_message_type(weld::EntryMessageType::Normal);
    if ( aName.isEmpty() )
    {
        m_xBtnAdd->set_sensitive(false);
@@ -141,7 +141,7 @@ bool ScNameDefDlg::IsNameValid()
    }
    else if ((eType = ScRangeData::IsNameValid( aName, mpDoc )) != ScRangeData::NAME_VALID)
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        if (eType == ScRangeData::NAME_INVALID_BAD_STRING)
        {
            m_xFtInfo->set_label(maErrInvalidNameStr);
@@ -155,7 +155,7 @@ bool ScNameDefDlg::IsNameValid()
    }
    else if (pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(aName)))
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        m_xFtInfo->set_label(maErrNameInUse);
        m_xBtnAdd->set_sensitive(false);
        return false;
@@ -163,7 +163,7 @@ bool ScNameDefDlg::IsNameValid()

    if (!IsFormulaValid())
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        m_xBtnAdd->set_sensitive(false);
        return false;
    }
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 352e138..d19c2d0 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -252,13 +252,13 @@ bool ScNameDlg::IsNameValid()

    if (ScRangeData::IsNameValid( aName, mpDoc ) != ScRangeData::NAME_VALID)
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        m_xFtInfo->set_label(maErrInvalidNameStr);
        return false;
    }
    else if (pRangeName && pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(aName)))
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        m_xFtInfo->set_label(maErrNameInUse);
        return false;
    }
@@ -272,7 +272,7 @@ bool ScNameDlg::IsFormulaValid()
    std::unique_ptr<ScTokenArray> pCode = aComp.CompileString(m_xEdAssign->GetText());
    if (pCode->GetCodeError() != FormulaError::NONE)
    {
        m_xFtInfo->set_error(true);
        m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
        return false;
    }
    else
@@ -343,7 +343,7 @@ void ScNameDlg::NameModified()
    OUString aOldName = aLine.aName;
    OUString aNewName = m_xEdName->get_text();
    aNewName = aNewName.trim();
    m_xFtInfo->set_error(false);
    m_xFtInfo->set_message_type(weld::EntryMessageType::Normal);
    if (aNewName != aOldName)
    {
        if (!IsNameValid())
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 03fb29f..f718589 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -434,7 +434,10 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
                        aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
                    else if ( nSlotId == SID_STYLE_NEW_BY_EXAMPLE )
                    {
                        SfxNewStyleDlg aDlg(pTabViewShell->GetFrameWeld(), *pStylePool);
                        weld::Window* pDialogParent = rReq.GetFrameWeld();
                        if (!pDialogParent)
                            pDialogParent = pTabViewShell->GetFrameWeld();
                        SfxNewStyleDlg aDlg(pDialogParent, *pStylePool);
                        if (aDlg.run() != RET_OK)
                            return;
                        aStyleName = aDlg.GetName();
@@ -848,7 +851,10 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )

                ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();

                pDlg.disposeAndReset(pFact->CreateScStyleDlg(pTabViewShell->GetFrameWeld(), *pStyleSheet, bPage));
                weld::Window* pDialogParent = rReq.GetFrameWeld();
                if (!pDialogParent)
                    pDialogParent = pTabViewShell->GetFrameWeld();
                pDlg.disposeAndReset(pFact->CreateScStyleDlg(pDialogParent, *pStyleSheet, bPage));
                short nResult = pDlg->Execute();
                pTabViewShell->SetInFormatDialog(false);

diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
index b26ad4a..2583a31 100644
--- a/sc/source/ui/view/reffact.cxx
+++ b/sc/source/ui/view/reffact.cxx
@@ -38,18 +38,18 @@ SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFilterDlgWrapper, SID_FILTER )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFilterDlgWrapper, SID_FILTER)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF )
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF)
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF)

SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)

@@ -64,29 +64,6 @@ namespace
    ScTabViewShell* lcl_GetTabViewShell( const SfxBindings* pBindings );
}

#define IMPL_CHILD_CTOR(Class,sid) \
    Class::Class( vcl::Window*               pParentP,                   \
                    sal_uInt16              nId,                        \
                    SfxBindings*        p,                          \
                    const SfxChildWinInfo*  pInfo )                     \
        : SfxChildWindow(pParentP, nId)                             \
    {                                                               \
        /************************************************************************************/\
        /*      When a new document is creating, the SfxViewFrame may be ready,             */\
        /*      But the ScTabViewShell may have not been activated yet. In this             */\
        /*      situation, SfxViewShell::Current() does not get the correct shell,          */\
        /*      and we should lcl_GetTabViewShell( p ) instead of SfxViewShell::Current()   */\
        /************************************************************************************/\
        ScTabViewShell* pViewShell = lcl_GetTabViewShell( p );      \
        if (!pViewShell)                                            \
            pViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current()  ); \
        OSL_ENSURE( pViewShell, "missing view shell :-(" );         \
        SetWindow( pViewShell ?                                      \
            pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : nullptr );    \
        if (pViewShell && !GetWindow())                                             \
            pViewShell->GetViewFrame()->SetChildWindow( nId, false );           \
    }

#define IMPL_CONTROLLER_CHILD_CTOR(Class,sid) \
    Class::Class( vcl::Window*               pParentP,                   \
                    sal_uInt16              nId,                        \
@@ -316,6 +293,6 @@ ScValidityRefChildWin::~ScValidityRefChildWin()
        SetController(nullptr);
}

IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF )
IMPL_CONTROLLER_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF )

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 3ff4ff5..939a722 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -115,73 +115,6 @@ void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialogController* pDialo
   }
}

VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
                                SfxBindings* pB, SfxChildWindow* pCW,
                                const SfxChildWinInfo* pInfo,
                                vcl::Window* pParent, sal_uInt16 nSlotId )
{
    // only open dialog when called through ScModule::SetRefDialog,
    // so that it does not re appear for instance after a crash (#42341#).

    if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
        return nullptr;

    if ( nCurRefDlgId != nSlotId )
    {
        //  the dialog has been opened in a different view
        //  -> lock the dispatcher for this view (modal mode)

        GetViewData().GetDispatcher().Lock( true );    // lock is reset when closing dialog
        return nullptr;
    }

    VclPtr<SfxModelessDialog> pResult;

    if(pCW)
        pCW->SetHideNotDelete(true);

    switch( nSlotId )
    {
        case WID_CONDFRMT_REF:
        {
            bool        bFound      = false;
            const ScCondFormatDlgItem* pDlgItem = nullptr;
            // Get the pool item stored by Conditional Format Manager Dialog.
            const SfxPoolItem* pItem = nullptr;
            auto itemsRange = GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
            if (itemsRange.begin() != itemsRange.end())
            {
                pItem = *itemsRange.begin();
                pDlgItem = static_cast<const ScCondFormatDlgItem*>(pItem);
                bFound = true;
            }

            ScViewData& rViewData = GetViewData();
            rViewData.SetRefTabNo( rViewData.GetTabNo() );

            pResult = VclPtr<ScCondFormatDlg>::Create( pB, pCW, pParent, &rViewData, pDlgItem );

            // Remove the pool item stored by Conditional Format Manager Dialog.
            if ( bFound && pItem )
                GetPool().Remove( *pItem );
        }
        break;
    }

    if (pResult)
    {
        // the dialogs are always displayed with the option button collapsed,
        // the size has to be carried over initialize
        // (or store the option status !!!)

        Size aSize = pResult->GetSizePixel();
        pResult->Initialize( pInfo );
        pResult->SetSizePixel(aSize);
    }

    return pResult;
}

std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogController(
                                SfxBindings* pB, SfxChildWindow* pCW,
                                const SfxChildWinInfo* pInfo,
@@ -473,6 +406,30 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont
            xResult.reset(new ScFormulaDlg(pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr()));
            break;
        }
        case WID_CONDFRMT_REF:
        {
            bool        bFound      = false;
            const ScCondFormatDlgItem* pDlgItem = nullptr;
            // Get the pool item stored by Conditional Format Manager Dialog.
            const SfxPoolItem* pItem = nullptr;
            auto itemsRange = GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
            if (itemsRange.begin() != itemsRange.end())
            {
                pItem = *itemsRange.begin();
                pDlgItem = static_cast<const ScCondFormatDlgItem*>(pItem);
                bFound = true;
            }

            ScViewData& rViewData = GetViewData();
            rViewData.SetRefTabNo( rViewData.GetTabNo() );

            xResult.reset(new ScCondFormatDlg(pB, pCW, pParent, &rViewData, pDlgItem));

            // Remove the pool item stored by Conditional Format Manager Dialog.
            if ( bFound && pItem )
                GetPool().Remove( *pItem );
            break;
        }
    }

    if (xResult)
diff --git a/sc/uiconfig/scalc/ui/conditionalentry.ui b/sc/uiconfig/scalc/ui/conditionalentry.ui
index 3e5a4663..717f9a2 100644
--- a/sc/uiconfig/scalc/ui/conditionalentry.ui
+++ b/sc/uiconfig/scalc/ui/conditionalentry.ui
@@ -2,251 +2,371 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkGrid" id="grid">
  <object class="GtkScrolledWindow" id="border">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="can_focus">True</property>
    <property name="hexpand">True</property>
    <property name="border_width">6</property>
    <property name="row_spacing">6</property>
    <property name="column_spacing">12</property>
    <property name="hscrollbar_policy">never</property>
    <property name="vscrollbar_policy">never</property>
    <property name="shadow_type">in</property>
    <child>
      <object class="GtkGrid" id="grid1">
      <object class="GtkViewport">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="hexpand">True</property>
        <property name="column_spacing">12</property>
        <child>
          <object class="GtkLabel" id="number">
          <object class="GtkGrid" id="grid">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="condition">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="left_attach">0</property>
        <property name="top_attach">0</property>
      </packing>
    </child>
    <child>
      <object class="GtkGrid" id="grid2">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="hexpand">True</property>
        <property name="row_spacing">6</property>
        <property name="column_spacing">12</property>
        <property name="column_homogeneous">True</property>
        <child>
          <object class="GtkComboBoxText" id="type">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <items>
              <item translatable="yes" context="conditionalentry|type">All Cells</item>
              <item translatable="yes" context="conditionalentry|type">Cell value is</item>
              <item translatable="yes" context="conditionalentry|type">Formula is</item>
              <item translatable="yes" context="conditionalentry|type">Date is</item>
            </items>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="styleft">
            <property name="can_focus">False</property>
            <property name="label" translatable="yes" context="conditionalentry|styleft">Apply Style:</property>
            <property name="use_underline">True</property>
            <property name="mnemonic_widget">style</property>
            <property name="xalign">0</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkComboBoxText" id="style">
            <property name="can_focus">False</property>
            <items>
              <item translatable="yes" context="conditionalentry|style">New Style...</item>
            </items>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="valueft">
            <property name="can_focus">False</property>
            <property name="label" translatable="yes" context="conditionalentry|valueft">Enter a value:</property>
            <property name="xalign">0</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">4</property>
            <property name="width">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkEntry" id="edcolscalemin">
            <property name="can_focus">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkEntry" id="edcolscalemiddle">
            <property name="can_focus">True</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkEntry" id="edcolscalemax">
            <property name="can_focus">True</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">5</property>
          </packing>
        </child>
        <child>
          <object class="svxcorelo-SvxColorListBox" id="lbcolmin">
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">6</property>
          </packing>
        </child>
        <child>
          <object class="svxcorelo-SvxColorListBox" id="lbcolmiddle">
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">6</property>
          </packing>
        </child>
        <child>
          <object class="svxcorelo-SvxColorListBox" id="lbcolmax">
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">6</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="options">
            <property name="label" translatable="yes" context="conditionalentry|options">More Options...</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">7</property>
          </packing>
        </child>
        <child>
          <object class="GtkComboBoxText" id="colscalemin">
            <property name="can_focus">False</property>
            <items>
              <item id="auto" translatable="yes" context="conditionalentry|colscalemin">Automatic</item>
              <item id="min" translatable="yes" context="conditionalentry|colscalemin">Min</item>
              <item id="max" translatable="yes" context="conditionalentry|colscalemin">Max</item>
              <item id="percentil" translatable="yes" context="conditionalentry|colscalemin">Percentile</item>
              <item id="value" translatable="yes" context="conditionalentry|colscalemin">Value</item>
              <item id="percent" translatable="yes" context="conditionalentry|colscalemin">Percent</item>
              <item id="formula" translatable="yes" context="conditionalentry|colscalemin">Formula</item>
            </items>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkComboBoxText" id="colscalemiddle">
            <property name="can_focus">False</property>
            <items>
              <item id="auto" translatable="yes" context="conditionalentry|colscalemiddle">Automatic</item>
              <item id="min" translatable="yes" context="conditionalentry|colscalemiddle">Min</item>
              <item id="max" translatable="yes" context="conditionalentry|colscalemiddle">Max</item>
              <item id="percentil" translatable="yes" context="conditionalentry|colscalemiddle">Percentile</item>
              <item id="value" translatable="yes" context="conditionalentry|colscalemiddle">Value</item>
              <item id="percent" translatable="yes" context="conditionalentry|colscalemiddle">Percent</item>
              <item id="formula" translatable="yes" context="conditionalentry|colscalemiddle">Formula</item>
            </items>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkComboBoxText" id="colscalemax">
            <property name="can_focus">False</property>
            <items>
              <item id="auto" translatable="yes" context="conditionalentry|colscalemax">Automatic</item>
              <item id="min" translatable="yes" context="conditionalentry|colscalemax">Min</item>
              <item id="max" translatable="yes" context="conditionalentry|colscalemax">Max</item>
              <item id="percentil" translatable="yes" context="conditionalentry|colscalemax">Percentile</item>
              <item id="value" translatable="yes" context="conditionalentry|colscalemax">Value</item>
              <item id="percent" translatable="yes" context="conditionalentry|colscalemax">Percent</item>
              <item id="formula" translatable="yes" context="conditionalentry|colscalemax">Formula</item>
            </items>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">2</property>
          </packing>
        </child>
        <child>
          <object class="svxlo-SvxFontPrevWindow" id="preview:border">
            <property name="can_focus">False</property>
            <property name="tooltip_text" translatable="yes" context="conditionalentry|preview|tooltip_text">Example</property>
            <property name="hexpand">True</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="border_width">6</property>
            <property name="row_spacing">6</property>
            <property name="column_spacing">12</property>
            <property name="column_homogeneous">True</property>
            <child>
              <object class="GtkGrid" id="grid1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="column_spacing">12</property>
                <child>
                  <object class="GtkLabel" id="number">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="condition">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkGrid" id="grid2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="row_spacing">6</property>
                <property name="column_spacing">12</property>
                <property name="column_homogeneous">True</property>
                <child>
                  <object class="GtkLabel" id="styleft">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <property name="label" translatable="yes" context="conditionalentry|styleft">Apply Style:</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">style</property>
                    <property name="xalign">0</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="style">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|style">New Style...</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="valueft">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <property name="label" translatable="yes" context="conditionalentry|valueft">Enter a value:</property>
                    <property name="xalign">0</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">3</property>
                    <property name="width">3</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkEntry" id="edcolscalemin">
                    <property name="can_focus">True</property>
                    <property name="no_show_all">True</property>
                    <property name="activates_default">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">4</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkEntry" id="edcolscalemiddle">
                    <property name="can_focus">True</property>
                    <property name="no_show_all">True</property>
                    <property name="activates_default">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">4</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkEntry" id="edcolscalemax">
                    <property name="can_focus">True</property>
                    <property name="no_show_all">True</property>
                    <property name="activates_default">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">4</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkMenuButton" id="lbcolmin">
                    <property name="can_focus">False</property>
                    <property name="receives_default">False</property>
                    <property name="no_show_all">True</property>
                    <property name="xalign">0</property>
                    <property name="draw_indicator">True</property>
                    <property name="label" translatable="no"></property>
                    <child>
                      <placeholder/>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">5</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkMenuButton" id="lbcolmiddle">
                    <property name="can_focus">False</property>
                    <property name="receives_default">False</property>
                    <property name="no_show_all">True</property>
                    <property name="xalign">0</property>
                    <property name="draw_indicator">True</property>
                    <property name="label" translatable="no"></property>
                    <child>
                      <placeholder/>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">5</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkMenuButton" id="lbcolmax">
                    <property name="can_focus">False</property>
                    <property name="receives_default">False</property>
                    <property name="no_show_all">True</property>
                    <property name="xalign">0</property>
                    <property name="draw_indicator">True</property>
                    <property name="label" translatable="no"></property>
                    <child>
                      <placeholder/>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">5</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkButton" id="options">
                    <property name="label" translatable="yes" context="conditionalentry|options">More Options...</property>
                    <property name="can_focus">True</property>
                    <property name="receives_default">True</property>
                    <property name="no_show_all">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">6</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="colscalemin">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item id="auto" translatable="yes" context="conditionalentry|colscalemin">Automatic</item>
                      <item id="min" translatable="yes" context="conditionalentry|colscalemin">Min</item>
                      <item id="max" translatable="yes" context="conditionalentry|colscalemin">Max</item>
                      <item id="percentil" translatable="yes" context="conditionalentry|colscalemin">Percentile</item>
                      <item id="value" translatable="yes" context="conditionalentry|colscalemin">Value</item>
                      <item id="percent" translatable="yes" context="conditionalentry|colscalemin">Percent</item>
                      <item id="formula" translatable="yes" context="conditionalentry|colscalemin">Formula</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="colscalemiddle">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item id="auto" translatable="yes" context="conditionalentry|colscalemiddle">Automatic</item>
                      <item id="min" translatable="yes" context="conditionalentry|colscalemiddle">Min</item>
                      <item id="max" translatable="yes" context="conditionalentry|colscalemiddle">Max</item>
                      <item id="percentil" translatable="yes" context="conditionalentry|colscalemiddle">Percentile</item>
                      <item id="value" translatable="yes" context="conditionalentry|colscalemiddle">Value</item>
                      <item id="percent" translatable="yes" context="conditionalentry|colscalemiddle">Percent</item>
                      <item id="formula" translatable="yes" context="conditionalentry|colscalemiddle">Formula</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="colscalemax">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item id="auto" translatable="yes" context="conditionalentry|colscalemax">Automatic</item>
                      <item id="min" translatable="yes" context="conditionalentry|colscalemax">Min</item>
                      <item id="max" translatable="yes" context="conditionalentry|colscalemax">Max</item>
                      <item id="percentil" translatable="yes" context="conditionalentry|colscalemax">Percentile</item>
                      <item id="value" translatable="yes" context="conditionalentry|colscalemax">Value</item>
                      <item id="percent" translatable="yes" context="conditionalentry|colscalemax">Percent</item>
                      <item id="formula" translatable="yes" context="conditionalentry|colscalemax">Formula</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkGrid" id="iconparent">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                    <child>
                      <placeholder/>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">7</property>
                    <property name="width">3</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="Label_minimum">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <property name="label" translatable="yes" context="conditionalentry|Label_minimum">Minimum</property>
                    <property name="mnemonic_widget">colscalemin</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkLabel" id="Label_maximum">
                    <property name="can_focus">False</property>
                    <property name="label" translatable="yes" context="conditionalentry|Label_maximum">Maximum</property>
                    <property name="mnemonic_widget">colscalemax</property>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkScrolledWindow" id="previewwin">
                    <property name="can_focus">True</property>
                    <property name="no_show_all">True</property>
                    <property name="hscrollbar_policy">never</property>
                    <property name="vscrollbar_policy">never</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>
                            <property name="tooltip_text" translatable="yes" context="conditionalentry|preview|tooltip_text">Example</property>
                          </object>
                        </child>
                      </object>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkGrid">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="column_spacing">12</property>
                <property name="column_homogeneous">True</property>
                <child>
                  <object class="GtkComboBoxText" id="typeis">
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|typeis">equal to</item>
                      <item translatable="yes" context="conditionalentry|typeis">less than</item>
@@ -275,14 +395,13 @@
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="left_attach">1</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="datetype">
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|datetype">Today</item>
                      <item translatable="yes" context="conditionalentry|datetype">Yesterday</item>
@@ -301,13 +420,12 @@
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">0</property>
                    <property name="top_attach">1</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="colorformat">
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|colorformat">Color Scale (2 Entries)</item>
                      <item translatable="yes" context="conditionalentry|colorformat">Color Scale (3 Entries)</item>
@@ -316,45 +434,79 @@
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkGrid">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="column_spacing">12</property>
                <child>
                  <object class="foruilo-RefEdit" id="val1">
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">0</property>
                    <property name="left_attach">1</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
                <child>
                  <object class="foruilo-RefEdit" id="val2">
                  <object class="GtkEntry" id="formula">
                    <property name="can_focus">True</property>
                    <property name="no_show_all">True</property>
                    <property name="hexpand">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">1</property>
                    <property name="top_attach">3</property>
                    <property name="width">2</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="type">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|type">All Cells</item>
                      <item translatable="yes" context="conditionalentry|type">Cell value is</item>
                      <item translatable="yes" context="conditionalentry|type">Formula is</item>
                      <item translatable="yes" context="conditionalentry|type">Date is</item>
                    </items>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">0</property>
                    <property name="height">4</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkGrid">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="column_spacing">6</property>
                    <child>
                      <object class="GtkEntry" id="val1">
                        <property name="can_focus">True</property>
                        <property name="no_show_all">True</property>
                        <property name="hexpand">True</property>
                        <property name="width_chars">5</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">0</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkEntry" id="val2">
                        <property name="can_focus">True</property>
                        <property name="no_show_all">True</property>
                        <property name="hexpand">True</property>
                        <property name="width_chars">5</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">0</property>
                      </packing>
                    </child>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBoxText" id="iconsettype">
                    <property name="can_focus">False</property>
                    <property name="no_show_all">True</property>
                    <items>
                      <item translatable="yes" context="conditionalentry|iconsettype">3 Arrows</item>
                      <item translatable="yes" context="conditionalentry|iconsettype">3 Gray Arrows</item>
@@ -382,83 +534,21 @@
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
                    <property name="top_attach">0</property>
                    <property name="top_attach">2</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">1</property>
                <property name="top_attach">0</property>
              </packing>
            </child>
            <child>
              <object class="foruilo-RefEdit" id="formula">
                <property name="can_focus">True</property>
                <property name="hexpand">True</property>
                <child>
                  <placeholder/>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">2</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
            <property name="width">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid" id="iconparent">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <placeholder/>
            </child>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">8</property>
            <property name="width">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="Label_minimum">
            <property name="can_focus">False</property>
            <property name="label" translatable="yes" context="conditionalentry|Label_minimum">Minimum</property>
            <property name="mnemonic_widget">colscalemin</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="Label_maximum">
            <property name="can_focus">False</property>
            <property name="label" translatable="yes" context="conditionalentry|Label_maximum">Maximum</property>
            <property name="mnemonic_widget">colscalemax</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">1</property>
          </packing>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
      </object>
      <packing>
        <property name="left_attach">0</property>
        <property name="top_attach">1</property>
      </packing>
    </child>
  </object>
</interface>
\ No newline at end of file
</interface>
diff --git a/sc/uiconfig/scalc/ui/conditionalformatdialog.ui b/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
index dc0861d..57b509d 100644
--- a/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
+++ b/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkDialog" id="ConditionalFormatDialog">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="conditionalformatdialog|ConditionalFormatDialog">Conditional Formatting for</property>
    <property name="resizable">False</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
        <property name="can_focus">False</property>
@@ -15,6 +18,64 @@
        <property name="vexpand">True</property>
        <property name="orientation">vertical</property>
        <property name="spacing">12</property>
        <child internal-child="action_area">
          <object class="GtkButtonBox" id="dialog-action_area1">
            <property name="can_focus">False</property>
            <property name="layout_style">end</property>
            <child>
              <object class="GtkButton" id="ok">
                <property name="label">gtk-ok</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="can_default">True</property>
                <property name="has_default">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="cancel">
                <property name="label">gtk-cancel</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="can_default">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="help">
                <property name="label">gtk-help</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
                <property name="secondary">True</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="pack_type">end</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkFrame" id="framecondition">
            <property name="visible">True</property>
@@ -36,11 +97,57 @@
                    <property name="orientation">vertical</property>
                    <property name="spacing">6</property>
                    <child>
                      <object class="sclo-ScCondFormatList" id="list:border">
                      <object class="GtkScrolledWindow" id="listwindow">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="can_focus">True</property>
                        <property name="hscrollbar_policy">never</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="GtkGrid" id="list">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="hexpand">True</property>
                                <property name="vexpand">True</property>
                                <property name="orientation">vertical</property>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <child>
                                  <placeholder/>
                                </child>
                                <style>
                                  <class name="notebook"/>
                                  <class name="stack"/>
                                </style>
                              </object>
                            </child>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -138,64 +245,6 @@
            <property name="position">0</property>
          </packing>
        </child>
        <child internal-child="action_area">
          <object class="GtkButtonBox" id="dialog-action_area1">
            <property name="can_focus">False</property>
            <property name="layout_style">end</property>
            <child>
              <object class="GtkButton" id="ok">
                <property name="label">gtk-ok</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="can_default">True</property>
                <property name="has_default">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="cancel">
                <property name="label">gtk-cancel</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="can_default">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="help">
                <property name="label">gtk-help</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
                <property name="secondary">True</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="pack_type">end</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkFrame" id="framerange">
            <property name="visible">True</property>
@@ -231,7 +280,7 @@
                      </packing>
                    </child>
                    <child>
                      <object class="foruilo-RefEdit" id="edassign">
                      <object class="GtkEntry" id="edassign">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="valign">center</property>
@@ -244,7 +293,7 @@
                      </packing>
                    </child>
                    <child>
                      <object class="foruilo-RefButton" id="rbassign">
                      <object class="GtkButton" id="rbassign">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
diff --git a/sc/uiconfig/scalc/ui/conditionaliconset.ui b/sc/uiconfig/scalc/ui/conditionaliconset.ui
index 43b8d85..515f728 100644
--- a/sc/uiconfig/scalc/ui/conditionaliconset.ui
+++ b/sc/uiconfig/scalc/ui/conditionaliconset.ui
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkGrid" id="ConditionalIconSet">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="halign">start</property>
    <property name="border_width">6</property>
    <child>
      <object class="GtkGrid">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="hexpand">True</property>
        <property name="row_spacing">6</property>
        <property name="column_spacing">12</property>
        <child>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 534089d..8a9df26 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -460,12 +460,9 @@ custom_widgets = [
    'PriorityMergedHBox',
    'PropertyControl',
    'RecentDocsView',
    'RefButton',
    'RefEdit',
    'ReplaceEdit',
    'RowEdit',
    'SameContentListBox',
    'ScCondFormatList',
    'ScCsvTableBox',
    'ScDataTableView',
    'ScDoubleField',
diff --git a/solenv/gbuild/UIConfig.mk b/solenv/gbuild/UIConfig.mk
index cd0b486..9098251 100644
--- a/solenv/gbuild/UIConfig.mk
+++ b/solenv/gbuild/UIConfig.mk
@@ -137,10 +137,6 @@ gb_UIConfig_gla11y_PARAMETERS += -g $(UI_A11YSUPPRS)
endif

# Tell gla11y about LO-specific widgets
# These are already automatically labelled Shrink/Expand
gb_UIConfig_gla11y_PARAMETERS += --widgets-ignored +foruilo-RefButton
# These, however, do need a label like a GtkEntry
gb_UIConfig_gla11y_PARAMETERS += --widgets-needlabel +foruilo-RefEdit
# These are storage, containers, or preview
gb_UIConfig_gla11y_PARAMETERS += --widgets-suffixignored +ValueSet,HBox,VBox,ToolBox,Preview,PreviewWin,PreviewWindow,PrevWindow
# These are buttons, thus already contain their label (but an image is not enough)
diff --git a/solenv/sanitizers/ui/modules/scalc.false b/solenv/sanitizers/ui/modules/scalc.false
index a49d5f2..e798fa3 100644
--- a/solenv/sanitizers/ui/modules/scalc.false
+++ b/solenv/sanitizers/ui/modules/scalc.false
@@ -5,6 +5,7 @@ sc/uiconfig/scalc/ui/analysisofvariancedialog.ui://GtkButton[@id='input-range-bu
sc/uiconfig/scalc/ui/analysisofvariancedialog.ui://GtkButton[@id='output-range-button'] button-no-label
sc/uiconfig/scalc/ui/chisquaretestdialog.ui://GtkButton[@id='input-range-button'] button-no-label
sc/uiconfig/scalc/ui/chisquaretestdialog.ui://GtkButton[@id='output-range-button'] button-no-label
sc/uiconfig/scalc/ui/conditionalformatdialog.ui://GtkButton[@id='rbassign'] button-no-label
sc/uiconfig/scalc/ui/consolidatedialog.ui://GtkButton[@id='rbdataarea'] button-no-label
sc/uiconfig/scalc/ui/consolidatedialog.ui://GtkButton[@id='rbdestarea'] button-no-label
sc/uiconfig/scalc/ui/correlationdialog.ui://GtkButton[@id='input-range-button'] button-no-label
diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr
index 4c56bf4..348404d 100644
--- a/solenv/sanitizers/ui/modules/scalc.suppr
+++ b/solenv/sanitizers/ui/modules/scalc.suppr
@@ -11,19 +11,20 @@ sc/uiconfig/scalc/ui/conditionalentry.ui://GtkLabel[@id='valueft'] orphan-label
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='edcolscalemin'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='edcolscalemiddle'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='edcolscalemax'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://svxcorelo-SvxColorListBox[@id='lbcolmin'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://svxcorelo-SvxColorListBox[@id='lbcolmiddle'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://svxcorelo-SvxColorListBox[@id='lbcolmax'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkMenuButton[@id='lbcolmin'] button-no-label
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkMenuButton[@id='lbcolmiddle'] button-no-label
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkMenuButton[@id='lbcolmax'] button-no-label
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='colscalemin'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='colscalemiddle'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='colscalemax'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='typeis'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='datetype'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='colorformat'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://foruilo-RefEdit[@id='val1'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://foruilo-RefEdit[@id='val2'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='val1'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='val2'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkComboBoxText[@id='iconsettype'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://foruilo-RefEdit[@id='formula'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='formula'] no-labelled-by
sc/uiconfig/scalc/ui/conditionalentry.ui://GtkEntry[@id='formula1'] no-labelled-by
sc/uiconfig/scalc/ui/conditionaliconset.ui://GtkLabel[@id='label'] orphan-label
sc/uiconfig/scalc/ui/conditionaliconset.ui://GtkEntry[@id='entry'] no-labelled-by
sc/uiconfig/scalc/ui/conditionaliconset.ui://GtkComboBoxText[@id='listbox'] no-labelled-by
@@ -58,7 +59,7 @@ sc/uiconfig/scalc/ui/dataproviderentry.ui://GtkEntry[@id='ed_id'] no-labelled-by
sc/uiconfig/scalc/ui/dataproviderentry.ui:GtkGrid[@id='grid']/GtkLabel orphan-label
sc/uiconfig/scalc/ui/dataproviderentry.ui:GtkGrid[@id='grid']/GtkLabel orphan-label
sc/uiconfig/scalc/ui/dataproviderentry.ui:GtkGrid[@id='grid']/GtkLabel orphan-label
sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://foruilo-RefEdit[@id='assign'] no-labelled-by
sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://GtkEntry[@id='assign'] no-labelled-by
sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://GtkLabel[@id='Source'] orphan-label
sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://GtkLabel[@id='Operations'] orphan-label
sc/uiconfig/scalc/ui/definedatabaserangedialog.ui://GtkLabel[@id='invalid'] orphan-label
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 1890d6a..ca7fd0d 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -749,9 +749,9 @@ IMPL_LINK(LanguageBox, ChangeHdl, weld::ComboBox&, rControl, void)
        if (eOldState != m_eEditedAndValid)
        {
            if (m_eEditedAndValid == EditedAndValid::Invalid)
                rControl.set_entry_error(true);
                rControl.set_entry_message_type(weld::EntryMessageType::Error);
            else
                rControl.set_entry_error(false);
                rControl.set_entry_message_type(weld::EntryMessageType::Normal);
        }
    }
    m_aChangeHdl.Call(rControl);
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index a0af882..07dd53d 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -549,7 +549,7 @@ void SvxSearchDialog::SetSearchLabel(const OUString& rStr)
    m_xSearchLabel->set_label(rStr);

    if (rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND))
        m_xSearchLB->set_entry_error(true);
        m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Error);
}

void SvxSearchDialog::ApplyTransliterationFlags_Impl( TransliterationFlags nSettings )
@@ -2184,7 +2184,7 @@ void SvxSearchDialog::SetModifyFlag_Impl( const weld::Widget* pCtrl )
    if (m_xSearchLB.get() == pCtrl)
    {
        nModifyFlag |= ModifyFlags::Search;
        m_xSearchLB->set_entry_error(false);
        m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Normal);
        SvxSearchDialogWrapper::SetSearchLabel("");
    }
    else if ( m_xReplaceLB.get() == pCtrl )
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 390305a..16cdc0d3 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -245,11 +245,13 @@ protected:
private:
    DECL_LINK(EventListener, VclWindowEvent&, void);
    DECL_LINK(KeyEventListener, VclWindowEvent&, bool);
    DECL_LINK(MouseEventListener, VclSimpleEvent&, void);
    DECL_LINK(MnemonicActivateHdl, vcl::Window&, bool);

    const bool m_bTakeOwnership;
    bool m_bEventListener;
    bool m_bKeyEventListener;
    bool m_bMouseEventListener;
    int m_nBlockNotify;

protected:
@@ -274,8 +276,20 @@ protected:
        }
    }

    // we want the ability to know about mouse events that happen in our children
    // so use this variant, we will need to filter them later
    void ensure_mouse_listener()
    {
        if (!m_bMouseEventListener)
        {
            Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener));
            m_bMouseEventListener = true;
        }
    }

    virtual void HandleEventListener(VclWindowEvent& rEvent);
    virtual bool HandleKeyEventListener(VclWindowEvent& rEvent);
    virtual void HandleMouseEventListener(VclSimpleEvent& rEvent);

public:
    SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
@@ -283,7 +297,7 @@ public:
        , m_pBuilder(pBuilder)
        , m_bTakeOwnership(bTakeOwnership)
        , m_bEventListener(false)
        , m_bKeyEventListener(false)
        , m_bMouseEventListener(false)
        , m_nBlockNotify(0)
    {
    }
@@ -529,19 +543,19 @@ public:

    virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) override
    {
        ensure_event_listener();
        ensure_mouse_listener();
        weld::Widget::connect_mouse_press(rLink);
    }

    virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) override
    {
        ensure_event_listener();
        ensure_mouse_listener();
        weld::Widget::connect_mouse_move(rLink);
    }

    virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) override
    {
        ensure_event_listener();
        ensure_mouse_listener();
        weld::Widget::connect_mouse_release(rLink);
    }

@@ -608,6 +622,8 @@ public:
    {
        if (m_aMnemonicActivateHdl.IsSet())
            m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&,bool>());
        if (m_bMouseEventListener)
            Application::RemoveEventListener(LINK(this, SalInstanceWidget, MouseEventListener));
        if (m_bKeyEventListener)
            Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener));
        if (m_bEventListener)
@@ -654,6 +670,15 @@ public:
        return m_xWidget->GetDropTarget();
    }

    virtual void set_stack_background() override
    {
        m_xWidget->SetControlBackground(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor());
        m_xWidget->SetBackground(m_xWidget->GetControlBackground());
        // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under"
        // transparent children of the widget
        m_xWidget->SetStyle(m_xWidget->GetStyle() & ~WB_CLIPCHILDREN);
    }

    SystemWindow* getSystemWindow()
    {
        return m_xWidget->GetSystemWindow();
@@ -668,20 +693,36 @@ void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent)
        m_aFocusOutHdl.Call(*this);
    else if (rEvent.GetId() == VclEventId::WindowResize)
        m_aSizeAllocateHdl.Call(m_xWidget->GetSizePixel());
    else if (rEvent.GetId() == VclEventId::WindowMouseButtonDown)
}

void SalInstanceWidget::HandleMouseEventListener(VclSimpleEvent& rEvent)
{
    if (rEvent.GetId() == VclEventId::WindowMouseButtonDown)
    {
        const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rEvent.GetData());
        m_aMousePressHdl.Call(*pMouseEvent);
        auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent);
        if (m_xWidget->IsWindowOrChild(rWinEvent.GetWindow()))
        {
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
            m_aMousePressHdl.Call(*pMouseEvent);
        }
    }
    else if (rEvent.GetId() == VclEventId::WindowMouseButtonUp)
    {
        const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rEvent.GetData());
        m_aMouseReleaseHdl.Call(*pMouseEvent);
        auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent);
        if (m_xWidget->IsWindowOrChild(rWinEvent.GetWindow()))
        {
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
            m_aMouseReleaseHdl.Call(*pMouseEvent);
        }
    }
    else if (rEvent.GetId() == VclEventId::WindowMouseMove)
    {
        const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rEvent.GetData());
        m_aMouseMotionHdl.Call(*pMouseEvent);
        auto& rWinEvent = static_cast<VclWindowEvent&>(rEvent);
        if (m_xWidget->IsWindowOrChild(rWinEvent.GetWindow()))
        {
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
            m_aMouseMotionHdl.Call(*pMouseEvent);
        }
    }
}

@@ -713,6 +754,11 @@ IMPL_LINK(SalInstanceWidget, KeyEventListener, VclWindowEvent&, rEvent, bool)
    return HandleKeyEventListener(rEvent);
}

IMPL_LINK(SalInstanceWidget, MouseEventListener, VclSimpleEvent&, rEvent, void)
{
    HandleMouseEventListener(rEvent);
}

IMPL_LINK_NOARG(SalInstanceWidget, MnemonicActivateHdl, vcl::Window&, bool)
{
    return m_aMnemonicActivateHdl.Call(*this);
@@ -2331,15 +2377,24 @@ public:
        return !m_xEntry->IsReadOnly();
    }

    virtual void set_error(bool bError) override
    virtual void set_message_type(weld::EntryMessageType eType) override
    {
        if (bError)
        if (eType == weld::EntryMessageType::Error)
        {
            // #i75179# enable setting the background to a different color
            // tdf#114603: enable setting the background to a different color;
            // relevant for GTK; see also #i75179#
            m_xEntry->SetForceControlBackground(true);
            m_xEntry->SetControlForeground(COL_WHITE);
            m_xEntry->SetControlBackground(0xff6563);
        }
        else if (eType == weld::EntryMessageType::Warning)
        {
            // tdf#114603: enable setting the background to a different color;
            // relevant for GTK; see also #i75179#
            m_xEntry->SetForceControlBackground(true);
            m_xEntry->SetControlForeground();
            m_xEntry->SetControlBackground(COL_YELLOW);
        }
        else
        {
            m_xEntry->SetForceControlBackground(false);
@@ -3904,10 +3959,12 @@ public:
        pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr);
    }

    virtual void set_error(bool bShowError) override
    virtual void set_message_type(weld::EntryMessageType eType) override
    {
        if (bShowError)
        if (eType == weld::EntryMessageType::Error)
            m_xLabel->SetControlBackground(m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor());
        else if (eType == weld::EntryMessageType::Warning)
            m_xLabel->SetControlBackground(COL_YELLOW);
        else
            m_xLabel->SetControlBackground();
    }
@@ -4127,16 +4184,23 @@ private:
    // in VclDrawingArea
    virtual void HandleEventListener(VclWindowEvent& rEvent) override
    {
        if (rEvent.GetId() == VclEventId::WindowResize ||
            rEvent.GetId() == VclEventId::WindowMouseButtonDown ||
        if (rEvent.GetId() == VclEventId::WindowResize)
            return;
        SalInstanceWidget::HandleEventListener(rEvent);
    }

    virtual void HandleMouseEventListener(VclSimpleEvent& rEvent) override
    {
        if (rEvent.GetId() == VclEventId::WindowMouseButtonDown ||
            rEvent.GetId() == VclEventId::WindowMouseButtonUp ||
            rEvent.GetId() == VclEventId::WindowMouseMove)
        {
            return;
        }
        SalInstanceWidget::HandleEventListener(rEvent);
        SalInstanceWidget::HandleMouseEventListener(rEvent);
    }


    virtual bool HandleKeyEventListener(VclWindowEvent& /*rEvent*/) override
    {
        return false;
@@ -4520,7 +4584,7 @@ public:
        return false;
    }

    virtual void set_entry_error(bool /*bError*/) override
    virtual void set_entry_message_type(weld::EntryMessageType /*eType*/) override
    {
        assert(false);
    }
@@ -4588,10 +4652,12 @@ public:
        return true;
    }

    virtual void set_entry_error(bool bError) override
    virtual void set_entry_message_type(weld::EntryMessageType eType) override
    {
        if (bError)
        if (eType == weld::EntryMessageType::Error)
            m_xComboBox->SetControlForeground(Color(0xf0, 0, 0));
        else if (eType == weld::EntryMessageType::Warning)
            m_xComboBox->SetControlForeground(COL_YELLOW);
        else
            m_xComboBox->SetControlForeground();
    }
diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx
index d00ad9f..4c01b7e 100644
--- a/vcl/source/window/stacking.cxx
+++ b/vcl/source/window/stacking.cxx
@@ -838,7 +838,7 @@ static SystemWindow *ImplGetLastSystemWindow( vcl::Window *pWin )

void Window::SetParent( vcl::Window* pNewParent )
{
    SAL_WARN_IF( !pNewParent, "vcl", "Window::SetParent(): pParent == NULL" );
    SAL_INFO_IF( !pNewParent, "vcl", "Window::SetParent(): pParent == NULL" );
    SAL_WARN_IF( pNewParent == this, "vcl", "someone tried to reparent a window to itself" );

    if( !pNewParent || pNewParent == this )
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index f12e6f4..1b4ab74 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1254,6 +1254,7 @@ class GtkInstanceWidget : public virtual weld::Widget
{
protected:
    GtkWidget* m_pWidget;
    GtkWidget* m_pMouseEventBox;
    GtkInstanceBuilder* m_pBuilder;

    DECL_LINK(async_signal_focus_in, void*, void);
@@ -1298,10 +1299,69 @@ protected:
        m_aFocusOutHdl.Call(*this);
    }

    void ensureEventWidget()
    {
        // not every widget has a GdkWindow and can get any event, so if we
        // want an event it doesn't have, insert a GtkEventBox so we can get
        // those
        if (!m_pMouseEventBox)
        {
            if (gtk_widget_get_has_window(m_pWidget))
                m_pMouseEventBox = m_pWidget;
            else
            {
                // remove the widget and replace it with an eventbox and put the old
                // widget into it
                GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);

                g_object_ref(m_pWidget);

                gint nTopAttach(0), nLeftAttach(0), nHeight(1), nWidth(1);
                if (GTK_IS_GRID(pParent))
                {
                    gtk_container_child_get(GTK_CONTAINER(pParent), m_pWidget,
                            "left-attach", &nTopAttach,
                            "top-attach", &nLeftAttach,
                            "width", &nWidth,
                            "height", &nHeight,
                            nullptr);
                }

                gtk_container_remove(GTK_CONTAINER(pParent), m_pWidget);

                m_pMouseEventBox = gtk_event_box_new();
                gtk_event_box_set_above_child(GTK_EVENT_BOX(m_pMouseEventBox), false);
                gtk_event_box_set_visible_window(GTK_EVENT_BOX(m_pMouseEventBox), false);
                gtk_widget_show(m_pMouseEventBox);

                gtk_container_add(GTK_CONTAINER(pParent), m_pMouseEventBox);

                if (GTK_IS_GRID(pParent))
                {
                    gtk_container_child_set(GTK_CONTAINER(pParent), m_pMouseEventBox,
                            "left-attach", nTopAttach,
                            "top-attach", nLeftAttach,
                            "width", nWidth,
                            "height", nHeight,
                            nullptr);
                }

                gtk_container_add(GTK_CONTAINER(m_pMouseEventBox), m_pWidget);
                g_object_unref(m_pWidget);

                gtk_widget_set_hexpand(m_pMouseEventBox, gtk_widget_get_hexpand(m_pWidget));
                gtk_widget_set_vexpand(m_pMouseEventBox, gtk_widget_get_vexpand(m_pWidget));
            }
        }
    }

    void ensureButtonPressSignal()
    {
        if (!m_nButtonPressSignalId)
            m_nButtonPressSignalId = g_signal_connect(m_pWidget, "button-press-event", G_CALLBACK(signalButton), this);
        {
            ensureEventWidget();
            m_nButtonPressSignalId = g_signal_connect(m_pMouseEventBox, "button-press-event", G_CALLBACK(signalButton), this);
        }
    }

    static gboolean signalPopupMenu(GtkWidget* pWidget, gpointer widget)
@@ -1515,6 +1575,7 @@ private:
public:
    GtkInstanceWidget(GtkWidget* pWidget, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
        : m_pWidget(pWidget)
        , m_pMouseEventBox(nullptr)
        , m_pBuilder(pBuilder)
        , m_bTakeOwnership(bTakeOwnership)
        , m_bFrozen(false)
@@ -1556,13 +1617,15 @@ public:

    virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) override
    {
        m_nMotionSignalId = g_signal_connect(m_pWidget, "motion-notify-event", G_CALLBACK(signalMotion), this);
        ensureEventWidget();
        m_nMotionSignalId = g_signal_connect(m_pMouseEventBox, "motion-notify-event", G_CALLBACK(signalMotion), this);
        weld::Widget::connect_mouse_move(rLink);
    }

    virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) override
    {
        m_nButtonReleaseSignalId = g_signal_connect(m_pWidget, "button-release-event", G_CALLBACK(signalButton), this);
        ensureEventWidget();
        m_nButtonReleaseSignalId = g_signal_connect(m_pMouseEventBox, "button-release-event", G_CALLBACK(signalButton), this);
        weld::Widget::connect_mouse_release(rLink);
    }

@@ -1993,6 +2056,17 @@ public:
        return m_xDropTarget.get();
    }

    virtual void set_stack_background() override
    {
        GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(m_pWidget));
        GtkCssProvider *pProvider = gtk_css_provider_new();
        OUString aBuffer = "* { background-color: #" + Application::GetSettings().GetStyleSettings().GetWindowColor().AsRGBHexString() + "; }";
        OString aResult = OUStringToOString(aBuffer, RTL_TEXTENCODING_UTF8);
        gtk_css_provider_load_from_data(pProvider, aResult.getStr(), aResult.getLength(), nullptr);
        gtk_style_context_add_provider(pWidgetContext, GTK_STYLE_PROVIDER(pProvider),
                                       GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    }

    virtual ~GtkInstanceWidget() override
    {
        if (m_nDragMotionSignalId)
@@ -2008,11 +2082,11 @@ public:
        if (m_nKeyReleaseSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nKeyReleaseSignalId);
        if (m_nButtonPressSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nButtonPressSignalId);
            g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonPressSignalId);
        if (m_nMotionSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nMotionSignalId);
            g_signal_handler_disconnect(m_pMouseEventBox, m_nMotionSignalId);
        if (m_nButtonReleaseSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nButtonReleaseSignalId);
            g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonReleaseSignalId);
        if (m_nFocusInSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nFocusInSignalId);
        if (m_nMnemonicActivateSignalId)
@@ -2021,6 +2095,21 @@ public:
            g_signal_handler_disconnect(m_pWidget, m_nFocusOutSignalId);
        if (m_nSizeAllocateSignalId)
            g_signal_handler_disconnect(m_pWidget, m_nSizeAllocateSignalId);

        if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget)
        {
            // put things back they way we found them
            GtkWidget* pParent = gtk_widget_get_parent(m_pMouseEventBox);

            g_object_ref(m_pWidget);
            gtk_container_remove(GTK_CONTAINER(m_pMouseEventBox), m_pWidget);

            gtk_widget_destroy(m_pMouseEventBox);

            gtk_container_add(GTK_CONTAINER(pParent), m_pWidget);
            g_object_unref(m_pWidget);
        }

        if (m_bTakeOwnership)
            gtk_widget_destroy(m_pWidget);
    }
@@ -5564,6 +5653,19 @@ namespace
    }
}

namespace
{
    void set_entry_message_type(GtkEntry* pEntry, weld::EntryMessageType eType)
    {
        if (eType == weld::EntryMessageType::Error)
            gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error");
        else if (eType == weld::EntryMessageType::Warning)
            gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
        else
            gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr);
    }
}

class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry
{
private:
@@ -5716,12 +5818,9 @@ public:
        return gtk_editable_get_editable(GTK_EDITABLE(m_pEntry));
    }

    virtual void set_error(bool bError) override
    virtual void set_message_type(weld::EntryMessageType eType) override
    {
        if (bError)
            gtk_entry_set_icon_from_icon_name(m_pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error");
        else
            gtk_entry_set_icon_from_icon_name(m_pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr);
        ::set_entry_message_type(m_pEntry, eType);
    }

    virtual void disable_notify_events() override
@@ -7917,6 +8016,19 @@ class GtkInstanceLabel : public GtkInstanceWidget, public virtual weld::Label
{
private:
    GtkLabel* m_pLabel;

    void set_text_color(const Color& rColor)
    {
        guint16 nRed = rColor.GetRed() << 8;
        guint16 nGreen = rColor.GetRed() << 8;
        guint16 nBlue = rColor.GetBlue() << 8;

        PangoAttrList* pAttrs = pango_attr_list_new();
        pango_attr_list_insert(pAttrs, pango_attr_background_new(nRed, nGreen, nBlue));
        gtk_label_set_attributes(m_pLabel, pAttrs);
        pango_attr_list_unref(pAttrs);
    }

public:
    GtkInstanceLabel(GtkLabel* pLabel, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
        : GtkInstanceWidget(GTK_WIDGET(pLabel), pBuilder, bTakeOwnership)
@@ -7941,21 +8053,12 @@ public:
        gtk_label_set_mnemonic_widget(m_pLabel, pTargetWidget ? pTargetWidget->getWidget() : nullptr);
    }

    virtual void set_error(bool bShowError) override
    virtual void set_message_type(weld::EntryMessageType eType) override
    {
        if (bShowError)
        {
            Color aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());

            guint16 nRed = aColor.GetRed() << 8;
            guint16 nGreen = aColor.GetRed() << 8;
            guint16 nBlue = aColor.GetBlue() << 8;

            PangoAttrList* pAttrs = pango_attr_list_new();
            pango_attr_list_insert(pAttrs, pango_attr_background_new(nRed, nGreen, nBlue));
            gtk_label_set_attributes(m_pLabel, pAttrs);
            pango_attr_list_unref(pAttrs);
        }
        if (eType == weld::EntryMessageType::Error)
            set_text_color(Application::GetSettings().GetStyleSettings().GetHighlightColor());
        else if (eType == weld::EntryMessageType::Warning)
            set_text_color(COL_YELLOW);
        else
            gtk_label_set_attributes(m_pLabel, nullptr);
    }
@@ -9032,15 +9135,12 @@ public:
        return gtk_combo_box_get_has_entry(m_pComboBox);
    }

    virtual void set_entry_error(bool bError) override
    virtual void set_entry_message_type(weld::EntryMessageType eType) override
    {
        GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox));
        assert(GTK_IS_ENTRY(pChild));
        GtkEntry* pEntry = GTK_ENTRY(pChild);
        if (bError)
            gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error");
        else
            gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr);
        ::set_entry_message_type(pEntry, eType);
    }

    virtual void set_entry_text(const OUString& rText) override