diff options
Diffstat (limited to 'basegfx/source/polygon/b2dpolypolygon.cxx')
-rw-r--r-- | basegfx/source/polygon/b2dpolypolygon.cxx | 349 |
1 files changed, 173 insertions, 176 deletions
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 301d5a68edd8..f6fcbd9c0e55 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygon.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-11-26 14:40:11 $ + * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,7 +81,7 @@ class ImplB2DPolyPolygon { - typedef ::std::vector< ::basegfx::polygon::B2DPolygon > PolygonVector; + typedef ::std::vector< ::basegfx::B2DPolygon > PolygonVector; PolygonVector maPolygons; sal_uInt32 mnRefCount; @@ -127,17 +127,17 @@ public: return sal_True; } - const ::basegfx::polygon::B2DPolygon& getB2DPolygon(sal_uInt32 nIndex) const + const ::basegfx::B2DPolygon& getB2DPolygon(sal_uInt32 nIndex) const { return maPolygons[nIndex]; } - void setB2DPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon) + void setB2DPolygon(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rPolygon) { maPolygons[nIndex] = rPolygon; } - void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_uInt32 nCount) + void insert(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rPolygon, sal_uInt32 nCount) { if(nCount) { @@ -148,7 +148,7 @@ public: } } - void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolyPolygon& rPolyPolygon) + void insert(sal_uInt32 nIndex, const ::basegfx::B2DPolyPolygon& rPolyPolygon) { const sal_uInt32 nCount = rPolyPolygon.count(); @@ -209,7 +209,7 @@ public: } } - void transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + void transform(const ::basegfx::B2DHomMatrix& rMatrix) { for(sal_uInt32 a(0L); a < maPolygons.size(); a++) { @@ -222,247 +222,244 @@ public: namespace basegfx { - namespace polygon - { - // init static default Polygon - static ImplB2DPolyPolygon maStaticDefaultPolyPolygon; + // init static default Polygon + static ImplB2DPolyPolygon maStaticDefaultPolyPolygon; - void B2DPolyPolygon::implForceUniqueCopy() + void B2DPolyPolygon::implForceUniqueCopy() + { + if(mpPolyPolygon->getRefCount()) { - if(mpPolyPolygon->getRefCount()) - { - mpPolyPolygon->decRefCount(); - mpPolyPolygon = new ImplB2DPolyPolygon(*mpPolyPolygon); - } + mpPolyPolygon->decRefCount(); + mpPolyPolygon = new ImplB2DPolyPolygon(*mpPolyPolygon); } + } - B2DPolyPolygon::B2DPolyPolygon() - : mpPolyPolygon(&maStaticDefaultPolyPolygon) - { - mpPolyPolygon->incRefCount(); - } + B2DPolyPolygon::B2DPolyPolygon() + : mpPolyPolygon(&maStaticDefaultPolyPolygon) + { + mpPolyPolygon->incRefCount(); + } - B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon) - : mpPolyPolygon(rPolyPolygon.mpPolyPolygon) + B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon) + : mpPolyPolygon(rPolyPolygon.mpPolyPolygon) + { + mpPolyPolygon->incRefCount(); + } + + B2DPolyPolygon::~B2DPolyPolygon() + { + if(mpPolyPolygon->getRefCount()) { - mpPolyPolygon->incRefCount(); + mpPolyPolygon->decRefCount(); } - - B2DPolyPolygon::~B2DPolyPolygon() + else { - if(mpPolyPolygon->getRefCount()) - { - mpPolyPolygon->decRefCount(); - } - else - { - delete mpPolyPolygon; - } + delete mpPolyPolygon; } + } - B2DPolyPolygon& B2DPolyPolygon::operator=(const B2DPolyPolygon& rPolyPolygon) + B2DPolyPolygon& B2DPolyPolygon::operator=(const B2DPolyPolygon& rPolyPolygon) + { + if(mpPolyPolygon->getRefCount()) { - if(mpPolyPolygon->getRefCount()) - { - mpPolyPolygon->decRefCount(); - } - else - { - delete mpPolyPolygon; - } - - mpPolyPolygon = rPolyPolygon.mpPolyPolygon; - mpPolyPolygon->incRefCount(); - - return *this; + mpPolyPolygon->decRefCount(); } - - sal_Bool B2DPolyPolygon::operator==(const B2DPolyPolygon& rPolyPolygon) const + else { - if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon) - { - return sal_True; - } - - return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon)); + delete mpPolyPolygon; } - sal_Bool B2DPolyPolygon::operator!=(const B2DPolyPolygon& rPolyPolygon) const - { - if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon) - { - return sal_False; - } + mpPolyPolygon = rPolyPolygon.mpPolyPolygon; + mpPolyPolygon->incRefCount(); - return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon)); - } + return *this; + } - sal_uInt32 B2DPolyPolygon::count() const + sal_Bool B2DPolyPolygon::operator==(const B2DPolyPolygon& rPolyPolygon) const + { + if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon) { - return mpPolyPolygon->count(); + return sal_True; } - B2DPolygon B2DPolyPolygon::getB2DPolygon(sal_uInt32 nIndex) const - { - OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); + return mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon)); + } - return mpPolyPolygon->getB2DPolygon(nIndex); + sal_Bool B2DPolyPolygon::operator!=(const B2DPolyPolygon& rPolyPolygon) const + { + if(mpPolyPolygon == rPolyPolygon.mpPolyPolygon) + { + return sal_False; } - void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon) - { - OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); + return !mpPolyPolygon->isEqual(*(rPolyPolygon.mpPolyPolygon)); + } - if(mpPolyPolygon->getB2DPolygon(nIndex) != rPolygon) - { - implForceUniqueCopy(); - mpPolyPolygon->setB2DPolygon(nIndex, rPolygon); - } - } + sal_uInt32 B2DPolyPolygon::count() const + { + return mpPolyPolygon->count(); + } - sal_Bool B2DPolyPolygon::areControlPointsUsed() const - { - for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++) - { - const ::basegfx::polygon::B2DPolygon& rPolygon = mpPolyPolygon->getB2DPolygon(a); + B2DPolygon B2DPolyPolygon::getB2DPolygon(sal_uInt32 nIndex) const + { + OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); - if(rPolygon.areControlPointsUsed()) - { - return sal_True; - } - } + return mpPolyPolygon->getB2DPolygon(nIndex); + } - return sal_False; + void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon) + { + OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)"); + + if(mpPolyPolygon->getB2DPolygon(nIndex) != rPolygon) + { + implForceUniqueCopy(); + mpPolyPolygon->setB2DPolygon(nIndex, rPolygon); } + } - void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount) + sal_Bool B2DPolyPolygon::areControlPointsUsed() const + { + for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++) { - OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); + const ::basegfx::B2DPolygon& rPolygon = mpPolyPolygon->getB2DPolygon(a); - if(nCount) + if(rPolygon.areControlPointsUsed()) { - implForceUniqueCopy(); - mpPolyPolygon->insert(nIndex, rPolygon, nCount); + return sal_True; } } - void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount) + return sal_False; + } + + void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount) + { + OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); + + if(nCount) { - if(nCount) - { - implForceUniqueCopy(); - mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount); - } + implForceUniqueCopy(); + mpPolyPolygon->insert(nIndex, rPolygon, nCount); } + } - void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon) + void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount) + { + if(nCount) { - OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); - - if(rPolyPolygon.count()) - { - implForceUniqueCopy(); - mpPolyPolygon->insert(nIndex, rPolyPolygon); - } + implForceUniqueCopy(); + mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount); } + } + + void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon) + { + OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)"); - void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon) + if(rPolyPolygon.count()) { - if(rPolyPolygon.count()) - { - implForceUniqueCopy(); - mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon); - } + implForceUniqueCopy(); + mpPolyPolygon->insert(nIndex, rPolyPolygon); } + } - void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount) + void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon) + { + if(rPolyPolygon.count()) { - OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)"); - - if(nCount) - { - implForceUniqueCopy(); - mpPolyPolygon->remove(nIndex, nCount); - } + implForceUniqueCopy(); + mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon); } + } - void B2DPolyPolygon::clear() - { - if(mpPolyPolygon->getRefCount()) - { - mpPolyPolygon->decRefCount(); - } - else - { - delete mpPolyPolygon; - } + void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount) + { + OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)"); - mpPolyPolygon = &maStaticDefaultPolyPolygon; - mpPolyPolygon->incRefCount(); + if(nCount) + { + implForceUniqueCopy(); + mpPolyPolygon->remove(nIndex, nCount); } + } - sal_Bool B2DPolyPolygon::isClosed() const + void B2DPolyPolygon::clear() + { + if(mpPolyPolygon->getRefCount()) + { + mpPolyPolygon->decRefCount(); + } + else { - sal_Bool bRetval(sal_True); + delete mpPolyPolygon; + } - // PolyPOlygon is closed when all contained Polygons are closed or - // no Polygon exists. - for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++) - { - if(!(mpPolyPolygon->getB2DPolygon(a)).isClosed()) - { - bRetval = sal_False; - } - } + mpPolyPolygon = &maStaticDefaultPolyPolygon; + mpPolyPolygon->incRefCount(); + } - return bRetval; - } + sal_Bool B2DPolyPolygon::isClosed() const + { + sal_Bool bRetval(sal_True); - void B2DPolyPolygon::setClosed(sal_Bool bNew) + // PolyPOlygon is closed when all contained Polygons are closed or + // no Polygon exists. + for(sal_uInt32 a(0L); bRetval && a < mpPolyPolygon->count(); a++) { - if(bNew != isClosed()) + if(!(mpPolyPolygon->getB2DPolygon(a)).isClosed()) { - implForceUniqueCopy(); - mpPolyPolygon->setClosed(bNew); + bRetval = sal_False; } } - void B2DPolyPolygon::flip() + return bRetval; + } + + void B2DPolyPolygon::setClosed(sal_Bool bNew) + { + if(bNew != isClosed()) { implForceUniqueCopy(); - mpPolyPolygon->flip(); + mpPolyPolygon->setClosed(bNew); } + } - sal_Bool B2DPolyPolygon::hasDoublePoints() const - { - sal_Bool bRetval(sal_False); - - for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++) - { - if((mpPolyPolygon->getB2DPolygon(a)).hasDoublePoints()) - { - bRetval = sal_True; - } - } + void B2DPolyPolygon::flip() + { + implForceUniqueCopy(); + mpPolyPolygon->flip(); + } - return bRetval; - } + sal_Bool B2DPolyPolygon::hasDoublePoints() const + { + sal_Bool bRetval(sal_False); - void B2DPolyPolygon::removeDoublePoints() + for(sal_uInt32 a(0L); !bRetval && a < mpPolyPolygon->count(); a++) { - if(hasDoublePoints()) + if((mpPolyPolygon->getB2DPolygon(a)).hasDoublePoints()) { - implForceUniqueCopy(); - mpPolyPolygon->removeDoublePoints(); + bRetval = sal_True; } } - void B2DPolyPolygon::transform(const ::basegfx::matrix::B2DHomMatrix& rMatrix) + return bRetval; + } + + void B2DPolyPolygon::removeDoublePoints() + { + if(hasDoublePoints()) { implForceUniqueCopy(); - mpPolyPolygon->transform(rMatrix); + mpPolyPolygon->removeDoublePoints(); } - } // end of namespace polygon + } + + void B2DPolyPolygon::transform(const ::basegfx::B2DHomMatrix& rMatrix) + { + implForceUniqueCopy(); + mpPolyPolygon->transform(rMatrix); + } } // end of namespace basegfx // eof |