Resolves: #i122041# Unified and centralized control for Color ValueSets

(cherry picked from commit 68e707bbc6fe23881b822e6efab8a2933343dc1a)

Conflicts:
	cui/source/inc/backgrnd.hxx
	cui/source/inc/cuitabarea.hxx
	cui/source/tabpages/backgrnd.cxx
	cui/source/tabpages/tpcolor.cxx
	sd/source/ui/view/drviews6.cxx
	svx/Package_inc.mk
	svx/inc/svx/colrctrl.hxx
	svx/source/sidebar/tools/ColorControl.cxx
	svx/source/tbxctrls/colorwindow.hxx
	svx/source/tbxctrls/colrctrl.cxx
	svx/source/tbxctrls/tbcontrl.cxx

Change-Id: Ie06fe355846b737ec8aae9aade4d408232c83193

Related: #i122041# Add a11y values for defining behaviour of ColorValueSets

(cherry picked from commit 401e8f2db607081e62eaaa1f08a8cd8971a3f637)

Conflicts:
	cui/source/tabpages/backgrnd.cxx
	officecfg/registry/schema/org/openoffice/Office/Common.xcs
	sc/source/ui/miscdlgs/tabbgcolordlg.cxx
	svtools/inc/svtools/accessibilityoptions.hxx
	svtools/source/inc/configitems/accessibilityoptions_const.hxx
	vcl/inc/vcl/bitmap.hxx
	vcl/source/gdi/bitmap4.cxx

Change-Id: If9d0db5f22974cad1ac886eca3719ca92ca7f240
diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx
index c3e13b9..cece693b 100644
--- a/cui/source/inc/backgrnd.hxx
+++ b/cui/source/inc/backgrnd.hxx
@@ -22,7 +22,7 @@
#include <vcl/group.hxx>
#include <svtools/stdctrl.hxx>
#include <vcl/graph.hxx>
#include <svtools/valueset.hxx>
#include <svx/SvxColorValueSet.hxx>
#include <svx/dlgctrl.hxx>
#include <editeng/brushitem.hxx>

@@ -82,7 +82,7 @@ private:
    ListBox*                m_pParaLBox;

    VclFrame*               m_pBackGroundColorFrame;
    ValueSet*               m_pBackgroundColorSet;
    SvxColorValueSet*       m_pBackgroundColorSet;
    BackgroundPreviewImpl*  m_pPreviewWin1;

    FixedText*              m_pColTransFT;///<color transparency
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 548a901..374dd319 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -27,6 +27,7 @@
#include <svx/xfillit0.hxx>
#include <svx/xfillit.hxx>
#include <svx/tabarea.hxx>
#include <svx/SvxColorValueSet.hxx>

class SdrModel;
class SdrView;
@@ -650,7 +651,7 @@ private:
    Edit*               m_pEdtName;
    ColorLB*            m_pLbColor;

    ValueSet*           m_pValSetColorList;
    SvxColorValueSet*   m_pValSetColorList;

    SvxXRectPreview*    m_pCtlPreviewOld;
    SvxXRectPreview*    m_pCtlPreviewNew;
@@ -698,7 +699,8 @@ private:
    sal_uInt16  ColorToPercent_Impl( sal_uInt16 nColor );
    sal_uInt16  PercentToColor_Impl( sal_uInt16 nPercent );

    void    FillValueSet_Impl( ValueSet& rVs );
    void ImpColorCountChanged();

    //-----------------------------------------------------------------------------------------------------
    DECL_LINK( ClickAddHdl_Impl, void * );
    DECL_LINK( ClickModifyHdl_Impl, void * );
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 3b94fdf..a8ce0a7 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -413,6 +413,8 @@ SvxBackgroundTabPage::SvxBackgroundTabPage(Window* pParent, const SfxItemSet& rC
    FillColorValueSets_Impl();

    m_pBackgroundColorSet->SetSelectHdl( HDL(BackgroundColorHdl_Impl) );
    m_pBackgroundColorSet->SetStyle(m_pBackgroundColorSet->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
    m_pBackgroundColorSet->SetText(SVX_RESSTR(RID_SVXSTR_TRANSPARENT));
}

//------------------------------------------------------------------------
@@ -1169,47 +1171,23 @@ void SvxBackgroundTabPage::FillColorValueSets_Impl()
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
    const SfxPoolItem* pItem = NULL;
    XColorListRef pColorTable = NULL;
    const Size aSize15x15 = Size( 15, 15 );

    if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
    {
        pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
    }

    if ( !pColorTable.is() )
        pColorTable = XColorList::CreateStdColorList();

    if ( pColorTable.is() )
    {
        short i = 0;
        long nCount = pColorTable->Count();
        XColorEntry* pEntry = NULL;
        Color aColWhite( COL_WHITE );
        String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
        WinBits nBits = ( m_pBackgroundColorSet->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD );
        m_pBackgroundColorSet->SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
        m_pBackgroundColorSet->SetStyle( nBits );
        m_pBackgroundColorSet->SetAccessibleName(m_pBackGroundColorFrame->get_label_widget()->GetText());
        for ( i = 0; i < nCount; i++ )
        {
            pEntry = pColorTable->GetColor(i);
            m_pBackgroundColorSet->InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
        }

        while ( i < 104 )
        {
            m_pBackgroundColorSet->InsertItem( i + 1, aColWhite, aStrWhite );
            i++;
        }

        if ( nCount > 104 )
        {
            m_pBackgroundColorSet->SetStyle( nBits | WB_VSCROLL );
        }
        m_pBackgroundColorSet->Clear();
        m_pBackgroundColorSet->addEntriesForXColorList(*pColorTable);
    }

    m_pBackgroundColorSet->SetColCount( 8 );
    m_pBackgroundColorSet->SetLineCount( 13 );
    m_pBackgroundColorSet->CalcWindowSizePixel( aSize15x15 );

    const WinBits nBits(m_pBackgroundColorSet->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
    m_pBackgroundColorSet->SetStyle(nBits);
    m_pBackgroundColorSet->SetColCount(m_pBackgroundColorSet->getColumnCount());
}

//------------------------------------------------------------------------
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 371b61e..fc209ed 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -391,10 +391,7 @@ SvxColorTabPage::SvxColorTabPage(Window* pParent, const SfxItemSet& rInAttrs)
        LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) );

    // ValueSet
    m_pValSetColorList->SetStyle( m_pValSetColorList->GetStyle() | WB_VSCROLL | WB_ITEMBORDER );
    m_pValSetColorList->SetColCount( 8 );
    m_pValSetColorList->SetLineCount( 13 );
    m_pValSetColorList->SetExtraSpacing( 0 );
    m_pValSetColorList->SetStyle( m_pValSetColorList->GetStyle() | WB_ITEMBORDER );
    m_pValSetColorList->Show();
}

@@ -405,11 +402,24 @@ SvxColorTabPage::~SvxColorTabPage()

// -----------------------------------------------------------------------

void SvxColorTabPage::ImpColorCountChanged()
{
    if (!pColorList.is())
        return;
    m_pValSetColorList->SetColCount(m_pValSetColorList->getColumnCount());
}

// -----------------------------------------------------------------------

void SvxColorTabPage::Construct()
{
    m_pLbColor->Fill(pColorList);
    FillValueSet_Impl(*m_pValSetColorList);
    UpdateTableName();
    if (pColorList.is())
    {
        m_pLbColor->Fill(pColorList);
        m_pValSetColorList->addEntriesForXColorList(*pColorList);
        ImpColorCountChanged();
        UpdateTableName();
    }
}

// -----------------------------------------------------------------------
@@ -722,6 +732,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
        m_pLbColor->Append( pEntry );
        m_pValSetColorList->InsertItem( m_pValSetColorList->GetItemCount() + 1,
                pEntry->GetColor(), pEntry->GetName() );
        ImpColorCountChanged();

        m_pLbColor->SelectEntryPos( m_pLbColor->GetEntryCount() - 1 );

@@ -874,7 +885,9 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl)
            // update Listbox and ValueSet
            m_pLbColor->RemoveEntry( nPos );
            m_pValSetColorList->Clear();
            FillValueSet_Impl(*m_pValSetColorList);
            m_pValSetColorList->addEntriesForXColorList(*pColorList);
            ImpColorCountChanged();
            //FillValueSet_Impl(*m_pValSetColorList);

            // positioning
            m_pLbColor->SelectEntryPos( nPos );
@@ -1043,20 +1056,20 @@ long SvxColorTabPage::ChangeColorHdl_Impl( void* )

//------------------------------------------------------------------------

