summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-03 17:23:20 +0200
committerNoel Grandin <noel@peralex.com>2013-05-06 11:27:50 +0200
commit46662428b2b17043e1d09c4107e7a5c0cf490b86 (patch)
tree1bc8f69d26e2a401d6f8f784e4c4498416d22c18
parent6e0d0934d0cbb74bb5a4fbf05b4448832f6d4722 (diff)
fdo#46808, Convert graphic::Primitive2DTools to new style
Change-Id: I9719b43dbf98cfca29638f54cc907e48c7ad28b7
-rw-r--r--offapi/UnoApi_offapi.mk2
-rw-r--r--offapi/com/sun/star/graphic/Primitive2DTools.idl8
-rw-r--r--sfx2/source/appl/appmisc.cxx63
-rw-r--r--vcl/source/gdi/svgdata.cxx60
4 files changed, 59 insertions, 74 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 1e5b21125ef9..c4261384f660 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -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 \
diff --git a/offapi/com/sun/star/graphic/Primitive2DTools.idl b/offapi/com/sun/star/graphic/Primitive2DTools.idl
index 75209fd5e549..a99b460186ec 100644
--- a/offapi/com/sun/star/graphic/Primitive2DTools.idl
+++ b/offapi/com/sun/star/graphic/Primitive2DTools.idl
@@ -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;
} ; } ; } ; } ;
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index f6d1597148a9..06f18fbe1c13 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -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;
}
}
}
diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx
index e175edafcbb7..d5f527c08184 100644
--- a/vcl/source/gdi/svgdata.cxx
+++ b/vcl/source/gdi/svgdata.cxx
@@ -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);
}
}
}