1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19*cde9e8dcSAndrew Rist  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "tp_AxisPositions.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "ResId.hxx"
29cdf0e10cSrcweir #include "TabPages.hrc"
30cdf0e10cSrcweir #include "Strings.hrc"
31cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx"
32cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx"
33cdf0e10cSrcweir #include "AxisHelper.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
36cdf0e10cSrcweir #include <svx/svxids.hrc>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <rtl/math.hxx>
39cdf0e10cSrcweir // header for class SvxDoubleItem
40cdf0e10cSrcweir #include <svx/chrtitem.hxx>
41cdf0e10cSrcweir // header for class SfxBoolItem
42cdf0e10cSrcweir #include <svl/eitem.hxx>
43cdf0e10cSrcweir // header for SfxInt32Item
44cdf0e10cSrcweir #include <svl/intitem.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // header for class WarningBox
47cdf0e10cSrcweir #include <vcl/msgbox.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir // header for class SvNumberformat
50cdf0e10cSrcweir #ifndef _ZFORMAT_HXX
51cdf0e10cSrcweir #ifndef _ZFORLIST_DECLARE_TABLE
52cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #include <svl/zformat.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include <svtools/controldims.hrc>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisPosition.hpp>
60cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using namespace ::com::sun::star;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //.............................................................................
65cdf0e10cSrcweir namespace chart
66cdf0e10cSrcweir {
67cdf0e10cSrcweir //.............................................................................
68cdf0e10cSrcweir 
69cdf0e10cSrcweir namespace
70cdf0e10cSrcweir {
lcl_newXPos(Control & rControl,long nXPos)71cdf0e10cSrcweir void lcl_newXPos( Control& rControl, long nXPos )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     Point aPos( rControl.GetPosPixel() );
74cdf0e10cSrcweir     aPos.X() = nXPos;
75cdf0e10cSrcweir     rControl.SetPosPixel(aPos);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
lcl_shiftY(Control & rControl,long nYDiff)78cdf0e10cSrcweir void lcl_shiftY( Control& rControl, long nYDiff )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     Point aPos( rControl.GetPosPixel() );
81cdf0e10cSrcweir     aPos.Y() += nYDiff;
82cdf0e10cSrcweir     rControl.SetPosPixel(aPos);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
AxisPositionsTabPage(Window * pWindow,const SfxItemSet & rInAttrs)87cdf0e10cSrcweir AxisPositionsTabPage::AxisPositionsTabPage(Window* pWindow,const SfxItemSet& rInAttrs)
88cdf0e10cSrcweir     : SfxTabPage(pWindow, SchResId(TP_AXIS_POSITIONS), rInAttrs)
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     , m_aFL_AxisLine(this,SchResId(FL_AXIS_LINE))
91cdf0e10cSrcweir     , m_aFT_CrossesAt(this,SchResId(FT_CROSSES_OTHER_AXIS_AT))
92cdf0e10cSrcweir     , m_aLB_CrossesAt(this,SchResId(LB_CROSSES_OTHER_AXIS_AT))
93cdf0e10cSrcweir     , m_aED_CrossesAt(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT))
94cdf0e10cSrcweir     , m_aED_CrossesAtCategory(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT_CATEGORY))
95cdf0e10cSrcweir     , m_aCB_AxisBetweenCategories(this, SchResId(CB_AXIS_BETWEEN_CATEGORIES))
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     , m_aFL_Labels(this,SchResId(FL_LABELS))
98cdf0e10cSrcweir     , m_aFT_PlaceLabels( this, SchResId( FT_PLACE_LABELS ) )
99cdf0e10cSrcweir     , m_aLB_PlaceLabels( this, SchResId( LB_PLACE_LABELS ) )
100cdf0e10cSrcweir     , m_aFT_LabelDistance( this, SchResId( FT_AXIS_LABEL_DISTANCE ) )
101cdf0e10cSrcweir     , m_aED_LabelDistance( this, SchResId( EDT_AXIS_LABEL_DISTANCE ) )
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     , m_aFL_Ticks(this,SchResId(FL_TICKS))
104cdf0e10cSrcweir     , m_aFT_Major(this,SchResId(FT_MAJOR))
105cdf0e10cSrcweir     , m_aCB_TicksInner(this,SchResId(CB_TICKS_INNER))
106cdf0e10cSrcweir 	, m_aCB_TicksOuter(this,SchResId(CB_TICKS_OUTER))
107cdf0e10cSrcweir     , m_aFT_Minor(this,SchResId(FT_MINOR))
108cdf0e10cSrcweir 	, m_aCB_MinorInner(this,SchResId(CB_MINOR_INNER))
109cdf0e10cSrcweir 	, m_aCB_MinorOuter(this,SchResId(CB_MINOR_OUTER))
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     , m_aFL_Vertical(this,SchResId(FL_VERTICAL))
112cdf0e10cSrcweir     , m_aFT_PlaceTicks(this,SchResId(FT_PLACE_TICKS))
113cdf0e10cSrcweir     , m_aLB_PlaceTicks(this,SchResId(LB_PLACE_TICKS))
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     , m_aFL_Grids(this,SchResId(FL_GRIDS))
116cdf0e10cSrcweir     , m_aCB_MajorGrid(this,SchResId(CB_MAJOR_GRID))
117cdf0e10cSrcweir     , m_aPB_MajorGrid(this,SchResId(PB_MAJOR_GRID))
118cdf0e10cSrcweir     , m_aCB_MinorGrid(this,SchResId(CB_MINOR_GRID))
119cdf0e10cSrcweir     , m_aPB_MinorGrid(this,SchResId(PB_MINOR_GRID))
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	, m_pNumFormatter(NULL)
122cdf0e10cSrcweir     , m_bCrossingAxisIsCategoryAxis(false)
123cdf0e10cSrcweir     , m_aCategories()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	FreeResource();
126cdf0e10cSrcweir 	SetExchangeSupport();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     const long nDialogWidth = GetSizePixel().Width();
129cdf0e10cSrcweir     const long nDistance = LogicToPixel( Size(RSC_SP_CTRL_X, 0), MapMode(MAP_APPFONT) ).Width();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     //axis line controls
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         if( m_aFT_CrossesAt.CalcMinimumSize().Width() < m_aFT_CrossesAt.GetSizePixel().Width() )
134cdf0e10cSrcweir         {
135cdf0e10cSrcweir             m_aFT_CrossesAt.SetSizePixel(m_aFT_CrossesAt.CalcMinimumSize());
136cdf0e10cSrcweir             long nXPos = m_aFT_CrossesAt.GetPosPixel().X() + m_aFT_CrossesAt.GetSizePixel().Width() + nDistance;
137cdf0e10cSrcweir             lcl_newXPos( m_aLB_CrossesAt, nXPos );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir             nXPos += m_aLB_CrossesAt.GetSizePixel().Width() + nDistance;
140cdf0e10cSrcweir             lcl_newXPos( m_aED_CrossesAt, nXPos );
141cdf0e10cSrcweir             lcl_newXPos( m_aED_CrossesAtCategory, nXPos );
142cdf0e10cSrcweir         }
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     long nFixTextHeight = m_aFT_PlaceLabels.GetSizePixel().Height();
146cdf0e10cSrcweir     long nLabelPlacementWidth = m_aFT_PlaceLabels.CalcMinimumSize().Width();
147cdf0e10cSrcweir     long nMarkPlacementWidth = m_aFT_PlaceTicks.CalcMinimumSize().Width();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     long nWidth_0 = ::std::max( m_aFT_Major.CalcMinimumSize().Width(), m_aFT_Minor.CalcMinimumSize().Width() );
151cdf0e10cSrcweir     nWidth_0 = ::std::max( nWidth_0, nLabelPlacementWidth );
152cdf0e10cSrcweir     nWidth_0 = ::std::max( nWidth_0, nMarkPlacementWidth );
153cdf0e10cSrcweir     nLabelPlacementWidth = nMarkPlacementWidth = nWidth_0;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     //label placement
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         m_aFT_PlaceLabels.SetSizePixel( Size( nLabelPlacementWidth, nFixTextHeight ) );
158cdf0e10cSrcweir         long nXPos = m_aFT_PlaceLabels.GetPosPixel().X() + nLabelPlacementWidth + nDistance;
159cdf0e10cSrcweir         lcl_newXPos( m_aLB_PlaceLabels, nXPos );
160cdf0e10cSrcweir         m_aLB_PlaceLabels.SetSizePixel(m_aLB_PlaceLabels.CalcMinimumSize());
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     //tickmark placement
164cdf0e10cSrcweir     {
165cdf0e10cSrcweir         m_aFT_PlaceTicks.SetSizePixel( Size( nMarkPlacementWidth, nFixTextHeight ) );
166cdf0e10cSrcweir         long nXPos = m_aFT_PlaceTicks.GetPosPixel().X() + nMarkPlacementWidth + nDistance;
167cdf0e10cSrcweir         lcl_newXPos( m_aLB_PlaceTicks, nXPos );
168cdf0e10cSrcweir         m_aLB_PlaceTicks.SetSizePixel( m_aLB_PlaceTicks.CalcMinimumSize() );
169cdf0e10cSrcweir     }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     //tickmark controls
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         long nWidth_1 = ::std::max( m_aCB_TicksInner.CalcMinimumSize().Width(), m_aCB_MinorInner.CalcMinimumSize().Width() );
174cdf0e10cSrcweir         long nWidth_2 = ::std::max( m_aCB_TicksOuter.CalcMinimumSize().Width(), m_aCB_MinorOuter.CalcMinimumSize().Width() );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         long nLeftSpace = nDialogWidth - nWidth_0 - nWidth_1 - nWidth_2 - 3*nDistance;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         if(nLeftSpace>=0)
179cdf0e10cSrcweir         {
180cdf0e10cSrcweir             m_aFT_Major.SetSizePixel(m_aFT_Major.CalcMinimumSize());
181cdf0e10cSrcweir             m_aFT_Minor.SetSizePixel(m_aFT_Minor.CalcMinimumSize());
182cdf0e10cSrcweir 
183cdf0e10cSrcweir             m_aCB_TicksInner.SetSizePixel( m_aCB_TicksInner.CalcMinimumSize()  );
184cdf0e10cSrcweir             m_aCB_MinorInner.SetSizePixel( m_aCB_MinorInner.CalcMinimumSize()  );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir             m_aCB_TicksOuter.SetSizePixel( m_aCB_TicksOuter.CalcMinimumSize() );
187cdf0e10cSrcweir             m_aCB_MinorOuter.SetSizePixel( m_aCB_MinorOuter.CalcMinimumSize() );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir             long nXPos = m_aFT_Major.GetPosPixel().X() + nWidth_0 + nDistance;
190cdf0e10cSrcweir             lcl_newXPos( m_aCB_TicksInner, nXPos );
191cdf0e10cSrcweir             lcl_newXPos( m_aCB_MinorInner, nXPos );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             nXPos += nWidth_1 + nDistance;
194cdf0e10cSrcweir             lcl_newXPos( m_aCB_TicksOuter, nXPos );
195cdf0e10cSrcweir             lcl_newXPos( m_aCB_MinorOuter, nXPos );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir             nXPos += nWidth_2 + nDistance;
198cdf0e10cSrcweir             lcl_newXPos( m_aFL_Vertical, nXPos );
199cdf0e10cSrcweir         }
200cdf0e10cSrcweir     }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     //right alignement of listboxes:
203cdf0e10cSrcweir     {
204cdf0e10cSrcweir         long nLabelRightBorder = m_aLB_PlaceLabels.GetPosPixel().X() + m_aLB_PlaceLabels.GetSizePixel().Width();
205cdf0e10cSrcweir         long nTickmarksRightBorder = m_aLB_PlaceTicks.GetPosPixel().X() + m_aLB_PlaceTicks.GetSizePixel().Width();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir         long nNewRightBorder = ::std::max( m_aLB_CrossesAt.GetPosPixel().X() + m_aLB_CrossesAt.GetSizePixel().Width(),  nLabelRightBorder);
208cdf0e10cSrcweir         nNewRightBorder = ::std::max( nTickmarksRightBorder, nNewRightBorder );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         long nListBoxHeight = m_aLB_PlaceLabels.GetSizePixel().Height();
211cdf0e10cSrcweir         m_aLB_PlaceLabels.SetSizePixel( Size( m_aLB_PlaceLabels.GetSizePixel().Width()+nNewRightBorder-nLabelRightBorder, nListBoxHeight ) );
212cdf0e10cSrcweir         m_aLB_PlaceTicks.SetSizePixel( Size( m_aLB_PlaceTicks.GetSizePixel().Width()+nNewRightBorder-nTickmarksRightBorder, nListBoxHeight ) );
213cdf0e10cSrcweir     }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     m_aLB_CrossesAt.SetSelectHdl( LINK( this, AxisPositionsTabPage, CrossesAtSelectHdl ) );
216cdf0e10cSrcweir     m_aLB_CrossesAt.SetDropDownLineCount( m_aLB_CrossesAt.GetEntryCount() );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     m_aLB_PlaceLabels.SetSelectHdl( LINK( this, AxisPositionsTabPage, PlaceLabelsSelectHdl ) );
219cdf0e10cSrcweir     m_aLB_PlaceLabels.SetDropDownLineCount( m_aLB_PlaceLabels.GetEntryCount() );
220cdf0e10cSrcweir     m_aLB_PlaceTicks.SetDropDownLineCount( m_aLB_PlaceTicks.GetEntryCount() );
221cdf0e10cSrcweir     m_aCB_TicksInner.SetAccessibleRelationLabeledBy(&m_aFT_Major);
222cdf0e10cSrcweir 	m_aCB_TicksOuter.SetAccessibleRelationLabeledBy(&m_aFT_Major);
223cdf0e10cSrcweir 	m_aCB_MinorInner.SetAccessibleRelationLabeledBy(&m_aFT_Minor);
224cdf0e10cSrcweir 	m_aCB_MinorOuter.SetAccessibleRelationLabeledBy(&m_aFT_Minor);
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
Create(Window * pWindow,const SfxItemSet & rOutAttrs)227cdf0e10cSrcweir SfxTabPage* AxisPositionsTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir     return new AxisPositionsTabPage(pWindow, rOutAttrs);
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rOutAttrs)232cdf0e10cSrcweir sal_Bool AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     // axis line
235cdf0e10cSrcweir 	sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos();
236cdf0e10cSrcweir     rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_POSITION, nPos+1 ));
237cdf0e10cSrcweir     if( 2==nPos )
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         double fCrossover = m_aED_CrossesAt.GetValue();
240cdf0e10cSrcweir         if( m_bCrossingAxisIsCategoryAxis )
241cdf0e10cSrcweir             fCrossover = m_aED_CrossesAtCategory.GetSelectEntryPos()+1;
242cdf0e10cSrcweir         rOutAttrs.Put(SvxDoubleItem(fCrossover,SCHATTR_AXIS_POSITION_VALUE));
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     // labels
246cdf0e10cSrcweir     sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos();
247cdf0e10cSrcweir     if( nLabelPos != LISTBOX_ENTRY_NOTFOUND )
248cdf0e10cSrcweir         rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_LABEL_POSITION, nLabelPos ));
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     // tick marks
251cdf0e10cSrcweir     long nTicks=0;
252cdf0e10cSrcweir 	long nMinorTicks=0;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	if(m_aCB_MinorInner.IsChecked())
255cdf0e10cSrcweir 		nMinorTicks|=CHAXIS_MARK_INNER;
256cdf0e10cSrcweir 	if(m_aCB_MinorOuter.IsChecked())
257cdf0e10cSrcweir 		nMinorTicks|=CHAXIS_MARK_OUTER;
258cdf0e10cSrcweir 	if(m_aCB_TicksInner.IsChecked())
259cdf0e10cSrcweir 		nTicks|=CHAXIS_MARK_INNER;
260cdf0e10cSrcweir 	if(m_aCB_TicksOuter.IsChecked())
261cdf0e10cSrcweir 		nTicks|=CHAXIS_MARK_OUTER;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TICKS,nTicks));
264cdf0e10cSrcweir 	rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELPTICKS,nMinorTicks));
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     sal_uInt16 nMarkPos = m_aLB_PlaceTicks.GetSelectEntryPos();
267cdf0e10cSrcweir     if( nMarkPos != LISTBOX_ENTRY_NOTFOUND )
268cdf0e10cSrcweir         rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_MARK_POSITION, nMarkPos ));
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	return sal_True;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
Reset(const SfxItemSet & rInAttrs)273cdf0e10cSrcweir void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     //init and enable controls
276cdf0e10cSrcweir     m_aED_CrossesAt.Show( !m_bCrossingAxisIsCategoryAxis );
277cdf0e10cSrcweir     m_aED_CrossesAtCategory.Show( m_bCrossingAxisIsCategoryAxis );
278cdf0e10cSrcweir     const sal_Int32 nMaxCount = LISTBOX_ENTRY_NOTFOUND;
279cdf0e10cSrcweir     if( m_bCrossingAxisIsCategoryAxis )
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         for( sal_Int32 nN=0; nN<m_aCategories.getLength() && nN<nMaxCount; nN++ )
282cdf0e10cSrcweir             m_aED_CrossesAtCategory.InsertEntry( m_aCategories[nN] );
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         sal_uInt16 nCount = m_aED_CrossesAtCategory.GetEntryCount();
285cdf0e10cSrcweir         if( nCount>30 )
286cdf0e10cSrcweir             nCount=30;
287cdf0e10cSrcweir         m_aED_CrossesAtCategory.SetDropDownLineCount( nCount );
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     if( m_aLB_CrossesAt.GetEntryCount() > 3 )
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         if( m_bCrossingAxisIsCategoryAxis )
293cdf0e10cSrcweir             m_aLB_CrossesAt.RemoveEntry(2);
294cdf0e10cSrcweir         else
295cdf0e10cSrcweir             m_aLB_CrossesAt.RemoveEntry(3);
296cdf0e10cSrcweir     }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     //fill controls
299cdf0e10cSrcweir     const SfxPoolItem *pPoolItem = NULL;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     //axis line
302cdf0e10cSrcweir     if(rInAttrs.GetItemState(SCHATTR_AXIS_POSITION,sal_True, &pPoolItem)== SFX_ITEM_SET)
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         bool bZero = false;
305cdf0e10cSrcweir 		sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
306cdf0e10cSrcweir         if(nPos==0)
307cdf0e10cSrcweir         {
308cdf0e10cSrcweir             //switch to value
309cdf0e10cSrcweir             bZero = true;
310cdf0e10cSrcweir             nPos = 2;
311cdf0e10cSrcweir         }
312cdf0e10cSrcweir         else
313cdf0e10cSrcweir             nPos--;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         if( nPos < m_aLB_CrossesAt.GetEntryCount() )
316cdf0e10cSrcweir             m_aLB_CrossesAt.SelectEntryPos( nPos );
317cdf0e10cSrcweir         CrossesAtSelectHdl( (void*)0 );
318cdf0e10cSrcweir 
319cdf0e10cSrcweir         if( rInAttrs.GetItemState(SCHATTR_AXIS_POSITION_VALUE,sal_True, &pPoolItem)== SFX_ITEM_SET || bZero )
320cdf0e10cSrcweir         {
321cdf0e10cSrcweir             double fCrossover = 0.0;
322cdf0e10cSrcweir             if( !bZero )
323cdf0e10cSrcweir                 fCrossover = (((const SvxDoubleItem*)pPoolItem)->GetValue());
324cdf0e10cSrcweir             if( m_bCrossingAxisIsCategoryAxis )
325cdf0e10cSrcweir                 m_aED_CrossesAtCategory.SelectEntryPos( static_cast<sal_uInt16>(::rtl::math::round(fCrossover-1.0)) );
326cdf0e10cSrcweir             else
327cdf0e10cSrcweir                 m_aED_CrossesAt.SetValue(fCrossover);
328cdf0e10cSrcweir         }
329cdf0e10cSrcweir         else
330cdf0e10cSrcweir         {
331cdf0e10cSrcweir             m_aED_CrossesAtCategory.SetNoSelection();
332cdf0e10cSrcweir             m_aED_CrossesAt.SetTextValue(XubString());
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir     else
336cdf0e10cSrcweir     {
337cdf0e10cSrcweir         m_aLB_CrossesAt.SetNoSelection();
338cdf0e10cSrcweir         m_aED_CrossesAt.Enable( sal_False );
339cdf0e10cSrcweir     }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     // Labels
342cdf0e10cSrcweir     if( rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET )
343cdf0e10cSrcweir     {
344cdf0e10cSrcweir         sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
345cdf0e10cSrcweir         if( nPos < m_aLB_PlaceLabels.GetEntryCount() )
346cdf0e10cSrcweir             m_aLB_PlaceLabels.SelectEntryPos( nPos );
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir     else
349cdf0e10cSrcweir         m_aLB_PlaceLabels.SetNoSelection();
350cdf0e10cSrcweir     PlaceLabelsSelectHdl( (void*)0 );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     // Tick marks
353cdf0e10cSrcweir     long nTicks=0,nMinorTicks=0;
354cdf0e10cSrcweir 	if(rInAttrs.GetItemState(SCHATTR_AXIS_TICKS,sal_True, &pPoolItem)== SFX_ITEM_SET)
355cdf0e10cSrcweir 		nTicks=((const SfxInt32Item*)pPoolItem)->GetValue();
356cdf0e10cSrcweir 	if(rInAttrs.GetItemState(SCHATTR_AXIS_HELPTICKS,sal_True, &pPoolItem)== SFX_ITEM_SET)
357cdf0e10cSrcweir 		nMinorTicks=((const SfxInt32Item*)pPoolItem)->GetValue();
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     m_aCB_TicksInner.Check(sal_Bool(nTicks&CHAXIS_MARK_INNER));
360cdf0e10cSrcweir 	m_aCB_TicksOuter.Check(sal_Bool(nTicks&CHAXIS_MARK_OUTER));
361cdf0e10cSrcweir 	m_aCB_MinorInner.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_INNER));
362cdf0e10cSrcweir 	m_aCB_MinorOuter.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_OUTER));
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     // Tick position
365cdf0e10cSrcweir     if( rInAttrs.GetItemState( SCHATTR_AXIS_MARK_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET )
366cdf0e10cSrcweir     {
367cdf0e10cSrcweir         sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
368cdf0e10cSrcweir         if( nPos < m_aLB_PlaceTicks.GetEntryCount() )
369cdf0e10cSrcweir             m_aLB_PlaceTicks.SelectEntryPos( nPos );
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir     else
372cdf0e10cSrcweir         m_aLB_PlaceTicks.SetNoSelection();
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     if( !m_bSupportAxisPositioning )
376cdf0e10cSrcweir     {
377cdf0e10cSrcweir         m_aFL_AxisLine.Show(false);
378cdf0e10cSrcweir         m_aFT_CrossesAt.Show(false);
379cdf0e10cSrcweir         m_aLB_CrossesAt.Show(false);
380cdf0e10cSrcweir         m_aED_CrossesAt.Show(false);
381cdf0e10cSrcweir         m_aED_CrossesAtCategory.Show(false);
382cdf0e10cSrcweir         m_aCB_AxisBetweenCategories.Show(false);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir         m_aFL_Labels.Show(false);
385cdf0e10cSrcweir         m_aFT_PlaceLabels.Show(false);
386cdf0e10cSrcweir         m_aLB_PlaceLabels.Show(false);
387cdf0e10cSrcweir         m_aFT_LabelDistance.Show(false);
388cdf0e10cSrcweir         m_aED_LabelDistance.Show(false);
389cdf0e10cSrcweir 
390cdf0e10cSrcweir         m_aFL_Vertical.Show(false);
391cdf0e10cSrcweir         m_aFT_PlaceTicks.Show(false);
392cdf0e10cSrcweir         m_aLB_PlaceTicks.Show(false);
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         long nYDiff = m_aFL_AxisLine.GetPosPixel().Y() - m_aFL_Ticks.GetPosPixel().Y();
395cdf0e10cSrcweir         lcl_shiftY( m_aFL_Ticks, nYDiff );
396cdf0e10cSrcweir         lcl_shiftY( m_aFT_Major, nYDiff );
397cdf0e10cSrcweir         lcl_shiftY( m_aCB_TicksInner, nYDiff );
398cdf0e10cSrcweir         lcl_shiftY( m_aCB_TicksOuter, nYDiff );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir         lcl_shiftY( m_aFT_Minor, nYDiff );
401cdf0e10cSrcweir         lcl_shiftY( m_aCB_MinorInner, nYDiff );
402cdf0e10cSrcweir         lcl_shiftY( m_aCB_MinorOuter, nYDiff );
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir     else if( !AxisHelper::isAxisPositioningEnabled() )
405cdf0e10cSrcweir     {
406cdf0e10cSrcweir         m_aFL_AxisLine.Enable(false);
407cdf0e10cSrcweir         m_aFT_CrossesAt.Enable(false);
408cdf0e10cSrcweir         m_aLB_CrossesAt.Enable(false);
409cdf0e10cSrcweir         m_aED_CrossesAt.Enable(false);
410cdf0e10cSrcweir         m_aED_CrossesAtCategory.Enable(false);
411cdf0e10cSrcweir         m_aCB_AxisBetweenCategories.Enable(false);
412cdf0e10cSrcweir 
413cdf0e10cSrcweir         m_aFL_Labels.Enable(false);
414cdf0e10cSrcweir         m_aFT_PlaceLabels.Enable(false);
415cdf0e10cSrcweir         m_aLB_PlaceLabels.Enable(false);
416cdf0e10cSrcweir         m_aFT_LabelDistance.Enable(false);
417cdf0e10cSrcweir         m_aED_LabelDistance.Enable(false);
418cdf0e10cSrcweir 
419cdf0e10cSrcweir         m_aFL_Vertical.Enable(false);
420cdf0e10cSrcweir         m_aFT_PlaceTicks.Enable(false);
421cdf0e10cSrcweir         m_aLB_PlaceTicks.Enable(false);
422cdf0e10cSrcweir 
423cdf0e10cSrcweir         //todo: maybe set a special help id to all those controls
424cdf0e10cSrcweir     }
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
DeactivatePage(SfxItemSet * pItemSet)427cdf0e10cSrcweir int AxisPositionsTabPage::DeactivatePage(SfxItemSet* pItemSet)
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     if( pItemSet )
430cdf0e10cSrcweir 		FillItemSet( *pItemSet );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     return LEAVE_PAGE;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
SetNumFormatter(SvNumberFormatter * pFormatter)435cdf0e10cSrcweir void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir 	m_pNumFormatter = pFormatter;
438cdf0e10cSrcweir     m_aED_CrossesAt.SetFormatter( m_pNumFormatter );
439cdf0e10cSrcweir 	m_aED_CrossesAt.UseInputStringForFormatting();
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	const SfxPoolItem *pPoolItem = NULL;
442cdf0e10cSrcweir     if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, sal_True, &pPoolItem ) == SFX_ITEM_SET )
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue();
445cdf0e10cSrcweir 		m_aED_CrossesAt.SetFormatKey( nFmt );
446cdf0e10cSrcweir 	}
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
SetCrossingAxisIsCategoryAxis(bool bCrossingAxisIsCategoryAxis)449cdf0e10cSrcweir void AxisPositionsTabPage::SetCrossingAxisIsCategoryAxis( bool bCrossingAxisIsCategoryAxis )
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     m_bCrossingAxisIsCategoryAxis = bCrossingAxisIsCategoryAxis;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
SetCategories(const::com::sun::star::uno::Sequence<rtl::OUString> & rCategories)454cdf0e10cSrcweir void AxisPositionsTabPage::SetCategories( const ::com::sun::star::uno::Sequence< rtl::OUString >& rCategories )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     m_aCategories = rCategories;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
SupportAxisPositioning(bool bSupportAxisPositioning)459cdf0e10cSrcweir void AxisPositionsTabPage::SupportAxisPositioning( bool bSupportAxisPositioning )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir     m_bSupportAxisPositioning = bSupportAxisPositioning;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
IMPL_LINK(AxisPositionsTabPage,CrossesAtSelectHdl,void *,EMPTYARG)464cdf0e10cSrcweir IMPL_LINK ( AxisPositionsTabPage, CrossesAtSelectHdl, void *, EMPTYARG )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir     sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos();
467cdf0e10cSrcweir     m_aED_CrossesAt.Show( (2==nPos) && !m_bCrossingAxisIsCategoryAxis );
468cdf0e10cSrcweir     m_aED_CrossesAtCategory.Show( (2==nPos) && m_bCrossingAxisIsCategoryAxis );
469cdf0e10cSrcweir 
470cdf0e10cSrcweir     if(! m_aED_CrossesAt.GetText().Len() )
471cdf0e10cSrcweir         m_aED_CrossesAt.SetValue(0.0);
472cdf0e10cSrcweir     if( 0 == m_aED_CrossesAtCategory.GetSelectEntryCount() )
473cdf0e10cSrcweir         m_aED_CrossesAtCategory.SelectEntryPos(0);
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     PlaceLabelsSelectHdl( (void*)0 );
476cdf0e10cSrcweir     return 0;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir 
IMPL_LINK(AxisPositionsTabPage,PlaceLabelsSelectHdl,void *,EMPTYARG)479cdf0e10cSrcweir IMPL_LINK ( AxisPositionsTabPage, PlaceLabelsSelectHdl, void *, EMPTYARG )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir     sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir     bool bEnableTickmarkPlacement = (nLabelPos>1);
484cdf0e10cSrcweir     if( bEnableTickmarkPlacement )
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         sal_uInt16 nAxisPos = m_aLB_CrossesAt.GetSelectEntryPos();
487cdf0e10cSrcweir         if( nLabelPos-2 == nAxisPos )
488cdf0e10cSrcweir             bEnableTickmarkPlacement=false;
489cdf0e10cSrcweir     }
490cdf0e10cSrcweir     m_aFT_PlaceTicks.Enable(bEnableTickmarkPlacement);
491cdf0e10cSrcweir     m_aLB_PlaceTicks.Enable(bEnableTickmarkPlacement);
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     return 0;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir //.............................................................................
497cdf0e10cSrcweir } //namespace chart
498cdf0e10cSrcweir //.............................................................................
499