Kaydet (Commit) 46662428 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Convert graphic::Primitive2DTools to new style

Change-Id: I9719b43dbf98cfca29638f54cc907e48c7ad28b7
üst 6e0d0934
......@@ -189,6 +189,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/graphic,\
GraphicObject \
GraphicProvider \
Primitive2DTools \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/inspection,\
DefaultHelpProvider \
......@@ -938,7 +939,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/graphic
GraphicRasterizer \
GraphicRendererVCL \
MediaProperties \
Primitive2DTools \
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/i18n,\
ChapterCollator \
......
......@@ -27,13 +27,7 @@ module com { module sun { module star { module graphic
/** Service that describes the necessary interfaces and properties
for tooling involved with XPrimitive2D interfaces
*/
service Primitive2DTools
{
/** Interface to render B2DPrimitives to a XBitmap
*/
interface ::com::sun::star::graphic::XPrimitive2DRenderer;
};
service Primitive2DTools : XPrimitive2DRenderer;
} ; } ; } ; } ;
......
......@@ -30,7 +30,7 @@
#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/graphic/XPrimitive2DRenderer.hpp>
#include <com/sun/star/graphic/Primitive2DTools.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/uno/Reference.h>
......@@ -218,44 +218,39 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid
// UNO dance to render from drawinglayer
// ---------------------------------------------------------------------
uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
const OUString aServiceName("com.sun.star.graphic.Primitive2DTools");
uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
try
{
const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer(
xFactory->createInstance(aServiceName),
uno::UNO_QUERY_THROW);
if(xPrimitive2DRenderer.is())
const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer =
graphic::Primitive2DTools::create( xContext );
// cancel out rasterize's mm2pixel conversion
// see fFactor100th_mmToInch in
// drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
const double fFakeDPI=2.54 * 1000.0;
geometry::RealRectangle2D aRealRect(
0, 0,
nWidth, nWidth / fAspectRatio);
const uno::Reference< rendering::XBitmap > xBitmap(
xPrimitive2DRenderer->rasterize(
drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1),
uno::Sequence< beans::PropertyValue >(),
fFakeDPI,
fFakeDPI,
aRealRect,
500000));
if(xBitmap.is())
{
// cancel out rasterize's mm2pixel conversion
// see fFactor100th_mmToInch in
// drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
const double fFakeDPI=2.54 * 1000.0;
geometry::RealRectangle2D aRealRect(
0, 0,
nWidth, nWidth / fAspectRatio);
const uno::Reference< rendering::XBitmap > xBitmap(
xPrimitive2DRenderer->rasterize(
drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1),
uno::Sequence< beans::PropertyValue >(),
fFakeDPI,
fFakeDPI,
aRealRect,
500000));
if(xBitmap.is())
{
const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
if(xIntBmp.is())
{
rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
return true;
}
if(xIntBmp.is())
{
rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
return true;
}
}
}
......
......@@ -22,7 +22,7 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/graphic/XSvgParser.hpp>
#include <com/sun/star/graphic/XPrimitive2DRenderer.hpp>
#include <com/sun/star/graphic/Primitive2DTools.hpp>
#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
#include <vcl/canvastools.hxx>
#include <comphelper/seqstream.hxx>
......@@ -46,43 +46,39 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
{
// create replacement graphic from maSequence
// create XPrimitive2DRenderer
uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
const OUString aServiceName("com.sun.star.graphic.Primitive2DTools");
uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
try
{
const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer(xFactory->createInstance(aServiceName), uno::UNO_QUERY_THROW);
const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer = graphic::Primitive2DTools::create(xContext);
if(xPrimitive2DRenderer.is())
uno::Sequence< beans::PropertyValue > aViewParameters;
geometry::RealRectangle2D aRealRect;
aRealRect.X1 = rTargetRange.getMinX();
aRealRect.Y1 = rTargetRange.getMinY();
aRealRect.X2 = rTargetRange.getMaxX();
aRealRect.Y2 = rTargetRange.getMaxY();
// get system DPI
const Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MAP_INCH));
const uno::Reference< rendering::XBitmap > xBitmap(
xPrimitive2DRenderer->rasterize(
rSequence,
aViewParameters,
aDPI.getWidth(),
aDPI.getHeight(),
aRealRect,
nMaximumQuadraticPixels));
if(xBitmap.is())
{
uno::Sequence< beans::PropertyValue > aViewParameters;
geometry::RealRectangle2D aRealRect;
aRealRect.X1 = rTargetRange.getMinX();
aRealRect.Y1 = rTargetRange.getMinY();
aRealRect.X2 = rTargetRange.getMaxX();
aRealRect.Y2 = rTargetRange.getMaxY();
// get system DPI
const Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MAP_INCH));
const uno::Reference< rendering::XBitmap > xBitmap(
xPrimitive2DRenderer->rasterize(
rSequence,
aViewParameters,
aDPI.getWidth(),
aDPI.getHeight(),
aRealRect,
nMaximumQuadraticPixels));
if(xBitmap.is())
{
const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
if(xIntBmp.is())
{
aRetval = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
}
if(xIntBmp.is())
{
aRetval = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment