summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-08-19 22:51:12 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-08-19 22:51:12 +0000
commit63caa885371bf27663e3f72c3e7d1507412b0354 (patch)
tree1aef67632fb50cc936aa69aafb52b96b48dfe74a
parent99dcb98fec03edd2eb46b83d6695c457c5755287 (diff)
INTEGRATION: CWS aw033 (1.9.2); FILE MERGED
2008/05/16 09:22:42 aw 1.9.2.5: adaptions after resync 2008/05/14 14:44:00 aw 1.9.2.4: RESYNC: (1.11-1.13); FILE MERGED 2007/08/09 22:02:07 aw 1.9.2.3: RESYNC: (1.10-1.11); FILE MERGED 2007/01/19 11:15:18 aw 1.9.2.2: RESYNC: (1.9-1.10); FILE MERGED 2006/05/16 14:09:23 aw 1.9.2.1: handish adaptions after resync
-rw-r--r--basegfx/inc/basegfx/numeric/ftools.hxx39
1 files changed, 32 insertions, 7 deletions
diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx
index c520a5cbca00..5003ede0c4cf 100644
--- a/basegfx/inc/basegfx/numeric/ftools.hxx
+++ b/basegfx/inc/basegfx/numeric/ftools.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: ftools.hxx,v $
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
* This file is part of OpenOffice.org.
*
@@ -33,9 +33,6 @@
#include <rtl/math.hxx>
-#include <algorithm> // for min/max
-
-
//////////////////////////////////////////////////////////////////////////////
// standard PI defines from solar.h, but we do not want to link against tools
@@ -98,9 +95,37 @@ namespace basegfx
*/
inline double pruneScaleValue( double fVal )
{
- return fVal < 0.0 ?
- (::std::min(fVal,-0.00001)) :
- (::std::max(fVal,0.00001));
+ // old version used ::std::min/max, but this collides if min is defined as preprocessor
+ // macro which is the case e.g with windows.h headers. The simplest way to avoid this is to
+ // just use the full comparison. I keep the original here, maybe there will be a better
+ // solution some day.
+ //
+ //return fVal < 0.0 ?
+ // (::std::min(fVal,-0.00001)) :
+ // (::std::max(fVal,0.00001));
+
+ if(fVal < 0.0)
+ return (fVal < -0.00001 ? fVal : -0.00001);
+ else
+ return (fVal > 0.00001 ? fVal : 0.00001);
+ }
+
+ /** clamp given value against given minimum and maximum values
+ */
+ template <class T> const T& clamp(const T& value, const T& minimum, const T& maximum)
+ {
+ if(value < minimum)
+ {
+ return minimum;
+ }
+ else if(value > maximum)
+ {
+ return maximum;
+ }
+ else
+ {
+ return value;
+ }
}
/** Convert value from degrees to radians