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 #ifndef INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_ACCEDITABLETEXT_H
21 #define INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_ACCEDITABLETEXT_H
22 
23 #include "Resource.h"
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
26 #include "UNOXWrapper.h"
27 
28 /**
29  * CAccEditableText implements IAccessibleEditableText interface.
30  */
31 class CAccEditableText :
32             public CComObjectRoot,
33             public CComCoClass<CAccEditableText,&CLSID_AccEditableText>,
34             public IAccessibleEditableText,
35             public CUNOXWrapper
36 {
37 public:
CAccEditableText()38     CAccEditableText()
39     {
40 
41     }
~CAccEditableText()42     virtual ~CAccEditableText()
43     {
44 
45     }
46 
47     BEGIN_COM_MAP(CAccEditableText)
COM_INTERFACE_ENTRY(IAccessibleEditableText)48     COM_INTERFACE_ENTRY(IAccessibleEditableText)
49     COM_INTERFACE_ENTRY(IUNOXWrapper)
50     COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_)
51 #if defined __clang__
52 #pragma clang diagnostic push
53 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
54 #endif
55     END_COM_MAP()
56 #if defined __clang__
57 #pragma clang diagnostic pop
58 #endif
59 
60     static HRESULT WINAPI SmartQI_(void* pv,
61                                    REFIID iid, void** ppvObject, DWORD_PTR)
62     {
63         return static_cast<CAccEditableText*>(pv)->SmartQI(iid,ppvObject);
64     }
65 
SmartQI(REFIID iid,void ** ppvObject)66     HRESULT SmartQI(REFIID iid, void** ppvObject)
67     {
68         if( m_pOuterUnknown )
69             return OuterQueryInterface(iid,ppvObject);
70         return E_FAIL;
71     }
72 
73     DECLARE_NO_REGISTRY()
74 
75 public:
76     // IAccessibleEditableText
77 
78     // Copies a range of text to the clipboard.
79     STDMETHOD(copyText)(long startOffset, long endOffset) override;
80 
81     // Deletes a range of text.
82     STDMETHOD(deleteText)(long startOffset, long endOffset) override;
83 
84     // Inserts text at a specified offset.
85     STDMETHOD(insertText)(long offset, BSTR * text) override;
86 
87     // Cuts a range of text to the clipboard.
88     STDMETHOD(cutText)(long startOffset, long endOffset) override;
89 
90     // Pastes text from clipboard at specified offset.
91     STDMETHOD(pasteText)(long offset) override;
92 
93     // Replaces range of text with new text.
94     STDMETHOD(replaceText)(long startOffset, long endOffset, BSTR * text) override;
95 
96 
97     // Sets attributes of range of text.
98     STDMETHOD(setAttributes)(long startOffset, long endOffset, BSTR * attributes) override;
99 
100     // Override of IUNOXWrapper.
101     STDMETHOD(put_XInterface)(hyper pXInterface) override;
102 
103 private:
104 
105     css::uno::Reference<css::accessibility::XAccessibleEditableText> pRXEdtTxt;
106 
107     static void get_AnyFromOLECHAR(const OUString &ouName, const OUString &ouValue, css::uno::Any &rAny);
108 
GetXInterface()109     css::accessibility::XAccessibleEditableText* GetXInterface()
110     {
111         return pRXEdtTxt.get();
112     }
113 };
114 
115 #endif // INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_ACCEDITABLETEXT_H
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
118