30#include <com/sun/star/uno/XComponentContext.hpp>
31#include <com/sun/star/lang/XMultiComponentFactory.hpp>
32#include <com/sun/star/rendering/XCanvas.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/beans/PropertyValue.hpp>
35#include <com/sun/star/util/XCloseable.hpp>
36#include <com/sun/star/awt/WindowDescriptor.hpp>
37#include <com/sun/star/awt/Toolkit.hpp>
38#include <com/sun/star/awt/XWindow2.hpp>
39#include <com/sun/star/awt/XWindowPeer.hpp>
40#include <com/sun/star/awt/WindowAttribute.hpp>
41#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
42#include <com/sun/star/awt/PosSize.hpp>
43#include <com/sun/star/frame/Frame.hpp>
44#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
56 const uno::Reference< drawing::XShape >& rxShape,
57 const OUString& rServiceName,
58 const char** pPropCopyTable,
59 std::size_t nNumPropEntries,
60 uno::Reference< uno::XComponentContext > xContext ) :
61 mpViewLayer(
std::move( xViewLayer )),
66 ENSURE_OR_THROW( rxShape.is(),
"ViewAppletShape::ViewAppletShape(): Invalid Shape" );
67 ENSURE_OR_THROW( mpViewLayer,
"ViewAppletShape::ViewAppletShape(): Invalid View" );
68 ENSURE_OR_THROW( mpViewLayer->getCanvas(),
"ViewAppletShape::ViewAppletShape(): Invalid ViewLayer canvas" );
71 uno::Reference<lang::XMultiComponentFactory>
xFactory(
75 mxViewer.set(
xFactory->createInstanceWithContext( rServiceName,
77 uno::UNO_QUERY_THROW );
79 uno::Reference< beans::XPropertySet > xShapePropSet( rxShape,
80 uno::UNO_QUERY_THROW );
81 uno::Reference< beans::XPropertySet > xViewerPropSet( mxViewer,
82 uno::UNO_QUERY_THROW );
86 for( std::size_t i=0;
i<nNumPropEntries; ++
i )
88 aPropName = OUString::createFromAscii( pPropCopyTable[i] );
89 xViewerPropSet->setPropertyValue( aPropName,
90 xShapePropSet->getPropertyValue(
95 ViewAppletShape::~ViewAppletShape()
101 catch (
const uno::Exception &)
112 void ViewAppletShape::startApplet( const ::basegfx::B2DRectangle& rBounds )
114 ENSURE_OR_RETURN_VOID( mpViewLayer && mpViewLayer->getCanvas() && mpViewLayer->getCanvas()->getUNOCanvas().is(),
115 "ViewAppletShape::startApplet(): Invalid or disposed view" );
121 uno::UNO_QUERY_THROW );
124 xPropSet->getPropertyValue(
"Window"),
125 uno::UNO_QUERY_THROW );
137 awt::WindowDescriptor aOwnWinDescriptor( awt::WindowClass_SIMPLE,
140 uno::UNO_QUERY_THROW),
143 awt::WindowAttribute::SHOW
144 | awt::VclWindowPeerAttribute::CLIPCHILDREN );
147 xToolkit->createWindow( aOwnWinDescriptor ));
149 uno::UNO_QUERY_THROW );
156 mxFrame->initialize( xOwnWindow );
159 uno::UNO_SET_THROW );
168 ::canvas::tools::calcTransformedRectBounds( aTmpRange,
170 mpViewLayer->getTransformation() );
171 const ::basegfx::B2IRange& rPixelBounds(
172 ::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange ));
175 if( xSurroundingWindow.is() )
176 xSurroundingWindow->setPosSize( rPixelBounds.getMinX(),
177 rPixelBounds.getMinY(),
178 static_cast<sal_Int32
>(rPixelBounds.getWidth()),
179 static_cast<sal_Int32
>(rPixelBounds.getHeight()),
180 awt::PosSize::POSSIZE );
183 if( xAppletWindow.is() )
184 xAppletWindow->setPosSize( 0, 0,
185 static_cast<sal_Int32
>(rPixelBounds.getWidth()),
186 static_cast<sal_Int32
>(rPixelBounds.getHeight()),
187 awt::PosSize::POSSIZE );
190 catch (uno::Exception &)
196 void ViewAppletShape::endApplet()
202 if( xCloseable.is() )
204 xCloseable->close(
true );
210 bool ViewAppletShape::render( const ::basegfx::B2DRectangle& rBounds )
const
228 bool ViewAppletShape::resize( const ::basegfx::B2DRectangle& rBounds )
const
234 ::canvas::tools::calcTransformedRectBounds( aTmpRange,
236 mpViewLayer->getTransformation() );
237 const ::basegfx::B2IRange& rPixelBounds(
238 ::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange ));
241 if( xFrameWindow.is() )
242 xFrameWindow->setPosSize( rPixelBounds.getMinX(),
243 rPixelBounds.getMinY(),
244 static_cast<sal_Int32
>(rPixelBounds.getWidth()),
245 static_cast<sal_Int32
>(rPixelBounds.getHeight()),
246 awt::PosSize::POSSIZE );
249 if( xAppletWindow.is() )
250 xAppletWindow->setPosSize( 0, 0,
251 static_cast<sal_Int32
>(rPixelBounds.getWidth()),
252 static_cast<sal_Int32
>(rPixelBounds.getHeight()),
253 awt::PosSize::POSSIZE );
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
ViewAppletShape(ViewLayerSharedPtr xViewLayer, const css::uno::Reference< css::drawing::XShape > &rxShape, const OUString &rServiceName, const char **pPropCopyTable, std::size_t nNumPropEntries, css::uno::Reference< css::uno::XComponentContext > xContext)
Create a ViewAppletShape for the given View.
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_THROW(c, m)
#define ENSURE_OR_RETURN_VOID(c, m)
Reference< XSingleServiceFactory > xFactory
std::shared_ptr< Canvas > CanvasSharedPtr
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
void fillRect(const ::cppcanvas::CanvasSharedPtr &rCanvas, const ::basegfx::B2DRectangle &rRect, ::cppcanvas::IntSRGBA aFillColor)