1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/attribute/fillgraphicattribute.hxx>
21 #include <vcl/graph.hxx>
23 namespace drawinglayer
27 class ImpFillGraphicAttribute
32 basegfx::B2DRange maGraphicRange
;
37 // tiling definitions, offsets in X/Y in percent for each 2nd row.
38 // If both are set, Y is ignored (X has precedence)
42 ImpFillGraphicAttribute(
43 const Graphic
& rGraphic
,
44 const basegfx::B2DRange
& rGraphicRange
,
48 : maGraphic(rGraphic
),
49 maGraphicRange(rGraphicRange
),
56 ImpFillGraphicAttribute()
57 : maGraphic(Graphic()),
58 maGraphicRange(basegfx::B2DRange()),
66 const Graphic
& getGraphic() const { return maGraphic
; }
67 const basegfx::B2DRange
& getGraphicRange() const { return maGraphicRange
; }
68 bool getTiling() const { return mbTiling
; }
69 double getOffsetX() const { return mfOffsetX
; }
70 double getOffsetY() const { return mfOffsetY
; }
72 bool operator==(const ImpFillGraphicAttribute
& rCandidate
) const
74 return (getGraphic() == rCandidate
.getGraphic()
75 && getGraphicRange() == rCandidate
.getGraphicRange()
76 && getTiling() == rCandidate
.getTiling()
77 && getOffsetX() == rCandidate
.getOffsetX()
78 && getOffsetY() == rCandidate
.getOffsetY());
84 struct theGlobalDefault
:
85 public rtl::Static
< FillGraphicAttribute::ImplType
, theGlobalDefault
> {};
88 FillGraphicAttribute::FillGraphicAttribute(
89 const Graphic
& rGraphic
,
90 const basegfx::B2DRange
& rGraphicRange
,
94 : mpFillGraphicAttribute(ImpFillGraphicAttribute(
95 rGraphic
, rGraphicRange
, bTiling
,
96 basegfx::clamp(fOffsetX
, 0.0, 1.0),
97 basegfx::clamp(fOffsetY
, 0.0, 1.0)))
101 FillGraphicAttribute::FillGraphicAttribute(const FillGraphicAttribute
& rCandidate
)
102 : mpFillGraphicAttribute(rCandidate
.mpFillGraphicAttribute
)
106 FillGraphicAttribute::~FillGraphicAttribute()
110 bool FillGraphicAttribute::isDefault() const
112 return mpFillGraphicAttribute
.same_object(theGlobalDefault::get());
115 FillGraphicAttribute
& FillGraphicAttribute::operator=(const FillGraphicAttribute
& rCandidate
)
117 mpFillGraphicAttribute
= rCandidate
.mpFillGraphicAttribute
;
121 bool FillGraphicAttribute::operator==(const FillGraphicAttribute
& rCandidate
) const
123 // tdf#87509 default attr is always != non-default attr, even with same values
124 if(rCandidate
.isDefault() != isDefault())
127 return rCandidate
.mpFillGraphicAttribute
== mpFillGraphicAttribute
;
130 const Graphic
& FillGraphicAttribute::getGraphic() const
132 return mpFillGraphicAttribute
->getGraphic();
135 const basegfx::B2DRange
& FillGraphicAttribute::getGraphicRange() const
137 return mpFillGraphicAttribute
->getGraphicRange();
140 bool FillGraphicAttribute::getTiling() const
142 return mpFillGraphicAttribute
->getTiling();
145 double FillGraphicAttribute::getOffsetX() const
147 return mpFillGraphicAttribute
->getOffsetX();
150 double FillGraphicAttribute::getOffsetY() const
152 return mpFillGraphicAttribute
->getOffsetY();
155 } // end of namespace attribute
156 } // end of namespace drawinglayer
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */