fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / dialogs / dlg_CreationWizard.cxx
blobfbf84d89374181dd93d76c1a36538fd3dfb54412
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "dlg_CreationWizard.hxx"
21 #include "ResId.hxx"
22 #include "macros.hxx"
23 #include "Strings.hrc"
24 #include "HelpIds.hrc"
26 #include "tp_ChartType.hxx"
27 #include "tp_RangeChooser.hxx"
28 #include "tp_Wizard_TitlesAndObjects.hxx"
29 #include "tp_DataSource.hxx"
30 #include "ChartTypeTemplateProvider.hxx"
31 #include "DialogModel.hxx"
33 #define CHART_WIZARD_PAGEWIDTH 250
34 #define CHART_WIZARD_PAGEHEIGHT 170
36 namespace chart
38 using namespace ::com::sun::star;
40 #define PATH_FULL 1
41 #define STATE_FIRST 0
42 #define STATE_CHARTTYPE STATE_FIRST
43 #define STATE_SIMPLE_RANGE 1
44 #define STATE_DATA_SERIES 2
45 #define STATE_OBJECTS 3
46 #define STATE_LAST STATE_OBJECTS
48 namespace
50 const sal_Int32 nPageCount = 4;
53 CreationWizard::CreationWizard( vcl::Window* pParent, const uno::Reference< frame::XModel >& xChartModel
54 , const uno::Reference< uno::XComponentContext >& xContext
55 , sal_Int32 nOnePageOnlyIndex )
56 : svt::RoadmapWizard( pParent,
57 (nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount)
58 ? WizardButtonFlags::HELP | WizardButtonFlags::CANCEL | WizardButtonFlags::FINISH
59 : WizardButtonFlags::HELP | WizardButtonFlags::CANCEL | WizardButtonFlags::PREVIOUS | WizardButtonFlags::NEXT | WizardButtonFlags::FINISH
61 , m_xChartModel(xChartModel,uno::UNO_QUERY)
62 , m_xCC( xContext )
63 , m_bIsClosable(true)
64 , m_nOnePageOnlyIndex(nOnePageOnlyIndex)
65 , m_pTemplateProvider(0)
66 , m_nFirstState(STATE_FIRST)
67 , m_nLastState(STATE_LAST)
68 , m_aTimerTriggeredControllerLock( xChartModel )
69 , m_bCanTravel( true )
71 m_pDialogModel.reset( new DialogModel( m_xChartModel, m_xCC ));
72 defaultButton( WizardButtonFlags::FINISH );
74 if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount )
76 m_nOnePageOnlyIndex = -1;
77 this->setTitleBase(SCH_RESSTR(STR_DLG_CHART_WIZARD));
79 else
80 this->setTitleBase(OUString());
82 declarePath( PATH_FULL
83 , STATE_CHARTTYPE
84 , STATE_SIMPLE_RANGE
85 , STATE_DATA_SERIES
86 , STATE_OBJECTS
87 , WZS_INVALID_STATE
89 this->SetRoadmapHelpId( HID_SCH_WIZARD_ROADMAP );
90 this->SetRoadmapInteractive( true );
91 Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
92 Size aSize(LogicToPixel(Size(CHART_WIZARD_PAGEWIDTH, CHART_WIZARD_PAGEHEIGHT), MAP_APPFONT));
93 aSize.Width() += aAdditionalRoadmapSize.Width();
94 this->SetSizePixel( aSize );
96 uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
97 bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
99 if( bHasOwnData )
101 this->enableState( STATE_SIMPLE_RANGE, false );
102 this->enableState( STATE_DATA_SERIES, false );
105 // Call ActivatePage, to create and activate the first page
106 ActivatePage();
109 VclPtr<TabPage> CreationWizard::createPage(WizardState nState)
111 VclPtr<svt::OWizardPage> pRet;
112 if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState)
113 return pRet;
114 bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1;
115 switch( nState )
117 case STATE_CHARTTYPE:
119 m_aTimerTriggeredControllerLock.startTimer();
120 VclPtrInstance<ChartTypeTabPage> pChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate);
121 pRet = pChartTypeTabPage;
122 m_pTemplateProvider = pChartTypeTabPage;
123 if (m_pDialogModel)
124 m_pDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
126 break;
127 case STATE_SIMPLE_RANGE:
129 m_aTimerTriggeredControllerLock.startTimer();
130 pRet = VclPtr<RangeChooserTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this);
132 break;
133 case STATE_DATA_SERIES:
135 m_aTimerTriggeredControllerLock.startTimer();
136 pRet = VclPtr<DataSourceTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this);
138 break;
139 case STATE_OBJECTS:
141 pRet = VclPtr<TitlesAndObjectsTabPage>::Create(this,m_xChartModel,m_xCC);
142 m_aTimerTriggeredControllerLock.startTimer();
144 break;
145 default:
146 break;
148 if(pRet)
149 pRet->SetText(OUString());//remove title of pages to not get them in the wizard title
150 return pRet;
153 bool CreationWizard::leaveState( WizardState /*_nState*/ )
155 return m_bCanTravel;
158 svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
160 if( !m_bCanTravel )
161 return WZS_INVALID_STATE;
162 if( nCurrentState == m_nLastState )
163 return WZS_INVALID_STATE;
164 svt::WizardTypes::WizardState nNextState = nCurrentState + 1;
165 while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState )
166 ++nNextState;
167 return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState;
169 void CreationWizard::enterState(WizardState nState)
171 m_aTimerTriggeredControllerLock.startTimer();
172 enableButtons( WizardButtonFlags::PREVIOUS, bool( nState > m_nFirstState ) );
173 enableButtons( WizardButtonFlags::NEXT, bool( nState < m_nLastState ) );
174 if( isStateEnabled( nState ))
175 svt::RoadmapWizard::enterState(nState);
178 void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ )
180 m_bCanTravel = false;
183 void CreationWizard::setValidPage( TabPage * /* pTabPage */ )
185 m_bCanTravel = true;
188 OUString CreationWizard::getStateDisplayName( WizardState nState ) const
190 sal_uInt16 nResId = 0;
191 switch( nState )
193 case STATE_CHARTTYPE:
194 nResId = STR_PAGE_CHARTTYPE;
195 break;
196 case STATE_SIMPLE_RANGE:
197 nResId = STR_PAGE_DATA_RANGE;
198 break;
199 case STATE_DATA_SERIES:
200 nResId = STR_OBJECT_DATASERIES_PLURAL;
201 break;
202 case STATE_OBJECTS:
203 nResId = STR_PAGE_CHART_ELEMENTS;
204 break;
205 default:
206 break;
208 return SCH_RESSTR(nResId);
211 } //namespace chart
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */