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 "TRANSPARENCE";
84 case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D
:
85 return "ANIMATEDSWITCH";
86 case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D
:
87 return "ANIMATEDBLINK";
88 case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D
:
89 return "ANIMATEDINTERPOLATE";
90 case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D
:
91 return "BACKGROUNDCOLOR";
92 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
:
94 case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D
:
96 case PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D
:
98 case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D
:
100 case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D
:
101 return "FILLGRADIENT";
102 case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D
:
104 case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D
:
106 case PRIMITIVE2D_ID_GRIDPRIMITIVE2D
:
108 case PRIMITIVE2D_ID_GROUPPRIMITIVE2D
:
110 case PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D
:
112 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
:
113 return "MARKERARRAY";
114 case PRIMITIVE2D_ID_MASKPRIMITIVE2D
:
116 case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D
:
118 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
:
120 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D
:
121 return "MODIFIEDCOLOR";
122 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
123 return "POLYGONHAIRLINE";
124 case PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D
:
125 return "POLYGONMARKER";
126 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
:
127 return "POLYGONSTROKE";
128 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
:
129 return "POLYGONSTROKEARROW";
130 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D
:
131 return "POLYPOLYGONSTROKE";
132 case PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D
:
133 return "POLYPOLYGONSTROKEARROW";
134 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
135 return "POLYPOLYGONCOLOR";
136 case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D
:
137 return "POLYPOLYGONGRADIENT";
138 case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D
:
139 return "POLYPOLYGONHATCH";
140 case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D
:
141 return "POLYPOLYGONGRAPHIC";
142 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D
:
144 case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
:
146 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D
:
147 return "TEXTSIMPLEPORTION";
148 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D
:
149 return "TEXTDECORATEDPORTION";
150 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
152 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D
:
153 return "UNIFIEDTRANSPARENCE";
154 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
:
156 case PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D
:
157 return "TEXTHIERARCHYFIELD";
158 case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D
:
159 return "TEXTHIERARCHYLINE";
160 case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D
:
161 return "TEXTHIERARCHYPARAGRAPH";
162 case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D
:
163 return "TEXTHIERARCHYBLOCK";
164 case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D
:
165 return "TEXTHIERARCHYEDIT";
166 case PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D
:
167 return "POLYGONWAVE";
168 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D
:
170 case PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D
:
172 case PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D
:
173 return "TEXTHIERARCHYBULLET";
174 case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D
:
175 return "POLYPOLYGONHAIRLINE";
176 case PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D
:
178 case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D
:
179 return "PAGEPREVIEW";
180 case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D
:
181 return "STRUCTURETAG";
182 case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D
:
184 case PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D
:
185 return "POLYPOLYGONMARKER";
186 case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D
:
188 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D
:
190 case PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D
:
191 return "DISCRETEBITMAP";
192 case PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D
:
193 return "WALLPAPERBITMAP";
194 case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D
:
196 case PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D
:
197 return "TEXTCHARACTERSTRIKEOUT";
198 case PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D
:
199 return "TEXTGEOMETRYSTRIKEOUT";
200 case PRIMITIVE2D_ID_EPSPRIMITIVE2D
:
202 case PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D
:
203 return "DISCRETESHADOW";
204 case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D
:
205 return "HIDDENGEOMETRY";
206 case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D
:
207 return "SVGLINEARGRADIENT";
208 case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D
:
209 return "SVGRADIALGRADIENT";
210 case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D
:
211 return "SVGLINEARATOM";
212 case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D
:
213 return "SVGRADIALATOM";
214 case PRIMITIVE2D_ID_CROPPRIMITIVE2D
:
216 case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D
:
217 return "PATTERNFILL";
218 case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D
:
220 case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D
:
221 return "POLYPOLYGONSELECTION";
222 case PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D
:
223 return "PAGEHIERARCHY";
224 case PRIMITIVE2D_ID_GLOWPRIMITIVE2D
:
225 return "GLOWPRIMITIVE";
226 case PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D
:
227 return "SOFTEDGEPRIMITIVE";
229 return OUString::number((nId
>> 16) & 0xFF) + "|" + OUString::number(nId
& 0xFF);
233 } // end of namespace drawinglayer::primitive2d
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */