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_AxisLabel.hxx"
21 :
22 : #include "ResId.hxx"
23 : #include "ResourceIds.hrc"
24 : #include "chartview/ChartSfxItemIds.hxx"
25 :
26 : #include <svx/chrtitem.hxx>
27 : #include <svl/intitem.hxx>
28 : #include <editeng/eeitem.hxx>
29 : #include <editeng/frmdiritem.hxx>
30 :
31 : namespace chart
32 : {
33 :
34 0 : SchAxisLabelTabPage::SchAxisLabelTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ) :
35 : SfxTabPage( pParent, "AxisLabelTabPage","modules/schart/ui/tp_axisLabel.ui", &rInAttrs ),
36 :
37 : m_bShowStaggeringControls( true ),
38 :
39 : m_nInitialDegrees( 0 ),
40 : m_bHasInitialDegrees( true ),
41 : m_bInitialStacking( false ),
42 : m_bHasInitialStacking( true ),
43 0 : m_bComplexCategories( false )
44 : {
45 0 : get(m_pCbShowDescription, "showlabelsCB");
46 0 : get(m_pFlOrder, "orderL");
47 0 : get(m_pRbSideBySide, "tile");
48 0 : get(m_pRbUpDown, "odd");
49 0 : get(m_pRbDownUp, "even");
50 0 : get(m_pRbAuto, "auto");
51 0 : get(m_pFlTextFlow, "textflowL");
52 0 : get(m_pCbTextOverlap, "overlapCB");
53 0 : get(m_pCbTextBreak, "breakCB");
54 0 : get(m_pFlOrient, "labelTextOrient");
55 0 : get(m_pCtrlDial,"dialCtrl");
56 0 : get(m_pFtRotate,"degreeL");
57 0 : get(m_pNfRotate,"OrientDegree");
58 0 : get(m_pCbStacked,"stackedCB");
59 0 : get(m_pFtTextDirection,"textdirL");
60 0 : get(m_pLbTextDirection,"textdirLB");
61 0 : get(m_pFtABCD,"labelABCD");
62 0 : m_pCtrlDial->SetText(m_pFtABCD->GetText());
63 0 : m_pOrientHlp = new svx::OrientationHelper(*m_pCtrlDial, *m_pNfRotate, *m_pCbStacked);
64 0 : m_pOrientHlp->Enable( true );
65 :
66 0 : m_pCbStacked->EnableTriState( false );
67 0 : m_pOrientHlp->AddDependentWindow( *m_pFlOrient );
68 0 : m_pOrientHlp->AddDependentWindow( *m_pFtRotate, TRISTATE_TRUE );
69 :
70 0 : m_pCbShowDescription->SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) );
71 :
72 0 : Construct();
73 0 : }
74 :
75 0 : SchAxisLabelTabPage::~SchAxisLabelTabPage()
76 0 : {delete m_pOrientHlp;}
77 :
78 0 : void SchAxisLabelTabPage::Construct()
79 : {
80 0 : }
81 :
82 0 : SfxTabPage* SchAxisLabelTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrs )
83 : {
84 0 : return new SchAxisLabelTabPage( pParent, *rAttrs );
85 : }
86 :
87 0 : bool SchAxisLabelTabPage::FillItemSet( SfxItemSet* rOutAttrs )
88 : {
89 0 : bool bStacked = false;
90 0 : if( m_pOrientHlp->GetStackedState() != TRISTATE_INDET )
91 : {
92 0 : bStacked = m_pOrientHlp->GetStackedState() == TRISTATE_TRUE;
93 0 : if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
94 0 : rOutAttrs->Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
95 : }
96 :
97 0 : if( m_pCtrlDial->HasRotation() )
98 : {
99 0 : sal_Int32 nDegrees = bStacked ? 0 : m_pCtrlDial->GetRotation();
100 0 : if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
101 0 : rOutAttrs->Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
102 : }
103 :
104 0 : if( m_bShowStaggeringControls )
105 : {
106 0 : SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE;
107 0 : bool bRadioButtonChecked = true;
108 :
109 0 : if( m_pRbUpDown->IsChecked())
110 0 : eOrder = CHTXTORDER_UPDOWN;
111 0 : else if( m_pRbDownUp->IsChecked())
112 0 : eOrder = CHTXTORDER_DOWNUP;
113 0 : else if( m_pRbAuto->IsChecked())
114 0 : eOrder = CHTXTORDER_AUTO;
115 0 : else if( m_pRbSideBySide->IsChecked())
116 0 : eOrder = CHTXTORDER_SIDEBYSIDE;
117 : else
118 0 : bRadioButtonChecked = false;
119 :
120 0 : if( bRadioButtonChecked )
121 0 : rOutAttrs->Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER ));
122 : }
123 :
124 0 : if( m_pCbTextOverlap->GetState() != TRISTATE_INDET )
125 0 : rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, m_pCbTextOverlap->IsChecked() ) );
126 0 : if( m_pCbTextBreak->GetState() != TRISTATE_INDET )
127 0 : rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, m_pCbTextBreak->IsChecked() ) );
128 0 : if( m_pCbShowDescription->GetState() != TRISTATE_INDET )
129 0 : rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, m_pCbShowDescription->IsChecked() ) );
130 :
131 0 : if( m_pLbTextDirection->GetSelectEntryCount() > 0 )
132 0 : rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR ) );
133 :
134 0 : return true;
135 : }
136 :
137 0 : void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs )
138 : {
139 0 : const SfxPoolItem* pPoolItem = NULL;
140 :
141 : // show description
142 0 : SfxItemState aState = rInAttrs->GetItemState( SCHATTR_AXIS_SHOWDESCR, false, &pPoolItem );
143 0 : if( aState == SfxItemState::DONTCARE )
144 : {
145 0 : m_pCbShowDescription->EnableTriState( true );
146 0 : m_pCbShowDescription->SetState( TRISTATE_INDET );
147 : }
148 : else
149 : {
150 0 : m_pCbShowDescription->EnableTriState( false );
151 0 : bool bCheck = false;
152 0 : if( aState == SfxItemState::SET )
153 0 : bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
154 0 : m_pCbShowDescription->Check( bCheck );
155 :
156 0 : if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
157 0 : m_pCbShowDescription->Hide();
158 : }
159 :
160 : // Rotation as orient item or in degrees ----------
161 :
162 : // check new degree item
163 0 : m_nInitialDegrees = 0;
164 0 : aState = rInAttrs->GetItemState( SCHATTR_TEXT_DEGREES, false, &pPoolItem );
165 0 : if( aState == SfxItemState::SET )
166 0 : m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
167 :
168 0 : m_bHasInitialDegrees = aState != SfxItemState::DONTCARE;
169 0 : if( m_bHasInitialDegrees )
170 0 : m_pCtrlDial->SetRotation( m_nInitialDegrees );
171 : else
172 0 : m_pCtrlDial->SetNoRotation();
173 :
174 : // check stacked item
175 0 : m_bInitialStacking = false;
176 0 : aState = rInAttrs->GetItemState( SCHATTR_TEXT_STACKED, false, &pPoolItem );
177 0 : if( aState == SfxItemState::SET )
178 0 : m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
179 :
180 0 : m_bHasInitialStacking = aState != SfxItemState::DONTCARE;
181 0 : if( m_bHasInitialDegrees )
182 0 : m_pOrientHlp->SetStackedState( m_bInitialStacking ? TRISTATE_TRUE : TRISTATE_FALSE );
183 : else
184 0 : m_pOrientHlp->SetStackedState( TRISTATE_INDET );
185 :
186 0 : if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET )
187 0 : m_pLbTextDirection->SelectEntryValue( SvxFrameDirection(static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue()) );
188 :
189 : // Text overlap ----------
190 0 : aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, false, &pPoolItem );
191 0 : if( aState == SfxItemState::DONTCARE )
192 : {
193 0 : m_pCbTextOverlap->EnableTriState( true );
194 0 : m_pCbTextOverlap->SetState( TRISTATE_INDET );
195 : }
196 : else
197 : {
198 0 : m_pCbTextOverlap->EnableTriState( false );
199 0 : bool bCheck = false;
200 0 : if( aState == SfxItemState::SET )
201 0 : bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
202 0 : m_pCbTextOverlap->Check( bCheck );
203 :
204 0 : if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
205 0 : m_pCbTextOverlap->Hide();
206 : }
207 :
208 : // text break ----------
209 0 : aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_BREAK, false, &pPoolItem );
210 0 : if( aState == SfxItemState::DONTCARE )
211 : {
212 0 : m_pCbTextBreak->EnableTriState( true );
213 0 : m_pCbTextBreak->SetState( TRISTATE_INDET );
214 : }
215 : else
216 : {
217 0 : m_pCbTextBreak->EnableTriState( false );
218 0 : bool bCheck = false;
219 0 : if( aState == SfxItemState::SET )
220 0 : bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
221 0 : m_pCbTextBreak->Check( bCheck );
222 :
223 0 : if( aState != SfxItemState::DEFAULT && aState != SfxItemState::SET )
224 : {
225 0 : m_pCbTextBreak->Hide();
226 0 : if( ! m_pCbTextOverlap->IsVisible() )
227 0 : m_pFlTextFlow->Hide();
228 : }
229 : }
230 :
231 : // text order ----------
232 0 : if( m_bShowStaggeringControls )
233 : {
234 0 : aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_ORDER, false, &pPoolItem );
235 0 : if( aState == SfxItemState::SET )
236 : {
237 0 : SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue();
238 :
239 0 : switch( eOrder )
240 : {
241 : case CHTXTORDER_SIDEBYSIDE:
242 0 : m_pRbSideBySide->Check();
243 0 : break;
244 : case CHTXTORDER_UPDOWN:
245 0 : m_pRbUpDown->Check();
246 0 : break;
247 : case CHTXTORDER_DOWNUP:
248 0 : m_pRbDownUp->Check();
249 0 : break;
250 : case CHTXTORDER_AUTO:
251 0 : m_pRbAuto->Check();
252 0 : break;
253 : }
254 : }
255 : }
256 :
257 0 : ToggleShowLabel( (void*)0 );
258 0 : }
259 :
260 0 : void SchAxisLabelTabPage::ShowStaggeringControls( bool bShowStaggeringControls )
261 : {
262 0 : m_bShowStaggeringControls = bShowStaggeringControls;
263 :
264 0 : if( !m_bShowStaggeringControls )
265 : {
266 0 : m_pRbSideBySide->Hide();
267 0 : m_pRbUpDown->Hide();
268 0 : m_pRbDownUp->Hide();
269 0 : m_pRbAuto->Hide();
270 0 : m_pFlOrder->Hide();
271 : }
272 0 : }
273 :
274 0 : void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories )
275 : {
276 0 : m_bComplexCategories = bComplexCategories;
277 0 : }
278 :
279 : // event handling routines
280 :
281 0 : IMPL_LINK_NOARG(SchAxisLabelTabPage, ToggleShowLabel)
282 : {
283 0 : bool bEnable = ( m_pCbShowDescription->GetState() != TRISTATE_FALSE );
284 :
285 0 : m_pOrientHlp->Enable( bEnable );
286 0 : m_pFlOrder->Enable( bEnable );
287 0 : m_pRbSideBySide->Enable( bEnable );
288 0 : m_pRbUpDown->Enable( bEnable );
289 0 : m_pRbDownUp->Enable( bEnable );
290 0 : m_pRbAuto->Enable( bEnable );
291 :
292 0 : m_pFlTextFlow->Enable( bEnable );
293 0 : m_pCbTextOverlap->Enable( bEnable && !m_bComplexCategories );
294 0 : m_pCbTextBreak->Enable( bEnable );
295 :
296 0 : m_pFtTextDirection->Enable( bEnable );
297 0 : m_pLbTextDirection->Enable( bEnable );
298 :
299 0 : return 0L;
300 : }
301 102 : } //namespace chart
302 :
303 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|