AccObjectWinManager.hxx 6.02 KB
Newer Older
1 2 3
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
4
 *
5 6 7
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * 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 12 13 14 15 16 17 18
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
19

20 21
#ifndef INCLUDED_WINACCESSIBILITY_INC_ACCOBJECTWINMANAGER_HXX
#define INCLUDED_WINACCESSIBILITY_INC_ACCOBJECTWINMANAGER_HXX
22 23 24

#include <com/sun/star/accessibility/XAccessible.hpp>
#include <map>
25 26 27
#if !defined WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
28
#include <windows.h>
29
#include <rtl/ref.hxx>
30
#include "ResIDGenerator.hxx"
31 32 33 34 35

#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#endif
36
#include  <UAccCOM.h>
37 38 39
#if defined __clang__
#pragma clang diagnostic pop
#endif
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

class ResIDGenerator;
class AccObjectManagerAgent;
class AccEventListener;
class AccObject;

/*******************************************************************
AccObjectWinManager complete the functions:
1. Insert, delete,query,update Acc objects
2. Create, delete,fire AccEventLister, the lifecycle of AccEventListener is as same as
   Acc Object
 3.Return COM interface for AT,by the call back in salframe
 4.Pass accessible information to Acc objects
 *******************************************************************/
class AccObjectWinManager
{
    friend class AccObjectManagerAgent;

private:
59 60 61
    typedef std::map<void*, AccObject> XIdToAccObjHash;
    typedef std::map<HWND, void*> XHWNDToXAccHash;
    typedef std::map<const long, AccObject*> XResIdToAccObjHash;
62

63
    typedef std::map<const HWND, css::accessibility::XAccessible* >
64
        XHWNDToDocumentHash;
65 66 67 68 69 70 71 72 73 74 75 76 77

    //XAccessible to AccObject
    XIdToAccObjHash  XIdAccList;

    //HWND to All XAccessible pointer
    XHWNDToXAccHash  HwndXAcc;

    //id_Child to AccObject
    XResIdToAccObjHash XResIdAccList;

    //for file name support
    XHWNDToDocumentHash XHWNDDocList;

78
    css::accessibility::XAccessible* oldFocus;
79 80 81 82

    AccObjectManagerAgent*   pAgent;
    ResIDGenerator ResIdGen;

83
    AccObjectWinManager(AccObjectManagerAgent* Agent=nullptr);
84 85 86

private:
    long ImpleGenerateResID();
87
    AccObject* GetAccObjByXAcc( css::accessibility::XAccessible* pXAcc);
88 89 90

    AccObject* GetTopWindowAccObj(HWND hWnd);

91
    css::accessibility::XAccessible* GetAccDocByHWND(HWND hWnd);
92

93 94 95
    static void DeleteAccListener( AccObject* pAccObj );
    static void InsertAccChildNode(AccObject* pCurObj,AccObject* pParentObj,HWND pWnd);
    static void DeleteAccChildNode(AccObject* pChild);
96
    void       DeleteFromHwndXAcc(css::accessibility::XAccessible const * pXAcc );
97
    int  UpdateAccSelection(css::accessibility::XAccessible* pXAcc);
98

99
    ::rtl::Reference<AccEventListener> CreateAccEventListener(
100
            css::accessibility::XAccessible* pXAcc);
101 102
public:
    virtual ~AccObjectWinManager();
103 104
    bool InsertAccObj( css::accessibility::XAccessible* pXAcc,css::accessibility::XAccessible* pParentXAcc,HWND pWnd);
    bool InsertChildrenAccObj( css::accessibility::XAccessible* pXAcc,HWND pWnd=nullptr);
105 106
    void DeleteAccObj( css::accessibility::XAccessible* pXAcc );
    void DeleteChildrenAccObj(css::accessibility::XAccessible* pAccObj);
107

108
    bool NotifyAccEvent( css::accessibility::XAccessible* pXAcc,short state = 0 );
109

110
    LRESULT Get_ToATInterface(HWND hWnd, long lParam, WPARAM wParam);
111

112 113 114 115
    void  DecreaseState( css::accessibility::XAccessible* pXAcc,unsigned short pState );
    void  IncreaseState( css::accessibility::XAccessible* pXAcc,unsigned short pState );
    void  UpdateState( css::accessibility::XAccessible* pXAcc );
    void  SetLocation( css::accessibility::XAccessible* pXAcc,
116 117
                       long Top = 0,long left = 0,long width = 0,long height = 0);

118 119
    void  SetValue( css::accessibility::XAccessible* pXAcc, css::uno::Any pAny );
    void  UpdateValue( css::accessibility::XAccessible* pXAcc );
120

121 122
    void  SetAccName( css::accessibility::XAccessible* pXAcc, css::uno::Any newName);
    void  UpdateAccName( css::accessibility::XAccessible* pXAcc );
123

124 125
    void  SetDescription( css::accessibility::XAccessible* pXAcc, css::uno::Any newDesc );
    void UpdateDescription( css::accessibility::XAccessible* pXAcc );
126

127
    void  SetRole( css::accessibility::XAccessible* pXAcc, long Role );
128

129 130
    void  UpdateAccFocus( css::accessibility::XAccessible* newFocus );
    void  UpdateAction( css::accessibility::XAccessible* pXAcc );
131

132
    static bool IsContainer( css::accessibility::XAccessible* pAccessible );
133

134
    IMAccessible* GetIMAccByXAcc( css::accessibility::XAccessible* pXAcc );
135 136
    IMAccessible* GetIAccessibleFromResID(long resID);

137 138 139
    void NotifyDestroy( css::accessibility::XAccessible* pXAcc );
    css::accessibility::XAccessible* GetParentXAccessible( css::accessibility::XAccessible* pXAcc );
    short GetParentRole( css::accessibility::XAccessible* pXAcc );
140

141
    void SaveTopWindowHandle(HWND hWnd, css::accessibility::XAccessible* pXAcc);
142

143
    void UpdateChildState(css::accessibility::XAccessible* pXAcc);
144

145
    bool IsSpecialToolboItem(css::accessibility::XAccessible* pXAcc);
146

147
    static short GetRole(css::accessibility::XAccessible* pXAcc);
148

149 150
    css::accessibility::XAccessible* GetAccDocByAccTopWin( css::accessibility::XAccessible* pXAcc );
    bool IsTopWinAcc( css::accessibility::XAccessible* pXAcc );
151

152
    static bool IsStateManageDescendant(css::accessibility::XAccessible* pAccessible);
153 154

};
155
#endif // INCLUDED_WINACCESSIBILITY_INC_ACCOBJECTWINMANAGER_HXX
156 157

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */