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_pGridPlotOptions,"gridPLOT_OPTIONS");
56 0 : get(m_pRB_DontPaint,"RB_DONT_PAINT");
57 0 : get(m_pRB_AssumeZero,"RB_ASSUME_ZERO");
58 0 : get(m_pRB_ContinueLine,"RB_CONTINUE_LINE");
59 0 : get(m_pCBIncludeHiddenCells,"CB_INCLUDE_HIDDEN_CELLS");
60 :
61 0 : m_pRbtAxis1->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
62 0 : m_pRbtAxis2->SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl ));
63 0 : }
64 :
65 0 : SchOptionTabPage::~SchOptionTabPage()
66 : {
67 0 : }
68 :
69 0 : IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl)
70 : {
71 0 : if( m_nAllSeriesAxisIndex == 0 )
72 0 : m_pCBAxisSideBySide->Enable( m_pRbtAxis2->IsChecked());
73 0 : else if( m_nAllSeriesAxisIndex == 1 )
74 0 : m_pCBAxisSideBySide->Enable( m_pRbtAxis1->IsChecked());
75 :
76 0 : return 0;
77 : }
78 :
79 0 : SfxTabPage* SchOptionTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs)
80 : {
81 0 : return new SchOptionTabPage(pWindow, *rOutAttrs);
82 : }
83 :
84 0 : bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
85 : {
86 0 : if(m_pRbtAxis2->IsChecked())
87 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y));
88 : else
89 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y));
90 :
91 0 : if(m_pMTGap->IsVisible())
92 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( m_pMTGap->GetValue())));
93 :
94 0 : if(m_pMTOverlap->IsVisible())
95 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( m_pMTOverlap->GetValue())));
96 :
97 0 : if(m_pCBConnect->IsVisible())
98 0 : rOutAttrs->Put(SfxBoolItem(SCHATTR_BAR_CONNECT,m_pCBConnect->IsChecked()));
99 :
100 : // model property is "group bars per axis", UI feature is the other way
101 : // round: "show bars side by side"
102 0 : if(m_pCBAxisSideBySide->IsVisible())
103 0 : rOutAttrs->Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! m_pCBAxisSideBySide->IsChecked()));
104 :
105 0 : if(m_pRB_DontPaint->IsChecked())
106 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP));
107 0 : else if(m_pRB_AssumeZero->IsChecked())
108 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO));
109 0 : else if(m_pRB_ContinueLine->IsChecked())
110 0 : rOutAttrs->Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE));
111 :
112 0 : if (m_pCBIncludeHiddenCells->IsVisible())
113 0 : rOutAttrs->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_pCBIncludeHiddenCells->IsChecked()));
114 :
115 0 : return true;
116 : }
117 :
118 0 : void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
119 : {
120 0 : const SfxPoolItem *pPoolItem = NULL;
121 :
122 0 : m_pRbtAxis1->Check(true);
123 0 : m_pRbtAxis2->Check(false);
124 0 : if (rInAttrs->GetItemState(SCHATTR_AXIS,true, &pPoolItem) == SfxItemState::SET)
125 : {
126 0 : long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
127 0 : if(nVal==CHART_AXIS_SECONDARY_Y)
128 : {
129 0 : m_pRbtAxis2->Check(true);
130 0 : m_pRbtAxis1->Check(false);
131 : }
132 : }
133 :
134 : long nTmp;
135 0 : if (rInAttrs->GetItemState(SCHATTR_BAR_GAPWIDTH, true, &pPoolItem) == SfxItemState::SET)
136 : {
137 0 : nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
138 0 : m_pMTGap->SetValue(nTmp);
139 : }
140 :
141 0 : if (rInAttrs->GetItemState(SCHATTR_BAR_OVERLAP, true, &pPoolItem) == SfxItemState::SET)
142 : {
143 0 : nTmp = (long)static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
144 0 : m_pMTOverlap->SetValue(nTmp);
145 : }
146 :
147 0 : if (rInAttrs->GetItemState(SCHATTR_BAR_CONNECT, true, &pPoolItem) == SfxItemState::SET)
148 : {
149 0 : bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
150 0 : m_pCBConnect->Check(bCheck);
151 : }
152 :
153 0 : if (rInAttrs->GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, true, &pPoolItem) == SfxItemState::SET)
154 : {
155 0 : m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
156 0 : m_pCBAxisSideBySide->Disable();
157 : }
158 0 : if (rInAttrs->GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, true, &pPoolItem) == SfxItemState::SET)
159 : {
160 : // model property is "group bars per axis", UI feature is the other way
161 : // round: "show bars side by side"
162 0 : bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
163 0 : m_pCBAxisSideBySide->Check( bCheck );
164 : }
165 : else
166 : {
167 0 : m_pCBAxisSideBySide->Show(false);
168 : }
169 :
170 : //missing value treatment
171 : {
172 0 : ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments;
173 0 : if( rInAttrs->GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, true, &pPoolItem) == SfxItemState::SET )
174 0 : aMissingValueTreatments =static_cast<const SfxIntegerListItem*>(pPoolItem)->GetConstSequence();
175 :
176 0 : if ( aMissingValueTreatments.getLength()>1 && rInAttrs->GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,true, &pPoolItem) == SfxItemState::SET)
177 : {
178 0 : m_pRB_DontPaint->Enable(false);
179 0 : m_pRB_AssumeZero->Enable(false);
180 0 : m_pRB_ContinueLine->Enable(false);
181 :
182 0 : for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ )
183 : {
184 0 : sal_Int32 nVal = aMissingValueTreatments[nN];
185 0 : if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
186 0 : m_pRB_DontPaint->Enable(true);
187 0 : else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
188 0 : m_pRB_AssumeZero->Enable(true);
189 0 : else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
190 0 : m_pRB_ContinueLine->Enable(true);
191 : }
192 :
193 0 : long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
194 0 : if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
195 0 : m_pRB_DontPaint->Check(true);
196 0 : else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO)
197 0 : m_pRB_AssumeZero->Check(true);
198 0 : else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE)
199 0 : m_pRB_ContinueLine->Check(true);
200 : }
201 : else
202 : {
203 0 : m_pGridPlotOptions->Show(false);
204 0 : }
205 : }
206 :
207 : // Include hidden cells
208 0 : if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) == SfxItemState::SET)
209 : {
210 0 : bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
211 0 : m_pCBIncludeHiddenCells->Check(bVal);
212 : }
213 : else
214 : {
215 0 : m_pCBIncludeHiddenCells->Show(false);
216 0 : m_pGridPlotOptions->Show(false);
217 : }
218 :
219 0 : AdaptControlPositionsAndVisibility();
220 0 : }
221 :
222 0 : void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors )
223 : {
224 0 : m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis;
225 0 : m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth;
226 0 : m_bProvidesBarConnectors = bProvidesBarConnectors;
227 :
228 0 : AdaptControlPositionsAndVisibility();
229 0 : }
230 :
231 0 : void SchOptionTabPage::AdaptControlPositionsAndVisibility()
232 : {
233 0 : m_pGrpAxis->Show(m_bProvidesSecondaryYAxis);
234 :
235 0 : m_pGrpBar->Show(m_bProvidesOverlapAndGapWidth);
236 :
237 0 : m_pCBConnect->Show(m_bProvidesBarConnectors);
238 :
239 0 : if( !m_pMTGap->IsVisible() && !m_pMTOverlap->IsVisible() )
240 : {
241 0 : m_pGrpBar->Show(false);
242 : }
243 0 : }
244 102 : } //namespace chart
245 :
246 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|