From 666a90d3aadf6f97c2c95fcf60f8103d38a7e013 Mon Sep 17 00:00:00 2001 From: Armin Weiss Date: Mon, 15 Oct 2007 15:11:08 +0000 Subject: #i39532# finetuning --- .../primitive2d/controlprimitive2d.hxx | 14 +++- .../drawinglayer/processor2d/vclprocessor2d.hxx | 9 ++- .../source/primitive2d/controlprimitive2d.cxx | 25 ++++++- .../source/processor2d/vclmetafileprocessor2d.cxx | 79 ++++++++++++++++++++-- .../source/processor2d/vclpixelprocessor2d.cxx | 49 +++++++++++++- drawinglayer/source/processor2d/vclprocessor2d.cxx | 57 +++++++++++++++- 6 files changed, 217 insertions(+), 16 deletions(-) (limited to 'drawinglayer') diff --git a/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx index 985a69e7a791..069464533695 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: controlprimitive2d.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2007-03-06 12:30:46 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:10:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -88,11 +88,21 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel); + // constructor with an additional XControl as parameter to allow to hand it over at incarnation time + // if it exists. This will avoid to create a 2nd one on demand in createXControl() + // and thus double the XControls. + ControlPrimitive2D( + const basegfx::B2DHomMatrix& rTransform, + const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel, + const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& rxXControl); + // get data const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& getControlModel() const { return mxControlModel; } // mxControl access. This will on demand create the awt::XControl using createXControl() + // if it does not exist. It may already have been created or even handed over at + // incarnation const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& getXControl() const; // compare operator diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 593239caa0bd..8d51b201593f 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: aw $ $Date: 2007-09-20 09:51:21 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:10:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -71,6 +71,7 @@ namespace drawinglayer { namespace primitive2d { class PointArrayPrimitive2D; class ModifiedColorPrimitive2D; class WrongSpellPrimitive2D; + class ControlPrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -109,6 +110,10 @@ namespace drawinglayer void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate); void RenderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate); + ///////////////////////////////////////////////////////////////////////////// + // FormControl support + basegfx::B2DPoint PositionAndSizeControl(const primitive2d::ControlPrimitive2D& rControlPrimitive2D); + // as tooling, the process() implementation takes over API handling and calls this // virtual render method when the primitive implementation is BasePrimitive2D-based. virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) = 0; diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx index 76a8e9a4daaf..0d17360f6867 100644 --- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: controlprimitive2d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2007-03-06 12:34:28 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:11:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -241,6 +241,8 @@ namespace drawinglayer Primitive2DSequence ControlPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const { + // try to create a bitmap decomposition. If that fails for some reason, + // at least create a replacement decomposition. Primitive2DReference xReference(createBitmapDecomposition(rViewInformation)); if(!xReference.is()) @@ -262,6 +264,18 @@ namespace drawinglayer { } + ControlPrimitive2D::ControlPrimitive2D( + const basegfx::B2DHomMatrix& rTransform, + const uno::Reference< awt::XControlModel >& rxControlModel, + const uno::Reference< awt::XControl >& rxXControl) + : BasePrimitive2D(), + maTransform(rTransform), + mxControlModel(rxControlModel), + mxXControl(rxXControl), + maLastViewScaling() + { + } + const uno::Reference< awt::XControl >& ControlPrimitive2D::getXControl() const { if(!mxXControl.is()) @@ -274,12 +288,16 @@ namespace drawinglayer bool ControlPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { + // use base class compare operator if(BasePrimitive2D::operator==(rPrimitive)) { const ControlPrimitive2D& rCompare = (ControlPrimitive2D&)rPrimitive; if(getTransform() == rCompare.getTransform()) { + // annotation: It is not necessary to compare mxXControl since + // it's creation completely relies on mxControlModel ad just + // is there to buffer it and/or to avoid multiple creations. if(getControlModel().is() == rCompare.getControlModel().is()) { if(getControlModel().is()) @@ -301,6 +319,7 @@ namespace drawinglayer basegfx::B2DRange ControlPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const { + // simply derivate from unit range basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); aRetval.transform(getTransform()); return aRetval; @@ -308,6 +327,8 @@ namespace drawinglayer Primitive2DSequence ControlPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { + // this primitive is view-dependent related to the scaling. If scaling has changed, + // destroy existing decomposition ::osl::MutexGuard aGuard( m_aMutex ); const basegfx::B2DVector aNewScaling(rViewInformation.getViewTransformation() * basegfx::B2DVector(1.0, 1.0)); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 5f01e6eff401..6098f8c625e4 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclmetafileprocessor2d.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:11:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -184,12 +184,32 @@ #include #endif +////////////////////////////////////////////////////////////////////////////// +// for Control printing + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { namespace processor2d { + ////////////////////////////////////////////////////////////////////////////// + // UNO usings + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::awt::XView; + //using ::com::sun::star::awt::XGraphics; + //using ::com::sun::star::awt::XWindow; + //using ::com::sun::star::awt::PosSize::POSSIZE; + Rectangle VclMetafileProcessor2D::impDumpToMetaFile( const primitive2d::Primitive2DSequence& rContent, GDIMetaFile& o_rContentMetafile) @@ -446,7 +466,7 @@ namespace drawinglayer } // init static break iterator - ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > VclMetafileProcessor2D::mxBreakIterator; + Reference< ::com::sun::star::i18n::XBreakIterator > VclMetafileProcessor2D::mxBreakIterator; VclMetafileProcessor2D::VclMetafileProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev) : VclProcessor2D(rViewInformation, rOutDev), @@ -751,6 +771,7 @@ namespace drawinglayer const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate); bool bDoProcessRecursively(true); static bool bSuppressPDFExtOutDevDataSupport(false); + static bool bSuppressPrinterOutput(false); if(mpPDFExtOutDevData && !bSuppressPDFExtOutDevDataSupport && mpPDFExtOutDevData->GetIsExportFormFields()) { @@ -783,6 +804,54 @@ namespace drawinglayer } } + // printer output preparation + if(bDoProcessRecursively && !bSuppressPrinterOutput) + { + // this needs to do the same as UnoControlPrintOrPreviewContact::doPaintObject + // does ATM. This means preparePrintOrPrintPreview and paintControl + bool bIsPrintableControl(false); + + if(rControlPrimitive.getXControl().is()) + { + try + { + // find out if control is printable + Reference< XPropertySet > xModelProperties(rControlPrimitive.getXControl()->getModel(), UNO_QUERY); + Reference< XPropertySetInfo > xPropertyInfo(xModelProperties.is() + ? xModelProperties->getPropertySetInfo() + : Reference< XPropertySetInfo >()); + const ::rtl::OUString sPrintablePropertyName(RTL_CONSTASCII_USTRINGPARAM("Printable")); + + if(xPropertyInfo.is() && xPropertyInfo->hasPropertyByName(sPrintablePropertyName)) + { + OSL_VERIFY(xModelProperties->getPropertyValue(sPrintablePropertyName) >>= bIsPrintableControl); + } + } + catch(const Exception&) + { + OSL_ENSURE(false, "VclMetafileProcessor2D: No access to printable flag of Control, caught an exception!"); + } + } + + if(bIsPrintableControl) + { + try + { + // update position and size + const basegfx::B2DPoint aTopLeftPixel(PositionAndSizeControl(rControlPrimitive)); + + // output to given device + Reference< XView > xControlView(rControlPrimitive.getXControl(), UNO_QUERY_THROW); + xControlView->draw(basegfx::fround(aTopLeftPixel.getX()), basegfx::fround(aTopLeftPixel.getY())); + bDoProcessRecursively = false; + } + catch( const Exception& ) + { + OSL_ENSURE(false, "VclMetafileProcessor2D: Printing of Control failed, caught an exception!"); + } + } + } + // process recursively and add MetaFile comment if(bDoProcessRecursively) { @@ -919,8 +988,8 @@ namespace drawinglayer // support for TEXT_ MetaFile actions only for decorated texts if(!mxBreakIterator.is()) { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory()); - mxBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), ::com::sun::star::uno::UNO_QUERY); + Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory()); + mxBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), UNO_QUERY); } if(mxBreakIterator.is()) diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index c8ba3e516b06..71be0d100dfd 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclpixelprocessor2d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2007-09-26 11:36:36 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:11:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -97,6 +97,14 @@ #include #endif +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX +#include +#endif + +#ifndef _COM_SUN_STAR_AWT_XWINDOW2_HPP_ +#include +#endif + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer @@ -241,6 +249,43 @@ namespace drawinglayer RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D : + { + // control primitive + const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate); + + // if control primitive is a xWindow2 and visible, it oes not need to be painted + bool bControlIsVisibleAsChildWindow(false); + + if(rControlPrimitive.getXControl().is()) + { + com::sun::star::uno::Reference< com::sun::star::awt::XWindow2 > xControlWindow(rControlPrimitive.getXControl(), com::sun::star::uno::UNO_QUERY_THROW); + + if(xControlWindow.is()) + { + if(xControlWindow->isVisible()) + { + bControlIsVisibleAsChildWindow = true; + } + } + } + + if(bControlIsVisibleAsChildWindow) + { + // update position and size as VCL Child Window + static bool bDoSizeAndPositionControlsB(false); + + if(bDoSizeAndPositionControlsB) + { + PositionAndSizeControl(rControlPrimitive); + } + } + else + { + // process recursively and use the decomposition as Bitmap + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } + } default : { // process recursively diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 08fd30c1d82d..039f96c115e3 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ + * last change: $Author: aw $ $Date: 2007-10-15 16:11:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -146,8 +146,23 @@ #endif ////////////////////////////////////////////////////////////////////////////// +// control support -using namespace com::sun::star; +#ifndef _COM_SUN_STAR_AWT_XWINDOW2_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_AWT_XVIEW_HPP_ +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX +#include +#endif ////////////////////////////////////////////////////////////////////////////// @@ -155,6 +170,16 @@ namespace drawinglayer { namespace processor2d { + ////////////////////////////////////////////////////////////////////////////// + // UNO usings + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::awt::XView; + using ::com::sun::star::awt::XGraphics; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::awt::PosSize::POSSIZE; + ////////////////////////////////////////////////////////////////////////////// // rendering support @@ -883,6 +908,32 @@ namespace drawinglayer } } + basegfx::B2DPoint VclProcessor2D::PositionAndSizeControl(const primitive2d::ControlPrimitive2D& rControlPrimitive2D) + { + // prepare output for given device + Reference< XGraphics > xGraphics(mpOutputDevice->CreateUnoGraphics()); + Reference< XView > xControlView(rControlPrimitive2D.getXControl(), UNO_QUERY_THROW); + xControlView->setGraphics(xGraphics); + + // set position and size (in pixel) + const basegfx::B2DHomMatrix aObjectToPixel(mpOutputDevice->GetViewTransformation() * rControlPrimitive2D.getTransform()); + const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0)); + Reference< XWindow > xControlWindow(rControlPrimitive2D.getXControl(), UNO_QUERY); + + if(xControlWindow.is()) + { + const basegfx::B2DPoint aBottomRightPixel(aObjectToPixel * basegfx::B2DPoint(1.0, 1.0)); + + xControlWindow->setPosSize( + basegfx::fround(aTopLeftPixel.getX()), basegfx::fround(aTopLeftPixel.getY()), + basegfx::fround(aBottomRightPixel.getX() - aTopLeftPixel.getX()), + basegfx::fround(aBottomRightPixel.getY() - aTopLeftPixel.getY()), + POSSIZE); + } + + return aTopLeftPixel; + } + ////////////////////////////////////////////////////////////////////////////// // process support -- cgit