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>
25 using namespace ::accessibility
;
26 using namespace ::rtl
;
27 using namespace ::com::sun::star
;
28 using namespace ::com::sun::star::accessibility
;
30 //===== internal ============================================================
32 AccessibleGraphicShape::AccessibleGraphicShape (
33 const AccessibleShapeInfo
& rShapeInfo
,
34 const AccessibleShapeTreeInfo
& rShapeTreeInfo
)
35 : AccessibleShape (rShapeInfo
, rShapeTreeInfo
)
42 AccessibleGraphicShape::~AccessibleGraphicShape (void)
49 //===== XAccessibleImage ====================================================
51 OUString SAL_CALL
AccessibleGraphicShape::getAccessibleImageDescription (void)
52 throw (::com::sun::star::uno::RuntimeException
)
54 return AccessibleShape::getAccessibleDescription ();
60 sal_Int32 SAL_CALL
AccessibleGraphicShape::getAccessibleImageHeight (void)
61 throw (::com::sun::star::uno::RuntimeException
)
63 return AccessibleShape::getSize().Height
;
69 sal_Int32 SAL_CALL
AccessibleGraphicShape::getAccessibleImageWidth (void)
70 throw (::com::sun::star::uno::RuntimeException
)
72 return AccessibleShape::getSize().Width
;
78 //===== XInterface ==========================================================
80 com::sun::star::uno::Any SAL_CALL
81 AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type
& rType
)
82 throw (::com::sun::star::uno::RuntimeException
)
84 ::com::sun::star::uno::Any aReturn
= AccessibleShape::queryInterface (rType
);
85 if ( ! aReturn
.hasValue())
86 aReturn
= ::cppu::queryInterface (rType
,
87 static_cast<XAccessibleImage
*>(this));
94 AccessibleGraphicShape::acquire (void)
97 AccessibleShape::acquire ();
103 AccessibleGraphicShape::release (void)
106 AccessibleShape::release ();
112 //===== XServiceInfo ========================================================
115 AccessibleGraphicShape::getImplementationName (void)
116 throw (::com::sun::star::uno::RuntimeException
)
118 return OUString("AccessibleGraphicShape");
124 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
125 AccessibleGraphicShape::getSupportedServiceNames (void)
126 throw (::com::sun::star::uno::RuntimeException
)
129 // Get list of supported service names from base class...
130 uno::Sequence
<OUString
> aServiceNames
=
131 AccessibleShape::getSupportedServiceNames();
132 sal_Int32
nCount (aServiceNames
.getLength());
134 // ...and add additional names.
135 aServiceNames
.realloc (nCount
+ 1);
136 static const OUString
sAdditionalServiceName ("com.sun.star.drawing.AccessibleGraphicShape");
137 aServiceNames
[nCount
] = sAdditionalServiceName
;
139 return aServiceNames
;
145 //===== XTypeProvider ===================================================
147 uno::Sequence
<uno::Type
> SAL_CALL
148 AccessibleGraphicShape::getTypes (void)
149 throw (uno::RuntimeException
)
151 // Get list of types from the context base implementation...
152 uno::Sequence
<uno::Type
> aTypeList (AccessibleShape::getTypes());
153 // ...and add the additional type for the component.
154 long nTypeCount
= aTypeList
.getLength();
155 aTypeList
.realloc (nTypeCount
+ 1);
156 const uno::Type aImageType
=
157 ::getCppuType((const uno::Reference
<XAccessibleImage
>*)0);
158 aTypeList
[nTypeCount
] = aImageType
;
166 /// Create the base name of this object, i.e. the name without appended number.
168 AccessibleGraphicShape::CreateAccessibleBaseName (void)
169 throw (::com::sun::star::uno::RuntimeException
)
173 ShapeTypeId nShapeType
= ShapeTypeHandler::Instance().GetTypeId (mxShape
);
176 case DRAWING_GRAPHIC_OBJECT
:
177 sName
= "GraphicObjectShape";
181 sName
= "UnknownAccessibleGraphicShape";
182 uno::Reference
<drawing::XShapeDescriptor
> xDescriptor (mxShape
, uno::UNO_QUERY
);
183 if (xDescriptor
.is())
184 sName
+= ": " + xDescriptor
->getShapeType();
193 AccessibleGraphicShape::CreateAccessibleDescription (void)
194 throw (::com::sun::star::uno::RuntimeException
)
196 return CreateAccessibleName ();
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */