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 "dlg_CreationWizard.hxx"
32 #include "dlg_CreationWizard.hrc"
35 #include "Strings.hrc"
36 #include "HelpIds.hrc"
38 #include "tp_ChartType.hxx"
39 #include "tp_RangeChooser.hxx"
40 #include "tp_Wizard_TitlesAndObjects.hxx"
41 #include "tp_Location.hxx"
43 #include "tp_DataSource.hxx"
44 #include "ChartTypeTemplateProvider.hxx"
45 #include "DialogModel.hxx"
47 //.............................................................................
50 //.............................................................................
51 using namespace ::com::sun::star
;
53 //#define LOCATION_PAGE 1
57 #define STATE_CHARTTYPE STATE_FIRST
58 #define STATE_SIMPLE_RANGE 1
59 #define STATE_DATA_SERIES 2
60 #define STATE_OBJECTS 3
61 #define STATE_LOCATION 4
64 #define STATE_LAST STATE_LOCATION
66 #define STATE_LAST STATE_OBJECTS
72 const sal_Int32 nPageCount
= 5;
74 const sal_Int32 nPageCount
= 4;
78 CreationWizard::CreationWizard( Window
* pParent
, const uno::Reference
< frame::XModel
>& xChartModel
79 , const uno::Reference
< uno::XComponentContext
>& xContext
80 , sal_Int32 nOnePageOnlyIndex
)
81 : svt::RoadmapWizard( pParent
, SchResId(DLG_CHART_WIZARD
)
82 , ( nOnePageOnlyIndex
>= 0 && nOnePageOnlyIndex
< nPageCount
)
83 ? WZB_HELP
| WZB_CANCEL
| WZB_FINISH
84 : WZB_HELP
| WZB_CANCEL
| WZB_PREVIOUS
| WZB_NEXT
| WZB_FINISH
86 , m_xChartModel(xChartModel
,uno::UNO_QUERY
)
89 , m_nOnePageOnlyIndex(nOnePageOnlyIndex
)
90 , m_pTemplateProvider(0)
91 , m_nFirstState(STATE_FIRST
)
92 , m_nLastState(STATE_LAST
)
93 , m_aTimerTriggeredControllerLock( xChartModel
)
94 , m_bCanTravel( true )
96 m_apDialogModel
.reset( new DialogModel( m_xChartModel
, m_xCC
));
97 // Do not call FreeResource(), because there are no sub-elements defined in
98 // the dialog resource
99 ShowButtonFixedLine( TRUE
);
100 defaultButton( WZB_FINISH
);
102 if( m_nOnePageOnlyIndex
< 0 || m_nOnePageOnlyIndex
>= nPageCount
)
104 m_nOnePageOnlyIndex
= -1;
105 this->setTitleBase(String(SchResId(STR_DLG_CHART_WIZARD
)));
108 this->setTitleBase(String());
110 declarePath( PATH_FULL
120 this->SetRoadmapSmartHelpId( SmartId( HID_SCH_WIZARD_ROADMAP
) );
121 this->SetRoadmapInteractive( sal_True
);
122 Size
aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT
) );
123 Size
aSize( this->GetSizePixel() );
124 aSize
.Width() += aAdditionalRoadmapSize
.Width();
125 this->SetSizePixel( aSize
);
127 uno::Reference
< chart2::XChartDocument
> xChartDoc( m_xChartModel
, uno::UNO_QUERY
);
128 bool bHasOwnData
= (xChartDoc
.is() && xChartDoc
->hasInternalDataProvider());
132 this->enableState( STATE_SIMPLE_RANGE
, false );
133 this->enableState( STATE_DATA_SERIES
, false );
136 // Call ActivatePage, to create and activate the first page
139 CreationWizard::~CreationWizard()
143 svt::OWizardPage
* CreationWizard::createPage(WizardState nState
)
145 svt::OWizardPage
* pRet
= 0;
146 if(m_nOnePageOnlyIndex
!=-1 && m_nOnePageOnlyIndex
!=nState
)
148 bool bDoLiveUpdate
= m_nOnePageOnlyIndex
== -1;
151 case STATE_CHARTTYPE
:
153 m_aTimerTriggeredControllerLock
.startTimer();
154 ChartTypeTabPage
* pChartTypeTabPage
= new ChartTypeTabPage(this,m_xChartModel
,m_xCC
,bDoLiveUpdate
);
155 pRet
= pChartTypeTabPage
;
156 m_pTemplateProvider
= pChartTypeTabPage
;
157 if( m_pTemplateProvider
&&
158 m_apDialogModel
.get() )
159 m_apDialogModel
->setTemplate( m_pTemplateProvider
->getCurrentTemplate());
162 case STATE_SIMPLE_RANGE
:
164 m_aTimerTriggeredControllerLock
.startTimer();
165 pRet
= new RangeChooserTabPage(this,*(m_apDialogModel
.get()),m_pTemplateProvider
,this);
168 case STATE_DATA_SERIES
:
170 m_aTimerTriggeredControllerLock
.startTimer();
171 pRet
= new DataSourceTabPage(this,*(m_apDialogModel
.get()),m_pTemplateProvider
,this);
176 pRet
= new TitlesAndObjectsTabPage(this,m_xChartModel
,m_xCC
);
177 m_aTimerTriggeredControllerLock
.startTimer();
183 m_aTimerTriggeredControllerLock
.startTimer();
184 pRet
= new LocationTabPage(this,m_xChartModel
,m_xCC
);
192 pRet
->SetText(String());//remove title of pages to not get them in the wizard title
196 sal_Bool
CreationWizard::leaveState( WizardState
/*_nState*/ )
201 svt::WizardTypes::WizardState
CreationWizard::determineNextState( WizardState nCurrentState
) const
204 return WZS_INVALID_STATE
;
205 if( nCurrentState
== m_nLastState
)
206 return WZS_INVALID_STATE
;
207 svt::WizardTypes::WizardState nNextState
= nCurrentState
+ 1;
208 while( !isStateEnabled( nNextState
) && nNextState
<= m_nLastState
)
210 return (nNextState
==m_nLastState
+1) ? WZS_INVALID_STATE
: nNextState
;
212 void CreationWizard::enterState(WizardState nState
)
214 m_aTimerTriggeredControllerLock
.startTimer();
215 enableButtons( WZB_PREVIOUS
, bool( nState
> m_nFirstState
) );
216 enableButtons( WZB_NEXT
, bool( nState
< m_nLastState
) );
217 if( isStateEnabled( nState
))
218 svt::RoadmapWizard::enterState(nState
);
221 bool CreationWizard::isClosable()
224 return m_bIsClosable
;
227 void CreationWizard::setInvalidPage( TabPage
* /* pTabPage */ )
229 m_bCanTravel
= false;
232 void CreationWizard::setValidPage( TabPage
* /* pTabPage */ )
237 String
CreationWizard::getStateDisplayName( WizardState nState
) const
242 case STATE_CHARTTYPE
:
243 nResId
= STR_PAGE_CHARTTYPE
;
245 case STATE_SIMPLE_RANGE
:
246 nResId
= STR_PAGE_DATA_RANGE
;
248 case STATE_DATA_SERIES
:
249 nResId
= STR_OBJECT_DATASERIES_PLURAL
;
252 nResId
= STR_PAGE_CHART_ELEMENTS
;
256 nResId
= STR_PAGE_CHART_LOCATION
;
262 return String(SchResId(nResId
));
265 //.............................................................................
267 //.............................................................................