LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_SeriesToAxis.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 144 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 374 0.0 %

           Branch data     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                 :            : #include "tp_SeriesToAxis.hrc"
      22                 :            : 
      23                 :            : #include "ResId.hxx"
      24                 :            : #include "chartview/ChartSfxItemIds.hxx"
      25                 :            : #include "NoWarningThisInCTOR.hxx"
      26                 :            : 
      27                 :            : // header for class SfxBoolItem
      28                 :            : #include <svl/eitem.hxx>
      29                 :            : // header for SfxInt32Item
      30                 :            : #include <svl/intitem.hxx>
      31                 :            : //SfxIntegerListItem
      32                 :            : #include <svl/ilstitem.hxx>
      33                 :            : #include <svtools/controldims.hrc>
      34                 :            : 
      35                 :            : #include <com/sun/star/chart/MissingValueTreatment.hpp>
      36                 :            : 
      37                 :            : //.............................................................................
      38                 :            : namespace chart
      39                 :            : {
      40                 :            : //.............................................................................
      41                 :            : 
      42                 :          0 : SchOptionTabPage::SchOptionTabPage(Window* pWindow,const SfxItemSet& rInAttrs) :
      43                 :            :     SfxTabPage(pWindow, SchResId(TP_OPTIONS), rInAttrs),
      44                 :            :     aGrpAxis(this, SchResId(GRP_OPT_AXIS)),
      45                 :            :     aRbtAxis1(this,SchResId(RBT_OPT_AXIS_1)),
      46                 :            :     aRbtAxis2(this,SchResId(RBT_OPT_AXIS_2)),
      47                 :            : 
      48                 :            :     aGrpBar(this, SchResId(GB_BAR)),
      49                 :            :     aFTGap(this,SchResId(FT_GAP)),
      50                 :            :     aMTGap(this,SchResId(MT_GAP)),
      51                 :            :     aFTOverlap(this,SchResId(FT_OVERLAP)),
      52                 :            :     aMTOverlap(this,SchResId(MT_OVERLAP)),
      53                 :            :     aCBConnect(this,SchResId(CB_CONNECTOR)),
      54                 :            :     aCBAxisSideBySide(this,SchResId(CB_BARS_SIDE_BY_SIDE)),
      55                 :            :     m_aFL_PlotOptions(this,SchResId(FL_PLOT_OPTIONS)),
      56                 :            :     m_aFT_MissingValues(this,SchResId(FT_MISSING_VALUES)),
      57                 :            :     m_aRB_DontPaint(this,SchResId(RB_DONT_PAINT)),
      58                 :            :     m_aRB_AssumeZero(this,SchResId(RB_ASSUME_ZERO)),
      59                 :            :     m_aRB_ContinueLine(this,SchResId(RB_CONTINUE_LINE)),
      60                 :            :     m_aCBIncludeHiddenCells(this,SchResId(CB_INCLUDE_HIDDEN_CELLS)),
      61                 :            :     m_bProvidesSecondaryYAxis(true),
      62 [ #  # ][ #  # ]:          0 :     m_bProvidesOverlapAndGapWidth(false)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      63                 :            : {
      64         [ #  # ]:          0 :     FreeResource();
      65                 :            : 
      66         [ #  # ]:          0 :     aRbtAxis1.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
      67         [ #  # ]:          0 :     aRbtAxis2.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
      68                 :          0 : }
      69                 :            : 
      70 [ #  # ][ #  # ]:          0 : SchOptionTabPage::~SchOptionTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      71                 :            : {
      72         [ #  # ]:          0 : }
      73                 :            : 
      74                 :          0 : IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl)
      75                 :            : {
      76         [ #  # ]:          0 :     if( m_nAllSeriesAxisIndex == 0 )
      77                 :          0 :         aCBAxisSideBySide.Enable( aRbtAxis2.IsChecked());
      78         [ #  # ]:          0 :     else if( m_nAllSeriesAxisIndex == 1 )
      79                 :          0 :         aCBAxisSideBySide.Enable( aRbtAxis1.IsChecked());
      80                 :            : 
      81                 :          0 :     return 0;
      82                 :            : }
      83                 :            : 
      84                 :          0 : SfxTabPage* SchOptionTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs)
      85                 :            : {
      86         [ #  # ]:          0 :     return new SchOptionTabPage(pWindow, rOutAttrs);
      87                 :            : }
      88                 :            : 
      89                 :          0 : sal_Bool SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs)
      90                 :            : {
      91         [ #  # ]:          0 :     if(aRbtAxis2.IsChecked())
      92         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y));
      93                 :            :     else
      94         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y));
      95                 :            : 
      96         [ #  # ]:          0 :     if(aMTGap.IsVisible())
      97         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( aMTGap.GetValue())));
      98                 :            : 
      99         [ #  # ]:          0 :     if(aMTOverlap.IsVisible())
     100         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( aMTOverlap.GetValue())));
     101                 :            : 
     102         [ #  # ]:          0 :     if(aCBConnect.IsVisible())
     103         [ #  # ]:          0 :         rOutAttrs.Put(SfxBoolItem(SCHATTR_BAR_CONNECT,aCBConnect.IsChecked()));
     104                 :            : 
     105                 :            :     // model property is "group bars per axis", UI feature is the other way
     106                 :            :     // round: "show bars side by side"
     107         [ #  # ]:          0 :     if(aCBAxisSideBySide.IsVisible())
     108         [ #  # ]:          0 :         rOutAttrs.Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! aCBAxisSideBySide.IsChecked()));
     109                 :            : 
     110         [ #  # ]:          0 :     if(m_aRB_DontPaint.IsChecked())
     111         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP));
     112         [ #  # ]:          0 :     else if(m_aRB_AssumeZero.IsChecked())
     113         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO));
     114         [ #  # ]:          0 :     else if(m_aRB_ContinueLine.IsChecked())
     115         [ #  # ]:          0 :         rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE));
     116                 :            : 
     117         [ #  # ]:          0 :     if (m_aCBIncludeHiddenCells.IsVisible())
     118         [ #  # ]:          0 :         rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCBIncludeHiddenCells.IsChecked()));
     119                 :            : 
     120                 :          0 :     return sal_True;
     121                 :            : }
     122                 :            : 
     123                 :          0 : void SchOptionTabPage::Reset(const SfxItemSet& rInAttrs)
     124                 :            : {
     125                 :          0 :     const SfxPoolItem *pPoolItem = NULL;
     126                 :            : 
     127         [ #  # ]:          0 :     aRbtAxis1.Check(sal_True);
     128         [ #  # ]:          0 :     aRbtAxis2.Check(sal_False);
     129 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_AXIS,sal_True, &pPoolItem) == SFX_ITEM_SET)
     130                 :            :     {
     131                 :          0 :         long nVal=((const SfxInt32Item*)pPoolItem)->GetValue();
     132         [ #  # ]:          0 :         if(nVal==CHART_AXIS_SECONDARY_Y)
     133                 :            :         {
     134         [ #  # ]:          0 :             aRbtAxis2.Check(sal_True);
     135         [ #  # ]:          0 :             aRbtAxis1.Check(sal_False);
     136                 :            :         }
     137                 :            :     }
     138                 :            : 
     139                 :            :     long nTmp;
     140 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_BAR_GAPWIDTH, sal_True, &pPoolItem) == SFX_ITEM_SET)
     141                 :            :     {
     142                 :          0 :         nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue();
     143         [ #  # ]:          0 :         aMTGap.SetValue(nTmp);
     144                 :            :     }
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_BAR_OVERLAP, sal_True, &pPoolItem) == SFX_ITEM_SET)
     147                 :            :     {
     148                 :          0 :         nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue();
     149         [ #  # ]:          0 :         aMTOverlap.SetValue(nTmp);
     150                 :            :     }
     151                 :            : 
     152 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_BAR_CONNECT, sal_True, &pPoolItem) == SFX_ITEM_SET)
     153                 :            :     {
     154                 :          0 :         sal_Bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     155         [ #  # ]:          0 :         aCBConnect.Check(bCheck);
     156                 :            :     }
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, sal_True, &pPoolItem) == SFX_ITEM_SET)
     159                 :            :     {
     160                 :          0 :         m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
     161         [ #  # ]:          0 :         aCBAxisSideBySide.Disable();
     162                 :            :     }
     163 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, sal_True, &pPoolItem) == SFX_ITEM_SET)
     164                 :            :     {
     165                 :            :         // model property is "group bars per axis", UI feature is the other way
     166                 :            :         // round: "show bars side by side"
     167                 :          0 :         sal_Bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     168         [ #  # ]:          0 :         aCBAxisSideBySide.Check( bCheck );
     169                 :            :     }
     170                 :            :     else
     171                 :            :     {
     172         [ #  # ]:          0 :         aCBAxisSideBySide.Show(sal_False);
     173                 :            :     }
     174                 :            : 
     175                 :            : 
     176                 :            :     //missing value treatment
     177                 :            :     {
     178         [ #  # ]:          0 :         ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments;
     179 [ #  # ][ #  # ]:          0 :         if( rInAttrs.GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, sal_True, &pPoolItem) == SFX_ITEM_SET )
     180 [ #  # ][ #  # ]:          0 :             aMissingValueTreatments =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence();
                 [ #  # ]
     181                 :            : 
     182 [ #  # ][ #  # ]:          0 :         if ( aMissingValueTreatments.getLength()>1 && rInAttrs.GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,sal_True, &pPoolItem) == SFX_ITEM_SET)
         [ #  # ][ #  # ]
     183                 :            :         {
     184         [ #  # ]:          0 :             m_aRB_DontPaint.Enable(sal_False);
     185         [ #  # ]:          0 :             m_aRB_AssumeZero.Enable(sal_False);
     186         [ #  # ]:          0 :             m_aRB_ContinueLine.Enable(sal_False);
     187                 :            : 
     188         [ #  # ]:          0 :             for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ )
     189                 :            :             {
     190         [ #  # ]:          0 :                 sal_Int32 nVal = aMissingValueTreatments[nN];
     191         [ #  # ]:          0 :                 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     192         [ #  # ]:          0 :                     m_aRB_DontPaint.Enable(sal_True);
     193         [ #  # ]:          0 :                 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
     194         [ #  # ]:          0 :                     m_aRB_AssumeZero.Enable(sal_True);
     195         [ #  # ]:          0 :                 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
     196         [ #  # ]:          0 :                     m_aRB_ContinueLine.Enable(sal_True);
     197                 :            :             }
     198                 :            : 
     199                 :          0 :             long nVal=((const SfxInt32Item*)pPoolItem)->GetValue();
     200         [ #  # ]:          0 :             if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     201         [ #  # ]:          0 :                 m_aRB_DontPaint.Check(sal_True);
     202         [ #  # ]:          0 :             else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
     203         [ #  # ]:          0 :                 m_aRB_AssumeZero.Check(sal_True);
     204         [ #  # ]:          0 :             else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
     205         [ #  # ]:          0 :                 m_aRB_ContinueLine.Check(sal_True);
     206                 :            :         }
     207                 :            :         else
     208                 :            :         {
     209         [ #  # ]:          0 :             m_aFT_MissingValues.Show(sal_False);
     210         [ #  # ]:          0 :             m_aRB_DontPaint.Show(sal_False);
     211         [ #  # ]:          0 :             m_aRB_AssumeZero.Show(sal_False);
     212         [ #  # ]:          0 :             m_aRB_ContinueLine.Show(sal_False);
     213         [ #  # ]:          0 :         }
     214                 :            :     }
     215                 :            : 
     216                 :            :     // Include hidden cells
     217 [ #  # ][ #  # ]:          0 :     if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True, &pPoolItem) == SFX_ITEM_SET)
     218                 :            :     {
     219                 :          0 :         bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
     220         [ #  # ]:          0 :         m_aCBIncludeHiddenCells.Check(bVal);
     221                 :            :     }
     222                 :            :     else
     223                 :            :     {
     224         [ #  # ]:          0 :         m_aCBIncludeHiddenCells.Show(sal_False);
     225 [ #  # ][ #  # ]:          0 :         if(!m_aFT_MissingValues.IsVisible())
     226         [ #  # ]:          0 :             m_aFL_PlotOptions.Show(sal_False);
     227                 :            :     }
     228                 :            : 
     229         [ #  # ]:          0 :     AdaptControlPositionsAndVisibility();
     230                 :          0 : }
     231                 :            : 
     232                 :          0 : void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors )
     233                 :            : {
     234                 :          0 :     m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis;
     235                 :          0 :     m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth;
     236                 :          0 :     m_bProvidesBarConnectors = bProvidesBarConnectors;
     237                 :            : 
     238                 :          0 :     AdaptControlPositionsAndVisibility();
     239                 :          0 : }
     240                 :            : 
     241                 :          0 : void lcl_offsetControl(Control& rCtrl, long nXOffset, long nYOffset )
     242                 :            : {
     243         [ #  # ]:          0 :     Point aPos = rCtrl.GetPosPixel();
     244         [ #  # ]:          0 :     rCtrl.SetPosPixel( Point(aPos.getX() + nXOffset, aPos.getY() + nYOffset) );
     245                 :          0 : }
     246                 :            : 
     247                 :          0 : void lcl_optimzeRadioButtonSize( RadioButton& rCtrl )
     248                 :            : {
     249         [ #  # ]:          0 :     rCtrl.SetSizePixel( rCtrl.CalcMinimumSize() );
     250                 :          0 : }
     251                 :            : 
     252                 :          0 : void SchOptionTabPage::AdaptControlPositionsAndVisibility()
     253                 :            : {
     254         [ #  # ]:          0 :     aRbtAxis1.Show(m_bProvidesSecondaryYAxis);
     255         [ #  # ]:          0 :     aRbtAxis2.Show(m_bProvidesSecondaryYAxis);
     256         [ #  # ]:          0 :     aGrpAxis.Show(m_bProvidesSecondaryYAxis);
     257                 :            : 
     258         [ #  # ]:          0 :     aMTGap.Show(m_bProvidesOverlapAndGapWidth);
     259         [ #  # ]:          0 :     aFTGap.Show(m_bProvidesOverlapAndGapWidth);
     260                 :            : 
     261         [ #  # ]:          0 :     aMTOverlap.Show(m_bProvidesOverlapAndGapWidth);
     262         [ #  # ]:          0 :     aFTOverlap.Show(m_bProvidesOverlapAndGapWidth);
     263                 :            : 
     264         [ #  # ]:          0 :     aCBConnect.Show(m_bProvidesBarConnectors);
     265                 :            : 
     266 [ #  # ][ #  # ]:          0 :     if( !aMTGap.IsVisible() && !aMTOverlap.IsVisible() )
         [ #  # ][ #  # ]
                 [ #  # ]
     267                 :            :     {
     268         [ #  # ]:          0 :         aGrpBar.Show(sal_False);
     269                 :          0 :         Point aPos;
     270 [ #  # ][ #  # ]:          0 :         if( !aRbtAxis1.IsVisible() && !aRbtAxis2.IsVisible() )
         [ #  # ][ #  # ]
                 [ #  # ]
     271         [ #  # ]:          0 :             aPos = aGrpAxis.GetPosPixel();
     272                 :            :         else
     273         [ #  # ]:          0 :             aPos = aGrpBar.GetPosPixel();
     274                 :            : 
     275         [ #  # ]:          0 :         long nYOffset = aPos.getY() - m_aFL_PlotOptions.GetPosPixel().getY();
     276         [ #  # ]:          0 :         lcl_offsetControl(m_aFL_PlotOptions,       0, nYOffset);
     277         [ #  # ]:          0 :         lcl_offsetControl(m_aFT_MissingValues,     0, nYOffset);
     278         [ #  # ]:          0 :         lcl_offsetControl(m_aRB_DontPaint,         0, nYOffset);
     279         [ #  # ]:          0 :         lcl_offsetControl(m_aRB_AssumeZero,        0, nYOffset);
     280         [ #  # ]:          0 :         lcl_offsetControl(m_aRB_ContinueLine,      0, nYOffset);
     281         [ #  # ]:          0 :         lcl_offsetControl(m_aCBIncludeHiddenCells, 0, nYOffset);
     282                 :            :     }
     283                 :            : 
     284 [ #  # ][ #  # ]:          0 :     m_aFT_MissingValues.SetSizePixel( m_aFT_MissingValues.CalcMinimumSize() );
     285         [ #  # ]:          0 :     lcl_optimzeRadioButtonSize( m_aRB_DontPaint );
     286         [ #  # ]:          0 :     lcl_optimzeRadioButtonSize( m_aRB_AssumeZero );
     287         [ #  # ]:          0 :     lcl_optimzeRadioButtonSize( m_aRB_ContinueLine );
     288                 :            : 
     289 [ #  # ][ #  # ]:          0 :     Size aControlDistance( m_aFT_MissingValues.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) );
                 [ #  # ]
     290 [ #  # ][ #  # ]:          0 :     long nXOffset = m_aFT_MissingValues.GetPosPixel().getX() + m_aFT_MissingValues.GetSizePixel().getWidth() + aControlDistance.getWidth() - m_aRB_DontPaint.GetPosPixel().getX();
                 [ #  # ]
     291         [ #  # ]:          0 :     lcl_offsetControl(m_aRB_DontPaint,         nXOffset, 0);
     292         [ #  # ]:          0 :     lcl_offsetControl(m_aRB_AssumeZero,        nXOffset, 0);
     293         [ #  # ]:          0 :     lcl_offsetControl(m_aRB_ContinueLine,      nXOffset, 0);
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :     if( !m_aFT_MissingValues.IsVisible() )
     296                 :            :     {
     297                 :            :         //for example for stock charts
     298 [ #  # ][ #  # ]:          0 :         m_aCBIncludeHiddenCells.SetPosPixel( m_aFT_MissingValues.GetPosPixel() );
     299                 :            :     }
     300                 :          0 : }
     301                 :            : //.............................................................................
     302                 :            : } //namespace chart
     303                 :            : //.............................................................................
     304                 :            : 
     305                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10