LibreOffice Module drawinglayer (master) 1
fillgraphicprimitive2d.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
23#include <texture/texture.hxx>
28#include <utility>
29#include <vcl/graph.hxx>
30
31
32using namespace com::sun::star;
33
34
36{
38 {
40
41 if(rAttribute.isDefault())
42 return;
43
44 const Graphic& rGraphic = rAttribute.getGraphic();
45
46 if(GraphicType::Bitmap != rGraphic.GetType() && GraphicType::GdiMetafile != rGraphic.GetType())
47 return;
48
49 const Size aSize(rGraphic.GetPrefSize());
50
51 if(!(aSize.Width() && aSize.Height()))
52 return;
53
54 // we have a graphic (bitmap or metafile) with some size
55 if(rAttribute.getTiling())
56 {
57 // get object range and create tiling matrices
58 std::vector< basegfx::B2DHomMatrix > aMatrices;
60 rAttribute.getGraphicRange(),
61 rAttribute.getOffsetX(),
62 rAttribute.getOffsetY());
63
64 // get matrices and realloc retval
65 aTiling.appendTransformations(aMatrices);
66
67 // prepare content primitive
70 rGraphic,
72
73 for(const auto &a : aMatrices)
74 {
75 rContainer.push_back(new TransformPrimitive2D(
78 }
79 }
80 else
81 {
82 // add graphic without tiling
83 const basegfx::B2DHomMatrix aObjectTransform(
85 rAttribute.getGraphicRange().getRange(),
86 rAttribute.getGraphicRange().getMinimum()));
87
89 rGraphic,
90 aObjectTransform);
91 }
92 }
93
95 basegfx::B2DHomMatrix aTransformation,
96 const attribute::FillGraphicAttribute& rFillGraphic)
97 : maTransformation(std::move(aTransformation)),
98 maFillGraphic(rFillGraphic),
99 maOffsetXYCreatedBitmap()
100 {
101 }
102
104 {
105 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
106 {
107 const FillGraphicPrimitive2D& rCompare = static_cast< const FillGraphicPrimitive2D& >(rPrimitive);
108
109 return (getTransformation() == rCompare.getTransformation()
110 && getFillGraphic() == rCompare.getFillGraphic());
111 }
112
113 return false;
114 }
115
117 {
118 // return range of it
120 aPolygon.transform(getTransformation());
121
122 return basegfx::utils::getRange(aPolygon);
123 }
124
125 // provide unique ID
127 {
129 }
130
131} // end of namespace
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Size GetPrefSize() const
GraphicType GetType() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
B2DVector getRange() const
B2DPoint getMinimum() const
const basegfx::B2DRange & getGraphicRange() const
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &rViewInformation) const override
get range
virtual sal_uInt32 getPrimitive2DID() const override
provide unique ID
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &rViewInformation) const override
local decomposition.
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
compare operator
FillGraphicPrimitive2D(basegfx::B2DHomMatrix aTransformation, const attribute::FillGraphicAttribute &rFillGraphic)
constructor
const attribute::FillGraphicAttribute & getFillGraphic() const
const basegfx::B2DHomMatrix & getTransformation() const
data read access
void appendTransformations(::std::vector< basegfx::B2DHomMatrix > &rMatrices) const
Definition: texture.cxx:997
#define PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D
uno_Any a
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
B2DPolygon const & createUnitPolygon()
B2DRange getRange(const B2DPolygon &rCandidate)
void create2DDecompositionOfGraphic(Primitive2DContainer &rContainer, const Graphic &rGraphic, const basegfx::B2DHomMatrix &rTransform)
Helper method with supports decomposing a Graphic with all possible contents to lower level primitive...
basegfx::B2DHomMatrix maTransformation