1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // #i13033#
28*4d196ef4Smseidel // New mechanism to hold a list of all original and cloned objects for later
29cdf0e10cSrcweir // re-creating the connections for contained connectors
30cdf0e10cSrcweir #include <clonelist.hxx>
31cdf0e10cSrcweir #include <svx/svdoedge.hxx>
32cdf0e10cSrcweir #include <svx/scene3d.hxx>
33cdf0e10cSrcweir
CloneList()34cdf0e10cSrcweir CloneList::CloneList()
35cdf0e10cSrcweir {
36cdf0e10cSrcweir }
37cdf0e10cSrcweir
~CloneList()38cdf0e10cSrcweir CloneList::~CloneList()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir }
41cdf0e10cSrcweir
AddPair(const SdrObject * pOriginal,SdrObject * pClone)42cdf0e10cSrcweir void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone)
43cdf0e10cSrcweir {
44cdf0e10cSrcweir maOriginalList.Insert((SdrObject*)pOriginal, LIST_APPEND);
45cdf0e10cSrcweir maCloneList.Insert(pClone, LIST_APPEND);
46cdf0e10cSrcweir
47cdf0e10cSrcweir // look for subobjects, too.
48cdf0e10cSrcweir sal_Bool bOriginalIsGroup(pOriginal->IsGroupObject());
49cdf0e10cSrcweir sal_Bool bCloneIsGroup(pClone->IsGroupObject());
50cdf0e10cSrcweir
51cdf0e10cSrcweir if(bOriginalIsGroup && pOriginal->ISA(E3dObject) && !pOriginal->ISA(E3dScene))
52cdf0e10cSrcweir bOriginalIsGroup = sal_False;
53cdf0e10cSrcweir
54cdf0e10cSrcweir if(bCloneIsGroup && pClone->ISA(E3dObject) && !pClone->ISA(E3dScene))
55cdf0e10cSrcweir bCloneIsGroup = sal_False;
56cdf0e10cSrcweir
57cdf0e10cSrcweir if(bOriginalIsGroup && bCloneIsGroup)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir const SdrObjList* pOriginalList = pOriginal->GetSubList();
60cdf0e10cSrcweir SdrObjList* pCloneList = pClone->GetSubList();
61cdf0e10cSrcweir
62cdf0e10cSrcweir if(pOriginalList && pCloneList
63cdf0e10cSrcweir && pOriginalList->GetObjCount() == pCloneList->GetObjCount())
64cdf0e10cSrcweir {
65cdf0e10cSrcweir for(sal_uInt32 a(0); a < pOriginalList->GetObjCount(); a++)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir // recursive call
68cdf0e10cSrcweir AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a));
69cdf0e10cSrcweir }
70cdf0e10cSrcweir }
71cdf0e10cSrcweir }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
Count() const74cdf0e10cSrcweir sal_uInt32 CloneList::Count() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir return maOriginalList.Count();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
GetOriginal(sal_uInt32 nIndex) const79cdf0e10cSrcweir const SdrObject* CloneList::GetOriginal(sal_uInt32 nIndex) const
80cdf0e10cSrcweir {
81cdf0e10cSrcweir return (SdrObject*)maOriginalList.GetObject(nIndex);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
GetClone(sal_uInt32 nIndex) const84cdf0e10cSrcweir SdrObject* CloneList::GetClone(sal_uInt32 nIndex) const
85cdf0e10cSrcweir {
86cdf0e10cSrcweir return (SdrObject*)maCloneList.GetObject(nIndex);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
CopyConnections() const89cdf0e10cSrcweir void CloneList::CopyConnections() const
90cdf0e10cSrcweir {
91cdf0e10cSrcweir for(sal_uInt32 a(0); a < maOriginalList.Count(); a++)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir const SdrEdgeObj* pOriginalEdge = PTR_CAST(SdrEdgeObj, GetOriginal(a));
94cdf0e10cSrcweir SdrEdgeObj* pCloneEdge = PTR_CAST(SdrEdgeObj, GetClone(a));
95cdf0e10cSrcweir
96cdf0e10cSrcweir if(pOriginalEdge && pCloneEdge)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir SdrObject* pOriginalNode1 = pOriginalEdge->GetConnectedNode(sal_True);
99cdf0e10cSrcweir SdrObject* pOriginalNode2 = pOriginalEdge->GetConnectedNode(sal_False);
100cdf0e10cSrcweir
101cdf0e10cSrcweir if(pOriginalNode1)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir sal_uLong nPos(maOriginalList.GetPos(pOriginalNode1));
104cdf0e10cSrcweir
105cdf0e10cSrcweir if(LIST_ENTRY_NOTFOUND != nPos)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir if(pOriginalEdge->GetConnectedNode(sal_True) != GetClone(nPos))
108cdf0e10cSrcweir {
109cdf0e10cSrcweir pCloneEdge->ConnectToNode(sal_True, GetClone(nPos));
110cdf0e10cSrcweir }
111cdf0e10cSrcweir }
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir if(pOriginalNode2)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir sal_uLong nPos(maOriginalList.GetPos(pOriginalNode2));
117cdf0e10cSrcweir
118cdf0e10cSrcweir if(LIST_ENTRY_NOTFOUND != nPos)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir if(pOriginalEdge->GetConnectedNode(sal_False) != GetClone(nPos))
121cdf0e10cSrcweir {
122cdf0e10cSrcweir pCloneEdge->ConnectToNode(sal_False, GetClone(nPos));
123cdf0e10cSrcweir }
124cdf0e10cSrcweir }
125cdf0e10cSrcweir }
126cdf0e10cSrcweir }
127cdf0e10cSrcweir }
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130*4d196ef4Smseidel /* vim: set noet sw=4 ts=4: */
131