1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "dlg_CreationWizard.hxx"
#include "dlg_CreationWizard.hrc"
#include "ResId.hxx"
#include "macros.hxx"
#include "Strings.hrc"
#include "HelpIds.hrc"
#include "tp_ChartType.hxx"
#include "tp_RangeChooser.hxx"
#include "tp_Wizard_TitlesAndObjects.hxx"
#include "tp_DataSource.hxx"
#include "ChartTypeTemplateProvider.hxx"
#include "DialogModel.hxx"
//.............................................................................
namespace chart
{
//.............................................................................
using namespace ::com::sun::star;
#define PATH_FULL 1
#define STATE_FIRST 0
#define STATE_CHARTTYPE STATE_FIRST
#define STATE_SIMPLE_RANGE 1
#define STATE_DATA_SERIES 2
#define STATE_OBJECTS 3
#define STATE_LOCATION 4
#define STATE_LAST STATE_OBJECTS
namespace
{
const sal_Int32 nPageCount = 4;
}
CreationWizard::CreationWizard( Window* pParent, const uno::Reference< frame::XModel >& xChartModel
, const uno::Reference< uno::XComponentContext >& xContext
, sal_Int32 nOnePageOnlyIndex )
: svt::RoadmapWizard( pParent, SchResId(DLG_CHART_WIZARD)
, ( nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount )
? WZB_HELP | WZB_CANCEL | WZB_FINISH
: WZB_HELP | WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT | WZB_FINISH
)
, m_xChartModel(xChartModel,uno::UNO_QUERY)
, m_xCC( xContext )
, m_bIsClosable(true)
, m_nOnePageOnlyIndex(nOnePageOnlyIndex)
, m_pTemplateProvider(0)
, m_nFirstState(STATE_FIRST)
, m_nLastState(STATE_LAST)
, m_aTimerTriggeredControllerLock( xChartModel )
, m_bCanTravel( true )
{
m_apDialogModel.reset( new DialogModel( m_xChartModel, m_xCC ));
// Do not call FreeResource(), because there are no sub-elements defined in
// the dialog resource
ShowButtonFixedLine( sal_True );
defaultButton( WZB_FINISH );
if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount )
{
m_nOnePageOnlyIndex = -1;
this->setTitleBase(String(SchResId(STR_DLG_CHART_WIZARD)));
}
else
this->setTitleBase(String());
declarePath( PATH_FULL
, STATE_CHARTTYPE
, STATE_SIMPLE_RANGE
, STATE_DATA_SERIES
, STATE_OBJECTS
, WZS_INVALID_STATE
);
this->SetRoadmapHelpId( HID_SCH_WIZARD_ROADMAP );
this->SetRoadmapInteractive( sal_True );
Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
Size aSize( this->GetSizePixel() );
aSize.Width() += aAdditionalRoadmapSize.Width();
this->SetSizePixel( aSize );
uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
if( bHasOwnData )
{
this->enableState( STATE_SIMPLE_RANGE, false );
this->enableState( STATE_DATA_SERIES, false );
}
// Call ActivatePage, to create and activate the first page
ActivatePage();
}
CreationWizard::~CreationWizard()
{
}
svt::OWizardPage* CreationWizard::createPage(WizardState nState)
{
svt::OWizardPage* pRet = 0;
if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState)
return pRet;
bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1;
switch( nState )
{
case STATE_CHARTTYPE:
{
m_aTimerTriggeredControllerLock.startTimer();
ChartTypeTabPage* pChartTypeTabPage = new ChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate);
pRet = pChartTypeTabPage;
m_pTemplateProvider = pChartTypeTabPage;
if( m_pTemplateProvider &&
m_apDialogModel.get() )
m_apDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
}
break;
case STATE_SIMPLE_RANGE:
{
m_aTimerTriggeredControllerLock.startTimer();
pRet = new RangeChooserTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this);
}
break;
case STATE_DATA_SERIES:
{
m_aTimerTriggeredControllerLock.startTimer();
pRet = new DataSourceTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this);
}
break;
case STATE_OBJECTS:
{
pRet = new TitlesAndObjectsTabPage(this,m_xChartModel,m_xCC);
m_aTimerTriggeredControllerLock.startTimer();
}
break;
default:
break;
}
if(pRet)
pRet->SetText(String());//remove title of pages to not get them in the wizard title
return pRet;
}
sal_Bool CreationWizard::leaveState( WizardState /*_nState*/ )
{
return m_bCanTravel;
}
svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
{
if( !m_bCanTravel )
return WZS_INVALID_STATE;
if( nCurrentState == m_nLastState )
return WZS_INVALID_STATE;
svt::WizardTypes::WizardState nNextState = nCurrentState + 1;
while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState )
++nNextState;
return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState;
}
void CreationWizard::enterState(WizardState nState)
{
m_aTimerTriggeredControllerLock.startTimer();
enableButtons( WZB_PREVIOUS, bool( nState > m_nFirstState ) );
enableButtons( WZB_NEXT, bool( nState < m_nLastState ) );
if( isStateEnabled( nState ))
svt::RoadmapWizard::enterState(nState);
}
bool CreationWizard::isClosable()
{
//@todo
return m_bIsClosable;
}
void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ )
{
m_bCanTravel = false;
}
void CreationWizard::setValidPage( TabPage * /* pTabPage */ )
{
m_bCanTravel = true;
}
String CreationWizard::getStateDisplayName( WizardState nState ) const
{
sal_uInt16 nResId = 0;
switch( nState )
{
case STATE_CHARTTYPE:
nResId = STR_PAGE_CHARTTYPE;
break;
case STATE_SIMPLE_RANGE:
nResId = STR_PAGE_DATA_RANGE;
break;
case STATE_DATA_SERIES:
nResId = STR_OBJECT_DATASERIES_PLURAL;
break;
case STATE_OBJECTS:
nResId = STR_PAGE_CHART_ELEMENTS;
break;
default:
break;
}
return String(SchResId(nResId));
}
//.............................................................................
} //namespace chart
//.............................................................................
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|