1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tp_Wizard_TitlesAndObjects.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "tp_Wizard_TitlesAndObjects.hxx"
35 #include "tp_Wizard_TitlesAndObjects.hrc"
36 #include "Strings.hrc"
37 #include "res_Titles.hxx"
38 #include "res_LegendPosition.hxx"
40 #include "HelpIds.hrc"
42 #include "ChartModelHelper.hxx"
43 #include "AxisHelper.hxx"
44 #include "LegendHelper.hxx"
45 #include "NoWarningThisInCTOR.hxx"
46 #include "ControllerLockGuard.hxx"
48 //.............................................................................
51 //.............................................................................
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::chart2
;
56 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine
* pParent
57 , const uno::Reference
< XChartDocument
>& xChartModel
58 , const uno::Reference
< uno::XComponentContext
>& xContext
)
59 : OWizardPage( pParent
, SchResId(TP_WIZARD_TITLEANDOBJECTS
) )
60 , m_aFT_TitleDescription( this, SchResId( FT_TITLEDESCRIPTION
) )
61 , m_aFL_Vertical( this, SchResId( FL_VERTICAL
) )
62 , m_apTitleResources( new TitleResources(this,false) )
63 , m_apLegendPositionResources( new LegendPositionResources(this,xContext
) )
64 , m_aFL_Grids( this, SchResId( FL_GRIDS
) )
65 , m_aCB_Grid_X( this, SchResId( CB_X_SECONDARY
) )
66 , m_aCB_Grid_Y( this, SchResId( CB_Y_SECONDARY
) )
67 , m_aCB_Grid_Z( this, SchResId( CB_Z_SECONDARY
) )
68 , m_xChartModel( xChartModel
)
70 , m_bCommitToModel( true )
71 , m_aTimerTriggeredControllerLock( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) )
75 this->SetText( String( SchResId( STR_PAGE_CHART_ELEMENTS
) ) );
77 Font
aFont( m_aFT_TitleDescription
.GetControlFont() );
78 aFont
.SetWeight( WEIGHT_BOLD
);
79 m_aFT_TitleDescription
.SetControlFont( aFont
);
81 m_aCB_Grid_X
.SetHelpId( HID_SCH_CB_XGRID
);
82 m_aCB_Grid_Y
.SetHelpId( HID_SCH_CB_YGRID
);
83 m_aCB_Grid_Z
.SetHelpId( HID_SCH_CB_ZGRID
);
85 m_apTitleResources
->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
86 m_apLegendPositionResources
->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
88 m_aCB_Grid_X
.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
89 m_aCB_Grid_Y
.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
90 m_aCB_Grid_Z
.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
93 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
97 void TitlesAndObjectsTabPage::initializePage()
99 m_bCommitToModel
= false;
103 TitleDialogData aTitleInput
;
104 aTitleInput
.readFromModel( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
105 m_apTitleResources
->writeToResources( aTitleInput
);
110 m_apLegendPositionResources
->writeToResources( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
113 //init grid checkboxes
115 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram( m_xChartModel
);
116 uno::Sequence
< sal_Bool
> aPossibilityList
;
117 uno::Sequence
< sal_Bool
> aExistenceList
;
118 AxisHelper::getAxisOrGridPossibilities( aPossibilityList
, xDiagram
, sal_False
);
119 AxisHelper::getAxisOrGridExcistence( aExistenceList
, xDiagram
, sal_False
);
120 m_aCB_Grid_X
.Enable( aPossibilityList
[0] );
121 m_aCB_Grid_Y
.Enable( aPossibilityList
[1] );
122 m_aCB_Grid_Z
.Enable( aPossibilityList
[2] );
123 m_aCB_Grid_X
.Check( aExistenceList
[0] );
124 m_aCB_Grid_Y
.Check( aExistenceList
[1] );
125 m_aCB_Grid_Z
.Check( aExistenceList
[2] );
128 m_bCommitToModel
= true;
131 sal_Bool
TitlesAndObjectsTabPage::commitPage( CommitPageReason
/*eReason*/ )
133 if( m_apTitleResources
->IsModified() ) //titles may have changed in the meanwhile
135 return sal_True
;//return false if this page should not be left
138 void TitlesAndObjectsTabPage::commitToModel()
140 bool bChanged
= false;
142 m_aTimerTriggeredControllerLock
.startTimer();
143 uno::Reference
< frame::XModel
> xModel( m_xChartModel
, uno::UNO_QUERY
);
145 ControllerLockGuard
aLockedControllers( xModel
);
147 //commit title changes to model
149 TitleDialogData aTitleOutput
;
150 m_apTitleResources
->readFromResources( aTitleOutput
);
151 bChanged
= bChanged
|| aTitleOutput
.writeDifferenceToModel( xModel
, m_xCC
);
152 m_apTitleResources
->ClearModifyFlag();
155 //commit legend changes to model
158 m_apLegendPositionResources
->writeToModel( xModel
);
161 //commit grid changes to model
163 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram( xModel
);
164 uno::Sequence
< sal_Bool
> aOldExistenceList
;
165 AxisHelper::getAxisOrGridExcistence( aOldExistenceList
, xDiagram
, sal_False
);
166 uno::Sequence
< sal_Bool
> aNewExistenceList(aOldExistenceList
);
167 aNewExistenceList
[0]=m_aCB_Grid_X
.IsChecked();
168 aNewExistenceList
[1]=m_aCB_Grid_Y
.IsChecked();
169 aNewExistenceList
[2]=m_aCB_Grid_Z
.IsChecked();
170 AxisHelper::changeVisibilityOfGrids( xDiagram
171 , aOldExistenceList
, aNewExistenceList
, m_xCC
);
175 IMPL_LINK( TitlesAndObjectsTabPage
, ChangeHdl
, void *, EMPTYARG
)
177 if( m_bCommitToModel
)
182 bool TitlesAndObjectsTabPage::canAdvance() const
188 //.............................................................................
190 //.............................................................................