LibreOffice Module drawinglayer (master) 1
backgroundcolorprimitive2d.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
27
28
29using namespace com::sun::star;
30
31
33{
35 {
36 // transparency invalid or completely transparent, done
37 if(getTransparency() < 0.0 || getTransparency() >= 1.0)
38 return;
39
40 // no viewport, not visible, done
41 if(rViewInformation.getViewport().isEmpty())
42 return;
43
44 // create decompose geometry
47
48 if(getTransparency() != 0.0)
49 {
50 // if used, embed decompose geometry to unified transparency
51 Primitive2DContainer aContent { aDecompose };
52 aDecompose = Primitive2DReference(
54 std::move(aContent),
56 }
57
58 rContainer.push_back(aDecompose);
59 }
60
62 const basegfx::BColor& rBColor,
63 double fTransparency)
64 : maBColor(rBColor),
65 mfTransparency(fTransparency)
66 {
67 }
68
70 {
71 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
72 {
73 const BackgroundColorPrimitive2D& rCompare = static_cast<const BackgroundColorPrimitive2D&>(rPrimitive);
74
75 return (getBColor() == rCompare.getBColor() && getTransparency() == rCompare.getTransparency());
76 }
77
78 return false;
79 }
80
82 {
83 // always as big as the view
84 return rViewInformation.getViewport();
85 }
86
88 {
89 if(!getBuffered2DDecomposition().empty() && (maLastViewport != rViewInformation.getViewport()))
90 {
91 // conditions of last local decomposition have changed, delete
93 }
94
95 if(getBuffered2DDecomposition().empty())
96 {
97 // remember ViewRange
98 const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport();
99 }
100
101 // use parent implementation
103 }
104
105 // provide unique ID
107 {
109 }
110
111} // end of namespace
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isEmpty() const
const basegfx::B2DRange & getViewport() const
Empty viewport means everything is visible.
const basegfx::BColor & getBColor() const
data read access
BackgroundColorPrimitive2D(const basegfx::BColor &rBColor, double fTransparency=0)
constructor
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &rViewInformation) const override
get B2Drange
virtual sal_uInt32 getPrimitive2DID() const override
provide unique ID
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
compare operator
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &rViewInformation) const override
create local decomposition
basegfx::B2DRange maLastViewport
the last used viewInformation, used from getDecomposition for buffering
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const override
Override standard getDecomposition call to be view-dependent here.
const Primitive2DContainer & getBuffered2DDecomposition() const
access methods to maBuffered2DDecomposition.
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const override
The getDecomposition default implementation will on demand use create2DDecomposition() if maBuffered2...
#define PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
rtl::Reference< BasePrimitive2D > Primitive2DReference
Definition: CommonTypes.hxx:27