tdf#50934: Initial plumbing and infrastructure

Change-Id: I355bdc8e6d67e7cdd47e4d6eccecedc4b53ac11b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155851
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/inc/bitmaps.hlst b/chart2/inc/bitmaps.hlst
index 5ef14f8..b73667d 100644
--- a/chart2/inc/bitmaps.hlst
+++ b/chart2/inc/bitmaps.hlst
@@ -26,6 +26,7 @@ inline constexpr OUString BMP_AREAS_2D_3 = u"chart2/res/areasfull_52x60.png"_ust
inline constexpr OUString BMP_AREAS_3D = u"chart2/res/areaspiled3d_52x60.png"_ustr;
inline constexpr OUString BMP_AREAS_3D_1 = u"chart2/res/areas3d_52x60.png"_ustr;
inline constexpr OUString BMP_AREAS_3D_2 = u"chart2/res/areasfull3d_52x60.png"_ustr;
inline constexpr OUString BMP_BAR_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO
inline constexpr OUString BMP_BARS_2D_1 = u"chart2/res/bar_52x60.png"_ustr;
inline constexpr OUString BMP_BARS_2D_2 = u"chart2/res/barstack_52x60.png"_ustr;
inline constexpr OUString BMP_BARS_2D_3 = u"chart2/res/barpercent_52x60.png"_ustr;
@@ -96,6 +97,7 @@ inline constexpr OUString BMP_NET_LINESYMB = u"chart2/res/netlinepoint_52x60.png
inline constexpr OUString BMP_NET_LINESYMB_STACK = u"chart2/res/netlinepointstack_52x60.png"_ustr;
inline constexpr OUString BMP_NET_FILL = u"chart2/res/netfill_52x60.png"_ustr;
inline constexpr OUString BMP_NET_FILL_STACK = u"chart2/res/netstackfill_52x60.png"_ustr;
inline constexpr OUString BMP_PIE_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO
inline constexpr OUString BMP_PYRAMIDQ_3D_1 = u"chart2/res/pyramindhori_52x60.png"_ustr;
inline constexpr OUString BMP_PYRAMIDQ_3D_2 = u"chart2/res/pyramindhoristack_52x60.png"_ustr;
inline constexpr OUString BMP_PYRAMIDQ_3D_3 = u"chart2/res/pyramindhoripercent_52x60.png"_ustr;
diff --git a/chart2/inc/strings.hrc b/chart2/inc/strings.hrc
index 8c22e85..8a6ec2f 100644
--- a/chart2/inc/strings.hrc
+++ b/chart2/inc/strings.hrc
@@ -161,6 +161,8 @@
#define STR_TYPE_AREA                               NC_("STR_TYPE_AREA", "Area")
#define STR_TYPE_PIE                                NC_("STR_TYPE_PIE", "Pie")
#define STR_PIE_EXPLODED                            NC_("STR_PIE_EXPLODED", "Exploded Pie Chart")
#define STR_BAR_OF_PIE                              NC_("STR_BAR_OF_PIE", "Bar-of-pie Chart")
#define STR_PIE_OF_PIE                              NC_("STR_PIE_OF_PIE", "Pie-of-pie Chart")
#define STR_DONUT_EXPLODED                          NC_("STR_DONUT_EXPLODED", "Exploded Donut Chart")
#define STR_DONUT                                   NC_("STR_DONUT", "Donut")
#define STR_TYPE_LINE                               NC_("STR_TYPE_LINE", "Line")
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index b52dbc2..2a597a2 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -567,6 +567,8 @@ const tTemplateServiceChartTypeParameterMap& PieChartDialogController::getTempla
    {"com.sun.star.chart2.template.PieAllExploded" ,         ChartTypeParameter(2,false,false)},
    {"com.sun.star.chart2.template.Donut" ,                  ChartTypeParameter(3,false,false)},
    {"com.sun.star.chart2.template.DonutAllExploded" ,       ChartTypeParameter(4,false,false)},
    {"com.sun.star.chart2.template.BarOfPie" ,               ChartTypeParameter(5,false,false)},
    {"com.sun.star.chart2.template.PieOfPie" ,               ChartTypeParameter(6,false,false)},
    {"com.sun.star.chart2.template.ThreeDPie" ,              ChartTypeParameter(1,false,true)},
    {"com.sun.star.chart2.template.ThreeDPieAllExploded" ,   ChartTypeParameter(2,false,true)},
    {"com.sun.star.chart2.template.ThreeDDonut" ,            ChartTypeParameter(3,false,true)},
