1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 31 #include "tp_Wizard_TitlesAndObjects.hxx" 32 #include "tp_Wizard_TitlesAndObjects.hrc" 33 #include "Strings.hrc" 34 #include "res_Titles.hxx" 35 #include "res_LegendPosition.hxx" 36 #include "ResId.hxx" 37 #include "HelpIds.hrc" 38 #include "macros.hxx" 39 #include "ChartModelHelper.hxx" 40 #include "AxisHelper.hxx" 41 #include "LegendHelper.hxx" 42 #include "NoWarningThisInCTOR.hxx" 43 #include "ControllerLockGuard.hxx" 44 45 //............................................................................. 46 namespace chart 47 { 48 //............................................................................. 49 using namespace ::com::sun::star; 50 using namespace ::com::sun::star::chart2; 51 52 53 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent 54 , const uno::Reference< XChartDocument >& xChartModel 55 , const uno::Reference< uno::XComponentContext >& xContext ) 56 : OWizardPage( pParent, SchResId(TP_WIZARD_TITLEANDOBJECTS) ) 57 , m_aFT_TitleDescription( this, SchResId( FT_TITLEDESCRIPTION ) ) 58 , m_aFL_Vertical( this, SchResId( FL_VERTICAL ) ) 59 , m_apTitleResources( new TitleResources(this,false) ) 60 , m_apLegendPositionResources( new LegendPositionResources(this,xContext) ) 61 , m_aFL_Grids( this, SchResId( FL_GRIDS ) ) 62 , m_aCB_Grid_X( this, SchResId( CB_X_SECONDARY ) ) 63 , m_aCB_Grid_Y( this, SchResId( CB_Y_SECONDARY ) ) 64 , m_aCB_Grid_Z( this, SchResId( CB_Z_SECONDARY ) ) 65 , m_xChartModel( xChartModel ) 66 , m_xCC( xContext ) 67 , m_bCommitToModel( true ) 68 , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) ) 69 { 70 FreeResource(); 71 72 this->SetText( String( SchResId( STR_PAGE_CHART_ELEMENTS ) ) ); 73 74 Font aFont( m_aFT_TitleDescription.GetControlFont() ); 75 aFont.SetWeight( WEIGHT_BOLD ); 76 m_aFT_TitleDescription.SetControlFont( aFont ); 77 78 m_aCB_Grid_X.SetHelpId( HID_SCH_CB_XGRID ); 79 m_aCB_Grid_Y.SetHelpId( HID_SCH_CB_YGRID ); 80 m_aCB_Grid_Z.SetHelpId( HID_SCH_CB_ZGRID ); 81 82 m_apTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); 83 m_apLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); 84 85 m_aCB_Grid_X.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); 86 m_aCB_Grid_Y.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); 87 m_aCB_Grid_Z.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); 88 } 89 90 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage() 91 { 92 } 93 94 void TitlesAndObjectsTabPage::initializePage() 95 { 96 m_bCommitToModel = false; 97 98 //init titles 99 { 100 TitleDialogData aTitleInput; 101 aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) ); 102 m_apTitleResources->writeToResources( aTitleInput ); 103 } 104 105 //init legend 106 { 107 m_apLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) ); 108 } 109 110 //init grid checkboxes 111 { 112 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel ); 113 uno::Sequence< sal_Bool > aPossibilityList; 114 uno::Sequence< sal_Bool > aExistenceList; 115 AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, sal_False ); 116 AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, sal_False ); 117 m_aCB_Grid_X.Enable( aPossibilityList[0] ); 118 m_aCB_Grid_Y.Enable( aPossibilityList[1] ); 119 m_aCB_Grid_Z.Enable( aPossibilityList[2] ); 120 m_aCB_Grid_X.Check( aExistenceList[0] ); 121 m_aCB_Grid_Y.Check( aExistenceList[1] ); 122 m_aCB_Grid_Z.Check( aExistenceList[2] ); 123 } 124 125 m_bCommitToModel = true; 126 } 127 128 sal_Bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ ) 129 { 130 if( m_apTitleResources->IsModified() ) //titles may have changed in the meanwhile 131 commitToModel(); 132 return sal_True;//return false if this page should not be left 133 } 134 135 void TitlesAndObjectsTabPage::commitToModel() 136 { 137 bool bChanged = false; 138 139 m_aTimerTriggeredControllerLock.startTimer(); 140 uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY); 141 142 ControllerLockGuard aLockedControllers( xModel ); 143 144 //commit title changes to model 145 { 146 TitleDialogData aTitleOutput; 147 m_apTitleResources->readFromResources( aTitleOutput ); 148 bChanged = bChanged || aTitleOutput.writeDifferenceToModel( xModel, m_xCC ); 149 m_apTitleResources->ClearModifyFlag(); 150 } 151 152 //commit legend changes to model 153 { 154 bChanged = true; 155 m_apLegendPositionResources->writeToModel( xModel ); 156 } 157 158 //commit grid changes to model 159 { 160 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); 161 uno::Sequence< sal_Bool > aOldExistenceList; 162 AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, sal_False ); 163 uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList); 164 aNewExistenceList[0]=m_aCB_Grid_X.IsChecked(); 165 aNewExistenceList[1]=m_aCB_Grid_Y.IsChecked(); 166 aNewExistenceList[2]=m_aCB_Grid_Z.IsChecked(); 167 AxisHelper::changeVisibilityOfGrids( xDiagram 168 , aOldExistenceList, aNewExistenceList, m_xCC ); 169 } 170 } 171 172 IMPL_LINK( TitlesAndObjectsTabPage, ChangeHdl, void *, EMPTYARG ) 173 { 174 if( m_bCommitToModel ) 175 commitToModel(); 176 return 0; 177 } 178 179 bool TitlesAndObjectsTabPage::canAdvance() const 180 { 181 return false; 182 } 183 184 185 //............................................................................. 186 } //namespace chart 187 //............................................................................. 188