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