summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-10 11:08:09 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-01-10 14:25:46 +0100
commit50bc5c2da75de1dec8e467fc4126687d3ffbb3fc (patch)
tree0b82e89af66f8c56aa3f74fc9cd234fce2f66b13 /basegfx/source
parent1692034d53ce28b2c5d1c63ab429232a92b2f861 (diff)
Replace uses of rtl/instance.hxx with plain local static vars in basegfx
Change-Id: I13fbecf59e99547bbe85124dc9aa2777eef015d7 Reviewed-on: https://gerrit.libreoffice.org/66072 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx82
-rw-r--r--basegfx/source/polygon/b3dpolygon.cxx15
-rw-r--r--basegfx/source/polygon/b3dpolypolygon.cxx15
-rw-r--r--basegfx/source/polygon/b3dpolypolygontools.cxx35
-rw-r--r--basegfx/source/tuple/b2dtuple.cxx6
-rw-r--r--basegfx/source/tuple/b3dtuple.cxx6
6 files changed, 56 insertions, 103 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index f005f2519026..5b00b312587d 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -21,7 +21,6 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <osl/diagnose.h>
#include <rtl/math.hxx>
-#include <rtl/instance.hxx>
#include <sal/log.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
@@ -1637,13 +1636,9 @@ namespace basegfx
return aPolygon;
}
- namespace
+ B2DPolygon const & createUnitPolygon()
{
- struct theUnitPolygon :
- public rtl::StaticWithInit<B2DPolygon, theUnitPolygon>
- {
- B2DPolygon operator () ()
- {
+ static auto const singleton = [] {
B2DPolygon aPolygon {
{ 0.0, 0.0 },
{ 1.0, 0.0 },
@@ -1655,13 +1650,8 @@ namespace basegfx
aPolygon.setClosed( true );
return aPolygon;
- }
- };
- }
-
- B2DPolygon const & createUnitPolygon()
- {
- return theUnitPolygon::get();
+ }();
+ return singleton;
}
B2DPolygon createPolygonFromCircle( const B2DPoint& rCenter, double fRadius )
@@ -1703,13 +1693,9 @@ namespace basegfx
return aUnitCircle;
}
- namespace
+ B2DPolygon const & createHalfUnitCircle()
{
- struct theUnitHalfCircle :
- public rtl::StaticWithInit<B2DPolygon, theUnitHalfCircle>
- {
- B2DPolygon operator()()
- {
+ static auto const singleton = [] {
B2DPolygon aUnitHalfCircle;
const double fSegmentKappa(impDistanceBezierPointToControl(F_PI2 / STEPSPERQUARTER));
const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(F_PI2 / STEPSPERQUARTER));
@@ -1727,40 +1713,8 @@ namespace basegfx
aForward *= aRotateMatrix;
}
return aUnitHalfCircle;
- }
- };
- }
-
- B2DPolygon const & createHalfUnitCircle()
- {
- return theUnitHalfCircle::get();
- }
-
- namespace
- {
- struct theUnitCircleStartQuadrantOne :
- public rtl::StaticWithInit<B2DPolygon, theUnitCircleStartQuadrantOne>
- {
- B2DPolygon operator()() { return impCreateUnitCircle(1); }
- };
-
- struct theUnitCircleStartQuadrantTwo :
- public rtl::StaticWithInit<B2DPolygon, theUnitCircleStartQuadrantTwo>
- {
- B2DPolygon operator()() { return impCreateUnitCircle(2); }
- };
-
- struct theUnitCircleStartQuadrantThree :
- public rtl::StaticWithInit<B2DPolygon, theUnitCircleStartQuadrantThree>
- {
- B2DPolygon operator()() { return impCreateUnitCircle(3); }
- };
-
- struct theUnitCircleStartQuadrantZero :
- public rtl::StaticWithInit<B2DPolygon, theUnitCircleStartQuadrantZero>
- {
- B2DPolygon operator()() { return impCreateUnitCircle(0); }
- };
+ }();
+ return singleton;
}
B2DPolygon const & createPolygonFromUnitCircle(sal_uInt32 nStartQuadrant)
@@ -1768,16 +1722,28 @@ namespace basegfx
switch(nStartQuadrant % 4)
{
case 1 :
- return theUnitCircleStartQuadrantOne::get();
+ {
+ static auto const singleton = impCreateUnitCircle(1);
+ return singleton;
+ }
case 2 :
- return theUnitCircleStartQuadrantTwo::get();
+ {
+ static auto const singleton = impCreateUnitCircle(2);
+ return singleton;
+ }
case 3 :
- return theUnitCircleStartQuadrantThree::get();
+ {
+ static auto const singleton = impCreateUnitCircle(3);
+ return singleton;
+ }
default : // case 0 :
- return theUnitCircleStartQuadrantZero::get();
+ {
+ static auto const singleton = impCreateUnitCircle(0);
+ return singleton;
+ }
}
}
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index 1c95fd5053f4..41f5add1f434 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -21,7 +21,6 @@
#include <basegfx/polygon/b3dpolygon.hxx>
#include <basegfx/point/b3dpoint.hxx>
#include <basegfx/matrix/b3dhommatrix.hxx>
-#include <rtl/instance.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/color/bcolor.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
@@ -1397,11 +1396,17 @@ public:
namespace basegfx
{
- namespace { struct DefaultPolygon : public rtl::Static< B3DPolygon::ImplType,
- DefaultPolygon > {}; }
+ namespace {
+
+ B3DPolygon::ImplType const & getDefaultPolygon() {
+ static B3DPolygon::ImplType const singleton;
+ return singleton;
+ }
+
+ }
B3DPolygon::B3DPolygon() :
- mpPolygon(DefaultPolygon::get())
+ mpPolygon(getDefaultPolygon())
{
}
@@ -1581,7 +1586,7 @@ namespace basegfx
void B3DPolygon::clear()
{
- mpPolygon = DefaultPolygon::get();
+ mpPolygon = getDefaultPolygon();
}
bool B3DPolygon::isClosed() const
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx
index 7cb977065e0f..5f7709987e57 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -20,7 +20,6 @@
#include <osl/diagnose.h>
#include <basegfx/polygon/b3dpolypolygon.hxx>
#include <basegfx/polygon/b3dpolygon.hxx>
-#include <rtl/instance.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <functional>
@@ -188,11 +187,17 @@ public:
namespace basegfx
{
- namespace { struct DefaultPolyPolygon : public rtl::Static<B3DPolyPolygon::ImplType,
- DefaultPolyPolygon> {}; }
+ namespace {
+
+ B3DPolyPolygon::ImplType const & getDefaultPolyPolygon() {
+ static B3DPolyPolygon::ImplType const singleton;
+ return singleton;
+ }
+
+ }
B3DPolyPolygon::B3DPolyPolygon() :
- mpPolyPolygon(DefaultPolyPolygon::get())
+ mpPolyPolygon(getDefaultPolyPolygon())
{
}
@@ -335,7 +340,7 @@ namespace basegfx
void B3DPolyPolygon::clear()
{
- mpPolyPolygon = DefaultPolyPolygon::get();
+ mpPolyPolygon = getDefaultPolyPolygon();
}
void B3DPolyPolygon::flip()
diff --git a/basegfx/source/polygon/b3dpolypolygontools.cxx b/basegfx/source/polygon/b3dpolypolygontools.cxx
index abd7340d4b69..c76e5d7dd134 100644
--- a/basegfx/source/polygon/b3dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolypolygontools.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <rtl/instance.hxx>
#include <osl/diagnose.h>
#include <basegfx/polygon/b3dpolypolygontools.hxx>
#include <basegfx/range/b3drange.hxx>
@@ -53,13 +52,9 @@ namespace basegfx
return aRetval;
}
- namespace
+ B3DPolyPolygon const & createUnitCubePolyPolygon()
{
- struct theUnitCubePolyPolygon : public rtl::StaticWithInit<B3DPolyPolygon,
- theUnitCubePolyPolygon>
- {
- B3DPolyPolygon operator()()
- {
+ static auto const singleton = [] {
B3DPolyPolygon aRetval;
B3DPolygon aTemp;
aTemp.append(B3DPoint(0.0, 0.0, 1.0));
@@ -97,22 +92,13 @@ namespace basegfx
aTemp.append(B3DPoint(1.0, 0.0, 1.0));
aRetval.append(aTemp);
return aRetval;
- }
- };
- }
-
- B3DPolyPolygon const & createUnitCubePolyPolygon()
- {
- return theUnitCubePolyPolygon::get();
+ }();
+ return singleton;
}
- namespace
+ B3DPolyPolygon const & createUnitCubeFillPolyPolygon()
{
- struct theUnitCubeFillPolyPolygon : public rtl::StaticWithInit<B3DPolyPolygon,
- theUnitCubeFillPolyPolygon>
- {
- B3DPolyPolygon operator()()
- {
+ static auto const singleton = [] {
B3DPolyPolygon aRetval;
B3DPolygon aTemp;
@@ -179,13 +165,8 @@ namespace basegfx
aTemp.setClosed(true);
aRetval.append(aTemp);
return aRetval;
- }
- };
- }
-
- B3DPolyPolygon const & createUnitCubeFillPolyPolygon()
- {
- return theUnitCubeFillPolyPolygon::get();
+ }();
+ return singleton;
}
B3DPolyPolygon createCubePolyPolygonFromB3DRange( const B3DRange& rRange)
diff --git a/basegfx/source/tuple/b2dtuple.cxx b/basegfx/source/tuple/b2dtuple.cxx
index 4a107869f3da..c894639a1511 100644
--- a/basegfx/source/tuple/b2dtuple.cxx
+++ b/basegfx/source/tuple/b2dtuple.cxx
@@ -20,15 +20,13 @@
#include <basegfx/tuple/b2dtuple.hxx>
#include <basegfx/tuple/b2ituple.hxx>
#include <basegfx/numeric/ftools.hxx>
-#include <rtl/instance.hxx>
-
-namespace { struct EmptyTuple : public rtl::Static<basegfx::B2DTuple, EmptyTuple> {}; }
namespace basegfx
{
const B2DTuple& B2DTuple::getEmptyTuple()
{
- return EmptyTuple::get();
+ static B2DTuple const singleton;
+ return singleton;
}
B2DTuple::B2DTuple(const B2ITuple& rTup)
diff --git a/basegfx/source/tuple/b3dtuple.cxx b/basegfx/source/tuple/b3dtuple.cxx
index 9d20e1b38f97..73e9fd042ac4 100644
--- a/basegfx/source/tuple/b3dtuple.cxx
+++ b/basegfx/source/tuple/b3dtuple.cxx
@@ -19,15 +19,13 @@
#include <basegfx/tuple/b3dtuple.hxx>
#include <basegfx/tuple/b3ituple.hxx>
-#include <rtl/instance.hxx>
-
-namespace { struct EmptyTuple : public rtl::Static<basegfx::B3DTuple, EmptyTuple> {}; }
namespace basegfx
{
const B3DTuple& B3DTuple::getEmptyTuple()
{
- return EmptyTuple::get();
+ static B3DTuple const singleton;
+ return singleton;
}
B3ITuple fround(const B3DTuple& rTup)