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 <utility>
30#include <vector>
31
32namespace accessibility { class AccessibleShape; }
33namespace accessibility { class AccessibleShapeInfo; }
34namespace accessibility { class AccessibleShapeTreeInfo; }
35namespace com::sun::star::drawing { class XShape; }
36namespace com::sun::star::uno { template <typename > class Reference; }
37
38namespace accessibility {
39
43typedef int ShapeTypeId;
44
49 (const AccessibleShapeInfo& rShapeInfo,
50 const AccessibleShapeTreeInfo& rShapeTreeInfo,
52
58{
60 OUString msServiceName;
63 ShapeTypeId nId, OUString sName, tCreateFunction aFunction)
65 msServiceName (std::move(sName)),
66 maCreateFunction (aFunction)
67 {}
69 : mnShapeTypeId (-1),
70 maCreateFunction (nullptr)
71 {}
72};
73
80{
81public:
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
145private:
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
157
160
166 ::std::vector<ShapeTypeDescriptor> maShapeTypeDescriptorList;
167
171 typedef std::unordered_map<OUString,ShapeTypeId> tServiceNameToSlotId;
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: */
@descr This class is a container for the information specific for a single shape that is passed to th...
This class bundles all information that is passed down the tree of accessible shapes so that each sha...
@descr This class is a singleton that has the purpose to transform between service names of shapes an...
ShapeTypeId GetTypeId(const css::uno::Reference< css::drawing::XShape > &rxShape) const
Determines the type id of the specified shape.
static ShapeTypeHandler * instance
Pointer to the only instance of this class.
SVX_DLLPRIVATE tools::Long GetSlotId(const css::uno::Reference< css::drawing::XShape > &rxShape) const
Determine the slot id of the specified shape type.
std::unordered_map< OUString, ShapeTypeId > tServiceNameToSlotId
This hash map allows the fast look up of a type descriptor for a given service name.
ShapeTypeHandler(const ShapeTypeHandler &aHandler)
::std::vector< ShapeTypeDescriptor > maShapeTypeDescriptorList
List of shape type descriptors.
tServiceNameToSlotId maServiceNameToSlotId
OUString sName
int ShapeTypeId
Use an integer to represent shape type ids.
rtl::Reference< AccessibleShape >(* tCreateFunction)(const AccessibleShapeInfo &rShapeInfo, const AccessibleShapeTreeInfo &rShapeTreeInfo, ShapeTypeId nId)
Define the function type for creating accessible objects for given service names.
Reference
long Long
sal_Int16 nId
Each shape type is described by listing its id, its service name and a function which creates a new a...
ShapeTypeDescriptor(ShapeTypeId nId, OUString sName, tCreateFunction aFunction)
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30