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