1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
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"
37 #include "HelpIds.hrc"
39 #include "ChartModelHelper.hxx"
40 #include "AxisHelper.hxx"
41 #include "LegendHelper.hxx"
42 #include "NoWarningThisInCTOR.hxx"
43 #include "ControllerLockGuard.hxx"
45 //.............................................................................
48 //.............................................................................
49 using namespace ::com::sun::star
;
50 using namespace ::com::sun::star::chart2
;
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
)
67 , m_bCommitToModel( true )
68 , m_aTimerTriggeredControllerLock( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) )
72 this->SetText( String( SchResId( STR_PAGE_CHART_ELEMENTS
) ) );
74 Font
aFont( m_aFT_TitleDescription
.GetControlFont() );
75 aFont
.SetWeight( WEIGHT_BOLD
);
76 m_aFT_TitleDescription
.SetControlFont( aFont
);
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
);
82 m_apTitleResources
->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
83 m_apLegendPositionResources
->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
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
));
90 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
94 void TitlesAndObjectsTabPage::initializePage()
96 m_bCommitToModel
= false;
100 TitleDialogData aTitleInput
;
101 aTitleInput
.readFromModel( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
102 m_apTitleResources
->writeToResources( aTitleInput
);
107 m_apLegendPositionResources
->writeToResources( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
110 //init grid checkboxes
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] );
125 m_bCommitToModel
= true;
128 sal_Bool
TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason
/*eReason*/ )
130 if( m_apTitleResources
->IsModified() ) //titles may have changed in the meanwhile
132 return sal_True
;//return false if this page should not be left
135 void TitlesAndObjectsTabPage::commitToModel()
137 bool bChanged
= false;
139 m_aTimerTriggeredControllerLock
.startTimer();
140 uno::Reference
< frame::XModel
> xModel( m_xChartModel
, uno::UNO_QUERY
);
142 ControllerLockGuard
aLockedControllers( xModel
);
144 //commit title changes to model
146 TitleDialogData aTitleOutput
;
147 m_apTitleResources
->readFromResources( aTitleOutput
);
148 bChanged
= bChanged
|| aTitleOutput
.writeDifferenceToModel( xModel
, m_xCC
);
149 m_apTitleResources
->ClearModifyFlag();
152 //commit legend changes to model
155 m_apLegendPositionResources
->writeToModel( xModel
);
158 //commit grid changes to model
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
);
172 IMPL_LINK( TitlesAndObjectsTabPage
, ChangeHdl
, void *, EMPTYARG
)
174 if( m_bCommitToModel
)
179 bool TitlesAndObjectsTabPage::canAdvance() const
185 //.............................................................................
187 //.............................................................................