merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / unocore / unoevtlstnr.cxx
blobf72aace753544ac0aa0ae71716fce48610a1cb20
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: unoevtlstnr.cxx,v $
10 * $Revision: 1.6 $
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_sw.hxx"
35 #include <unoevtlstnr.hxx>
36 #include <tools/debug.hxx>
37 #include <com/sun/star/lang/EventObject.hpp>
38 #include <com/sun/star/lang/XEventListener.hpp>
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::lang;
43 using namespace ::com::sun::star::uno;
45 /* -----------------22.04.99 11:24-------------------
47 * --------------------------------------------------*/
48 SV_IMPL_PTRARR(SwEvtLstnrArray, XEventListenerPtr);
50 /*-- 22.04.99 11:24:59---------------------------------------------------
52 -----------------------------------------------------------------------*/
53 SwEventListenerContainer::SwEventListenerContainer( uno::XInterface* _pxParent) :
54 pListenerArr(0),
55 pxParent(_pxParent)
58 /*-- 22.04.99 11:24:59---------------------------------------------------
60 -----------------------------------------------------------------------*/
61 SwEventListenerContainer::~SwEventListenerContainer()
63 if(pListenerArr && pListenerArr->Count())
65 pListenerArr->DeleteAndDestroy(0, pListenerArr->Count());
67 delete pListenerArr;
69 /*-- 22.04.99 11:24:59---------------------------------------------------
71 -----------------------------------------------------------------------*/
72 void SwEventListenerContainer::AddListener(const uno::Reference< lang::XEventListener > & rxListener)
74 if(!pListenerArr)
75 pListenerArr = new SwEvtLstnrArray;
76 uno::Reference< lang::XEventListener > * pInsert = new uno::Reference< lang::XEventListener > ;
77 *pInsert = rxListener;
78 pListenerArr->Insert(pInsert, pListenerArr->Count());
80 /*-- 22.04.99 11:25:00---------------------------------------------------
82 -----------------------------------------------------------------------*/
83 sal_Bool SwEventListenerContainer::RemoveListener(const uno::Reference< lang::XEventListener > & rxListener)
85 if(!pListenerArr)
86 return sal_False;
87 else
89 lang::XEventListener* pLeft = rxListener.get();
90 for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
92 XEventListenerPtr pElem = pListenerArr->GetObject(i);
93 lang::XEventListener* pRight = pElem->get();
94 if(pLeft == pRight)
96 pListenerArr->Remove(i);
97 delete pElem;
98 return sal_True;
102 return sal_False;
104 /*-- 22.04.99 11:25:00---------------------------------------------------
106 -----------------------------------------------------------------------*/
107 void SwEventListenerContainer::Disposing()
109 if(!pListenerArr)
110 return;
112 lang::EventObject aObj(pxParent);
113 for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
115 XEventListenerPtr pElem = pListenerArr->GetObject(i);
116 (*pElem)->disposing(aObj);
118 pListenerArr->DeleteAndDestroy(0, pListenerArr->Count());