LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_Wizard_TitlesAndObjects.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 61 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "tp_Wizard_TitlesAndObjects.hxx"
      21             : #include "tp_Wizard_TitlesAndObjects.hrc"
      22             : #include "Strings.hrc"
      23             : #include "res_Titles.hxx"
      24             : #include "res_LegendPosition.hxx"
      25             : #include "ResId.hxx"
      26             : #include "HelpIds.hrc"
      27             : #include "macros.hxx"
      28             : #include "ChartModelHelper.hxx"
      29             : #include "AxisHelper.hxx"
      30             : #include "LegendHelper.hxx"
      31             : #include "ControllerLockGuard.hxx"
      32             : 
      33             : namespace chart
      34             : {
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::chart2;
      37             : 
      38           0 : TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent
      39             :         , const uno::Reference< XChartDocument >& xChartModel
      40             :         , const uno::Reference< uno::XComponentContext >& xContext )
      41             :         : OWizardPage(pParent, "WizElementsPage", "modules/schart/ui/wizelementspage.ui")
      42           0 :         , m_xTitleResources(new TitleResources(*this, false))
      43           0 :         , m_xLegendPositionResources(new LegendPositionResources(*this, xContext))
      44             :         , m_xChartModel(xChartModel)
      45             :         , m_xCC(xContext)
      46             :         , m_bCommitToModel(true)
      47           0 :         , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
      48             : {
      49           0 :     get(m_pCB_Grid_X, "x");
      50           0 :     get(m_pCB_Grid_Y, "y");
      51           0 :     get(m_pCB_Grid_Z, "z");
      52             : 
      53           0 :     m_xTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
      54           0 :     m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
      55             : 
      56           0 :     m_pCB_Grid_X->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
      57           0 :     m_pCB_Grid_Y->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
      58           0 :     m_pCB_Grid_Z->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
      59           0 : }
      60             : 
      61           0 : void TitlesAndObjectsTabPage::initializePage()
      62             : {
      63           0 :     m_bCommitToModel = false;
      64             : 
      65             :     //init titles
      66             :     {
      67           0 :         TitleDialogData aTitleInput;
      68           0 :         aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
      69           0 :         m_xTitleResources->writeToResources( aTitleInput );
      70             :     }
      71             : 
      72             :     //init legend
      73             :     {
      74           0 :         m_xLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) );
      75             :     }
      76             : 
      77             :     //init grid checkboxes
      78             :     {
      79           0 :         uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
      80           0 :         uno::Sequence< sal_Bool > aPossibilityList;
      81           0 :         uno::Sequence< sal_Bool > aExistenceList;
      82           0 :         AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, sal_False );
      83           0 :         AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, sal_False );
      84           0 :         m_pCB_Grid_X->Enable( aPossibilityList[0] );
      85           0 :         m_pCB_Grid_Y->Enable( aPossibilityList[1] );
      86           0 :         m_pCB_Grid_Z->Enable( aPossibilityList[2] );
      87           0 :         m_pCB_Grid_X->Check( aExistenceList[0] );
      88           0 :         m_pCB_Grid_Y->Check( aExistenceList[1] );
      89           0 :         m_pCB_Grid_Z->Check( aExistenceList[2] );
      90             :     }
      91             : 
      92           0 :     m_bCommitToModel = true;
      93           0 : }
      94             : 
      95           0 : bool TitlesAndObjectsTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
      96             : {
      97           0 :     if( m_xTitleResources->IsModified() ) //titles may have changed in the meanwhile
      98           0 :         commitToModel();
      99           0 :     return true;//return false if this page should not be left
     100             : }
     101             : 
     102           0 : void TitlesAndObjectsTabPage::commitToModel()
     103             : {
     104           0 :     m_aTimerTriggeredControllerLock.startTimer();
     105           0 :     uno::Reference< frame::XModel >  xModel( m_xChartModel, uno::UNO_QUERY);
     106             : 
     107           0 :     ControllerLockGuardUNO aLockedControllers( xModel );
     108             : 
     109             :     //commit title changes to model
     110             :     {
     111           0 :         TitleDialogData aTitleOutput;
     112           0 :         m_xTitleResources->readFromResources( aTitleOutput );
     113           0 :         aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
     114           0 :         m_xTitleResources->ClearModifyFlag();
     115             :     }
     116             : 
     117             :     //commit legend changes to model
     118             :     {
     119           0 :         m_xLegendPositionResources->writeToModel( xModel );
     120             :     }
     121             : 
     122             :     //commit grid changes to model
     123             :     {
     124           0 :         uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
     125           0 :         uno::Sequence< sal_Bool > aOldExistenceList;
     126           0 :         AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, sal_False );
     127           0 :         uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
     128           0 :         aNewExistenceList[0] = m_pCB_Grid_X->IsChecked();
     129           0 :         aNewExistenceList[1] = m_pCB_Grid_Y->IsChecked();
     130           0 :         aNewExistenceList[2] = m_pCB_Grid_Z->IsChecked();
     131             :         AxisHelper::changeVisibilityOfGrids( xDiagram
     132           0 :                 , aOldExistenceList, aNewExistenceList, m_xCC );
     133           0 :     }
     134           0 : }
     135             : 
     136           0 : IMPL_LINK_NOARG(TitlesAndObjectsTabPage, ChangeHdl)
     137             : {
     138           0 :     if( m_bCommitToModel )
     139           0 :         commitToModel();
     140           0 :     return 0;
     141             : }
     142             : 
     143           0 : bool TitlesAndObjectsTabPage::canAdvance() const
     144             : {
     145           0 :     return false;
     146             : }
     147             : 
     148             : } //namespace chart
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10