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/primitive2d/Tools.hxx>
21 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
22 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
23 #include <drawinglayer/geometry/viewinformation2d.hxx>
27 namespace drawinglayer::primitive2d
29 // get B2DRange from a given Primitive2DReference
31 getB2DRangeFromPrimitive2DReference(const Primitive2DReference
& rCandidate
,
32 const geometry::ViewInformation2D
& aViewInformation
)
35 return basegfx::B2DRange();
37 return rCandidate
->getB2DRange(aViewInformation
);
40 bool arePrimitive2DReferencesEqual(const Primitive2DReference
& rxA
, const Primitive2DReference
& rxB
)
42 const bool bAIs(rxA
.is());
54 return rxA
->operator==(*rxB
);
57 bool arePrimitive2DReferencesEqual(const css::uno::Reference
<css::graphic::XPrimitive2D
>& rxA
,
58 const css::uno::Reference
<css::graphic::XPrimitive2D
>& rxB
)
60 const bool bAIs(rxA
.is());
72 auto pA
= static_cast<const UnoPrimitive2D
*>(rxA
.get());
73 auto pB
= static_cast<const UnoPrimitive2D
*>(rxB
.get());
75 return (*pA
->getBasePrimitive2D()) == (*pB
->getBasePrimitive2D());
78 OUString
idToString(sal_uInt32 nId
)
82 case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D
:
83 return u
"TRANSPARENCE"_ustr
;
84 case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D
:
85 return u
"ANIMATEDSWITCH"_ustr
;
86 case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D
:
87 return u
"ANIMATEDBLINK"_ustr
;
88 case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D
:
89 return u
"ANIMATEDINTERPOLATE"_ustr
;
90 case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D
:
91 return u
"BACKGROUNDCOLOR"_ustr
;
92 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
:
93 return u
"BITMAP"_ustr
;
94 case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D
:
95 return u
"CONTROL"_ustr
;
96 case PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D
:
97 return u
"EMBEDDED3D"_ustr
;
98 case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D
:
99 return u
"FILLGRAPHIC"_ustr
;
100 case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D
:
101 return u
"FILLGRADIENT"_ustr
;
102 case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D
:
103 return u
"FILLHATCH"_ustr
;
104 case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D
:
105 return u
"GRAPHIC"_ustr
;
106 case PRIMITIVE2D_ID_GRIDPRIMITIVE2D
:
108 case PRIMITIVE2D_ID_GROUPPRIMITIVE2D
:
109 return u
"GROUP"_ustr
;
110 case PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D
:
111 return u
"HELPLINE"_ustr
;
112 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
:
113 return u
"MARKERARRAY"_ustr
;
114 case PRIMITIVE2D_ID_MASKPRIMITIVE2D
:
116 case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D
:
117 return u
"MEDIA"_ustr
;
118 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
:
119 return u
"METAFILE"_ustr
;
120 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D
:
121 return u
"MODIFIEDCOLOR"_ustr
;
122 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
123 return u
"POLYGONHAIRLINE"_ustr
;
124 case PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D
:
125 return u
"POLYGONMARKER"_ustr
;
126 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
:
127 return u
"POLYGONSTROKE"_ustr
;
128 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
:
129 return u
"POLYGONSTROKEARROW"_ustr
;
130 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D
:
131 return u
"POLYPOLYGONSTROKE"_ustr
;
132 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D
:
133 return u
"POLYPOLYGONSTROKEARROW"_ustr
;
134 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
135 return u
"POLYPOLYGONCOLOR"_ustr
;
136 case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D
:
137 return u
"POLYPOLYGONGRADIENT"_ustr
;
138 case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D
:
139 return u
"POLYPOLYGONHATCH"_ustr
;
140 case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D
:
141 return u
"POLYPOLYGONGRAPHIC"_ustr
;
142 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D
:
143 return u
"SCENE"_ustr
;
144 case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
:
145 return u
"SHADOW"_ustr
;
146 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D
:
147 return u
"TEXTSIMPLEPORTION"_ustr
;
148 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D
:
149 return u
"TEXTDECORATEDPORTION"_ustr
;
150 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
151 return u
"TRANSFORM"_ustr
;
152 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D
:
153 return u
"UNIFIEDTRANSPARENCE"_ustr
;
154 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
:
155 return u
"POINTARRAY"_ustr
;
156 case PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D
:
157 return u
"TEXTHIERARCHYFIELD"_ustr
;
158 case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D
:
159 return u
"TEXTHIERARCHYLINE"_ustr
;
160 case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D
:
161 return u
"TEXTHIERARCHYPARAGRAPH"_ustr
;
162 case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D
:
163 return u
"TEXTHIERARCHYBLOCK"_ustr
;
164 case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D
:
165 return u
"TEXTHIERARCHYEDIT"_ustr
;
166 case PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D
:
167 return u
"POLYGONWAVE"_ustr
;
168 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D
:
169 return u
"WRONGSPELL"_ustr
;
170 case PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D
:
171 return u
"TEXTEFFECT"_ustr
;
172 case PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D
:
173 return u
"TEXTHIERARCHYBULLET"_ustr
;
174 case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D
:
175 return u
"POLYPOLYGONHAIRLINE"_ustr
;
176 case PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D
:
177 return u
"EXECUTE"_ustr
;
178 case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D
:
179 return u
"PAGEPREVIEW"_ustr
;
180 case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D
:
181 return u
"STRUCTURETAG"_ustr
;
182 case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D
:
183 return u
"BORDERLINE"_ustr
;
184 case PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D
:
185 return u
"POLYPOLYGONMARKER"_ustr
;
186 case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D
:
187 return u
"HITTEST"_ustr
;
188 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D
:
189 return u
"INVERT"_ustr
;
190 case PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D
:
191 return u
"DISCRETEBITMAP"_ustr
;
192 case PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D
:
193 return u
"WALLPAPERBITMAP"_ustr
;
194 case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D
:
195 return u
"TEXTLINE"_ustr
;
196 case PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D
:
197 return u
"TEXTCHARACTERSTRIKEOUT"_ustr
;
198 case PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D
:
199 return u
"TEXTGEOMETRYSTRIKEOUT"_ustr
;
200 case PRIMITIVE2D_ID_EPSPRIMITIVE2D
:
202 case PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D
:
203 return u
"DISCRETESHADOW"_ustr
;
204 case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D
:
205 return u
"HIDDENGEOMETRY"_ustr
;
206 case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D
:
207 return u
"SVGLINEARGRADIENT"_ustr
;
208 case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D
:
209 return u
"SVGRADIALGRADIENT"_ustr
;
210 case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D
:
211 return u
"SVGLINEARATOM"_ustr
;
212 case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D
:
213 return u
"SVGRADIALATOM"_ustr
;
214 case PRIMITIVE2D_ID_CROPPRIMITIVE2D
:
216 case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D
:
217 return u
"PATTERNFILL"_ustr
;
218 case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D
:
219 return u
"OBJECTINFO"_ustr
;
220 case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D
:
221 return u
"POLYPOLYGONSELECTION"_ustr
;
222 case PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D
:
223 return u
"PAGEHIERARCHY"_ustr
;
224 case PRIMITIVE2D_ID_GLOWPRIMITIVE2D
:
225 return u
"GLOWPRIMITIVE"_ustr
;
226 case PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D
:
227 return u
"SOFTEDGEPRIMITIVE"_ustr
;
228 case PRIMITIVE2D_ID_LINERECTANGLEPRIMITIVE2D
:
229 return u
"LINERECTANGLEPRIMITIVE"_ustr
;
230 case PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D
:
231 return u
"FILLEDRECTANGLEPRIMITIVE"_ustr
;
232 case PRIMITIVE2D_ID_SINGLELINEPRIMITIVE2D
:
233 return u
"SINGLELINEPRIMITIVE"_ustr
;
234 case PRIMITIVE2D_ID_EXCLUSIVEEDITVIEWPRIMITIVE2D
:
235 return u
"EXCLUSIVEEDITVIEWPRIMITIVE2D"_ustr
;
236 case PRIMITIVE2D_ID_ANIMATEDGRAPHICPRIMITIVE2D
:
237 return u
"ANIMATEDGRAPHICPRIMITIVE2D"_ustr
;
238 case PRIMITIVE2D_ID_POLYPOLYGONRGBAPRIMITIVE2D
:
239 return u
"POLYPOLYGONRGBAPRIMITIVE2D"_ustr
;
240 case PRIMITIVE2D_ID_BITMAPALPHAPRIMITIVE2D
:
241 return u
"BITMAPALPHAPRIMITIVE2D"_ustr
;
242 case PRIMITIVE2D_ID_POLYPOLYGONALPHAGRADIENTPRIMITIVE2D
:
243 return u
"POLYPOLYGONALPHAGRADIENTPRIMITIVE2D"_ustr
;
244 case PRIMITIVE2D_ID_TEXTHIERARCHYEMPHASISMARKPRIMITIVE2D
:
245 return u
"TEXTHIERARCHYEMPHASISMARKPRIMITIVE2D"_ustr
;
247 return OUString::number((nId
>> 16) & 0xFF) + "|" + OUString::number(nId
& 0xFF);
251 } // end of namespace drawinglayer::primitive2d
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */