LibreOffice Module cppcanvas (master) 1
canvasgraphichelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
22
23#include <com/sun/star/rendering/XCanvas.hpp>
24
28#include <utility>
29
30
31using namespace ::com::sun::star;
32
33/* Implementation of CanvasGraphicHelper class */
34
35namespace cppcanvas::internal
36{
38 mpCanvas(std::move( xParentCanvas ))
39 {
40 OSL_ENSURE( mpCanvas && mpCanvas->getUNOCanvas().is(),
41 "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
42
44 }
45
46 void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
47 {
48 ::canvas::tools::setRenderStateTransform( maRenderState, rMatrix );
49 }
50
51 void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
52 {
53 // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
54 maClipPolyPolygon = rClipPoly;
55 maRenderState.Clip.clear();
56 }
57
59 {
60 maClipPolyPolygon.reset();
61 maRenderState.Clip.clear();
62 }
63
64 const rendering::RenderState& CanvasGraphicHelper::getRenderState() const
65 {
66 if( maClipPolyPolygon && !maRenderState.Clip.is() )
67 {
68 uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
69 if( !xCanvas.is() )
70 return maRenderState;
71
72 maRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
73 xCanvas->getDevice(),
75 }
76
77 return maRenderState;
78 }
79
81 {
82 maRenderState.CompositeOperation = aOp;
83 }
84
85}
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CanvasSharedPtr mpCanvas
const css::rendering::RenderState & getRenderState() const
virtual void setTransformation(const ::basegfx::B2DHomMatrix &rMatrix) override
Set object transformation matrix.
CanvasGraphicHelper(CanvasSharedPtr xParentCanvas)
virtual void setCompositeOp(sal_Int8 aOp) override
Set object composite mode.
std::optional< basegfx::B2DPolyPolygon > maClipPolyPolygon
virtual void setClip() override
Clear object clipping polygon.
void initRenderState(rendering::RenderState &renderState, const ::cppcanvas::internal::OutDevState &outdevState)
Definition: mtftools.cxx:42
std::shared_ptr< Canvas > CanvasSharedPtr
signed char sal_Int8