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
26 #include <com/sun/star/drawing/XShape.hpp>
27 #include <com/sun/star/drawing/XShapeDescriptor.hpp>
28 #include <comphelper/sequence.hxx>
29 #include <cppuhelper/queryinterface.hxx>
30
31 using namespace ::accessibility;
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::accessibility;
34
35 // internal
AccessibleGraphicShape(const AccessibleShapeInfo & rShapeInfo,const AccessibleShapeTreeInfo & rShapeTreeInfo)36 AccessibleGraphicShape::AccessibleGraphicShape (
37 const AccessibleShapeInfo& rShapeInfo,
38 const AccessibleShapeTreeInfo& rShapeTreeInfo)
39 : AccessibleShape (rShapeInfo, rShapeTreeInfo)
40 {
41 }
42
43
~AccessibleGraphicShape()44 AccessibleGraphicShape::~AccessibleGraphicShape()
45 {
46 }
47
48 // XAccessibleImage
getAccessibleImageDescription()49 OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription()
50 {
51 if (m_pShape)
52 return m_pShape->GetTitle();
53 return AccessibleShape::getAccessibleDescription ();
54 }
55
56
getAccessibleImageHeight()57 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight()
58 {
59 return AccessibleShape::getSize().Height;
60 }
61
62
getAccessibleImageWidth()63 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth()
64 {
65 return AccessibleShape::getSize().Width;
66 }
67
68 // XInterface
69 css::uno::Any SAL_CALL
queryInterface(const css::uno::Type & rType)70 AccessibleGraphicShape::queryInterface (const css::uno::Type & rType)
71 {
72 css::uno::Any aReturn = AccessibleShape::queryInterface (rType);
73 if ( ! aReturn.hasValue())
74 aReturn = ::cppu::queryInterface (rType,
75 static_cast<XAccessibleImage*>(this));
76 return aReturn;
77 }
78
79
80 void SAL_CALL
acquire()81 AccessibleGraphicShape::acquire()
82 noexcept
83 {
84 AccessibleShape::acquire ();
85 }
86
87
88 void SAL_CALL
release()89 AccessibleGraphicShape::release()
90 noexcept
91 {
92 AccessibleShape::release ();
93 }
94
95 // XServiceInfo
96 OUString SAL_CALL
getImplementationName()97 AccessibleGraphicShape::getImplementationName()
98 {
99 return "AccessibleGraphicShape";
100 }
101
102
103 css::uno::Sequence< OUString> SAL_CALL
getSupportedServiceNames()104 AccessibleGraphicShape::getSupportedServiceNames()
105 {
106 ThrowIfDisposed ();
107 const css::uno::Sequence<OUString> vals { "com.sun.star.drawing.AccessibleGraphicShape" };
108 return comphelper::concatSequences(AccessibleShape::getSupportedServiceNames(), vals);
109 }
110
111 // XTypeProvider
112 uno::Sequence<uno::Type> SAL_CALL
getTypes()113 AccessibleGraphicShape::getTypes()
114 {
115 // Get list of types from the context base implementation...
116 return comphelper::concatSequences(AccessibleShape::getTypes(),
117 uno::Sequence { cppu::UnoType<XAccessibleImage>::get() });
118 }
119
120
121 /// Create the base name of this object, i.e. the name without appended number.
122 OUString
CreateAccessibleBaseName()123 AccessibleGraphicShape::CreateAccessibleBaseName()
124 {
125 OUString sName;
126
127 ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
128 switch (nShapeType)
129 {
130 case DRAWING_GRAPHIC_OBJECT:
131 sName = "GraphicObjectShape";
132 break;
133
134 default:
135 sName = "UnknownAccessibleGraphicShape";
136 uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape);
137 if (xDescriptor.is())
138 sName += ": " + xDescriptor->getShapeType();
139 }
140
141 return sName;
142 }
143
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
145