From e4d95fa557179d787fd78211b76dd7c311940762 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 21 May 2018 10:59:34 +0100 Subject: weld SchAxisDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I18441b4fc06b69caf12dc73e5042ad2b609a7cc5 Reviewed-on: https://gerrit.libreoffice.org/54620 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../controller/dialogs/dlg_InsertAxis_Grid.cxx | 87 +++++++++------------- chart2/source/controller/inc/ChartController.hxx | 1 + .../source/controller/inc/dlg_InsertAxis_Grid.hxx | 25 +++---- chart2/source/controller/main/ChartController.cxx | 9 +++ .../controller/main/ChartController_Insert.cxx | 12 +-- chart2/uiconfig/ui/insertaxisdlg.ui | 8 +- chart2/uiconfig/ui/insertgriddlg.ui | 8 +- 7 files changed, 74 insertions(+), 76 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx index 74f2ce9b8831..9a227f59b2f5 100644 --- a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx @@ -40,74 +40,55 @@ InsertAxisOrGridDialogData::InsertAxisOrGridDialogData() // SchAxisDlg -SchAxisDlg::SchAxisDlg(vcl::Window* pWindow, +SchAxisDlg::SchAxisDlg(weld::Window* pWindow, const InsertAxisOrGridDialogData& rInput, bool bAxisDlg) - : ModalDialog(pWindow, - bAxisDlg ? - OUString("InsertAxisDialog") : - OUString("InsertGridDialog"), + : GenericDialogController(pWindow, bAxisDlg ? OUString("modules/schart/ui/insertaxisdlg.ui") : - OUString("modules/schart/ui/insertgriddlg.ui")) + OUString("modules/schart/ui/insertgriddlg.ui"), + bAxisDlg ? + OString("InsertAxisDialog") : + OString("InsertGridDialog")) + , m_xCbPrimaryX(m_xBuilder->weld_check_button("primaryX")) + , m_xCbPrimaryY(m_xBuilder->weld_check_button("primaryY")) + , m_xCbPrimaryZ(m_xBuilder->weld_check_button("primaryZ")) + , m_xCbSecondaryX(m_xBuilder->weld_check_button("secondaryX")) + , m_xCbSecondaryY(m_xBuilder->weld_check_button("secondaryY")) + , m_xCbSecondaryZ(m_xBuilder->weld_check_button("secondaryZ")) { - get(m_pCbPrimaryX, "primaryX"); - get(m_pCbPrimaryY, "primaryY"); - get(m_pCbPrimaryZ, "primaryZ"); - get(m_pCbSecondaryX, "secondaryX"); - get(m_pCbSecondaryY, "secondaryY"); - get(m_pCbSecondaryZ, "secondaryZ"); - if (bAxisDlg) { - //todo: remove if secondary z axis are possible somewhere - m_pCbSecondaryZ->Hide(); + m_xCbSecondaryZ->hide(); } - m_pCbPrimaryX->Check( rInput.aExistenceList[0] ); - m_pCbPrimaryY->Check( rInput.aExistenceList[1] ); - m_pCbPrimaryZ->Check( rInput.aExistenceList[2] ); - m_pCbSecondaryX->Check( rInput.aExistenceList[3] ); - m_pCbSecondaryY->Check( rInput.aExistenceList[4] ); - m_pCbSecondaryZ->Check( rInput.aExistenceList[5] ); - - m_pCbPrimaryX->Enable( rInput.aPossibilityList[0] ); - m_pCbPrimaryY->Enable( rInput.aPossibilityList[1] ); - m_pCbPrimaryZ->Enable( rInput.aPossibilityList[2] ); - m_pCbSecondaryX->Enable( rInput.aPossibilityList[3] ); - m_pCbSecondaryY->Enable( rInput.aPossibilityList[4] ); - m_pCbSecondaryZ->Enable( rInput.aPossibilityList[5] ); -} - -SchAxisDlg::~SchAxisDlg() -{ - disposeOnce(); -} - -void SchAxisDlg::dispose() -{ - m_pCbPrimaryX.clear(); - m_pCbPrimaryY.clear(); - m_pCbPrimaryZ.clear(); - m_pCbSecondaryX.clear(); - m_pCbSecondaryY.clear(); - m_pCbSecondaryZ.clear(); - ModalDialog::dispose(); + m_xCbPrimaryX->set_active( rInput.aExistenceList[0] ); + m_xCbPrimaryY->set_active( rInput.aExistenceList[1] ); + m_xCbPrimaryZ->set_active( rInput.aExistenceList[2] ); + m_xCbSecondaryX->set_active( rInput.aExistenceList[3] ); + m_xCbSecondaryY->set_active( rInput.aExistenceList[4] ); + m_xCbSecondaryZ->set_active( rInput.aExistenceList[5] ); + + m_xCbPrimaryX->set_sensitive( rInput.aPossibilityList[0] ); + m_xCbPrimaryY->set_sensitive( rInput.aPossibilityList[1] ); + m_xCbPrimaryZ->set_sensitive( rInput.aPossibilityList[2] ); + m_xCbSecondaryX->set_sensitive( rInput.aPossibilityList[3] ); + m_xCbSecondaryY->set_sensitive( rInput.aPossibilityList[4] ); + m_xCbSecondaryZ->set_sensitive( rInput.aPossibilityList[5] ); } - void SchAxisDlg::getResult( InsertAxisOrGridDialogData& rOutput ) { - rOutput.aExistenceList[0]=m_pCbPrimaryX->IsChecked(); - rOutput.aExistenceList[1]=m_pCbPrimaryY->IsChecked(); - rOutput.aExistenceList[2]=m_pCbPrimaryZ->IsChecked(); - rOutput.aExistenceList[3]=m_pCbSecondaryX->IsChecked(); - rOutput.aExistenceList[4]=m_pCbSecondaryY->IsChecked(); - rOutput.aExistenceList[5]=m_pCbSecondaryZ->IsChecked(); + rOutput.aExistenceList[0]=m_xCbPrimaryX->get_active(); + rOutput.aExistenceList[1]=m_xCbPrimaryY->get_active(); + rOutput.aExistenceList[2]=m_xCbPrimaryZ->get_active(); + rOutput.aExistenceList[3]=m_xCbSecondaryX->get_active(); + rOutput.aExistenceList[4]=m_xCbSecondaryY->get_active(); + rOutput.aExistenceList[5]=m_xCbSecondaryZ->get_active(); } -SchGridDlg::SchGridDlg( vcl::Window* pParent, const InsertAxisOrGridDialogData& rInput ) - : SchAxisDlg( pParent, rInput, false )//rInAttrs, b3D, bNet, bSecondaryX, bSecondaryY, false ) +SchGridDlg::SchGridDlg(weld::Window* pParent, const InsertAxisOrGridDialogData& rInput) + : SchAxisDlg(pParent, rInput, false) //rInAttrs, b3D, bNet, bSecondaryX, bSecondaryY, false ) { } diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 5a47a8838e55..941672c0cc6e 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -321,6 +321,7 @@ public: DrawModelWrapper* GetDrawModelWrapper(); DrawViewWrapper* GetDrawViewWrapper(); VclPtr GetChartWindow(); + weld::Window* GetChartFrame(); bool isAdditionalShapeSelected(); void SetAndApplySelection(const css::uno::Reference& rxShape); void StartTextEdit( const Point* pMousePixel = nullptr ); diff --git a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx index fea533d7b22d..14e3c6669d51 100644 --- a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx +++ b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx @@ -19,9 +19,7 @@ #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_INC_DLG_INSERTAXIS_GRID_HXX #define INCLUDED_CHART2_SOURCE_CONTROLLER_INC_DLG_INSERTAXIS_GRID_HXX -#include -#include -#include +#include #include namespace chart @@ -40,21 +38,18 @@ struct InsertAxisOrGridDialogData |* insert Axis dialog (also base for grid dialog) |* \************************************************************************/ -class SchAxisDlg : public ModalDialog +class SchAxisDlg : public weld::GenericDialogController { protected: - VclPtr m_pCbPrimaryX; - VclPtr m_pCbPrimaryY; - VclPtr m_pCbPrimaryZ; - VclPtr m_pCbSecondaryX; - VclPtr m_pCbSecondaryY; - VclPtr m_pCbSecondaryZ; + std::unique_ptr m_xCbPrimaryX; + std::unique_ptr m_xCbPrimaryY; + std::unique_ptr m_xCbPrimaryZ; + std::unique_ptr m_xCbSecondaryX; + std::unique_ptr m_xCbSecondaryY; + std::unique_ptr m_xCbSecondaryZ; public: - SchAxisDlg(vcl::Window* pParent, const InsertAxisOrGridDialogData& rInput, bool bAxisDlg=true); - virtual ~SchAxisDlg() override; - virtual void dispose() override; - + SchAxisDlg(weld::Window* pParent, const InsertAxisOrGridDialogData& rInput, bool bAxisDlg = true); void getResult( InsertAxisOrGridDialogData& rOutput ); }; @@ -66,7 +61,7 @@ public: class SchGridDlg : public SchAxisDlg { public: - SchGridDlg( vcl::Window* pParent, const InsertAxisOrGridDialogData& rInput ); + SchGridDlg(weld::Window* pParent, const InsertAxisOrGridDialogData& rInput); }; } //namespace chart diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index a57ddc676396..3fc25dd822a7 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1487,6 +1487,15 @@ VclPtr ChartController::GetChartWindow() return dynamic_cast(VCLUnoHelper::GetWindow(m_xViewWindow).get()); } +weld::Window* ChartController::GetChartFrame() +{ + // clients getting the naked VCL Window from UNO should always have the + // solar mutex (and keep it over the lifetime of this ptr), as VCL might + // might deinit otherwise + DBG_TESTSOLARMUTEX(); + return Application::GetFrameWeld(m_xViewWindow); +} + bool ChartController::isAdditionalShapeSelected() { return m_aSelection.isAdditionalShapeSelected(); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 3589d0cc2d02..a1510a7db984 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -97,14 +97,14 @@ void ChartController::executeDispatch_InsertAxes() AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram ); SolarMutexGuard aGuard; - ScopedVclPtrInstance aDlg( GetChartWindow(), aDialogInput ); - if( aDlg->Execute() == RET_OK ) + SchAxisDlg aDlg(GetChartFrame(), aDialogInput); + if (aDlg.run() == RET_OK) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); InsertAxisOrGridDialogData aDialogOutput; - aDlg->getResult( aDialogOutput ); + aDlg.getResult(aDialogOutput); std::unique_ptr< ReferenceSizeProvider > pRefSizeProvider( impl_createReferenceSizeProvider()); bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram @@ -135,13 +135,13 @@ void ChartController::executeDispatch_InsertGrid() AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, false ); SolarMutexGuard aGuard; - ScopedVclPtrInstance aDlg(GetChartWindow(), aDialogInput);//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY ); - if( aDlg->Execute() == RET_OK ) + SchGridDlg aDlg(GetChartFrame(), aDialogInput);//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY ); + if (aDlg.run() == RET_OK) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); InsertAxisOrGridDialogData aDialogOutput; - aDlg->getResult( aDialogOutput ); + aDlg.getResult( aDialogOutput ); bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram , aDialogInput.aExistenceList, aDialogOutput.aExistenceList ); if( bChanged ) diff --git a/chart2/uiconfig/ui/insertaxisdlg.ui b/chart2/uiconfig/ui/insertaxisdlg.ui index 99441951b724..c445cc8256f2 100644 --- a/chart2/uiconfig/ui/insertaxisdlg.ui +++ b/chart2/uiconfig/ui/insertaxisdlg.ui @@ -1,12 +1,18 @@ - + False 6 Axes + True + 0 + 0 dialog + + + False diff --git a/chart2/uiconfig/ui/insertgriddlg.ui b/chart2/uiconfig/ui/insertgriddlg.ui index 26b9ce55302e..ae3863a59ff5 100644 --- a/chart2/uiconfig/ui/insertgriddlg.ui +++ b/chart2/uiconfig/ui/insertgriddlg.ui @@ -1,12 +1,18 @@ - + False 6 Grids + True + 0 + 0 dialog + + + False -- cgit v1.2.3