chart2/source/controller/sidebar/Chart2PanelFactory.cxx |   10 
 chart2/source/controller/sidebar/ChartTypePanel.cxx     |  309 +++++-----------
 chart2/source/controller/sidebar/ChartTypePanel.hxx     |   43 +-
 chart2/uiconfig/ui/sidebartype.ui                       |  203 ++++++----
 4 files changed, 277 insertions(+), 288 deletions(-)

New commits:
commit a9cc0100645deea53f27e35c7e754c9f062680d8
Author:     Muhammet Kara <muhammet.k...@collabora.com>
AuthorDate: Fri Nov 15 11:13:03 2019 +0300
Commit:     Muhammet Kara <muhammet.k...@collabora.com>
CommitDate: Fri Nov 15 16:28:50 2019 +0100

    chart2: Weld ChartTypePanel
    
    Change-Id: I8ed178ffe0d880b362f98b9754bce40b20942bd7
    Reviewed-on: https://gerrit.libreoffice.org/82768
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.k...@collabora.com>

diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx 
b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index 33e5c75d7f82..a4235233f1bb 100644
--- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
+++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
@@ -86,7 +86,15 @@ Reference<css::ui::XUIElement> SAL_CALL 
ChartPanelFactory::createUIElement (
         if (rsResourceURL.endsWith("/ElementsPanel"))
             pPanel = ChartElementsPanel::Create( pParentWindow, xFrame, 
pController );
         else if (rsResourceURL.endsWith("/TypePanel"))
-            pPanel = ChartTypePanel::Create( pParentWindow, xFrame, 
pController );
+        {
+            //pPanel = ChartTypePanel::Create( pParentWindow, xFrame, 
pController );
+            VclPtrInstance<ChartTypePanel> ppPanel(pParentWindow, xFrame, 
pController);
+            xElement = sfx2::sidebar::SidebarPanelBase::Create(
+                rsResourceURL,
+                xFrame,
+                ppPanel,
+                css::ui::LayoutSize(-1,-1,-1));
+        }
         else if (rsResourceURL.endsWith("/SeriesPanel"))
             pPanel = ChartSeriesPanel::Create(pParentWindow, xFrame, 
pController);
         else if (rsResourceURL.endsWith("/AxisPanel"))
diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx 
b/chart2/source/controller/sidebar/ChartTypePanel.cxx
index 9539095e26c5..1774d6a9961b 100644
--- a/chart2/source/controller/sidebar/ChartTypePanel.cxx
+++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx
@@ -23,6 +23,7 @@
 #include <ChartController.hxx>
 #include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
+#include <ChartResourceGroups.hxx>
 #include <ChartTypeDialogController.hxx>
 #include <ChartTypeHelper.hxx>
 #include <DiagramHelper.hxx>
@@ -37,6 +38,7 @@
 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
 
 #include <vcl/field.hxx>
 #include <vcl/fixed.hxx>
@@ -51,147 +53,43 @@
 #include <svtools/valueset.hxx>
 #include <tools/diagnose_ex.h>
 
