LibreOffice Module svx (master)  1
ShapeTypeHandler.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SVX_SHAPETYPEHANDLER_HXX
21 #define INCLUDED_SVX_SHAPETYPEHANDLER_HXX
22 
23 #include <svx/svxdllapi.h>
24 
25 #include <rtl/ref.hxx>
26 #include <rtl/ustring.hxx>
27 #include <tools/long.hxx>
28 #include <unordered_map>
29 #include <vector>
30 
31 namespace accessibility { class AccessibleShape; }
32 namespace accessibility { class AccessibleShapeInfo; }
33 namespace accessibility { class AccessibleShapeTreeInfo; }
34 namespace com::sun::star::drawing { class XShape; }
35 namespace com::sun::star::uno { template <typename > class Reference; }
36 
37 namespace accessibility {
38 
42 typedef int ShapeTypeId;
43 
47 typedef AccessibleShape* (*tCreateFunction)
48  (const AccessibleShapeInfo& rShapeInfo,
49  const AccessibleShapeTreeInfo& rShapeTreeInfo,
50  ShapeTypeId nId);
51 
57 {
58  ShapeTypeId mnShapeTypeId;
59  OUString msServiceName;
62  ShapeTypeId nId, const OUString& sName, tCreateFunction aFunction)
63  : mnShapeTypeId (nId),
64  msServiceName (sName),
65  maCreateFunction (aFunction)
66  {}
68  : mnShapeTypeId (-1),
69  msServiceName (),
70  maCreateFunction (nullptr)
71  {}
72 };
73 
80 {
81 public:
82  enum { UNKNOWN_SHAPE_TYPE = 0 };
83 
89  static ShapeTypeHandler& Instance();
90 
98  ShapeTypeId GetTypeId (const OUString& aServiceName) const;
99 
109  ShapeTypeId GetTypeId (const css::uno::Reference<
110  css::drawing::XShape>& rxShape) const;
111 
123  CreateAccessibleObject (
124  const AccessibleShapeInfo& rShapeInfo,
125  const AccessibleShapeTreeInfo& rShapeTreeInfo) const;
126 
136  void AddShapeTypeList (int nDescriptorCount,
137  ShapeTypeDescriptor const aDescriptorList[]);
138 
142  static OUString CreateAccessibleBaseName (
143  const css::uno::Reference< css::drawing::XShape >& rxShape);
144 
145 private:
146  // Declare default constructor, copy constructor, destructor, and
147  // assignment operation protected so that no one accidentally creates a
148  // second instance of this singleton class or deletes it.
150  ShapeTypeHandler (const ShapeTypeHandler& aHandler); // never implemented, this is a singleton class
151  ShapeTypeHandler& operator= (const ShapeTypeHandler& aHandler); // never implemented, this is a singleton class
152 
156  ~ShapeTypeHandler();
157 
160 
166  ::std::vector<ShapeTypeDescriptor> maShapeTypeDescriptorList;
167 
171  typedef std::unordered_map<OUString,ShapeTypeId> tServiceNameToSlotId;
172  mutable tServiceNameToSlotId maServiceNameToSlotId;
173 
182  SVX_DLLPRIVATE tools::Long GetSlotId (const OUString& aServiceName) const;
183 
192  SVX_DLLPRIVATE tools::Long GetSlotId (const css::uno::Reference<
193  css::drawing::XShape>& rxShape) const;
194 };
195 
196 } // end of namespace accessible
197 
198 #endif
199 
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Each shape type is described by listing its id, its service name and a function which creates a new a...
long Long
Reference
sal_Int16 nId
tServiceNameToSlotId maServiceNameToSlotId
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
::std::vector< ShapeTypeDescriptor > maShapeTypeDescriptorList
List of shape type descriptors.
AccessibleShape *(* tCreateFunction)(const AccessibleShapeInfo &rShapeInfo, const AccessibleShapeTreeInfo &rShapeTreeInfo, ShapeTypeId nId)
Define the function type for creating accessible objects for given service names. ...
This class is a singleton that has the purpose to transform between service names of shapes and assoc...
static ShapeTypeHandler * instance
Pointer to the only instance of this class.
OUString sName
int ShapeTypeId
Use an integer to represent shape type ids.
std::unordered_map< OUString, ShapeTypeId > tServiceNameToSlotId
This hash map allows the fast look up of a type descriptor for a given service name.
This base class provides a base implementation for all shapes.
ShapeTypeDescriptor(ShapeTypeId nId, const OUString &sName, tCreateFunction aFunction)
This class is a container for the information specific for a single shape that is passed to the const...
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
This class bundles all information that is passed down the tree of accessible shapes so that each sha...