office-gobmx/configmgr/source/api/confevents.cxx

177 lines
6.1 KiB
C++
Raw Normal View History

2000-09-18 10:18:56 -05:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 10:18:56 -05:00
*
* $RCSfile: confevents.cxx,v $
2000-09-18 10:18:56 -05:00
*
* $Revision: 1.8 $
2000-09-18 10:18:56 -05:00
*
* last change: $Author: rt $ $Date: 2005-09-08 03:04:01 $
2000-09-18 10:18:56 -05:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 10:18:56 -05:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 10:18:56 -05:00
*
* 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.
2000-09-18 10:18:56 -05:00
*
* 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.
2000-09-18 10:18:56 -05:00
*
* 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
2000-09-18 10:18:56 -05:00
*
************************************************************************/
#include <stdio.h>
2002-02-21 07:11:15 -06:00
#include <string.h>
2000-09-18 10:18:56 -05:00
#include "confevents.hxx"
#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
#include "confeventhelpers.hxx"
#endif
#ifndef CONFIGMGR_TREECHANGELIST_HXX
#include "treechangelist.hxx"
#endif
2000-09-18 10:18:56 -05:00
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
namespace configmgr
{
/////////////////////////////////////////////////////////////////////////
using internal::ConfigChangesBroadcasterImpl;
/////////////////////////////////////////////////////////////////////////
class ConfigChangeBroadcastHelper // broadcasts changes for a given set of options
2000-09-18 10:18:56 -05:00
{
ConfigChangesBroadcasterImpl m_changes;
2000-09-18 10:18:56 -05:00
public:
ConfigChangeBroadcastHelper();
~ConfigChangeBroadcastHelper();
2000-09-18 10:18:56 -05:00
void broadcast(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& anUpdate, sal_Bool bError, IConfigBroadcaster* pSource);
2000-09-18 10:18:56 -05:00
public:
// IConfigBroadcaster implementation helper
void addListener(AbsolutePath const& aName, INodeListenerRef const& );
void removeListener(INodeListenerRef const&);
2000-09-18 10:18:56 -05:00
void dispose(IConfigBroadcaster* pSource);
};
2000-09-18 10:18:56 -05:00
/////////////////////////////////////////////////////////////////////////
ConfigChangeBroadcaster::ConfigChangeBroadcaster()
2000-09-18 10:18:56 -05:00
{
}
ConfigChangeBroadcaster::~ConfigChangeBroadcaster()
2000-09-18 10:18:56 -05:00
{
}
/////////////////////////////////////////////////////////////////////////
ConfigChangeBroadcastHelper::ConfigChangeBroadcastHelper()
: m_changes()
2000-09-18 10:18:56 -05:00
{
}
ConfigChangeBroadcastHelper::~ConfigChangeBroadcastHelper()
2000-09-18 10:18:56 -05:00
{
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispose(IConfigBroadcaster* pSource)
2000-09-18 10:18:56 -05:00
{
m_changes.disposing(pSource);
2000-09-18 10:18:56 -05:00
}
/////////////////////////////////////////////////////////////////////////
// IConfigBroadcaster implementation
void ConfigChangeBroadcaster::addListener(AbsolutePath const& aName, RequestOptions const & _aOptions, INodeListenerRef const& pHandler)
2000-09-18 10:18:56 -05:00
{
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_aOptions,true))
2000-09-18 10:18:56 -05:00
{
pHelper->addListener(aName, pHandler);
2000-09-18 10:18:56 -05:00
}
else
OSL_ASSERT(false);
2000-09-18 10:18:56 -05:00
}
void ConfigChangeBroadcaster::removeListener(RequestOptions const & _aOptions, INodeListenerRef const& pHandler)
2000-09-18 10:18:56 -05:00
{
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_aOptions,false))
2000-09-18 10:18:56 -05:00
{
pHelper->removeListener( pHandler);
2000-09-18 10:18:56 -05:00
}
}
/* void ConfigChangeBroadcaster::removeNode(OUString const& aPath, const vos::ORef < OOptions >& _xOptions, bool bRemovedFromModel)
2000-09-18 10:18:56 -05:00
{
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,false))
2000-09-18 10:18:56 -05:00
{
pHelper->removeNode(aPath, bRemovedFromModel, this);
2000-09-18 10:18:56 -05:00
}
}
*/
2000-09-18 10:18:56 -05:00
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcaster::fireChanges(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& rList_, sal_Bool bError_)
2000-09-18 10:18:56 -05:00
{
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(rList_.getOptions(),false))
2000-09-18 10:18:56 -05:00
{
pHelper->broadcast(_aChangedDataAccessor, rList_, bError_, this);
2000-09-18 10:18:56 -05:00
}
}
/////////////////////////////////////////////////////////////////////////
ConfigChangeBroadcastHelper* ConfigChangeBroadcaster::newBroadcastHelper()
2000-09-18 10:18:56 -05:00
{
return new ConfigChangeBroadcastHelper();
2000-09-18 10:18:56 -05:00
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcaster::disposeBroadcastHelper(ConfigChangeBroadcastHelper* pHelper)
2000-09-18 10:18:56 -05:00
{
if (pHelper)
2000-09-18 10:18:56 -05:00
{
pHelper->dispose(this);
delete pHelper;
2000-09-18 10:18:56 -05:00
}
}
/////////////////////////////////////////////////////////////////////////
// IConfigBroadcaster implementation help
void ConfigChangeBroadcastHelper::addListener(AbsolutePath const& aName, INodeListenerRef const& pHandler)
2000-09-18 10:18:56 -05:00
{
m_changes.add(aName, pHandler);
2000-09-18 10:18:56 -05:00
}
void ConfigChangeBroadcastHelper::removeListener(INodeListenerRef const& pHandler)
2000-09-18 10:18:56 -05:00
{
m_changes.remove(pHandler);
2000-09-18 10:18:56 -05:00
}
/* void ConfigChangeBroadcastHelper::removeNode(OUString const& aPath, bool bRemovedFromModel, IConfigBroadcaster* pSource)
2000-09-18 10:18:56 -05:00
{
m_changes.removed(aPath, bRemovedFromModel,pSource);
2000-09-18 10:18:56 -05:00
}
*/
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::broadcast(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& anUpdate, sal_Bool bError, IConfigBroadcaster* pSource)
2000-09-18 10:18:56 -05:00
{
m_changes.dispatch(_aChangedDataAccessor, anUpdate, bError, pSource);
2000-09-18 10:18:56 -05:00
}
} // namespace