fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_SeriesToAxis.cxx
blobe6d37217875207e12240bfa24c7fbe6bfff0a1cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "tp_SeriesToAxis.hxx"
22 #include "ResId.hxx"
23 #include "chartview/ChartSfxItemIds.hxx"
25 #include <svl/eitem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svl/ilstitem.hxx>
28 #include <svtools/controldims.hrc>
30 #include <com/sun/star/chart/MissingValueTreatment.hpp>
32 namespace chart
35 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 , m_bProvidesBarConnectors(false)
45 get(m_pGrpAxis,"frameGrpAxis");
46 get(m_pRbtAxis1,"RBT_OPT_AXIS_1");
47 get(m_pRbtAxis2,"RBT_OPT_AXIS_2");
49 get(m_pGrpBar,"frameSettings");
50 get(m_pMTGap,"MT_GAP");
51 get(m_pMTOverlap,"MT_OVERLAP");
52 get(m_pCBConnect,"CB_CONNECTOR");
53 get(m_pCBAxisSideBySide,"CB_BARS_SIDE_BY_SIDE");
55 get(m_pGrpPlotOptions,"frameFL_PLOT_OPTIONS" );
56 get(m_pGridPlotOptions,"gridPLOT_OPTIONS");
57 get(m_pRB_DontPaint,"RB_DONT_PAINT");
58 get(m_pRB_AssumeZero,"RB_ASSUME_ZERO");
59 get(m_pRB_ContinueLine,"RB_CONTINUE_LINE");
60 get(m_pCBIncludeHiddenCells,"CB_INCLUDE_HIDDEN_CELLS");
62 m_pRbtAxis1->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
63 m_pRbtAxis2->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
66 SchOptionTabPage::~SchOptionTabPage()
68 disposeOnce();
71 void SchOptionTabPage::dispose()
73 m_pGrpAxis.clear();
74 m_pRbtAxis1.clear();
75 m_pRbtAxis2.clear();
76 m_pGrpBar.clear();
77 m_pMTGap.clear();
78 m_pMTOverlap.clear();
79 m_pCBConnect.clear();
80 m_pCBAxisSideBySide.clear();
81 m_pGrpPlotOptions.clear();
82 m_pGridPlotOptions.clear();
83 m_pRB_DontPaint.clear();
84 m_pRB_AssumeZero.clear();
85 m_pRB_ContinueLine.clear();
86 m_pCBIncludeHiddenCells.clear();
87 SfxTabPage::dispose();
90 IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl)
92 if( m_nAllSeriesAxisIndex == 0 )
93 m_pCBAxisSideBySide->Enable( m_pRbtAxis2->IsChecked());
94 else if( m_nAllSeriesAxisIndex == 1 )
95 m_pCBAxisSideBySide->Enable( m_pRbtAxis1->IsChecked());
97 return 0;
100 VclPtr<SfxTabPage> SchOptionTabPage::Create(vcl::Window* pWindow,
101 const SfxItemSet* rOutAttrs)
103 return VclPtr<SchOptionTabPage>::Create(pWindow, *rOutAttrs);
106 bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
108 if(m_pRbtAxis2->IsChecked())
109 rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y));
110 else
111 rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y));
113 if(m_pMTGap->IsVisible())
114 rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( m_pMTGap->GetValue())));
116 if(m_pMTOverlap->IsVisible())
117 rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( m_pMTOverlap->GetValue())));
119 if(m_pCBConnect->IsVisible())
120 rOutAttrs->Put(SfxBoolItem(SCHATTR_BAR_CONNECT,m_pCBConnect->IsChecked()));
122 // model property is "group bars per axis", UI feature is the other way
123 // round: "show bars side by side"
124 if(m_pCBAxisSideBySide->IsVisible())
125 rOutAttrs->Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! m_pCBAxisSideBySide->IsChecked()));
127 if(m_pRB_DontPaint->IsChecked())
128 rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP));
129 else if(m_pRB_AssumeZero->IsChecked())
130 rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO));
131 else if(m_pRB_ContinueLine->IsChecked())
132 rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE));
134 if (m_pCBIncludeHiddenCells->IsVisible())
135 rOutAttrs->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_pCBIncludeHiddenCells->IsChecked()));
137 return true;
140 void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
142 const SfxPoolItem *pPoolItem = NULL;
144 m_pRbtAxis1->Check(true);
145 m_pRbtAxis2->Check(false);
146 if (rInAttrs->GetItemState(SCHATTR_AXIS,true, &pPoolItem) == SfxItemState::SET)
148 long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
149 if(nVal==CHART_AXIS_SECONDARY_Y)
151 m_pRbtAxis2->Check(true);
152 m_pRbtAxis1->Check(false);
156 long nTmp;
157 if (rInAttrs->GetItemState(SCHATTR_BAR_GAPWIDTH, true, &pPoolItem) == SfxItemState::SET)
159 nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
160 m_pMTGap->SetValue(nTmp);
163 if (rInAttrs->GetItemState(SCHATTR_BAR_OVERLAP, true, &pPoolItem) == SfxItemState::SET)
165 nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
166 m_pMTOverlap->SetValue(nTmp);
169 if (rInAttrs->GetItemState(SCHATTR_BAR_CONNECT, true, &pPoolItem) == SfxItemState::SET)
171 bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
172 m_pCBConnect->Check(bCheck);
175 if (rInAttrs->GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, true, &pPoolItem) == SfxItemState::SET)
177 m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
178 m_pCBAxisSideBySide->Disable();
180 if (rInAttrs->GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, true, &pPoolItem) == SfxItemState::SET)
182 // model property is "group bars per axis", UI feature is the other way
183 // round: "show bars side by side"
184 bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
185 m_pCBAxisSideBySide->Check( bCheck );
187 else
189 m_pCBAxisSideBySide->Show(false);
192 //missing value treatment
194 ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments;
195 if( rInAttrs->GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, true, &pPoolItem) == SfxItemState::SET )
196 aMissingValueTreatments =static_cast<const SfxIntegerListItem*>(pPoolItem)->GetConstSequence();
198 if ( aMissingValueTreatments.getLength()>1 && rInAttrs->GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,true, &pPoolItem) == SfxItemState::SET)
200 m_pRB_DontPaint->Enable(false);
201 m_pRB_AssumeZero->Enable(false);
202 m_pRB_ContinueLine->Enable(false);
204 for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ )
206 sal_Int32 nVal = aMissingValueTreatments[nN];
207 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
208 m_pRB_DontPaint->Enable(true);
209 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
210 m_pRB_AssumeZero->Enable(true);
211 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
212 m_pRB_ContinueLine->Enable(true);
215 long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
216 if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
217 m_pRB_DontPaint->Check(true);
218 else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
219 m_pRB_AssumeZero->Check(true);
220 else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
221 m_pRB_ContinueLine->Check(true);
223 else
225 m_pGridPlotOptions->Show(false);
229 // Include hidden cells
230 if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) == SfxItemState::SET)
232 bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
233 m_pCBIncludeHiddenCells->Check(bVal);
235 else
237 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 if(!m_pGridPlotOptions->IsVisible())
242 m_pGrpPlotOptions->Show(false);
245 AdaptControlPositionsAndVisibility();
248 void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors )
250 m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis;
251 m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth;
252 m_bProvidesBarConnectors = bProvidesBarConnectors;
254 AdaptControlPositionsAndVisibility();
257 void SchOptionTabPage::AdaptControlPositionsAndVisibility()
259 m_pGrpAxis->Show(m_bProvidesSecondaryYAxis);
261 m_pGrpBar->Show(m_bProvidesOverlapAndGapWidth);
263 m_pCBConnect->Show(m_bProvidesBarConnectors);
265 if( !m_pMTGap->IsVisible() && !m_pMTOverlap->IsVisible() )
267 m_pGrpBar->Show(false);
270 } //namespace chart
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */