| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "tp_Wizard_TitlesAndObjects.hxx" |
| 21 |
#include <res_Titles.hxx> |
| 22 |
#include <res_LegendPosition.hxx> |
| 23 |
#include <ChartModel.hxx> |
| 24 |
#include <Diagram.hxx> |
| 25 |
#include <AxisHelper.hxx> |
| 26 |
#include <ControllerLockGuard.hxx> |
| 27 |
#include <utility> |
| 28 |
|
| 29 |
namespace chart |
| 30 |
{ |
| 31 |
using namespace ::com::sun::star; |
| 32 |
|
| 33 |
TitlesAndObjectsTabPage::TitlesAndObjectsTabPage(weld::Container* pPage, weld::DialogController* pController, |
| 34 |
rtl::Reference<::chart::ChartModel> xChartModel, |
| 35 |
const uno::Reference< uno::XComponentContext >& xContext ) |
| 36 |
: OWizardPage(pPage, pController, u"modules/schart/ui/wizelementspage.ui"_ustr, u"WizElementsPage"_ustr) |
| 37 |
, m_xTitleResources(new TitleResources(*m_xBuilder, false)) |
| 38 |
, m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xContext)) |
| 39 |
, m_xChartModel(std::move(xChartModel)) |
| 40 |
, m_xCC(xContext) |
| 41 |
, m_bCommitToModel(true) |
| 42 |
, m_aTimerTriggeredControllerLock( m_xChartModel ) |
| 43 |
, m_xCB_Grid_X(m_xBuilder->weld_check_button(u"x"_ustr)) |
| 44 |
, m_xCB_Grid_Y(m_xBuilder->weld_check_button(u"y"_ustr)) |
| 45 |
, m_xCB_Grid_Z(m_xBuilder->weld_check_button(u"z"_ustr)) |
| 46 |
{ |
| 47 |
m_xTitleResources->connect_changed( LINK( this, TitlesAndObjectsTabPage, ChangeEditHdl )); |
| 48 |
m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); |
| 49 |
|
| 50 |
m_xCB_Grid_X->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl )); |
| 51 |
m_xCB_Grid_Y->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl )); |
| 52 |
m_xCB_Grid_Z->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl )); |
| 53 |
} |
| 54 |
|
| 55 |
TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage() |
| 56 |
{ |
| 57 |
} |
| 58 |
|
| 59 |
void TitlesAndObjectsTabPage::initializePage() |
| 60 |
{ |
| 61 |
m_bCommitToModel = false; |
| 62 |
|
| 63 |
//init titles |
| 64 |
{ |
| 65 |
TitleDialogData aTitleInput; |
| 66 |
aTitleInput.readFromModel( m_xChartModel ); |
| 67 |
m_xTitleResources->writeToResources( aTitleInput ); |
| 68 |
} |
| 69 |
|
| 70 |
//init legend |
| 71 |
{ |
| 72 |
m_xLegendPositionResources->writeToResources( m_xChartModel ); |
| 73 |
} |
| 74 |
|
| 75 |
//init grid checkboxes |
| 76 |
{ |
| 77 |
rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); |
| 78 |
uno::Sequence< sal_Bool > aPossibilityList; |
| 79 |
uno::Sequence< sal_Bool > aExistenceList; |
| 80 |
AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false ); |
| 81 |
AxisHelper::getAxisOrGridExistence( aExistenceList, xDiagram, false ); |
| 82 |
m_xCB_Grid_X->set_sensitive( aPossibilityList[0] ); |
| 83 |
m_xCB_Grid_Y->set_sensitive( aPossibilityList[1] ); |
| 84 |
m_xCB_Grid_Z->set_sensitive( aPossibilityList[2] ); |
| 85 |
m_xCB_Grid_X->set_active( aExistenceList[0] ); |
| 86 |
m_xCB_Grid_Y->set_active( aExistenceList[1] ); |
| 87 |
m_xCB_Grid_Z->set_active( aExistenceList[2] ); |
| 88 |
} |
| 89 |
|
| 90 |
m_bCommitToModel = true; |
| 91 |
} |
| 92 |
|
| 93 |
bool TitlesAndObjectsTabPage::commitPage( ::vcl::WizardTypes::CommitPageReason /*eReason*/ ) |
| 94 |
{ |
| 95 |
if( m_xTitleResources->get_value_changed_from_saved() ) //titles may have changed in the meanwhile |
| 96 |
commitToModel(); |
| 97 |
return true;//return false if this page should not be left |
| 98 |
} |
| 99 |
|
| 100 |
void TitlesAndObjectsTabPage::commitToModel() |
| 101 |
{ |
| 102 |
m_aTimerTriggeredControllerLock.startTimer(); |
| 103 |
rtl::Reference<::chart::ChartModel> xModel = m_xChartModel; |
| 104 |
|
| 105 |
ControllerLockGuardUNO aLockedControllers( xModel ); |
| 106 |
|
| 107 |
//commit title changes to model |
| 108 |
{ |
| 109 |
TitleDialogData aTitleOutput; |
| 110 |
m_xTitleResources->readFromResources( aTitleOutput ); |
| 111 |
aTitleOutput.writeDifferenceToModel( xModel, m_xCC ); |
| 112 |
m_xTitleResources->save_value(); |
| 113 |
} |
| 114 |
|
| 115 |
//commit legend changes to model |
| 116 |
{ |
| 117 |
m_xLegendPositionResources->writeToModel( xModel ); |
| 118 |
} |
| 119 |
|
| 120 |
//commit grid changes to model |
| 121 |
{ |
| 122 |
rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); |
| 123 |
uno::Sequence< sal_Bool > aOldExistenceList; |
| 124 |
AxisHelper::getAxisOrGridExistence( aOldExistenceList, xDiagram, false ); |
| 125 |
uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList); |
| 126 |
sal_Bool* pNewExistenceList = aNewExistenceList.getArray(); |
| 127 |
pNewExistenceList[0] = m_xCB_Grid_X->get_active(); |
| 128 |
pNewExistenceList[1] = m_xCB_Grid_Y->get_active(); |
| 129 |
pNewExistenceList[2] = m_xCB_Grid_Z->get_active(); |
| 130 |
AxisHelper::changeVisibilityOfGrids( xDiagram |
| 131 |
, aOldExistenceList, aNewExistenceList ); |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeCheckBoxHdl, weld::Toggleable&, void) |
| 136 |
{ |
| 137 |
ChangeHdl(nullptr); |
| 138 |
} |
| 139 |
|
| 140 |
IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeEditHdl, weld::Entry&, void) |
| 141 |
{ |
| 142 |
ChangeHdl(nullptr); |
| 143 |
} |
| 144 |
|
| 145 |
IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeHdl, LinkParamNone*, void) |
| 146 |
{ |
| 147 |
if( m_bCommitToModel ) |
| 148 |
commitToModel(); |
| 149 |
} |
| 150 |
|
| 151 |
bool TitlesAndObjectsTabPage::canAdvance() const |
| 152 |
{ |
| 153 |
return false; |
| 154 |
} |
| 155 |
|
| 156 |
} //namespace chart |
| 157 |
|
| 158 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |