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 <unordered_map>
28 #include <vector>
29 
30 namespace accessibility { class AccessibleShape; }
31 namespace accessibility { class AccessibleShapeInfo; }
32 namespace accessibility { class AccessibleShapeTreeInfo; }
33 namespace com::sun::star::drawing { class XShape; }
34 namespace com::sun::star::uno { template <typename > class Reference; }
35 
36 namespace accessibility {
37 
41 typedef int ShapeTypeId;
42 
46 typedef AccessibleShape* (*tCreateFunction)
47  (const AccessibleShapeInfo& rShapeInfo,
48  const AccessibleShapeTreeInfo& rShapeTreeInfo,
49  ShapeTypeId nId);
50 
56 {
57  ShapeTypeId mnShapeTypeId;
58  OUString msServiceName;
61  ShapeTypeId nId, const OUString& sName, tCreateFunction aFunction)
62  : mnShapeTypeId (nId),
63  msServiceName (sName),
64  maCreateFunction (aFunction)
65  {}
67  : mnShapeTypeId (-1),
68  msServiceName (),
69  maCreateFunction (nullptr)
70  {}
71 };
72 
79 {
80 public:
81  enum { UNKNOWN_SHAPE_TYPE = 0 };
82 
88  static ShapeTypeHandler& Instance();
89 
97  ShapeTypeId GetTypeId (const OUString& aServiceName) const;
98 
108  ShapeTypeId GetTypeId (const css::uno::Reference<
109  css::drawing::XShape>& rxShape) const;
110 
122  CreateAccessibleObject (
123  const AccessibleShapeInfo& rShapeInfo,
124  const AccessibleShapeTreeInfo& rShapeTreeInfo) const;
125 
135  void AddShapeTypeList (int nDescriptorCount,
136  ShapeTypeDescriptor const aDescriptorList[]);
137 
141  static OUString CreateAccessibleBaseName (
142  const css::uno::Reference< css::drawing::XShape >& rxShape);
143 
144 private:
145  // Declare default constructor, copy constructor, destructor, and
146  // assignment operation protected so that no one accidentally creates a
147  // second instance of this singleton class or deletes it.
149  ShapeTypeHandler (const ShapeTypeHandler& aHandler); // never implemented, this is a singleton class
150  ShapeTypeHandler& operator= (const ShapeTypeHandler& aHandler); // never implemented, this is a singleton class
151 
155  ~ShapeTypeHandler();
156 
159 
165  ::std::vector<ShapeTypeDescriptor> maShapeTypeDescriptorList;
166 
170  typedef std::unordered_map<OUString,ShapeTypeId> tServiceNameToSlotId;
171  mutable tServiceNameToSlotId maServiceNameToSlotId;
172 
181  SVX_DLLPRIVATE long GetSlotId (const OUString& aServiceName) const;
182 
191  SVX_DLLPRIVATE long GetSlotId (const css::uno::Reference<
192  css::drawing::XShape>& rxShape) const;
193 };
194 
195 } // end of namespace accessible
196 
197 #endif
198 
199 /* 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...
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...