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