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: dlg_CreationWizard.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 "dlg_CreationWizard.hxx"
35 #include "dlg_CreationWizard.hrc"
38 #include "Strings.hrc"
39 #include "HelpIds.hrc"
41 #include "tp_ChartType.hxx"
42 #include "tp_RangeChooser.hxx"
43 #include "tp_Wizard_TitlesAndObjects.hxx"
44 #include "tp_Location.hxx"
46 #include "tp_DataSource.hxx"
47 #include "ChartTypeTemplateProvider.hxx"
48 #include "DialogModel.hxx"
50 //.............................................................................
53 //.............................................................................
54 using namespace ::com::sun::star
;
56 //#define LOCATION_PAGE 1
60 #define STATE_CHARTTYPE STATE_FIRST
61 #define STATE_SIMPLE_RANGE 1
62 #define STATE_DATA_SERIES 2
63 #define STATE_OBJECTS 3
64 #define STATE_LOCATION 4
67 #define STATE_LAST STATE_LOCATION
69 #define STATE_LAST STATE_OBJECTS
75 const sal_Int32 nPageCount
= 5;
77 const sal_Int32 nPageCount
= 4;
81 CreationWizard::CreationWizard( Window
* pParent
, const uno::Reference
< frame::XModel
>& xChartModel
82 , const uno::Reference
< uno::XComponentContext
>& xContext
83 , sal_Int32 nOnePageOnlyIndex
)
84 : svt::RoadmapWizard( pParent
, SchResId(DLG_CHART_WIZARD
)
85 , ( nOnePageOnlyIndex
>= 0 && nOnePageOnlyIndex
< nPageCount
)
86 ? WZB_HELP
| WZB_CANCEL
| WZB_FINISH
87 : WZB_HELP
| WZB_CANCEL
| WZB_PREVIOUS
| WZB_NEXT
| WZB_FINISH
89 , m_xChartModel(xChartModel
,uno::UNO_QUERY
)
92 , m_nOnePageOnlyIndex(nOnePageOnlyIndex
)
93 , m_pTemplateProvider(0)
94 , m_nFirstState(STATE_FIRST
)
95 , m_nLastState(STATE_LAST
)
96 , m_aTimerTriggeredControllerLock( xChartModel
)
97 , m_bCanTravel( true )
99 m_apDialogModel
.reset( new DialogModel( m_xChartModel
, m_xCC
));
100 // Do not call FreeResource(), because there are no sub-elements defined in
101 // the dialog resource
102 ShowButtonFixedLine( TRUE
);
103 defaultButton( WZB_FINISH
);
105 if( m_nOnePageOnlyIndex
< 0 || m_nOnePageOnlyIndex
>= nPageCount
)
107 m_nOnePageOnlyIndex
= -1;
108 this->setTitleBase(String(SchResId(STR_DLG_CHART_WIZARD
)));
111 this->setTitleBase(String());
113 declarePath( PATH_FULL
123 this->SetRoadmapSmartHelpId( SmartId( HID_SCH_WIZARD_ROADMAP
) );
124 this->SetRoadmapInteractive( sal_True
);
125 Size
aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT
) );
126 Size
aSize( this->GetSizePixel() );
127 aSize
.Width() += aAdditionalRoadmapSize
.Width();
128 this->SetSizePixel( aSize
);
130 uno::Reference
< chart2::XChartDocument
> xChartDoc( m_xChartModel
, uno::UNO_QUERY
);
131 bool bHasOwnData
= (xChartDoc
.is() && xChartDoc
->hasInternalDataProvider());
135 this->enableState( STATE_SIMPLE_RANGE
, false );
136 this->enableState( STATE_DATA_SERIES
, false );
139 // Call ActivatePage, to create and activate the first page
142 CreationWizard::~CreationWizard()
146 svt::OWizardPage
* CreationWizard::createPage(WizardState nState
)
148 svt::OWizardPage
* pRet
= 0;
149 if(m_nOnePageOnlyIndex
!=-1 && m_nOnePageOnlyIndex
!=nState
)
151 bool bDoLiveUpdate
= m_nOnePageOnlyIndex
== -1;
154 case STATE_CHARTTYPE
:
156 m_aTimerTriggeredControllerLock
.startTimer();
157 ChartTypeTabPage
* pChartTypeTabPage
= new ChartTypeTabPage(this,m_xChartModel
,m_xCC
,bDoLiveUpdate
);
158 pRet
= pChartTypeTabPage
;
159 m_pTemplateProvider
= pChartTypeTabPage
;
160 if( m_pTemplateProvider
&&
161 m_apDialogModel
.get() )
162 m_apDialogModel
->setTemplate( m_pTemplateProvider
->getCurrentTemplate());
165 case STATE_SIMPLE_RANGE
:
167 m_aTimerTriggeredControllerLock
.startTimer();
168 pRet
= new RangeChooserTabPage(this,*(m_apDialogModel
.get()),m_pTemplateProvider
,this);
171 case STATE_DATA_SERIES
:
173 m_aTimerTriggeredControllerLock
.startTimer();
174 pRet
= new DataSourceTabPage(this,*(m_apDialogModel
.get()),m_pTemplateProvider
,this);
179 pRet
= new TitlesAndObjectsTabPage(this,m_xChartModel
,m_xCC
);
180 m_aTimerTriggeredControllerLock
.startTimer();
186 m_aTimerTriggeredControllerLock
.startTimer();
187 pRet
= new LocationTabPage(this,m_xChartModel
,m_xCC
);
195 pRet
->SetText(String());//remove title of pages to not get them in the wizard title
199 sal_Bool
CreationWizard::leaveState( WizardState
/*_nState*/ )
204 svt::WizardTypes::WizardState
CreationWizard::determineNextState( WizardState nCurrentState
) const
207 return WZS_INVALID_STATE
;
208 if( nCurrentState
== m_nLastState
)
209 return WZS_INVALID_STATE
;
210 svt::WizardTypes::WizardState nNextState
= nCurrentState
+ 1;
211 while( !isStateEnabled( nNextState
) && nNextState
<= m_nLastState
)
213 return (nNextState
==m_nLastState
+1) ? WZS_INVALID_STATE
: nNextState
;
215 void CreationWizard::enterState(WizardState nState
)
217 m_aTimerTriggeredControllerLock
.startTimer();
218 enableButtons( WZB_PREVIOUS
, bool( nState
> m_nFirstState
) );
219 enableButtons( WZB_NEXT
, bool( nState
< m_nLastState
) );
220 if( isStateEnabled( nState
))
221 svt::RoadmapWizard::enterState(nState
);
224 bool CreationWizard::isClosable()
227 return m_bIsClosable
;
230 void CreationWizard::setInvalidPage( TabPage
* /* pTabPage */ )
232 m_bCanTravel
= false;
235 void CreationWizard::setValidPage( TabPage
* /* pTabPage */ )
240 String
CreationWizard::getStateDisplayName( WizardState nState
) const
245 case STATE_CHARTTYPE
:
246 nResId
= STR_PAGE_CHARTTYPE
;
248 case STATE_SIMPLE_RANGE
:
249 nResId
= STR_PAGE_DATA_RANGE
;
251 case STATE_DATA_SERIES
:
252 nResId
= STR_OBJECT_DATASERIES_PLURAL
;
255 nResId
= STR_PAGE_CHART_ELEMENTS
;
259 nResId
= STR_PAGE_CHART_LOCATION
;
265 return String(SchResId(nResId
));
268 //.............................................................................
270 //.............................................................................