1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
22 #include <strings.hrc>
25 #include "tp_ChartType.hxx"
26 #include "tp_RangeChooser.hxx"
27 #include "tp_Wizard_TitlesAndObjects.hxx"
28 #include "tp_DataSource.hxx"
29 #include "ChartTypeTemplateProvider.hxx"
30 #include "DialogModel.hxx"
32 #define CHART_WIZARD_PAGEWIDTH 250
33 #define CHART_WIZARD_PAGEHEIGHT 170
41 #define STATE_CHARTTYPE STATE_FIRST
42 #define STATE_SIMPLE_RANGE 1
43 #define STATE_DATA_SERIES 2
44 #define STATE_OBJECTS 3
45 #define STATE_LAST STATE_OBJECTS
47 CreationWizard::CreationWizard(vcl::Window
* pParent
, const uno::Reference
<frame::XModel
>& xChartModel
,
48 const uno::Reference
<uno::XComponentContext
>& xContext
)
49 : svt::RoadmapWizard(pParent
)
50 , m_xChartModel(xChartModel
,uno::UNO_QUERY
)
51 , m_xComponentContext(xContext
)
52 , m_pTemplateProvider(nullptr)
53 , m_nLastState(STATE_LAST
)
54 , m_aTimerTriggeredControllerLock(xChartModel
)
57 m_pDialogModel
.reset(new DialogModel(m_xChartModel
, m_xComponentContext
));
58 defaultButton(WizardButtonFlags::FINISH
);
60 setTitleBase(SchResId(STR_DLG_CHART_WIZARD
));
69 declarePath(PATH_FULL
, aPath
);
71 SetRoadmapHelpId(HID_SCH_WIZARD_ROADMAP
);
72 SetRoadmapInteractive(true);
74 Size
aAdditionalRoadmapSize(LogicToPixel(Size(85, 0), MapMode(MapUnit::MapAppFont
)));
75 Size
aSize(LogicToPixel(Size(CHART_WIZARD_PAGEWIDTH
, CHART_WIZARD_PAGEHEIGHT
), MapMode(MapUnit::MapAppFont
)));
76 aSize
.AdjustWidth(aAdditionalRoadmapSize
.Width() );
79 if (!m_pDialogModel
->getModel().isDataFromSpreadsheet())
81 enableState(STATE_SIMPLE_RANGE
, false);
82 enableState(STATE_DATA_SERIES
, false);
85 // Call ActivatePage, to create and activate the first page
89 CreationWizard::~CreationWizard() = default;
91 VclPtr
<TabPage
> CreationWizard::createPage(WizardState nState
)
93 VclPtr
<svt::OWizardPage
> pRet
;
98 m_aTimerTriggeredControllerLock
.startTimer();
99 VclPtrInstance
<ChartTypeTabPage
> pChartTypeTabPage(this,m_xChartModel
);
100 pRet
= pChartTypeTabPage
;
101 m_pTemplateProvider
= pChartTypeTabPage
;
103 m_pDialogModel
->setTemplate( m_pTemplateProvider
->getCurrentTemplate());
106 case STATE_SIMPLE_RANGE
:
108 m_aTimerTriggeredControllerLock
.startTimer();
109 pRet
= VclPtr
<RangeChooserTabPage
>::Create(this, *m_pDialogModel
, m_pTemplateProvider
, this);
112 case STATE_DATA_SERIES
:
114 m_aTimerTriggeredControllerLock
.startTimer();
115 pRet
= VclPtr
<DataSourceTabPage
>::Create(this, *m_pDialogModel
, m_pTemplateProvider
, this);
120 pRet
= VclPtr
<TitlesAndObjectsTabPage
>::Create(this,m_xChartModel
, m_xComponentContext
);
121 m_aTimerTriggeredControllerLock
.startTimer();
129 pRet
->SetText(OUString()); //remove title of pages to not get them in the wizard title
134 bool CreationWizard::leaveState( WizardState
/*_nState*/ )
139 svt::WizardTypes::WizardState
CreationWizard::determineNextState( WizardState nCurrentState
) const
142 return WZS_INVALID_STATE
;
143 if( nCurrentState
== m_nLastState
)
144 return WZS_INVALID_STATE
;
145 svt::WizardTypes::WizardState nNextState
= nCurrentState
+ 1;
146 while( !isStateEnabled( nNextState
) && nNextState
<= m_nLastState
)
148 return (nNextState
==m_nLastState
+1) ? WZS_INVALID_STATE
: nNextState
;
150 void CreationWizard::enterState(WizardState nState
)
152 m_aTimerTriggeredControllerLock
.startTimer();
153 enableButtons( WizardButtonFlags::PREVIOUS
, nState
> STATE_FIRST
);
154 enableButtons( WizardButtonFlags::NEXT
, nState
< m_nLastState
);
155 if( isStateEnabled( nState
))
156 svt::RoadmapWizard::enterState(nState
);
159 void CreationWizard::setInvalidPage( TabPage
* /* pTabPage */ )
161 m_bCanTravel
= false;
164 void CreationWizard::setValidPage( TabPage
* /* pTabPage */ )
169 OUString
CreationWizard::getStateDisplayName( WizardState nState
) const
171 const char* pResId
= nullptr;
174 case STATE_CHARTTYPE
:
175 pResId
= STR_PAGE_CHARTTYPE
;
177 case STATE_SIMPLE_RANGE
:
178 pResId
= STR_PAGE_DATA_RANGE
;
180 case STATE_DATA_SERIES
:
181 pResId
= STR_OBJECT_DATASERIES_PLURAL
;
184 pResId
= STR_PAGE_CHART_ELEMENTS
;
191 return SchResId(pResId
);
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */