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