void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
{
    long nCount = pColorList->Count();
    XColorEntry* pColorEntry;

    if( nCount > 104 )
        rVs.SetStyle( rVs.GetStyle() | WB_VSCROLL );

    for( long i = 0; i < nCount; i++ )
    {
        pColorEntry = pColorList->GetColor( i );
        rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
    }
}
//void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
//{
//    long nCount = pColorList->Count();
//    XColorEntry* pColorEntry;
//
//    if( nCount > 104 )
//        rVs.SetStyle( rVs.GetStyle() | WB_VSCROLL );
//
//    for( long i = 0; i < nCount; i++ )
//    {
//        pColorEntry = pColorList->GetColor( i );
//        rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
//    }
//}

//------------------------------------------------------------------------

diff --git a/cui/uiconfig/ui/backgroundpage.ui b/cui/uiconfig/ui/backgroundpage.ui
index 3182e28..78d761f 100644
--- a/cui/uiconfig/ui/backgroundpage.ui
+++ b/cui/uiconfig/ui/backgroundpage.ui
@@ -217,7 +217,7 @@
                  </packing>
                </child>
                <child>
                  <object class="svtlo-ValueSet" id="backgroundcolorset">
                  <object class="svxlo-SvxColorValueSet" id="backgroundcolorset">
                    <property name="width_request">150</property>
                    <property name="height_request">150</property>
                    <property name="visible">True</property>
diff --git a/cui/uiconfig/ui/colorpage.ui b/cui/uiconfig/ui/colorpage.ui
index 48da1f3..0146da1 100644
--- a/cui/uiconfig/ui/colorpage.ui
+++ b/cui/uiconfig/ui/colorpage.ui
@@ -129,7 +129,7 @@
                          </packing>
                        </child>
                        <child>
                          <object class="svtlo-ValueSet" id="colorset">
                          <object class="svxlo-SvxColorValueSet" id="colorset">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="hexpand">True</property>
diff --git a/include/svtools/accessibilityoptions.hxx b/include/svtools/accessibilityoptions.hxx
index 4c16814..52b12b9 100644
--- a/include/svtools/accessibilityoptions.hxx
+++ b/include/svtools/accessibilityoptions.hxx
@@ -49,6 +49,15 @@ public:
    sal_Bool    IsSelectionInReadonly() const;
    sal_Bool    GetAutoDetectSystemHC() const;

    // options for configuring the look and feel for the ColorValueSet (color selector)
    sal_Int16   GetColorValueSetMaximumRowCount() const;
    sal_Int16   GetColorValueSetEntryEdgeLength() const;
    sal_Int16   GetColorValueSetColumnCount() const;

    // option to activate EdgeBlending for previews in the UI (ColorValueSet, ColorDropDown,
    // FillStyle/LineStyle previews, etc...). 0 == off, 100% == full paint, in-between == alpha
    sal_Int16   GetEdgeBlending() const;

    void        SetIsForPagePreviews(sal_Bool bSet);
    void        SetIsHelpTipsDisappear(sal_Bool bSet);
    void        SetIsAllowAnimatedGraphics(sal_Bool bSet);
@@ -59,6 +68,11 @@ public:
    void        SetSelectionInReadonly(sal_Bool bSet);
    void        SetAutoDetectSystemHC(sal_Bool bSet);

    void        SetColorValueSetMaximumRowCount(sal_Int16 nSet);
    void        SetColorValueSetEntryEdgeLength(sal_Int16 nSet);
    void        SetColorValueSetColumnCount(sal_Int16 nSet);
    void        SetEdgeBlending(sal_Int16 nSet);

    sal_Bool                IsModified() const;
    void                    Commit();

diff --git a/include/svx/SvxColorChildWindow.hxx b/include/svx/SvxColorChildWindow.hxx
new file mode 100644
index 0000000..0b9b320
--- /dev/null
+++ b/include/svx/SvxColorChildWindow.hxx
@@ -0,0 +1,40 @@
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef _SVX_COLORCHILDWINDOW_HXX
#define _SVX_COLORCHILDWINDOW_HXX

#include <sfx2/childwin.hxx>
#include "svx/svxdllapi.h"

/*************************************************************************
|*
|* Ableitung vom SfxChildWindow als "Behaelter" fuer Controller
|*
\************************************************************************/

class SVX_DLLPUBLIC SvxColorChildWindow : public SfxChildWindow
{
 public:
    SvxColorChildWindow( Window*, sal_uInt16, SfxBindings*,
                         SfxChildWinInfo* );

    SFX_DECL_CHILDWINDOW_WITHID(SvxColorChildWindow);
};


#endif // _SVX_COLORCHILDWINDOW_HXX
diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
new file mode 100644
index 0000000..819de02
--- /dev/null
+++ b/include/svx/SvxColorValueSet.hxx
@@ -0,0 +1,51 @@
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef _SVX_COLORVALUESET_HXX
#define _SVX_COLORVALUESET_HXX

#include <svtools/valueset.hxx>
#include "svx/svxdllapi.h"

//////////////////////////////////////////////////////////////////////////////

class XColorList;

//////////////////////////////////////////////////////////////////////////////

class SVX_DLLPUBLIC SvxColorValueSet : public ValueSet
{
private:
protected:
public:
    SvxColorValueSet(Window* pParent, WinBits nWinStyle = WB_ITEMBORDER);
    SvxColorValueSet(Window* pParent, const ResId& rResId);

    sal_uInt32 getMaxRowCount() const;
    sal_uInt32 getEntryEdgeLength() const;
    sal_uInt32 getColumnCount() const;

    void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
    Size layoutAllVisible(sal_uInt32 nEntryCount);
    Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
};

//////////////////////////////////////////////////////////////////////////////

#endif // _SVX_COLORVALUESET_HXX

// eof
diff --git a/include/svx/colrctrl.hxx b/include/svx/colrctrl.hxx
index ee3451bc..cd0fa07 100644
--- a/include/svx/colrctrl.hxx
+++ b/include/svx/colrctrl.hxx
@@ -21,7 +21,7 @@

#include <sfx2/dockwin.hxx>
#include <sfx2/childwin.hxx>
#include <svtools/valueset.hxx>
#include <svx/SvxColorValueSet.hxx>
#include <svtools/transfer.hxx>
#include <svl/lstner.hxx>
#include <svx/svxdllapi.h>
@@ -31,17 +31,16 @@ class SvData;

/*************************************************************************
|*
|* SvxColorValueSet
|* SvxColorValueSet_docking
|*
\************************************************************************/

class SvxColorValueSet : public ValueSet, public DragSourceHelper
class SvxColorValueSet_docking : public SvxColorValueSet, public DragSourceHelper
{
    using ValueSet::StartDrag;

private:
    using SvxColorValueSet::StartDrag;

    sal_Bool            bLeft;
    bool            mbLeftButton;
    Point           aDragPosPixel;

protected:
@@ -56,27 +55,13 @@ protected:
    // DragSourceHelper
    virtual void    StartDrag( sal_Int8 nAction, const Point& rPtPixel );

                    DECL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*);
                    DECL_STATIC_LINK(SvxColorValueSet_docking, ExecDragHdl, void*);

public:
                    SvxColorValueSet( Window* pParent, const ResId& rResId );
                    SvxColorValueSet_docking( Window* pParent, WinBits nWinStyle = WB_ITEMBORDER );
                    SvxColorValueSet_docking( Window* pParent, const ResId& rResId );

    sal_Bool            IsLeftButton() const { return bLeft; }
};

/*************************************************************************
|*
|* Derivation from SfxChildWindow as "container" for Controller
|*
\************************************************************************/

class SVX_DLLPUBLIC SvxColorChildWindow : public SfxChildWindow
{
 public:
    SvxColorChildWindow( Window*, sal_uInt16, SfxBindings*,
                         SfxChildWinInfo* );

    SFX_DECL_CHILDWINDOW_WITHID(SvxColorChildWindow);
    bool IsLeftButton() const { return mbLeftButton; }
};

