1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26
27 #include "tp_Wizard_TitlesAndObjects.hxx"
28 #include "tp_Wizard_TitlesAndObjects.hrc"
29 #include "Strings.hrc"
30 #include "res_Titles.hxx"
31 #include "res_LegendPosition.hxx"
32 #include "ResId.hxx"
33 #include "HelpIds.hrc"
34 #include "macros.hxx"
35 #include "ChartModelHelper.hxx"
36 #include "AxisHelper.hxx"
37 #include "LegendHelper.hxx"
38 #include "NoWarningThisInCTOR.hxx"
39 #include "ControllerLockGuard.hxx"
40
41 //.............................................................................
42 namespace chart
43 {
44 //.............................................................................
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::chart2;
47
48
TitlesAndObjectsTabPage(svt::OWizardMachine * pParent,const uno::Reference<XChartDocument> & xChartModel,const uno::Reference<uno::XComponentContext> & xContext)49 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent
50 , const uno::Reference< XChartDocument >& xChartModel
51 , const uno::Reference< uno::XComponentContext >& xContext )
52 : OWizardPage( pParent, SchResId(TP_WIZARD_TITLEANDOBJECTS) )
53 , m_aFT_TitleDescription( this, SchResId( FT_TITLEDESCRIPTION ) )
54 , m_aFL_Vertical( this, SchResId( FL_VERTICAL ) )
55 , m_apTitleResources( new TitleResources(this,false) )
56 , m_apLegendPositionResources( new LegendPositionResources(this,xContext) )
57 , m_aFL_Grids( this, SchResId( FL_GRIDS ) )
58 , m_aCB_Grid_X( this, SchResId( CB_X_SECONDARY ) )
59 , m_aCB_Grid_Y( this, SchResId( CB_Y_SECONDARY ) )
60 , m_aCB_Grid_Z( this, SchResId( CB_Z_SECONDARY ) )
61 , m_xChartModel( xChartModel )
62 , m_xCC( xContext )
63 , m_bCommitToModel( true )
64 , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
65 {
66 FreeResource();
67
68 this->SetText( String( SchResId( STR_PAGE_CHART_ELEMENTS ) ) );
69
70 Font aFont( m_aFT_TitleDescription.GetControlFont() );
71 aFont.SetWeight( WEIGHT_BOLD );
72 m_aFT_TitleDescription.SetControlFont( aFont );
73
74 m_aCB_Grid_X.SetHelpId( HID_SCH_CB_XGRID );
75 m_aCB_Grid_Y.SetHelpId( HID_SCH_CB_YGRID );
76 m_aCB_Grid_Z.SetHelpId( HID_SCH_CB_ZGRID );
77
78 m_apTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
79 m_apLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
80
81 m_aCB_Grid_X.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
82 m_aCB_Grid_Y.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
83 m_aCB_Grid_Z.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
84 }
85
~TitlesAndObjectsTabPage()86 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
87 {
88 }
89
initializePage()90 void TitlesAndObjectsTabPage::initializePage()
91 {
92 m_bCommitToModel = false;
93
94 //init titles
95 {
96 TitleDialogData aTitleInput;
97 aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
98 m_apTitleResources->writeToResources( aTitleInput );
99 }
100
101 //init legend
102 {
103 m_apLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
104 }
105
106 //init grid checkboxes
107 {
108 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
109 uno::Sequence< sal_Bool > aPossibilityList;
110 uno::Sequence< sal_Bool > aExistenceList;
111 AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, sal_False );
112 AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, sal_False );
113 m_aCB_Grid_X.Enable( aPossibilityList[0] );
114 m_aCB_Grid_Y.Enable( aPossibilityList[1] );
115 m_aCB_Grid_Z.Enable( aPossibilityList[2] );
116 m_aCB_Grid_X.Check( aExistenceList[0] );
117 m_aCB_Grid_Y.Check( aExistenceList[1] );
118 m_aCB_Grid_Z.Check( aExistenceList[2] );
119 }
120
121 m_bCommitToModel = true;
122 }
123
commitPage(::svt::WizardTypes::CommitPageReason)124 sal_Bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
125 {
126 if( m_apTitleResources->IsModified() ) //titles may have changed in the meanwhile
127 commitToModel();
128 return sal_True;//return false if this page should not be left
129 }
130
commitToModel()131 void TitlesAndObjectsTabPage::commitToModel()
132 {
133 bool bChanged = false;
134
135 m_aTimerTriggeredControllerLock.startTimer();
136 uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY);
137
138 ControllerLockGuard aLockedControllers( xModel );
139
140 //commit title changes to model
141 {
142 TitleDialogData aTitleOutput;
143 m_apTitleResources->readFromResources( aTitleOutput );
144 bChanged = bChanged || aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
145 m_apTitleResources->ClearModifyFlag();
146 }
147
148 //commit legend changes to model
149 {
150 bChanged = true;
151 m_apLegendPositionResources->writeToModel( xModel );
152 }
153
154 //commit grid changes to model
155 {
156 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
157 uno::Sequence< sal_Bool > aOldExistenceList;
158 AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, sal_False );
159 uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
160 aNewExistenceList[0]=m_aCB_Grid_X.IsChecked();
161 aNewExistenceList[1]=m_aCB_Grid_Y.IsChecked();
162 aNewExistenceList[2]=m_aCB_Grid_Z.IsChecked();
163 AxisHelper::changeVisibilityOfGrids( xDiagram
164 , aOldExistenceList, aNewExistenceList, m_xCC );
165 }
166 }
167
IMPL_LINK(TitlesAndObjectsTabPage,ChangeHdl,void *,EMPTYARG)168 IMPL_LINK( TitlesAndObjectsTabPage, ChangeHdl, void *, EMPTYARG )
169 {
170 if( m_bCommitToModel )
171 commitToModel();
172 return 0;
173 }
174
canAdvance() const175 bool TitlesAndObjectsTabPage::canAdvance() const
176 {
177 return false;
178 }
179
180
181 //.............................................................................
182 } //namespace chart
183 //.............................................................................
184