update emoji autocorrect entries from po-files
[LibreOffice.git] / drawinglayer / source / attribute / fillgraphicattribute.cxx
blob89422befac87827f86b736dcb4d33e87a4aa4041
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
25 namespace attribute
27 class ImpFillGraphicAttribute
29 public:
30 // data definitions
31 Graphic maGraphic;
32 basegfx::B2DRange maGraphicRange;
34 // bitfield
35 bool mbTiling : 1;
37 // tiling definitions, offsets in X/Y in percent for each 2nd row.
38 // If both are set, Y is ignored (X has precedence)
39 double mfOffsetX;
40 double mfOffsetY;
42 ImpFillGraphicAttribute(
43 const Graphic& rGraphic,
44 const basegfx::B2DRange& rGraphicRange,
45 bool bTiling,
46 double fOffsetX,
47 double fOffsetY)
48 : maGraphic(rGraphic),
49 maGraphicRange(rGraphicRange),
50 mbTiling(bTiling),
51 mfOffsetX(fOffsetX),
52 mfOffsetY(fOffsetY)
56 ImpFillGraphicAttribute()
57 : maGraphic(Graphic()),
58 maGraphicRange(basegfx::B2DRange()),
59 mbTiling(false),
60 mfOffsetX(0.0),
61 mfOffsetY(0.0)
65 // data read access
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());
82 namespace
84 struct theGlobalDefault :
85 public rtl::Static< FillGraphicAttribute::ImplType, theGlobalDefault > {};
88 FillGraphicAttribute::FillGraphicAttribute(
89 const Graphic& rGraphic,
90 const basegfx::B2DRange& rGraphicRange,
91 bool bTiling,
92 double fOffsetX,
93 double fOffsetY)
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;
118 return *this;
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())
125 return false;
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: */