@@ -590,11 +592,15 @@ void PieChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, const Ch
        rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_CIRCLES_2D_EXPLODED));
        rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_DONUT_2D));
        rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_DONUT_2D_EXPLODED));
        rSubTypeList.InsertItem(5, Image(StockImage::Yes, BMP_BAR_OF_PIE));
        rSubTypeList.InsertItem(6, Image(StockImage::Yes, BMP_PIE_OF_PIE));
    }
    rSubTypeList.SetItemText( 1, SchResId( STR_NORMAL         ) );
    rSubTypeList.SetItemText( 2, SchResId( STR_PIE_EXPLODED   ) );
    rSubTypeList.SetItemText( 3, SchResId( STR_DONUT          ) );
    rSubTypeList.SetItemText( 4, SchResId( STR_DONUT_EXPLODED ) );
    rSubTypeList.SetItemText( 5, SchResId( STR_BAR_OF_PIE ) );
    rSubTypeList.SetItemText( 6, SchResId( STR_PIE_OF_PIE ) );
}

bool PieChartDialogController::shouldShow_3DLookControl() const
diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx
index 267d06f4..84e8048 100644
--- a/chart2/source/inc/ChartType.hxx
+++ b/chart2/source/inc/ChartType.hxx
@@ -41,7 +41,8 @@ class ModifyEventForwarder;
enum
{
    PROP_PIECHARTTYPE_USE_RINGS,
    PROP_PIECHARTTYPE_3DRELATIVEHEIGHT
    PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
    PROP_PIECHARTTYPE_SUBTYPE // none, of-bar, of-pie
};


diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx
index bc6c2fb..accf2078 100644
--- a/chart2/source/model/template/ChartTypeManager.cxx
+++ b/chart2/source/model/template/ChartTypeManager.cxx
@@ -89,6 +89,8 @@ enum TemplateId
    TEMPLATE_PIEALLEXPLODED,
    TEMPLATE_DONUT,
    TEMPLATE_DONUTALLEXPLODED,
    TEMPLATE_BAROFPIE,
    TEMPLATE_PIEOFPIE,
    TEMPLATE_THREEDPIE,
    TEMPLATE_THREEDPIEALLEXPLODED,
    TEMPLATE_THREEDDONUT,
@@ -163,6 +165,9 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
        {"com.sun.star.chart2.template.PieAllExploded",                 TEMPLATE_PIEALLEXPLODED},
        {"com.sun.star.chart2.template.Donut",                          TEMPLATE_DONUT},
        {"com.sun.star.chart2.template.DonutAllExploded",               TEMPLATE_DONUTALLEXPLODED},
        {"com.sun.star.chart2.template.BarOfPie",                       TEMPLATE_BAROFPIE},
        {"com.sun.star.chart2.template.PieOfPie",                       TEMPLATE_PIEOFPIE},
        {"com.sun.star.chart2.template.DonutAllExploded",               TEMPLATE_DONUTALLEXPLODED},
        {"com.sun.star.chart2.template.ThreeDPie",                      TEMPLATE_THREEDPIE},
        {"com.sun.star.chart2.template.ThreeDPieAllExploded",           TEMPLATE_THREEDPIEALLEXPLODED},
        {"com.sun.star.chart2.template.ThreeDDonut",                    TEMPLATE_THREEDDONUT},
@@ -382,35 +387,49 @@ rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate(

        case TEMPLATE_PIE:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_NONE, false ));
                chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_NONE ));
            break;
        case TEMPLATE_PIEALLEXPLODED:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
                chart2::PieChartOffsetMode_ALL_EXPLODED, false,
                chart2::PieChartSubType_NONE ));
            break;
        case TEMPLATE_DONUT:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_NONE, true ));
                chart2::PieChartOffsetMode_NONE, true, chart2::PieChartSubType_NONE ));
            break;
        case TEMPLATE_DONUTALLEXPLODED:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
                chart2::PieChartOffsetMode_ALL_EXPLODED, true,
                chart2::PieChartSubType_NONE ));
            break;
        case TEMPLATE_BAROFPIE:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, true,
                chart2::PieChartSubType_BAR ));
            break;
        case TEMPLATE_PIEOFPIE:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, true,
                chart2::PieChartSubType_PIE ));
            break;
        case TEMPLATE_THREEDPIE:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_NONE, false, 3 ));
                chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_NONE, 3 ));
            break;
        case TEMPLATE_THREEDPIEALLEXPLODED:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, false, 3 ));
                chart2::PieChartOffsetMode_ALL_EXPLODED, false,
                chart2::PieChartSubType_NONE, 3 ));
            break;
        case TEMPLATE_THREEDDONUT:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_NONE, true, 3 ));
                chart2::PieChartOffsetMode_NONE, true, chart2::PieChartSubType_NONE, 3 ));
            break;
        case TEMPLATE_THREEDDONUTALLEXPLODED:
            xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
                chart2::PieChartOffsetMode_ALL_EXPLODED, true, 3 ));
                chart2::PieChartOffsetMode_ALL_EXPLODED, true,
                chart2::PieChartSubType_NONE, 3 ));
            break;

        case TEMPLATE_SCATTERLINESYMBOL:
diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx
index dc45c24..a835f635 100644
--- a/chart2/source/model/template/PieChartType.cxx
+++ b/chart2/source/model/template/PieChartType.cxx
@@ -27,6 +27,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/PieChartSubType.hpp>

using namespace ::com::sun::star;

@@ -45,6 +46,7 @@ namespace
            ::chart::tPropertyValueMap aOutMap;
            ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_USE_RINGS, false );
            ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT, 100 );
            ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_SUBTYPE, chart2::PieChartSubType_NONE );
            return aOutMap;
        }();
    return aStaticDefaults;
@@ -64,7 +66,11 @@ namespace
                { "3DRelativeHeight",
                  ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
                  cppu::UnoType<sal_Int32>::get(),
                  beans::PropertyAttribute::MAYBEVOID }
                  beans::PropertyAttribute::MAYBEVOID },
                { "SubPieType",
                  ::chart::PROP_PIECHARTTYPE_SUBTYPE,
                  cppu::UnoType<chart2::PieChartSubType>::get(),
                  beans::PropertyAttribute::MAYBEDEFAULT }
            };
            std::sort( aProperties.begin(), aProperties.end(),
                         ::chart::PropertyNameLess() );
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 07e150b..2f8c7fb 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -56,7 +56,8 @@ enum
    PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
    PROP_PIE_TEMPLATE_OFFSET_MODE,
    PROP_PIE_TEMPLATE_DIMENSION,
    PROP_PIE_TEMPLATE_USE_RINGS
    PROP_PIE_TEMPLATE_USE_RINGS,
    PROP_PIE_TEMPLATE_SUB_PIE_TYPE
};

::chart::tPropertyValueMap& StaticPieChartTypeTemplateDefaults()
@@ -68,6 +69,7 @@ enum
            ::chart::PropertyHelper::setPropertyValueDefault< double >( aOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 );
            ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
            ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false );
            ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_SUB_PIE_TYPE, chart2::PieChartSubType_NONE );
            return aOutMap;
        }();
    return aStaticDefaults;
