1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "tp_AxisLabel.hxx"
27 
28 #include "ResId.hxx"
29 #include "TabPages.hrc"
30 #include "chartview/ChartSfxItemIds.hxx"
31 #include "NoWarningThisInCTOR.hxx"
32 
33 // header for SvxChartTextOrientItem / SvxChartTextOrderItem
34 #include <svx/chrtitem.hxx>
35 
36 // header for SfxInt32Item
37 #include <svl/intitem.hxx>
38 #include <editeng/eeitem.hxx>
39 #include <editeng/frmdiritem.hxx>
40 
41 //.............................................................................
42 namespace chart
43 {
44 //.............................................................................
45 
SchAxisLabelTabPage(Window * pParent,const SfxItemSet & rInAttrs)46 SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
47 		SfxTabPage( pParent, SchResId( TP_AXIS_LABEL ), rInAttrs ),
48 
49 		aCbShowDescription( this, SchResId( CB_AXIS_LABEL_SCHOW_DESCR ) ),
50 
51 		aFlOrder( this, SchResId( FL_AXIS_LABEL_ORDER ) ),
52 		aRbSideBySide( this, SchResId( RB_AXIS_LABEL_SIDEBYSIDE ) ),
53 		aRbUpDown( this, SchResId( RB_AXIS_LABEL_UPDOWN ) ),
54 		aRbDownUp( this, SchResId( RB_AXIS_LABEL_DOWNUP ) ),
55 		aRbAuto( this, SchResId( RB_AXIS_LABEL_AUTOORDER ) ),
56 
57         aFlSeparator( this, SchResId( FL_SEPARATOR ) ),
58         aFlTextFlow( this, SchResId( FL_AXIS_LABEL_TEXTFLOW ) ),
59         aCbTextOverlap( this, SchResId( CB_AXIS_LABEL_TEXTOVERLAP ) ),
60         aCbTextBreak( this, SchResId( CB_AXIS_LABEL_TEXTBREAK ) ),
61 
62         aFlOrient( this, SchResId( FL_AXIS_LABEL_ORIENTATION ) ),
63         aCtrlDial( this, SchResId( CT_AXIS_LABEL_DIAL ) ),
64         aFtRotate( this, SchResId( FT_AXIS_LABEL_DEGREES ) ),
65         aNfRotate( this, SchResId( NF_AXIS_LABEL_ORIENT ) ),
66         aCbStacked( this, SchResId( PB_AXIS_LABEL_TEXTSTACKED ) ),
67         aOrientHlp( aCtrlDial, aNfRotate, aCbStacked ),
68 
69         m_aFtTextDirection( this, SchResId( FT_AXIS_TEXTDIR ) ),
70         m_aLbTextDirection( this, SchResId( LB_AXIS_TEXTDIR ), &m_aFtTextDirection ),
71 
72 		m_bShowStaggeringControls( true ),
73 
74         m_nInitialDegrees( 0 ),
75         m_bHasInitialDegrees( true ),
76         m_bInitialStacking( false ),
77         m_bHasInitialStacking( true ),
78         m_bComplexCategories( false )
79 {
80 	FreeResource();
81 
82     aCbStacked.EnableTriState( sal_False );
83     aOrientHlp.AddDependentWindow( aFlOrient );
84     aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK );
85 
86 	aCbShowDescription.SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) );
87 
88     //	Make the fixed line separator vertical.
89     aFlSeparator.SetStyle (aFlSeparator.GetStyle() | WB_VERT);
90 
91 	Construct();
92 }
93 
~SchAxisLabelTabPage()94 SchAxisLabelTabPage::~SchAxisLabelTabPage()
95 {}
96 
Construct()97 void SchAxisLabelTabPage::Construct()
98 {
99 }
100 
101 
Create(Window * pParent,const SfxItemSet & rAttrs)102 SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs )
103 {
104 	return new SchAxisLabelTabPage( pParent, rAttrs );
105 }
106 
FillItemSet(SfxItemSet & rOutAttrs)107 sal_Bool SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs )
108 {
109     bool bStacked = false;
110     if( aOrientHlp.GetStackedState() != STATE_DONTKNOW )
111     {
112         bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
113         if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) )
114             rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
115     }
116 
117     if( aCtrlDial.HasRotation() )
118     {
119         sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation();
120         if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) )
121             rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
122     }
123 
124     if( m_bShowStaggeringControls )
125 	{
126 		SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE;
127         bool bRadioButtonChecked = true;
128 
129 		if( aRbUpDown.IsChecked())
130 			eOrder = CHTXTORDER_UPDOWN;
131 		else if( aRbDownUp.IsChecked())
132 			eOrder = CHTXTORDER_DOWNUP;
133 		else if( aRbAuto.IsChecked())
134 			eOrder = CHTXTORDER_AUTO;
135 		else if( aRbSideBySide.IsChecked())
136             eOrder = CHTXTORDER_SIDEBYSIDE;
137         else
138             bRadioButtonChecked = false;
139 
140         if( bRadioButtonChecked )
141             rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER ));
142 	}
143 
144     if( aCbTextOverlap.GetState() != STATE_DONTKNOW )
145         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) );
146     if( aCbTextBreak.GetState() != STATE_DONTKNOW )
147         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) );
148     if( aCbShowDescription.GetState() != STATE_DONTKNOW )
149         rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) );
150 
151     if( m_aLbTextDirection.GetSelectEntryCount() > 0 )
152         rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) );
153 
154 	return sal_True;
155 }
156 
Reset(const SfxItemSet & rInAttrs)157 void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs )
158 {
159 	const SfxPoolItem* pPoolItem = NULL;
160     SfxItemState aState = SFX_ITEM_UNKNOWN;
161 
162     // show description ----------
163     aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, sal_False, &pPoolItem );
164     if( aState == SFX_ITEM_DONTCARE )
165     {
166         aCbShowDescription.EnableTriState( sal_True );
167         aCbShowDescription.SetState( STATE_DONTKNOW );
168     }
169     else
170     {
171         aCbShowDescription.EnableTriState( sal_False );
172         sal_Bool bCheck = sal_False;
173         if( aState == SFX_ITEM_SET )
174             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
175         aCbShowDescription.Check( bCheck );
176 
177         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
178             aCbShowDescription.Hide();
179     }
180 
181     // Rotation as orient item or in degrees ----------
182 
183     // check new degree item
184     m_nInitialDegrees = 0;
185     aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_False, &pPoolItem );
186     if( aState == SFX_ITEM_SET )
187         m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
188 
189     m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE;
190     if( m_bHasInitialDegrees )
191         aCtrlDial.SetRotation( m_nInitialDegrees );
192     else
193         aCtrlDial.SetNoRotation();
194 
195     // check stacked item
196     m_bInitialStacking = false;
197     aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, sal_False, &pPoolItem );
198     if( aState == SFX_ITEM_SET )
199         m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
200 
201     m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE;
202     if( m_bHasInitialDegrees )
203         aOrientHlp.SetStackedState( m_bInitialStacking ? STATE_CHECK : STATE_NOCHECK );
204     else
205         aOrientHlp.SetStackedState( STATE_DONTKNOW );
206 
207     if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET )
208         m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) );
209 
210     // Text overlap ----------
211     aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, sal_False, &pPoolItem );
212     if( aState == SFX_ITEM_DONTCARE )
213     {
214         aCbTextOverlap.EnableTriState( sal_True );
215         aCbTextOverlap.SetState( STATE_DONTKNOW );
216     }
217     else
218     {
219         aCbTextOverlap.EnableTriState( sal_False );
220         sal_Bool bCheck = sal_False;
221         if( aState == SFX_ITEM_SET )
222             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
223         aCbTextOverlap.Check( bCheck );
224 
225         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
226             aCbTextOverlap.Hide();
227     }
228 
229     // text break ----------
230     aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, sal_False, &pPoolItem );
231     if( aState == SFX_ITEM_DONTCARE )
232     {
233         aCbTextBreak.EnableTriState( sal_True );
234         aCbTextBreak.SetState( STATE_DONTKNOW );
235     }
236     else
237     {
238         aCbTextBreak.EnableTriState( sal_False );
239         sal_Bool bCheck = sal_False;
240         if( aState == SFX_ITEM_SET )
241             bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
242         aCbTextBreak.Check( bCheck );
243 
244         if( ( aState & SFX_ITEM_DEFAULT ) == 0 )
245         {
246             aCbTextBreak.Hide();
247             if( ! aCbTextOverlap.IsVisible() )
248                 aFlTextFlow.Hide();
249         }
250     }
251 
252     // text order ----------
253     if( m_bShowStaggeringControls )
254     {
255         aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, sal_False, &pPoolItem );
256         if( aState == SFX_ITEM_SET )
257         {
258             SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue();
259 
260             switch( eOrder )
261             {
262                 case CHTXTORDER_SIDEBYSIDE:
263                     aRbSideBySide.Check();
264                     break;
265                 case CHTXTORDER_UPDOWN:
266                     aRbUpDown.Check();
267                     break;
268                 case CHTXTORDER_DOWNUP:
269                     aRbDownUp.Check();
270                     break;
271                 case CHTXTORDER_AUTO:
272                     aRbAuto.Check();
273                     break;
274             }
275         }
276     }
277 
278     ToggleShowLabel( (void*)0 );
279 }
280 
ShowStaggeringControls(sal_Bool bShowStaggeringControls)281 void SchAxisLabelTabPage::ShowStaggeringControls( sal_Bool bShowStaggeringControls )
282 {
283     m_bShowStaggeringControls = bShowStaggeringControls;
284 
285     if( !m_bShowStaggeringControls )
286 	{
287 		aRbSideBySide.Hide();
288 		aRbUpDown.Hide();
289 		aRbDownUp.Hide();
290 		aRbAuto.Hide();
291 		aFlOrder.Hide();
292 	}
293 }
294 
SetComplexCategories(bool bComplexCategories)295 void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories )
296 {
297     m_bComplexCategories = bComplexCategories;
298 }
299 
300 // event handling routines
301 // -----------------------
302 
IMPL_LINK(SchAxisLabelTabPage,ToggleShowLabel,void *,EMPTYARG)303 IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG )
304 {
305     sal_Bool bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK );
306 
307     aOrientHlp.Enable( bEnable );
308 	aFlOrder.Enable( bEnable );
309 	aRbSideBySide.Enable( bEnable );
310 	aRbUpDown.Enable( bEnable );
311 	aRbDownUp.Enable( bEnable );
312 	aRbAuto.Enable( bEnable );
313 
314 	aFlTextFlow.Enable( bEnable );
315 	aCbTextOverlap.Enable( bEnable && !m_bComplexCategories );
316 	aCbTextBreak.Enable( bEnable );
317 
318     m_aFtTextDirection.Enable( bEnable );
319     m_aLbTextDirection.Enable( bEnable );
320 
321 	return 0L;
322 }
323 //.............................................................................
324 } //namespace chart
325 //.............................................................................
326