merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / treemgr / directview.cxx
blob16737a23a117446e97c635d45d8b8636a3323cee
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: directview.cxx,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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
33 #include <stdio.h>
34 #include "directview.hxx"
35 #include "viewfactory.hxx"
36 #include "setnodeimpl.hxx"
38 namespace configmgr
40 namespace view
42 //-----------------------------------------------------------------------------
44 void DirectViewStrategy::implMarkNondefault(SetNode const& _aSetNode)
46 sharable::SetNode * set = _aSetNode.getAccess();
48 OSL_ASSERT(set != 0);
50 sharable::SetNode* pNode = NULL;
51 if (m_aTreeSegment.is())
52 pNode = set;
54 OSL_ASSERT(pNode);
56 pNode->info.markAsDefault(false);
58 //-----------------------------------------------------------------------------
60 bool DirectViewStrategy::doHasChanges(Node const& ) const
62 return false;
64 //-----------------------------------------------------------------------------
66 void DirectViewStrategy::doMarkChanged(Node const& )
68 // do nothing
70 //-----------------------------------------------------------------------------
72 node::Attributes DirectViewStrategy::doAdjustAttributes(node::Attributes const& _aAttributes) const
74 node::Attributes aAttributes = _aAttributes;
76 if (aAttributes.isReadonly())
77 aAttributes.setAccess(node::accessFinal);
79 return aAttributes;
81 //-----------------------------------------------------------------------------
83 configuration::ValueMemberNode DirectViewStrategy::doGetValueMember(GroupNode const& _aNode, rtl::OUString const& _aName, bool _bForUpdate) const
85 return ViewStrategy::doGetValueMember(_aNode,_aName,_bForUpdate);
87 //-----------------------------------------------------------------------------
88 void DirectViewStrategy::doInsertElement(SetNode const& _aNode, rtl::OUString const& _aName, configuration::SetEntry const& _aNewEntry)
90 // move to this memory segment
91 // should already be direct (as any free-floating one)
93 //implMakeElement(aNewEntry)
94 configuration::ElementTreeData aNewElement = implMakeElement(_aNode, _aNewEntry );
95 // _aNewEntry.tree()->rebuild(this, _aNode.accessor());
97 _aNode.get_impl()->insertElement(_aName, aNewElement);
99 aNewElement->attachTo( _aNode.getAccess(), _aName );
101 implMarkNondefault( _aNode );
103 //-----------------------------------------------------------------------------
105 void DirectViewStrategy::doRemoveElement(SetNode const& _aNode, rtl::OUString const& _aName)
107 configuration::ElementTreeData aOldElement = _aNode.get_impl()->removeElement(_aName);
109 aOldElement->detachFrom( _aNode.getAccess(), _aName);
111 implMarkNondefault( _aNode );
113 //-----------------------------------------------------------------------------
115 extern NodeFactory& getDirectAccessFactory();
117 NodeFactory& DirectViewStrategy::doGetNodeFactory()
119 return getDirectAccessFactory();
121 //-----------------------------------------------------------------------------
123 rtl::Reference<ViewStrategy> createDirectAccessStrategy(rtl::Reference< data::TreeSegment > const & _aTreeSegment)
125 return new DirectViewStrategy(_aTreeSegment);
128 //-----------------------------------------------------------------------------