Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_Wizard_TitlesAndObjects.cxx
blob902208cf33adfed8e697e6fefa5852d5a0e440c3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "tp_Wizard_TitlesAndObjects.hxx"
21 #include <res_Titles.hxx>
22 #include <res_LegendPosition.hxx>
23 #include <ChartModelHelper.hxx>
24 #include <AxisHelper.hxx>
25 #include <LegendHelper.hxx>
26 #include <ControllerLockGuard.hxx>
28 namespace chart
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::chart2;
33 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent
34 , const uno::Reference< XChartDocument >& xChartModel
35 , const uno::Reference< uno::XComponentContext >& xContext )
36 : OWizardPage(pParent, "WizElementsPage", "modules/schart/ui/wizelementspage.ui")
37 , m_xTitleResources(new TitleResources(*this, false))
38 , m_xLegendPositionResources(new LegendPositionResources(*this, xContext))
39 , m_xChartModel(xChartModel)
40 , m_xCC(xContext)
41 , m_bCommitToModel(true)
42 , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
44 get(m_pCB_Grid_X, "x");
45 get(m_pCB_Grid_Y, "y");
46 get(m_pCB_Grid_Z, "z");
48 m_xTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeEditHdl ));
49 m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
51 m_pCB_Grid_X->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
52 m_pCB_Grid_Y->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
53 m_pCB_Grid_Z->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
56 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
58 disposeOnce();
61 void TitlesAndObjectsTabPage::dispose()
63 m_pCB_Grid_X.clear();
64 m_pCB_Grid_Y.clear();
65 m_pCB_Grid_Z.clear();
66 OWizardPage::dispose();
69 void TitlesAndObjectsTabPage::initializePage()
71 m_bCommitToModel = false;
73 //init titles
75 TitleDialogData aTitleInput;
76 aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
77 m_xTitleResources->writeToResources( aTitleInput );
80 //init legend
82 m_xLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
85 //init grid checkboxes
87 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
88 uno::Sequence< sal_Bool > aPossibilityList;
89 uno::Sequence< sal_Bool > aExistenceList;
90 AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false );
91 AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, false );
92 m_pCB_Grid_X->Enable( aPossibilityList[0] );
93 m_pCB_Grid_Y->Enable( aPossibilityList[1] );
94 m_pCB_Grid_Z->Enable( aPossibilityList[2] );
95 m_pCB_Grid_X->Check( aExistenceList[0] );
96 m_pCB_Grid_Y->Check( aExistenceList[1] );
97 m_pCB_Grid_Z->Check( aExistenceList[2] );
100 m_bCommitToModel = true;
103 bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
105 if( m_xTitleResources->IsModified() ) //titles may have changed in the meanwhile
106 commitToModel();
107 return true;//return false if this page should not be left
110 void TitlesAndObjectsTabPage::commitToModel()
112 m_aTimerTriggeredControllerLock.startTimer();
113 uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY);
115 ControllerLockGuardUNO aLockedControllers( xModel );
117 //commit title changes to model
119 TitleDialogData aTitleOutput;
120 m_xTitleResources->readFromResources( aTitleOutput );
121 aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
122 m_xTitleResources->ClearModifyFlag();
125 //commit legend changes to model
127 m_xLegendPositionResources->writeToModel( xModel );
130 //commit grid changes to model
132 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
133 uno::Sequence< sal_Bool > aOldExistenceList;
134 AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, false );
135 uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
136 aNewExistenceList[0] = m_pCB_Grid_X->IsChecked();
137 aNewExistenceList[1] = m_pCB_Grid_Y->IsChecked();
138 aNewExistenceList[2] = m_pCB_Grid_Z->IsChecked();
139 AxisHelper::changeVisibilityOfGrids( xDiagram
140 , aOldExistenceList, aNewExistenceList );
145 IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeCheckBoxHdl, CheckBox&, void)
147 ChangeHdl(nullptr);
149 IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeEditHdl, Edit&, void)
151 ChangeHdl(nullptr);
153 IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeHdl, LinkParamNone*, void)
155 if( m_bCommitToModel )
156 commitToModel();
159 bool TitlesAndObjectsTabPage::canAdvance() const
161 return false;
164 } //namespace chart
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */