2000-11-07 07:40:31 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* $RCSfile: nodechangeinfo.hxx,v $
|
2008-06-16 07:43:58 -05:00
|
|
|
* $Revision: 1.12 $
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:53:15 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
|
|
|
|
#define CONFIGMGR_CONFIGCHANGEINFO_HXX_
|
|
|
|
|
|
|
|
#include "configpath.hxx"
|
|
|
|
#include "noderef.hxx"
|
2001-06-20 14:26:39 -05:00
|
|
|
#include "valueref.hxx"
|
2002-02-11 06:47:56 -06:00
|
|
|
#include <rtl/ref.hxx>
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2002-02-11 06:47:56 -06:00
|
|
|
#ifndef INCLUDED_VECTOR
|
2001-02-13 09:08:06 -06:00
|
|
|
#include <vector>
|
2002-02-11 06:47:56 -06:00
|
|
|
#define INCLUDED_VECTOR
|
|
|
|
#endif
|
2001-02-13 09:08:06 -06:00
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
namespace configmgr
|
|
|
|
{
|
|
|
|
namespace configuration
|
|
|
|
{
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class NodeRef;
|
2001-06-20 14:26:39 -05:00
|
|
|
class ValueRef;
|
2000-11-07 07:40:31 -06:00
|
|
|
class NodeID;
|
2001-06-20 14:26:39 -05:00
|
|
|
class SubNodeID;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2008-10-29 09:38:47 -05:00
|
|
|
class ElementTree;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-02-13 09:08:06 -06:00
|
|
|
/// captures the values of something changing
|
|
|
|
template <class DataT>
|
|
|
|
struct DataChange
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2001-02-13 09:08:06 -06:00
|
|
|
DataT newValue;
|
|
|
|
DataT oldValue;
|
|
|
|
|
|
|
|
DataChange()
|
|
|
|
: newValue(), oldValue()
|
|
|
|
{}
|
|
|
|
|
|
|
|
DataChange(DataT const& newValue_, DataT const& oldValue_)
|
|
|
|
: newValue(newValue_), oldValue(oldValue_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// note: maybe we should support a comparison object
|
|
|
|
bool isDataChange() const
|
|
|
|
{ return !(oldValue == newValue); } // not using != to avoid conversion warning
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// information about what changed (but close to no context)
|
|
|
|
class NodeChangeData
|
|
|
|
{
|
|
|
|
public:
|
2000-11-07 07:40:31 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
eNoChange,
|
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
// Changes to value nodes
|
2000-11-07 07:40:31 -06:00
|
|
|
eSetValue,
|
|
|
|
eSetDefault,
|
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
// Changes to set nodes
|
2000-11-07 07:40:31 -06:00
|
|
|
eInsertElement,
|
|
|
|
eReplaceElement,
|
|
|
|
eRemoveElement,
|
|
|
|
|
2001-09-28 06:44:40 -05:00
|
|
|
eRenameElementTree, // not fully supported yet
|
|
|
|
|
|
|
|
eResetSetDefault
|
2000-11-07 07:40:31 -06:00
|
|
|
};
|
|
|
|
//-------------------------------------------------
|
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
bool isEmptyChange() const { return eNoChange == type; }
|
2000-11-07 07:40:31 -06:00
|
|
|
bool isValueChange() const { return eSetValue <= type && type <= eSetDefault; }
|
|
|
|
bool isSetChange() const { return eInsertElement <= type && type <= eRemoveElement; }
|
2004-06-18 09:50:16 -05:00
|
|
|
bool isRemoveSetChange() const { return eRemoveElement == type;}
|
|
|
|
bool isReplaceSetChange() const { return eReplaceElement == type;}
|
2000-11-07 07:40:31 -06:00
|
|
|
//-------------------------------------------------
|
2001-02-13 09:08:06 -06:00
|
|
|
bool isDataChange() const;
|
|
|
|
|
|
|
|
//-------------------------------------------------
|
|
|
|
// wrapper object creation
|
2008-10-29 09:38:47 -05:00
|
|
|
rtl::Reference< Tree > getNewElementTree() const;
|
|
|
|
rtl::Reference< Tree > getOldElementTree() const;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
NodeID getNewElementNodeID() const;
|
|
|
|
NodeID getOldElementNodeID() const;
|
|
|
|
//-------------------------------------------------
|
|
|
|
|
|
|
|
//-- Compiler barrier for element tree ------------
|
|
|
|
NodeChangeData();
|
|
|
|
NodeChangeData(NodeChangeData const& aOther);
|
|
|
|
NodeChangeData& operator=(NodeChangeData const& aOther);
|
|
|
|
~NodeChangeData();
|
2000-11-07 07:40:31 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
Type type;
|
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
// Value change: old/new value; Set change: new/old api element (if known); Rename: old/new name
|
2008-10-29 09:38:47 -05:00
|
|
|
DataChange< com::sun::star::uno::Any > unoData;
|
2001-02-13 09:08:06 -06:00
|
|
|
// Value change: NULL,NULL; Set change: new/old tree element; Rename: the affected element-tree (twice)
|
2008-10-29 09:38:47 -05:00
|
|
|
DataChange< rtl::Reference<ElementTree> > element;
|
2001-02-13 09:08:06 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------
|
|
|
|
// Identify the location of a change. Interpretation of members may depend upon
|
|
|
|
class NodeChangeLocation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//-------------------------------------------------
|
|
|
|
// checks whether the base has been properly set up.
|
|
|
|
// Does not check for existence of the affected node
|
2008-06-16 07:43:58 -05:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2001-02-13 09:08:06 -06:00
|
|
|
/// check whether the location has been initialized properly
|
2002-02-11 06:47:56 -06:00
|
|
|
bool isValidData() const;
|
2008-06-16 07:43:58 -05:00
|
|
|
#endif
|
2002-02-11 06:47:56 -06:00
|
|
|
/// check whether the location is for a valid object
|
2007-11-23 07:21:33 -06:00
|
|
|
bool isValidLocation() const;
|
2001-02-13 09:08:06 -06:00
|
|
|
|
|
|
|
//-------------------------------------------------
|
|
|
|
/// retrieve the path from the base node to the changed node (which might be a child of the affected node)
|
|
|
|
RelativePath getAccessor() const { return m_path; }
|
|
|
|
|
|
|
|
/// retrieve the tree where the change is actually initiated/reported
|
2008-10-29 09:38:47 -05:00
|
|
|
rtl::Reference< Tree > getBaseTree() const;
|
2001-02-13 09:08:06 -06:00
|
|
|
/// retrieve the node where the change is actually initiated/reported
|
|
|
|
NodeRef getBaseNode() const;
|
|
|
|
|
2002-02-11 06:47:56 -06:00
|
|
|
/// retrieve the tree where the change is actually taking place (may be Empty, if the tree has never been accessed)
|
2008-10-29 09:38:47 -05:00
|
|
|
rtl::Reference< Tree > getAffectedTreeRef() const;
|
2001-02-13 09:08:06 -06:00
|
|
|
/// identify the node where the change is actually taking place
|
|
|
|
NodeID getAffectedNodeID() const;
|
|
|
|
|
|
|
|
/// identify the node (within the affected tree), that actually is changed (this one may be a value node)
|
2001-06-20 14:26:39 -05:00
|
|
|
SubNodeID getChangingValueID() const;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
void setAccessor( RelativePath const& aAccessor );
|
|
|
|
|
|
|
|
void setBase( NodeID const& aBaseID );
|
2008-10-29 09:38:47 -05:00
|
|
|
void setBase( rtl::Reference< Tree > const& aBaseTree, NodeRef const& aBaseNode )
|
2001-02-13 09:08:06 -06:00
|
|
|
{ setBase( NodeID(aBaseTree,aBaseNode) ); }
|
|
|
|
|
2001-06-20 14:26:39 -05:00
|
|
|
void setAffected( NodeID const& aTargetID );
|
2008-10-29 09:38:47 -05:00
|
|
|
void setAffected( rtl::Reference< Tree > const& aTargetTree, NodeRef const& aTargetNode )
|
2001-06-20 14:26:39 -05:00
|
|
|
{ setAffected( NodeID(aTargetTree,aTargetNode) ); }
|
2001-02-13 09:08:06 -06:00
|
|
|
|
2001-06-20 14:26:39 -05:00
|
|
|
void setChangingSubnode( bool bSubnode = true );
|
2001-02-13 09:08:06 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
NodeChangeLocation();
|
|
|
|
// NodeChangeLocation(NodeChangeLocation const& aOther);
|
|
|
|
// NodeChangeLocation& operator=(NodeChangeLocation const& aOther);
|
|
|
|
// ~NodeChangeLocation();
|
|
|
|
//-------------------------------------------------
|
|
|
|
private:
|
|
|
|
RelativePath m_path; // path from baseNode to changing node
|
|
|
|
NodeID m_base; // a (non-empty) node
|
2001-06-20 14:26:39 -05:00
|
|
|
NodeID m_affected; // identifies the affected node (if available)
|
|
|
|
bool m_bSubNodeChanging; // do we change a value ?
|
2000-11-07 07:40:31 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-02-13 09:08:06 -06:00
|
|
|
class NodeChangeInformation
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2001-02-13 09:08:06 -06:00
|
|
|
public:
|
|
|
|
//-------------------------------------------------
|
2002-02-11 06:47:56 -06:00
|
|
|
explicit
|
2007-11-23 07:21:33 -06:00
|
|
|
NodeChangeInformation()
|
|
|
|
: change()
|
2002-02-11 06:47:56 -06:00
|
|
|
, location()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
//-------------------------------------------------
|
2001-02-13 09:08:06 -06:00
|
|
|
NodeChangeData change;
|
|
|
|
NodeChangeLocation location;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
//-------------------------------------------------
|
2007-11-23 07:21:33 -06:00
|
|
|
bool hasValidLocation() const { return location.isValidLocation(); }
|
2001-02-13 09:08:06 -06:00
|
|
|
bool isDataChange() const { return change.isDataChange(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-02-13 09:08:06 -06:00
|
|
|
bool isEmptyChange() const { return change.isEmptyChange(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
bool isValueChange() const { return change.isValueChange(); }
|
|
|
|
bool isSetChange() const { return change.isSetChange(); }
|
2001-02-13 09:08:06 -06:00
|
|
|
//-------------------------------------------------
|
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class NodeChangesInformation
|
|
|
|
{
|
|
|
|
public:
|
2008-10-29 09:38:47 -05:00
|
|
|
std::vector< NodeChangeInformation >::size_type size() const { return m_data.size(); }
|
2001-02-13 09:08:06 -06:00
|
|
|
bool empty() const { return m_data.empty(); }
|
|
|
|
|
2008-10-29 09:38:47 -05:00
|
|
|
void reserve(std::vector< NodeChangeInformation >::size_type sz_) { m_data.reserve(sz_); }
|
2001-02-13 09:08:06 -06:00
|
|
|
void clear() { m_data.clear(); }
|
|
|
|
void swap(NodeChangesInformation& aOther) throw() { m_data.swap(aOther.m_data); }
|
|
|
|
|
2002-02-11 06:47:56 -06:00
|
|
|
void push_back(NodeChangeInformation const& aChange_)
|
2001-02-13 09:08:06 -06:00
|
|
|
{ m_data.push_back(aChange_); }
|
|
|
|
|
2008-10-29 09:38:47 -05:00
|
|
|
std::vector< NodeChangeInformation >::const_iterator begin() const { return m_data.begin(); }
|
|
|
|
std::vector< NodeChangeInformation >::const_iterator end() const { return m_data.end(); }
|
2001-02-13 09:08:06 -06:00
|
|
|
private:
|
2008-10-29 09:38:47 -05:00
|
|
|
std::vector< NodeChangeInformation > m_data;
|
2000-11-07 07:40:31 -06:00
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-25 06:49:10 -05:00
|
|
|
#if !defined(WNT) || (defined(WNT) && _MSC_VER < 1400)
|
2001-02-13 09:08:06 -06:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
inline
|
|
|
|
void swap(configmgr::configuration::NodeChangesInformation& lhs, configmgr::configuration::NodeChangesInformation& rhs)
|
|
|
|
{ lhs.swap(rhs); }
|
|
|
|
}
|
2006-09-25 06:49:10 -05:00
|
|
|
#endif
|
2001-02-13 09:08:06 -06:00
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
#endif // CONFIGMGR_CONFIGCHANGEINFO_HXX_
|