LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - dlg_CreationWizard.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 89 1.1 %
Date: 2015-06-13 12:38:46 Functions: 2 10 20.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 "ResId.hxx"
      22             : #include "macros.hxx"
      23             : #include "Strings.hrc"
      24             : #include "HelpIds.hrc"
      25             : 
      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"
      32             : 
      33             : #define CHART_WIZARD_PAGEWIDTH  250
      34             : #define CHART_WIZARD_PAGEHEIGHT 170
      35             : 
      36             : namespace chart
      37             : {
      38             : using namespace ::com::sun::star;
      39             : 
      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
      47             : 
      48             : namespace
      49             : {
      50             :     const sal_Int32 nPageCount = 4;
      51             : }
      52             : 
      53           0 : 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           0 :                     (nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount)
      58           0 :                         ?  WizardButtonFlags::HELP | WizardButtonFlags::CANCEL | WizardButtonFlags::FINISH
      59           0 :                         :  WizardButtonFlags::HELP | WizardButtonFlags::CANCEL | WizardButtonFlags::PREVIOUS | WizardButtonFlags::NEXT | WizardButtonFlags::FINISH
      60             :                   )
      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           0 :                 , m_bCanTravel( true )
      70             : {
      71           0 :     m_pDialogModel.reset( new DialogModel( m_xChartModel, m_xCC ));
      72           0 :     defaultButton( WizardButtonFlags::FINISH );
      73             : 
      74           0 :     if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount )
      75             :     {
      76           0 :         m_nOnePageOnlyIndex = -1;
      77           0 :         this->setTitleBase(SCH_RESSTR(STR_DLG_CHART_WIZARD));
      78             :     }
      79             :     else
      80           0 :         this->setTitleBase(OUString());
      81             : 
      82             :     declarePath( PATH_FULL
      83             :         , STATE_CHARTTYPE
      84             :         , STATE_SIMPLE_RANGE
      85             :         , STATE_DATA_SERIES
      86             :         , STATE_OBJECTS
      87             :         , WZS_INVALID_STATE
      88           0 :     );
      89           0 :     this->SetRoadmapHelpId( HID_SCH_WIZARD_ROADMAP );
      90           0 :     this->SetRoadmapInteractive( true );
      91           0 :     Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
      92           0 :     Size aSize(LogicToPixel(Size(CHART_WIZARD_PAGEWIDTH, CHART_WIZARD_PAGEHEIGHT), MAP_APPFONT));
      93           0 :     aSize.Width() += aAdditionalRoadmapSize.Width();
      94           0 :     this->SetSizePixel( aSize );
      95             : 
      96           0 :     uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
      97           0 :     bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
      98             : 
      99           0 :     if( bHasOwnData )
     100             :     {
     101           0 :         this->enableState( STATE_SIMPLE_RANGE, false );
     102           0 :         this->enableState( STATE_DATA_SERIES, false );
     103             :     }
     104             : 
     105             :     // Call ActivatePage, to create and activate the first page
     106           0 :     ActivatePage();
     107           0 : }
     108             : 
     109           0 : VclPtr<TabPage> CreationWizard::createPage(WizardState nState)
     110             : {
     111           0 :     VclPtr<svt::OWizardPage> pRet;
     112           0 :     if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState)
     113           0 :         return pRet;
     114           0 :     bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1;
     115           0 :     switch( nState )
     116             :     {
     117             :     case STATE_CHARTTYPE:
     118             :         {
     119           0 :         m_aTimerTriggeredControllerLock.startTimer();
     120           0 :         VclPtrInstance<ChartTypeTabPage> pChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate);
     121           0 :         pRet  = pChartTypeTabPage;
     122           0 :         m_pTemplateProvider = pChartTypeTabPage;
     123           0 :         if (m_pDialogModel)
     124           0 :             m_pDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
     125             :         }
     126           0 :         break;
     127             :     case STATE_SIMPLE_RANGE:
     128             :         {
     129           0 :         m_aTimerTriggeredControllerLock.startTimer();
     130           0 :         pRet = VclPtr<RangeChooserTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this);
     131             :         }
     132           0 :         break;
     133             :     case STATE_DATA_SERIES:
     134             :         {
     135           0 :         m_aTimerTriggeredControllerLock.startTimer();
     136           0 :         pRet = VclPtr<DataSourceTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this);
     137             :         }
     138           0 :         break;
     139             :     case STATE_OBJECTS:
     140             :         {
     141           0 :         pRet  = VclPtr<TitlesAndObjectsTabPage>::Create(this,m_xChartModel,m_xCC);
     142           0 :         m_aTimerTriggeredControllerLock.startTimer();
     143             :         }
     144           0 :         break;
     145             :     default:
     146           0 :         break;
     147             :     }
     148           0 :     if(pRet)
     149           0 :         pRet->SetText(OUString());//remove title of pages to not get them in the wizard title
     150           0 :     return pRet;
     151             : }
     152             : 
     153           0 : bool CreationWizard::leaveState( WizardState /*_nState*/ )
     154             : {
     155           0 :     return m_bCanTravel;
     156             : }
     157             : 
     158           0 : svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
     159             : {
     160           0 :     if( !m_bCanTravel )
     161           0 :         return WZS_INVALID_STATE;
     162           0 :     if( nCurrentState == m_nLastState )
     163           0 :         return WZS_INVALID_STATE;
     164           0 :     svt::WizardTypes::WizardState nNextState = nCurrentState + 1;
     165           0 :     while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState )
     166           0 :         ++nNextState;
     167           0 :     return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState;
     168             : }
     169           0 : void CreationWizard::enterState(WizardState nState)
     170             : {
     171           0 :     m_aTimerTriggeredControllerLock.startTimer();
     172           0 :     enableButtons( WizardButtonFlags::PREVIOUS, bool( nState > m_nFirstState ) );
     173           0 :     enableButtons( WizardButtonFlags::NEXT, bool( nState < m_nLastState ) );
     174           0 :     if( isStateEnabled( nState ))
     175           0 :         svt::RoadmapWizard::enterState(nState);
     176           0 : }
     177             : 
     178           0 : void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ )
     179             : {
     180           0 :     m_bCanTravel = false;
     181           0 : }
     182             : 
     183           0 : void CreationWizard::setValidPage( TabPage * /* pTabPage */ )
     184             : {
     185           0 :     m_bCanTravel = true;
     186           0 : }
     187             : 
     188           0 : OUString CreationWizard::getStateDisplayName( WizardState nState ) const
     189             : {
     190           0 :     sal_uInt16 nResId = 0;
     191           0 :     switch( nState )
     192             :     {
     193             :     case STATE_CHARTTYPE:
     194           0 :         nResId = STR_PAGE_CHARTTYPE;
     195           0 :         break;
     196             :     case STATE_SIMPLE_RANGE:
     197           0 :         nResId = STR_PAGE_DATA_RANGE;
     198           0 :         break;
     199             :     case STATE_DATA_SERIES:
     200           0 :         nResId = STR_OBJECT_DATASERIES_PLURAL;
     201           0 :         break;
     202             :     case STATE_OBJECTS:
     203           0 :         nResId = STR_PAGE_CHART_ELEMENTS;
     204           0 :         break;
     205             :     default:
     206           0 :         break;
     207             :     }
     208           0 :     return SCH_RESSTR(nResId);
     209             : }
     210             : 
     211          57 : } //namespace chart
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11