1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 #include "tp_SeriesToAxis.hxx" 31 #include "tp_SeriesToAxis.hrc" 32 33 #include "ResId.hxx" 34 #include "chartview/ChartSfxItemIds.hxx" 35 #include "NoWarningThisInCTOR.hxx" 36 37 // header for class SfxBoolItem 38 #include <svl/eitem.hxx> 39 // header for SfxInt32Item 40 #include <svl/intitem.hxx> 41 //SfxIntegerListItem 42 #include <svl/ilstitem.hxx> 43 #include <svtools/controldims.hrc> 44 45 #include <com/sun/star/chart/MissingValueTreatment.hpp> 46 47 //............................................................................. 48 namespace chart 49 { 50 //............................................................................. 51 52 SchOptionTabPage::SchOptionTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : 53 SfxTabPage(pWindow, SchResId(TP_OPTIONS), rInAttrs), 54 aGrpAxis(this, SchResId(GRP_OPT_AXIS)), 55 aRbtAxis1(this,SchResId(RBT_OPT_AXIS_1)), 56 aRbtAxis2(this,SchResId(RBT_OPT_AXIS_2)), 57 58 aGrpBar(this, SchResId(GB_BAR)), 59 aFTGap(this,SchResId(FT_GAP)), 60 aMTGap(this,SchResId(MT_GAP)), 61 aFTOverlap(this,SchResId(FT_OVERLAP)), 62 aMTOverlap(this,SchResId(MT_OVERLAP)), 63 aCBConnect(this,SchResId(CB_CONNECTOR)), 64 aCBAxisSideBySide(this,SchResId(CB_BARS_SIDE_BY_SIDE)), 65 m_aFL_PlotOptions(this,SchResId(FL_PLOT_OPTIONS)), 66 m_aFT_MissingValues(this,SchResId(FT_MISSING_VALUES)), 67 m_aRB_DontPaint(this,SchResId(RB_DONT_PAINT)), 68 m_aRB_AssumeZero(this,SchResId(RB_ASSUME_ZERO)), 69 m_aRB_ContinueLine(this,SchResId(RB_CONTINUE_LINE)), 70 m_aCBIncludeHiddenCells(this,SchResId(CB_INCLUDE_HIDDEN_CELLS)), 71 m_bProvidesSecondaryYAxis(true), 72 m_bProvidesOverlapAndGapWidth(false) 73 { 74 FreeResource(); 75 76 aRbtAxis1.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl )); 77 aRbtAxis2.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl )); 78 } 79 80 SchOptionTabPage::~SchOptionTabPage() 81 { 82 } 83 84 IMPL_LINK( SchOptionTabPage, EnableHdl, RadioButton *, EMPTYARG ) 85 { 86 if( m_nAllSeriesAxisIndex == 0 ) 87 aCBAxisSideBySide.Enable( aRbtAxis2.IsChecked()); 88 else if( m_nAllSeriesAxisIndex == 1 ) 89 aCBAxisSideBySide.Enable( aRbtAxis1.IsChecked()); 90 91 return 0; 92 } 93 94 SfxTabPage* SchOptionTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) 95 { 96 return new SchOptionTabPage(pWindow, rOutAttrs); 97 } 98 99 sal_Bool SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs) 100 { 101 if(aRbtAxis2.IsChecked()) 102 rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y)); 103 else 104 rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y)); 105 106 if(aMTGap.IsVisible()) 107 rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( aMTGap.GetValue()))); 108 109 if(aMTOverlap.IsVisible()) 110 rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( aMTOverlap.GetValue()))); 111 112 if(aCBConnect.IsVisible()) 113 rOutAttrs.Put(SfxBoolItem(SCHATTR_BAR_CONNECT,aCBConnect.IsChecked())); 114 115 // model property is "group bars per axis", UI feature is the other way 116 // round: "show bars side by side" 117 if(aCBAxisSideBySide.IsVisible()) 118 rOutAttrs.Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! aCBAxisSideBySide.IsChecked())); 119 120 if(m_aRB_DontPaint.IsChecked()) 121 rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)); 122 else if(m_aRB_AssumeZero.IsChecked()) 123 rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO)); 124 else if(m_aRB_ContinueLine.IsChecked()) 125 rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE)); 126 127 if (m_aCBIncludeHiddenCells.IsVisible()) 128 rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCBIncludeHiddenCells.IsChecked())); 129 130 return sal_True; 131 } 132 133 void SchOptionTabPage::Reset(const SfxItemSet& rInAttrs) 134 { 135 const SfxPoolItem *pPoolItem = NULL; 136 137 aRbtAxis1.Check(sal_True); 138 aRbtAxis2.Check(sal_False); 139 if (rInAttrs.GetItemState(SCHATTR_AXIS,sal_True, &pPoolItem) == SFX_ITEM_SET) 140 { 141 long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); 142 if(nVal==CHART_AXIS_SECONDARY_Y) 143 { 144 aRbtAxis2.Check(sal_True); 145 aRbtAxis1.Check(sal_False); 146 } 147 } 148 149 long nTmp; 150 if (rInAttrs.GetItemState(SCHATTR_BAR_GAPWIDTH, sal_True, &pPoolItem) == SFX_ITEM_SET) 151 { 152 nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); 153 aMTGap.SetValue(nTmp); 154 } 155 156 if (rInAttrs.GetItemState(SCHATTR_BAR_OVERLAP, sal_True, &pPoolItem) == SFX_ITEM_SET) 157 { 158 nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); 159 aMTOverlap.SetValue(nTmp); 160 } 161 162 if (rInAttrs.GetItemState(SCHATTR_BAR_CONNECT, sal_True, &pPoolItem) == SFX_ITEM_SET) 163 { 164 sal_Bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 165 aCBConnect.Check(bCheck); 166 } 167 168 if (rInAttrs.GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, sal_True, &pPoolItem) == SFX_ITEM_SET) 169 { 170 m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 171 aCBAxisSideBySide.Disable(); 172 } 173 if (rInAttrs.GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) 174 { 175 // model property is "group bars per axis", UI feature is the other way 176 // round: "show bars side by side" 177 sal_Bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); 178 aCBAxisSideBySide.Check( bCheck ); 179 } 180 else 181 { 182 aCBAxisSideBySide.Show(sal_False); 183 } 184 185 186 //missing value treatment 187 { 188 ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments; 189 if( rInAttrs.GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, sal_True, &pPoolItem) == SFX_ITEM_SET ) 190 aMissingValueTreatments =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); 191 192 if ( aMissingValueTreatments.getLength()>1 && rInAttrs.GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,sal_True, &pPoolItem) == SFX_ITEM_SET) 193 { 194 m_aRB_DontPaint.Enable(sal_False); 195 m_aRB_AssumeZero.Enable(sal_False); 196 m_aRB_ContinueLine.Enable(sal_False); 197 198 for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ ) 199 { 200 sal_Int32 nVal = aMissingValueTreatments[nN]; 201 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP) 202 m_aRB_DontPaint.Enable(sal_True); 203 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO) 204 m_aRB_AssumeZero.Enable(sal_True); 205 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE) 206 m_aRB_ContinueLine.Enable(sal_True); 207 } 208 209 long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); 210 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP) 211 m_aRB_DontPaint.Check(sal_True); 212 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO) 213 m_aRB_AssumeZero.Check(sal_True); 214 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE) 215 m_aRB_ContinueLine.Check(sal_True); 216 } 217 else 218 { 219 m_aFT_MissingValues.Show(sal_False); 220 m_aRB_DontPaint.Show(sal_False); 221 m_aRB_AssumeZero.Show(sal_False); 222 m_aRB_ContinueLine.Show(sal_False); 223 } 224 } 225 226 // Include hidden cells 227 if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True, &pPoolItem) == SFX_ITEM_SET) 228 { 229 bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); 230 m_aCBIncludeHiddenCells.Check(bVal); 231 } 232 else 233 { 234 m_aCBIncludeHiddenCells.Show(sal_False); 235 if(!m_aFT_MissingValues.IsVisible()) 236 m_aFL_PlotOptions.Show(sal_False); 237 } 238 239 AdaptControlPositionsAndVisibility(); 240 } 241 242 void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors ) 243 { 244 m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis; 245 m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth; 246 m_bProvidesBarConnectors = bProvidesBarConnectors; 247 248 AdaptControlPositionsAndVisibility(); 249 } 250 251 void lcl_offsetControl(Control& rCtrl, long nXOffset, long nYOffset ) 252 { 253 Point aPos = rCtrl.GetPosPixel(); 254 rCtrl.SetPosPixel( Point(aPos.getX() + nXOffset, aPos.getY() + nYOffset) ); 255 } 256 257 void lcl_optimzeRadioButtonSize( RadioButton& rCtrl ) 258 { 259 rCtrl.SetSizePixel( rCtrl.CalcMinimumSize() ); 260 } 261 262 void SchOptionTabPage::AdaptControlPositionsAndVisibility() 263 { 264 aRbtAxis1.Show(m_bProvidesSecondaryYAxis); 265 aRbtAxis2.Show(m_bProvidesSecondaryYAxis); 266 aGrpAxis.Show(m_bProvidesSecondaryYAxis); 267 268 aMTGap.Show(m_bProvidesOverlapAndGapWidth); 269 aFTGap.Show(m_bProvidesOverlapAndGapWidth); 270 271 aMTOverlap.Show(m_bProvidesOverlapAndGapWidth); 272 aFTOverlap.Show(m_bProvidesOverlapAndGapWidth); 273 274 aCBConnect.Show(m_bProvidesBarConnectors); 275 276 if( !aMTGap.IsVisible() && !aMTOverlap.IsVisible() ) 277 { 278 aGrpBar.Show(sal_False); 279 Point aPos; 280 if( !aRbtAxis1.IsVisible() && !aRbtAxis2.IsVisible() ) 281 aPos = aGrpAxis.GetPosPixel(); 282 else 283 aPos = aGrpBar.GetPosPixel(); 284 285 long nYOffset = aPos.getY() - m_aFL_PlotOptions.GetPosPixel().getY(); 286 lcl_offsetControl(m_aFL_PlotOptions, 0, nYOffset); 287 lcl_offsetControl(m_aFT_MissingValues, 0, nYOffset); 288 lcl_offsetControl(m_aRB_DontPaint, 0, nYOffset); 289 lcl_offsetControl(m_aRB_AssumeZero, 0, nYOffset); 290 lcl_offsetControl(m_aRB_ContinueLine, 0, nYOffset); 291 lcl_offsetControl(m_aCBIncludeHiddenCells, 0, nYOffset); 292 } 293 294 m_aFT_MissingValues.SetSizePixel( m_aFT_MissingValues.CalcMinimumSize() ); 295 lcl_optimzeRadioButtonSize( m_aRB_DontPaint ); 296 lcl_optimzeRadioButtonSize( m_aRB_AssumeZero ); 297 lcl_optimzeRadioButtonSize( m_aRB_ContinueLine ); 298 299 Size aControlDistance( m_aFT_MissingValues.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) ); 300 long nXOffset = m_aFT_MissingValues.GetPosPixel().getX() + m_aFT_MissingValues.GetSizePixel().getWidth() + aControlDistance.getWidth() - m_aRB_DontPaint.GetPosPixel().getX(); 301 lcl_offsetControl(m_aRB_DontPaint, nXOffset, 0); 302 lcl_offsetControl(m_aRB_AssumeZero, nXOffset, 0); 303 lcl_offsetControl(m_aRB_ContinueLine, nXOffset, 0); 304 305 if( !m_aFT_MissingValues.IsVisible() ) 306 { 307 //for example for stock charts 308 m_aCBIncludeHiddenCells.SetPosPixel( m_aFT_MissingValues.GetPosPixel() ); 309 } 310 } 311 //............................................................................. 312 } //namespace chart 313 //............................................................................. 314