Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccText.h
blobeba821aae84d11e779a64c8b280ad5fc67c612df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "Resource.h" // main symbols
24 #include "AccTextBase.h"
26 /**
27 * CAccText implements IAccessibleText interface.
29 class ATL_NO_VTABLE CAccText :
30 public CComObjectRoot,
31 public CComCoClass<CAccText,&CLSID_AccText>,
32 public IAccessibleText,
33 public CAccTextBase
35 public:
36 CAccText()
40 BEGIN_COM_MAP(CAccText)
41 COM_INTERFACE_ENTRY(IAccessibleText)
42 COM_INTERFACE_ENTRY(IUNOXWrapper)
43 COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_)
44 #if defined __clang__
45 #pragma clang diagnostic push
46 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
47 #endif
48 END_COM_MAP()
49 #if defined __clang__
50 #pragma clang diagnostic pop
51 #endif
53 static HRESULT WINAPI SmartQI_(void* pv,
54 REFIID iid, void** ppvObject, DWORD_PTR)
56 return static_cast<CAccText*>(pv)->SmartQI(iid,ppvObject);
59 HRESULT SmartQI(REFIID iid, void** ppvObject)
61 if( m_pOuterUnknown )
62 return OuterQueryInterface(iid,ppvObject);
63 return E_FAIL;
66 DECLARE_NO_REGISTRY()
68 public:
69 // IAccessibleText
71 // Adds a text selection.
72 STDMETHOD(addSelection)(long startOffset, long endOffset) override;//, unsigned char * success);
74 // Gets text attributes.
75 STDMETHOD(get_attributes)(long offset, long * startOffset, long * endOffset, BSTR * textAttributes) override;
77 // Gets caret offset.
78 STDMETHOD(get_caretOffset)(long * offset) override;
80 // Gets bounding rect containing the glyph(s) representing the character
81 // at the specified text offset
82 STDMETHOD(get_characterExtents)(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height) override;
84 // Gets number of active non-contiguous selections.
85 STDMETHOD(get_nSelections)(long * nSelections) override;
87 // Gets bounding rect for the glyph at a certain point.
88 STDMETHOD(get_offsetAtPoint)(long x, long y, IA2CoordinateType coordType, long * offset) override;
90 // Gets character offsets of N-th active text selection.
91 STDMETHOD(get_selection)(long selection, long * startOffset, long * endOffset) override;
93 // Gets a range of text by offset NOTE: returned string may be longer
94 // than endOffset-startOffset bytes if text contains multi-byte characters.
95 STDMETHOD(get_text)(long startOffset, long endOffset, BSTR * text) override;
97 // Gets a specified amount of text that ends before a specified offset.
98 STDMETHOD(get_textBeforeOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) override;
100 // Gets a specified amount of text that spans the specified offset.
101 STDMETHOD(get_textAfterOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) override;
103 // Gets a specified amount of text that starts after a specified offset.
104 STDMETHOD(get_textAtOffset)(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) override;
106 // Unselects a range of text.
107 STDMETHOD(removeSelection)(long selectionIndex) override;//, unsigned char * success);
109 // Moves text caret.
110 STDMETHOD(setCaretOffset)(long offset) override;//, unsigned char * success);
112 // Changes the bounds of an existing selection.
113 STDMETHOD(setSelection)(long selectionIndex, long startOffset, long endOffset) override;//, unsigned char * success);
115 // Gets total number of characters.
116 // NOTE: this may be different than the total number of bytes required
117 // to store the text, if the text contains multi-byte characters.
118 STDMETHOD(get_nCharacters)(long * nCharacters) override;
120 // Makes specific part of string visible on screen.
121 STDMETHOD(scrollSubstringTo)(long startIndex, long endIndex,enum IA2ScrollType scrollType) override;
122 STDMETHOD(scrollSubstringToPoint)(long startIndex, long endIndex,enum IA2CoordinateType coordinateType, long x, long y ) override;
124 STDMETHOD(get_newText)( IA2TextSegment *newText) override;
126 STDMETHOD(get_oldText)( IA2TextSegment *oldText) override;
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */