vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / chart2 / source / controller / dialogs / dlg_CreationWizard.cxx
blobccf2cdc5221fe844e6d95ffc4c83577e43fe233d
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 <strings.hrc>
23 #include <helpids.h>
24 #include <ChartModel.hxx>
25 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
27 #include "tp_ChartType.hxx"
28 #include "tp_RangeChooser.hxx"
29 #include "tp_Wizard_TitlesAndObjects.hxx"
30 #include "tp_DataSource.hxx"
31 #include <ChartTypeTemplateProvider.hxx>
32 #include "DialogModel.hxx"
34 using namespace css;
36 using vcl::RoadmapWizardTypes::WizardPath;
38 namespace chart
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 CreationWizard::CreationWizard(weld::Window* pParent, const uno::Reference<frame::XModel>& xChartModel,
49 const uno::Reference<uno::XComponentContext>& xContext)
50 : vcl::RoadmapWizardMachine(pParent)
51 , m_xChartModel(xChartModel,uno::UNO_QUERY)
52 , m_xComponentContext(xContext)
53 , m_pTemplateProvider(nullptr)
54 , m_aTimerTriggeredControllerLock(xChartModel)
55 , m_bCanTravel(true)
57 m_pDialogModel.reset(new DialogModel(m_xChartModel, m_xComponentContext));
58 defaultButton(WizardButtonFlags::FINISH);
60 setTitleBase(SchResId(STR_DLG_CHART_WIZARD));
62 WizardPath aPath = {
63 STATE_CHARTTYPE,
64 STATE_SIMPLE_RANGE,
65 STATE_DATA_SERIES,
66 STATE_OBJECTS
69 declarePath(PATH_FULL, aPath);
71 SetRoadmapHelpId(HID_SCH_WIZARD_ROADMAP);
73 if (!m_pDialogModel->getModel().isDataFromSpreadsheet())
75 enableState(STATE_SIMPLE_RANGE, false);
76 enableState(STATE_DATA_SERIES, false);
79 // Call ActivatePage, to create and activate the first page
80 ActivatePage();
82 m_xAssistant->set_current_page(0);
85 CreationWizard::~CreationWizard() = default;
87 std::unique_ptr<BuilderPage> CreationWizard::createPage(WizardState nState)
89 std::unique_ptr<vcl::OWizardPage> xRet;
91 OString sIdent(OString::number(nState));
92 weld::Container* pPageContainer = m_xAssistant->append_page(sIdent);
94 switch( nState )
96 case STATE_CHARTTYPE:
98 m_aTimerTriggeredControllerLock.startTimer();
99 xRet = std::make_unique<ChartTypeTabPage>(pPageContainer, this, m_xChartModel);
100 m_pTemplateProvider = static_cast<ChartTypeTabPage*>(xRet.get());
101 if (m_pDialogModel)
102 m_pDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
103 break;
105 case STATE_SIMPLE_RANGE:
107 m_aTimerTriggeredControllerLock.startTimer();
108 xRet = std::make_unique<RangeChooserTabPage>(pPageContainer, this, *m_pDialogModel, m_pTemplateProvider);
109 break;
111 case STATE_DATA_SERIES:
113 m_aTimerTriggeredControllerLock.startTimer();
114 xRet = std::make_unique<DataSourceTabPage>(pPageContainer, this, *m_pDialogModel, m_pTemplateProvider);
115 break;
117 case STATE_OBJECTS:
119 xRet = std::make_unique<TitlesAndObjectsTabPage>(pPageContainer, this, m_xChartModel, m_xComponentContext);
120 m_aTimerTriggeredControllerLock.startTimer();
121 break;
123 default:
124 break;
127 if (xRet)
128 xRet->SetPageTitle(OUString()); //remove title of pages to not get them in the wizard title
130 return xRet;
133 bool CreationWizard::leaveState( WizardState /*_nState*/ )
135 return m_bCanTravel;
138 vcl::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
140 if( !m_bCanTravel )
141 return WZS_INVALID_STATE;
142 if( nCurrentState == STATE_LAST )
143 return WZS_INVALID_STATE;
144 vcl::WizardTypes::WizardState nNextState = nCurrentState + 1;
145 while( !isStateEnabled( nNextState ) && nNextState <= STATE_LAST )
146 ++nNextState;
147 return (nNextState==STATE_LAST+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 < STATE_LAST );
155 if( isStateEnabled( nState ))
156 vcl::RoadmapWizardMachine::enterState(nState);
159 void CreationWizard::setInvalidPage(BuilderPage* pTabPage)
161 if (pTabPage == m_pCurTabPage)
162 m_bCanTravel = false;
165 void CreationWizard::setValidPage(BuilderPage* pTabPage)
167 if (pTabPage == m_pCurTabPage)
168 m_bCanTravel = true;
171 OUString CreationWizard::getStateDisplayName( WizardState nState ) const
173 const char* pResId = nullptr;
174 switch( nState )
176 case STATE_CHARTTYPE:
177 pResId = STR_PAGE_CHARTTYPE;
178 break;
179 case STATE_SIMPLE_RANGE:
180 pResId = STR_PAGE_DATA_RANGE;
181 break;
182 case STATE_DATA_SERIES:
183 pResId = STR_OBJECT_DATASERIES_PLURAL;
184 break;
185 case STATE_OBJECTS:
186 pResId = STR_PAGE_CHART_ELEMENTS;
187 break;
188 default:
189 break;
191 if (!pResId)
192 return OUString();
193 return SchResId(pResId);
196 } //namespace chart
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */