Update ooo320-m1
[ooovba.git] / chart2 / source / view / axes / MinimumAndMaximumSupplier.cxx
blobcaa10e2e49ec44b30d0569f0aced1ddd34e8c0f1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MinimumAndMaximumSupplier.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "MinimumAndMaximumSupplier.hxx"
35 #include <rtl/math.hxx>
36 #include <com/sun/star/awt/Size.hpp>
38 //.............................................................................
39 namespace chart
41 //.............................................................................
42 using namespace ::com::sun::star;
44 MergedMinimumAndMaximumSupplier::MergedMinimumAndMaximumSupplier()
48 MergedMinimumAndMaximumSupplier::~MergedMinimumAndMaximumSupplier()
52 void MergedMinimumAndMaximumSupplier::addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
54 m_aMinimumAndMaximumSupplierList.insert( pMinimumAndMaximumSupplier );
57 bool MergedMinimumAndMaximumSupplier::hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
59 return m_aMinimumAndMaximumSupplierList.count( pMinimumAndMaximumSupplier ) != 0;
62 double MergedMinimumAndMaximumSupplier::getMinimumX()
64 double fGlobalExtremum;
65 ::rtl::math::setInf(&fGlobalExtremum, false);
66 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
68 double fLocalExtremum = (*aIt)->getMinimumX();
69 if(fLocalExtremum<fGlobalExtremum)
70 fGlobalExtremum=fLocalExtremum;
72 if(::rtl::math::isInf(fGlobalExtremum))
73 ::rtl::math::setNan(&fGlobalExtremum);
74 return fGlobalExtremum;
77 double MergedMinimumAndMaximumSupplier::getMaximumX()
79 double fGlobalExtremum;
80 ::rtl::math::setInf(&fGlobalExtremum, true);
81 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
83 double fLocalExtremum = (*aIt)->getMaximumX();
84 if(fLocalExtremum>fGlobalExtremum)
85 fGlobalExtremum=fLocalExtremum;
87 if(::rtl::math::isInf(fGlobalExtremum))
88 ::rtl::math::setNan(&fGlobalExtremum);
89 return fGlobalExtremum;
92 double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
94 double fGlobalExtremum;
95 ::rtl::math::setInf(&fGlobalExtremum, false);
96 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
98 double fLocalExtremum = (*aIt)->getMinimumYInRange( fMinimumX, fMaximumX, nAxisIndex );
99 if(fLocalExtremum<fGlobalExtremum)
100 fGlobalExtremum=fLocalExtremum;
102 if(::rtl::math::isInf(fGlobalExtremum))
103 ::rtl::math::setNan(&fGlobalExtremum);
104 return fGlobalExtremum;
107 double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
109 double fGlobalExtremum;
110 ::rtl::math::setInf(&fGlobalExtremum, true);
111 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
113 double fLocalExtremum = (*aIt)->getMaximumYInRange( fMinimumX, fMaximumX, nAxisIndex );
114 if(fLocalExtremum>fGlobalExtremum)
115 fGlobalExtremum=fLocalExtremum;
117 if(::rtl::math::isInf(fGlobalExtremum))
118 ::rtl::math::setNan(&fGlobalExtremum);
119 return fGlobalExtremum;
122 double MergedMinimumAndMaximumSupplier::getMinimumZ()
124 double fGlobalExtremum;
125 ::rtl::math::setInf(&fGlobalExtremum, false);
126 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
128 double fLocalExtremum = (*aIt)->getMinimumZ();
129 if(fLocalExtremum<fGlobalExtremum)
130 fGlobalExtremum=fLocalExtremum;
132 if(::rtl::math::isInf(fGlobalExtremum))
133 ::rtl::math::setNan(&fGlobalExtremum);
134 return fGlobalExtremum;
137 double MergedMinimumAndMaximumSupplier::getMaximumZ()
139 double fGlobalExtremum;
140 ::rtl::math::setInf(&fGlobalExtremum, true);
141 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
143 double fLocalExtremum = (*aIt)->getMaximumZ();
144 if(fLocalExtremum>fGlobalExtremum)
145 fGlobalExtremum=fLocalExtremum;
147 if(::rtl::math::isInf(fGlobalExtremum))
148 ::rtl::math::setNan(&fGlobalExtremum);
149 return fGlobalExtremum;
152 bool MergedMinimumAndMaximumSupplier::isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex )
154 // only return true, if *all* suppliers want to scale to the main tick marks
155 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
156 if( !(*aIt)->isExpandBorderToIncrementRhythm( nDimensionIndex ) )
157 return false;
158 return true;
161 bool MergedMinimumAndMaximumSupplier::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex )
163 // only return true, if *all* suppliers want to expand the range
164 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
165 if( !(*aIt)->isExpandIfValuesCloseToBorder( nDimensionIndex ) )
166 return false;
167 return true;
170 bool MergedMinimumAndMaximumSupplier::isExpandWideValuesToZero( sal_Int32 nDimensionIndex )
172 // already return true, if at least one supplier wants to expand the range
173 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
174 if( (*aIt)->isExpandWideValuesToZero( nDimensionIndex ) )
175 return true;
176 return false;
179 bool MergedMinimumAndMaximumSupplier::isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex )
181 // already return true, if at least one supplier wants to expand the range
182 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
183 if( (*aIt)->isExpandNarrowValuesTowardZero( nDimensionIndex ) )
184 return true;
185 return false;
188 bool MergedMinimumAndMaximumSupplier::isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex )
190 // should not be called
191 for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
192 if( (*aIt)->isSeperateStackingForDifferentSigns( nDimensionIndex ) )
193 return true;
194 return false;
197 void MergedMinimumAndMaximumSupplier::clearMinimumAndMaximumSupplierList()
199 m_aMinimumAndMaximumSupplierList.clear();
202 //.............................................................................
203 } //namespace chart
204 //.............................................................................