1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/AccessibleGraphicShape.hxx>
22 #include <svx/ShapeTypeHandler.hxx>
23 #include <svx/SvxShapeTypes.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdmodel.hxx>
27 #include <cppuhelper/queryinterface.hxx>
29 using namespace ::accessibility
;
30 using namespace ::com::sun::star
;
31 using namespace ::com::sun::star::accessibility
;
34 AccessibleGraphicShape::AccessibleGraphicShape (
35 const AccessibleShapeInfo
& rShapeInfo
,
36 const AccessibleShapeTreeInfo
& rShapeTreeInfo
)
37 : AccessibleShape (rShapeInfo
, rShapeTreeInfo
)
44 AccessibleGraphicShape::~AccessibleGraphicShape()
49 OUString SAL_CALL
AccessibleGraphicShape::getAccessibleImageDescription()
50 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
53 return m_pShape
->GetTitle();
54 return AccessibleShape::getAccessibleDescription ();
60 sal_Int32 SAL_CALL
AccessibleGraphicShape::getAccessibleImageHeight()
61 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
63 return AccessibleShape::getSize().Height
;
69 sal_Int32 SAL_CALL
AccessibleGraphicShape::getAccessibleImageWidth()
70 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
72 return AccessibleShape::getSize().Width
;
76 com::sun::star::uno::Any SAL_CALL
77 AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type
& rType
)
78 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
80 ::com::sun::star::uno::Any aReturn
= AccessibleShape::queryInterface (rType
);
81 if ( ! aReturn
.hasValue())
82 aReturn
= ::cppu::queryInterface (rType
,
83 static_cast<XAccessibleImage
*>(this));
90 AccessibleGraphicShape::acquire()
93 AccessibleShape::acquire ();
99 AccessibleGraphicShape::release()
102 AccessibleShape::release ();
107 AccessibleGraphicShape::getImplementationName()
108 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
110 return OUString("AccessibleGraphicShape");
116 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
117 AccessibleGraphicShape::getSupportedServiceNames()
118 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
121 // Get list of supported service names from base class...
122 uno::Sequence
<OUString
> aServiceNames
=
123 AccessibleShape::getSupportedServiceNames();
124 sal_Int32
nCount (aServiceNames
.getLength());
126 // ...and add additional names.
127 aServiceNames
.realloc (nCount
+ 1);
128 aServiceNames
[nCount
] = "com.sun.star.drawing.AccessibleGraphicShape";
130 return aServiceNames
;
134 uno::Sequence
<uno::Type
> SAL_CALL
135 AccessibleGraphicShape::getTypes()
136 throw (uno::RuntimeException
, std::exception
)
138 // Get list of types from the context base implementation...
139 uno::Sequence
<uno::Type
> aTypeList (AccessibleShape::getTypes());
140 // ...and add the additional type for the component.
141 long nTypeCount
= aTypeList
.getLength();
142 aTypeList
.realloc (nTypeCount
+ 1);
143 const uno::Type aImageType
=
144 cppu::UnoType
<XAccessibleImage
>::get();
145 aTypeList
[nTypeCount
] = aImageType
;
153 /// Create the base name of this object, i.e. the name without appended number.
155 AccessibleGraphicShape::CreateAccessibleBaseName()
156 throw (::com::sun::star::uno::RuntimeException
)
160 ShapeTypeId nShapeType
= ShapeTypeHandler::Instance().GetTypeId (mxShape
);
163 case DRAWING_GRAPHIC_OBJECT
:
164 sName
= "GraphicObjectShape";
168 sName
= "UnknownAccessibleGraphicShape";
169 uno::Reference
<drawing::XShapeDescriptor
> xDescriptor (mxShape
, uno::UNO_QUERY
);
170 if (xDescriptor
.is())
171 sName
+= ": " + xDescriptor
->getShapeType();
177 OUString
AccessibleGraphicShape::CreateAccessibleDescription()
178 throw (::com::sun::star::uno::RuntimeException
)
180 //Don't use the same information for accessible name and accessible description.
183 sDesc
= m_pShape
->GetTitle();
184 if (!sDesc
.isEmpty())
186 return CreateAccessibleBaseName();
189 // Return this object's role.
190 sal_Int16 SAL_CALL
AccessibleGraphicShape::getAccessibleRole()
191 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
193 if( m_pShape
->GetModel()->GetImageMapForObject(m_pShape
) != NULL
)
194 return AccessibleRole::IMAGE_MAP
;
196 return AccessibleShape::getAccessibleRole();
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */