summaryrefslogtreecommitdiff
path: root/canvas/source/tools/parametricpolypolygon.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'canvas/source/tools/parametricpolypolygon.cxx')
-rw-r--r--canvas/source/tools/parametricpolypolygon.cxx69
1 files changed, 30 insertions, 39 deletions
diff --git a/canvas/source/tools/parametricpolypolygon.cxx b/canvas/source/tools/parametricpolypolygon.cxx
index a0a9a7880219..cb948e095277 100644
--- a/canvas/source/tools/parametricpolypolygon.cxx
+++ b/canvas/source/tools/parametricpolypolygon.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <parametricpolypolygon.hxx>
+#include <utility>
using namespace ::com::sun::star;
@@ -34,28 +35,24 @@ namespace canvas
{
uno::Sequence<OUString> ParametricPolyPolygon::getAvailableServiceNames()
{
- return {"LinearGradient",
- "EllipticalGradient",
- "RectangularGradient"};
+ return {u"LinearGradient"_ustr,
+ u"EllipticalGradient"_ustr,
+ u"RectangularGradient"_ustr};
}
- ParametricPolyPolygon* ParametricPolyPolygon::create(
+ rtl::Reference<ParametricPolyPolygon> ParametricPolyPolygon::create(
const uno::Reference< rendering::XGraphicDevice >& rDevice,
- const OUString& rServiceName,
+ std::u16string_view rServiceName,
const uno::Sequence< uno::Any >& rArgs )
{
- uno::Sequence< uno::Sequence< double > > colorSequence(2);
- uno::Sequence< double > colorStops(2);
double fAspectRatio=1.0;
// defaults
- uno::Sequence< rendering::RGBColor > rgbColors(1);
- rgbColors[0] = rendering::RGBColor(0,0,0);
- colorSequence[0] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors);
- rgbColors[0] = rendering::RGBColor(1,1,1);
- colorSequence[1] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors);
- colorStops[0] = 0;
- colorStops[1] = 1;
+ uno::Sequence< uno::Sequence< double > > colorSequence{
+ rDevice->getDeviceColorSpace()->convertFromRGB({ rendering::RGBColor(0,0,0) }),
+ rDevice->getDeviceColorSpace()->convertFromRGB({ rendering::RGBColor(1,1,1) })
+ };
+ uno::Sequence< double > colorStops{ 0, 1 };
// extract args
for( const uno::Any& rArg : rArgs )
@@ -78,31 +75,31 @@ namespace canvas
}
}
- if ( rServiceName == "LinearGradient" )
+ if ( rServiceName == u"LinearGradient" )
{
return createLinearHorizontalGradient(rDevice, colorSequence, colorStops);
}
- else if ( rServiceName == "EllipticalGradient" )
+ else if ( rServiceName == u"EllipticalGradient" )
{
return createEllipticalGradient(rDevice, colorSequence, colorStops, fAspectRatio);
}
- else if ( rServiceName == "RectangularGradient" )
+ else if ( rServiceName == u"RectangularGradient" )
{
return createRectangularGradient(rDevice, colorSequence, colorStops, fAspectRatio);
}
- else if ( rServiceName == "VerticalLineHatch" )
+ else if ( rServiceName == u"VerticalLineHatch" )
{
// TODO: NYI
}
- else if ( rServiceName == "OrthogonalLinesHatch" )
+ else if ( rServiceName == u"OrthogonalLinesHatch" )
{
// TODO: NYI
}
- else if ( rServiceName == "ThreeCrossingLinesHatch" )
+ else if ( rServiceName == u"ThreeCrossingLinesHatch" )
{
// TODO: NYI
}
- else if ( rServiceName == "FourCrossingLinesHatch" )
+ else if ( rServiceName == u"FourCrossingLinesHatch" )
{
// TODO: NYI
}
@@ -110,7 +107,7 @@ namespace canvas
return nullptr;
}
- ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient(
+ rtl::Reference<ParametricPolyPolygon> ParametricPolyPolygon::createLinearHorizontalGradient(
const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops )
@@ -120,7 +117,7 @@ namespace canvas
return new ParametricPolyPolygon( rDevice, GradientType::Linear, colors, stops );
}
- ParametricPolyPolygon* ParametricPolyPolygon::createEllipticalGradient(
+ rtl::Reference<ParametricPolyPolygon> ParametricPolyPolygon::createEllipticalGradient(
const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops,
@@ -136,7 +133,7 @@ namespace canvas
colors, stops, fAspectRatio );
}
- ParametricPolyPolygon* ParametricPolyPolygon::createRectangularGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice,
+ rtl::Reference<ParametricPolyPolygon> ParametricPolyPolygon::createRectangularGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice,
const uno::Sequence< uno::Sequence< double > >& colors,
const uno::Sequence< double >& stops,
double fAspectRatio )
@@ -151,10 +148,8 @@ namespace canvas
colors, stops, fAspectRatio );
}
- void SAL_CALL ParametricPolyPolygon::disposing()
+ void ParametricPolyPolygon::disposing(std::unique_lock<std::mutex>&)
{
- ::osl::MutexGuard aGuard( m_aMutex );
-
mxDevice.clear();
}
@@ -178,7 +173,7 @@ namespace canvas
uno::Reference< rendering::XColorSpace > SAL_CALL ParametricPolyPolygon::getColorSpace()
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
return mxDevice.is() ? mxDevice->getDeviceColorSpace() : uno::Reference< rendering::XColorSpace >();
}
@@ -186,7 +181,7 @@ namespace canvas
OUString SAL_CALL ParametricPolyPolygon::getImplementationName( )
{
- return "Canvas::ParametricPolyPolygon";
+ return u"Canvas::ParametricPolyPolygon"_ustr;
}
sal_Bool SAL_CALL ParametricPolyPolygon::supportsService( const OUString& ServiceName )
@@ -196,21 +191,20 @@ namespace canvas
uno::Sequence< OUString > SAL_CALL ParametricPolyPolygon::getSupportedServiceNames( )
{
- return { "com.sun.star.rendering.ParametricPolyPolygon" };
+ return { u"com.sun.star.rendering.ParametricPolyPolygon"_ustr };
}
ParametricPolyPolygon::~ParametricPolyPolygon()
{
}
- ParametricPolyPolygon::ParametricPolyPolygon( const uno::Reference< rendering::XGraphicDevice >& rDevice,
+ ParametricPolyPolygon::ParametricPolyPolygon( uno::Reference< rendering::XGraphicDevice > xDevice,
const ::basegfx::B2DPolygon& rGradientPoly,
GradientType eType,
const uno::Sequence< uno::Sequence< double > >& rColors,
const uno::Sequence< double >& rStops,
double nAspectRatio ) :
- ParametricPolyPolygon_Base( m_aMutex ),
- mxDevice( rDevice ),
+ mxDevice(std::move( xDevice )),
maValues( rGradientPoly,
rColors,
rStops,
@@ -219,12 +213,11 @@ namespace canvas
{
}
- ParametricPolyPolygon::ParametricPolyPolygon( const uno::Reference< rendering::XGraphicDevice >& rDevice,
+ ParametricPolyPolygon::ParametricPolyPolygon( uno::Reference< rendering::XGraphicDevice > xDevice,
GradientType eType,
const uno::Sequence< uno::Sequence< double > >& rColors,
const uno::Sequence< double >& rStops ) :
- ParametricPolyPolygon_Base( m_aMutex ),
- mxDevice( rDevice ),
+ mxDevice(std::move( xDevice )),
maValues( ::basegfx::B2DPolygon(),
rColors,
rStops,
@@ -233,10 +226,8 @@ namespace canvas
{
}
- ParametricPolyPolygon::Values ParametricPolyPolygon::getValues() const
+ const ParametricPolyPolygon::Values & ParametricPolyPolygon::getValues() const
{
- ::osl::MutexGuard aGuard( m_aMutex );
-
return maValues;
}