/*************************************************************************
@@ -91,13 +76,12 @@ class SvxColorDockingWindow : public SfxDockingWindow, public SfxListener

private:
    XColorListRef       pColorList;
    SvxColorValueSet    aColorSet;
    SvxColorValueSet_docking aColorSet;
    sal_uInt16          nLeftSlot;
    sal_uInt16          nRightSlot;
    sal_uInt16          nCols;
    sal_uInt16          nLines;
    long                nCount;
    Size                aColorSize;
    Size                aItemSize;

    void                FillValueSet();
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 292c3fb..bacec11 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -20,6 +20,7 @@
#ifndef _SV_BITMAP_HXX
#define _SV_BITMAP_HXX

#include <tools/color.hxx>
#include <tools/link.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
@@ -823,6 +824,36 @@ public:
    bool                        HasAlpha();

public:
    /** Draw a blend frame to the Bitmap

        @param nAlpha
        The blend value defines how strong the frame will be blended with the
        existing content, 255 == full coverage, 0 == no frame will be drawn

        @param aColorTopLeft, aColorBottomRight, aColorTopRight, aColorBottomLeft
        The colors defining the frame. If the version without aColorTopRight and
        aColorBottomLeft is used, these colors are linearly interpolated from
        aColorTopLeft and aColorBottomRight using the width and height of the area

        @param rTopLeft
        The start point of the frame in pixels

        @param rSize
        The size of the frame in pixels
     */
    void DrawBlendFrame(
        sal_uInt8 nAlpha = 128,
        Color aColorTopLeft = Color(COL_WHITE),
        Color aColorBottomRight = Color(COL_BLACK));
    void DrawBlendFrame(
        const Point& rTopLeft,
        const Size& rSize,
        sal_uInt8 nAlpha = 128,
        Color   aColorTopLeft = Color(COL_WHITE),
        Color   aColorTopRight = Color(COL_GRAY),
        Color   aColorBottomRight = Color(COL_BLACK),
        Color   aColorBottomLeft = Color(COL_GRAY));

    BitmapReadAccess*       AcquireReadAccess();
    BitmapWriteAccess*      AcquireWriteAccess();
    void                    ReleaseAccess( BitmapReadAccess* pAccess );
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index fbff56b8..517d8c2 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -618,6 +618,86 @@
        </constraints>
        <value>10000</value>
      </prop>
      <prop oor:name="ColorValueSetMaximumRowCount" oor:type="xs:short">
        <info>
          <author>ALG</author>
          <desc>Defines the maximum row count for ColorValueSets. If more rows are needed, a Scrollbar will be used.</desc>
          <label>A Scrollbar will be used when more rows are needed.</label>
        </info>
        <constraints>
          <minInclusive oor:value="10">
            <info>
              <desc>Specifies the minimum number of rows before a Scrollbar will be used.</desc>
            </info>
          </minInclusive>
          <maxInclusive oor:value="99">
            <info>
              <desc>Specifies the maximum number of rows before a Scrollbar will be used.</desc>
            </info>
          </maxInclusive>
        </constraints>
        <value>40</value>
      </prop>
      <prop oor:name="ColorValueSetEntryEdgeLength" oor:type="xs:short">
        <info>
          <author>ALG</author>
          <desc>Defines the EdgeLength in Pixels for Entries generated inside of ColorValueSets. The Entries are quadratic for Colors.</desc>
          <label>Entries in ColorValueSets will have this quadratic size in Pixels.</label>
        </info>
        <constraints>
          <minInclusive oor:value="8">
            <info>
              <desc>Specifies the minimum EdgeLength for Entries in ColorValueSets.</desc>
            </info>
          </minInclusive>
          <maxInclusive oor:value="18">
            <info>
              <desc>Specifies the minimum EdgeLength for Entries in ColorValueSets.</desc>
            </info>
          </maxInclusive>
        </constraints>
        <value>14</value>
      </prop>
      <prop oor:name="ColorValueSetColumnCount" oor:type="xs:short">
        <info>
          <author>ALG</author>
          <desc>Defines how many colums are to be used in ColorValueSets. The idea is to use this defined count to have a good visualisation in ColorValueSets which offers the used ColorTable schema nicely layouted to the User.</desc>
          <label>The ColumnCount used in ColorValueSets.</label>
        </info>
        <constraints>
          <minInclusive oor:value="12">
            <info>
              <desc>Specifies the perfect number of columns for ColorValueSet layout.</desc>
            </info>
          </minInclusive>
          <maxInclusive oor:value="24">
            <info>
              <desc>Specifies a maximum number of columns for ColorValueSet layout.</desc>
            </info>
          </maxInclusive>
        </constraints>
        <value>12</value>
      </prop>
      <prop oor:name="EdgeBlending" oor:type="xs:short">
        <info>
          <author>ALG</author>
          <desc>Option to use EdgeBlending for previews in the UI (for ColorValueSet, ColorDropDown, FillStyle/LineStyle previews, etc...). EdgeBlending will visualize a one pixel border on the preview object so that a noce 3D effect is shown. It is a percent value describing how strong the effect shall be. The value 0% switches it off, while the value 100% will cover the preview object completely on it's borders.</desc>
          <label>Defines the EdgeBlending for Previews in percent.</label>
        </info>
        <constraints>
          <minInclusive oor:value="0">
            <info>
              <desc>Specifies that no EdgeBlending shall happen.</desc>
            </info>
          </minInclusive>
          <maxInclusive oor:value="99">
            <info>
              <desc>Specifies that EdgeBlending will cover the edges of Previews completely.</desc>
            </info>
          </maxInclusive>
        </constraints>
        <value>35</value>
      </prop>
    </group>
    <group oor:name="ObjectNames">
      <info>
diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx
index 73f6127..3b6de2c 100644
--- a/sc/source/ui/inc/tabbgcolordlg.hxx
+++ b/sc/source/ui/inc/tabbgcolordlg.hxx
@@ -23,7 +23,7 @@
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <svtools/valueset.hxx>
#include <svx/SvxColorValueSet.hxx>

//------------------------------------------------------------------------

@@ -40,7 +40,7 @@ public:
    void GetSelectedColor( Color& rColor ) const;

