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

Generated by: LCOV version 1.10