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 #if !defined(AFX_ACCHYPERLINK_H__59DA79A5_A895_43DB_9495_2B2049CF5C65__INCLUDED_)
23 #define AFX_ACCHYPERLINK_H__59DA79A5_A895_43DB_9495_2B2049CF5C65__INCLUDED_
24 
25 #if _MSC_VER > 1000
26 #pragma once
27 #endif // _MSC_VER > 1000
28 
29 #include "resource.h"       // main symbols
30 
31 
32 #include <com/sun/star/accessibility/XAccessibleHyperlink.hpp>
33 #include "AccActionBase.h"
34 #include "UNOXWrapper.h"
35 
36 /**
37  * CAccHyperLink implements IAccessibleHyperlink interface.
38  */
39 class ATL_NO_VTABLE CAccHyperLink :
40             public CComObjectRoot,
41             public CComCoClass<CAccHyperLink,&CLSID_AccHyperLink>,
42             public IAccessibleHyperlink,
43             public CAccActionBase
44 {
45 public:
CAccHyperLink()46     CAccHyperLink()
47     {
48             }
~CAccHyperLink()49     ~CAccHyperLink()
50     {
51             }
52 
53     BEGIN_COM_MAP(CAccHyperLink)
COM_INTERFACE_ENTRY(IAccessibleAction)54     COM_INTERFACE_ENTRY(IAccessibleAction)
55     COM_INTERFACE_ENTRY(IAccessibleHyperlink)
56     COM_INTERFACE_ENTRY(IUNOXWrapper)
57     END_COM_MAP()
58 
59     DECLARE_REGISTRY_RESOURCEID(IDR_AccHyperLink)
60 
61     static HRESULT WINAPI _SmartQI(void* pv,
62                                    REFIID iid, void** ppvObject, DWORD)
63     {
64         return ((CAccHyperLink*)pv)->SmartQI(iid,ppvObject);
65     }
66 
SmartQI(REFIID iid,void ** ppvObject)67     HRESULT SmartQI(REFIID iid, void** ppvObject)
68     {
69         if( m_pOuterUnknown )
70             return OuterQueryInterface(iid,ppvObject);
71         return E_FAIL;
72     }
73 
74     // IAccessibleHyperlink
75 public:
76     // IAccessibleAction
77 
78     // Returns the number of action.
79     STDMETHOD(nActions)(/*[out,retval]*/long* nActions);
80 
81     // Performs specified action on the object.
82     STDMETHOD(doAction)(/* [in] */ long actionIndex);
83 
84     // get the action name
85     STDMETHOD(get_name)( long actionIndex, BSTR __RPC_FAR *name);
86 
87     // get the localized action name
88     STDMETHOD(get_localizedName)( long actionIndex, BSTR __RPC_FAR *localizedName);
89 
90     // Gets description of specified action.
91     STDMETHOD(get_description)(long actionIndex,BSTR __RPC_FAR *description);
92 
93     // Returns key binding object (if any) associated with specified action
94     // key binding is string.
95     // e.g. "alt+d" (like IAccessible::get_accKeyboardShortcut).
96     STDMETHOD(get_keyBinding)(
97         /* [in] */ long actionIndex,
98         /* [in] */ long nMaxBinding,
99         /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding,
100         /* [retval][out] */ long __RPC_FAR *nBinding);
101 
102     // IAccessibleHyperlink
103 
104     // get an object, e.g. BSTR or image object, that is overloaded with link behavior
105     STDMETHOD(get_anchor)(/* [in] */ long index,
106                                      /* [retval][out] */ VARIANT __RPC_FAR *anchor);
107 
108     // get an object representing the target of the link, usually a BSTR of the URI
109     STDMETHOD(get_anchorTarget)(/* [in] */ long index,
110                                            /* [retval][out] */ VARIANT __RPC_FAR *anchorTarget);
111 
112     // Returns the index at which the textual representation of the
113     // hyperlink (group) starts.
114     STDMETHOD(get_startIndex)(/* [retval][out] */ long __RPC_FAR *index);
115 
116     // Returns the index at which the textual rerpesentation of the
117     // hyperlink (group) ends.
118     STDMETHOD(get_endIndex)(/* [retval][out] */ long __RPC_FAR *index);
119 
120     // Returns whether the document referenced by this links is still valid.
121     STDMETHOD(get_valid)(/* [retval][out] */ boolean __RPC_FAR *valid);
122 
123     // Overide of IUNOXWrapper.
124     STDMETHOD(put_XInterface)(long pXInterface);
125 
126     // Overide of IUNOXWrapper.
127     STDMETHOD(put_XSubInterface)(long pXSubInterface);
128 
129 private:
130 
131     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleHyperlink> pRXLink;
132 
GetXInterface()133     inline com::sun::star::accessibility::XAccessibleHyperlink* GetXInterface()
134     {
135         return pRXLink.get();
136     }
137 
138 };
139 
140 #endif // !defined(AFX_ACCHYPERLINK_H__59DA79A5_A895_43DB_9495_2B2049CF5C65__INCLUDED_)
141