1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 // New mechanism to hold a ist of all original and cloned objects for later
23 // re-creating the connections for contained connectors
24 #include <clonelist.hxx>
25 #include <svx/svdoedge.hxx>
26 #include <svx/scene3d.hxx>
28 void CloneList::AddPair(const SdrObject
* pOriginal
, SdrObject
* pClone
)
30 maOriginalList
.push_back(pOriginal
);
31 maCloneList
.push_back(pClone
);
33 // look for subobjects, too.
34 bool bOriginalIsGroup(pOriginal
->IsGroupObject());
35 bool bCloneIsGroup(pClone
->IsGroupObject());
37 if(bOriginalIsGroup
&& pOriginal
->ISA(E3dObject
) && !pOriginal
->ISA(E3dScene
))
38 bOriginalIsGroup
= false;
40 if(bCloneIsGroup
&& pClone
->ISA(E3dObject
) && !pClone
->ISA(E3dScene
))
41 bCloneIsGroup
= false;
43 if(bOriginalIsGroup
&& bCloneIsGroup
)
45 const SdrObjList
* pOriginalList
= pOriginal
->GetSubList();
46 SdrObjList
* pCloneList
= pClone
->GetSubList();
48 if(pOriginalList
&& pCloneList
49 && pOriginalList
->GetObjCount() == pCloneList
->GetObjCount())
51 for(sal_uInt32
a(0); a
< pOriginalList
->GetObjCount(); a
++)
54 AddPair(pOriginalList
->GetObj(a
), pCloneList
->GetObj(a
));
60 const SdrObject
* CloneList::GetOriginal(sal_uInt32 nIndex
) const
62 return maOriginalList
[nIndex
];
65 SdrObject
* CloneList::GetClone(sal_uInt32 nIndex
) const
67 return maCloneList
[nIndex
];
70 void CloneList::CopyConnections() const
72 sal_uInt32 cloneCount
= maCloneList
.size();
74 for(sal_uInt32 a
= 0; a
< maOriginalList
.size(); a
++)
76 const SdrEdgeObj
* pOriginalEdge
= PTR_CAST(SdrEdgeObj
, GetOriginal(a
));
77 SdrEdgeObj
* pCloneEdge
= PTR_CAST(SdrEdgeObj
, GetClone(a
));
79 if(pOriginalEdge
&& pCloneEdge
)
81 SdrObject
* pOriginalNode1
= pOriginalEdge
->GetConnectedNode(true);
82 SdrObject
* pOriginalNode2
= pOriginalEdge
->GetConnectedNode(false);
86 std::vector
<const SdrObject
*>::const_iterator it
= std::find(maOriginalList
.begin(),
90 sal_uInt32 nPos
= it
- maOriginalList
.begin();
92 if(it
!= maOriginalList
.end())
94 SdrObject
*cObj
= NULL
;
96 if (nPos
< cloneCount
)
97 cObj
= GetClone(nPos
);
99 if(pOriginalEdge
->GetConnectedNode(true) != cObj
)
100 pCloneEdge
->ConnectToNode(true, cObj
);
106 std::vector
<const SdrObject
*>::const_iterator it
= std::find(maOriginalList
.begin(),
107 maOriginalList
.end(),
110 sal_uInt32 nPos
= it
- maOriginalList
.begin();
112 if(it
!= maOriginalList
.end())
114 SdrObject
*cObj
= NULL
;
116 if (nPos
< cloneCount
)
117 cObj
= GetClone(nPos
);
119 if(pOriginalEdge
->GetConnectedNode(false) != cObj
)
120 pCloneEdge
->ConnectToNode(false, cObj
);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */