LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - dlg_CreationWizard.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 92 0.0 %
Date: 2014-04-14 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "dlg_CreationWizard.hxx"
      21             : #include "dlg_CreationWizard.hrc"
      22             : #include "ResId.hxx"
      23             : #include "macros.hxx"
      24             : #include "Strings.hrc"
      25             : #include "HelpIds.hrc"
      26             : 
      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"
      33             : 
      34             : namespace chart
      35             : {
      36             : using namespace ::com::sun::star;
      37             : 
      38             : #define PATH_FULL   1
      39             : #define STATE_FIRST        0
      40             : #define STATE_CHARTTYPE    STATE_FIRST
      41             : #define STATE_SIMPLE_RANGE 1
      42             : #define STATE_DATA_SERIES  2
      43             : #define STATE_OBJECTS      3
      44             : #define STATE_LAST         STATE_OBJECTS
      45             : 
      46             : namespace
      47             : {
      48             :     const sal_Int32 nPageCount = 4;
      49             : }
      50             : 
      51           0 : CreationWizard::CreationWizard( Window* pParent, const uno::Reference< frame::XModel >& xChartModel
      52             :                                , const uno::Reference< uno::XComponentContext >& xContext
      53             :                                , sal_Int32 nOnePageOnlyIndex )
      54             :                 : svt::RoadmapWizard( pParent, SchResId(DLG_CHART_WIZARD)
      55           0 :                     , ( nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount )
      56             :                         ?  WZB_HELP | WZB_CANCEL | WZB_FINISH
      57             :                         :  WZB_HELP | WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT | WZB_FINISH
      58             :                   )
      59             :                 , m_xChartModel(xChartModel,uno::UNO_QUERY)
      60             :                 , m_xCC( xContext )
      61             :                 , m_bIsClosable(true)
      62             :                 , m_nOnePageOnlyIndex(nOnePageOnlyIndex)
      63             :                 , m_pTemplateProvider(0)
      64             :                 , m_nFirstState(STATE_FIRST)
      65             :                 , m_nLastState(STATE_LAST)
      66             :                 , m_aTimerTriggeredControllerLock( xChartModel )
      67           0 :                 , m_bCanTravel( true )
      68             : {
      69           0 :     m_apDialogModel.reset( new DialogModel( m_xChartModel, m_xCC ));
      70             :     // Do not call FreeResource(), because there are no sub-elements defined in
      71             :     // the dialog resource
      72           0 :     ShowButtonFixedLine( true );
      73           0 :     defaultButton( WZB_FINISH );
      74             : 
      75           0 :     if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount )
      76             :     {
      77           0 :         m_nOnePageOnlyIndex = -1;
      78           0 :         this->setTitleBase(SCH_RESSTR(STR_DLG_CHART_WIZARD));
      79             :     }
      80             :     else
      81           0 :         this->setTitleBase(OUString());
      82             : 
      83             :     declarePath( PATH_FULL
      84             :         , STATE_CHARTTYPE
      85             :         , STATE_SIMPLE_RANGE
      86             :         , STATE_DATA_SERIES
      87             :         , STATE_OBJECTS
      88             :         , WZS_INVALID_STATE
      89           0 :     );
      90           0 :     this->SetRoadmapHelpId( HID_SCH_WIZARD_ROADMAP );
      91           0 :     this->SetRoadmapInteractive( true );
      92           0 :     Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
      93           0 :     Size aSize( this->GetSizePixel() );
      94           0 :     aSize.Width() += aAdditionalRoadmapSize.Width();
      95           0 :     this->SetSizePixel( aSize );
      96             : 
      97           0 :     uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
      98           0 :     bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
      99             : 
     100           0 :     if( bHasOwnData )
     101             :     {
     102           0 :         this->enableState( STATE_SIMPLE_RANGE, false );
     103           0 :         this->enableState( STATE_DATA_SERIES, false );
     104             :     }
     105             : 
     106             :     // Call ActivatePage, to create and activate the first page
     107           0 :     ActivatePage();
     108           0 : }
     109           0 : CreationWizard::~CreationWizard()
     110             : {
     111           0 : }
     112             : 
     113           0 : svt::OWizardPage* CreationWizard::createPage(WizardState nState)
     114             : {
     115           0 :     svt::OWizardPage* pRet = 0;
     116           0 :     if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState)
     117           0 :         return pRet;
     118           0 :     bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1;
     119           0 :     switch( nState )
     120             :     {
     121             :     case STATE_CHARTTYPE:
     122             :         {
     123           0 :         m_aTimerTriggeredControllerLock.startTimer();
     124           0 :         ChartTypeTabPage* pChartTypeTabPage = new ChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate);
     125           0 :         pRet  = pChartTypeTabPage;
     126           0 :         m_pTemplateProvider = pChartTypeTabPage;
     127           0 :         if( m_pTemplateProvider &&
     128           0 :             m_apDialogModel.get() )
     129           0 :             m_apDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
     130             :         }
     131           0 :         break;
     132             :     case STATE_SIMPLE_RANGE:
     133             :         {
     134           0 :         m_aTimerTriggeredControllerLock.startTimer();
     135           0 :         pRet = new RangeChooserTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this);
     136             :         }
     137           0 :         break;
     138             :     case STATE_DATA_SERIES:
     139             :         {
     140           0 :         m_aTimerTriggeredControllerLock.startTimer();
     141           0 :         pRet = new DataSourceTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this);
     142             :         }
     143           0 :         break;
     144             :     case STATE_OBJECTS:
     145             :         {
     146           0 :         pRet  = new TitlesAndObjectsTabPage(this,m_xChartModel,m_xCC);
     147           0 :         m_aTimerTriggeredControllerLock.startTimer();
     148             :         }
     149           0 :         break;
     150             :     default:
     151           0 :         break;
     152             :     }
     153           0 :     if(pRet)
     154           0 :         pRet->SetText(OUString());//remove title of pages to not get them in the wizard title
     155           0 :     return pRet;
     156             : }
     157             : 
     158           0 : bool CreationWizard::leaveState( WizardState /*_nState*/ )
     159             : {
     160           0 :     return m_bCanTravel;
     161             : }
     162             : 
     163           0 : svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
     164             : {
     165           0 :     if( !m_bCanTravel )
     166           0 :         return WZS_INVALID_STATE;
     167           0 :     if( nCurrentState == m_nLastState )
     168           0 :         return WZS_INVALID_STATE;
     169           0 :     svt::WizardTypes::WizardState nNextState = nCurrentState + 1;
     170           0 :     while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState )
     171           0 :         ++nNextState;
     172           0 :     return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState;
     173             : }
     174           0 : void CreationWizard::enterState(WizardState nState)
     175             : {
     176           0 :     m_aTimerTriggeredControllerLock.startTimer();
     177           0 :     enableButtons( WZB_PREVIOUS, bool( nState > m_nFirstState ) );
     178           0 :     enableButtons( WZB_NEXT, bool( nState < m_nLastState ) );
     179           0 :     if( isStateEnabled( nState ))
     180           0 :         svt::RoadmapWizard::enterState(nState);
     181           0 : }
     182             : 
     183           0 : bool CreationWizard::isClosable()
     184             : {
     185             :     //@todo
     186           0 :     return m_bIsClosable;
     187             : }
     188             : 
     189           0 : void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ )
     190             : {
     191           0 :     m_bCanTravel = false;
     192           0 : }
     193             : 
     194           0 : void CreationWizard::setValidPage( TabPage * /* pTabPage */ )
     195             : {
     196           0 :     m_bCanTravel = true;
     197           0 : }
     198             : 
     199           0 : OUString CreationWizard::getStateDisplayName( WizardState nState ) const
     200             : {
     201           0 :     sal_uInt16 nResId = 0;
     202           0 :     switch( nState )
     203             :     {
     204             :     case STATE_CHARTTYPE:
     205           0 :         nResId = STR_PAGE_CHARTTYPE;
     206           0 :         break;
     207             :     case STATE_SIMPLE_RANGE:
     208           0 :         nResId = STR_PAGE_DATA_RANGE;
     209           0 :         break;
     210             :     case STATE_DATA_SERIES:
     211           0 :         nResId = STR_OBJECT_DATASERIES_PLURAL;
     212           0 :         break;
     213             :     case STATE_OBJECTS:
     214           0 :         nResId = STR_PAGE_CHART_ELEMENTS;
     215           0 :         break;
     216             :     default:
     217           0 :         break;
     218             :     }
     219           0 :     return SCH_RESSTR(nResId);
     220             : }
     221             : 
     222             : } //namespace chart
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10