diff options
Diffstat (limited to 'drawinglayer')
3 files changed, 58 insertions, 15 deletions
diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx index ffb8fcff165e..e7156bdb3238 100644 --- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx @@ -55,8 +55,10 @@ #include <basegfx/utils/systemdependentdata.hxx> #include <basegfx/utils/bgradient.hxx> #include <vcl/BitmapReadAccess.hxx> -#include <officecfg/Office/Common.hxx> #include <vcl/vcllayout.hxx> +#include <officecfg/Office/Common.hxx> +#include <com/sun/star/awt/XView.hpp> +#include <com/sun/star/awt/XControl.hpp> #include <unordered_map> #include <dlfcn.h> @@ -959,6 +961,7 @@ CairoPixelProcessor2D::CairoPixelProcessor2D(const geometry::ViewInformation2D& officecfg::Office::Common::Drawinglayer::RenderDecoratedTextDirect::get()) , mnClipRecursionCount(0) , mbCairoCoordinateLimitWorkaroundActive(false) + , maXGraphics() { if (nWidthPixel <= 0 || nHeightPixel <= 0) // no size, invalid @@ -1002,6 +1005,7 @@ CairoPixelProcessor2D::CairoPixelProcessor2D(const geometry::ViewInformation2D& officecfg::Office::Common::Drawinglayer::RenderDecoratedTextDirect::get()) , mnClipRecursionCount(0) , mbCairoCoordinateLimitWorkaroundActive(false) + , maXGraphics() { // no target, nothing to initialize if (nullptr == pTarget) @@ -3881,12 +3885,44 @@ void CairoPixelProcessor2D::processControlPrimitive2D( return; } - // process recursively and use the decomposition as Bitmap - // NOTE: The VclPixelProcessor2D tries to paint it using - // UNO API and awt::XView/awt::XGraphics to directly paint the - // control. To do so would need the target OutDev which we - // want to avoid here - process(rControlPrimitive); + bool bDone(false); + + try + { + if (getXGraphics().is()) + { + // Needs to be drawn. Link new graphics and view + const uno::Reference<awt::XControl>& rXControl(rControlPrimitive.getXControl()); + uno::Reference<awt::XView> xControlView(rXControl, uno::UNO_QUERY_THROW); + const uno::Reference<awt::XGraphics> xOriginalGraphics(xControlView->getGraphics()); + xControlView->setGraphics(getXGraphics()); + + // get position + const basegfx::B2DHomMatrix aObjectToPixel( + getViewInformation2D().getObjectToViewTransformation() + * rControlPrimitive.getTransform()); + const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0)); + + xControlView->draw(basegfx::fround(aTopLeftPixel.getX()), + basegfx::fround(aTopLeftPixel.getY())); + + // restore original graphics + xControlView->setGraphics(xOriginalGraphics); + bDone = true; + } + } + catch (const uno::Exception&) + { + // #i116763# removing since there is a good alternative when the xControlView + // is not found and it is allowed to happen + // DBG_UNHANDLED_EXCEPTION(); + } + + if (!bDone) + { + // process recursively and use the decomposition as Bitmap + process(rControlPrimitive); + } } void CairoPixelProcessor2D::evaluateCairoCoordinateLimitWorkaround() diff --git a/drawinglayer/source/processor2d/processor2dtools.cxx b/drawinglayer/source/processor2d/processor2dtools.cxx index f87bffea6b21..b4a453a7edec 100644 --- a/drawinglayer/source/processor2d/processor2dtools.cxx +++ b/drawinglayer/source/processor2d/processor2dtools.cxx @@ -30,6 +30,8 @@ #include <officecfg/Office/Common.hxx> #endif +using namespace com::sun::star; + namespace drawinglayer::processor2d { std::unique_ptr<BaseProcessor2D> createPixelProcessor2DFromScratch( @@ -125,7 +127,14 @@ std::unique_ptr<BaseProcessor2D> createPixelProcessor2DFromOutputDevice( rTargetOutDev.GetOutputWidthPixel(), rTargetOutDev.GetOutputHeightPixel())); if (aRetval->valid()) + { + // if we construct a CairoPixelProcessor2D from OutputDevice, + // additionally set the XGraphics that can be obtained from + // there. It may be used e.g. to render FormControls directly + aRetval->setXGraphics(rTargetOutDev.CreateUnoGraphics()); + return aRetval; + } } #endif diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 79eba7bb0024..98182a43a758 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -657,21 +657,19 @@ void VclPixelProcessor2D::processControlPrimitive2D( return; } - // get awt::XControl from control primitive - const uno::Reference<awt::XControl>& rXControl(rControlPrimitive.getXControl()); bool bDone(false); try { - // remember old graphics and create new - uno::Reference<awt::XView> xControlView(rXControl, uno::UNO_QUERY_THROW); - const uno::Reference<awt::XGraphics> xOriginalGraphics(xControlView->getGraphics()); - const uno::Reference<awt::XGraphics> xNewGraphics(mpOutputDevice->CreateUnoGraphics()); + const uno::Reference<awt::XGraphics> xTargetGraphics(mpOutputDevice->CreateUnoGraphics()); - if (xNewGraphics.is()) + if (xTargetGraphics.is()) { // Needs to be drawn. Link new graphics and view - xControlView->setGraphics(xNewGraphics); + const uno::Reference<awt::XControl>& rXControl(rControlPrimitive.getXControl()); + uno::Reference<awt::XView> xControlView(rXControl, uno::UNO_QUERY_THROW); + const uno::Reference<awt::XGraphics> xOriginalGraphics(xControlView->getGraphics()); + xControlView->setGraphics(xTargetGraphics); // get position const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation |