Line data Source code
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 "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"
31 :
32 : namespace chart
33 : {
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::chart2;
36 :
37 0 : 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 0 : , m_xTitleResources(new TitleResources(*this, false))
42 0 : , m_xLegendPositionResources(new LegendPositionResources(*this, xContext))
43 : , m_xChartModel(xChartModel)
44 : , m_xCC(xContext)
45 : , m_bCommitToModel(true)
46 0 : , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
47 : {
48 0 : get(m_pCB_Grid_X, "x");
49 0 : get(m_pCB_Grid_Y, "y");
50 0 : get(m_pCB_Grid_Z, "z");
51 :
52 0 : m_xTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
53 0 : m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
54 :
55 0 : m_pCB_Grid_X->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
56 0 : m_pCB_Grid_Y->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
57 0 : m_pCB_Grid_Z->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
58 0 : }
59 :
60 0 : void TitlesAndObjectsTabPage::initializePage()
61 : {
62 0 : m_bCommitToModel = false;
63 :
64 : //init titles
65 : {
66 0 : TitleDialogData aTitleInput;
67 0 : aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
68 0 : m_xTitleResources->writeToResources( aTitleInput );
69 : }
70 :
71 : //init legend
72 : {
73 0 : m_xLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
74 : }
75 :
76 : //init grid checkboxes
77 : {
78 0 : uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
79 0 : uno::Sequence< sal_Bool > aPossibilityList;
80 0 : uno::Sequence< sal_Bool > aExistenceList;
81 0 : AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false );
82 0 : AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, false );
83 0 : m_pCB_Grid_X->Enable( aPossibilityList[0] );
84 0 : m_pCB_Grid_Y->Enable( aPossibilityList[1] );
85 0 : m_pCB_Grid_Z->Enable( aPossibilityList[2] );
86 0 : m_pCB_Grid_X->Check( aExistenceList[0] );
87 0 : m_pCB_Grid_Y->Check( aExistenceList[1] );
88 0 : m_pCB_Grid_Z->Check( aExistenceList[2] );
89 : }
90 :
91 0 : m_bCommitToModel = true;
92 0 : }
93 :
94 0 : bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
95 : {
96 0 : if( m_xTitleResources->IsModified() ) //titles may have changed in the meanwhile
97 0 : commitToModel();
98 0 : return true;//return false if this page should not be left
99 : }
100 :
101 0 : void TitlesAndObjectsTabPage::commitToModel()
102 : {
103 0 : m_aTimerTriggeredControllerLock.startTimer();
104 0 : uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY);
105 :
106 0 : ControllerLockGuardUNO aLockedControllers( xModel );
107 :
108 : //commit title changes to model
109 : {
110 0 : TitleDialogData aTitleOutput;
111 0 : m_xTitleResources->readFromResources( aTitleOutput );
112 0 : aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
113 0 : m_xTitleResources->ClearModifyFlag();
114 : }
115 :
116 : //commit legend changes to model
117 : {
118 0 : m_xLegendPositionResources->writeToModel( xModel );
119 : }
120 :
121 : //commit grid changes to model
122 : {
123 0 : uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
124 0 : uno::Sequence< sal_Bool > aOldExistenceList;
125 0 : AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, false );
126 0 : uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
127 0 : aNewExistenceList[0] = m_pCB_Grid_X->IsChecked();
128 0 : aNewExistenceList[1] = m_pCB_Grid_Y->IsChecked();
129 0 : aNewExistenceList[2] = m_pCB_Grid_Z->IsChecked();
130 : AxisHelper::changeVisibilityOfGrids( xDiagram
131 0 : , aOldExistenceList, aNewExistenceList, m_xCC );
132 0 : }
133 0 : }
134 :
135 0 : IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeHdl)
136 : {
137 0 : if( m_bCommitToModel )
138 0 : commitToModel();
139 0 : return 0;
140 : }
141 :
142 0 : bool TitlesAndObjectsTabPage::canAdvance() const
143 : {
144 0 : return false;
145 : }
146 :
147 102 : } //namespace chart
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|