LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - dlg_CreationWizard.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 89 1.1 %
Date: 2014-11-03 Functions: 2 12 16.7 %
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 :                     static_cast<sal_uInt32>((nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount)
      58             :                         ?  WZB_HELP | WZB_CANCEL | WZB_FINISH
      59             :                         :  WZB_HELP | WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT | WZB_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( WZB_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 : 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 && m_pDialogModel)
     128           0 :             m_pDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate());
     129             :         }
     130           0 :         break;
     131             :     case STATE_SIMPLE_RANGE:
     132             :         {
     133           0 :         m_aTimerTriggeredControllerLock.startTimer();
     134           0 :         pRet = new RangeChooserTabPage(this, *m_pDialogModel, m_pTemplateProvider, this);
     135             :         }
     136           0 :         break;
     137             :     case STATE_DATA_SERIES:
     138             :         {
     139           0 :         m_aTimerTriggeredControllerLock.startTimer();
     140           0 :         pRet = new DataSourceTabPage(this, *m_pDialogModel, m_pTemplateProvider, this);
     141             :         }
     142           0 :         break;
     143             :     case STATE_OBJECTS:
     144             :         {
     145           0 :         pRet  = new TitlesAndObjectsTabPage(this,m_xChartModel,m_xCC);
     146           0 :         m_aTimerTriggeredControllerLock.startTimer();
     147             :         }
     148           0 :         break;
     149             :     default:
     150           0 :         break;
     151             :     }
     152           0 :     if(pRet)
     153           0 :         pRet->SetText(OUString());//remove title of pages to not get them in the wizard title
     154           0 :     return pRet;
     155             : }
     156             : 
     157           0 : bool CreationWizard::leaveState( WizardState /*_nState*/ )
     158             : {
     159           0 :     return m_bCanTravel;
     160             : }
     161             : 
     162           0 : svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const
     163             : {
     164           0 :     if( !m_bCanTravel )
     165           0 :         return WZS_INVALID_STATE;
     166           0 :     if( nCurrentState == m_nLastState )
     167           0 :         return WZS_INVALID_STATE;
     168           0 :     svt::WizardTypes::WizardState nNextState = nCurrentState + 1;
     169           0 :     while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState )
     170           0 :         ++nNextState;
     171           0 :     return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState;
     172             : }
     173           0 : void CreationWizard::enterState(WizardState nState)
     174             : {
     175           0 :     m_aTimerTriggeredControllerLock.startTimer();
     176           0 :     enableButtons( WZB_PREVIOUS, bool( nState > m_nFirstState ) );
     177           0 :     enableButtons( WZB_NEXT, bool( nState < m_nLastState ) );
     178           0 :     if( isStateEnabled( nState ))
     179           0 :         svt::RoadmapWizard::enterState(nState);
     180           0 : }
     181             : 
     182           0 : void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ )
     183             : {
     184           0 :     m_bCanTravel = false;
     185           0 : }
     186             : 
     187           0 : void CreationWizard::setValidPage( TabPage * /* pTabPage */ )
     188             : {
     189           0 :     m_bCanTravel = true;
     190           0 : }
     191             : 
     192           0 : OUString CreationWizard::getStateDisplayName( WizardState nState ) const
     193             : {
     194           0 :     sal_uInt16 nResId = 0;
     195           0 :     switch( nState )
     196             :     {
     197             :     case STATE_CHARTTYPE:
     198           0 :         nResId = STR_PAGE_CHARTTYPE;
     199           0 :         break;
     200             :     case STATE_SIMPLE_RANGE:
     201           0 :         nResId = STR_PAGE_DATA_RANGE;
     202           0 :         break;
     203             :     case STATE_DATA_SERIES:
     204           0 :         nResId = STR_OBJECT_DATASERIES_PLURAL;
     205           0 :         break;
     206             :     case STATE_OBJECTS:
     207           0 :         nResId = STR_PAGE_CHART_ELEMENTS;
     208           0 :         break;
     209             :     default:
     210           0 :         break;
     211             :     }
     212           0 :     return SCH_RESSTR(nResId);
     213             : }
     214             : 
     215         102 : } //namespace chart
     216             : 
     217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10