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

Generated by: LCOV version 1.11