private:
    class ScTabBgColorValueSet : public ValueSet
    class ScTabBgColorValueSet : public SvxColorValueSet
    {
    public:
        ScTabBgColorValueSet(Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg);
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
index c2c8fa8..9d1c9c6 100644
--- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -84,7 +84,6 @@ void ScTabBgColorDlg::FillColorValueSets_Impl()
    const SfxPoolItem* pItem = NULL;
    XColorListRef pColorList;

    const Size aSize15x15 = Size( 15, 15 );
    sal_uInt16 nSelectedItem = 0;

    OSL_ENSURE( pDocSh, "DocShell not found!" );
@@ -94,39 +93,72 @@ void ScTabBgColorDlg::FillColorValueSets_Impl()
    if ( !pColorList.is() )
        pColorList = XColorList::CreateStdColorList();

    long nColorCount(0);

    if ( pColorList.is() )
    {
        sal_uInt16 i = 0;
        long nCount = pColorList->Count();
        XColorEntry* pEntry = NULL;
        nColorCount = pColorList->Count();
        Color aColWhite( COL_WHITE );
        String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
        WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
        aTabBgColorSet.addEntriesForXColorList(*pColorList);
    }

    if(nColorCount)
    {
        const WinBits nBits(aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
        aTabBgColorSet.SetText( aTabBgColorNoColorText );
        aTabBgColorSet.SetStyle( nBits );
        for ( i = 0; i < nCount; i++ )
        {
            pEntry = pColorList->GetColor(i);
            aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
            if (pEntry->GetColor() == aTabBgColor)
                nSelectedItem = (i + 1);
        }
        static sal_Int32 nAdd = 4;

        while ( i < 80 )
        {
            aTabBgColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
            i++;
        }
        // calculate new size of color control as base, derive size of border win
        const Size aNewSize(aTabBgColorSet.layoutAllVisible(nColorCount));
        const Size aNewSizeBorderWin(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd);

        if ( nCount > 80 )
        {
            aTabBgColorSet.SetStyle( nBits | WB_VSCROLL );
        }
        // from that, calculate a new dialog size
        const Size aCurrentSizeDialog(GetOutputSizePixel());
        const Size aCurrentSizeBorderWin(aBorderWin.GetOutputSizePixel());
        const long nOffsetX(aCurrentSizeDialog.Width() - aCurrentSizeBorderWin.Width());
        const long nOffsetY(aCurrentSizeDialog.Height() - aCurrentSizeBorderWin.Height());
        const Size aNewSizeDialog(aNewSizeBorderWin.Width() + nOffsetX, aNewSizeBorderWin.Height() + nOffsetY);

        // also need to adapt pos and size for the three buttons; as a base, take their original
        // distance from the dialog bottom and get new Y-Pos
        const long aButtonOffsetFromBottom(aCurrentSizeDialog.Height() - aBtnOk.GetPosPixel().Y());
        const long aNewButtonY(aNewSizeDialog.Height() - aButtonOffsetFromBottom);

        // for each button, scale width and x-pos by old/new dialog sizes and re-layout
        // for Okay-Button
        const long aNewWidthOkay((aBtnOk.GetSizePixel().Width() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const long aNewPosOkay((aBtnOk.GetPosPixel().X() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const Size aNewSizeOkay(aNewWidthOkay, aBtnOk.GetOutputSizePixel().Height());
        aBtnOk.SetOutputSizePixel(aNewSizeOkay);
        aBtnOk.SetPosSizePixel(Point(aNewPosOkay, aNewButtonY), aNewSizeOkay);

        // for Cancel-Button
        const long aNewWidthCancel((aBtnCancel.GetSizePixel().Width() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const long aNewPosCancel((aBtnCancel.GetPosPixel().X() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const Size aNewSizeCancel(aNewWidthCancel, aBtnCancel.GetOutputSizePixel().Height());
        aBtnCancel.SetOutputSizePixel(aNewSizeCancel);
        aBtnCancel.SetPosSizePixel(Point(aNewPosCancel, aNewButtonY), aNewSizeCancel);

        // for Help-Button
        const long aNewWidthHelp((aBtnHelp.GetSizePixel().Width() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const long aNewPosHelp((aBtnHelp.GetPosPixel().X() * aNewSizeDialog.Width()) / aCurrentSizeDialog.Width());
        const Size aNewSizeHelp(aNewWidthHelp, aBtnHelp.GetOutputSizePixel().Height());
        aBtnHelp.SetOutputSizePixel(aNewSizeHelp);
        aBtnHelp.SetPosSizePixel(Point(aNewPosHelp, aNewButtonY), aNewSizeHelp);

        // set new sizes for color control
        aTabBgColorSet.SetOutputSizePixel(aNewSize);
        aTabBgColorSet.SetPosSizePixel(Point(nAdd/2, nAdd/2), aNewSize);

        // set new size for border win
        aBorderWin.SetOutputSizePixel(aNewSizeBorderWin);

        // set new size for dialog itself
        SetOutputSizePixel(aNewSizeDialog);
    }
    aTabBgColorSet.SetColCount( 10 );
    aTabBgColorSet.SetLineCount( 10 );
    aTabBgColorSet.CalcWindowSizePixel( aSize15x15 );
    aTabBgColorSet.Format();

    aTabBgColorSet.SelectItem(nSelectedItem);
    aTabBgColorSet.Resize();
}
@@ -156,7 +188,7 @@ IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl)
}

ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet( Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg ) :
    ValueSet(pParent, rResId)
    SvxColorValueSet(pParent, rResId)
{
    aTabBgColorDlg = pTabBgColorDlg;
}
@@ -175,7 +207,7 @@ void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
        }
        break;
    }
    ValueSet::KeyInput(rKEvt);
    SvxColorValueSet::KeyInput(rKEvt);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/app/sddll2.cxx b/sd/source/ui/app/sddll2.cxx
index e961cbf0..3088415 100644
--- a/sd/source/ui/app/sddll2.cxx
+++ b/sd/source/ui/app/sddll2.cxx
@@ -28,7 +28,7 @@
#include <svx/galbrws.hxx>
#include <svx/srchdlg.hxx>
#include <svx/fontwork.hxx>
#include <svx/colrctrl.hxx>
#include <svx/SvxColorChildWindow.hxx>
#include <svx/verttexttbxctrl.hxx>
#include <svx/hyperdlg.hxx>
#include <svx/fillctrl.hxx>
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 7bb32b8..6f67a1b 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -50,7 +50,7 @@
#include <svx/f3dchild.hxx>
#include <svx/imapdlg.hxx>
#include <svx/fontwork.hxx>
#include <svx/colrctrl.hxx>
#include <svx/SvxColorChildWindow.hxx>
#include <svx/bmpmask.hxx>
#include <svx/srchdlg.hxx>
#include <svx/hyperdlg.hxx>
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index e5c12ca..37619aa 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -93,6 +93,7 @@
#include <editeng/shdditem.hxx>
#include <svx/xtable.hxx>
#include <svx/svdobj.hxx>
#include <svx/SvxColorChildWindow.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/flstitem.hxx>
#include <editeng/scripttypeitem.hxx>
diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
index 8ccc1bd..a4b0c2e 100644
--- a/sd/source/ui/view/drviews6.cxx
+++ b/sd/source/ui/view/drviews6.cxx
@@ -30,7 +30,7 @@
#include <svx/galbrws.hxx>
#include <svx/imapdlg.hxx>
#include <svx/xftsfit.hxx>
#include <svx/colrctrl.hxx>
#include <svx/SvxColorChildWindow.hxx>
#include <svx/f3dchild.hxx>
#include "optsitem.hxx"
#include <svx/extrusionbar.hxx>
diff --git a/sd/source/ui/view/drvwshrg.cxx b/sd/source/ui/view/drvwshrg.cxx
index abe2d38..c71959c 100644
--- a/sd/source/ui/view/drvwshrg.cxx
+++ b/sd/source/ui/view/drvwshrg.cxx
@@ -26,7 +26,7 @@
#include <svx/bmpmask.hxx>
#include <svx/galbrws.hxx>
#include <svx/imapdlg.hxx>
#include <svx/colrctrl.hxx>
#include <svx/SvxColorChildWindow.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/sidebar/SidebarChildWindow.hxx>
#include <svx/f3dchild.hxx>
diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx
index 4bc1653..a830a99 100644
--- a/svtools/source/config/accessibilityoptions.cxx
+++ b/svtools/source/config/accessibilityoptions.cxx
@@ -54,6 +54,10 @@ namespace
    const char s_sIsAutomaticFontColor[] = "IsAutomaticFontColor";
    const char s_sIsSystemFont[] = "IsSystemFont";
    const char s_sIsSelectionInReadonly[] = "IsSelectionInReadonly";
    const char s_sColorValueSetMaximumRowCount[] = "ColorValueSetMaximumRowCount";
    const char s_sColorValueSetEntryEdgeLength[] = "ColorValueSetEntryEdgeLength";
    const char s_sColorValueSetColumnCount[] = "ColorValueSetColumnCount";
    const char s_sEdgeBlending[] = "EdgeBlending";
}

// class SvtAccessibilityOptions_Impl ---------------------------------------------
@@ -78,6 +82,10 @@ public:
    sal_Bool    GetIsSystemFont() const;
    sal_Int16   GetHelpTipSeconds() const;
    sal_Bool    IsSelectionInReadonly() const;
    sal_Int16   GetColorValueSetMaximumRowCount() const;
    sal_Int16   GetColorValueSetEntryEdgeLength() const;
    sal_Int16   GetColorValueSetColumnCount() const;
    sal_Int16   GetEdgeBlending() const;

    void        SetAutoDetectSystemHC(sal_Bool bSet);
    void        SetIsForPagePreviews(sal_Bool bSet);
@@ -88,6 +96,10 @@ public:
    void        SetIsSystemFont(sal_Bool bSet);
    void        SetHelpTipSeconds(sal_Int16 nSet);
    void        SetSelectionInReadonly(sal_Bool bSet);
    void        SetColorValueSetMaximumRowCount(sal_Int16 nSet);
    void        SetColorValueSetEntryEdgeLength(sal_Int16 nSet);
    void        SetColorValueSetColumnCount(sal_Int16 nSet);
    void        SetEdgeBlending(sal_Int16 nSet);

    sal_Bool    IsModified() const { return bIsModified; };
};
@@ -292,6 +304,78 @@ sal_Bool SvtAccessibilityOptions_Impl::IsSelectionInReadonly() const
    return bRet;
}

sal_Int16 SvtAccessibilityOptions_Impl::GetColorValueSetMaximumRowCount() const
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
    sal_Int16 nRet = 40;

    try
    {
        if(xNode.is())
            xNode->getPropertyValue(s_sColorValueSetMaximumRowCount) >>= nRet;
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }

    return nRet;
}

sal_Int16 SvtAccessibilityOptions_Impl::GetColorValueSetEntryEdgeLength() const
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
    sal_Int16 nRet = 14;

    try
    {
        if(xNode.is())
            xNode->getPropertyValue(s_sColorValueSetEntryEdgeLength) >>= nRet;
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }

    return nRet;
}

sal_Int16 SvtAccessibilityOptions_Impl::GetColorValueSetColumnCount() const
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
    sal_Int16 nRet = 12;

    try
    {
        if(xNode.is())
            xNode->getPropertyValue(s_sColorValueSetColumnCount) >>= nRet;
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }

    return nRet;
}

sal_Int16 SvtAccessibilityOptions_Impl::GetEdgeBlending() const
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
    sal_Int16 nRet = 35;

    try
    {
        if(xNode.is())
            xNode->getPropertyValue(s_sEdgeBlending) >>= nRet;
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }

    return nRet;
}

void SvtAccessibilityOptions_Impl::SetAutoDetectSystemHC(sal_Bool bSet)
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
@@ -489,6 +573,86 @@ void SvtAccessibilityOptions_Impl::SetVCLSettings()
    Application::SetSettings(aAllSettings);
}

void SvtAccessibilityOptions_Impl::SetColorValueSetMaximumRowCount(sal_Int16 nSet)
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);

    try
    {
        if(xNode.is() && xNode->getPropertyValue(s_sColorValueSetMaximumRowCount)!=nSet)
        {
            xNode->setPropertyValue(s_sColorValueSetMaximumRowCount, css::uno::makeAny(nSet));
            ::comphelper::ConfigurationHelper::flush(m_xCfg);

            bIsModified = sal_True;
        }
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }
}

void SvtAccessibilityOptions_Impl::SetColorValueSetEntryEdgeLength(sal_Int16 nSet)
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);

    try
    {
        if(xNode.is() && xNode->getPropertyValue(s_sColorValueSetEntryEdgeLength)!=nSet)
        {
            xNode->setPropertyValue(s_sColorValueSetEntryEdgeLength, css::uno::makeAny(nSet));
            ::comphelper::ConfigurationHelper::flush(m_xCfg);

            bIsModified = sal_True;
        }
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }
}

void SvtAccessibilityOptions_Impl::SetColorValueSetColumnCount(sal_Int16 nSet)
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);

    try
    {
        if(xNode.is() && xNode->getPropertyValue(s_sColorValueSetColumnCount)!=nSet)
        {
            xNode->setPropertyValue(s_sColorValueSetColumnCount, css::uno::makeAny(nSet));
            ::comphelper::ConfigurationHelper::flush(m_xCfg);

            bIsModified = sal_True;
        }
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }
}

void SvtAccessibilityOptions_Impl::SetEdgeBlending(sal_Int16 nSet)
{
    css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);

    try
    {
        if(xNode.is() && xNode->getPropertyValue(s_sEdgeBlending)!=nSet)
        {
            xNode->setPropertyValue(s_sEdgeBlending, css::uno::makeAny(nSet));
            ::comphelper::ConfigurationHelper::flush(m_xCfg);

            bIsModified = sal_True;
        }
    }
    catch(const css::uno::Exception& ex)
    {
        SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
    }
}

// -----------------------------------------------------------------------
// class SvtAccessibilityOptions --------------------------------------------------

@@ -582,6 +746,26 @@ sal_Bool SvtAccessibilityOptions::IsSelectionInReadonly() const
    return sm_pSingleImplConfig->IsSelectionInReadonly();
}

sal_Int16 SvtAccessibilityOptions::GetColorValueSetMaximumRowCount() const
{
    return sm_pSingleImplConfig->GetColorValueSetMaximumRowCount();
}

sal_Int16 SvtAccessibilityOptions::GetColorValueSetEntryEdgeLength() const
{
    return sm_pSingleImplConfig->GetColorValueSetEntryEdgeLength();
}

sal_Int16 SvtAccessibilityOptions::GetColorValueSetColumnCount() const
{
    return sm_pSingleImplConfig->GetColorValueSetColumnCount();
}

sal_Int16 SvtAccessibilityOptions::GetEdgeBlending() const
{
    return sm_pSingleImplConfig->GetEdgeBlending();
}

// -----------------------------------------------------------------------
void SvtAccessibilityOptions::SetAutoDetectSystemHC(sal_Bool bSet)
{
@@ -619,11 +803,26 @@ void SvtAccessibilityOptions::SetSelectionInReadonly(sal_Bool bSet)
{
    sm_pSingleImplConfig->SetSelectionInReadonly(bSet);
}

void SvtAccessibilityOptions::SetVCLSettings()
{
    sm_pSingleImplConfig->SetVCLSettings();
}
void SvtAccessibilityOptions::SetColorValueSetMaximumRowCount(sal_Int16 nSet)
{
    sm_pSingleImplConfig->SetColorValueSetMaximumRowCount(nSet);
}
void SvtAccessibilityOptions::SetColorValueSetEntryEdgeLength(sal_Int16 nSet)
{
    sm_pSingleImplConfig->SetColorValueSetEntryEdgeLength(nSet);
}
void SvtAccessibilityOptions::SetColorValueSetColumnCount(sal_Int16 nSet)
{
    sm_pSingleImplConfig->SetColorValueSetColumnCount(nSet);
}
void SvtAccessibilityOptions::SetEdgeBlending(sal_Int16 nSet)
{
    sm_pSingleImplConfig->SetEdgeBlending(nSet);
}
// -----------------------------------------------------------------------

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 9eb2124..1006bf0 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -28,7 +28,7 @@
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <rtl/ustring.hxx>

#include <svtools/accessibilityoptions.hxx>
#include "valueimp.hxx"

#include <svtools/valueset.hxx>
@@ -294,6 +294,25 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect )
        {
            maVirDev.SetFillColor( pItem->maColor );
            maVirDev.DrawRect( aRect );

            const SvtAccessibilityOptions aOptions;
            const sal_Int16 nEdgeBlendingPercent(aOptions.GetEdgeBlending());
            static bool bTest(false);

            if(nEdgeBlendingPercent && bTest)
            {
                Bitmap aBitmap(maVirDev.GetBitmap(aRect.TopLeft(), aRect.GetSize()));

                if(!aBitmap.IsEmpty())
                {
                    const Color aTopLeft(COL_WHITE);
                    const Color aBottomRight(COL_BLACK);
                    const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);

                    aBitmap.DrawBlendFrame(nAlpha, aTopLeft, aBottomRight);
                    maVirDev.DrawBitmap(aRect.TopLeft(), aBitmap);
                }
            }
        }
        else
        {
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index 3089cde..420bb63 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -214,6 +214,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
    svx/source/table/tablertfexporter \
    svx/source/table/tablertfimporter \
    svx/source/tbxctrls/colrctrl \
    svx/source/tbxctrls/SvxColorChildWindow \
    svx/source/tbxctrls/fillctrl \
    svx/source/tbxctrls/formatpaintbrushctrl \
    svx/source/tbxctrls/grafctrl \
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 2f3eaf9..94fbf16 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -334,6 +334,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
    svx/source/tbxctrls/fontworkgallery \
    svx/source/tbxctrls/tbcontrl \
    svx/source/tbxctrls/tbxcolorupdate \
    svx/source/tbxctrls/SvxColorValueSet \
    svx/source/toolbars/extrusionbar \
    svx/source/toolbars/fontworkbar \
    svx/source/unodraw/gluepts \
diff --git a/svx/inc/svx/sidebar/ColorControl.hxx b/svx/inc/svx/sidebar/ColorControl.hxx
index 58ab534..606a906 100644
--- a/svx/inc/svx/sidebar/ColorControl.hxx
+++ b/svx/inc/svx/sidebar/ColorControl.hxx
@@ -19,6 +19,7 @@

#include <svtools/valueset.hxx>
#include <boost/function.hpp>
#include <svx/SvxColorValueSet.hxx>

class Window;
class SfxBindings;
@@ -69,7 +70,7 @@ public:

private:
    SfxBindings* mpBindings;
    ValueSet maVSColor;
    SvxColorValueSet maVSColor;
    FloatingWindow* mpFloatingWindow;
    const String msNoColorString;
    ::boost::function<Color(void)> maNoColorGetter;
diff --git a/svx/source/sidebar/tools/ColorControl.cxx b/svx/source/sidebar/tools/ColorControl.cxx
index 85d3f353..3a517b9 100644
--- a/svx/source/sidebar/tools/ColorControl.cxx
+++ b/svx/source/sidebar/tools/ColorControl.cxx
@@ -104,6 +104,7 @@ ColorControl::ColorControl (
      maColorSetter(rColorSetter)
{
    FreeResource();
    FillColors();
}


@@ -121,40 +122,37 @@ void ColorControl::FillColors (void)

    if (xColorTable.is())
    {
        const long nColorCount (xColorTable->Count());
        const long nColorCount(xColorTable->Count());
        if (nColorCount <= 0)
            return;
        const sal_Int32 nColumnCount (ceil(sqrt(double(nColorCount))));
        const sal_Int32 nRowCount (ceil(double(nColorCount)/nColumnCount));
        maVSColor.SetColCount(nColumnCount);
        maVSColor.SetLineCount(nRowCount);
        const sal_Int32 nItemSize (15*12 / ::std::max<sal_Int32>(nColumnCount, nRowCount));
        maVSColor.CalcWindowSizePixel(Size(nItemSize,nItemSize));
        Link aLink =  LINK(this, ColorControl, VSSelectHdl);
        maVSColor.SetSelectHdl(aLink);
        maVSColor.SetStyle(
            (maVSColor.GetStyle()
                | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD// | WB_FLATVALUESET
                | WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT)
                        & ~WB_VSCROLL);

        if (msNoColorString.Len() > 0)
        const WinBits aWinBits(maVSColor.GetStyle() | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD |
            WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT);

        maVSColor.SetStyle(aWinBits);

        // neds to be done *before* layouting
        if(msNoColorString.Len() > 0)
        {
            maVSColor.SetStyle(maVSColor.GetStyle() | WB_NONEFIELD);
            maVSColor.SetText(msNoColorString);
        }

        const Size aNewSize(maVSColor.layoutAllVisible(nColorCount));
        maVSColor.SetOutputSizePixel(aNewSize);
        static sal_Int32 nAdd = 4;

        SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
        Link aLink = LINK(this, ColorControl, VSSelectHdl);
        maVSColor.SetSelectHdl(aLink);

        // Now, after all calls to SetStyle, we can change the
        // background color.
        maVSColor.SetBackground(Theme::GetWallpaper(Theme::Paint_DropDownBackground));

        // add entrties
        maVSColor.Clear();
        XColorEntry* pEntry = NULL;
        for (sal_Int32 nIndex=0; nIndex<nColorCount; ++nIndex)
        {
            pEntry = xColorTable->GetColor(nIndex);
            maVSColor.InsertItem(nIndex+1, pEntry->GetColor(), pEntry->GetName() );
        }
        maVSColor.addEntriesForXColorList(*xColorTable);
    }

    maVSColor.Show();
@@ -173,7 +171,7 @@ void ColorControl::GetFocus (void)

void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable)
{
    FillColors();
//  FillColors();
    short nCol = GetItemId_Imp( maVSColor, aCol );
    if(! bAvailable)
    {
@@ -188,7 +186,9 @@ void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable)
    }
    else
    {
        maVSColor.SelectItem( nCol );
        // remove selection first to force evtl. scroll when scroll is needed
        maVSColor.SetNoSelection();
        maVSColor.SelectItem(nCol);
    }
}

diff --git a/svx/source/tbxctrls/SvxColorChildWindow.cxx b/svx/source/tbxctrls/SvxColorChildWindow.cxx
new file mode 100644
index 0000000..1ce729e
--- /dev/null
+++ b/svx/source/tbxctrls/SvxColorChildWindow.cxx
@@ -0,0 +1,47 @@
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <svx/SvxColorChildWindow.hxx>
#include <sfx2/dockwin.hxx>
#include <svx/svxids.hrc>
#include <svx/dialogs.hrc>
#include <svx/colrctrl.hxx>
#include <svx/dialmgr.hxx>

SFX_IMPL_DOCKINGWINDOW_WITHID( SvxColorChildWindow, SID_COLOR_CONTROL )

/*************************************************************************
|*
|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator
|*
\************************************************************************/

SvxColorChildWindow::SvxColorChildWindow( Window* _pParent,
                                          sal_uInt16 nId,
                                          SfxBindings* pBindings,
                                          SfxChildWinInfo* pInfo ) :
    SfxChildWindow( _pParent, nId )
{
    SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this,
                                        _pParent, SVX_RES( RID_SVXCTRL_COLOR ) );
    pWindow = pWin;

    eChildAlignment = SFX_ALIGN_BOTTOM;

    pWin->Initialize( pInfo );
}
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
new file mode 100644
index 0000000..34dfa6c
--- /dev/null
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -0,0 +1,149 @@
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <svx/SvxColorValueSet.hxx>
#include <svx/xtable.hxx>
#include <svtools/accessibilityoptions.hxx>

//////////////////////////////////////////////////////////////////////////////

SvxColorValueSet::SvxColorValueSet(Window* _pParent, WinBits nWinStyle)
:   ValueSet(_pParent, nWinStyle)
{
}

SvxColorValueSet::SvxColorValueSet(Window* _pParent, const ResId& rResId)
:   ValueSet(_pParent, rResId)
{
}

sal_uInt32 SvxColorValueSet::getMaxRowCount() const
{
    const SvtAccessibilityOptions aOptions;

    return aOptions.GetColorValueSetMaximumRowCount();
}

sal_uInt32 SvxColorValueSet::getEntryEdgeLength() const
{
    const SvtAccessibilityOptions aOptions;

    return aOptions.GetColorValueSetEntryEdgeLength();
}

sal_uInt32 SvxColorValueSet::getColumnCount() const
{
    const SvtAccessibilityOptions aOptions;

    return aOptions.GetColorValueSetColumnCount();
}

void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex)
{
    const sal_uInt32 nColorCount(rXColorList.Count());

    for(sal_uInt32 nIndex(0); nIndex < nColorCount; nIndex++, nStartIndex++)
    {
        const XColorEntry* pEntry = rXColorList.GetColor(nIndex);

        if(pEntry)
        {
            InsertItem(nStartIndex, pEntry->GetColor(), pEntry->GetName());
        }
        else
        {
            OSL_ENSURE(false, "OOps, XColorList with empty entries (!)");
        }
    }
}

Size SvxColorValueSet::layoutAllVisible(sal_uInt32 nEntryCount)
{
    if(!nEntryCount)
    {
        nEntryCount++;
    }

    const sal_uInt32 nRowCount(ceil(double(nEntryCount)/getColumnCount()));
    const Size aItemSize(getEntryEdgeLength() - 2, getEntryEdgeLength() - 2);
    const WinBits aWinBits(GetStyle() & ~WB_VSCROLL);

    if(nRowCount > getMaxRowCount())
    {
        SetStyle(aWinBits|WB_VSCROLL);
    }
    else
    {
        SetStyle(aWinBits);
    }

    SetColCount(getColumnCount());
    SetLineCount(std::min(nRowCount, getMaxRowCount()));
    SetItemWidth(aItemSize.Width());
    SetItemHeight(aItemSize.Height());

    return CalcWindowSizePixel(aItemSize);
}

Size SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount)
{
    if(!nEntryCount)
    {
        nEntryCount++;
    }

    const Size aItemSize(getEntryEdgeLength(), getEntryEdgeLength());
    const WinBits aWinBits(GetStyle() & ~WB_VSCROLL);

    // get size whith all fields disabled
    const WinBits aWinBitsNoScrollNoFields(GetStyle() & ~(WB_VSCROLL|WB_NAMEFIELD|WB_NONEFIELD));
    SetStyle(aWinBitsNoScrollNoFields);
    const Size aSizeNoScrollNoFields(CalcWindowSizePixel(aItemSize, getColumnCount()));

    // get size with all needed fields
    SetStyle(aWinBits);
    Size aNewSize(CalcWindowSizePixel(aItemSize, getColumnCount()));

    // evtl. activate vertical scroll
    const bool bAdaptHeight(static_cast< sal_uInt32 >(aNewSize.Height()) > nHeight);

    if(bAdaptHeight)
    {
        SetStyle(aWinBits|WB_VSCROLL);
        aNewSize = CalcWindowSizePixel(aItemSize, getColumnCount());
    }

    // calculate field height and available height for requested height
    const sal_uInt32 nFieldHeight(aNewSize.Height() - aSizeNoScrollNoFields.Height());
    const sal_uInt32 nAvailableHeight(nHeight >= nFieldHeight ? nHeight - nFieldHeight : 0);

    // calculate how many lines can be shown there
    const Size aItemSizePixel(CalcItemSizePixel(aItemSize));
    const sal_uInt32 nLineCount((nAvailableHeight + aItemSizePixel.Height() - 1) / aItemSizePixel.Height());

    // set height to wanted height
    aNewSize.Height() = nHeight;

    SetItemWidth(aItemSize.Width());
    SetItemHeight(aItemSize.Height());
    SetColCount(getColumnCount());
    SetLineCount(nLineCount);

    return aNewSize;
}

diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 4251608..1a0bf5f1 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -28,6 +28,7 @@
#include <svl/lstner.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/frame/XFrame.hpp>
#include <svx/SvxColorValueSet.hxx>

//========================================================================
// class SvxColorWindow_Impl --------------------------------------------------
@@ -39,7 +40,7 @@ class SvxColorWindow_Impl : public SfxPopupWindow

private:
    const sal_uInt16 theSlotId;
    ValueSet       aColorSet;
    SvxColorValueSet aColorSet;
    OUString  maCommand;
    const Color    mLastColor;

diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
index aec84ef..9f9e89d 100644
--- a/svx/source/tbxctrls/colrctrl.cxx
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -36,8 +36,6 @@
#include "svx/xexch.hxx"
#include <vcl/svapp.hxx>

SFX_IMPL_DOCKINGWINDOW_WITHID( SvxColorChildWindow, SID_COLOR_CONTROL )

// ------------------------
// - SvxColorValueSetData -
// ------------------------
@@ -92,41 +90,41 @@ sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, 

/*************************************************************************
|*
|* SvxColorValueSet: Ctor
|* SvxColorValueSet_docking: Ctor
|*
\************************************************************************/

SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) :
    ValueSet( _pParent, rResId ),
SvxColorValueSet_docking::SvxColorValueSet_docking( Window* _pParent, const ResId& rResId ) :
    SvxColorValueSet( _pParent, rResId ),
    DragSourceHelper( this ),
    bLeft (sal_True)
    mbLeftButton(true)
{
    SetAccessibleName(String( SVX_RES( STR_COLORTABLE )  ));
}

/*************************************************************************
|*
|* SvxColorValueSet: MouseButtonDown
|* SvxColorValueSet_docking: MouseButtonDown
|*
\************************************************************************/

void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt )
void SvxColorValueSet_docking::MouseButtonDown( const MouseEvent& rMEvt )
{
    // Fuer Mac noch anders handlen !
    if( rMEvt.IsLeft() )
    {
        bLeft = sal_True;
        ValueSet::MouseButtonDown( rMEvt );
        mbLeftButton = true;
        SvxColorValueSet::MouseButtonDown( rMEvt );
    }
    else
    {
        bLeft = sal_False;
        mbLeftButton = false;
        MouseEvent aMEvt( rMEvt.GetPosPixel(),
                          rMEvt.GetClicks(),
                          rMEvt.GetMode(),
                          MOUSE_LEFT,
                          rMEvt.GetModifier() );
        ValueSet::MouseButtonDown( aMEvt );
        SvxColorValueSet::MouseButtonDown( aMEvt );
    }

    aDragPosPixel = GetPointerPosPixel();
@@ -134,27 +132,27 @@ void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt )

/*************************************************************************
|*
|* SvxColorValueSet: MouseButtonUp
|* SvxColorValueSet_docking: MouseButtonUp
|*
\************************************************************************/

void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt )
void SvxColorValueSet_docking::MouseButtonUp( const MouseEvent& rMEvt )
{
    // Fuer Mac noch anders handlen !
    if( rMEvt.IsLeft() )
    {
        bLeft = sal_True;
        ValueSet::MouseButtonUp( rMEvt );
        mbLeftButton = true;
        SvxColorValueSet::MouseButtonUp( rMEvt );
    }
    else
    {
        bLeft = sal_False;
        mbLeftButton = false;
        MouseEvent aMEvt( rMEvt.GetPosPixel(),
                          rMEvt.GetClicks(),
                          rMEvt.GetMode(),
                          MOUSE_LEFT,
                          rMEvt.GetModifier() );
        ValueSet::MouseButtonUp( aMEvt );
        SvxColorValueSet::MouseButtonUp( aMEvt );
    }
    SetNoSelection();
}
@@ -165,10 +163,10 @@ void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt )
|*
\************************************************************************/

void SvxColorValueSet::Command(const CommandEvent& rCEvt)
void SvxColorValueSet_docking::Command(const CommandEvent& rCEvt)
{
    // Basisklasse
    ValueSet::Command(rCEvt);
    SvxColorValueSet::Command(rCEvt);
}

/*************************************************************************
@@ -177,9 +175,9 @@ void SvxColorValueSet::Command(const CommandEvent& rCEvt)
|*
\************************************************************************/

void SvxColorValueSet::StartDrag( sal_Int8 , const Point&  )
void SvxColorValueSet_docking::StartDrag( sal_Int8 , const Point&  )
{
    Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl));
    Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet_docking, ExecDragHdl));
}

/*************************************************************************
@@ -188,7 +186,7 @@ void SvxColorValueSet::StartDrag( sal_Int8 , const Point&  )
|*
\************************************************************************/

void SvxColorValueSet::DoDrag()
void SvxColorValueSet_docking::DoDrag()
{
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
    sal_uInt16          nItemId = GetItemId( aDragPosPixel );
@@ -207,7 +205,7 @@ void SvxColorValueSet::DoDrag()
    }
}

IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG)
IMPL_STATIC_LINK(SvxColorValueSet_docking, ExecDragHdl, void*, EMPTYARG)
{
    // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die
    // Farbleiste geloescht werden darf
@@ -217,29 +215,6 @@ IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG)

/*************************************************************************
|*
|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator
|*
\************************************************************************/

SvxColorChildWindow::SvxColorChildWindow( Window* _pParent,
                                          sal_uInt16 nId,
                                          SfxBindings* pBindings,
                                          SfxChildWinInfo* pInfo ) :
    SfxChildWindow( _pParent, nId )
{
    SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this,
                                        _pParent, SVX_RES( RID_SVXCTRL_COLOR ) );
    pWindow = pWin;

    eChildAlignment = SFX_ALIGN_BOTTOM;

    pWin->Initialize( pInfo );
}



/*************************************************************************
|*
|* Ctor: SvxColorDockingWindow
|*
\************************************************************************/
@@ -258,8 +233,7 @@ SvxColorDockingWindow::SvxColorDockingWindow
    nLeftSlot       ( SID_ATTR_FILL_COLOR ),
    nRightSlot      ( SID_ATTR_LINE_COLOR ),
    nCols           ( 20 ),
    nLines          ( 1 ),
    aColorSize      ( 14, 14 )
    nLines          ( 1 )

{
    FreeResource();
@@ -294,10 +268,11 @@ SvxColorDockingWindow::SvxColorDockingWindow
            FillValueSet();
        }
    }
    aItemSize = aColorSet.CalcItemSizePixel( aColorSize );
    aItemSize.Width() = aItemSize.Width() + aColorSize.Width();

    aItemSize = aColorSet.CalcItemSizePixel(Size(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength()));
    aItemSize.Width() = aItemSize.Width() + aColorSet.getEntryEdgeLength();
    aItemSize.Width() /= 2;
    aItemSize.Height() = aItemSize.Height() + aColorSize.Height();
    aItemSize.Height() = aItemSize.Height() + aColorSet.getEntryEdgeLength();
    aItemSize.Height() /= 2;

    SetSize();
@@ -345,12 +320,15 @@ void SvxColorDockingWindow::FillValueSet()
{
    if( pColorList.is() )
    {
        nCount = pColorList->Count();
        aColorSet.Clear();

        // Erster Eintrag: unsichtbar
        // create the first entry for 'invisible/none'
        const Size aColorSize(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength());
        long nPtX = aColorSize.Width() - 1;
        long nPtY = aColorSize.Height() - 1;
        VirtualDevice aVD;

        aVD.SetOutputSizePixel( aColorSize );
        aVD.SetLineColor( Color( COL_BLACK ) );
        aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) );
@@ -361,15 +339,7 @@ void SvxColorDockingWindow::FillValueSet()

        aColorSet.InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );

        XColorEntry* pEntry;
        nCount = pColorList->Count();

        for( long i = 0; i < nCount; i++ )
        {
            pEntry = pColorList->GetColor( i );
            aColorSet.InsertItem( (sal_uInt16)i+2,
                            pEntry->GetColor(), pEntry->GetName() );
        }
        aColorSet.addEntriesForXColorList(*pColorList, 2);
    }
}

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 981e9fb..e58ddae 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1065,10 +1065,6 @@ void SvxFontNameBox_Impl::Select()
#define WB_NO_DIRECTSELECT      ((WinBits)0x04000000)
#endif

#define PALETTE_X 8
#define PALETTE_Y 13
#define PALETTE_SIZE (PALETTE_X * PALETTE_Y)

SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
                                          sal_uInt16                     nSlotId,
                                          const Reference< XFrame >& rFrame,
@@ -1087,7 +1083,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
    const SfxPoolItem* pItem = NULL;
    XColorListRef pColorList;
    const Size aSize12( 13, 13 );

    if ( pDocSh )
        if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
@@ -1125,41 +1120,19 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,

    if ( pColorList.is() )
    {
        short i = 0;
        long nCount = pColorList->Count();
        XColorEntry* pEntry = NULL;
        ::Color aColWhite( COL_WHITE );
        String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );
        const long nColorCount(pColorList->Count());
        const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
        aColorSet.SetOutputSizePixel(aNewSize);
        static sal_Int32 nAdd = 4;

        if ( nCount > PALETTE_SIZE )
            // Show scrollbar if more than PALLETTE_SIZE colors are available
            aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL );

        for ( i = 0; i < nCount; i++ )
        {
            pEntry = pColorList->GetColor(i);
            aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
            if( pEntry->GetColor() == mLastColor )
                aColorSet.SelectItem( i+1 );
        }

        while ( i < PALETTE_SIZE )
        {
            // fill empty elements if less then PALLETTE_SIZE colors are available
            aColorSet.InsertItem( i+1, aColWhite, aStrWhite );
            i++;
        }
        SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
        aColorSet.Clear();
        aColorSet.addEntriesForXColorList(*pColorList);
    }

    aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
    aColorSet.SetColCount( PALETTE_X );
    aColorSet.SetLineCount( PALETTE_Y );

    lcl_CalcSizeValueSet( *this, aColorSet, aSize12 );

    SetHelpId( HID_POPUP_COLOR );
    aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );

    SetText( rWndTitle );
    aColorSet.Show();

@@ -1264,34 +1237,14 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
            if ( pState )
            {
                XColorListRef pColorList = ((SvxColorListItem *)pState)->GetColorList();
                const long nColorCount(pColorList->Count());
                const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
                aColorSet.SetOutputSizePixel(aNewSize);
                static sal_Int32 nAdd = 4;

                short i = 0;
                long nCount = pColorList->Count();
                XColorEntry* pEntry = NULL;
                ::Color aColWhite( COL_WHITE );
                String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );

                // ScrollBar on or off
                WinBits nBits = aColorSet.GetStyle();
                if ( nCount > PALETTE_SIZE )
                    nBits &= ~WB_VSCROLL;
                else
                    nBits |= WB_VSCROLL;
                aColorSet.SetStyle( nBits );

                for ( i = 0; i < nCount; ++i )
                {
                    pEntry = pColorList->GetColor(i);
                    aColorSet.SetItemColor( i + 1, pEntry->GetColor() );
                    aColorSet.SetItemText ( i + 1, pEntry->GetName() );
                }

                while ( i < PALETTE_SIZE )
                {
                    aColorSet.SetItemColor( i + 1, aColWhite );
                    aColorSet.SetItemText ( i + 1, aStrWhite );
                    i++;
                }
                SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
                aColorSet.Clear();
                aColorSet.addEntriesForXColorList(*pColorList);
            }
        }
    }
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index b0afd67..efe8209 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -1165,4 +1165,196 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) {
}


void impMixPixel(BitmapWriteAccess& rAcc, long y, long x, const Color& rColor, sal_uInt8 nAlpha)
{
    const BitmapColor aBitmapColor(rColor);

    if(nAlpha)
    {
        if(255 != nAlpha)
        {
            BitmapColor aTarget(rAcc.GetColor(y, x));

            aTarget.Merge(aBitmapColor, nAlpha);
            rAcc.SetPixel(y, x, aTarget);
        }
    }
    else
    {
        rAcc.SetPixel(y, x, aBitmapColor);
    }
}

inline bool impVisibleX(long x, const Size& rSizePixel)
{
    return x >= 0 && x < rSizePixel.Width();
}

inline bool impVisibleY(long y, const Size& rSizePixel)
{
    return y >= 0 && y < rSizePixel.Width();
}

inline bool impVisibleXY(long y, long x, const Size& rSizePixel)
{
    return impVisibleX(x, rSizePixel) && impVisibleY(y, rSizePixel);
}

void Bitmap::DrawBlendFrame(
    const Point& rTopLeft,
    const Size& rSize,
    sal_uInt8 nAlpha,
    Color aColorTopLeft,
    Color aColorTopRight,
    Color aColorBottomRight,
    Color aColorBottomLeft)
{
    if(!IsEmpty())
    {
        const Size aSizePixel(GetSizePixel());

        if(aSizePixel.Width() && aSizePixel.Height())
        {
            const long nW(rSize.Width());
            const long nH(rSize.Height());

            if(nW || nH)
            {
                BitmapWriteAccess* pAcc = AcquireWriteAccess();
                const long nStartX(rTopLeft.X());
                const long nStartY(rTopLeft.X());
                const long nEndX(rTopLeft.X() + nW);
                const long nEndY(rTopLeft.X() + nH);
                long x(nStartX);
                long y(nStartY);

                if(pAcc)
                {
                    if(impVisibleXY(y, x, aSizePixel))
                    {
                        // x == nStartX, y == nStartY
                        impMixPixel(*pAcc, y, x, aColorTopLeft, nAlpha);
                    }

                    if(impVisibleY(y, aSizePixel))
                    {
                        for(x = 1; x < nEndX - 1; x++) // y == nStartY
                        {
                            if(impVisibleX(x, aSizePixel))
                            {
                                Color aMix(aColorTopLeft);
                                aMix.Merge(aColorTopRight, 255 - sal_uInt8(((x - nStartX) * 255) / nW));
                                impMixPixel(*pAcc, y, x, aMix, nAlpha);
                            }
                        }
                    }
                    else
                    {
                        x = nEndX - 1;
                    }

                    if(impVisibleXY(y, x, aSizePixel))
                    {
                        // x == nEndX - 1, y == nStartY
                        impMixPixel(*pAcc, y, x, aColorTopRight, nAlpha);
                    }

                    const bool bLeftVisible(impVisibleX(nStartX, aSizePixel));
                    const bool bRightVisible(impVisibleX(x, aSizePixel));

                    if(bLeftVisible || bRightVisible)
                    {
                        if(bLeftVisible)
                        {
                            for(y = 1; y < nEndY - 1; y++) // x == nStartX and nEndX-1
                            {
                                if(impVisibleY(y, aSizePixel))
                                {
                                    Color aMix(aColorTopLeft);
                                    aMix.Merge(aColorBottomLeft, 255 - sal_uInt8(((y - nStartY) * 255) / nH));
                                    impMixPixel(*pAcc, y, nStartX, aMix, nAlpha);
                                }
                            }
                        }

                        if(bRightVisible)
                        {
                            for(y = 1; y < nEndY - 1; y++) // x == nStartX and nEndX-1
                            {
                                if(impVisibleY(y, aSizePixel))
                                {
                                    Color aMix(aColorTopRight);
                                    aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((y -nStartY) * 255) / nH));
                                    impMixPixel(*pAcc, y, x, aMix, nAlpha);
                                }
                            }
                        }
                    }
                    else
                    {
                        y = nEndY - 1;
                    }

                    if(impVisibleXY(y, x, aSizePixel))
                    {
                        x = nStartX; // x == nStartX, y == nEndY-1
                        impMixPixel(*pAcc, y, x, aColorBottomLeft, nAlpha);
                    }

                    if(impVisibleY(y, aSizePixel))
                    {
                        for(x = 1; x < nEndX - 1; x++) // y == nEndY-1
                        {
                            if(impVisibleX(x, aSizePixel))
                            {
                                Color aMix(aColorBottomLeft);
                                aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - nStartX)* 255) / nW));
                                impMixPixel(*pAcc, y, x, aMix, nAlpha);
                            }
                        }
                    }
                    else
                    {
                        x = nEndX - 1;
                    }

                    if(impVisibleXY(y, x, aSizePixel))
                    {
                        // x == nEndX - 1, y == nEndY - 1
                        impMixPixel(*pAcc, y, x, aColorBottomRight, nAlpha);
                    }

                    ReleaseAccess(pAcc);
                }
            }
        }
    }
}

void Bitmap::DrawBlendFrame(
    sal_uInt8 nAlpha,
    Color aColorTopLeft,
    Color aColorBottomRight)
{
    if(!IsEmpty())
    {
        const Point aTopLeft(0, 0);
        const Size aSize(GetSizePixel());
        const sal_uInt32 nW(aSize.Width());
        const sal_uInt32 nH(aSize.Height());

        if(nW || nH)
        {
            Color aColTopRight(aColorTopLeft);
            Color aColBottomLeft(aColorTopLeft);
            const sal_uInt32 nDE(nW + nH);

            aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW * 255) / nDE));
            aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH * 255) / nDE));

            DrawBlendFrame(aTopLeft, aSize, nAlpha, aColorTopLeft, aColTopRight, aColorBottomRight, aColBottomLeft);
        }
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */