1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 // #i13033# 32 // New mechanism to hold a ist of all original and cloned objects for later 33 // re-creating the connections for contained connectors 34 #include <clonelist.hxx> 35 #include <svx/svdoedge.hxx> 36 #include <svx/scene3d.hxx> 37 38 CloneList::CloneList() 39 { 40 } 41 42 CloneList::~CloneList() 43 { 44 } 45 46 void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone) 47 { 48 maOriginalList.Insert((SdrObject*)pOriginal, LIST_APPEND); 49 maCloneList.Insert(pClone, LIST_APPEND); 50 51 // look for subobjects, too. 52 sal_Bool bOriginalIsGroup(pOriginal->IsGroupObject()); 53 sal_Bool bCloneIsGroup(pClone->IsGroupObject()); 54 55 if(bOriginalIsGroup && pOriginal->ISA(E3dObject) && !pOriginal->ISA(E3dScene)) 56 bOriginalIsGroup = sal_False; 57 58 if(bCloneIsGroup && pClone->ISA(E3dObject) && !pClone->ISA(E3dScene)) 59 bCloneIsGroup = sal_False; 60 61 if(bOriginalIsGroup && bCloneIsGroup) 62 { 63 const SdrObjList* pOriginalList = pOriginal->GetSubList(); 64 SdrObjList* pCloneList = pClone->GetSubList(); 65 66 if(pOriginalList && pCloneList 67 && pOriginalList->GetObjCount() == pCloneList->GetObjCount()) 68 { 69 for(sal_uInt32 a(0); a < pOriginalList->GetObjCount(); a++) 70 { 71 // recursive call 72 AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a)); 73 } 74 } 75 } 76 } 77 78 sal_uInt32 CloneList::Count() const 79 { 80 return maOriginalList.Count(); 81 } 82 83 const SdrObject* CloneList::GetOriginal(sal_uInt32 nIndex) const 84 { 85 return (SdrObject*)maOriginalList.GetObject(nIndex); 86 } 87 88 SdrObject* CloneList::GetClone(sal_uInt32 nIndex) const 89 { 90 return (SdrObject*)maCloneList.GetObject(nIndex); 91 } 92 93 void CloneList::CopyConnections() const 94 { 95 for(sal_uInt32 a(0); a < maOriginalList.Count(); a++) 96 { 97 const SdrEdgeObj* pOriginalEdge = PTR_CAST(SdrEdgeObj, GetOriginal(a)); 98 SdrEdgeObj* pCloneEdge = PTR_CAST(SdrEdgeObj, GetClone(a)); 99 100 if(pOriginalEdge && pCloneEdge) 101 { 102 SdrObject* pOriginalNode1 = pOriginalEdge->GetConnectedNode(sal_True); 103 SdrObject* pOriginalNode2 = pOriginalEdge->GetConnectedNode(sal_False); 104 105 if(pOriginalNode1) 106 { 107 sal_uLong nPos(maOriginalList.GetPos(pOriginalNode1)); 108 109 if(LIST_ENTRY_NOTFOUND != nPos) 110 { 111 if(pOriginalEdge->GetConnectedNode(sal_True) != GetClone(nPos)) 112 { 113 pCloneEdge->ConnectToNode(sal_True, GetClone(nPos)); 114 } 115 } 116 } 117 118 if(pOriginalNode2) 119 { 120 sal_uLong nPos(maOriginalList.GetPos(pOriginalNode2)); 121 122 if(LIST_ENTRY_NOTFOUND != nPos) 123 { 124 if(pOriginalEdge->GetConnectedNode(sal_False) != GetClone(nPos)) 125 { 126 pCloneEdge->ConnectToNode(sal_False, GetClone(nPos)); 127 } 128 } 129 } 130 } 131 } 132 } 133 134 // eof 135