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 
21 #include <svx/SvxShapeTypes.hxx>
22 #include <svx/AccessibleShape.hxx>
23 #include <svx/AccessibleGraphicShape.hxx>
24 #include <svx/AccessibleOLEShape.hxx>
25 #include <svx/AccessibleControlShape.hxx>
26 #include <svx/ShapeTypeHandler.hxx>
27 #include <AccessibleTableShape.hxx>
28 
29 namespace accessibility {
30 
CreateSvxAccessibleShape(const AccessibleShapeInfo & rShapeInfo,const AccessibleShapeTreeInfo & rShapeTreeInfo,ShapeTypeId nId)31 static AccessibleShape* CreateSvxAccessibleShape (
32     const AccessibleShapeInfo& rShapeInfo,
33     const AccessibleShapeTreeInfo& rShapeTreeInfo,
34     ShapeTypeId nId)
35 {
36     switch (nId)
37     {
38         case DRAWING_3D_CUBE:
39         case DRAWING_3D_EXTRUDE:
40         case DRAWING_3D_LATHE:
41         case DRAWING_3D_SCENE:
42         case DRAWING_3D_SPHERE:
43         case DRAWING_CAPTION:
44         case DRAWING_CLOSED_BEZIER:
45         case DRAWING_CLOSED_FREEHAND:
46         case DRAWING_CONNECTOR:
47         case DRAWING_ELLIPSE:
48         case DRAWING_GROUP:
49         case DRAWING_LINE:
50         case DRAWING_MEASURE:
51         case DRAWING_OPEN_BEZIER:
52         case DRAWING_OPEN_FREEHAND:
53         case DRAWING_PAGE:
54         case DRAWING_POLY_POLYGON:
55         case DRAWING_POLY_LINE:
56         case DRAWING_POLY_POLYGON_PATH:
57         case DRAWING_POLY_LINE_PATH:
58         case DRAWING_RECTANGLE:
59         case DRAWING_TEXT:
60         // Default accessibility shape for
61         // css::drawing::CustomShape (#i37790#)
62         case DRAWING_CUSTOM:
63         // Default accessibility shape for
64         // css::drawing::MediaShape (#i85429#)
65         case DRAWING_MEDIA:
66             return new AccessibleShape (rShapeInfo, rShapeTreeInfo);
67 
68         case DRAWING_CONTROL:
69             return new AccessibleControlShape (rShapeInfo, rShapeTreeInfo);
70 
71         case DRAWING_GRAPHIC_OBJECT:
72             return new AccessibleGraphicShape (rShapeInfo, rShapeTreeInfo);
73 
74         case DRAWING_APPLET:
75         case DRAWING_FRAME:
76         case DRAWING_OLE:
77         case DRAWING_PLUGIN:
78             return new AccessibleOLEShape (rShapeInfo, rShapeTreeInfo);
79 
80         case DRAWING_TABLE:
81             return new AccessibleTableShape( rShapeInfo, rShapeTreeInfo );
82 
83         default:
84             return nullptr;
85     }
86 }
87 
RegisterDrawShapeTypes()88 void RegisterDrawShapeTypes()
89 {
90     /** List of shape type descriptors corresponding to the
91         <type>SvxShapeTypes</type> enum.
92     */
93     static ShapeTypeDescriptor const aSvxShapeTypeList[] = {
94         ShapeTypeDescriptor ( DRAWING_TEXT, "com.sun.star.drawing.TextShape",
95             CreateSvxAccessibleShape),
96         ShapeTypeDescriptor (DRAWING_RECTANGLE, "com.sun.star.drawing.RectangleShape",
97             CreateSvxAccessibleShape),
98         ShapeTypeDescriptor ( DRAWING_ELLIPSE, "com.sun.star.drawing.EllipseShape",
99             CreateSvxAccessibleShape ),
100         ShapeTypeDescriptor ( DRAWING_CONTROL, "com.sun.star.drawing.ControlShape",
101             CreateSvxAccessibleShape ),
102         ShapeTypeDescriptor ( DRAWING_CONNECTOR, "com.sun.star.drawing.ConnectorShape",
103             CreateSvxAccessibleShape ),
104         ShapeTypeDescriptor ( DRAWING_MEASURE, "com.sun.star.drawing.MeasureShape",
105             CreateSvxAccessibleShape ),
106         ShapeTypeDescriptor ( DRAWING_LINE, "com.sun.star.drawing.LineShape",
107             CreateSvxAccessibleShape ),
108         ShapeTypeDescriptor ( DRAWING_POLY_POLYGON, "com.sun.star.drawing.PolyPolygonShape",
109             CreateSvxAccessibleShape ),
110         ShapeTypeDescriptor ( DRAWING_POLY_LINE, "com.sun.star.drawing.PolyLineShape",
111             CreateSvxAccessibleShape ),
112         ShapeTypeDescriptor ( DRAWING_OPEN_BEZIER, "com.sun.star.drawing.OpenBezierShape",
113             CreateSvxAccessibleShape ),
114         ShapeTypeDescriptor ( DRAWING_CLOSED_BEZIER, "com.sun.star.drawing.ClosedBezierShape",
115             CreateSvxAccessibleShape ),
116         ShapeTypeDescriptor ( DRAWING_OPEN_FREEHAND, "com.sun.star.drawing.OpenFreeHandShape",
117             CreateSvxAccessibleShape ),
118         ShapeTypeDescriptor ( DRAWING_CLOSED_FREEHAND, "com.sun.star.drawing.ClosedFreeHandShape",
119             CreateSvxAccessibleShape ),
120         ShapeTypeDescriptor ( DRAWING_POLY_POLYGON_PATH, "com.sun.star.drawing.PolyPolygonPathShape",
121             CreateSvxAccessibleShape ),
122         ShapeTypeDescriptor ( DRAWING_POLY_LINE_PATH, "com.sun.star.drawing.PolyLinePathShape",
123             CreateSvxAccessibleShape ),
124         ShapeTypeDescriptor ( DRAWING_GRAPHIC_OBJECT, "com.sun.star.drawing.GraphicObjectShape",
125             CreateSvxAccessibleShape ),
126         ShapeTypeDescriptor ( DRAWING_GROUP, "com.sun.star.drawing.GroupShape",
127             CreateSvxAccessibleShape ),
128         ShapeTypeDescriptor ( DRAWING_OLE, "com.sun.star.drawing.OLE2Shape",
129             CreateSvxAccessibleShape ),
130         ShapeTypeDescriptor ( DRAWING_PAGE, "com.sun.star.drawing.PageShape",
131             CreateSvxAccessibleShape ),
132         ShapeTypeDescriptor ( DRAWING_CAPTION, "com.sun.star.drawing.CaptionShape",
133             CreateSvxAccessibleShape ),
134         ShapeTypeDescriptor ( DRAWING_FRAME, "com.sun.star.drawing.FrameShape",
135             CreateSvxAccessibleShape ),
136         ShapeTypeDescriptor ( DRAWING_PLUGIN, "com.sun.star.drawing.PluginShape",
137             CreateSvxAccessibleShape ),
138         ShapeTypeDescriptor ( DRAWING_APPLET, "com.sun.star.drawing.AppletShape",
139             CreateSvxAccessibleShape ),
140         ShapeTypeDescriptor ( DRAWING_3D_SCENE, "com.sun.star.drawing.Shape3DSceneObject",
141             CreateSvxAccessibleShape ),
142         ShapeTypeDescriptor ( DRAWING_3D_CUBE, "com.sun.star.drawing.Shape3DCubeObject",
143             CreateSvxAccessibleShape ),
144         ShapeTypeDescriptor ( DRAWING_3D_SPHERE, "com.sun.star.drawing.Shape3DSphereObject",
145             CreateSvxAccessibleShape ),
146         ShapeTypeDescriptor ( DRAWING_3D_LATHE, "com.sun.star.drawing.Shape3DLatheObject",
147             CreateSvxAccessibleShape ),
148         ShapeTypeDescriptor ( DRAWING_3D_EXTRUDE, "com.sun.star.drawing.Shape3DExtrudeObject",
149             CreateSvxAccessibleShape ),
150         ShapeTypeDescriptor ( DRAWING_CUSTOM, "com.sun.star.drawing.CustomShape",
151             CreateSvxAccessibleShape ),
152         ShapeTypeDescriptor ( DRAWING_TABLE, "com.sun.star.drawing.TableShape",
153             CreateSvxAccessibleShape ),
154         ShapeTypeDescriptor ( DRAWING_MEDIA, "com.sun.star.drawing.MediaShape",
155             CreateSvxAccessibleShape ),
156 
157     };
158 
159     // Crash while inserting callout with activated accessibility (#i37790#)
160     ShapeTypeHandler::Instance().AddShapeTypeList ( DRAWING_END, aSvxShapeTypeList);
161 }
162 
163 } // end of namespace accessibility
164 
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
166