Prepare for removal of non-const operator[] from Sequence in canvas

Change-Id: Ifb96e496b0994b5fc66975b7aea0a60bcb4a3a03
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124345
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2021-10-29 06:50:51 +02:00
parent f6aef99057
commit 1a58461bfa
8 changed files with 40 additions and 58 deletions
+3 -9
View File
@@ -97,9 +97,7 @@ namespace dxcanvas
HBITMAP aHBmp;
mpBitmap->getBitmap()->GetHBITMAP(Gdiplus::Color(), &aHBmp );
uno::Sequence< uno::Any > args(1);
args[0] <<= reinterpret_cast<sal_Int64>(aHBmp);
uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(aHBmp)) };
aRes <<= args;
}
else
@@ -153,9 +151,7 @@ namespace dxcanvas
pGDIPlusBitmap->UnlockBits( &aBmpData );
uno::Sequence< uno::Any > args(1);
args[0] <<= reinterpret_cast<sal_Int64>(hBmpBitmap);
uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(hBmpBitmap)) };
aRes <<= args;
}
}
@@ -230,9 +226,7 @@ namespace dxcanvas
aSize.getY(), pAlphaBits.get(),
reinterpret_cast<PBITMAPINFO>(&aDIB), DIB_RGB_COLORS );
uno::Sequence< uno::Any > args(1);
args[0] <<= reinterpret_cast<sal_Int64>(hBmpBitmap);
uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(hBmpBitmap)) };
aRes <<= args;
}
}
+3 -7
View File
@@ -45,9 +45,7 @@ namespace dxcanvas
{
try
{
uno::Sequence< OUString > aName { "DeviceDenylist" };
uno::Sequence< uno::Any > aProps( GetProperties( aName ));
uno::Sequence< uno::Any > aProps( GetProperties( { "DeviceDenylist" } ));
uno::Sequence< sal_Int32 > aValues;
if( aProps.getLength() > 0 &&
@@ -70,13 +68,11 @@ namespace dxcanvas
}
}
aName[0] = "DenylistCurrentDevice";
aProps = GetProperties( aName );
aProps = GetProperties( { "DenylistCurrentDevice" } );
if( aProps.getLength() > 0 )
aProps[0] >>= mbDenylistCurrentDevice;
aName[0] = "MaxTextureSize";
aProps = GetProperties( aName );
aProps = GetProperties( { "MaxTextureSize" } );
if( aProps.getLength() > 0 )
maMaxTextureSize = aProps[0].get<sal_Int32>();
else
+2 -4
View File
@@ -185,13 +185,11 @@ CanvasFactory::CanvasFactory( Reference<XComponentContext> const & xContext ) :
{
// Ugh. Looks like configuration is borked. Fake minimal
// setup.
Sequence<OUString> aServices { "com.sun.star.comp.rendering.Canvas.VCL" };
m_aAvailableImplementations.emplace_back(OUString("com.sun.star.rendering.Canvas"),
aServices );
Sequence<OUString>{ "com.sun.star.comp.rendering.Canvas.VCL" } );
aServices[0] = "com.sun.star.comp.rendering.SpriteCanvas.VCL";
m_aAvailableImplementations.emplace_back(OUString("com.sun.star.rendering.SpriteCanvas"),
aServices );
Sequence<OUString>{ "com.sun.star.comp.rendering.SpriteCanvas.VCL" } );
}
}
+13 -17
View File
@@ -45,29 +45,25 @@ namespace
uno::Sequence< double > color2Sequence( sal_Int32 nColor )
{
// TODO(F3): Color management
uno::Sequence< double > aRes( 4 );
aRes[0] = static_cast<sal_uInt8>( (nColor&0xFF000000U) >> 24U ) / 255.0;
aRes[1] = static_cast<sal_uInt8>( (nColor&0x00FF0000U) >> 16U ) / 255.0;
aRes[2] = static_cast<sal_uInt8>( (nColor&0x0000FF00U) >> 8U ) / 255.0;
aRes[3] = static_cast<sal_uInt8>( (nColor&0x000000FFU) ) / 255.0;
uno::Sequence< double > aRes{
static_cast<sal_uInt8>( (nColor&0xFF000000U) >> 24U ) / 255.0,
static_cast<sal_uInt8>( (nColor&0x00FF0000U) >> 16U ) / 255.0,
static_cast<sal_uInt8>( (nColor&0x0000FF00U) >> 8U ) / 255.0,
static_cast<sal_uInt8>( (nColor&0x000000FFU) ) / 255.0
};
return aRes;
}
uno::Reference< rendering::XPolyPolygon2D > rect2Poly( uno::Reference<rendering::XGraphicDevice> const& xDevice,
geometry::RealRectangle2D const& rRect )
{
uno::Sequence< geometry::RealPoint2D > rectSequence( 4 );
geometry::RealPoint2D* pOutput = rectSequence.getArray();
pOutput[0] = geometry::RealPoint2D( rRect.X1, rRect.Y1 );
pOutput[1] = geometry::RealPoint2D( rRect.X2, rRect.Y1 );
pOutput[2] = geometry::RealPoint2D( rRect.X2, rRect.Y2 );
pOutput[3] = geometry::RealPoint2D( rRect.X1, rRect.Y2 );
uno::Sequence< uno::Sequence< geometry::RealPoint2D > > sequenceSequence( 1 );
sequenceSequence[0] = rectSequence;
uno::Sequence< geometry::RealPoint2D > rectSequence{
geometry::RealPoint2D( rRect.X1, rRect.Y1 ),
geometry::RealPoint2D( rRect.X2, rRect.Y1 ),
geometry::RealPoint2D( rRect.X2, rRect.Y2 ),
geometry::RealPoint2D( rRect.X1, rRect.Y2 )
};
uno::Sequence< uno::Sequence< geometry::RealPoint2D > > sequenceSequence{ rectSequence };
uno::Reference< rendering::XPolyPolygon2D > xRes =
xDevice->createCompatibleLinePolyPolygon( sequenceSequence );
if( xRes.is() )
+2 -4
View File
@@ -1092,10 +1092,8 @@ namespace canvas::tools
uno::Reference< beans::XPropertySet > xPropSet( xDevice,
uno::UNO_QUERY_THROW );
o_rxParams.realloc( 2 );
o_rxParams[ 0 ] <<= xServiceInfo->getImplementationName();
o_rxParams[ 1 ] = xPropSet->getPropertyValue( "DeviceHandle" );
o_rxParams = { uno::Any(xServiceInfo->getImplementationName()),
xPropSet->getPropertyValue( "DeviceHandle" ) };
}
catch( const uno::Exception& )
{
@@ -44,18 +44,14 @@ namespace canvas
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 )
+2 -1
View File
@@ -178,10 +178,11 @@ namespace vclcanvas
aMetricVector))
{
aBoundingBoxes.realloc(aMetricVector.size());
auto pBoundingBoxes = aBoundingBoxes.getArray();
sal_Int32 nIndex (0);
for (auto const& metric : aMetricVector)
{
aBoundingBoxes[nIndex++] = geometry::RealRectangle2D(
pBoundingBoxes[nIndex++] = geometry::RealRectangle2D(
metric.Left(),
metric.Top(),
metric.Right(),
+10 -7
View File
@@ -211,27 +211,28 @@ class DemoRenderer
int nLength = SAL_N_ELEMENTS( hilbert );
uno::Sequence< geometry::RealPoint2D > aPoints( nLength );
auto pPoints = aPoints.getArray();
uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
aPoints[0] = geometry::RealPoint2D( anchor_x, anchor_y );
pPoints[0] = geometry::RealPoint2D( anchor_x, anchor_y );
for (int i = 0; i < nLength; i++ )
{
switch( hilbert[i] )
{
case 'u':
aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
pPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
aPoints[i].Y - SCALE );
break;
case 'd':
aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
pPoints[i+1] = geometry::RealPoint2D( aPoints[i].X,
aPoints[i].Y + SCALE );
break;
case 'l':
aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X - SCALE,
pPoints[i+1] = geometry::RealPoint2D( aPoints[i].X - SCALE,
aPoints[i].Y );
break;
case 'r':
aPoints[i+1] = geometry::RealPoint2D( aPoints[i].X + SCALE,
pPoints[i+1] = geometry::RealPoint2D( aPoints[i].X + SCALE,
aPoints[i].Y );
break;
}
@@ -385,10 +386,11 @@ class DemoRenderer
//hacky hack hack
uno::Sequence< geometry::RealBezierSegment2D > aBeziers (num_curves);
auto pBeziers = aBeziers.getArray();
uno::Reference< rendering::XBezierPolyPolygon2D > xPoly;
for (int i= 0; i < num_curves; i++)
aBeziers[i]= geometry::RealBezierSegment2D( r * cos(i*2*M_PI/num_curves), //Px
pBeziers[i]= geometry::RealBezierSegment2D( r * cos(i*2*M_PI/num_curves), //Px
r * sin(i*2*M_PI/num_curves), //py
r * 2 * cos((i*2*M_PI + 2*M_PI)/num_curves), //C1x
r * 2 * sin((i*2*M_PI + 2*M_PI)/num_curves), //C1y
@@ -477,11 +479,12 @@ class DemoRenderer
{
//hacky hack hack
uno::Sequence< geometry::RealPoint2D > aPoints (sides);
auto pPoints = aPoints.getArray();
uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
for (int i= 0; i < sides; i++)
{
aPoints[i]= geometry::RealPoint2D( centerx + r * cos(i*2 * M_PI/sides),
pPoints[i]= geometry::RealPoint2D( centerx + r * cos(i*2 * M_PI/sides),
centery + r * sin(i*2 * M_PI/sides));
}
uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys { aPoints };