-//Borrowed from vcl/inc/bitmaps.hlst
-#define IMG_ERROR "dbaccess/res/exerror.png"
-#define IMG_INFO "dbaccess/res/exinfo.png"
-#define IMG_WARN "dbaccess/res/exwarning.png"
-
 using namespace css;
 using namespace css::uno;
 
 namespace chart
 {
-enum
-{
-    POS_3DSCHEME_SIMPLE = 0,
-    POS_3DSCHEME_REALISTIC = 1
-};
-
-class Dim3DLookResourceGroup_unwelded : public ChangingResource
-{
-public:
-    explicit Dim3DLookResourceGroup_unwelded(VclBuilderContainer* pWindow);
-
-    void showControls(bool bShow);
-
-    void fillControls(const ChartTypeParameter& rParameter);
-    void fillParameter(ChartTypeParameter& rParameter);
-
-private:
-    DECL_LINK(Dim3DLookCheckHdl, CheckBox&, void);
-    DECL_LINK(SelectSchemeHdl, ListBox&, void);
-
-private:
-    VclPtr<CheckBox> m_pCB_3DLook;
-    VclPtr<ListBox> m_pLB_Scheme;
-};
-
-Dim3DLookResourceGroup_unwelded::Dim3DLookResourceGroup_unwelded(VclBuilderContainer*
 pWindow)
-    : ChangingResource()
-{
-    pWindow->get(m_pCB_3DLook, "3dlook");
-    pWindow->get(m_pLB_Scheme, "3dscheme");
-
-    m_pCB_3DLook->SetToggleHdl(LINK(this, Dim3DLookResourceGroup_unwelded, 
Dim3DLookCheckHdl));
-    m_pLB_Scheme->SetSelectHdl(LINK(this, Dim3DLookResourceGroup_unwelded, 
SelectSchemeHdl));
-}
-
-void Dim3DLookResourceGroup_unwelded::showControls(bool bShow)
-{
-    m_pCB_3DLook->Show(bShow);
-    m_pLB_Scheme->Show(bShow);
-}
-
-void Dim3DLookResourceGroup_unwelded::fillControls(const ChartTypeParameter& 
rParameter)
-{
-    m_pCB_3DLook->Check(rParameter.b3DLook);
-    m_pLB_Scheme->Enable(rParameter.b3DLook);
-
-    if (rParameter.eThreeDLookScheme == ThreeDLookScheme_Simple)
-        m_pLB_Scheme->SelectEntryPos(POS_3DSCHEME_SIMPLE);
-    else if (rParameter.eThreeDLookScheme == ThreeDLookScheme_Realistic)
-        m_pLB_Scheme->SelectEntryPos(POS_3DSCHEME_REALISTIC);
-    else
-        m_pLB_Scheme->SetNoSelection();
-}
-
-void Dim3DLookResourceGroup_unwelded::fillParameter(ChartTypeParameter& 
rParameter)
-{
-    rParameter.b3DLook = m_pCB_3DLook->IsChecked();
-    const sal_Int32 nPos = m_pLB_Scheme->GetSelectedEntryPos();
-    if (nPos == POS_3DSCHEME_SIMPLE)
-        rParameter.eThreeDLookScheme = ThreeDLookScheme_Simple;
-    else if (nPos == POS_3DSCHEME_REALISTIC)
-        rParameter.eThreeDLookScheme = ThreeDLookScheme_Realistic;
-    else
-        rParameter.eThreeDLookScheme = ThreeDLookScheme_Unknown;
-}
-
-IMPL_LINK_NOARG(Dim3DLookResourceGroup_unwelded, Dim3DLookCheckHdl, CheckBox&, 
void)
-{
-    if (m_pChangeListener)
-        m_pChangeListener->stateChanged();
-}
-
-IMPL_LINK_NOARG(Dim3DLookResourceGroup_unwelded, SelectSchemeHdl, ListBox&, 
void)
-{
-    if (m_pChangeListener)
-        m_pChangeListener->stateChanged();
-}
-
 namespace sidebar
 {
-namespace
-{
-Image createImage(const OUString& rImage)
-{
-    if (rImage.lastIndexOf('.') != rImage.getLength() - 4)
-    {
-        assert((rImage == "dialog-warning" || rImage == "dialog-error"
-                || rImage == "dialog-information")
-               && "unknown stock image");
-        if (rImage == "dialog-warning")
-            return Image(BitmapEx(IMG_WARN));
-        else if (rImage == "dialog-error")
-            return Image(BitmapEx(IMG_ERROR));
-        else if (rImage == "dialog-information")
-            return Image(BitmapEx(IMG_INFO));
-    }
-    return Image(BitmapEx(rImage));
-}
-} //end of anonymous namespace
-
 ChartTypePanel::ChartTypePanel(vcl::Window* pParent,
                                const css::uno::Reference<css::frame::XFrame>& 
rxFrame,
                                ::chart::ChartController* pController)
-    : PanelLayout(pParent, "ChartTypePanel", 
"modules/schart/ui/sidebartype.ui", rxFrame)
+    : PanelLayout(pParent, "ChartTypePanel", 
"modules/schart/ui/sidebartype.ui", rxFrame, true)
     , maContext()
     , mxModel(pController->getModel())
     , mxListener(new ChartSidebarModifyListener(this))
     , mbModelValid(true)
-    , m_pDim3DLookResourceGroup(new Dim3DLookResourceGroup_unwelded(this))
+    , m_pDim3DLookResourceGroup(new Dim3DLookResourceGroup(m_xBuilder.get()))
     , m_xChartModel(mxModel, css::uno::UNO_QUERY_THROW)
     , m_aChartTypeDialogControllerList(0)
     , m_pCurrentMainType(nullptr)
     , m_nChangingCalls(0)
     , m_aTimerTriggeredControllerLock(m_xChartModel)
+    , m_xChartTypeLabel(m_xBuilder->weld_label("lbl_chartType"))
+    , m_xMainTypeList(m_xBuilder->weld_combo_box("cmb_chartType"))
+    , m_xSubTypeList(new 
SvtValueSet(m_xBuilder->weld_scrolled_window("subtypewin")))
+    , m_xSubTypeListWin(new weld::CustomWeld(*m_xBuilder, "subtype", 
*m_xSubTypeList))
 {
-    get(mpChartTypeLabel, "lbl_chartType");
-    get(m_pMainTypeList, "cmb_chartType");
-    get(m_pSubTypeList, "subtype");
-
-    //Chart Type related
-    /*m_pMainTypeList->SetSelectHdl(LINK(this, ChartTypePanel, 
SelectMainTypeHdl));
-    m_pSubTypeList->SetSelectHdl(LINK(this, ChartTypePanel, 
SelectSubTypeHdl));*/
+    Size aSize(m_xSubTypeList->GetDrawingArea()->get_ref_device().LogicToPixel(
+        Size(120, 40), MapMode(MapUnit::MapAppFont)));
+    m_xSubTypeListWin->set_size_request(aSize.Width(), aSize.Height());
 
-    Size aSize(m_pSubTypeList->LogicToPixel(Size(120, 40), 
MapMode(MapUnit::MapAppFont)));
-    m_pSubTypeList->set_width_request(aSize.Width());
-    m_pSubTypeList->set_height_request(aSize.Height());
+    m_xMainTypeList->connect_changed(LINK(this, ChartTypePanel, 
SelectMainTypeHdl));
+    m_xSubTypeList->SetSelectHdl(LINK(this, ChartTypePanel, SelectSubTypeHdl));
 
-    m_pSubTypeList->SetStyle(m_pSubTypeList->GetStyle() | WB_ITEMBORDER | 
WB_DOUBLEBORDER
+    m_xSubTypeList->SetStyle(m_xSubTypeList->GetStyle() | WB_ITEMBORDER | 
WB_DOUBLEBORDER
                              | WB_NAMEFIELD | WB_FLATVALUESET | WB_3DLOOK);
-    m_pSubTypeList->SetColCount(4);
-    m_pSubTypeList->SetLineCount(1);
+    m_xSubTypeList->SetColCount(4);
+    m_xSubTypeList->SetLineCount(1);
 
     bool bEnableComplexChartTypes = true;
     uno::Reference<beans::XPropertySet> xProps(m_xChartModel, uno::UNO_QUERY);
@@ -212,7 +110,6 @@ ChartTypePanel::ChartTypePanel(vcl::Window* pParent,
     
m_aChartTypeDialogControllerList.push_back(std::make_unique<PieChartDialogController>());
     
m_aChartTypeDialogControllerList.push_back(std::make_unique<AreaChartDialogController>());
     
m_aChartTypeDialogControllerList.push_back(std::make_unique<LineChartDialogController>());
-
     if (bEnableComplexChartTypes)
     {
         
m_aChartTypeDialogControllerList.push_back(std::make_unique<XYChartDialogController>());
@@ -228,7 +125,7 @@ ChartTypePanel::ChartTypePanel(vcl::Window* pParent,
 
     for (auto const& elem : m_aChartTypeDialogControllerList)
     {
-        m_pMainTypeList->InsertEntry(elem->getName(), 
createImage(elem->getImage()));
+        m_xMainTypeList->append("", elem->getName(), elem->getImage());
         elem->setChangeListener(this);
     }
 
@@ -245,31 +142,36 @@ void ChartTypePanel::dispose()
                                                                     
css::uno::UNO_QUERY_THROW);
     xBroadcaster->removeModifyListener(mxListener);
 
-    mpChartTypeLabel.clear();
+    /*mpChartTypeLabel.clear();
     m_pMainTypeList.clear();
-    m_pSubTypeList.clear();
+    m_pSubTypeList.clear();*/
 
     //delete all resource helpers
+    //m_pDim3DLookResourceGroup.reset();
+
+    //delete all dialog controller
+    m_aChartTypeDialogControllerList.clear();
+
+    //delete all resource helper
     m_pDim3DLookResourceGroup.reset();
+    m_xSubTypeListWin.reset();
+    m_xSubTypeList.reset();
 
     PanelLayout::dispose();
 }
 
-/*IMPL_LINK_NOARG(ChartTypePanel, SelectMainTypeHdl, ListBox&, void)
-{
-    //selectMainType();
-}
+IMPL_LINK_NOARG(ChartTypePanel, SelectMainTypeHdl, weld::ComboBox&, void) { 
selectMainType(); }
 
-IMPL_LINK_NOARG(ChartTypePanel, SelectSubTypeHdl, ValueSet*, void)
+IMPL_LINK_NOARG(ChartTypePanel, SelectSubTypeHdl, SvtValueSet*, void)
 {
-    if( m_pCurrentMainType )
+    if (m_pCurrentMainType)
     {
-        ChartTypeParameter aParameter( getCurrentParamter() );
-        m_pCurrentMainType->adjustParameterToSubType( aParameter );
-        fillAllControls( aParameter, false );
-        commitToModel( aParameter );
+        ChartTypeParameter aParameter(getCurrentParamter());
+        m_pCurrentMainType->adjustParameterToSubType(aParameter);
+        fillAllControls(aParameter, false);
+        commitToModel(aParameter);
     }
-}*/
+}
 
 void ChartTypePanel::Initialize()
 {
@@ -277,8 +179,7 @@ void ChartTypePanel::Initialize()
         return;
     uno::Reference<lang::XMultiServiceFactory> xTemplateManager(
         m_xChartModel->getChartTypeManager(), uno::UNO_QUERY);
-    uno::Reference<frame::XModel> xModel(m_xChartModel);
-    uno::Reference<css::chart2::XDiagram> 
xDiagram(ChartModelHelper::findDiagram(xModel));
+    uno::Reference<css::chart2::XDiagram> 
xDiagram(ChartModelHelper::findDiagram(m_xChartModel));
     DiagramHelper::tTemplateWithServiceName aTemplate
         = DiagramHelper::getTemplateForDiagram(xDiagram, xTemplateManager);
     OUString aServiceName(aTemplate.second);
@@ -292,7 +193,7 @@ void ChartTypePanel::Initialize()
         {
             bFound = true;
 
-            m_pMainTypeList->SelectEntryPos(nM);
+            m_xMainTypeList->set_active(nM);
             showAllControls(*elem);
             uno::Reference<beans::XPropertySet> 
xTemplateProps(aTemplate.first, uno::UNO_QUERY);
             ChartTypeParameter aParameter
@@ -325,12 +226,12 @@ void ChartTypePanel::Initialize()
 
     if (!bFound)
     {
-        m_pSubTypeList->Hide();
+        m_xSubTypeList->Hide();
         m_pDim3DLookResourceGroup->showControls(false);
         /*m_pStackingResourceGroup->showControls( false, false );
-            m_pSplineResourceGroup->showControls( false );
-            m_pGeometryResourceGroup->showControls( false );
-            m_pSortByXValuesResourceGroup->showControls( false );*/
+        m_pSplineResourceGroup->showControls( false );
+        m_pGeometryResourceGroup->showControls( false );
+        m_pSortByXValuesResourceGroup->showControls( false );*/
     }
 }
 
@@ -352,7 +253,8 @@ void ChartTypePanel::updateData()
     {
         if (elem->isSubType(aServiceName))
         {
-            m_pMainTypeList->SelectEntryPos(nM);
+            //m_pMainTypeList->SelectEntryPos(nM);
+            //m_pMainTypeList->select_entry_region(nM, nM);
             break;
         }
         ++nM;
@@ -405,11 +307,24 @@ void 
ChartTypePanel::updateModel(css::uno::Reference<css::frame::XModel> xModel)
     xBroadcasterNew->addModifyListener(mxListener);
 }
 
+uno::Reference<css::chart2::XChartTypeTemplate> 
ChartTypePanel::getCurrentTemplate() const
+{
+    if (m_pCurrentMainType && m_xChartModel.is())
+    {
+        ChartTypeParameter aParameter(getCurrentParamter());
+        m_pCurrentMainType->adjustParameterToSubType(aParameter);
+        uno::Reference<lang::XMultiServiceFactory> xTemplateManager(
+            m_xChartModel->getChartTypeManager(), uno::UNO_QUERY);
+        return m_pCurrentMainType->getCurrentTemplate(aParameter, 
xTemplateManager);
+    }
+    return nullptr;
+}
+
 ChartTypeDialogController* ChartTypePanel::getSelectedMainType()
 {
     ChartTypeDialogController* pTypeController = nullptr;
     auto nM = static_cast<std::vector<ChartTypeDialogController*>::size_type>(
-        m_pMainTypeList->GetSelectedEntryPos());
+        m_xMainTypeList->get_active());
     if (nM < m_aChartTypeDialogControllerList.size())
         pTypeController = m_aChartTypeDialogControllerList[nM].get();
     return pTypeController;
@@ -417,20 +332,20 @@ ChartTypeDialogController* 
ChartTypePanel::getSelectedMainType()
 
 void ChartTypePanel::showAllControls(ChartTypeDialogController& 
rTypeController)
 {
-    m_pMainTypeList->Show();
-    m_pSubTypeList->Show();
+    m_xMainTypeList->show();
+    m_xSubTypeList->Show();
 
     bool bShow = rTypeController.shouldShow_3DLookControl();
     m_pDim3DLookResourceGroup->showControls(bShow);
     /*bShow = rTypeController.shouldShow_StackingControl();
-    m_pStackingResourceGroup->showControls( bShow, 
rTypeController.shouldShow_DeepStackingControl() );
+    m_pStackingResourceGroup->showControls( bShow, false );
     bShow = rTypeController.shouldShow_SplineControl();
     m_pSplineResourceGroup->showControls( bShow );
     bShow = rTypeController.shouldShow_GeometryControl();
     m_pGeometryResourceGroup->showControls( bShow );
     bShow = rTypeController.shouldShow_SortByXValuesResourceGroup();
-    m_pSortByXValuesResourceGroup->showControls( bShow );
-    rTypeController.showExtraControls(this);*/
+    m_pSortByXValuesResourceGroup->showControls( bShow );*/
+    rTypeController.showExtraControls(m_xBuilder.get());
 }
 
 void ChartTypePanel::fillAllControls(const ChartTypeParameter& rParameter,
@@ -439,54 +354,9 @@ void ChartTypePanel::fillAllControls(const 
ChartTypeParameter& rParameter,
     m_nChangingCalls++;
     if (m_pCurrentMainType && bAlsoResetSubTypeList)
     {
-        // FIXME: This is just to test. This if-block should just call 
m_pCurrentMainType->fillSubTypeList(*m_pSubTypeList, rParameter);
-        // after adding a new method to ColumnChartDialogController and its 
children
-        //m_pCurrentMainType->fillSubTypeList(*m_pSubTypeList, rParameter);
-        m_pSubTypeList->Clear();
-
-        if (rParameter.b3DLook)
-        {
-            switch (rParameter.nGeometry3D)
-            {
-                case css::chart2::DataPointGeometry3D::CYLINDER:
-                    m_pSubTypeList->InsertItem(1, Image(StockImage::Yes, 
BMP_SAEULE_3D_1));
-                    m_pSubTypeList->InsertItem(2, Image(StockImage::Yes, 
BMP_SAEULE_3D_2));
-                    m_pSubTypeList->InsertItem(3, Image(StockImage::Yes, 
BMP_SAEULE_3D_3));
-                    m_pSubTypeList->InsertItem(4, Image(StockImage::Yes, 
BMP_SAEULE_3D_4));
-                    break;
-                case css::chart2::DataPointGeometry3D::CONE:
-                    m_pSubTypeList->InsertItem(1, Image(StockImage::Yes, 
BMP_KEGEL_3D_1));
-                    m_pSubTypeList->InsertItem(2, Image(StockImage::Yes, 
BMP_KEGEL_3D_2));
-                    m_pSubTypeList->InsertItem(3, Image(StockImage::Yes, 
BMP_KEGEL_3D_3));
-                    m_pSubTypeList->InsertItem(4, Image(StockImage::Yes, 
BMP_KEGEL_3D_4));
-                    break;
-                case css::chart2::DataPointGeometry3D::PYRAMID:
-                    m_pSubTypeList->InsertItem(1, Image(StockImage::Yes, 
BMP_PYRAMID_3D_1));
-                    m_pSubTypeList->InsertItem(2, Image(StockImage::Yes, 
BMP_PYRAMID_3D_2));
-                    m_pSubTypeList->InsertItem(3, Image(StockImage::Yes, 
BMP_PYRAMID_3D_3));
-                    m_pSubTypeList->InsertItem(4, Image(StockImage::Yes, 
BMP_PYRAMID_3D_4));
-                    break;
-                default: //DataPointGeometry3D::CUBOID:
-                    m_pSubTypeList->InsertItem(1, Image(StockImage::Yes, 
BMP_COLUMNS_3D_1));
-                    m_pSubTypeList->InsertItem(2, Image(StockImage::Yes, 
BMP_COLUMNS_3D_2));
-                    m_pSubTypeList->InsertItem(3, Image(StockImage::Yes, 
BMP_COLUMNS_3D_3));
-                    m_pSubTypeList->InsertItem(4, Image(StockImage::Yes, 
BMP_COLUMNS_3D));
-                    break;
-            }
-        }
-        else
-        {
-            m_pSubTypeList->InsertItem(1, Image(StockImage::Yes, 
BMP_COLUMNS_2D_1));
-            m_pSubTypeList->InsertItem(2, Image(StockImage::Yes, 
BMP_COLUMNS_2D_2));
-            m_pSubTypeList->InsertItem(3, Image(StockImage::Yes, 
BMP_COLUMNS_2D_3));
-        }
-
-        m_pSubTypeList->SetItemText(1, SchResId(STR_NORMAL));
-        m_pSubTypeList->SetItemText(2, SchResId(STR_STACKED));
-        m_pSubTypeList->SetItemText(3, SchResId(STR_PERCENT));
-        m_pSubTypeList->SetItemText(4, SchResId(STR_DEEP));
+        m_pCurrentMainType->fillSubTypeList(*m_xSubTypeList, rParameter);
     }
-    
m_pSubTypeList->SelectItem(static_cast<sal_uInt16>(rParameter.nSubTypeIndex));
+    
m_xSubTypeList->SelectItem(static_cast<sal_uInt16>(rParameter.nSubTypeIndex));
     m_pDim3DLookResourceGroup->fillControls(rParameter);
     /*m_pStackingResourceGroup->fillControls( rParameter );
     m_pSplineResourceGroup->fillControls( rParameter );
@@ -498,12 +368,12 @@ void ChartTypePanel::fillAllControls(const 
ChartTypeParameter& rParameter,
 ChartTypeParameter ChartTypePanel::getCurrentParamter() const
 {
     ChartTypeParameter aParameter;
-    aParameter.nSubTypeIndex = 
static_cast<sal_Int32>(m_pSubTypeList->GetSelectedItemId());
+    aParameter.nSubTypeIndex = 
static_cast<sal_Int32>(m_xSubTypeList->GetSelectedItemId());
     m_pDim3DLookResourceGroup->fillParameter(aParameter);
-    //m_pStackingResourceGroup->fillParameter( aParameter );
-    //m_pSplineResourceGroup->fillParameter( aParameter );
-    //m_pGeometryResourceGroup->fillParameter( aParameter );
-    //m_pSortByXValuesResourceGroup->fillParameter( aParameter );
+    /*m_pStackingResourceGroup->fillParameter( aParameter );
+    m_pSplineResourceGroup->fillParameter( aParameter );
+    m_pGeometryResourceGroup->fillParameter( aParameter );
+    m_pSortByXValuesResourceGroup->fillParameter( aParameter );*/
     return aParameter;
 }
 
@@ -547,6 +417,47 @@ void ChartTypePanel::commitToModel(const 
ChartTypeParameter& rParameter)
     m_aTimerTriggeredControllerLock.startTimer();
     m_pCurrentMainType->commitToModel(rParameter, m_xChartModel);
 }
+
+void ChartTypePanel::selectMainType()
+{
+    ChartTypeParameter aParameter(getCurrentParamter());
+
+    if (m_pCurrentMainType)
+    {
+        m_pCurrentMainType->adjustParameterToSubType(aParameter);
+        m_pCurrentMainType->hideExtraControls();
+    }
+
+    m_pCurrentMainType = getSelectedMainType();
+    if (m_pCurrentMainType)
+    {
+        showAllControls(*m_pCurrentMainType);
+
+        m_pCurrentMainType->adjustParameterToMainType(aParameter);
+        commitToModel(aParameter);
+        //detect the new ThreeDLookScheme
+        aParameter.eThreeDLookScheme
+            = 
ThreeDHelper::detectScheme(ChartModelHelper::findDiagram(m_xChartModel));
+        if (!aParameter.b3DLook && aParameter.eThreeDLookScheme != 
ThreeDLookScheme_Realistic)
+            aParameter.eThreeDLookScheme = ThreeDLookScheme_Realistic;
+
+        uno::Reference<css::chart2::XDiagram> xDiagram
+            = ChartModelHelper::findDiagram(m_xChartModel);
+        try
+        {
+            uno::Reference<beans::XPropertySet> xPropSet(xDiagram, 
uno::UNO_QUERY_THROW);
+            xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= 
aParameter.bSortByXValues;
+        }
+        catch (const uno::Exception&)
+        {
+            DBG_UNHANDLED_EXCEPTION("chart2");
+        }
+
+        fillAllControls(aParameter);
+        uno::Reference<beans::XPropertySet> 
xTemplateProps(getCurrentTemplate(), uno::UNO_QUERY);
+        m_pCurrentMainType->fillExtraControls(m_xChartModel, xTemplateProps);
+    }
+}
 }
 } // end of namespace ::chart::sidebar
 
diff --git a/chart2/source/controller/sidebar/ChartTypePanel.hxx 
b/chart2/source/controller/sidebar/ChartTypePanel.hxx
index ad6f20c61988..3e131f11eba4 100644
--- a/chart2/source/controller/sidebar/ChartTypePanel.hxx
+++ b/chart2/source/controller/sidebar/ChartTypePanel.hxx
@@ -25,6 +25,7 @@
 //#include <vcl/layout.hxx>
 #include "ChartSidebarModifyListener.hxx"
 #include <ChartTypeDialogController.hxx>
+#include <ChartTypeTemplateProvider.hxx>
 #include <TimerTriggeredControllerLock.hxx>
 #include <TitleHelper.hxx>
 
@@ -42,18 +43,23 @@ class XModifyListener;
 }
 }
 
+namespace weld
+{
+class CustomWeld;
+}
+
 class ListBox;
 class ValueSet;
 
 namespace chart
 {
 class ChartController;
-class Dim3DLookResourceGroup_unwelded;
-class StackingResourceGroup_unwelded;
-class SplineResourceGroup_unwelded;
-class GeometryResourceGroup_unwelded;
-class ChartTypeParameter_unwelded;
-class SortByXValuesResourceGroup_unwelded;
+class Dim3DLookResourceGroup;
+class StackingResourceGroup;
+class SplineResourceGroup;
+class GeometryResourceGroup;
+class ChartTypeParameter;
+class SortByXValuesResourceGroup;
 
 namespace sidebar
 {
@@ -61,7 +67,8 @@ class ChartTypePanel : public ResourceChangeListener,
                        public PanelLayout,
                        public ::sfx2::sidebar::IContextChangeReceiver,
                        public sfx2::sidebar::SidebarModelUpdate,
-                       public ChartSidebarModifyListenerParent
+                       public ChartSidebarModifyListenerParent,
+                       public ChartTypeTemplateProvider
 {
 public:
     static VclPtr<vcl::Window> Create(vcl::Window* pParent,
@@ -85,6 +92,9 @@ public:
 
     virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) 
override;
 
+    virtual css::uno::Reference<css::chart2::XChartTypeTemplate>
+    getCurrentTemplate() const override;
+
 private:
     ChartTypeDialogController* getSelectedMainType();
     void showAllControls(ChartTypeDialogController& rTypeController);
@@ -94,14 +104,16 @@ private:
     virtual void stateChanged() override;
 
     void commitToModel(const ChartTypeParameter& rParameter);
+    void selectMainType();
 
-    /*DECL_LINK(SelectMainTypeHdl, ListBox&, void);
-    DECL_LINK(SelectSubTypeHdl, ValueSet*, void);*/
+    DECL_LINK(SelectMainTypeHdl, weld::ComboBox&, void);
+    DECL_LINK(SelectSubTypeHdl, SvtValueSet*, void);
 
     //ui controls
-    VclPtr<FixedText> mpChartTypeLabel;
-    VclPtr<ListBox> m_pMainTypeList;
-    VclPtr<ValueSet> m_pSubTypeList;
+    //std::unique_ptr<weld::Label>  mpChartTypeLabel;
+    //std::unique_ptr<weld::ComboBox> m_pMainTypeList;
+    //VclPtr<ListBox> m_pMainTypeList;
+    //VclPtr<ValueSet> m_pSubTypeList;
 
     vcl::EnumContext maContext;
 
@@ -112,7 +124,7 @@ private:
 
     void Initialize();
 
-    std::unique_ptr<Dim3DLookResourceGroup_unwelded> m_pDim3DLookResourceGroup;
+    std::unique_ptr<Dim3DLookResourceGroup> m_pDim3DLookResourceGroup;
     /*std::unique_ptr<StackingResourceGroup>      m_pStackingResourceGroup;
     std::unique_ptr<SplineResourceGroup>        m_pSplineResourceGroup;
     std::unique_ptr<GeometryResourceGroup>      m_pGeometryResourceGroup;
@@ -126,6 +138,11 @@ private:
     sal_Int32 m_nChangingCalls;
 
     TimerTriggeredControllerLock m_aTimerTriggeredControllerLock;
+
+    std::unique_ptr<weld::Label> m_xChartTypeLabel;
+    std::unique_ptr<weld::ComboBox> m_xMainTypeList;
+    std::unique_ptr<SvtValueSet> m_xSubTypeList;
+    std::unique_ptr<weld::CustomWeld> m_xSubTypeListWin;
 };
 }
 } // end of namespace ::chart::sidebar
diff --git a/chart2/uiconfig/ui/sidebartype.ui 
b/chart2/uiconfig/ui/sidebartype.ui
index d12e6259154a..ce1c1fd28fc6 100644
--- a/chart2/uiconfig/ui/sidebartype.ui
+++ b/chart2/uiconfig/ui/sidebartype.ui
@@ -2,68 +2,71 @@
 <!-- Generated with glade 3.22.1 -->
 <interface domain="chart">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="lower">1</property>
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name image -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkGrid" id="ChartTypePanel">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
+    <property name="margin_left">6</property>
+    <property name="margin_right">6</property>
+    <property name="margin_top">6</property>
+    <property name="margin_bottom">6</property>
+    <property name="row_spacing">6</property>
+    <property name="column_spacing">6</property>
     <child>
-      <object class="GtkBox" id="container">
+      <object class="GtkGrid" id="grid1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="border_width">6</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">6</property>
+        <property name="hexpand">True</property>
+        <property name="row_spacing">6</property>
         <child>
-          <object class="GtkGrid">
+          <object class="GtkScrolledWindow" id="subtypewin">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="row_spacing">6</property>
-            <property name="column_spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="lbl_chartType">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" 
context="sidebartype|lbl_chartType">Chart Type:</property>
-                <accessibility>
-                  <relation type="label-for" target="cmb_chartType"/>
-                </accessibility>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
+            <property name="can_focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">never</property>
+            <property name="shadow_type">in</property>
             <child>
-              <object class="GtkComboBox" id="cmb_chartType">
+              <object class="GtkViewport">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <accessibility>
-                  <relation type="labelled-by" target="lbl_chartType"/>
-                </accessibility>
+                <child>
+                  <object class="GtkDrawingArea" id="subtype">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="events">GDK_BUTTON_MOTION_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+                    <property name="hexpand">True</property>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="svtlo-ValueSet" id="subtype:border">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
           </packing>
         </child>
         <child>
@@ -79,7 +82,6 @@
                 <child>
                   <object class="GtkCheckButton" id="3dlook">
                     <property name="label" translatable="yes" 
context="sidebartype|3dlook">_3D Look</property>
-                    <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
@@ -96,7 +98,6 @@
                 </child>
                 <child>
                   <object class="GtkComboBoxText" id="3dscheme">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <items>
                       <item translatable="yes" 
context="sidebartype|3dscheme">Simple</item>
@@ -123,7 +124,7 @@
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes" 
context="sidebartype|shapeft">Sh_ape</property>
                 <property name="use_underline">True</property>
-                <property name="mnemonic_widget">shape:border</property>
+                <property name="mnemonic_widget">shape</property>
                 <property name="angle">0.02</property>
                 <property name="xalign">0</property>
               </object>
@@ -133,12 +134,35 @@
               </packing>
             </child>
             <child>
-              <object class="GtkTreeView" id="shape:border">
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="search_column">0</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection"/>
+                <property name="vexpand">True</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="shape">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore1</property>
+                    <property name="headers_visible">False</property>
+                    <property name="headers_clickable">False</property>
+                    <property name="search_column">0</property>
+                    <property name="show_expanders">False</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <child>
+                          <object class="GtkCellRendererText" 
id="cellrenderertext1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
                 </child>
               </object>
               <packing>
@@ -148,9 +172,8 @@
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
           </packing>
         </child>
         <child>
@@ -161,7 +184,6 @@
             <child>
               <object class="GtkCheckButton" id="stack">
                 <property name="label" translatable="yes" 
context="sidebartype|stack">_Stack series</property>
-                <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
                 <property name="use_underline">True</property>
@@ -174,7 +196,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkAlignment" id="alignment2">
+              <object class="GtkAlignment" id="alignment1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="left_padding">12</property>
@@ -186,13 +208,12 @@
                     <child>
                       <object class="GtkRadioButton" id="ontop">
                         <property name="label" translatable="yes" 
context="sidebartype|ontop">On top</property>
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
                         <property name="use_underline">True</property>
                         <property name="xalign">0</property>
+                        <property name="active">True</property>
                         <property name="draw_indicator">True</property>
-                        <property name="group">percent</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -202,13 +223,12 @@
                     <child>
                       <object class="GtkRadioButton" id="percent">
                         <property name="label" translatable="yes" 
context="sidebartype|percent">Percent</property>
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
                         <property name="use_underline">True</property>
                         <property name="xalign">0</property>
                         <property name="draw_indicator">True</property>
-                        <property name="group">deep</property>
+                        <property name="group">ontop</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -218,7 +238,6 @@
                     <child>
                       <object class="GtkRadioButton" id="deep">
                         <property name="label" translatable="yes" 
context="sidebartype|deep">Deep</property>
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
                         <property name="use_underline">True</property>
@@ -246,12 +265,10 @@
                 <property name="column_spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="linetypeft">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="label" translatable="yes" 
context="sidebartype|linetypeft">_Line type</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">linetype</property>
-                    <property name="ellipsize">end</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -261,7 +278,6 @@
                 </child>
                 <child>
                   <object class="GtkComboBoxText" id="linetype">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <items>
                       <item translatable="yes" 
context="sidebartype|linetype">Straight</item>
@@ -277,7 +293,6 @@
                 <child>
                   <object class="GtkButton" id="properties">
                     <property name="label" translatable="yes" 
context="sidebartype|properties">Properties...</property>
-                    <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="use_underline">True</property>
@@ -296,7 +311,6 @@
             <child>
               <object class="GtkCheckButton" id="sort">
                 <property name="label" translatable="yes" 
context="sidebartype|sort">_Sort by X values</property>
-                <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
                 <property name="use_underline">True</property>
@@ -315,7 +329,6 @@
                 <property name="column_spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="nolinesft">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="no_show_all">True</property>
                     <property name="label" translatable="yes" 
context="sidebartype|nolinesft">_Number of lines</property>
@@ -331,10 +344,10 @@
                 </child>
                 <child>
                   <object class="GtkSpinButton" id="nolines">
-                    <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="no_show_all">True</property>
-                    <property name="value">1</property>
+                    <property name="activates_default">True</property>
+                    <property name="adjustment">adjustment1</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
@@ -349,9 +362,49 @@
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">3</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="charttypeblock">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="lbl_chartType">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" 
context="sidebartype|lbl_chartType">Chart Type:</property>
+                <accessibility>
+                  <relation type="label-for" target="cmb_chartType"/>
+                </accessibility>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="cmb_chartType">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="model">liststore2</property>
+                <accessibility>
+                  <relation type="labelled-by" target="lbl_chartType"/>
+                </accessibility>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
       </object>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to