1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include "stdafx.h"
23 #include "UAccCOM2.h"
24 #include "AccImage.h"
25 #include <com/sun/star/accessibility/XAccessible.hpp>
26 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
27 
28 using namespace com::sun::star::accessibility;
29 using namespace com::sun::star::uno;
30 
31 /**
32    * Get description.
33    * @param description Variant to get description.
34    * @return Result.
35 */
get_description(BSTR * description)36 STDMETHODIMP CAccImage::get_description(BSTR * description)
37 {
38 
39 	CHECK_ENABLE_INF
40 
41     ENTER_PROTECTED_BLOCK
42 
43     // #CHECK#
44     if (description == NULL)
45         return E_INVALIDARG;
46     if( !pRXImg.is() )
47         return E_FAIL;
48 
49     ::rtl::OUString ouStr = GetXInterface()->getAccessibleImageDescription();
50     SAFE_SYSFREESTRING(*description);
51     *description = SysAllocString((OLECHAR*)ouStr.getStr());
52 
53     return S_OK;
54 
55     LEAVE_PROTECTED_BLOCK
56 }
57 
get_imagePosition(enum IA2CoordinateType,long __RPC_FAR *,long __RPC_FAR *)58 STDMETHODIMP CAccImage::get_imagePosition(
59     /* [in] */ enum IA2CoordinateType,
60     /* [out] */ long __RPC_FAR *,
61     /* [retval][out] */ long __RPC_FAR *)
62 {
63     return E_NOTIMPL;
64 }
65 
get_imageSize(long __RPC_FAR *,long __RPC_FAR *)66 STDMETHODIMP CAccImage::get_imageSize(
67     /* [out] */ long __RPC_FAR *,
68     /* [retval][out] */ long __RPC_FAR *)
69 {
70     return E_NOTIMPL;
71 }
72 
73 /**
74    * Put UNO interface.
75    * @param pXInterface UNO interface.
76    * @return Result.
77 */
put_XInterface(long pXInterface)78 STDMETHODIMP CAccImage::put_XInterface(long pXInterface)
79 {
80 
81 
82     ENTER_PROTECTED_BLOCK
83 
84     CUNOXWrapper::put_XInterface(pXInterface);
85     //special query.
86     if(pUNOInterface == NULL)
87         return E_FAIL;
88 
89     Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
90     if( !pRContext.is() )
91     {
92         return E_FAIL;
93     }
94     Reference<XAccessibleImage> pRXI(pRContext,UNO_QUERY);
95     if( !pRXI.is() )
96         pRXImg = NULL;
97     else
98         pRXImg = pRXI.get();
99     return S_OK;
100 
101     LEAVE_PROTECTED_BLOCK
102 }
103