merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / treemgr / collectchanges.hxx
blobc8a924e3e2df629fafa14425e42feaf370364253
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: collectchanges.hxx,v $
10 * $Revision: 1.7 $
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 #ifndef CONFIGMGR_COLLECTCHANGES_HXX_
32 #define CONFIGMGR_COLLECTCHANGES_HXX_
34 // low.level (cache model) changes (needed for change tree action class)
35 #include "change.hxx"
37 // pathes for accessors
38 #include "configpath.hxx"
40 // need c_TreeDepthAll
41 #include "tree.hxx"
43 namespace configmgr
45 //-----------------------------------------------------------------------------
46 namespace configuration
48 //-----------------------------------------------------------------------------
49 class NodeChangeData;
50 class NodeChangeLocation;
51 class NodeChangeInformation;
52 class NodeChangesInformation;
53 //-----------------------------------------------------------------------------
55 /// Change model translation: Create a NodeChangeData from a ValueChange object
56 bool convertNodeChange(NodeChangeData& aData_, ValueChange const& aChange_);
57 /// Change model translation: Create a NodeChangeData from an AddNode change object
58 bool convertNodeChange(NodeChangeData& aData_, AddNode const& aChange_);
59 /// Change model translation: Create a NodeChangeData from a RemoveNode change object
60 bool convertNodeChange(NodeChangeData& aData_, RemoveNode const& aChange_);
62 /** Change Tree Visitor that appends all changes in the changes tree
63 to a NodeChanges list, optionally restricted to a given depth
65 class CollectChanges : private ChangeTreeAction
67 NodeChangesInformation& m_rTargetList;
68 RelativePath m_aAccessor;
69 rtl::OUString m_aContextTypeName;
70 Tree* m_pBaseTree;
71 unsigned int m_nBaseNode;
72 unsigned int m_nDepthLeft;
74 public:
75 /// Constructs a Visitor object, sets the output target list and context
76 CollectChanges( NodeChangesInformation& rTargetList_,
77 Tree& rStartTree_, unsigned int nStartNode_,
78 rtl::Reference<Template> aElementTemplate_,
79 unsigned int nMaxDepth = c_TreeDepthAll);
81 /// Adds a (translated) ValueChange to the target list
82 void collectFrom(ValueChange const& aChange_);
84 /// Adds a (translated) AddNode to the target list
85 void collectFrom(AddNode const& aChange_);
87 /// Adds a (translated) RemoveNode to the target list
88 void collectFrom(RemoveNode const& aChange_);
90 /// Appends (translated) Changes from the subtree to the target list, possibly with a depth limit
91 void collectFrom(SubtreeChange const& aChange_);
93 /// Appends the given Change and its descendants to the target list, possibly with a depth limit
94 void collectFrom(Change const& aChange_)
96 this->applyToChange( aChange_ );
99 /// Appends the descendants of the given Change to the target list, possibly with a depth limit
100 void collectFromChildren(SubtreeChange const& aParent_)
102 this->applyToChildren( aParent_ );
105 protected:
106 /// Constructs a Visitor object for a child of another one's context
107 CollectChanges( CollectChanges const& rBase, Path::Component const& rChildName, rtl::OUString const& aSubTypeName );
109 private:
110 // ChangeTreeAction implementations
111 virtual void handle(ValueChange const& aValueNode);
112 virtual void handle(AddNode const& aAddNode);
113 virtual void handle(RemoveNode const& aRemoveNode);
114 virtual void handle(SubtreeChange const& aSubtree);
116 bool implSetLocation(NodeChangeLocation& rLocation_, Change const& aOriginal_, bool bSet_) const;
117 void implAdd(NodeChangeInformation const& aChangeInfo_);
118 Path::Component implGetNodeName(Change const& _aChange_) const;
120 //-----------------------------------------------------------------------------
124 #endif // CONFIGMGR_COLLECTCHANGES_HXX_