2000-09-18 15:33:13 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* $RCSfile: InterfaceContainer.cxx,v $
|
|
|
|
|
*
|
2001-07-11 09:34:00 +00:00
|
|
|
|
* $Revision: 1.6 $
|
2000-09-18 15:33:13 +00:00
|
|
|
|
*
|
2001-07-11 09:34:00 +00:00
|
|
|
|
* last change: $Author: oj $ $Date: 2001-07-11 10:33:59 $
|
2000-09-18 15:33:13 +00:00
|
|
|
|
*
|
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
|
* either of the following licenses
|
|
|
|
|
*
|
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
|
*
|
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
|
*
|
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
|
* =============================================
|
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
|
* =================================================
|
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
|
*
|
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
|
* obligations concerning the Software.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
|
*
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef _FRM_INTERFACE_CONTAINER_HXX_
|
|
|
|
|
#include "InterfaceContainer.hxx"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
|
|
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_EVENTATTACHERMGR_HXX_
|
|
|
|
|
#include <comphelper/eventattachermgr.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
|
#include <comphelper/types.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_ENUMHELPER_HXX_
|
|
|
|
|
#include <comphelper/enumhelper.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_PROPERTY_HXX_
|
|
|
|
|
#include <comphelper/property.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_CONTAINER_HXX_
|
|
|
|
|
#include <comphelper/container.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
2000-10-19 10:52:20 +00:00
|
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _FRM_PROPERTY_HRC_
|
|
|
|
|
#include "property.hrc"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _FRM_SERVICES_HXX_
|
|
|
|
|
#include "services.hxx"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _FRM_RESOURCE_HRC_
|
|
|
|
|
#include "frm_resource.hrc"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _FRM_RESOURCE_HXX_
|
|
|
|
|
#include "frm_resource.hxx"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
|
|
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_IO_XMARKABLESTREAM_HPP_
|
|
|
|
|
#include <com/sun/star/io/XMarkableStream.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_IO_WRONGFORMATEXCEPTION_HPP_
|
|
|
|
|
#include <com/sun/star/io/WrongFormatException.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
|
namespace frm
|
|
|
|
|
{
|
|
|
|
|
//.........................................................................
|
2000-11-23 08:42:45 +00:00
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
|
using namespace ::com::sun::star::script;
|
|
|
|
|
using namespace ::com::sun::star::io;
|
|
|
|
|
using namespace ::com::sun::star::form;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
OInterfaceContainer::OInterfaceContainer(
|
2000-11-23 08:42:45 +00:00
|
|
|
|
const Reference<XMultiServiceFactory>& _rxFactory,
|
2000-09-18 15:33:13 +00:00
|
|
|
|
::osl::Mutex& _rMutex,
|
2000-11-23 08:42:45 +00:00
|
|
|
|
const Type& _rElementType)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
:m_rMutex(_rMutex)
|
|
|
|
|
,m_aContainerListeners(_rMutex)
|
|
|
|
|
,m_aElementType(_rElementType)
|
|
|
|
|
,m_xServiceFactory(_rxFactory)
|
|
|
|
|
{
|
2000-10-19 10:52:20 +00:00
|
|
|
|
m_xEventAttacher = ::comphelper::createEventAttacherManager(m_xServiceFactory);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void OInterfaceContainer::disposing()
|
|
|
|
|
{
|
|
|
|
|
// dispose aller elemente
|
|
|
|
|
for (sal_Int32 i = m_aItems.size(); i > 0; --i)
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(m_aItems[i - 1], UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
xSet->removePropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
|
|
|
|
|
// Eventverkn<6B>pfungen aufheben
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef xIfc(xSet, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
m_xEventAttacher->detach(i - 1, xIfc);
|
|
|
|
|
m_xEventAttacher->removeEntry(i - 1);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XComponent> xComponent(xSet, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xComponent.is())
|
|
|
|
|
xComponent->dispose();
|
|
|
|
|
}
|
|
|
|
|
m_aMap.clear();
|
|
|
|
|
m_aItems.clear();
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
EventObject aEvt(static_cast<XContainer*>(this));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
m_aContainerListeners.disposeAndClear(aEvt);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XPersistObject
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::writeEvents(const Reference<XObjectOutputStream>& _rxOutStream)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XMarkableStream> xMark(_rxOutStream, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
sal_Int32 nMark = xMark->createMark();
|
|
|
|
|
|
|
|
|
|
sal_Int32 nObjLen = 0;
|
|
|
|
|
_rxOutStream->writeLong(nObjLen);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPersistObject> xScripts(m_xEventAttacher, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xScripts.is())
|
|
|
|
|
xScripts->write(_rxOutStream);
|
|
|
|
|
|
|
|
|
|
// feststellen der Laenge
|
|
|
|
|
nObjLen = xMark->offsetToMark(nMark) - 4;
|
|
|
|
|
xMark->jumpToMark(nMark);
|
|
|
|
|
_rxOutStream->writeLong(nObjLen);
|
|
|
|
|
xMark->jumpToFurthest();
|
|
|
|
|
xMark->deleteMark(nMark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::readEvents(const Reference<XObjectInputStream>& _rxInStream, sal_Int32 nCount)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
if (nCount)
|
|
|
|
|
{
|
|
|
|
|
// Scripting Info lesen
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
sal_Int32 nObjLen = _rxInStream->readLong();
|
|
|
|
|
if (nObjLen)
|
|
|
|
|
{
|
|
|
|
|
sal_Int32 nMark = xMark->createMark();
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPersistObject> xObj(m_xEventAttacher, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xObj.is())
|
|
|
|
|
xObj->read(_rxInStream);
|
|
|
|
|
xMark->jumpToMark(nMark);
|
|
|
|
|
_rxInStream->skipBytes(nObjLen);
|
|
|
|
|
xMark->deleteMark(nMark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attachement lesen
|
|
|
|
|
for (sal_Int32 i = 0; i < nCount; i++)
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef xIfc(m_aItems[i], UNO_QUERY);
|
|
|
|
|
Reference<XPropertySet> xSet(xIfc, UNO_QUERY);
|
|
|
|
|
Any aHelper;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aHelper <<= xSet;
|
|
|
|
|
m_xEventAttacher->attach( i, xIfc, aHelper );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// neuen EventManager
|
2000-10-19 10:52:20 +00:00
|
|
|
|
m_xEventAttacher = ::comphelper::createEventAttacherManager(m_xServiceFactory);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::write( const Reference< XObjectOutputStream >& _rxOutStream ) throw(IOException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
sal_Int32 nLen = m_aItems.size();
|
|
|
|
|
|
|
|
|
|
// schreiben der laenge
|
|
|
|
|
_rxOutStream->writeLong(nLen);
|
|
|
|
|
|
|
|
|
|
if (nLen)
|
|
|
|
|
{
|
|
|
|
|
// 1. Version
|
|
|
|
|
_rxOutStream->writeShort(0x0001);
|
|
|
|
|
|
|
|
|
|
// 2. Objekte
|
|
|
|
|
for (sal_Int32 i = 0; i < nLen; i++)
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPersistObject> xObj(m_aItems[i], UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xObj.is())
|
|
|
|
|
_rxOutStream->writeObject(xObj);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ::com::sun::star::chaos::Error
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Scripts
|
|
|
|
|
writeEvents(_rxOutStream);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& _rxInStream ) throw(IOException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
|
|
|
|
|
// after ::read the object is expected to be in the state it was when ::write was called, so we have
|
|
|
|
|
// to empty ourself here
|
|
|
|
|
// FS - 71598 - 12.01.00
|
|
|
|
|
while (getCount())
|
|
|
|
|
removeByIndex(0);
|
|
|
|
|
|
|
|
|
|
// Schreibt nur in Abhaengigkeit der L<>nge
|
|
|
|
|
sal_Int32 nLen = _rxInStream->readLong();
|
|
|
|
|
|
|
|
|
|
if (nLen)
|
|
|
|
|
{
|
|
|
|
|
// 1. Version
|
|
|
|
|
sal_uInt16 nVersion = _rxInStream->readShort();
|
|
|
|
|
|
|
|
|
|
// 2. Objekte
|
|
|
|
|
for (sal_Int32 i = 0; i < nLen; i++)
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPersistObject> xObj;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
xObj = _rxInStream->readObject();
|
|
|
|
|
}
|
2000-11-23 08:42:45 +00:00
|
|
|
|
catch(WrongFormatException& e)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
e; // make compiler happy
|
|
|
|
|
// the object could not be read
|
|
|
|
|
xObj = NULL;
|
|
|
|
|
// create a dummy starform (so the readEvents below will assign the events to the right controls)
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xObj = Reference<XPersistObject> (m_xServiceFactory->createInstance(FRM_COMPONENT_HIDDENCONTROL), UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
DBG_ASSERT(xObj.is(), "OInterfaceContainer::read : could not create a substitute for the unknown object !");
|
|
|
|
|
if (!xObj.is())
|
|
|
|
|
// couldn't handle it ...
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
|
|
// set some properties describing what we did
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xObjProps(xObj, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xObjProps.is())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xObjProps->setPropertyValue(PROPERTY_NAME, makeAny(FRM_RES_STRING(RID_STR_CONTROL_SUBSTITUTED_NAME)));
|
|
|
|
|
xObjProps->setPropertyValue(PROPERTY_TAG, makeAny(FRM_RES_STRING(RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN)));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
2000-11-23 08:42:45 +00:00
|
|
|
|
catch(Exception&)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 72133 - 09.02.00 - FS
|
|
|
|
|
}
|
2000-11-23 08:42:45 +00:00
|
|
|
|
catch(Exception&)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
// unsere Map leeren
|
|
|
|
|
while (!m_aItems.empty())
|
|
|
|
|
removeElementsNoEvents(0);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// und die Exception nach aussen
|
2000-09-18 15:33:13 +00:00
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xObj.is())
|
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any aElement = xObj->queryInterface(m_aElementType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (aElement.hasValue())
|
|
|
|
|
insert(m_aItems.size(), *static_cast<const InterfaceRef*>(aElement.getValue()), sal_False);
|
|
|
|
|
else
|
|
|
|
|
; // form konnte nicht gelesen werden; nyi
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readEvents(_rxInStream, nLen);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XContainer
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::addContainerListener(const Reference<XContainerListener>& _rxListener) throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_aContainerListeners.addInterface(_rxListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::removeContainerListener(const Reference<XContainerListener>& _rxListener) throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_aContainerListeners.removeInterface(_rxListener);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XEventListener
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::disposing(const EventObject& _rSource) throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
|
|
|
|
|
OInterfaceArray::iterator j = find(m_aItems.begin(), m_aItems.end(), _rSource.Source);
|
|
|
|
|
if (j != m_aItems.end())
|
|
|
|
|
{
|
|
|
|
|
OInterfaceMap::iterator i = m_aMap.begin();
|
|
|
|
|
while (i != m_aMap.end() && (*i).second != _rSource.Source)
|
|
|
|
|
++i;
|
|
|
|
|
|
|
|
|
|
m_aMap.erase(i);
|
|
|
|
|
m_aItems.erase(j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XPropertyChangeListener
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void OInterfaceContainer::propertyChange(const PropertyChangeEvent& evt)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2001-07-11 09:34:00 +00:00
|
|
|
|
if (evt.PropertyName == PROPERTY_NAME)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
OInterfaceMap::iterator i = find(m_aMap.begin(), m_aMap.end(),
|
2000-10-19 10:52:20 +00:00
|
|
|
|
pair<const ::rtl::OUString, InterfaceRef >(::comphelper::getString(evt.OldValue),evt.Source));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (i != m_aMap.end())
|
|
|
|
|
{
|
|
|
|
|
InterfaceRef xCorrectType((*i).second);
|
|
|
|
|
m_aMap.erase(i);
|
2000-10-19 10:52:20 +00:00
|
|
|
|
m_aMap.insert(pair<const ::rtl::OUString, InterfaceRef >(::comphelper::getString(evt.NewValue),xCorrectType));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XElementAccess
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
sal_Bool SAL_CALL OInterfaceContainer::hasElements() throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
return !m_aMap.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Type SAL_CALL OInterfaceContainer::getElementType() throw(RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
return m_aElementType;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XEnumerationAccess
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XEnumeration> SAL_CALL OInterfaceContainer::createEnumeration() throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
2000-11-23 08:42:45 +00:00
|
|
|
|
return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XNameAccess
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any SAL_CALL OInterfaceContainer::getByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
pair <OInterfaceMap::iterator,
|
|
|
|
|
OInterfaceMap::iterator> aPair = m_aMap.equal_range(_rName);
|
|
|
|
|
|
|
|
|
|
if (aPair.first == aPair.second)
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw NoSuchElementException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
return Any(&(*aPair.first).second, m_aElementType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
StringSequence SAL_CALL OInterfaceContainer::getElementNames() throw(RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
StringSequence aNameList(m_aItems.size());
|
|
|
|
|
::rtl::OUString* pStringArray = aNameList.getArray();
|
|
|
|
|
|
|
|
|
|
for (OInterfaceMap::const_iterator i = m_aMap.begin(); i != m_aMap.end(); ++i, ++pStringArray)
|
|
|
|
|
{
|
|
|
|
|
*pStringArray = (*i).first;
|
|
|
|
|
}
|
|
|
|
|
return aNameList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
sal_Bool SAL_CALL OInterfaceContainer::hasByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
pair <OInterfaceMap::iterator,
|
|
|
|
|
OInterfaceMap::iterator> aPair = m_aMap.equal_range(_rName);
|
|
|
|
|
return aPair.first != aPair.second;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XIndexAccess
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
sal_Int32 OInterfaceContainer::getCount() throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
return m_aItems.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any OInterfaceContainer::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
if (_nIndex < 0 || _nIndex >= m_aItems.size())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IndexOutOfBoundsException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
return Any(&m_aItems[_nIndex], m_aElementType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void OInterfaceContainer::insert(sal_Int32 _nIndex, const InterfaceRef& xElement, sal_Bool bEvents) throw( IllegalArgumentException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
// das richtige Interface besorgen
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any aCorrectType = xElement->queryInterface(m_aElementType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (!aCorrectType.hasValue())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
InterfaceRef xCorrectType = *static_cast<const InterfaceRef*>(aCorrectType.getValue());
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sName;
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
{
|
|
|
|
|
if (!hasProperty(PROPERTY_NAME, xSet))
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any aValue = xSet->getPropertyValue(PROPERTY_NAME);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aValue >>= sName;
|
|
|
|
|
xSet->addPropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
}
|
|
|
|
|
else
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
if (_nIndex > m_aItems.size()) // ermitteln des tatsaechlichen Indexs
|
|
|
|
|
{
|
|
|
|
|
_nIndex = m_aItems.size();
|
|
|
|
|
m_aItems.push_back(xCorrectType);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_aItems.insert(m_aItems.begin() + _nIndex, xCorrectType);
|
|
|
|
|
|
|
|
|
|
m_aMap.insert(pair<const ::rtl::OUString, InterfaceRef >(sName,xCorrectType));
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XChild> xChild(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xChild.is())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xChild->setParent(static_cast<XContainer*>(this));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
if (bEvents)
|
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->insertEntry(_nIndex);
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef xIfc(xElement, UNO_QUERY);// wichtig
|
|
|
|
|
Any aHelper;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aHelper <<= xSet;
|
|
|
|
|
m_xEventAttacher->attach(_nIndex, xIfc, aHelper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// notify derived classes
|
|
|
|
|
implInserted(xCorrectType);
|
|
|
|
|
|
|
|
|
|
// notify listeners
|
2000-11-23 08:42:45 +00:00
|
|
|
|
ContainerEvent aEvt;
|
|
|
|
|
aEvt.Source = static_cast<XContainer*>(this);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aEvt.Accessor <<= _nIndex;
|
2000-11-23 08:42:45 +00:00
|
|
|
|
aEvt.Element = Any(&xCorrectType, m_aElementType);
|
|
|
|
|
NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementInserted, aEvt);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void OInterfaceContainer::removeElementsNoEvents(sal_Int32 nIndex)
|
|
|
|
|
{
|
|
|
|
|
OInterfaceArray::iterator i = m_aItems.begin() + nIndex;
|
|
|
|
|
InterfaceRef xElement(*i);
|
|
|
|
|
|
|
|
|
|
OInterfaceMap::iterator j = m_aMap.begin();
|
|
|
|
|
while (j != m_aMap.end() && (*j).second != xElement) ++j;
|
|
|
|
|
|
|
|
|
|
m_aItems.erase(i);
|
|
|
|
|
m_aMap.erase(j);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
xSet->removePropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XChild> xChild(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xChild.is())
|
|
|
|
|
xChild->setParent(InterfaceRef ());
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XIndexContainer
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::insertByIndex(sal_Int32 _nIndex, const Any& Element) throw(IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
|
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
insert(_nIndex, InterfaceRef (*(InterfaceRef *)Element.getValue()), sal_True);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& Element) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
|
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
if (_nIndex < 0 || _nIndex >= m_aItems.size())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IndexOutOfBoundsException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InterfaceRef xOldElement(m_aItems[_nIndex]);
|
|
|
|
|
InterfaceRef xNewElement(*(InterfaceRef *)Element.getValue());
|
|
|
|
|
|
|
|
|
|
OInterfaceMap::iterator j = m_aMap.begin();
|
|
|
|
|
while (j != m_aMap.end() && (*j).second != xOldElement) ++j;
|
|
|
|
|
|
|
|
|
|
// Eventverkn<6B>pfungen aufheben
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef xIfc(xOldElement, UNO_QUERY);// wichtig
|
2000-09-18 15:33:13 +00:00
|
|
|
|
m_xEventAttacher->detach(_nIndex, xIfc);
|
|
|
|
|
m_xEventAttacher->removeEntry(_nIndex);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(xOldElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
xSet->removePropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XChild> xChild(xOldElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xChild.is())
|
|
|
|
|
xChild->setParent(InterfaceRef ());
|
|
|
|
|
|
|
|
|
|
// neue einfuegen
|
|
|
|
|
::rtl::OUString sName;
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xSet = Reference<XPropertySet> (xNewElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
{
|
|
|
|
|
if (!hasProperty(PROPERTY_NAME, xSet))
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any aValue = xSet->getPropertyValue(PROPERTY_NAME);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aValue >>= sName;
|
|
|
|
|
xSet->addPropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
}
|
|
|
|
|
else
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
// remove the old one
|
|
|
|
|
m_aMap.erase(j);
|
|
|
|
|
|
|
|
|
|
// insert the new one
|
|
|
|
|
m_aMap.insert(pair<const ::rtl::OUString, InterfaceRef >(sName,xNewElement));
|
|
|
|
|
m_aItems[_nIndex] = xNewElement;
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xChild = Reference<XChild> (xNewElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xChild.is())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xChild->setParent(static_cast<XContainer*>(this));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
m_xEventAttacher->insertEntry(_nIndex);
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xIfc = InterfaceRef (xNewElement, UNO_QUERY);// wichtig
|
|
|
|
|
Any aHelper;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aHelper <<= xSet;
|
|
|
|
|
m_xEventAttacher->attach(_nIndex, xIfc, aHelper);
|
|
|
|
|
|
2000-12-19 15:51:01 +00:00
|
|
|
|
implReplaced(xOldElement, xNewElement);
|
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
|
// benachrichtigen
|
2000-11-23 08:42:45 +00:00
|
|
|
|
ContainerEvent aEvt;
|
|
|
|
|
aEvt.Source = static_cast<XContainer*>(this);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aEvt.Accessor <<= _nIndex;
|
2000-11-23 08:42:45 +00:00
|
|
|
|
aEvt.Element = Any(&xNewElement, m_aElementType);
|
|
|
|
|
aEvt.ReplacedElement = Any(&xOldElement, m_aElementType);
|
|
|
|
|
NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementReplaced, aEvt);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::removeByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
if (_nIndex < 0 || _nIndex >= m_aItems.size())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IndexOutOfBoundsException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
OInterfaceArray::iterator i = m_aItems.begin() + _nIndex;
|
|
|
|
|
InterfaceRef xElement(*i);
|
|
|
|
|
|
|
|
|
|
OInterfaceMap::iterator j = m_aMap.begin();
|
|
|
|
|
while (j != m_aMap.end() && (*j).second != xElement) ++j;
|
|
|
|
|
|
|
|
|
|
m_aItems.erase(i);
|
|
|
|
|
m_aMap.erase(j);
|
|
|
|
|
|
|
|
|
|
// Eventverkn<6B>pfungen aufheben
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef xIfc(xElement, UNO_QUERY);// wichtig
|
2000-09-18 15:33:13 +00:00
|
|
|
|
m_xEventAttacher->detach(_nIndex, xIfc);
|
|
|
|
|
m_xEventAttacher->removeEntry(_nIndex);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
xSet->removePropertyChangeListener(PROPERTY_NAME, this);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XChild> xChild(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xChild.is())
|
|
|
|
|
xChild->setParent(InterfaceRef ());
|
|
|
|
|
|
|
|
|
|
// notify derived classes
|
|
|
|
|
implRemoved(xElement);
|
|
|
|
|
|
|
|
|
|
// notify listeners
|
2000-11-23 08:42:45 +00:00
|
|
|
|
ContainerEvent aEvt;
|
|
|
|
|
aEvt.Source = static_cast<XContainer*>(this);
|
|
|
|
|
aEvt.Element = Any(&xElement, m_aElementType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aEvt.Accessor <<= _nIndex;
|
2000-11-23 08:42:45 +00:00
|
|
|
|
NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementRemoved, aEvt);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::insertByName(const ::rtl::OUString& Name, const Any& Element) throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
2000-11-23 08:42:45 +00:00
|
|
|
|
if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
|
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
InterfaceRef xElement(*(InterfaceRef *)Element.getValue());
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(xElement, UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
{
|
|
|
|
|
if (!hasProperty(PROPERTY_NAME, xSet))
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xSet->setPropertyValue(PROPERTY_NAME, makeAny(Name));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
insertByIndex(m_aItems.size(), Element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::replaceByName(const ::rtl::OUString& Name, const Any& Element) throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
pair <OInterfaceMap::iterator,
|
|
|
|
|
OInterfaceMap::iterator> aPair = m_aMap.equal_range(Name);
|
|
|
|
|
if (aPair.first == aPair.second)
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw NoSuchElementException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
|
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Reference<XPropertySet> xSet(*(InterfaceRef *)Element.getValue(), UNO_QUERY);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (xSet.is())
|
|
|
|
|
{
|
|
|
|
|
if (!hasProperty(PROPERTY_NAME, xSet))
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw IllegalArgumentException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
xSet->setPropertyValue(PROPERTY_NAME, makeAny(Name));
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// determine the element pos
|
|
|
|
|
sal_Int32 nPos = find(m_aItems.begin(), m_aItems.end(), (*aPair.first).second) - m_aItems.begin();
|
|
|
|
|
replaceByIndex(nPos, Element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::removeByName(const ::rtl::OUString& Name) throw( NoSuchElementException, WrappedTargetException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_rMutex );
|
|
|
|
|
pair <OInterfaceMap::iterator,
|
|
|
|
|
OInterfaceMap::iterator> aPair = m_aMap.equal_range(Name);
|
|
|
|
|
if (aPair.first == aPair.second)
|
2000-11-23 08:42:45 +00:00
|
|
|
|
throw NoSuchElementException();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
sal_Int32 nPos = find(m_aItems.begin(), m_aItems.end(), (*aPair.first).second) - m_aItems.begin();
|
|
|
|
|
removeByIndex(nPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
// XEventAttacherManager
|
2000-09-18 15:33:13 +00:00
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::registerScriptEvent( sal_Int32 nIndex, const ScriptEventDescriptor& aScriptEvent ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->registerScriptEvent(nIndex, aScriptEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::registerScriptEvents( sal_Int32 nIndex, const Sequence< ScriptEventDescriptor >& aScriptEvents ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->registerScriptEvents(nIndex, aScriptEvents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::revokeScriptEvent( sal_Int32 nIndex, const ::rtl::OUString& aListenerType, const ::rtl::OUString& aEventMethod, const ::rtl::OUString& aRemoveListenerParam ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->revokeScriptEvent(nIndex,
|
|
|
|
|
aListenerType, aEventMethod, aRemoveListenerParam );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::revokeScriptEvents( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->revokeScriptEvents(nIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::insertEntry( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->insertEntry(nIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::removeEntry( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->removeEntry(nIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Sequence< ScriptEventDescriptor > SAL_CALL OInterfaceContainer::getScriptEvents( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
return m_xEventAttacher->getScriptEvents(nIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::attach( sal_Int32 nIndex, const Reference< XInterface >& xObject, const Any& aHelper ) throw(IllegalArgumentException, ServiceNotRegisteredException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->attach(nIndex, xObject, aHelper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::detach( sal_Int32 nIndex, const Reference< XInterface >& xObject ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->detach(nIndex, xObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::addScriptListener( const Reference< XScriptListener >& xListener ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->addScriptListener(xListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void SAL_CALL OInterfaceContainer::removeScriptListener( const Reference< XScriptListener >& xListener ) throw(IllegalArgumentException, RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_xEventAttacher->removeScriptListener(xListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
//= OFormComponents
|
|
|
|
|
//==================================================================
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any SAL_CALL OFormComponents::queryAggregation(const Type& _rType) throw(RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Any aReturn = OFormComponents_BASE::queryInterface(_rType);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
if (!aReturn.hasValue())
|
2000-11-23 08:42:45 +00:00
|
|
|
|
{
|
2000-09-18 15:33:13 +00:00
|
|
|
|
aReturn = OInterfaceContainer::queryInterface(_rType);
|
|
|
|
|
|
2000-11-23 08:42:45 +00:00
|
|
|
|
if (!aReturn.hasValue())
|
|
|
|
|
aReturn = FormComponentsBase::queryAggregation(_rType);
|
|
|
|
|
}
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
Sequence<Type> SAL_CALL OFormComponents::getTypes() throw(RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
2000-11-23 08:42:45 +00:00
|
|
|
|
return ::comphelper::concatSequences(OInterfaceContainer::getTypes(), FormComponentsBase::getTypes(), OFormComponents_BASE::getTypes());
|
2000-09-18 15:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
OFormComponents::OFormComponents(const Reference<XMultiServiceFactory>& _rxFactory)
|
2000-09-18 15:33:13 +00:00
|
|
|
|
:FormComponentsBase(m_aMutex)
|
2000-11-23 08:42:45 +00:00
|
|
|
|
,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XFormComponent>*>(NULL)))
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
OFormComponents::~OFormComponents()
|
|
|
|
|
{
|
|
|
|
|
if (!FormComponentsBase::rBHelper.bDisposed)
|
|
|
|
|
{
|
|
|
|
|
acquire();
|
|
|
|
|
dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OComponentHelper
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void OFormComponents::disposing()
|
|
|
|
|
{
|
|
|
|
|
OInterfaceContainer::disposing();
|
|
|
|
|
FormComponentsBase::disposing();
|
|
|
|
|
m_xParent = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//XChild
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
void OFormComponents::setParent(const InterfaceRef& Parent) throw( NoSupportException, RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
m_xParent = Parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 08:42:45 +00:00
|
|
|
|
InterfaceRef OFormComponents::getParent() throw( RuntimeException )
|
2000-09-18 15:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
return m_xParent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
|
} // namespace frm
|
|
|
|
|
//.........................................................................
|
|
|
|
|
|