fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_Wizard_TitlesAndObjects.cxx
blob8c40e6d4351277ccbc580c00cd902c0987807024
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 "Strings.hrc"
22 #include "res_Titles.hxx"
23 #include "res_LegendPosition.hxx"
24 #include "ResId.hxx"
25 #include "HelpIds.hrc"
26 #include "macros.hxx"
27 #include "ChartModelHelper.hxx"
28 #include "AxisHelper.hxx"
29 #include "LegendHelper.hxx"
30 #include "ControllerLockGuard.hxx"
32 namespace chart
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::chart2;
37 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent
38 , const uno::Reference< XChartDocument >& xChartModel
39 , const uno::Reference< uno::XComponentContext >& xContext )
40 : OWizardPage(pParent, "WizElementsPage", "modules/schart/ui/wizelementspage.ui")
41 , m_xTitleResources(new TitleResources(*this, false))
42 , m_xLegendPositionResources(new LegendPositionResources(*this, xContext))
43 , m_xChartModel(xChartModel)
44 , m_xCC(xContext)
45 , m_bCommitToModel(true)
46 , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
48 get(m_pCB_Grid_X, "x");
49 get(m_pCB_Grid_Y, "y");
50 get(m_pCB_Grid_Z, "z");
52 m_xTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
53 m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
55 m_pCB_Grid_X->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
56 m_pCB_Grid_Y->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
57 m_pCB_Grid_Z->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
60 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
62 disposeOnce();
65 void TitlesAndObjectsTabPage::dispose()
67 m_pCB_Grid_X.clear();
68 m_pCB_Grid_Y.clear();
69 m_pCB_Grid_Z.clear();
70 OWizardPage::dispose();
73 void TitlesAndObjectsTabPage::initializePage()
75 m_bCommitToModel = false;
77 //init titles
79 TitleDialogData aTitleInput;
80 aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
81 m_xTitleResources->writeToResources( aTitleInput );
84 //init legend
86 m_xLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
89 //init grid checkboxes
91 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
92 uno::Sequence< sal_Bool > aPossibilityList;
93 uno::Sequence< sal_Bool > aExistenceList;
94 AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false );
95 AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, false );
96 m_pCB_Grid_X->Enable( aPossibilityList[0] );
97 m_pCB_Grid_Y->Enable( aPossibilityList[1] );
98 m_pCB_Grid_Z->Enable( aPossibilityList[2] );
99 m_pCB_Grid_X->Check( aExistenceList[0] );
100 m_pCB_Grid_Y->Check( aExistenceList[1] );
101 m_pCB_Grid_Z->Check( aExistenceList[2] );
104 m_bCommitToModel = true;
107 bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
109 if( m_xTitleResources->IsModified() ) //titles may have changed in the meanwhile
110 commitToModel();
111 return true;//return false if this page should not be left
114 void TitlesAndObjectsTabPage::commitToModel()
116 m_aTimerTriggeredControllerLock.startTimer();
117 uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY);
119 ControllerLockGuardUNO aLockedControllers( xModel );
121 //commit title changes to model
123 TitleDialogData aTitleOutput;
124 m_xTitleResources->readFromResources( aTitleOutput );
125 aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
126 m_xTitleResources->ClearModifyFlag();
129 //commit legend changes to model
131 m_xLegendPositionResources->writeToModel( xModel );
134 //commit grid changes to model
136 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
137 uno::Sequence< sal_Bool > aOldExistenceList;
138 AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, false );
139 uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
140 aNewExistenceList[0] = m_pCB_Grid_X->IsChecked();
141 aNewExistenceList[1] = m_pCB_Grid_Y->IsChecked();
142 aNewExistenceList[2] = m_pCB_Grid_Z->IsChecked();
143 AxisHelper::changeVisibilityOfGrids( xDiagram
144 , aOldExistenceList, aNewExistenceList, m_xCC );
148 IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeHdl)
150 if( m_bCommitToModel )
151 commitToModel();
152 return 0;
155 bool TitlesAndObjectsTabPage::canAdvance() const
157 return false;
160 } //namespace chart
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */