Line data Source code
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 <svx/AccessibleGraphicShape.hxx>
21 :
22 : #include <svx/ShapeTypeHandler.hxx>
23 : #include <svx/SvxShapeTypes.hxx>
24 : #include <svx/svdobj.hxx>
25 : #include <svx/svdmodel.hxx>
26 :
27 : #include <cppuhelper/queryinterface.hxx>
28 :
29 : using namespace ::accessibility;
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::accessibility;
32 :
33 : // internal
34 0 : AccessibleGraphicShape::AccessibleGraphicShape (
35 : const AccessibleShapeInfo& rShapeInfo,
36 : const AccessibleShapeTreeInfo& rShapeTreeInfo)
37 0 : : AccessibleShape (rShapeInfo, rShapeTreeInfo)
38 : {
39 0 : }
40 :
41 :
42 :
43 :
44 0 : AccessibleGraphicShape::~AccessibleGraphicShape()
45 : {
46 0 : }
47 :
48 : // XAccessibleImage
49 0 : OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription()
50 : throw (::com::sun::star::uno::RuntimeException, std::exception)
51 : {
52 0 : if (m_pShape)
53 0 : return m_pShape->GetTitle();
54 0 : return AccessibleShape::getAccessibleDescription ();
55 : }
56 :
57 :
58 :
59 :
60 0 : sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight()
61 : throw (::com::sun::star::uno::RuntimeException, std::exception)
62 : {
63 0 : return AccessibleShape::getSize().Height;
64 : }
65 :
66 :
67 :
68 :
69 0 : sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth()
70 : throw (::com::sun::star::uno::RuntimeException, std::exception)
71 : {
72 0 : return AccessibleShape::getSize().Width;
73 : }
74 :
75 : // XInterface
76 : com::sun::star::uno::Any SAL_CALL
77 0 : AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType)
78 : throw (::com::sun::star::uno::RuntimeException, std::exception)
79 : {
80 0 : ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType);
81 0 : if ( ! aReturn.hasValue())
82 0 : aReturn = ::cppu::queryInterface (rType,
83 0 : static_cast<XAccessibleImage*>(this));
84 0 : return aReturn;
85 : }
86 :
87 :
88 :
89 : void SAL_CALL
90 0 : AccessibleGraphicShape::acquire()
91 : throw ()
92 : {
93 0 : AccessibleShape::acquire ();
94 0 : }
95 :
96 :
97 :
98 : void SAL_CALL
99 0 : AccessibleGraphicShape::release()
100 : throw ()
101 : {
102 0 : AccessibleShape::release ();
103 0 : }
104 :
105 : // XServiceInfo
106 : OUString SAL_CALL
107 0 : AccessibleGraphicShape::getImplementationName()
108 : throw (::com::sun::star::uno::RuntimeException, std::exception)
109 : {
110 0 : return OUString("AccessibleGraphicShape");
111 : }
112 :
113 :
114 :
115 :
116 : ::com::sun::star::uno::Sequence< OUString> SAL_CALL
117 0 : AccessibleGraphicShape::getSupportedServiceNames()
118 : throw (::com::sun::star::uno::RuntimeException, std::exception)
119 : {
120 0 : ThrowIfDisposed ();
121 : // Get list of supported service names from base class...
122 : uno::Sequence<OUString> aServiceNames =
123 0 : AccessibleShape::getSupportedServiceNames();
124 0 : sal_Int32 nCount (aServiceNames.getLength());
125 :
126 : // ...and add additional names.
127 0 : aServiceNames.realloc (nCount + 1);
128 0 : aServiceNames[nCount] = "com.sun.star.drawing.AccessibleGraphicShape";
129 :
130 0 : return aServiceNames;
131 : }
132 :
133 : // XTypeProvider
134 : uno::Sequence<uno::Type> SAL_CALL
135 0 : AccessibleGraphicShape::getTypes()
136 : throw (uno::RuntimeException, std::exception)
137 : {
138 : // Get list of types from the context base implementation...
139 0 : uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes());
140 : // ...and add the additional type for the component.
141 0 : long nTypeCount = aTypeList.getLength();
142 0 : aTypeList.realloc (nTypeCount + 1);
143 : const uno::Type aImageType =
144 0 : cppu::UnoType<XAccessibleImage>::get();
145 0 : aTypeList[nTypeCount] = aImageType;
146 :
147 0 : return aTypeList;
148 : }
149 :
150 :
151 :
152 :
153 : /// Create the base name of this object, i.e. the name without appended number.
154 : OUString
155 0 : AccessibleGraphicShape::CreateAccessibleBaseName()
156 : throw (::com::sun::star::uno::RuntimeException)
157 : {
158 0 : OUString sName;
159 :
160 0 : ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
161 0 : switch (nShapeType)
162 : {
163 : case DRAWING_GRAPHIC_OBJECT:
164 0 : sName = "GraphicObjectShape";
165 0 : break;
166 :
167 : default:
168 0 : sName = "UnknownAccessibleGraphicShape";
169 0 : uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
170 0 : if (xDescriptor.is())
171 0 : sName += ": " + xDescriptor->getShapeType();
172 : }
173 :
174 0 : return sName;
175 : }
176 :
177 0 : OUString AccessibleGraphicShape::CreateAccessibleDescription()
178 : throw (::com::sun::star::uno::RuntimeException)
179 : {
180 : //Don't use the same information for accessible name and accessible description.
181 0 : OUString sDesc;
182 0 : if (m_pShape)
183 0 : sDesc = m_pShape->GetTitle();
184 0 : if (!sDesc.isEmpty())
185 0 : return sDesc;
186 0 : return CreateAccessibleBaseName();
187 : }
188 :
189 : // Return this object's role.
190 0 : sal_Int16 SAL_CALL AccessibleGraphicShape::getAccessibleRole()
191 : throw (::com::sun::star::uno::RuntimeException, std::exception)
192 : {
193 0 : if( m_pShape->GetModel()->GetImageMapForObject(m_pShape) != NULL )
194 0 : return AccessibleRole::IMAGE_MAP;
195 : else
196 0 : return AccessibleShape::getAccessibleRole();
197 390 : }
198 :
199 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|