summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/range
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/inc/basegfx/range')
-rw-r--r--basegfx/inc/basegfx/range/b1drange.hxx165
-rw-r--r--basegfx/inc/basegfx/range/b1ibox.hxx143
-rw-r--r--basegfx/inc/basegfx/range/b1irange.hxx144
-rw-r--r--basegfx/inc/basegfx/range/b2dconnectedranges.hxx263
-rw-r--r--basegfx/inc/basegfx/range/b2dpolyrange.hxx145
-rw-r--r--basegfx/inc/basegfx/range/b2drange.hxx295
-rw-r--r--basegfx/inc/basegfx/range/b2drangeclipper.hxx53
-rw-r--r--basegfx/inc/basegfx/range/b2drectangle.hxx42
-rw-r--r--basegfx/inc/basegfx/range/b2ibox.hxx251
-rw-r--r--basegfx/inc/basegfx/range/b2irange.hxx254
-rw-r--r--basegfx/inc/basegfx/range/b2irectangle.hxx42
-rw-r--r--basegfx/inc/basegfx/range/b3drange.hxx302
-rw-r--r--basegfx/inc/basegfx/range/b3dvolume.hxx42
-rw-r--r--basegfx/inc/basegfx/range/b3ibox.hxx259
-rw-r--r--basegfx/inc/basegfx/range/b3irange.hxx262
-rw-r--r--basegfx/inc/basegfx/range/b3ivolume.hxx42
-rw-r--r--basegfx/inc/basegfx/range/basicbox.hxx136
-rw-r--r--basegfx/inc/basegfx/range/basicrange.hxx297
-rw-r--r--basegfx/inc/basegfx/range/rangeexpander.hxx83
19 files changed, 3220 insertions, 0 deletions
diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx
new file mode 100644
index 000000000000..eba1536f4ee6
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b1drange.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B1DRANGE_HXX
+#define _BGFX_RANGE_B1DRANGE_HXX
+
+#include <basegfx/range/basicrange.hxx>
+
+
+namespace basegfx
+{
+ class B1IRange;
+
+ class B1DRange
+ {
+ ::basegfx::BasicRange< double, DoubleTraits > maRange;
+
+ public:
+ B1DRange()
+ {
+ }
+
+ explicit B1DRange(double fStartValue)
+ : maRange(fStartValue)
+ {
+ }
+
+ B1DRange(double fStartValue1, double fStartValue2)
+ : maRange(fStartValue1)
+ {
+ expand(fStartValue2);
+ }
+
+ B1DRange(const B1DRange& rRange)
+ : maRange(rRange.maRange)
+ {
+ }
+
+ explicit B1DRange( const B1IRange& rRange );
+
+ bool isEmpty() const
+ {
+ return maRange.isEmpty();
+ }
+
+ void reset()
+ {
+ maRange.reset();
+ }
+
+ bool operator==( const B1DRange& rRange ) const
+ {
+ return (maRange == rRange.maRange);
+ }
+
+ bool operator!=( const B1DRange& rRange ) const
+ {
+ return (maRange != rRange.maRange);
+ }
+
+ B1DRange& operator=(const B1DRange& rRange)
+ {
+ maRange = rRange.maRange;
+ return *this;
+ }
+
+ bool equal(const B1DRange& rRange) const
+ {
+ return (maRange.equal(rRange.maRange));
+ }
+
+ double getMinimum() const
+ {
+ return maRange.getMinimum();
+ }
+
+ double getMaximum() const
+ {
+ return maRange.getMaximum();
+ }
+
+ double getRange() const
+ {
+ return maRange.getRange();
+ }
+
+ double getCenter() const
+ {
+ return maRange.getCenter();
+ }
+
+ bool isInside(double fValue) const
+ {
+ return maRange.isInside(fValue);
+ }
+
+ bool isInside(const B1DRange& rRange) const
+ {
+ return maRange.isInside(rRange.maRange);
+ }
+
+ bool overlaps(const B1DRange& rRange) const
+ {
+ return maRange.overlaps(rRange.maRange);
+ }
+
+ bool overlapsMore(const B1DRange& rRange) const
+ {
+ return maRange.overlapsMore(rRange.maRange);
+ }
+
+ void expand(double fValue)
+ {
+ maRange.expand(fValue);
+ }
+
+ void expand(const B1DRange& rRange)
+ {
+ maRange.expand(rRange.maRange);
+ }
+
+ void intersect(const B1DRange& rRange)
+ {
+ maRange.intersect(rRange.maRange);
+ }
+
+ void grow(double fValue)
+ {
+ maRange.grow(fValue);
+ }
+ };
+
+ /** Round double to nearest integer for 1D range
+
+ @return the nearest integer for this range
+ */
+ B1IRange fround(const B1DRange& rRange);
+} // end of namespace basegfx
+
+
+#endif /* _BGFX_RANGE_B1DRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b1ibox.hxx b/basegfx/inc/basegfx/range/b1ibox.hxx
new file mode 100644
index 000000000000..cb4ab8770a49
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b1ibox.hxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B1IBOX_HXX
+#define _BGFX_RANGE_B1IBOX_HXX
+
+#include <basegfx/range/basicbox.hxx>
+
+
+namespace basegfx
+{
+ class B1IBox
+ {
+ ::basegfx::BasicBox maRange;
+
+ public:
+ B1IBox()
+ {
+ }
+
+ explicit B1IBox(sal_Int32 nStartValue)
+ : maRange(nStartValue)
+ {
+ }
+
+ B1IBox(sal_Int32 nStartValue1, sal_Int32 nStartValue2)
+ : maRange(nStartValue1)
+ {
+ expand(nStartValue2);
+ }
+
+ B1IBox(const B1IBox& rBox)
+ : maRange(rBox.maRange)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRange.isEmpty();
+ }
+
+ void reset()
+ {
+ maRange.reset();
+ }
+
+ bool operator==( const B1IBox& rBox ) const
+ {
+ return (maRange == rBox.maRange);
+ }
+
+ bool operator!=( const B1IBox& rBox ) const
+ {
+ return (maRange != rBox.maRange);
+ }
+
+ void operator=(const B1IBox& rBox)
+ {
+ maRange = rBox.maRange;
+ }
+
+ sal_Int32 getMinimum() const
+ {
+ return maRange.getMinimum();
+ }
+
+ sal_Int32 getMaximum() const
+ {
+ return maRange.getMaximum();
+ }
+
+ Int32Traits::DifferenceType getRange() const
+ {
+ return maRange.getRange();
+ }
+
+ double getCenter() const
+ {
+ return maRange.getCenter();
+ }
+
+ bool isInside(sal_Int32 nValue) const
+ {
+ return maRange.isInside(nValue);
+ }
+
+ bool isInside(const B1IBox& rBox) const
+ {
+ return maRange.isInside(rBox.maRange);
+ }
+
+ bool overlaps(const B1IBox& rBox) const
+ {
+ return maRange.overlaps(rBox.maRange);
+ }
+
+ void expand(sal_Int32 nValue)
+ {
+ maRange.expand(nValue);
+ }
+
+ void expand(const B1IBox& rBox)
+ {
+ maRange.expand(rBox.maRange);
+ }
+
+ void intersect(const B1IBox& rBox)
+ {
+ maRange.intersect(rBox.maRange);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRange.grow(nValue);
+ }
+ };
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B1IBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/b1irange.hxx b/basegfx/inc/basegfx/range/b1irange.hxx
new file mode 100644
index 000000000000..6c65fbaebff4
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b1irange.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B1IRANGE_HXX
+#define _BGFX_RANGE_B1IRANGE_HXX
+
+#include <basegfx/range/basicrange.hxx>
+
+
+namespace basegfx
+{
+ class B1IRange
+ {
+ ::basegfx::BasicRange< sal_Int32, Int32Traits > maRange;
+
+ public:
+ B1IRange()
+ {
+ }
+
+ explicit B1IRange(sal_Int32 nStartValue)
+ : maRange(nStartValue)
+ {
+ }
+
+ B1IRange(sal_Int32 nStartValue1, sal_Int32 nStartValue2)
+ : maRange(nStartValue1)
+ {
+ expand(nStartValue2);
+ }
+
+ B1IRange(const B1IRange& rRange)
+ : maRange(rRange.maRange)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRange.isEmpty();
+ }
+
+ void reset()
+ {
+ maRange.reset();
+ }
+
+ bool operator==( const B1IRange& rRange ) const
+ {
+ return (maRange == rRange.maRange);
+ }
+
+ bool operator!=( const B1IRange& rRange ) const
+ {
+ return (maRange != rRange.maRange);
+ }
+
+ B1IRange& operator=(const B1IRange& rRange)
+ {
+ maRange = rRange.maRange;
+ return *this;
+ }
+
+ sal_Int32 getMinimum() const
+ {
+ return maRange.getMinimum();
+ }
+
+ sal_Int32 getMaximum() const
+ {
+ return maRange.getMaximum();
+ }
+
+ Int32Traits::DifferenceType getRange() const
+ {
+ return maRange.getRange();
+ }
+
+ double getCenter() const
+ {
+ return maRange.getCenter();
+ }
+
+ bool isInside(sal_Int32 nValue) const
+ {
+ return maRange.isInside(nValue);
+ }
+
+ bool isInside(const B1IRange& rRange) const
+ {
+ return maRange.isInside(rRange.maRange);
+ }
+
+ bool overlaps(const B1IRange& rRange) const
+ {
+ return maRange.overlaps(rRange.maRange);
+ }
+
+ void expand(sal_Int32 nValue)
+ {
+ maRange.expand(nValue);
+ }
+
+ void expand(const B1IRange& rRange)
+ {
+ maRange.expand(rRange.maRange);
+ }
+
+ void intersect(const B1IRange& rRange)
+ {
+ maRange.intersect(rRange.maRange);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRange.grow(nValue);
+ }
+ };
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B1IRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2dconnectedranges.hxx b/basegfx/inc/basegfx/range/b2dconnectedranges.hxx
new file mode 100644
index 000000000000..6c41ede934cf
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2dconnectedranges.hxx
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DCONNECTEDRANGES_HXX
+#define _BGFX_RANGE_B2DCONNECTEDRANGES_HXX
+
+#include <osl/diagnose.h>
+#include <basegfx/range/b2drange.hxx>
+#include <list>
+#include <utility>
+#include <algorithm>
+
+
+namespace basegfx
+{
+ /** Calculate connected ranges from input ranges.
+
+ This template constructs a list of connected ranges from the
+ given input ranges. That is, the output will contain a set of
+ ranges, itself containing a number of input ranges, which will
+ be mutually non-intersecting.
+
+ Example:
+ <code>
+ -------------------
+ | -------|
+ | | ||
+ | --- | ||
+ | | | -------| --------
+ | | +--------- | | |
+ | --+ | | | |
+ | | | | --------
+ | ---------- |
+ -------------------
+ </code
+
+ Here, the outer rectangles represent the output
+ ranges. Contained are the input rectangles that comprise these
+ output ranges.
+
+ @tpl UserData
+ User data to be stored along with the range, to later identify
+ which range went into which connected component. Must be
+ assignable, default- and copy-constructible.
+ */
+ template< typename UserData > class B2DConnectedRanges
+ {
+ public:
+ /// Type of the basic entity (rect + user data)
+ typedef ::std::pair< B2DRange, UserData > ComponentType;
+ typedef ::std::list< ComponentType > ComponentListType;
+
+ /// List of (intersecting) components, plus overall bounds
+ struct ConnectedComponents
+ {
+ ComponentListType maComponentList;
+ B2DRange maTotalBounds;
+ };
+
+ typedef ::std::list< ConnectedComponents > ConnectedComponentsType;
+
+
+ /// Create the range calculator
+ B2DConnectedRanges() :
+ maDisjunctAggregatesList(),
+ maTotalBounds()
+ {
+ }
+
+ /** Query total bounds of all added ranges.
+
+ @return the union bound rect over all added ranges.
+ */
+ B2DRange getBounds() const
+ {
+ return maTotalBounds;
+ }
+
+ /** Add an additional range.
+
+ This method integrates a new range into the connected
+ ranges lists. The method has a worst-case time complexity
+ of O(n^2), with n denoting the number of already added
+ ranges (typically, for well-behaved input, it is O(n)
+ though).
+ */
+ void addRange( const B2DRange& rRange,
+ const UserData& rUserData )
+ {
+ // check whether fast path is possible: if new range is
+ // outside accumulated total range, can add it as a
+ // separate component right away.
+ const bool bNotOutsideEverything(
+ maTotalBounds.overlaps( rRange ) );
+
+ // update own global bounds range
+ maTotalBounds.expand( rRange );
+
+ // assemble anything intersecting with rRange into
+ // this new connected component
+ ConnectedComponents aNewConnectedComponent;
+
+ // as at least rRange will be a member of
+ // aNewConnectedComponent (will be added below), can
+ // preset the overall bounds here.
+ aNewConnectedComponent.maTotalBounds = rRange;
+
+
+ //
+ // STAGE 1: Search for intersecting maDisjunctAggregatesList entries
+ // =================================================================
+ //
+
+ // if rRange is empty, it will intersect with no
+ // maDisjunctAggregatesList member. Thus, we can safe us
+ // the check.
+ // if rRange is outside all other rectangle, skip here,
+ // too
+ if( bNotOutsideEverything &&
+ !rRange.isEmpty() )
+ {
+ typename ConnectedComponentsType::iterator aCurrAggregate;
+ typename ConnectedComponentsType::iterator aLastAggregate;
+
+ // flag, determining whether we touched one or more of
+ // the maDisjunctAggregatesList entries. _If_ we did,
+ // we have to repeat the intersection process, because
+ // these changes might have generated new
+ // intersections.
+ bool bSomeAggregatesChanged;
+
+ // loop, until bSomeAggregatesChanged stays false
+ do
+ {
+ // only continue loop if 'intersects' branch below was hit
+ bSomeAggregatesChanged = false;
+
+ // iterate over all current members of maDisjunctAggregatesList
+ for( aCurrAggregate=maDisjunctAggregatesList.begin(),
+ aLastAggregate=maDisjunctAggregatesList.end();
+ aCurrAggregate != aLastAggregate; )
+ {
+ // first check if current component's bounds
+ // are empty. This ensures that distinct empty
+ // components are not merged into one
+ // aggregate. As a matter of fact, they have
+ // no position and size.
+
+ if( !aCurrAggregate->maTotalBounds.isEmpty() &&
+ aCurrAggregate->maTotalBounds.overlaps(
+ aNewConnectedComponent.maTotalBounds ) )
+ {
+ // union the intersecting
+ // maDisjunctAggregatesList element into
+ // aNewConnectedComponent
+
+ // calc union bounding box
+ aNewConnectedComponent.maTotalBounds.expand( aCurrAggregate->maTotalBounds );
+
+ // extract all aCurrAggregate components
+ // to aNewConnectedComponent
+ aNewConnectedComponent.maComponentList.splice(
+ aNewConnectedComponent.maComponentList.end(),
+ aCurrAggregate->maComponentList );
+
+ // remove and delete aCurrAggregate entry
+ // from list (we've gutted it's content
+ // above). list::erase() will update our
+ // iterator with the predecessor here.
+ aCurrAggregate = maDisjunctAggregatesList.erase( aCurrAggregate );
+
+ // at least one aggregate changed, need to rescan everything
+ bSomeAggregatesChanged = true;
+ }
+ else
+ {
+ aCurrAggregate++;
+ }
+ }
+ }
+ while( bSomeAggregatesChanged );
+ }
+
+ //
+ // STAGE 2: Add newly generated connected component list element
+ // =============================================================
+ //
+
+ // add new component to the end of the component list
+ aNewConnectedComponent.maComponentList.push_back(
+ ComponentType( rRange, rUserData ) );
+
+ // do some consistency checks (aka post conditions)
+ OSL_ENSURE( !aNewConnectedComponent.maComponentList.empty(),
+ "B2DConnectedRanges::addRange(): empty aggregate list" );
+ OSL_ENSURE( !aNewConnectedComponent.maTotalBounds.isEmpty() ||
+ (aNewConnectedComponent.maTotalBounds.isEmpty() &&
+ aNewConnectedComponent.maComponentList.size() == 1),
+ "B2DConnectedRanges::addRange(): empty ranges must be solitary");
+
+ // add aNewConnectedComponent as a new entry to
+ // maDisjunctAggregatesList
+ maDisjunctAggregatesList.push_back( aNewConnectedComponent );
+ }
+
+ /** Apply a functor to each of the disjunct component
+ aggregates.
+
+ @param aFunctor
+ Functor to apply. Must provide an operator( const ConnectedComponents& ).
+
+ @return a copy of the functor, as applied to all aggregates.
+ */
+ template< typename UnaryFunctor > UnaryFunctor forEachAggregate( UnaryFunctor aFunctor ) const
+ {
+ return ::std::for_each( maDisjunctAggregatesList.begin(),
+ maDisjunctAggregatesList.end(),
+ aFunctor );
+ }
+
+ private:
+ // default: disabled copy/assignment
+ B2DConnectedRanges(const B2DConnectedRanges&);
+ B2DConnectedRanges& operator=( const B2DConnectedRanges& );
+
+ /** Current list of disjunct sets of connected components
+
+ Each entry corresponds to one of the top-level rectangles
+ in the drawing above.
+ */
+ ConnectedComponentsType maDisjunctAggregatesList;
+
+ /** Global bound rect over all added ranges.
+ */
+ B2DRange maTotalBounds;
+ };
+}
+
+#endif /* _BGFX_RANGE_B2DCONNECTEDRANGES_HXX */
diff --git a/basegfx/inc/basegfx/range/b2dpolyrange.hxx b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
new file mode 100644
index 000000000000..2202869dc921
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DPOLYRANGE_HXX
+#define _BGFX_RANGE_B2DPOLYRANGE_HXX
+
+#include <o3tl/cow_wrapper.hxx>
+#include <boost/tuple/tuple.hpp>
+#include <basegfx/vector/b2enums.hxx>
+
+namespace basegfx
+{
+ class B2DTuple;
+ class B2DRange;
+ class B2DPolyPolygon;
+ class ImplB2DPolyRange;
+
+ /** Multiple ranges in one object.
+
+ This class combines multiple ranges in one object, providing a
+ total, enclosing range for it.
+
+ You can use this class e.g. when updating views containing
+ rectangular objects. Add each modified object to a
+ B2DMultiRange, then test each viewable object against
+ intersection with the multi range.
+
+ Similar in spirit to the poly-polygon vs. polygon relationship.
+
+ Note that comparable to polygons, a poly-range can also
+ contain 'holes' - this is encoded via polygon orientation at
+ the poly-polygon, and via explicit flags for the poly-range.
+ */
+ class B2DPolyRange
+ {
+ public:
+ typedef boost::tuple<B2DRange,B2VectorOrientation> ElementType ;
+
+ B2DPolyRange();
+ ~B2DPolyRange();
+
+ /** Create a multi range with exactly one containing range
+ */
+ explicit B2DPolyRange( const ElementType& rElement );
+ B2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient );
+ B2DPolyRange( const B2DPolyRange& );
+ B2DPolyRange& operator=( const B2DPolyRange& );
+
+ /// unshare this poly-range with all internally shared instances
+ void makeUnique();
+
+ bool operator==(const B2DPolyRange&) const;
+ bool operator!=(const B2DPolyRange&) const;
+
+ /// Number of included ranges
+ sal_uInt32 count() const;
+
+ ElementType getElement(sal_uInt32 nIndex) const;
+ void setElement(sal_uInt32 nIndex, const ElementType& rElement );
+ void setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient );
+
+ // insert/append a single range
+ void insertElement(sal_uInt32 nIndex, const ElementType& rElement, sal_uInt32 nCount = 1);
+ void insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1);
+ void appendElement(const ElementType& rElement, sal_uInt32 nCount = 1);
+ void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1);
+
+ // insert/append multiple ranges
+ void insertPolyRange(sal_uInt32 nIndex, const B2DPolyRange&);
+ void appendPolyRange(const B2DPolyRange&);
+
+ void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
+ void clear();
+
+ // flip range orientations - converts holes to solids, and vice versa
+ void flip();
+
+ /** Get overall range
+
+ @return
+ The union range of all contained ranges
+ */
+ B2DRange getBounds() const;
+
+ /** Test whether given tuple is inside one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool isInside( const B2DTuple& rTuple ) const;
+
+ /** Test whether given range is inside one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool isInside( const B2DRange& rRange ) const;
+
+ /** Test whether given range overlaps one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool overlaps( const B2DRange& rRange ) const;
+
+ /** Request a poly-polygon with solved cross-overs
+ */
+ B2DPolyPolygon solveCrossovers() const;
+
+ // element iterators (same iterator validity conditions as for vector)
+ const B2DRange* begin() const;
+ const B2DRange* end() const;
+ B2DRange* begin();
+ B2DRange* end();
+
+ private:
+ o3tl::cow_wrapper< ImplB2DPolyRange > mpImpl;
+ };
+}
+
+#endif /* _BGFX_RANGE_B2DPOLYRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx
new file mode 100644
index 000000000000..fc3a6fe53659
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2drange.hxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DRANGE_HXX
+#define _BGFX_RANGE_B2DRANGE_HXX
+
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/tuple/b2dtuple.hxx>
+#include <basegfx/range/basicrange.hxx>
+#include <vector>
+
+
+namespace basegfx
+{
+ // predeclarations
+ class B2IRange;
+ class B2DHomMatrix;
+
+ class B2DRange
+ {
+ public:
+ typedef double ValueType;
+ typedef DoubleTraits TraitsType;
+
+ B2DRange()
+ {
+ }
+
+ explicit B2DRange(const B2DTuple& rTuple)
+ : maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY())
+ {
+ }
+
+ B2DRange(double x1,
+ double y1,
+ double x2,
+ double y2)
+ : maRangeX(x1),
+ maRangeY(y1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ }
+
+ B2DRange(const B2DTuple& rTuple1,
+ const B2DTuple& rTuple2)
+ : maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY())
+ {
+ expand( rTuple2 );
+ }
+
+ B2DRange(const B2DRange& rRange)
+ : maRangeX(rRange.maRangeX),
+ maRangeY(rRange.maRangeY)
+ {
+ }
+
+ explicit B2DRange(const B2IRange& rRange);
+
+ bool isEmpty() const
+ {
+ return (
+ maRangeX.isEmpty()
+ || maRangeY.isEmpty()
+ );
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ }
+
+ bool operator==( const B2DRange& rRange ) const
+ {
+ return (maRangeX == rRange.maRangeX
+ && maRangeY == rRange.maRangeY);
+ }
+
+ bool operator!=( const B2DRange& rRange ) const
+ {
+ return (maRangeX != rRange.maRangeX
+ || maRangeY != rRange.maRangeY);
+ }
+
+ B2DRange& operator=(const B2DRange& rRange)
+ {
+ maRangeX = rRange.maRangeX;
+ maRangeY = rRange.maRangeY;
+ return *this;
+ }
+
+ bool equal(const B2DRange& rRange) const
+ {
+ return (maRangeX.equal(rRange.maRangeX)
+ && maRangeY.equal(rRange.maRangeY));
+ }
+
+ double getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ double getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ double getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ double getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ double getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ double getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ B2DPoint getMinimum() const
+ {
+ return B2DPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum()
+ );
+ }
+
+ B2DPoint getMaximum() const
+ {
+ return B2DPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum()
+ );
+ }
+
+ B2DVector getRange() const
+ {
+ return B2DVector(
+ maRangeX.getRange(),
+ maRangeY.getRange()
+ );
+ }
+
+ B2DPoint getCenter() const
+ {
+ return B2DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter()
+ );
+ }
+
+ double getCenterX() const
+ {
+ return maRangeX.getCenter();
+ }
+
+ double getCenterY() const
+ {
+ return maRangeY.getCenter();
+ }
+
+ bool isInside(const B2DTuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ );
+ }
+
+ bool isInside(const B2DRange& rRange) const
+ {
+ return (
+ maRangeX.isInside(rRange.maRangeX)
+ && maRangeY.isInside(rRange.maRangeY)
+ );
+ }
+
+ bool overlaps(const B2DRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ );
+ }
+
+ bool overlapsMore(const B2DRange& rRange) const
+ {
+ return (
+ maRangeX.overlapsMore(rRange.maRangeX)
+ && maRangeY.overlapsMore(rRange.maRangeY)
+ );
+ }
+
+ void expand(const B2DTuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ }
+
+ void expand(const B2DRange& rRange)
+ {
+ maRangeX.expand(rRange.maRangeX);
+ maRangeY.expand(rRange.maRangeY);
+ }
+
+ void intersect(const B2DRange& rRange)
+ {
+ maRangeX.intersect(rRange.maRangeX);
+ maRangeY.intersect(rRange.maRangeY);
+ }
+
+ void grow(double fValue)
+ {
+ maRangeX.grow(fValue);
+ maRangeY.grow(fValue);
+ }
+
+ void transform(const B2DHomMatrix& rMatrix);
+
+ private:
+ typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange;
+
+ MyBasicRange maRangeX;
+ MyBasicRange maRangeY;
+ };
+
+ /** Round double to nearest integer for 2D range
+
+ @return the nearest integer for this range
+ */
+ B2IRange fround(const B2DRange& rRange);
+
+ /** Compute the set difference of the two given ranges
+
+ This method calculates the symmetric difference (aka XOR)
+ between the two given ranges, and returning the resulting
+ ranges. Thus, the result will contain all areas where one, but
+ not both ranges lie.
+
+ @param o_rResult
+ Result vector. The up to four difference ranges are returned
+ within this vector
+
+ @param rFirst
+ The first range
+
+ @param rSecond
+ The second range
+
+ @return the input vector
+ */
+ ::std::vector< B2DRange >& computeSetDifference( ::std::vector< B2DRange >& o_rResult,
+ const B2DRange& rFirst,
+ const B2DRange& rSecond );
+
+} // end of namespace basegfx
+
+
+#endif /* _BGFX_RANGE_B2DRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2drangeclipper.hxx b/basegfx/inc/basegfx/range/b2drangeclipper.hxx
new file mode 100644
index 000000000000..3285ffeaffe1
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2drangeclipper.hxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DRANGECLIPPER_HXX
+#define _BGFX_RANGE_B2DRANGECLIPPER_HXX
+
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <vector>
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Extract poly-polygon w/o self-intersections from poly-range
+
+ Similar to the solveCrossovers(const B2DPolyPolygon&)
+ method, this one calculates a self-intersection-free
+ poly-polygon with the same topology, and encoding
+ inside/outsidedness via polygon orientation and layering.
+ */
+ B2DPolyPolygon solveCrossovers(const std::vector<B2DRange>& rRanges,
+ const std::vector<B2VectorOrientation>& rOrientations);
+ }
+}
+
+#endif /* _BGFX_RANGE_B2DRANGECLIPPER_HXX */
diff --git a/basegfx/inc/basegfx/range/b2drectangle.hxx b/basegfx/inc/basegfx/range/b2drectangle.hxx
new file mode 100644
index 000000000000..1fd2087f0bcd
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2drectangle.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
+#define _BGFX_RANGE_B2DRECTANGLE_HXX
+
+#include <basegfx/range/b2drange.hxx>
+
+namespace basegfx
+{
+ // syntactic sugar: a B2DRange exactly models a Rectangle, thus,
+ // for interface clarity, we provide an alias name
+
+ /// Alias name for interface clarity (not everybody is aware of the identity)
+ typedef B2DRange B2DRectangle;
+}
+
+#endif /* _BGFX_RANGE_B2DRECTANGLE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2ibox.hxx b/basegfx/inc/basegfx/range/b2ibox.hxx
new file mode 100644
index 000000000000..a188c7e8abe6
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2ibox.hxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2IBOX_HXX
+#define _BGFX_RANGE_B2IBOX_HXX
+
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/tuple/b2ituple.hxx>
+#include <basegfx/tuple/b2i64tuple.hxx>
+#include <basegfx/range/basicbox.hxx>
+#include <vector>
+
+
+namespace basegfx
+{
+ class B2IBox
+ {
+ public:
+ typedef sal_Int32 ValueType;
+ typedef Int32Traits TraitsType;
+
+ B2IBox()
+ {
+ }
+
+ explicit B2IBox(const B2ITuple& rTuple)
+ : maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY())
+ {
+ }
+
+ B2IBox(sal_Int32 x1,
+ sal_Int32 y1,
+ sal_Int32 x2,
+ sal_Int32 y2) :
+ maRangeX(x1),
+ maRangeY(y1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ }
+
+ B2IBox(const B2ITuple& rTuple1,
+ const B2ITuple& rTuple2) :
+ maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY())
+ {
+ expand( rTuple2 );
+ }
+
+ B2IBox(const B2IBox& rBox) :
+ maRangeX(rBox.maRangeX),
+ maRangeY(rBox.maRangeY)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRangeX.isEmpty() || maRangeY.isEmpty();
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ }
+
+ bool operator==( const B2IBox& rBox ) const
+ {
+ return (maRangeX == rBox.maRangeX
+ && maRangeY == rBox.maRangeY);
+ }
+
+ bool operator!=( const B2IBox& rBox ) const
+ {
+ return (maRangeX != rBox.maRangeX
+ || maRangeY != rBox.maRangeY);
+ }
+
+ void operator=(const B2IBox& rBox)
+ {
+ maRangeX = rBox.maRangeX;
+ maRangeY = rBox.maRangeY;
+ }
+
+ sal_Int32 getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ sal_Int32 getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ sal_Int32 getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ sal_Int32 getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ sal_Int64 getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ sal_Int64 getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ B2IPoint getMinimum() const
+ {
+ return B2IPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum()
+ );
+ }
+
+ B2IPoint getMaximum() const
+ {
+ return B2IPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum()
+ );
+ }
+
+ B2I64Tuple getRange() const
+ {
+ return B2I64Tuple(
+ maRangeX.getRange(),
+ maRangeY.getRange()
+ );
+ }
+
+ B2DPoint getCenter() const
+ {
+ return B2DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter()
+ );
+ }
+
+ bool isInside(const B2ITuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ );
+ }
+
+ bool isInside(const B2IBox& rBox) const
+ {
+ return (
+ maRangeX.isInside(rBox.maRangeX)
+ && maRangeY.isInside(rBox.maRangeY)
+ );
+ }
+
+ bool overlaps(const B2IBox& rBox) const
+ {
+ return (
+ maRangeX.overlaps(rBox.maRangeX)
+ && maRangeY.overlaps(rBox.maRangeY)
+ );
+ }
+
+ void expand(const B2ITuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ }
+
+ void expand(const B2IBox& rBox)
+ {
+ maRangeX.expand(rBox.maRangeX);
+ maRangeY.expand(rBox.maRangeY);
+ }
+
+ void intersect(const B2IBox& rBox)
+ {
+ maRangeX.intersect(rBox.maRangeX);
+ maRangeY.intersect(rBox.maRangeY);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRangeX.grow(nValue);
+ maRangeY.grow(nValue);
+ }
+
+ private:
+ BasicBox maRangeX;
+ BasicBox maRangeY;
+ };
+
+ /** Compute the set difference of the two given boxes
+
+ This method calculates the symmetric difference (aka XOR)
+ between the two given boxes, and returning the resulting
+ boxes. Thus, the result will contain all areas where one, but
+ not both boxes lie.
+
+ @param o_rResult
+ Result vector. The up to four difference boxes are returned
+ within this vector
+
+ @param rFirst
+ The first box
+
+ @param rSecond
+ The second box
+
+ @return the input vector
+ */
+ ::std::vector< B2IBox >& computeSetDifference( ::std::vector< B2IBox >& o_rResult,
+ const B2IBox& rFirst,
+ const B2IBox& rSecond );
+
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B2IBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/b2irange.hxx b/basegfx/inc/basegfx/range/b2irange.hxx
new file mode 100644
index 000000000000..8d4690283da0
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2irange.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2IRANGE_HXX
+#define _BGFX_RANGE_B2IRANGE_HXX
+
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/tuple/b2ituple.hxx>
+#include <basegfx/tuple/b2i64tuple.hxx>
+#include <basegfx/range/basicrange.hxx>
+#include <vector>
+
+
+namespace basegfx
+{
+ class B2IRange
+ {
+ public:
+ typedef sal_Int32 ValueType;
+ typedef Int32Traits TraitsType;
+
+ B2IRange()
+ {
+ }
+
+ explicit B2IRange(const B2ITuple& rTuple)
+ : maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY())
+ {
+ }
+
+ B2IRange(sal_Int32 x1,
+ sal_Int32 y1,
+ sal_Int32 x2,
+ sal_Int32 y2)
+ : maRangeX(x1),
+ maRangeY(y1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ }
+
+ B2IRange(const B2ITuple& rTuple1,
+ const B2ITuple& rTuple2)
+ : maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY())
+ {
+ expand( rTuple2 );
+ }
+
+ B2IRange(const B2IRange& rRange)
+ : maRangeX(rRange.maRangeX),
+ maRangeY(rRange.maRangeY)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRangeX.isEmpty() || maRangeY.isEmpty();
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ }
+
+ bool operator==( const B2IRange& rRange ) const
+ {
+ return (maRangeX == rRange.maRangeX
+ && maRangeY == rRange.maRangeY);
+ }
+
+ bool operator!=( const B2IRange& rRange ) const
+ {
+ return (maRangeX != rRange.maRangeX
+ || maRangeY != rRange.maRangeY);
+ }
+
+ B2IRange& operator=(const B2IRange& rRange)
+ {
+ maRangeX = rRange.maRangeX;
+ maRangeY = rRange.maRangeY;
+ return *this;
+ }
+
+ sal_Int32 getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ sal_Int32 getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ sal_Int32 getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ sal_Int32 getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ sal_Int64 getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ sal_Int64 getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ B2IPoint getMinimum() const
+ {
+ return B2IPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum()
+ );
+ }
+
+ B2IPoint getMaximum() const
+ {
+ return B2IPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum()
+ );
+ }
+
+ B2I64Tuple getRange() const
+ {
+ return B2I64Tuple(
+ maRangeX.getRange(),
+ maRangeY.getRange()
+ );
+ }
+
+ B2DPoint getCenter() const
+ {
+ return B2DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter()
+ );
+ }
+
+ bool isInside(const B2ITuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ );
+ }
+
+ bool isInside(const B2IRange& rRange) const
+ {
+ return (
+ maRangeX.isInside(rRange.maRangeX)
+ && maRangeY.isInside(rRange.maRangeY)
+ );
+ }
+
+ bool overlaps(const B2IRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ );
+ }
+
+ void expand(const B2ITuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ }
+
+ void expand(const B2IRange& rRange)
+ {
+ maRangeX.expand(rRange.maRangeX);
+ maRangeY.expand(rRange.maRangeY);
+ }
+
+ void intersect(const B2IRange& rRange)
+ {
+ maRangeX.intersect(rRange.maRangeX);
+ maRangeY.intersect(rRange.maRangeY);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRangeX.grow(nValue);
+ maRangeY.grow(nValue);
+ }
+
+ private:
+ typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange;
+
+ MyBasicRange maRangeX;
+ MyBasicRange maRangeY;
+ };
+
+ /** Compute the set difference of the two given ranges
+
+ This method calculates the symmetric difference (aka XOR)
+ between the two given ranges, and returning the resulting
+ ranges. Thus, the result will contain all areas where one, but
+ not both ranges lie.
+
+ @param o_rResult
+ Result vector. The up to four difference ranges are returned
+ within this vector
+
+ @param rFirst
+ The first range
+
+ @param rSecond
+ The second range
+
+ @return the input vector
+ */
+ ::std::vector< B2IRange >& computeSetDifference( ::std::vector< B2IRange >& o_rResult,
+ const B2IRange& rFirst,
+ const B2IRange& rSecond );
+
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B2IRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2irectangle.hxx b/basegfx/inc/basegfx/range/b2irectangle.hxx
new file mode 100644
index 000000000000..a9e46c82710c
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2irectangle.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2IRECTANGLE_HXX
+#define _BGFX_RANGE_B2IRECTANGLE_HXX
+
+#include <basegfx/range/b2irange.hxx>
+
+namespace basegfx
+{
+ // syntactic sugar: a B2IRange exactly models a Rectangle, thus,
+ // for interface clarity, we provide an alias name
+
+ /// Alias name for interface clarity (not everybody is aware of the identity)
+ typedef B2IRange B2IRectangle;
+}
+
+#endif /* _BGFX_RANGE_B2IRECTANGLE_HXX */
diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx
new file mode 100644
index 000000000000..2a2a42aa0718
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b3drange.hxx
@@ -0,0 +1,302 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B3DRANGE_HXX
+#define _BGFX_RANGE_B3DRANGE_HXX
+
+#include <basegfx/vector/b3dvector.hxx>
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/tuple/b3dtuple.hxx>
+#include <basegfx/range/basicrange.hxx>
+
+namespace basegfx
+{
+ // predeclarations
+ class B3IRange;
+ class B3DHomMatrix;
+
+ class B3DRange
+ {
+ typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange;
+
+ MyBasicRange maRangeX;
+ MyBasicRange maRangeY;
+ MyBasicRange maRangeZ;
+
+ public:
+ B3DRange()
+ {
+ }
+
+ explicit B3DRange(const B3DTuple& rTuple)
+ : maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY()),
+ maRangeZ(rTuple.getZ())
+ {
+ }
+
+ B3DRange(double x1,
+ double y1,
+ double z1,
+ double x2,
+ double y2,
+ double z2)
+ : maRangeX(x1),
+ maRangeY(y1),
+ maRangeZ(z1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ maRangeZ.expand(z2);
+ }
+
+ B3DRange(const B3DTuple& rTuple1,
+ const B3DTuple& rTuple2)
+ : maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY()),
+ maRangeZ(rTuple1.getZ())
+ {
+ expand(rTuple2);
+ }
+
+ B3DRange(const B3DRange& rRange)
+ : maRangeX(rRange.maRangeX),
+ maRangeY(rRange.maRangeY),
+ maRangeZ(rRange.maRangeZ)
+ {
+ }
+
+ explicit B3DRange(const B3IRange& rRange);
+
+ bool isEmpty() const
+ {
+ return (
+ maRangeX.isEmpty()
+ || maRangeY.isEmpty()
+ || maRangeZ.isEmpty()
+ );
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ maRangeZ.reset();
+ }
+
+ bool operator==( const B3DRange& rRange ) const
+ {
+ return (maRangeX == rRange.maRangeX
+ && maRangeY == rRange.maRangeY
+ && maRangeZ == rRange.maRangeZ);
+ }
+
+ bool operator!=( const B3DRange& rRange ) const
+ {
+ return (maRangeX != rRange.maRangeX
+ || maRangeY != rRange.maRangeY
+ || maRangeZ != rRange.maRangeZ);
+ }
+
+ B3DRange& operator=(const B3DRange& rRange)
+ {
+ maRangeX = rRange.maRangeX;
+ maRangeY = rRange.maRangeY;
+ maRangeZ = rRange.maRangeZ;
+ return *this;
+ }
+
+ bool equal(const B3DRange& rRange) const
+ {
+ return (maRangeX.equal(rRange.maRangeX)
+ && maRangeY.equal(rRange.maRangeY)
+ && maRangeZ.equal(rRange.maRangeZ));
+ }
+
+ double getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ double getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ double getMinZ() const
+ {
+ return maRangeZ.getMinimum();
+ }
+
+ double getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ double getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ double getMaxZ() const
+ {
+ return maRangeZ.getMaximum();
+ }
+
+ double getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ double getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ double getDepth() const
+ {
+ return maRangeZ.getRange();
+ }
+
+ B3DPoint getMinimum() const
+ {
+ return B3DPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum(),
+ maRangeZ.getMinimum()
+ );
+ }
+
+ B3DPoint getMaximum() const
+ {
+ return B3DPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum(),
+ maRangeZ.getMaximum()
+ );
+ }
+
+ B3DVector getRange() const
+ {
+ return B3DVector(
+ maRangeX.getRange(),
+ maRangeY.getRange(),
+ maRangeZ.getRange()
+ );
+ }
+
+ B3DPoint getCenter() const
+ {
+ return B3DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter(),
+ maRangeZ.getCenter()
+ );
+ }
+
+ double getCenterX() const
+ {
+ return maRangeX.getCenter();
+ }
+
+ double getCenterY() const
+ {
+ return maRangeY.getCenter();
+ }
+
+ double getCenterZ() const
+ {
+ return maRangeZ.getCenter();
+ }
+
+ bool isInside(const B3DTuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ && maRangeZ.isInside(rTuple.getZ())
+ );
+ }
+
+ bool isInside(const B3DRange& rRange) const
+ {
+ return (
+ maRangeX.isInside(rRange.maRangeX)
+ && maRangeY.isInside(rRange.maRangeY)
+ && maRangeZ.isInside(rRange.maRangeZ)
+ );
+ }
+
+ bool overlaps(const B3DRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ && maRangeZ.overlaps(rRange.maRangeZ)
+ );
+ }
+
+ void expand(const B3DTuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ maRangeZ.expand(rTuple.getZ());
+ }
+
+ void expand(const B3DRange& rRange)
+ {
+ maRangeX.expand(rRange.maRangeX);
+ maRangeY.expand(rRange.maRangeY);
+ maRangeZ.expand(rRange.maRangeZ);
+ }
+
+ void intersect(const B3DRange& rRange)
+ {
+ maRangeX.intersect(rRange.maRangeX);
+ maRangeY.intersect(rRange.maRangeY);
+ maRangeZ.intersect(rRange.maRangeZ);
+ }
+
+ void grow(double fValue)
+ {
+ maRangeX.grow(fValue);
+ maRangeY.grow(fValue);
+ maRangeZ.grow(fValue);
+ }
+
+ void transform(const B3DHomMatrix& rMatrix);
+ };
+
+ /** Round double to nearest integer for 3D range
+
+ @return the nearest integer for this range
+ */
+ B3IRange fround(const B3DRange& rRange);
+} // end of namespace basegfx
+
+
+#endif /* _BGFX_RANGE_B3DRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b3dvolume.hxx b/basegfx/inc/basegfx/range/b3dvolume.hxx
new file mode 100644
index 000000000000..18163d5b6c34
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b3dvolume.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B3DBOX_HXX
+#define _BGFX_RANGE_B3DBOX_HXX
+
+#include <basegfx/range/b3drange.hxx>
+
+namespace basegfx
+{
+ // syntactic sugar: a B3DRange exactly models a Volume in 3D, thus,
+ // for interface clarity, we provide an alias name
+
+ /// Alias name for interface clarity (not everybody is aware of the identity)
+ typedef B3DRange B3DVolume;
+}
+
+#endif /* _BGFX_RANGE_B3DBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/b3ibox.hxx b/basegfx/inc/basegfx/range/b3ibox.hxx
new file mode 100644
index 000000000000..f9693465a2bb
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b3ibox.hxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B3IBOX_HXX
+#define _BGFX_RANGE_B3IBOX_HXX
+
+#include <basegfx/point/b3ipoint.hxx>
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/tuple/b3ituple.hxx>
+#include <basegfx/tuple/b3i64tuple.hxx>
+#include <basegfx/range/basicbox.hxx>
+
+namespace basegfx
+{
+ class B3IBox
+ {
+ BasicBox maRangeX;
+ BasicBox maRangeY;
+ BasicBox maRangeZ;
+
+ public:
+ B3IBox()
+ {
+ }
+
+ explicit B3IBox(const B3ITuple& rTuple) :
+ maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY()),
+ maRangeZ(rTuple.getZ())
+ {
+ }
+
+ B3IBox(sal_Int32 x1,
+ sal_Int32 y1,
+ sal_Int32 z1,
+ sal_Int32 x2,
+ sal_Int32 y2,
+ sal_Int32 z2) :
+ maRangeX(x1),
+ maRangeY(y1),
+ maRangeZ(z1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ maRangeZ.expand(z2);
+ }
+
+ B3IBox(const B3ITuple& rTuple1,
+ const B3ITuple& rTuple2) :
+ maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY()),
+ maRangeZ(rTuple1.getZ())
+ {
+ expand(rTuple2);
+ }
+
+ B3IBox(const B3IBox& rBox) :
+ maRangeX(rBox.maRangeX),
+ maRangeY(rBox.maRangeY),
+ maRangeZ(rBox.maRangeZ)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRangeX.isEmpty() || maRangeY.isEmpty() || maRangeZ.isEmpty();
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ maRangeZ.reset();
+ }
+
+ bool operator==( const B3IBox& rBox ) const
+ {
+ return (maRangeX == rBox.maRangeX
+ && maRangeY == rBox.maRangeY
+ && maRangeZ == rBox.maRangeZ);
+ }
+
+ bool operator!=( const B3IBox& rBox ) const
+ {
+ return (maRangeX != rBox.maRangeX
+ || maRangeY != rBox.maRangeY
+ || maRangeZ != rBox.maRangeZ);
+ }
+
+ void operator=(const B3IBox& rBox)
+ {
+ maRangeX = rBox.maRangeX;
+ maRangeY = rBox.maRangeY;
+ maRangeZ = rBox.maRangeZ;
+ }
+
+ sal_Int32 getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ sal_Int32 getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ sal_Int32 getMinZ() const
+ {
+ return maRangeZ.getMinimum();
+ }
+
+ sal_Int32 getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ sal_Int32 getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ sal_Int32 getMaxZ() const
+ {
+ return maRangeZ.getMaximum();
+ }
+
+ sal_Int64 getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ sal_Int64 getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ sal_Int64 getDepth() const
+ {
+ return maRangeZ.getRange();
+ }
+
+ B3IPoint getMinimum() const
+ {
+ return B3IPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum(),
+ maRangeZ.getMinimum()
+ );
+ }
+
+ B3IPoint getMaximum() const
+ {
+ return B3IPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum(),
+ maRangeZ.getMaximum()
+ );
+ }
+
+ B3I64Tuple getRange() const
+ {
+ return B3I64Tuple(
+ maRangeX.getRange(),
+ maRangeY.getRange(),
+ maRangeZ.getRange()
+ );
+ }
+
+ B3DPoint getCenter() const
+ {
+ return B3DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter(),
+ maRangeZ.getCenter()
+ );
+ }
+
+ bool isInside(const B3ITuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ && maRangeZ.isInside(rTuple.getZ())
+ );
+ }
+
+ bool isInside(const B3IBox& rBox) const
+ {
+ return (
+ maRangeX.isInside(rBox.maRangeX)
+ && maRangeY.isInside(rBox.maRangeY)
+ && maRangeZ.isInside(rBox.maRangeZ)
+ );
+ }
+
+ bool overlaps(const B3IBox& rBox) const
+ {
+ return (
+ maRangeX.overlaps(rBox.maRangeX)
+ && maRangeY.overlaps(rBox.maRangeY)
+ && maRangeZ.overlaps(rBox.maRangeZ)
+ );
+ }
+
+ void expand(const B3ITuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ maRangeZ.expand(rTuple.getZ());
+ }
+
+ void expand(const B3IBox& rBox)
+ {
+ maRangeX.expand(rBox.maRangeX);
+ maRangeY.expand(rBox.maRangeY);
+ maRangeZ.expand(rBox.maRangeZ);
+ }
+
+ void intersect(const B3IBox& rBox)
+ {
+ maRangeX.intersect(rBox.maRangeX);
+ maRangeY.intersect(rBox.maRangeY);
+ maRangeZ.intersect(rBox.maRangeZ);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRangeX.grow(nValue);
+ maRangeY.grow(nValue);
+ maRangeZ.grow(nValue);
+ }
+ };
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B3IBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/b3irange.hxx b/basegfx/inc/basegfx/range/b3irange.hxx
new file mode 100644
index 000000000000..e2b9a08c3093
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b3irange.hxx
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B3IRANGE_HXX
+#define _BGFX_RANGE_B3IRANGE_HXX
+
+#include <basegfx/point/b3ipoint.hxx>
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/tuple/b3ituple.hxx>
+#include <basegfx/tuple/b3i64tuple.hxx>
+#include <basegfx/range/basicrange.hxx>
+
+namespace basegfx
+{
+ class B3IRange
+ {
+ typedef ::basegfx::BasicRange< sal_Int32, Int32Traits > MyBasicRange;
+
+ MyBasicRange maRangeX;
+ MyBasicRange maRangeY;
+ MyBasicRange maRangeZ;
+
+ public:
+ B3IRange()
+ {
+ }
+
+ explicit B3IRange(const B3ITuple& rTuple)
+ : maRangeX(rTuple.getX()),
+ maRangeY(rTuple.getY()),
+ maRangeZ(rTuple.getZ())
+ {
+ }
+
+ B3IRange(sal_Int32 x1,
+ sal_Int32 y1,
+ sal_Int32 z1,
+ sal_Int32 x2,
+ sal_Int32 y2,
+ sal_Int32 z2)
+ : maRangeX(x1),
+ maRangeY(y1),
+ maRangeZ(z1)
+ {
+ maRangeX.expand(x2);
+ maRangeY.expand(y2);
+ maRangeZ.expand(z2);
+ }
+
+ B3IRange(const B3ITuple& rTuple1,
+ const B3ITuple& rTuple2)
+ : maRangeX(rTuple1.getX()),
+ maRangeY(rTuple1.getY()),
+ maRangeZ(rTuple1.getZ())
+ {
+ expand(rTuple2);
+ }
+
+ B3IRange(const B3IRange& rRange)
+ : maRangeX(rRange.maRangeX),
+ maRangeY(rRange.maRangeY),
+ maRangeZ(rRange.maRangeZ)
+ {
+ }
+
+ bool isEmpty() const
+ {
+ return maRangeX.isEmpty() || maRangeY.isEmpty() || maRangeZ.isEmpty();
+ }
+
+ void reset()
+ {
+ maRangeX.reset();
+ maRangeY.reset();
+ maRangeZ.reset();
+ }
+
+ bool operator==( const B3IRange& rRange ) const
+ {
+ return (maRangeX == rRange.maRangeX
+ && maRangeY == rRange.maRangeY
+ && maRangeZ == rRange.maRangeZ);
+ }
+
+ bool operator!=( const B3IRange& rRange ) const
+ {
+ return (maRangeX != rRange.maRangeX
+ || maRangeY != rRange.maRangeY
+ || maRangeZ != rRange.maRangeZ);
+ }
+
+ B3IRange& operator=(const B3IRange& rRange)
+ {
+ maRangeX = rRange.maRangeX;
+ maRangeY = rRange.maRangeY;
+ maRangeZ = rRange.maRangeZ;
+ return *this;
+ }
+
+ sal_Int32 getMinX() const
+ {
+ return maRangeX.getMinimum();
+ }
+
+ sal_Int32 getMinY() const
+ {
+ return maRangeY.getMinimum();
+ }
+
+ sal_Int32 getMinZ() const
+ {
+ return maRangeZ.getMinimum();
+ }
+
+ sal_Int32 getMaxX() const
+ {
+ return maRangeX.getMaximum();
+ }
+
+ sal_Int32 getMaxY() const
+ {
+ return maRangeY.getMaximum();
+ }
+
+ sal_Int32 getMaxZ() const
+ {
+ return maRangeZ.getMaximum();
+ }
+
+ sal_Int64 getWidth() const
+ {
+ return maRangeX.getRange();
+ }
+
+ sal_Int64 getHeight() const
+ {
+ return maRangeY.getRange();
+ }
+
+ sal_Int64 getDepth() const
+ {
+ return maRangeZ.getRange();
+ }
+
+ B3IPoint getMinimum() const
+ {
+ return B3IPoint(
+ maRangeX.getMinimum(),
+ maRangeY.getMinimum(),
+ maRangeZ.getMinimum()
+ );
+ }
+
+ B3IPoint getMaximum() const
+ {
+ return B3IPoint(
+ maRangeX.getMaximum(),
+ maRangeY.getMaximum(),
+ maRangeZ.getMaximum()
+ );
+ }
+
+ B3I64Tuple getRange() const
+ {
+ return B3I64Tuple(
+ maRangeX.getRange(),
+ maRangeY.getRange(),
+ maRangeZ.getRange()
+ );
+ }
+
+ B3DPoint getCenter() const
+ {
+ return B3DPoint(
+ maRangeX.getCenter(),
+ maRangeY.getCenter(),
+ maRangeZ.getCenter()
+ );
+ }
+
+ bool isInside(const B3ITuple& rTuple) const
+ {
+ return (
+ maRangeX.isInside(rTuple.getX())
+ && maRangeY.isInside(rTuple.getY())
+ && maRangeZ.isInside(rTuple.getZ())
+ );
+ }
+
+ bool isInside(const B3IRange& rRange) const
+ {
+ return (
+ maRangeX.isInside(rRange.maRangeX)
+ && maRangeY.isInside(rRange.maRangeY)
+ && maRangeZ.isInside(rRange.maRangeZ)
+ );
+ }
+
+ bool overlaps(const B3IRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ && maRangeZ.overlaps(rRange.maRangeZ)
+ );
+ }
+
+ void expand(const B3ITuple& rTuple)
+ {
+ maRangeX.expand(rTuple.getX());
+ maRangeY.expand(rTuple.getY());
+ maRangeZ.expand(rTuple.getZ());
+ }
+
+ void expand(const B3IRange& rRange)
+ {
+ maRangeX.expand(rRange.maRangeX);
+ maRangeY.expand(rRange.maRangeY);
+ maRangeZ.expand(rRange.maRangeZ);
+ }
+
+ void intersect(const B3IRange& rRange)
+ {
+ maRangeX.intersect(rRange.maRangeX);
+ maRangeY.intersect(rRange.maRangeY);
+ maRangeZ.intersect(rRange.maRangeZ);
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ maRangeX.grow(nValue);
+ maRangeY.grow(nValue);
+ maRangeZ.grow(nValue);
+ }
+ };
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_B3IRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b3ivolume.hxx b/basegfx/inc/basegfx/range/b3ivolume.hxx
new file mode 100644
index 000000000000..0250a9050251
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b3ivolume.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B3IBOX_HXX
+#define _BGFX_RANGE_B3IBOX_HXX
+
+#include <basegfx/range/b3irange.hxx>
+
+namespace basegfx
+{
+ // syntactic sugar: a B3IRange exactly models a Box in 3D, thus,
+ // for interface clarity, we provide an alias name
+
+ /// Alias name for interface clarity (not everybody is aware of the identity)
+ typedef B3IRange B3IBox;
+}
+
+#endif /* _BGFX_RANGE_B3IBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/basicbox.hxx b/basegfx/inc/basegfx/range/basicbox.hxx
new file mode 100644
index 000000000000..0a5274bc9bc9
--- /dev/null
+++ b/basegfx/inc/basegfx/range/basicbox.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_BASICBOX_HXX
+#define _BGFX_RANGE_BASICBOX_HXX
+
+#include <basegfx/range/basicrange.hxx>
+
+
+namespace basegfx
+{
+ /** Specialization of BasicRange, handling the inside predicates
+ differently.
+
+ This template considers the rightmost and bottommost border as
+ <em>outside</em> of the range, in contrast to BasicRange,
+ which considers them inside.
+ */
+ class BasicBox : public BasicRange< sal_Int32, Int32Traits >
+ {
+ typedef BasicRange< sal_Int32, Int32Traits > Base;
+ public:
+ BasicBox() :
+ Base()
+ {
+ }
+
+ BasicBox( sal_Int32 nValue ) :
+ Base( nValue )
+ {
+ }
+
+ BasicBox(const BasicBox& rBox) :
+ Base( rBox )
+ {
+ }
+
+ double getCenter() const
+ {
+ if(isEmpty())
+ {
+ return 0.0;
+ }
+ else
+ {
+ return ((mnMaximum + mnMinimum - 1.0) / 2.0);
+ }
+ }
+
+ using Base::isInside;
+
+ bool isInside(sal_Int32 nValue) const
+ {
+ if(isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ return (nValue >= mnMinimum) && (nValue < mnMaximum);
+ }
+ }
+
+ using Base::overlaps;
+
+ bool overlaps(const BasicBox& rBox) const
+ {
+ if(isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ if(rBox.isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ return !((rBox.mnMaximum <= mnMinimum) || (rBox.mnMinimum >= mnMaximum));
+ }
+ }
+ }
+
+ void grow(sal_Int32 nValue)
+ {
+ if(!isEmpty())
+ {
+ bool bLessThanZero(nValue < 0);
+
+ if(nValue > 0 || bLessThanZero)
+ {
+ mnMinimum -= nValue;
+ mnMaximum += nValue;
+
+ if(bLessThanZero)
+ {
+ // test if range did collapse
+ if(mnMinimum > mnMaximum)
+ {
+ // if yes, collapse to center
+ mnMinimum = mnMaximum = ((mnMaximum + mnMinimum - 1) / 2);
+ }
+ }
+ }
+ }
+ }
+ };
+
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_BASICBOX_HXX */
diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx
new file mode 100644
index 000000000000..578e36824cf3
--- /dev/null
+++ b/basegfx/inc/basegfx/range/basicrange.hxx
@@ -0,0 +1,297 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_BASICRANGE_HXX
+#define _BGFX_RANGE_BASICRANGE_HXX
+
+#include <sal/types.h>
+#include <float.h>
+#include <basegfx/numeric/ftools.hxx>
+
+
+namespace basegfx
+{
+ template< typename T, typename Traits > class BasicRange
+ {
+ protected:
+ T mnMinimum;
+ T mnMaximum;
+
+ public:
+ typedef T ValueType;
+ typedef Traits TraitsType;
+
+ BasicRange() :
+ mnMinimum(Traits::maxVal()),
+ mnMaximum(Traits::minVal())
+ {
+ }
+
+ BasicRange( T nValue ) :
+ mnMinimum(nValue),
+ mnMaximum(nValue)
+ {
+ }
+
+ BasicRange(const BasicRange& rRange) :
+ mnMinimum(rRange.mnMinimum),
+ mnMaximum(rRange.mnMaximum)
+ {
+ }
+
+ void reset()
+ {
+ mnMinimum = Traits::maxVal();
+ mnMaximum = Traits::minVal();
+ }
+
+ bool isEmpty() const
+ {
+ return Traits::maxVal() == mnMinimum;
+ }
+
+ T getMinimum() const { return mnMinimum; }
+ T getMaximum() const { return mnMaximum; }
+
+ double getCenter() const
+ {
+ if(isEmpty())
+ {
+ return 0.0;
+ }
+ else
+ {
+ return ((mnMaximum + mnMinimum) / 2.0);
+ }
+ }
+
+ bool isInside(T nValue) const
+ {
+ if(isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ return (nValue >= mnMinimum) && (nValue <= mnMaximum);
+ }
+ }
+
+ bool isInside(const BasicRange& rRange) const
+ {
+ if(isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ if(rRange.isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ return (rRange.mnMinimum >= mnMinimum) && (rRange.mnMaximum <= mnMaximum);
+ }
+ }
+ }
+
+ bool overlaps(const BasicRange& rRange) const
+ {
+ if(isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ if(rRange.isEmpty())
+ {
+ return false;
+ }
+ else
+ {
+ return !((rRange.mnMaximum < mnMinimum) || (rRange.mnMinimum > mnMaximum));
+ }
+ }
+ }
+
+ bool overlapsMore(const BasicRange& rRange) const
+ {
+ if(isEmpty() || rRange.isEmpty())
+ return false;
+ // returns true if the overlap is more than just a touching at the limits
+ return ((rRange.mnMaximum > mnMinimum) && (rRange.mnMinimum < mnMaximum));
+ }
+
+ bool operator==( const BasicRange& rRange ) const
+ {
+ return (mnMinimum == rRange.mnMinimum && mnMaximum == rRange.mnMaximum);
+ }
+
+ bool operator!=( const BasicRange& rRange ) const
+ {
+ return (mnMinimum != rRange.mnMinimum || mnMaximum != rRange.mnMaximum);
+ }
+
+ BasicRange& operator=(const BasicRange& rRange)
+ {
+ mnMinimum = rRange.mnMinimum;
+ mnMaximum = rRange.mnMaximum;
+ return *this;
+ }
+
+ bool equal(const BasicRange& rRange) const
+ {
+ return (
+ fTools::equal(mnMinimum, rRange.mnMinimum) &&
+ fTools::equal(mnMaximum, rRange.mnMaximum));
+ }
+
+ void expand(T nValue)
+ {
+ if(isEmpty())
+ {
+ mnMinimum = mnMaximum = nValue;
+ }
+ else
+ {
+ if(nValue < mnMinimum)
+ {
+ mnMinimum = nValue;
+ }
+
+ if(nValue > mnMaximum)
+ {
+ mnMaximum = nValue;
+ }
+ }
+ }
+
+ void expand(const BasicRange& rRange)
+ {
+ if(isEmpty())
+ {
+ mnMinimum = rRange.mnMinimum;
+ mnMaximum = rRange.mnMaximum;
+ }
+ else
+ {
+ if(!rRange.isEmpty())
+ {
+ if(rRange.mnMinimum < mnMinimum)
+ {
+ mnMinimum = rRange.mnMinimum;
+ }
+
+ if(rRange.mnMaximum > mnMaximum)
+ {
+ mnMaximum = rRange.mnMaximum;
+ }
+ }
+ }
+ }
+
+ void intersect(const BasicRange& rRange)
+ {
+ // here, overlaps also tests all isEmpty() conditions already.
+ if( !overlaps( rRange ) )
+ {
+ reset();
+ }
+ else
+ {
+ if(rRange.mnMinimum > mnMinimum)
+ {
+ mnMinimum = rRange.mnMinimum;
+ }
+
+ if(rRange.mnMaximum < mnMaximum)
+ {
+ mnMaximum = rRange.mnMaximum;
+ }
+ }
+ }
+
+ void grow(T nValue)
+ {
+ if(!isEmpty())
+ {
+ bool bLessThanZero(nValue < 0);
+
+ if(nValue > 0 || bLessThanZero)
+ {
+ mnMinimum -= nValue;
+ mnMaximum += nValue;
+
+ if(bLessThanZero)
+ {
+ // test if range did collapse
+ if(mnMinimum > mnMaximum)
+ {
+ // if yes, collapse to center
+ mnMinimum = mnMaximum = (mnMinimum + mnMaximum) / 2;
+ }
+ }
+ }
+ }
+ }
+
+ typename Traits::DifferenceType getRange() const
+ {
+ if(isEmpty())
+ {
+ return Traits::neutral();
+ }
+ else
+ {
+ return (mnMaximum - mnMinimum);
+ }
+ }
+ };
+
+ // some pre-fabricated traits
+ struct DoubleTraits
+ {
+ static double minVal() { return DBL_MIN; };
+ static double maxVal() { return DBL_MAX; };
+ static double neutral() { return 0.0; };
+
+ typedef double DifferenceType;
+ };
+
+ struct Int32Traits
+ {
+ static sal_Int32 minVal() { return SAL_MIN_INT32; };
+ static sal_Int32 maxVal() { return SAL_MAX_INT32; };
+ static sal_Int32 neutral() { return 0L; };
+
+ typedef sal_Int64 DifferenceType;
+ };
+
+} // end of namespace basegfx
+
+#endif /* _BGFX_RANGE_BASICRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/rangeexpander.hxx b/basegfx/inc/basegfx/range/rangeexpander.hxx
new file mode 100644
index 000000000000..f8d2ac9c6b68
--- /dev/null
+++ b/basegfx/inc/basegfx/range/rangeexpander.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_RANGEEXPANDER_HXX
+#define _BGFX_RANGE_RANGEEXPANDER_HXX
+
+#include <basegfx/range/b1drange.hxx>
+#include <basegfx/range/b1irange.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/range/b2irange.hxx>
+#include <basegfx/range/b3drange.hxx>
+#include <basegfx/range/b3irange.hxx>
+
+namespace basegfx
+{
+ /** Generic functor for expanding a range with a number of other
+ ranges.
+
+ Since *Range::expand() is overloaded, straight-forward
+ application of ::boost::bind and friends fails (because of
+ ambiguities). Thus, this functor template can be used, to
+ expand the given range with a number of other ranges, passed
+ in at the function operator.
+
+ @tpl RangeType
+ Range type to operate with. Preferrably, one of B1*Range,
+ B2*Range, or B3*Range.
+ */
+ template< typename RangeType > class RangeExpander
+ {
+ public:
+ typedef RangeType ValueType;
+ typedef void result_type;
+
+ explicit RangeExpander( ValueType& rBounds ) :
+ mrBounds( rBounds )
+ {
+ }
+
+ void operator()( const ValueType& rBounds )
+ {
+ mrBounds.expand( rBounds );
+ }
+
+ private:
+ ValueType& mrBounds;
+ };
+
+ typedef RangeExpander< B1DRange > B1DRangeExpander;
+ typedef RangeExpander< B1IRange > B1IRangeExpander;
+ typedef RangeExpander< B2DRange > B2DRangeExpander;
+ typedef RangeExpander< B2IRange > B2IRangeExpander;
+ typedef RangeExpander< B3DRange > B3DRangeExpander;
+ typedef RangeExpander< B3IRange > B3IRangeExpander;
+
+} // end of namespace basegfx
+
+
+#endif /* _BGFX_RANGE_RANGEEXPANDER_HXX */