Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / source / UAccCOM / UAccCOM.cxx
blob2914e16c36f7d626103df536450069c362601373
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 #include "stdafx.h"
21 #include "Resource.h"
22 #include <initguid.h>
23 #include <UAccCOM.h>
24 #include <accHelper.hxx>
26 #if defined __clang__
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored \
29 "-Wextra-tokens" // "#endif !_MIDL_USE_GUIDDEF_" in midl-generated code
30 #endif
31 #include <UAccCOM_i.c>
32 #include <ia2_api_all_i.c>
33 #if defined __clang__
34 #pragma clang diagnostic pop
35 #endif
37 #include "MAccessible.h"
38 #include "EnumVariant.h"
39 #include "UNOXWrapper.h"
40 #include "AccComponent.h"
41 #include "AccRelation.h"
42 #include "AccAction.h"
43 #include "AccText.h"
44 #include "AccEditableText.h"
45 #include "AccImage.h"
46 #include "AccValue.h"
47 #include "AccTable.h"
48 #include "AccTableCell.h"
49 #include "AccHyperLink.h"
50 #include "AccHypertext.h"
52 CComModule _Module;
54 BEGIN_OBJECT_MAP(ObjectMap)
55 OBJECT_ENTRY(CLSID_MAccessible, CMAccessible)
56 OBJECT_ENTRY(CLSID_EnumVariant, CEnumVariant)
57 OBJECT_ENTRY(CLSID_AccComponent, CAccComponent)
58 OBJECT_ENTRY(CLSID_AccRelation, CAccRelation)
59 OBJECT_ENTRY(CLSID_AccAction, CAccAction)
60 OBJECT_ENTRY(CLSID_AccText, CAccText)
61 OBJECT_ENTRY(CLSID_AccEditableText, CAccEditableText)
62 OBJECT_ENTRY(CLSID_AccImage, CAccImage)
63 OBJECT_ENTRY(CLSID_AccValue, CAccValue)
64 OBJECT_ENTRY(CLSID_AccTable, CAccTable)
65 OBJECT_ENTRY(CLSID_AccTableCell, CAccTableCell)
66 OBJECT_ENTRY(CLSID_AccHyperLink, CAccHyperLink)
67 OBJECT_ENTRY(CLSID_AccHypertext, CAccHypertext)
68 #if defined __clang__
69 #pragma clang diagnostic push
70 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
71 #endif
72 END_OBJECT_MAP()
73 #if defined __clang__
74 #pragma clang diagnostic pop
75 #endif
77 // DLL Entry Point
79 extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
81 if (dwReason == DLL_PROCESS_ATTACH)
83 _Module.Init(ObjectMap, hInstance, &LIBID_UACCCOMLib);
84 DisableThreadLibraryCalls(hInstance);
86 else if (dwReason == DLL_PROCESS_DETACH)
87 _Module.Term();
88 return TRUE; // ok
91 // Used to determine whether the DLL can be unloaded by OLE
93 STDAPI DllCanUnloadNow() { return (_Module.GetLockCount() == 0) ? S_OK : E_FAIL; }
95 // Returns a class factory to create an object of the requested type
97 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
99 return _Module.GetClassObject(rclsid, riid, ppv);
102 IMAccessible* UAccCOMCreateInstance()
104 IMAccessible* pIMA = nullptr;
105 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMA);
106 return (S_OK == hr) ? pIMA : nullptr;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */