Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccEditableText.h
blob244dc626bb5a39c362838a9d5a560466e5924d96
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 <sal/config.h>
24 #include <string_view>
26 #include "Resource.h"
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
29 #include "UNOXWrapper.h"
31 /**
32 * CAccEditableText implements IAccessibleEditableText interface.
34 class CAccEditableText :
35 public CComObjectRoot,
36 public CComCoClass<CAccEditableText,&CLSID_AccEditableText>,
37 public IAccessibleEditableText,
38 public CUNOXWrapper
40 public:
41 CAccEditableText()
45 virtual ~CAccEditableText()
50 BEGIN_COM_MAP(CAccEditableText)
51 COM_INTERFACE_ENTRY(IAccessibleEditableText)
52 COM_INTERFACE_ENTRY(IUNOXWrapper)
53 COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_)
54 #if defined __clang__
55 #pragma clang diagnostic push
56 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
57 #endif
58 END_COM_MAP()
59 #if defined __clang__
60 #pragma clang diagnostic pop
61 #endif
63 static HRESULT WINAPI SmartQI_(void* pv,
64 REFIID iid, void** ppvObject, DWORD_PTR)
66 return static_cast<CAccEditableText*>(pv)->SmartQI(iid,ppvObject);
69 HRESULT SmartQI(REFIID iid, void** ppvObject)
71 if( m_pOuterUnknown )
72 return OuterQueryInterface(iid,ppvObject);
73 return E_FAIL;
76 DECLARE_NO_REGISTRY()
78 public:
79 // IAccessibleEditableText
81 // Copies a range of text to the clipboard.
82 STDMETHOD(copyText)(long startOffset, long endOffset) override;
84 // Deletes a range of text.
85 STDMETHOD(deleteText)(long startOffset, long endOffset) override;
87 // Inserts text at a specified offset.
88 STDMETHOD(insertText)(long offset, BSTR * text) override;
90 // Cuts a range of text to the clipboard.
91 STDMETHOD(cutText)(long startOffset, long endOffset) override;
93 // Pastes text from clipboard at specified offset.
94 STDMETHOD(pasteText)(long offset) override;
96 // Replaces range of text with new text.
97 STDMETHOD(replaceText)(long startOffset, long endOffset, BSTR * text) override;
100 // Sets attributes of range of text.
101 STDMETHOD(setAttributes)(long startOffset, long endOffset, BSTR * attributes) override;
103 // Override of IUNOXWrapper.
104 STDMETHOD(put_XInterface)(hyper pXInterface) override;
106 private:
108 css::uno::Reference<css::accessibility::XAccessibleEditableText> pRXEdtTxt;
110 static void get_AnyFromOLECHAR(std::u16string_view ouName, const OUString &ouValue, css::uno::Any &rAny);
112 css::accessibility::XAccessibleEditableText* GetXInterface()
114 return pRXEdtTxt.get();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */