update dev300-m58
[ooovba.git] / comphelper / source / misc / accessibleeventbuffer.cxx
blobe292bbb0c3b84273e1890a5964e2494b5ec03797
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibleeventbuffer.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_comphelper.hxx"
34 #include "comphelper/accessibleeventbuffer.hxx"
36 #include "com/sun/star/uno/Reference.hxx"
37 #include "com/sun/star/uno/RuntimeException.hpp"
38 #include "com/sun/star/uno/Sequence.hxx"
39 #include "com/sun/star/uno/XInterface.hpp"
40 #include "com/sun/star/accessibility/AccessibleEventObject.hpp"
41 #include "com/sun/star/accessibility/XAccessibleEventListener.hpp"
42 #include "osl/diagnose.h"
43 #include "rtl/textenc.h"
44 #include "rtl/ustring.hxx"
45 #include "sal/types.h"
47 namespace css = ::com::sun::star;
49 using comphelper::AccessibleEventBuffer;
51 struct AccessibleEventBuffer::Entry
53 inline Entry(::css::accessibility::AccessibleEventObject const & rEvent,
54 ::css::uno::Sequence< ::css::uno::Reference<
55 ::css::uno::XInterface > > const & rListeners):
56 m_aEvent(rEvent), m_aListeners(rListeners) {}
58 ::css::accessibility::AccessibleEventObject m_aEvent;
60 ::css::uno::Sequence<
61 ::css::uno::Reference< ::css::uno::XInterface > > m_aListeners;
64 AccessibleEventBuffer::AccessibleEventBuffer()
67 AccessibleEventBuffer::AccessibleEventBuffer(
68 AccessibleEventBuffer const & rOther):
69 m_aEntries(rOther.m_aEntries)
72 AccessibleEventBuffer::~AccessibleEventBuffer()
75 AccessibleEventBuffer
76 AccessibleEventBuffer::operator =(AccessibleEventBuffer const & rOther)
78 m_aEntries = rOther.m_aEntries;
79 return *this;
82 void AccessibleEventBuffer::addEvent(
83 ::css::accessibility::AccessibleEventObject const & rEvent,
84 ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > >
85 const & rListeners)
87 m_aEntries.push_back(Entry(rEvent, rListeners));
90 void AccessibleEventBuffer::sendEvents() const
92 for (Entries::const_iterator aIt(m_aEntries.begin());
93 aIt != m_aEntries.end(); ++aIt)
94 for (::sal_Int32 i = 0; i < aIt->m_aListeners.getLength(); ++i)
96 ::css::uno::Reference<
97 ::css::accessibility::XAccessibleEventListener > xListener(
98 aIt->m_aListeners[i], ::css::uno::UNO_QUERY);
99 if (xListener.is())
102 xListener->notifyEvent(aIt->m_aEvent);
104 catch (::css::uno::RuntimeException & rEx)
106 OSL_TRACE(
107 "comphelper::AccessibleEventBuffer::sendEvents:"
108 " caught %s\n",
109 ::rtl::OUStringToOString(
110 rEx.Message, RTL_TEXTENCODING_UTF8).getStr());