LibreOffice Module drawinglayer (master) 1
fillgraphicattribute.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#include <sal/config.h>
21
22#include <algorithm>
23
25#include <utility>
26#include <vcl/graph.hxx>
27
29{
31 {
32 public:
33 // data definitions
36
37 bool mbTiling : 1;
38
39 // tiling definitions, offsets in X/Y in percent for each 2nd row.
40 // If both are set, Y is ignored (X has precedence)
41 double mfOffsetX;
42 double mfOffsetY;
43
45 Graphic aGraphic,
46 const basegfx::B2DRange& rGraphicRange,
47 bool bTiling,
48 double fOffsetX,
49 double fOffsetY)
50 : maGraphic(std::move(aGraphic)),
51 maGraphicRange(rGraphicRange),
52 mbTiling(bTiling),
53 mfOffsetX(fOffsetX),
54 mfOffsetY(fOffsetY)
55 {
56 // access once to ensure that the buffered bitmap exists, else
57 // the SolarMutex may be needed to create it. This may not be
58 // available when a renderer works with multi-threading.
59 // When changing this, please check if it is still possible to
60 // use a metafile as texture for a 3D object
62 }
63
65 : mbTiling(false),
66 mfOffsetX(0.0),
67 mfOffsetY(0.0)
68 {
69 }
70
71 // data read access
72 const Graphic& getGraphic() const { return maGraphic; }
74 bool getTiling() const { return mbTiling; }
75 double getOffsetX() const { return mfOffsetX; }
76 double getOffsetY() const { return mfOffsetY; }
77
78 bool operator==(const ImpFillGraphicAttribute& rCandidate) const
79 {
80 return (getGraphic() == rCandidate.getGraphic()
81 && getGraphicRange() == rCandidate.getGraphicRange()
82 && getTiling() == rCandidate.getTiling()
83 && getOffsetX() == rCandidate.getOffsetX()
84 && getOffsetY() == rCandidate.getOffsetY());
85 }
86 };
87
88 namespace
89 {
90 FillGraphicAttribute::ImplType& theGlobalDefault()
91 {
92 static FillGraphicAttribute::ImplType SINGLETON;
93 return SINGLETON;
94 }
95 }
96
98 const Graphic& rGraphic,
99 const basegfx::B2DRange& rGraphicRange,
100 bool bTiling,
101 double fOffsetX,
102 double fOffsetY)
103 : mpFillGraphicAttribute(ImpFillGraphicAttribute(
104 rGraphic, rGraphicRange, bTiling,
105 std::clamp(fOffsetX, 0.0, 1.0),
106 std::clamp(fOffsetY, 0.0, 1.0)))
107 {
108 }
109
111
113
115 {
116 return mpFillGraphicAttribute.same_object(theGlobalDefault());
117 }
118
120
122 {
123 // tdf#87509 default attr is always != non-default attr, even with same values
124 if(rCandidate.isDefault() != isDefault())
125 return false;
126
128 }
129
131 {
132 return mpFillGraphicAttribute->getGraphic();
133 }
134
136 {
137 return mpFillGraphicAttribute->getGraphicRange();
138 }
139
141 {
142 return mpFillGraphicAttribute->getTiling();
143 }
144
146 {
147 return mpFillGraphicAttribute->getOffsetX();
148 }
149
151 {
152 return mpFillGraphicAttribute->getOffsetY();
153 }
154
155} // end of namespace
156
157/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
FillGraphicAttribute(const Graphic &rGraphic, const basegfx::B2DRange &rGraphicRange, bool bTiling, double fOffsetX=0.0, double fOffsetY=0.0)
constructors/assignmentoperator/destructor
o3tl::cow_wrapper< ImpFillGraphicAttribute > ImplType
FillGraphicAttribute & operator=(const FillGraphicAttribute &)
bool operator==(const FillGraphicAttribute &rCandidate) const
const basegfx::B2DRange & getGraphicRange() const
bool operator==(const ImpFillGraphicAttribute &rCandidate) const
ImpFillGraphicAttribute(Graphic aGraphic, const basegfx::B2DRange &rGraphicRange, bool bTiling, double fOffsetX, double fOffsetY)
bool same_object(const cow_wrapper &rOther) const