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 #if !defined(AFX_ACCHYPERTEXT_H__6DC133B6_03DB_42C6_A9B7_27AF4FDA00CA__INCLUDED_)
30 #define AFX_ACCHYPERTEXT_H__6DC133B6_03DB_42C6_A9B7_27AF4FDA00CA__INCLUDED_
31 
32 #if _MSC_VER > 1000
33 #pragma once
34 #endif // _MSC_VER > 1000
35 
36 #include "resource.h"       // main symbols
37 
38 
39 #include <com/sun/star/accessibility/XAccessible.hpp>
40 #include <com/sun/star/accessibility/XAccessibleHypertext.hpp>
41 #include "AccTextBase.h"
42 
43 /**
44  * CAccHypertext implements IAccessibleHypertext interface.
45  */
46 class ATL_NO_VTABLE CAccHypertext :
47             public CComObjectRoot,
48             public CComCoClass<CAccHypertext,&CLSID_AccHypertext>,
49             public IAccessibleHypertext,
50             public CAccTextBase
51 {
52 public:
53     CAccHypertext()
54     {
55             }
56     ~CAccHypertext()
57     {
58             }
59 
60     BEGIN_COM_MAP(CAccHypertext)
61     COM_INTERFACE_ENTRY(IAccessibleText)
62     COM_INTERFACE_ENTRY(IAccessibleHypertext)
63     COM_INTERFACE_ENTRY(IUNOXWrapper)
64     COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,_SmartQI)
65     END_COM_MAP()
66 
67     static HRESULT WINAPI _SmartQI(void* pv,
68                                    REFIID iid, void** ppvObject, DWORD)
69     {
70         return ((CAccHypertext*)pv)->SmartQI(iid,ppvObject);
71     }
72 
73     HRESULT SmartQI(REFIID iid, void** ppvObject)
74     {
75         if( m_pOuterUnknown )
76             return OuterQueryInterface(iid,ppvObject);
77         return E_FAIL;
78     }
79 
80     DECLARE_REGISTRY_RESOURCEID(IDR_AccHypertext)
81 
82     // IAccessibleHypertext
83 public:
84     // IAccessibleText
85 
86     // Adds a text selection.
87     STDMETHOD(addSelection)(long startOffset, long endOffset);//, unsigned char * success)
88 
89     // Gets text attributes.
90     STDMETHOD(get_attributes)(long offset, long * startOffset, long * endOffset, BSTR * textAttributes);
91 
92     // Gets caret offset.
93     STDMETHOD(get_caretOffset)(long * offset);
94 
95     // Gets total number of characters.
96     STDMETHOD(get_characterCount)(long * nCharacters);
97 
98     // Gets bounding rect containing the glyph(s) representing the character
99     // at the specified text offset
100     STDMETHOD(get_characterExtents)(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height);
101 
102     // Gets number of active non-contiguous selections.
103     STDMETHOD(get_nSelections)(long * nSelections);
104 
105     // Gets bounding rect for the glyph at a certain point.
106     STDMETHOD(get_offsetAtPoint)(long x, long y, IA2CoordinateType coordType, long * offset);
107 
108     // Gets character offsets of N-th active text selection.
109     STDMETHOD(get_selection)(long selection, long * startOffset, long * endOffset);
110 
111     // Gets a range of text by offset NOTE: returned string may be longer
112     // than endOffset-startOffset bytes if text contains multi-byte characters.
113     STDMETHOD(get_text)(long startOffset, long endOffset, BSTR * text);
114 
115     // Gets a specified amount of text that ends before a specified offset.
116     STDMETHOD(get_textBeforeOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text);
117 
118     // Gets a specified amount of text that spans the specified offset.
119     STDMETHOD(get_textAfterOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text);
120 
121     // Gets a specified amount of text that starts after a specified offset.
122     STDMETHOD(get_textAtOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text);
123 
124     // Unselects a range of text.
125     STDMETHOD(removeSelection)(long selectionIndex);
126 
127     // Moves text caret.
128     STDMETHOD(setCaretOffset)(long offset);
129 
130     // Changes the bounds of an existing selection.
131     STDMETHOD(setSelection)(long selectionIndex, long startOffset, long endOffset);
132 
133     // Gets total number of characters.
134     // NOTE: this may be different than the total number of bytes required
135     // to store the text, if the text contains multi-byte characters.
136     STDMETHOD(get_nCharacters)(long * nCharacters);
137 
138     // Makes specific part of string visible on screen.
139     STDMETHOD(scrollSubstringTo)(long startIndex, long endIndex,enum IA2ScrollType scrollType);
140 
141     STDMETHOD(scrollSubstringToPoint)(long startIndex, long endIndex,enum IA2CoordinateType coordinateType, long x, long y );
142 
143     STDMETHOD(get_newText)( IA2TextSegment *newText);
144 
145     STDMETHOD(get_oldText)( IA2TextSegment *oldText);
146 
147     //IAccessibleHypertext
148 
149     // Gets the number of hyperlink.
150     STDMETHOD(get_nHyperlinks)(long *hyperlinkCount);
151 
152     // Gets the hyperlink object via specified index.
153     STDMETHOD(get_hyperlink)(long index,IAccessibleHyperlink **hyperlink);
154 
155     // Returns the index of the hyperlink that is associated with this
156     // character index.
157     STDMETHOD(get_hyperlinkIndex)(long charIndex, long *hyperlinkIndex);
158 
159     // Overide of IUNOXWrapper.
160     STDMETHOD(put_XInterface)(long pXInterface);
161 
162 private:
163 
164     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleHypertext> pHyperText;
165 
166 };
167 
168 #endif // !defined(AFX_ACCHYPERTEXT_H__6DC133B6_03DB_42C6_A9B7_27AF4FDA00CA__INCLUDED_)
169