Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/svdraw/clonelist.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
21
// #i13033#
22
// New mechanism to hold a list 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/svdpage.hxx>
27
28
void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone)
29
17.9k
{
30
17.9k
    maOriginalList.push_back(pOriginal);
31
17.9k
    maCloneList.push_back(pClone);
32
33
    // look for subobjects, too.
34
17.9k
    bool bOriginalIsGroup(pOriginal->IsGroupObject());
35
17.9k
    bool bCloneIsGroup(pClone->IsGroupObject());
36
37
17.9k
    if(bOriginalIsGroup && DynCastE3dObject(pOriginal) != nullptr && DynCastE3dScene(pOriginal) == nullptr )
38
0
        bOriginalIsGroup = false;
39
40
17.9k
    if(bCloneIsGroup && DynCastE3dObject(pClone) != nullptr && DynCastE3dScene(pClone) == nullptr)
41
0
        bCloneIsGroup = false;
42
43
17.9k
    if(!(bOriginalIsGroup && bCloneIsGroup))
44
17.7k
        return;
45
46
180
    const SdrObjList* pOriginalList = pOriginal->GetSubList();
47
180
    SdrObjList* pCloneList = pClone->GetSubList();
48
49
180
    if(pOriginalList && pCloneList
50
180
        && pOriginalList->GetObjCount() == pCloneList->GetObjCount())
51
180
    {
52
543
        for(size_t a = 0; a < pOriginalList->GetObjCount(); ++a)
53
363
        {
54
            // recursive call
55
363
            AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a));
56
363
        }
57
180
    }
58
180
}
59
60
const SdrObject* CloneList::GetOriginal(sal_uInt32 nIndex) const
61
17.9k
{
62
17.9k
    return maOriginalList[nIndex];
63
17.9k
}
64
65
SdrObject* CloneList::GetClone(sal_uInt32 nIndex) const
66
17.9k
{
67
17.9k
    return maCloneList[nIndex];
68
17.9k
}
69
70
void CloneList::CopyConnections() const
71
8.10k
{
72
8.10k
    sal_uInt32 cloneCount = maCloneList.size();
73
74
26.0k
    for(size_t a = 0; a < maOriginalList.size(); a++)
75
17.9k
    {
76
17.9k
        const SdrEdgeObj* pOriginalEdge = dynamic_cast<const SdrEdgeObj*>( GetOriginal(a) );
77
17.9k
        SdrEdgeObj* pCloneEdge = dynamic_cast<SdrEdgeObj*>( GetClone(a) );
78
79
17.9k
        if(pOriginalEdge && pCloneEdge)
80
36
        {
81
36
            for (bool bTail1 : { true, false })
82
72
            {
83
72
                SdrObject* pOriginalNode = pOriginalEdge->GetConnectedNode(bTail1);
84
72
                if (pOriginalNode)
85
0
                {
86
0
                    std::vector<const SdrObject*>::const_iterator it = std::find(maOriginalList.begin(),
87
0
                                                                     maOriginalList.end(),
88
0
                                                                     pOriginalNode);
89
90
0
                    if(it != maOriginalList.end())
91
0
                    {
92
0
                        sal_uInt32 nPos = it - maOriginalList.begin();
93
0
                        SdrObject *cObj = nullptr;
94
95
0
                        if (nPos < cloneCount)
96
0
                            cObj = GetClone(nPos);
97
98
0
                        if(pOriginalNode != cObj)
99
0
                            pCloneEdge->ConnectToNode(bTail1, cObj);
100
0
                    }
101
0
                }
102
72
            }
103
36
        }
104
17.9k
    }
105
8.10k
}
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */