fdo#59299 Personas for bottom toolbars

Change-Id: If823964bf3bb67563504db61b6c5d557cab89243
Reviewed-on: https://gerrit.libreoffice.org/11609
Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 10ae6a6..fb16ee3 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -522,6 +522,8 @@ public:

    const BitmapEx                  GetPersonaHeader() const;

    const BitmapEx                  GetPersonaFooter() const;

    const boost::optional<Color>&   GetPersonaMenuBarTextColor() const;

    // global switch to allow EdgeBlenging; currently possible for ValueSet and ListBox
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 184c3f1..a4fb97e 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2116,8 +2116,9 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
    OUString aPersona( officecfg::Office::Common::Misc::Persona::get( xContext ) );
    OUString aPersonaSettings( officecfg::Office::Common::Misc::PersonaSettings::get( xContext ) );

    // have the settings changed?
    OUString aOldValue( aPersona + ";" + aPersonaSettings );
    // have the settings changed? marks if header /footer prepared before
    //should maybe extended to a flag that marks if header /footer /both are loaded
    OUString  aOldValue= eWhich==PERSONA_HEADER?OUString(aPersona + ";" + aPersonaSettings+";h" ):OUString(aPersona + ";" + aPersonaSettings+";f" );
    if ( rHeaderFooter == aOldValue )
        return;

@@ -2186,6 +2187,12 @@ const BitmapEx StyleSettings::GetPersonaHeader() const
    return mpData->maPersonaHeaderBitmap;
}

const BitmapEx StyleSettings::GetPersonaFooter() const
{
    setupPersonaHeaderFooter( PERSONA_FOOTER, mpData->maPersonaHeaderFooter, mpData->maPersonaFooterBitmap, mpData->maPersonaMenuBarTextColor );
    return mpData->maPersonaFooterBitmap;
}

const boost::optional<Color>& StyleSettings::GetPersonaMenuBarTextColor() const
{
    GetPersonaHeader();
diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx
index bda794b..6d6416d 100644
--- a/vcl/source/window/dockingarea.cxx
+++ b/vcl/source/window/dockingarea.cxx
@@ -46,12 +46,16 @@ DockingAreaWindow::ImplData::~ImplData()

static void ImplInitBackground( DockingAreaWindow* pThis )
{
    const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
    if ( !rPersonaBitmap.IsEmpty() && pThis->GetAlign() == WINDOWALIGN_TOP )
    const StyleSettings rSetting = Application::GetSettings().GetStyleSettings();
    const BitmapEx& rPersonaBitmap = pThis->GetAlign() == WINDOWALIGN_TOP ? rSetting.GetPersonaHeader() :rSetting.GetPersonaFooter();
    if ( !rPersonaBitmap.IsEmpty() &&( pThis->GetAlign() == WINDOWALIGN_TOP|| pThis->GetAlign()==WINDOWALIGN_BOTTOM ) )
    {
        Wallpaper aWallpaper( rPersonaBitmap );
        aWallpaper.SetStyle( WALLPAPER_TOPRIGHT );
        aWallpaper.SetColor( Application::GetSettings().GetStyleSettings().GetWorkspaceColor() );
        if(pThis->GetAlign()==WINDOWALIGN_TOP )
            aWallpaper.SetStyle( WALLPAPER_TOPRIGHT );
        else
            aWallpaper.SetStyle( WALLPAPER_BOTTOMRIGHT );
        aWallpaper.SetColor( rSetting.GetWorkspaceColor() );

        // we need to shift the bitmap vertically so that it spans over the
        // menubar conveniently
@@ -155,6 +159,7 @@ void DockingAreaWindow::Paint( const Rectangle& )
    if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
    {
        ToolbarValue        aControlValue;
        const StyleSettings rSetting = Application::GetSettings().GetStyleSettings();

        if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
        {
@@ -162,9 +167,11 @@ void DockingAreaWindow::Paint( const Rectangle& )
            // useful for special gradient effects that should cover both windows
            aControlValue.mbIsTopDockingArea = true;
        }
        ControlState        nState = CTRL_STATE_ENABLED;

        if ( GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
        ControlState        nState = CTRL_STATE_ENABLED;
        const bool isFooter = GetAlign() == WINDOWALIGN_BOTTOM && !rSetting.GetPersonaFooter().IsEmpty();

        if (( GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter  )
            Erase();
        else if ( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
        {
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index c42f80f..b8ac59a 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -524,11 +524,12 @@ void ToolBox::ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect )
        bool bNativeOk = false;
        if( pThis->ImplIsFloatingMode() && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL) )
            bNativeOk = ImplDrawNativeBackground( pThis, aPaintRegion );

        const StyleSettings rSetting = Application::GetSettings().GetStyleSettings();
        if( !bNativeOk )
        {
            const bool isFooter = pThis->GetAlign() == WINDOWALIGN_BOTTOM && !rSetting.GetPersonaFooter().IsEmpty();
            if( !pThis->IsBackground() ||
                ( pThis->GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) )
                (( pThis->GetAlign() == WINDOWALIGN_TOP && ! rSetting.GetPersonaHeader().IsEmpty() ) || isFooter ) )
            {
                if( !pThis->IsInPaint() )
                    ImplDrawTransparentBackground( pThis, aPaintRegion );
@@ -1468,9 +1469,11 @@ void ToolBox::ImplInitSettings( bool bFont,
        else
        {
            if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) ||
                ( GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) )
                ( GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )||
                ( GetAlign() == WINDOWALIGN_BOTTOM && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty()) )
            {
                SetBackground();
                SetTextColor(rStyleSettings.GetMenuBarTextColor());
                SetPaintTransparent( true );
                SetParentClipMode( PARENTCLIPMODE_NOCLIP );
                mpData->maDisplayBackground = Wallpaper( rStyleSettings.GetFaceColor() );