1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright IBM Corporation 2010.
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org.  If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #include "stdafx.h"
30 #include "UAccCOM2.h"
31 #include "AccImage.h"
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
34 
35 using namespace com::sun::star::accessibility;
36 using namespace com::sun::star::uno;
37 
38 /**
39    * Get description.
40    * @param description Variant to get description.
41    * @return Result.
42 */
43 STDMETHODIMP CAccImage::get_description(BSTR * description)
44 {
45 
46 	CHECK_ENABLE_INF
47 
48     ENTER_PROTECTED_BLOCK
49 
50     // #CHECK#
51     if (description == NULL)
52         return E_INVALIDARG;
53     if( !pRXImg.is() )
54         return E_FAIL;
55 
56     ::rtl::OUString ouStr = GetXInterface()->getAccessibleImageDescription();
57     SAFE_SYSFREESTRING(*description);
58     *description = SysAllocString((OLECHAR*)ouStr.getStr());
59 
60     return S_OK;
61 
62     LEAVE_PROTECTED_BLOCK
63 }
64 
65 STDMETHODIMP CAccImage::get_imagePosition(
66     /* [in] */ enum IA2CoordinateType,
67     /* [out] */ long __RPC_FAR *,
68     /* [retval][out] */ long __RPC_FAR *)
69 {
70     return E_NOTIMPL;
71 }
72 
73 STDMETHODIMP CAccImage::get_imageSize(
74     /* [out] */ long __RPC_FAR *,
75     /* [retval][out] */ long __RPC_FAR *)
76 {
77     return E_NOTIMPL;
78 }
79 
80 /**
81    * Put UNO interface.
82    * @param pXInterface UNO interface.
83    * @return Result.
84 */
85 STDMETHODIMP CAccImage::put_XInterface(long pXInterface)
86 {
87 
88 
89     ENTER_PROTECTED_BLOCK
90 
91     CUNOXWrapper::put_XInterface(pXInterface);
92     //special query.
93     if(pUNOInterface == NULL)
94         return E_FAIL;
95 
96     Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
97     if( !pRContext.is() )
98     {
99         return E_FAIL;
100     }
101     Reference<XAccessibleImage> pRXI(pRContext,UNO_QUERY);
102     if( !pRXI.is() )
103         pRXImg = NULL;
104     else
105         pRXImg = pRXI.get();
106     return S_OK;
107 
108     LEAVE_PROTECTED_BLOCK
109 }
110