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