/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: nodechangeimpl.cxx,v $ * * $Revision: 1.21 $ * * last change: $Author: ihi $ $Date: 2007-11-23 14:43:02 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 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 * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_configmgr.hxx" #include "nodechangeimpl.hxx" #ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_ #include "nodechangeinfo.hxx" #endif #ifndef CONFIGMGR_CONFIGNODEBEHAVIOR_HXX_ #include "nodeimpl.hxx" #endif #ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_ #include "treeimpl.hxx" #endif #ifndef CONFIGMGR_CONFIGSET_HXX_ #include "configset.hxx" #endif #ifndef CONFIGMGR_SETNODEBEHAVIOR_HXX_ #include "setnodeimpl.hxx" #endif #ifndef CONFIGMGR_GROUPNODEBEHAVIOR_HXX_ #include "groupnodeimpl.hxx" #endif #ifndef _CONFIGMGR_TREE_VALUENODE_HXX #include "valuenode.hxx" #endif #ifndef CONFIGMGR_CHANGE_HXX #include "change.hxx" #endif namespace configmgr { namespace configuration { //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // All Changes:NodeChangeImpl - common base //----------------------------------------------------------------------------- // life cycle states for a NodeChangeImpl enum { eTestedChange = 0x01, eAppliedChange = 0x02, eNoCheck = 0x07 }; //----------------------------------------------------------------------------- NodeChangeImpl::NodeChangeImpl(bool bNoCheck) : m_aAffectedTree() , m_nAffectedNode(0) , m_nState(0) { if (bNoCheck) m_nState = eNoCheck; } //----------------------------------------------------------------------------- view::ViewTreeAccess NodeChangeImpl::getTargetView() { OSL_ENSURE( m_aAffectedTree.is(), "ERROR: Configuration Change: Target Tree Access has not been set up" ); return Tree(m_aAffectedTree.get()).getView(); } //----------------------------------------------------------------------------- TreeHolder NodeChangeImpl::getTargetTree() const { TreeHolder aRet = m_aAffectedTree; OSL_ENSURE( aRet.is(), "ERROR: Configuration Change: Target Tree has not been set up" ); return aRet; } //----------------------------------------------------------------------------- NodeOffset NodeChangeImpl::getTargetNode() const { NodeOffset nRet = m_nAffectedNode; OSL_ENSURE( nRet != 0, "ERROR: Configuration Change: Target Node has not been set up" ); OSL_ENSURE( m_aAffectedTree.is() && m_aAffectedTree->isValidNode(nRet), "ERROR: Configuration Change: Changing Node does not match tree" ); return nRet; } //----------------------------------------------------------------------------- void NodeChangeImpl::setTarget(view::Node _aAffectedNode) { this->setTarget(_aAffectedNode.tree().get_impl(), _aAffectedNode.get_offset()); } void NodeChangeImpl::setTarget(TreeHolder const& _aAffectedTree, NodeOffset _nAffectedNode) { OSL_ENSURE(m_nState == 0 || (!m_aAffectedTree.is() && m_nState == eNoCheck), "WARNING: Configuration: Retargeting change that already was tested or applied"); OSL_ENSURE( _aAffectedTree.is(), "ERROR: Configuration Change: NULL Target Tree is not allowed" ); OSL_ENSURE( _nAffectedNode, "ERROR: Configuration Change: NULL Target Node is not allowed" ); OSL_ENSURE( _aAffectedTree->isValidNode(_nAffectedNode), "ERROR: Configuration Change: Target Node does not match Tree" ); if (m_nState != eNoCheck) m_nState = 0; // previous checks are invalidated m_aAffectedTree = _aAffectedTree; m_nAffectedNode = _nAffectedNode; } //----------------------------------------------------------------------------- bool NodeChangeImpl::isChange(bool bAllowUntested) const { OSL_ENSURE(bAllowUntested || (m_nState & eTestedChange), "WARNING: Configuration: Change was not tested - isChange is meaningless"); if (m_nState == eNoCheck) return true; if (!(m_nState & eTestedChange)) return bAllowUntested; return doIsChange(); } //----------------------------------------------------------------------------- NodeChangeImpl::ChangeCount NodeChangeImpl::getChangeDataCount() const { OSL_PRECOND(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - change data count may be incorrect"); return doGetChangeCount(); } //----------------------------------------------------------------------------- bool NodeChangeImpl::fillChangeData(NodeChangeData& rChange, ChangeCount _ix) const { OSL_PRECOND(_ix < doGetChangeCount(), "ERROR: Configuration: Change index out of range"); OSL_PRECOND(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - fillChange is partially meaningless"); return doFillChange(rChange, _ix) || rChange.isDataChange(); // force true if the data is signaling change } //----------------------------------------------------------------------------- bool NodeChangeImpl::fillChangeLocation(NodeChangeLocation& rChange, ChangeCount _ix) const { if (!m_aAffectedTree.is()) return false; rChange.setBase( NodeID(this->getTargetTree().get(), this->getTargetNode()) ); rChange.setAccessor( this->doGetChangingNodePath(_ix) ); rChange.setAffected( NodeID(this->getTargetTree().get(), this->getTargetNode()) ); rChange.setChangingSubnode( this->doIsChangingSubnode() ); return true; } //----------------------------------------------------------------------------- bool NodeChangeImpl::fillChangeInfo(NodeChangeInformation& rChange, ChangeCount _ix) const { return fillChangeLocation(rChange.location, _ix) & fillChangeData(rChange.change, _ix); } //----------------------------------------------------------------------------- void NodeChangeImpl::test() { if (!(m_nState & eTestedChange)) { doTest(implGetTarget()); m_nState |= eTestedChange; } } //----------------------------------------------------------------------------- void NodeChangeImpl::apply() { if (!(m_nState & eAppliedChange)) { implApply(); OSL_ENSURE(m_nState & eAppliedChange, "ERROR: Configuration: Change could not be applied"); OSL_ENSURE(m_nState & eTestedChange, "ERROR: Configuration: Change was not tested while applied"); } else OSL_ENSURE(m_nState & eTestedChange, "ERROR: Configuration: Change marked applied but not tested"); } //----------------------------------------------------------------------------- // default count is 1 NodeChangeImpl::ChangeCount NodeChangeImpl::doGetChangeCount() const { return 1; } //----------------------------------------------------------------------------- /// apply this change to the given node - start state is nState (which is then updated) void NodeChangeImpl::implApply() { OSL_ASSERT( !(m_nState & eAppliedChange)); // Caller must check view::Node aTarget = implGetTarget(); if (!(m_nState & eTestedChange)) // Test checks the old value if there is realy a change { // for eventlisteners to say "the old value is kept" doTest(aTarget); m_nState |= eTestedChange; } doApply(aTarget); m_nState |= eAppliedChange; } //----------------------------------------------------------------------------- view::Node NodeChangeImpl::implGetTarget() { OSL_ENSURE(m_aAffectedTree.is(), "ERROR: Configuration Change: no target tree set"); OSL_ENSURE(m_aAffectedTree->isValidNode(m_nAffectedNode), "ERROR: Configuration Change: target node not in target tree"); view::Node aTarget = getTargetView().makeNode(m_nAffectedNode); OSL_ENSURE(aTarget.is(), "ERROR: Configuration: No target for change"); return aTarget; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Value operations: ValueChangeImpl = common base //----------------------------------------------------------------------------- ValueChangeImpl::ValueChangeImpl() : m_aNewValue() , m_aOldValue() { } //----------------------------------------------------------------------------- ValueChangeImpl::ValueChangeImpl(UnoAny const& aNewValue) : m_aNewValue(aNewValue) , m_aOldValue() { } //----------------------------------------------------------------------------- ValueChangeImpl::ValueChangeImpl(UnoAny const& aNewValue, UnoAny const& aOldValue) : NodeChangeImpl(true) , m_aNewValue(aNewValue) , m_aOldValue(aOldValue) { } //----------------------------------------------------------------------------- ValueChangeImpl::~ValueChangeImpl() { } //----------------------------------------------------------------------------- void ValueChangeImpl::setTarget(view::GroupNode const& _aParentNode, Name const& sNodeName) { OSL_ENSURE(!sNodeName.isEmpty(), "ValueChangeTarget is being set without a name"); NodeChangeImpl::setTarget(_aParentNode.node()); m_aName = sNodeName; } //----------------------------------------------------------------------------- void ValueChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nParentNode, Name const& sNodeName) { OSL_ENSURE(!sNodeName.isEmpty(), "ValueChangeTarget is being set without a name"); NodeChangeImpl::setTarget(aAffectedTree,nParentNode); m_aName = sNodeName; } //----------------------------------------------------------------------------- RelativePath ValueChangeImpl::doGetChangingNodePath(ChangeCount ) const { return RelativePath( Path::wrapSimpleName(m_aName) ); } //----------------------------------------------------------------------------- bool ValueChangeImpl::doIsChangingSubnode() const { return ! m_aName.isEmpty(); } //----------------------------------------------------------------------------- bool ValueChangeImpl::doIsChange() const { return !!(getNewValue() != getOldValue()); } //----------------------------------------------------------------------------- bool ValueChangeImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const { rChange.unoData.newValue = getNewValue(); rChange.unoData.oldValue = getOldValue(); return rChange.unoData.isDataChange(); } //----------------------------------------------------------------------------- void ValueChangeImpl::doTest( view::Node const& rTarget) { view::ViewTreeAccess aTargetView = getTargetView(); OSL_ENSURE(rTarget.isGroupNode(), "ERROR: Configuration: Target type mismatch: expected a group node holding the value"); ValueMemberNode aValueTarget = aTargetView.getValue( view::GroupNode(rTarget), m_aName ); OSL_ENSURE(aValueTarget.isValid(), "ERROR: Configuration: Target missing: could not find the changing value"); preCheckValue(aValueTarget, m_aOldValue, m_aNewValue); } //----------------------------------------------------------------------------- void ValueChangeImpl::doApply( view::Node const& rTarget) { view::ViewTreeAccess aTargetView = getTargetView(); OSL_ENSURE(rTarget.isGroupNode(), "ERROR: Configuration: Target type mismatch: expected a group node holding the value"); ValueMemberUpdate aValueTarget = aTargetView.getValueForUpdate( view::GroupNode(rTarget), m_aName ); OSL_ENSURE(aValueTarget.isValid(), "ERROR: Configuration: Target missing: could not find the changing value"); doApplyChange(aValueTarget); configmgr::configuration::ValueMemberNode aNode(aValueTarget.getNode()); postCheckValue(aNode, m_aNewValue); // Sideeffect: m_aNewValue will be changed } //----------------------------------------------------------------------------- void ValueChangeImpl::preCheckValue(ValueMemberNode& rNode, UnoAny& rOld, UnoAny& ) { UnoAny aPrevValue = rNode.getValue(); OSL_ENSURE(!rOld.hasValue() || rOld == aPrevValue, "ERROR: Configuration: Stored old value of target does not match the actual value"); rOld = aPrevValue; } //----------------------------------------------------------------------------- void ValueChangeImpl::postCheckValue(ValueMemberNode& rNode, UnoAny& rNew) { UnoAny aResultValue = rNode.getValue(); OSL_ENSURE(!rNew.hasValue() || rNew == aResultValue, "ERROR: Configuration: New value of target does not match the predicted result"); rNew = aResultValue; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Value operations: ValueReplaceImpl = set local value //----------------------------------------------------------------------------- ValueReplaceImpl::ValueReplaceImpl(UnoAny const& aNewValue) :ValueChangeImpl(aNewValue) { } //----------------------------------------------------------------------------- ValueReplaceImpl::ValueReplaceImpl(UnoAny const& aNewValue, UnoAny const& aOldValue) :ValueChangeImpl(aNewValue, aOldValue) { } //----------------------------------------------------------------------------- void ValueReplaceImpl::doApplyChange( ValueMemberUpdate& rNode) { rNode.setValue(getNewValue()); } //----------------------------------------------------------------------------- bool ValueReplaceImpl::doFillChange( NodeChangeData& rChange, ChangeCount _ix) const { rChange.type = NodeChangeData::eSetValue; return ValueChangeImpl::doFillChange(rChange, _ix); } //----------------------------------------------------------------------------- // Value operations: ValueResetImpl = set to default //----------------------------------------------------------------------------- ValueResetImpl::ValueResetImpl() :ValueChangeImpl() , m_bTargetIsDefault(false) { } //----------------------------------------------------------------------------- ValueResetImpl::ValueResetImpl(UnoAny const& aNewValue, UnoAny const& aOldValue) :ValueChangeImpl(aNewValue, aOldValue) , m_bTargetIsDefault(false) { } //----------------------------------------------------------------------------- void ValueResetImpl::doApplyChange( ValueMemberUpdate& rNode) { rNode.setDefault(); } //----------------------------------------------------------------------------- bool ValueResetImpl::doIsChange() const { return !m_bTargetIsDefault; } //----------------------------------------------------------------------------- bool ValueResetImpl::doFillChange( NodeChangeData& rChange, ChangeCount _ix) const { rChange.type = NodeChangeData::eSetDefault; ValueChangeImpl::doFillChange(rChange,_ix); return !m_bTargetIsDefault && !rChange.isEmptyChange(); // do it defensively here - default (= 'new') may be unknown still } //----------------------------------------------------------------------------- void ValueResetImpl::preCheckValue(ValueMemberNode& rNode, UnoAny& rOld, UnoAny& rNew) { ValueChangeImpl::preCheckValue(rNode,rOld,rNew); UnoAny aDefaultValue = rNode.getDefaultValue(); OSL_ENSURE(!rNew.hasValue() || rNew == aDefaultValue, "ERROR: Configuration: Stored new value of target does not match the actual default value"); rNew = aDefaultValue; m_bTargetIsDefault = rNode.isDefault(); } //----------------------------------------------------------------------------- // All Set Changes: SetChangeImpl - common base //----------------------------------------------------------------------------- SetChangeImpl::SetChangeImpl(bool bNoCheck) : NodeChangeImpl(bNoCheck) { } //----------------------------------------------------------------------------- bool SetChangeImpl::doIsChangingSubnode() const { return false; } //----------------------------------------------------------------------------- // Resetting a set to its default state //----------------------------------------------------------------------------- SetResetImpl::SetResetImpl( SetElementFactory& _rElementFactory, std::auto_ptr _pDefaultData, bool _bNoCheck ) : SetChangeImpl(_bNoCheck) , m_aDefaultData(_pDefaultData) , m_rElementFactory(_rElementFactory) , m_aTreeChanges() { } //----------------------------------------------------------------------------- SetResetImpl::~SetResetImpl() { } //----------------------------------------------------------------------------- RelativePath SetResetImpl::doGetChangingNodePath(ChangeCount _ix) const { OSL_ENSURE( _ix < m_aTreeChanges.size() || _ix == scCommonBase, "Illegal Change index" ); OSL_ASSERT( static_cast(scCommonBase) > m_aTreeChanges.size() ); if ( _ix < m_aTreeChanges.size() ) return RelativePath( m_aTreeChanges[_ix].m_aElementName); else return RelativePath(); } //----------------------------------------------------------------------------- static NodeChangeData::Type getChangeType(ElementTreeChange const& aChange) { sal_Bool bHasNew = aChange.m_aAddedElement.is(); sal_Bool bHasOld = aChange.m_aRemovedElement.is(); NodeChangeData::Type aResult; if (bHasNew) aResult = bHasOld ? NodeChangeData::eReplaceElement : NodeChangeData::eInsertElement; else aResult = bHasOld ? NodeChangeData::eRemoveElement : NodeChangeData::eSetDefault; return aResult; } //----------------------------------------------------------------------------- bool SetResetImpl::doIsChange() const { return !m_aTreeChanges.empty() || m_aDefaultData.get(); } //----------------------------------------------------------------------------- bool SetResetImpl::doFillChange(NodeChangeData& rChange, ChangeCount _ix) const { OSL_ENSURE( _ix < m_aTreeChanges.size() || _ix == scCommonBase, "Illegal Change index" ); if (_ix >= m_aTreeChanges.size()) { rChange.type = NodeChangeData::eResetSetDefault; return m_aDefaultData.get() != NULL; } ElementTreeChange const& aChange = m_aTreeChanges[_ix]; rChange.type = getChangeType(aChange); rChange.element.newValue = aChange.m_aAddedElement; rChange.element.oldValue = aChange.m_aRemovedElement; return true; } //----------------------------------------------------------------------------- void SetResetImpl::doTest( view::Node const& rTarget) { if ( m_aDefaultData.get() ) { view::ViewTreeAccess accessor = this->getTargetView(); view::SetNode aTargetSet(rTarget); std::auto_ptr pChanges = accessor.differenceToDefaultState(aTargetSet, *m_aDefaultData); if (pChanges.get()) { for (SubtreeChange::MutatingChildIterator it = pChanges->begin_changes(), stop = pChanges->end_changes(); it != stop; ++it) { Name aName = makeElementName(it->getNodeName(), Name::NoValidate()); SetEntry anExistingEntry = accessor.findElement(aTargetSet,aName); ElementTreeHolder aOldTree = anExistingEntry.tree(); ElementTreeHolder aNewTree; if (it->ISA(AddNode)) { AddNode& rAddNode = static_cast(*it); data::TreeSegment pAddedNode = rAddNode.getNewTree(); OSL_ENSURE(pAddedNode.is(),"Processing an addNode to default - no node to add"); aNewTree = m_rElementFactory.instantiateOnDefault(pAddedNode,accessor.getElementTemplate(aTargetSet)).get(); } Path::Component aFullName = aNewTree.is() ? aNewTree->getExtendedRootName() : aOldTree.is() ? aOldTree->getExtendedRootName() : Path::makeCompositeName(aName,accessor.getElementTemplate(aTargetSet)->getName()); OSL_ENSURE(aOldTree.is() || aNewTree.is(), "No data for change to default"); m_aTreeChanges.push_back(ElementTreeChange(aFullName,aNewTree,aOldTree)); } } m_aDefaultData.reset(); } } //----------------------------------------------------------------------------- void SetResetImpl::doApply( view::Node const& rTarget) { typedef TreeChanges::iterator Iter; view::ViewTreeAccess accessor = this->getTargetView(); view::SetNode aTargetSet(rTarget); for (Iter it = m_aTreeChanges.begin(); it != m_aTreeChanges.end(); ++it) { Name aElementName = it->m_aElementName.getName(); if (it->m_aRemovedElement.is()) accessor.removeElement(aTargetSet, aElementName); if (it->m_aAddedElement.is()) { SetEntry aNewEntry( it->m_aAddedElement.get() ); accessor.insertElement(aTargetSet, aElementName, aNewEntry); } OSL_ENSURE(getChangeType(*it) != NodeChangeData::eSetDefault, "Cannot apply change without data"); } } //----------------------------------------------------------------------------- // All Set Changes affecting a single element: SetElementChangeImpl - common base //----------------------------------------------------------------------------- SetElementChangeImpl::SetElementChangeImpl(Path::Component const& aName, bool bNoCheck) : SetChangeImpl(bNoCheck) , m_aName(aName) { } //----------------------------------------------------------------------------- RelativePath SetElementChangeImpl::doGetChangingNodePath(ChangeCount ) const { return RelativePath(getFullElementName()); } //----------------------------------------------------------------------------- void SetElementChangeImpl::doTest( view::Node const& rTarget) { doTestElement(view::SetNode(rTarget), getElementName() ); } //----------------------------------------------------------------------------- void SetElementChangeImpl::doApply( view::Node const& rTarget) { doApplyToElement(view::SetNode(rTarget), getElementName() ); } //----------------------------------------------------------------------------- // Full Sets: SetInsertTreeImpl //----------------------------------------------------------------------------- SetInsertImpl::SetInsertImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck) : SetElementChangeImpl(aName,bNoCheck) , m_aNewTree(aNewTree) { } //----------------------------------------------------------------------------- bool SetInsertImpl::doIsChange() const { return !!m_aNewTree.is(); } //----------------------------------------------------------------------------- bool SetInsertImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const { rChange.type = NodeChangeData::eInsertElement; if (m_aNewTree.is()) rChange.element.newValue = m_aNewTree; return isChange(true); } //----------------------------------------------------------------------------- void SetInsertImpl::doTestElement( view::SetNode const& _aNode, Name const& aName) { SetEntry anEntry = getTargetView().findElement(_aNode,aName); // require loaded children OSL_ENSURE(!anEntry.isValid(), "ERROR: Configuration: Adding a node that already exists"); } //----------------------------------------------------------------------------- void SetInsertImpl::doApplyToElement( view::SetNode const& _aNode, Name const& aName) { if (m_aNewTree.is()) { SetEntry aNewEntry( m_aNewTree.get() ); getTargetView().insertElement( _aNode, aName, aNewEntry); } } //----------------------------------------------------------------------------- // Full Sets: SetReplaceTreeImpl //----------------------------------------------------------------------------- SetReplaceImpl::SetReplaceImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree) : SetElementChangeImpl(aName) , m_aNewTree(aNewTree) , m_aOldTree() { } //----------------------------------------------------------------------------- SetReplaceImpl::SetReplaceImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree) : SetElementChangeImpl(aName,true) , m_aNewTree(aNewTree) , m_aOldTree(aOldTree) { } //----------------------------------------------------------------------------- /// checks, if this represents an actual change bool SetReplaceImpl::doIsChange() const { return !(m_aOldTree == m_aNewTree); } //----------------------------------------------------------------------------- /// fills in pre- and post-change values, returns wether they differ bool SetReplaceImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const { rChange.type = NodeChangeData::eReplaceElement; if (m_aNewTree.is()) rChange.element.newValue = m_aNewTree; if (m_aOldTree.is()) rChange.element.oldValue = m_aOldTree; return isChange(true); } //----------------------------------------------------------------------------- void SetReplaceImpl::doTestElement( view::SetNode const& _aNode, Name const& aName) { OSL_ASSERT(!m_aOldTree.is()); // already tested ? // remove the old node SetEntry anEntry = getTargetView().findElement(_aNode,aName); // require loaded children OSL_ENSURE(anEntry.isValid(), "ERROR: Configuration: Replacing a node that doesn't exist"); m_aOldTree = anEntry.tree(); } //----------------------------------------------------------------------------- void SetReplaceImpl::doApplyToElement( view::SetNode const& _aNode, Name const& aName) { if (m_aOldTree != m_aNewTree) { view::ViewTreeAccess aTargetView = this->getTargetView(); OSL_ENSURE(m_aOldTree.is(), "ERROR: Configuration: Replacing a node that doesn't exist"); aTargetView.removeElement(_aNode, aName); // add the new one OSL_ENSURE(m_aNewTree.is(), "ERROR: Configuration: Replacing a node with nothing"); if (m_aNewTree.is()) { SetEntry aNewEntry( m_aNewTree.get() ); aTargetView.insertElement( _aNode, aName, aNewEntry); } } } //----------------------------------------------------------------------------- // Full Sets: SetRemoveTreeImpl //----------------------------------------------------------------------------- SetRemoveImpl::SetRemoveImpl(Path::Component const& aName) : SetElementChangeImpl(aName) , m_aOldTree() { } //----------------------------------------------------------------------------- SetRemoveImpl::SetRemoveImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree) : SetElementChangeImpl(aName,true) , m_aOldTree(aOldTree) { } //----------------------------------------------------------------------------- /// checks, if this represents an actual change bool SetRemoveImpl::doIsChange() const { return !!m_aOldTree.is(); } //----------------------------------------------------------------------------- /// fills in pre- and post-change values, returns wether they differ bool SetRemoveImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const { rChange.type = NodeChangeData::eRemoveElement; if (m_aOldTree.is()) rChange.element.oldValue = m_aOldTree; return isChange(true); } //----------------------------------------------------------------------------- void SetRemoveImpl::doTestElement( view::SetNode const& _aNode, Name const& aName) { OSL_ASSERT(!m_aOldTree.is()); // already tested ? // remove the old node SetEntry anEntry = getTargetView().findElement(_aNode,aName); // require loaded children OSL_ENSURE(anEntry.isValid(), "ERROR: Configuration: Removing a node that doesn't exist"); m_aOldTree = anEntry.tree(); } //----------------------------------------------------------------------------- void SetRemoveImpl::doApplyToElement( view::SetNode const& _aNode, Name const& aName) { getTargetView().removeElement(_aNode, aName); } //----------------------------------------------------------------------------- } } 'libreoffice-4-0-1'>libreoffice-4-0-1 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-11-05tdf#42949 Fix new IWYU warnings in directories [ab]*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Ib0008b9bb095f27e5e436d6b507dc709ab7bf01a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105313 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-04-07SOSAW080: Added first bunch of basic changes to helpersArmin Le Grand
SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078 Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c Reviewed-on: https://gerrit.libreoffice.org/52526 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-04-06Revert "SOSAW080: Added first bunch of basic changes to helpers"Armin Le Grand
This reverts commit 6c14c27c75a03e2363f2b363ddf0a6f2f46cfa91.
2018-04-06SOSAW080: Added first bunch of basic changes to helpersArmin Le Grand
SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078
2017-11-18RotateFlyFrame3: Initial support addedArmin Le Grand
First steps to get a rotated FlyFrame and content that only uses layouted sizes/positions and does not change the model data (except rotation). This works with persistence, after reload the rotation can be resetted with going back to the original FrameSize. Lot of stuff not yet working, experimental state. Change-Id: Ie29d501fe2e618a1cb4457d600ce97575ed372d0
2014-03-28Merge back branch alg_writerframes to trunkArmin Le Grand
(cherry picked from commit b635b4fa4e42053d30ab639643d2236a20243f62) Conflicts: comphelper/inc/comphelper/TypeGeneration.hxx comphelper/source/property/TypeGeneration.cxx cui/source/factory/dlgfact.hxx cui/source/inc/cuitabarea.hxx cui/source/tabpages/tabarea.cxx cui/source/tabpages/tabarea.hrc cui/source/tabpages/tabarea.src cui/source/tabpages/tparea.cxx drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx drawinglayer/source/texture/texture.cxx editeng/inc/editeng/unotext.hxx editeng/source/items/frmitems.cxx include/drawinglayer/texture/texture.hxx include/editeng/brushitem.hxx include/svx/sdr/primitive2d/sdrdecompositiontools.hxx include/svx/svxids.hrc include/xmloff/xmltypes.hxx reportdesign/source/ui/misc/UITools.cxx sc/source/ui/drawfunc/drawsh.cxx sfx2/source/dialog/tabdlg.cxx svl/source/undo/undo.cxx svx/inc/svx/unoshprp.hxx sw/Library_sw.mk sw/inc/doc.hxx sw/inc/format.hxx sw/inc/frmfmt.hxx sw/inc/swatrset.hxx sw/inc/unomap.hxx sw/inc/unoprnms.hxx sw/source/core/access/accpara.cxx sw/source/core/attr/format.cxx sw/source/core/attr/swatrset.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docfly.cxx sw/source/core/doc/notxtfrm.cxx sw/source/core/inc/frame.hxx sw/source/core/inc/frmtool.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/porfld.cxx sw/source/core/text/txtfly.cxx sw/source/core/txtnode/fntcache.cxx sw/source/core/uibase/app/docst.cxx sw/source/core/uibase/app/docstyle.cxx sw/source/core/uibase/shells/drawdlg.cxx sw/source/core/uibase/shells/frmsh.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unomap.cxx sw/source/core/unocore/unoprnms.cxx sw/source/core/unocore/unostyle.cxx sw/source/ui/fmtui/tmpdlg.cxx sw/source/ui/fmtui/tmpdlg.src sw/source/ui/frmdlg/frmdlg.cxx sw/source/ui/frmdlg/frmpage.src sw/source/ui/inc/frmsh.hxx xmloff/source/text/txtprhdl.cxx xmloff/source/text/txtprmap.cxx Change-Id: Id3ffaa83bb5594d287f1ac8f2c1c9cf55c70946d