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

Generated by: LCOV version 1.10