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 #include "precompiled_chart2.hxx"
25 #include "tp_PolarOptions.hxx"
26 #include "tp_PolarOptions.hrc"
27 #include "ResId.hxx"
28 #include "chartview/ChartSfxItemIds.hxx"
29 #include "NoWarningThisInCTOR.hxx"
30 
31 #include <svl/eitem.hxx>
32 #include <svl/intitem.hxx>
33 #include <svtools/controldims.hrc>
34 
35 //.............................................................................
36 namespace chart
37 {
38 //.............................................................................
39 
PolarOptionsTabPage(Window * pWindow,const SfxItemSet & rInAttrs)40 PolarOptionsTabPage::PolarOptionsTabPage( Window* pWindow,const SfxItemSet& rInAttrs ) :
41     SfxTabPage( pWindow, SchResId(TP_POLAROPTIONS), rInAttrs ),
42     m_aCB_Clockwise( this, SchResId( CB_CLOCKWISE ) ),
43     m_aFL_StartingAngle( this, SchResId( FL_STARTING_ANGLE ) ),
44     m_aAngleDial( this, SchResId( CT_ANGLE_DIAL ) ),
45     m_aFT_Degrees( this, SchResId( FT_ROTATION_DEGREES ) ),
46     m_aNF_StartingAngle( this, SchResId( NF_STARTING_ANGLE ) ),
47     m_aFL_PlotOptions( this, SchResId( FL_PLOT_OPTIONS_POLAR ) ),
48     m_aCB_IncludeHiddenCells( this, SchResId( CB_INCLUDE_HIDDEN_CELLS_POLAR ) )
49 {
50     FreeResource();
51 
52     m_aAngleDial.SetLinkedField( &m_aNF_StartingAngle );
53 }
54 
~PolarOptionsTabPage()55 PolarOptionsTabPage::~PolarOptionsTabPage()
56 {
57 }
58 
Create(Window * pWindow,const SfxItemSet & rOutAttrs)59 SfxTabPage* PolarOptionsTabPage::Create( Window* pWindow,const SfxItemSet& rOutAttrs )
60 {
61     return new PolarOptionsTabPage( pWindow, rOutAttrs );
62 }
63 
FillItemSet(SfxItemSet & rOutAttrs)64 sal_Bool PolarOptionsTabPage::FillItemSet( SfxItemSet& rOutAttrs )
65 {
66     if( m_aAngleDial.IsVisible() )
67     {
68         rOutAttrs.Put(SfxInt32Item(SCHATTR_STARTING_ANGLE,
69             static_cast< sal_Int32 >(m_aAngleDial.GetRotation()/100)));
70     }
71 
72     if( m_aCB_Clockwise.IsVisible() )
73         rOutAttrs.Put(SfxBoolItem(SCHATTR_CLOCKWISE,m_aCB_Clockwise.IsChecked()));
74 
75     if (m_aCB_IncludeHiddenCells.IsVisible())
76         rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCB_IncludeHiddenCells.IsChecked()));
77 
78     return sal_True;
79 }
80 
Reset(const SfxItemSet & rInAttrs)81 void PolarOptionsTabPage::Reset(const SfxItemSet& rInAttrs)
82 {
83     const SfxPoolItem *pPoolItem = NULL;
84 
85     long nTmp;
86     if (rInAttrs.GetItemState(SCHATTR_STARTING_ANGLE, sal_True, &pPoolItem) == SFX_ITEM_SET)
87     {
88         nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue();
89 
90         m_aAngleDial.SetRotation( nTmp*100 );
91     }
92     else
93     {
94         m_aFL_StartingAngle.Show(sal_False);
95         m_aAngleDial.Show(sal_False);
96         m_aNF_StartingAngle.Show(sal_False);
97         m_aFT_Degrees.Show(sal_False);
98     }
99     if (rInAttrs.GetItemState(SCHATTR_CLOCKWISE, sal_True, &pPoolItem) == SFX_ITEM_SET)
100     {
101         sal_Bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
102         m_aCB_Clockwise.Check(bCheck);
103     }
104     else
105     {
106         m_aCB_Clockwise.Show(sal_False);
107     }
108     if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True, &pPoolItem) == SFX_ITEM_SET)
109     {
110         bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
111         m_aCB_IncludeHiddenCells.Check(bVal);
112     }
113     else
114     {
115         m_aCB_IncludeHiddenCells.Show(sal_False);
116         m_aFL_PlotOptions.Show(sal_False);
117     }
118 }
119 
120 //.............................................................................
121 } //namespace chart
122 //.............................................................................
123