tdf#153808 Fix numbering preview in dark mode

This patch fixes the color used for numbers and bullets in the preview
of the Bullets and Numbering dialog in Impress. Currently the
implementation causes the bullets and numbers to be rendered in white
over a white background when using dark mode.

The fix uses DOCCOLOR and FONTCOLOR to create the preview, instead of
FieldColor and FieldTextColor.

Change-Id: Icf41c5be59c67a2d68e3c520744276492e9baa59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147664
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
(cherry picked from commit 3a4b32c9e1dfc56d9b00e3720834d21c9095f629)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149435
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 0c66f69..916e513 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -44,6 +44,7 @@
#include <unotools/pathoptions.hxx>
#include <svtools/ctrltool.hxx>
#include <svtools/unitconv.hxx>
#include <svtools/colorcfg.hxx>
#include <com/sun/star/style/NumberingType.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
@@ -2154,10 +2155,10 @@ static tools::Long lcl_DrawBullet(VirtualDevice* pVDev,
    aFont.SetFontSize(aTmpSize);
    aFont.SetTransparent(true);
    Color aBulletColor = rFmt.GetBulletColor();
    if(aBulletColor == COL_AUTO)
        aBulletColor = pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK;
    else if(aBulletColor == pVDev->GetFillColor())
        aBulletColor.Invert();
    if (aBulletColor == COL_AUTO)
        aBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
    else if (pVDev->GetBackgroundColor().IsDark() == aBulletColor.IsDark())
        aBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
    aFont.SetColor(aBulletColor);
    pVDev->SetFont( aFont );
    sal_UCS4 cChar = rFmt.GetBulletChar();
@@ -2183,9 +2184,9 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
{
    Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel()));

    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
    const Color aBackColor = rStyleSettings.GetFieldColor();
    const Color aTextColor = rStyleSettings.GetFieldTextColor();
    // Use default document and font colors to create preview
    const Color aBackColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
    const Color aTextColor = svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;

    ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext);
    pVDev->EnableRTL(rRenderContext.IsRTLEnabled());
@@ -2197,6 +2198,8 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
        aLineColor.Invert();
    pVDev->SetLineColor(aLineColor);
    pVDev->SetFillColor(aBackColor);
    pVDev->SetBackground(Wallpaper(aBackColor));
    pVDev->DrawWallpaper(pVDev->GetOutputRectPixel(), pVDev->GetBackground());

    if (pActNum)
    {
@@ -2224,6 +2227,9 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool

        if (bPosition)
        {
            // When bPosition == true, draw the preview used in the Writer's "Position" tab
            // This is not used in Impress/Draw

            tools::Long nLineHeight = nFontHeight * 8 / 7;
            sal_uInt8 nStart = 0;
            while (!(nActLevel & (1<<nStart)))
@@ -2290,9 +2296,9 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
                    vcl::Font aColorFont(aSaveFont);
                    Color aTmpBulletColor = rFmt.GetBulletColor();
                    if (aTmpBulletColor == COL_AUTO)
                        aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
                    else if (aTmpBulletColor == aBackColor)
                        aTmpBulletColor.Invert();
                        aTmpBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
                    else if (pVDev->GetBackgroundColor().IsDark() == aTmpBulletColor.IsDark())
                        aTmpBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
                    aColorFont.SetColor(aTmpBulletColor);
                    pVDev->SetFont(aColorFont);
                    pVDev->DrawText(Point(nNumberXPos, nYStart), aText);
@@ -2354,14 +2360,15 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
        }
        else
        {
            // When bPosition == false, draw the preview used in Writer's "Customize" tab
            // and in Impress' "Bullets and Numbering" dialog

            //#i5153# painting gray or black rectangles as 'normal' numbering text
            tools::Long nWidth = pVDev->GetTextWidth("Preview");
            tools::Long nTextHeight = pVDev->GetTextHeight();
            tools::Long nRectHeight = nTextHeight * 2 / 3;
            tools::Long nTopOffset = nTextHeight - nRectHeight;
            Color aBlackColor(COL_BLACK);
            if (aBlackColor == aBackColor)
                aBlackColor.Invert();
            Color aSelRectColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;

            for (sal_uInt16 nLevel = 0; nLevel < pActNum->GetLevelCount(); ++nLevel, nYStart = nYStart + nYStep)
            {
@@ -2422,9 +2429,9 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
                    aFont.SetFontSize(aTmpSize);
                    Color aTmpBulletColor = rFmt.GetBulletColor();
                    if (aTmpBulletColor == COL_AUTO)
                        aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
                    else if (aTmpBulletColor == aBackColor)
                        aTmpBulletColor.Invert();
                        aTmpBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
                    else if (pVDev->GetBackgroundColor().IsDark() == aTmpBulletColor.IsDark())
                        aTmpBulletColor = pVDev->GetBackgroundColor().IsDark() ? COL_WHITE : COL_BLACK;
                    aFont.SetColor(aTmpBulletColor);
                    pVDev->SetFont(aFont);
                    aNum.SetLevel( nLevel );
@@ -2442,8 +2449,8 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool
                //#i5153# the selected rectangle(s) should be black
                if (0 != (nActLevel & (1<<nLevel)))
                {
                    pVDev->SetFillColor( aBlackColor );
                    pVDev->SetLineColor( aBlackColor );
                    pVDev->SetFillColor( aSelRectColor );
                    pVDev->SetLineColor( aSelRectColor );
                }
                else
                {