@@ -98,7 +100,14 @@ enum
                  PROP_PIE_TEMPLATE_USE_RINGS,
                  cppu::UnoType<bool>::get(),
                  beans::PropertyAttribute::BOUND
                  | beans::PropertyAttribute::MAYBEDEFAULT } };
                  | beans::PropertyAttribute::MAYBEDEFAULT }
                ,
                { "SubPieType",
                  PROP_PIE_TEMPLATE_SUB_PIE_TYPE,
                  cppu::UnoType<chart2::PieChartSubType>::get(),
                  beans::PropertyAttribute::BOUND
                  | beans::PropertyAttribute::MAYBEDEFAULT }
            };

            std::sort( aProperties.begin(), aProperties.end(),
                         ::chart::PropertyNameLess() );
@@ -125,13 +134,15 @@ PieChartTypeTemplate::PieChartTypeTemplate(
        uno::XComponentContext > const & xContext,
    const OUString & rServiceName,
    chart2::PieChartOffsetMode eMode,
    bool bRings            /* = false */,
    bool bRings,
    chart2::PieChartSubType eSubType,
    sal_Int32 nDim         /* = 2 */    ) :
        ChartTypeTemplate( xContext, rServiceName )
{
    setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_OFFSET_MODE,    uno::Any( eMode ));
    setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION,      uno::Any( nDim ));
    setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS,      uno::Any( bRings ));
    setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SUB_PIE_TYPE,   uno::Any( eSubType ));
}

PieChartTypeTemplate::~PieChartTypeTemplate()
@@ -283,6 +294,10 @@ bool PieChartTypeTemplate::matchesTemplate2(
    getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
    chart2::PieChartOffsetMode ePieOffsetMode;
    getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
    /*
    chart2::PieChartSubType ePieSubType;
    getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ) >>= ePieSubType;
    */

    //check offset-mode
    if( bResult )
@@ -370,6 +385,8 @@ rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_Int3
        xResult = new PieChartType();
        xResult->setFastPropertyValue(
            PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
        xResult->setFastPropertyValue(
            PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
    }
    catch( const uno::Exception & )
    {
@@ -390,6 +407,8 @@ rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForNewSeries2(
        ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
        xResult->setFastPropertyValue(
            PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
        xResult->setFastPropertyValue(
            PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
    }
    catch( const uno::Exception & )
    {
diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx
index a92cfbf..b603392 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.hxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.hxx
@@ -23,6 +23,7 @@

#include <ChartTypeTemplate.hxx>
#include <com/sun/star/chart2/PieChartOffsetMode.hpp>
#include <com/sun/star/chart2/PieChartSubType.hpp>

namespace chart
{
@@ -37,6 +38,7 @@ public:
        const OUString & rServiceName,
        css::chart2::PieChartOffsetMode eMode,
        bool bRings,
        css::chart2::PieChartSubType eSubType,
        sal_Int32 nDim = 2 );
    virtual ~PieChartTypeTemplate() override;

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 5399c70..ce31dcb 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2014,6 +2014,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2,\
	LegendPosition \
	LightSource \
	PieChartOffsetMode \
	PieChartSubType \
	RelativePosition \
	RelativeSize \
	ScaleData \
diff --git a/offapi/com/sun/star/chart2/PieChartSubType.idl b/offapi/com/sun/star/chart2/PieChartSubType.idl
new file mode 100644
index 0000000..9e5af14
--- /dev/null
+++ b/offapi/com/sun/star/chart2/PieChartSubType.idl
@@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 .
 */

module com
{
module sun
{
module star
{
module chart2
{

/** Mode used for a pie chart template to determine the initial state
    of exploded pies.
 */
enum PieChartSubType
{
    /** Default: pie chart only
     */
    NONE,

    /** Bar subchart
     */
    BAR,

    /** Pie subchart
     */
    PIE
};

} ; // chart2
} ; // com
} ; // sun
} ; // star


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