LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_SeriesToAxis.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 139 0.7 %
Date: 2015-06-13 12:38:46 Functions: 2 13 15.4 %
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_SeriesToAxis.hxx"
      21             : 
      22             : #include "ResId.hxx"
      23             : #include "chartview/ChartSfxItemIds.hxx"
      24             : 
      25             : #include <svl/eitem.hxx>
      26             : #include <svl/intitem.hxx>
      27             : #include <svl/ilstitem.hxx>
      28             : #include <svtools/controldims.hrc>
      29             : 
      30             : #include <com/sun/star/chart/MissingValueTreatment.hpp>
      31             : 
      32             : namespace chart
      33             : {
      34             : 
      35           0 : SchOptionTabPage::SchOptionTabPage(vcl::Window* pWindow,const SfxItemSet& rInAttrs)
      36             :     : SfxTabPage(pWindow,
      37             :                "TP_OPTIONS",
      38             :                "modules/schart/ui/tp_SeriesToAxis.ui",
      39             :                &rInAttrs)
      40             :     , m_nAllSeriesAxisIndex(0)
      41             :     , m_bProvidesSecondaryYAxis(true)
      42             :     , m_bProvidesOverlapAndGapWidth(false)
      43           0 :     , m_bProvidesBarConnectors(false)
      44             : {
      45           0 :     get(m_pGrpAxis,"frameGrpAxis");
      46           0 :     get(m_pRbtAxis1,"RBT_OPT_AXIS_1");
      47           0 :     get(m_pRbtAxis2,"RBT_OPT_AXIS_2");
      48             : 
      49           0 :     get(m_pGrpBar,"frameSettings");
      50           0 :     get(m_pMTGap,"MT_GAP");
      51           0 :     get(m_pMTOverlap,"MT_OVERLAP");
      52           0 :     get(m_pCBConnect,"CB_CONNECTOR");
      53           0 :     get(m_pCBAxisSideBySide,"CB_BARS_SIDE_BY_SIDE");
      54             : 
      55           0 :     get(m_pGrpPlotOptions,"frameFL_PLOT_OPTIONS" );
      56           0 :     get(m_pGridPlotOptions,"gridPLOT_OPTIONS");
      57           0 :     get(m_pRB_DontPaint,"RB_DONT_PAINT");
      58           0 :     get(m_pRB_AssumeZero,"RB_ASSUME_ZERO");
      59           0 :     get(m_pRB_ContinueLine,"RB_CONTINUE_LINE");
      60           0 :     get(m_pCBIncludeHiddenCells,"CB_INCLUDE_HIDDEN_CELLS");
      61             : 
      62           0 :     m_pRbtAxis1->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
      63           0 :     m_pRbtAxis2->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
      64           0 : }
      65             : 
      66           0 : SchOptionTabPage::~SchOptionTabPage()
      67             : {
      68           0 :     disposeOnce();
      69           0 : }
      70             : 
      71           0 : void SchOptionTabPage::dispose()
      72             : {
      73           0 :     m_pGrpAxis.clear();
      74           0 :     m_pRbtAxis1.clear();
      75           0 :     m_pRbtAxis2.clear();
      76           0 :     m_pGrpBar.clear();
      77           0 :     m_pMTGap.clear();
      78           0 :     m_pMTOverlap.clear();
      79           0 :     m_pCBConnect.clear();
      80           0 :     m_pCBAxisSideBySide.clear();
      81           0 :     m_pGrpPlotOptions.clear();
      82           0 :     m_pGridPlotOptions.clear();
      83           0 :     m_pRB_DontPaint.clear();
      84           0 :     m_pRB_AssumeZero.clear();
      85           0 :     m_pRB_ContinueLine.clear();
      86           0 :     m_pCBIncludeHiddenCells.clear();
      87           0 :     SfxTabPage::dispose();
      88           0 : }
      89             : 
      90           0 : IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl)
      91             : {
      92           0 :     if( m_nAllSeriesAxisIndex == 0 )
      93           0 :         m_pCBAxisSideBySide->Enable( m_pRbtAxis2->IsChecked());
      94           0 :     else if( m_nAllSeriesAxisIndex == 1 )
      95           0 :         m_pCBAxisSideBySide->Enable( m_pRbtAxis1->IsChecked());
      96             : 
      97           0 :     return 0;
      98             : }
      99             : 
     100           0 : VclPtr<SfxTabPage> SchOptionTabPage::Create(vcl::Window* pWindow,
     101             :                                             const SfxItemSet* rOutAttrs)
     102             : {
     103           0 :     return VclPtr<SchOptionTabPage>::Create(pWindow, *rOutAttrs);
     104             : }
     105             : 
     106           0 : bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
     107             : {
     108           0 :     if(m_pRbtAxis2->IsChecked())
     109           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y));
     110             :     else
     111           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y));
     112             : 
     113           0 :     if(m_pMTGap->IsVisible())
     114           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( m_pMTGap->GetValue())));
     115             : 
     116           0 :     if(m_pMTOverlap->IsVisible())
     117           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( m_pMTOverlap->GetValue())));
     118             : 
     119           0 :     if(m_pCBConnect->IsVisible())
     120           0 :         rOutAttrs->Put(SfxBoolItem(SCHATTR_BAR_CONNECT,m_pCBConnect->IsChecked()));
     121             : 
     122             :     // model property is "group bars per axis", UI feature is the other way
     123             :     // round: "show bars side by side"
     124           0 :     if(m_pCBAxisSideBySide->IsVisible())
     125           0 :         rOutAttrs->Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! m_pCBAxisSideBySide->IsChecked()));
     126             : 
     127           0 :     if(m_pRB_DontPaint->IsChecked())
     128           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP));
     129           0 :     else if(m_pRB_AssumeZero->IsChecked())
     130           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO));
     131           0 :     else if(m_pRB_ContinueLine->IsChecked())
     132           0 :         rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE));
     133             : 
     134           0 :     if (m_pCBIncludeHiddenCells->IsVisible())
     135           0 :         rOutAttrs->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_pCBIncludeHiddenCells->IsChecked()));
     136             : 
     137           0 :     return true;
     138             : }
     139             : 
     140           0 : void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
     141             : {
     142           0 :     const SfxPoolItem *pPoolItem = NULL;
     143             : 
     144           0 :     m_pRbtAxis1->Check(true);
     145           0 :     m_pRbtAxis2->Check(false);
     146           0 :     if (rInAttrs->GetItemState(SCHATTR_AXIS,true, &pPoolItem) == SfxItemState::SET)
     147             :     {
     148           0 :         long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
     149           0 :         if(nVal==CHART_AXIS_SECONDARY_Y)
     150             :         {
     151           0 :             m_pRbtAxis2->Check(true);
     152           0 :             m_pRbtAxis1->Check(false);
     153             :         }
     154             :     }
     155             : 
     156             :     long nTmp;
     157           0 :     if (rInAttrs->GetItemState(SCHATTR_BAR_GAPWIDTH, true, &pPoolItem) == SfxItemState::SET)
     158             :     {
     159           0 :         nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
     160           0 :         m_pMTGap->SetValue(nTmp);
     161             :     }
     162             : 
     163           0 :     if (rInAttrs->GetItemState(SCHATTR_BAR_OVERLAP, true, &pPoolItem) == SfxItemState::SET)
     164             :     {
     165           0 :         nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
     166           0 :         m_pMTOverlap->SetValue(nTmp);
     167             :     }
     168             : 
     169           0 :     if (rInAttrs->GetItemState(SCHATTR_BAR_CONNECT, true, &pPoolItem) == SfxItemState::SET)
     170             :     {
     171           0 :         bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     172           0 :         m_pCBConnect->Check(bCheck);
     173             :     }
     174             : 
     175           0 :     if (rInAttrs->GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, true, &pPoolItem) == SfxItemState::SET)
     176             :     {
     177           0 :         m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
     178           0 :         m_pCBAxisSideBySide->Disable();
     179             :     }
     180           0 :     if (rInAttrs->GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, true, &pPoolItem) == SfxItemState::SET)
     181             :     {
     182             :         // model property is "group bars per axis", UI feature is the other way
     183             :         // round: "show bars side by side"
     184           0 :         bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     185           0 :         m_pCBAxisSideBySide->Check( bCheck );
     186             :     }
     187             :     else
     188             :     {
     189           0 :         m_pCBAxisSideBySide->Show(false);
     190             :     }
     191             : 
     192             :     //missing value treatment
     193             :     {
     194           0 :         ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments;
     195           0 :         if( rInAttrs->GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, true, &pPoolItem) == SfxItemState::SET )
     196           0 :             aMissingValueTreatments =static_cast<const SfxIntegerListItem*>(pPoolItem)->GetConstSequence();
     197             : 
     198           0 :         if ( aMissingValueTreatments.getLength()>1 && rInAttrs->GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,true, &pPoolItem) == SfxItemState::SET)
     199             :         {
     200           0 :             m_pRB_DontPaint->Enable(false);
     201           0 :             m_pRB_AssumeZero->Enable(false);
     202           0 :             m_pRB_ContinueLine->Enable(false);
     203             : 
     204           0 :             for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ )
     205             :             {
     206           0 :                 sal_Int32 nVal = aMissingValueTreatments[nN];
     207           0 :                 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     208           0 :                     m_pRB_DontPaint->Enable(true);
     209           0 :                 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
     210           0 :                     m_pRB_AssumeZero->Enable(true);
     211           0 :                 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
     212           0 :                     m_pRB_ContinueLine->Enable(true);
     213             :             }
     214             : 
     215           0 :             long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
     216           0 :             if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     217           0 :                 m_pRB_DontPaint->Check(true);
     218           0 :             else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
     219           0 :                 m_pRB_AssumeZero->Check(true);
     220           0 :             else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
     221           0 :                 m_pRB_ContinueLine->Check(true);
     222             :         }
     223             :         else
     224             :         {
     225           0 :             m_pGridPlotOptions->Show(false);
     226           0 :         }
     227             :     }
     228             : 
     229             :     // Include hidden cells
     230           0 :     if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) == SfxItemState::SET)
     231             :     {
     232           0 :         bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
     233           0 :         m_pCBIncludeHiddenCells->Check(bVal);
     234             :     }
     235             :     else
     236             :     {
     237           0 :         m_pCBIncludeHiddenCells->Show(false);
     238             :         // check if the radiobutton guys above
     239             :         // are visible. If they aren't, we can
     240             :         // as well hide the whole frame
     241           0 :         if(!m_pGridPlotOptions->IsVisible())
     242           0 :             m_pGrpPlotOptions->Show(false);
     243             :     }
     244             : 
     245           0 :     AdaptControlPositionsAndVisibility();
     246           0 : }
     247             : 
     248           0 : void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors )
     249             : {
     250           0 :     m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis;
     251           0 :     m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth;
     252           0 :     m_bProvidesBarConnectors = bProvidesBarConnectors;
     253             : 
     254           0 :     AdaptControlPositionsAndVisibility();
     255           0 : }
     256             : 
     257           0 : void SchOptionTabPage::AdaptControlPositionsAndVisibility()
     258             : {
     259           0 :     m_pGrpAxis->Show(m_bProvidesSecondaryYAxis);
     260             : 
     261           0 :     m_pGrpBar->Show(m_bProvidesOverlapAndGapWidth);
     262             : 
     263           0 :     m_pCBConnect->Show(m_bProvidesBarConnectors);
     264             : 
     265           0 :      if( !m_pMTGap->IsVisible() && !m_pMTOverlap->IsVisible() )
     266             :      {
     267           0 :          m_pGrpBar->Show(false);
     268             :      }
     269           0 : }
     270          57 : } //namespace chart
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11