Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/primitive3d/baseprimitive3d.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
#include <drawinglayer/primitive3d/baseprimitive3d.hxx>
21
#include <drawinglayer/geometry/viewinformation3d.hxx>
22
#include <basegfx/range/b3drange.hxx>
23
#include <basegfx/utils/canvastools.hxx>
24
#include <comphelper/sequence.hxx>
25
26
27
using namespace com::sun::star;
28
29
30
namespace drawinglayer::primitive3d
31
{
32
        BasePrimitive3D::BasePrimitive3D()
33
0
        {
34
0
        }
35
36
        BasePrimitive3D::~BasePrimitive3D()
37
0
        {
38
0
        }
39
40
        bool BasePrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const
41
0
        {
42
0
            return (getPrimitive3DID() == rPrimitive.getPrimitive3DID());
43
0
        }
44
45
        basegfx::B3DRange BasePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
46
0
        {
47
0
            return get3DDecomposition(rViewInformation).getB3DRange(rViewInformation);
48
0
        }
49
50
        Primitive3DContainer BasePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
51
0
        {
52
0
            return Primitive3DContainer();
53
0
        }
54
55
        css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive3D > > SAL_CALL BasePrimitive3D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters )
56
0
        {
57
0
            const geometry::ViewInformation3D aViewInformation(rViewParameters);
58
0
            return comphelper::containerToSequence(get3DDecomposition(aViewInformation));
59
0
        }
60
61
        css::geometry::RealRectangle3D SAL_CALL BasePrimitive3D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters )
62
0
        {
63
0
            const geometry::ViewInformation3D aViewInformation(rViewParameters);
64
0
            return basegfx::unotools::rectangle3DFromB3DRectangle(getB3DRange(aViewInformation));
65
0
        }
66
67
68
        Primitive3DContainer BufferedDecompositionPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
69
0
        {
70
0
            return Primitive3DContainer();
71
0
        }
72
73
        BufferedDecompositionPrimitive3D::BufferedDecompositionPrimitive3D()
74
0
        {
75
0
        }
76
77
        Primitive3DContainer BufferedDecompositionPrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const
78
0
        {
79
0
            std::unique_lock aGuard( m_aMutex );
80
81
0
            if(getBuffered3DDecomposition().empty())
82
0
            {
83
0
                const Primitive3DContainer aNewSequence(create3DDecomposition(rViewInformation));
84
0
                const_cast< BufferedDecompositionPrimitive3D* >(this)->setBuffered3DDecomposition(aNewSequence);
85
0
            }
86
87
0
            return getBuffered3DDecomposition();
88
0
        }
89
90
// tooling
91
92
        // get range3D from a given Primitive3DReference
93
        basegfx::B3DRange getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, const geometry::ViewInformation3D& aViewInformation)
94
0
        {
95
0
            basegfx::B3DRange aRetval;
96
97
0
            if(rCandidate.is())
98
0
            {
99
0
                const BasePrimitive3D* pCandidate(static_cast< BasePrimitive3D* >(rCandidate.get()));
100
0
                aRetval.expand(pCandidate->getB3DRange(aViewInformation));
101
0
            }
102
103
0
            return aRetval;
104
0
        }
105
106
        // get range3D from a given Primitive3DContainer
107
        basegfx::B3DRange Primitive3DContainer::getB3DRange(const geometry::ViewInformation3D& aViewInformation) const
108
0
        {
109
0
            basegfx::B3DRange aRetval;
110
111
0
            if(!empty())
112
0
            {
113
0
                const size_t nCount(size());
114
115
0
                for(size_t a(0); a < nCount; a++)
116
0
                {
117
0
                    aRetval.expand(getB3DRangeFromPrimitive3DReference((*this)[a], aViewInformation));
118
0
                }
119
0
            }
120
121
0
            return aRetval;
122
0
        }
123
124
        bool arePrimitive3DReferencesEqual(const Primitive3DReference& rxA, const Primitive3DReference& rxB)
125
0
        {
126
0
            const bool bAIs(rxA.is());
127
128
0
            if(bAIs != rxB.is())
129
0
            {
130
0
                return false;
131
0
            }
132
133
0
            if(!bAIs)
134
0
            {
135
0
                return true;
136
0
            }
137
138
0
            const BasePrimitive3D* pA(static_cast< const BasePrimitive3D* >(rxA.get()));
139
0
            const BasePrimitive3D* pB(static_cast< const BasePrimitive3D* >(rxB.get()));
140
141
0
            return pA->operator==(*pB);
142
0
        }
143
144
        bool Primitive3DContainer::operator==(const Primitive3DContainer& rB) const
145
0
        {
146
0
            const bool bAHasElements(!empty());
147
148
0
            if(bAHasElements != !rB.empty())
149
0
            {
150
0
                return false;
151
0
            }
152
153
0
            if(!bAHasElements)
154
0
            {
155
0
                return true;
156
0
            }
157
158
0
            const size_t nCount(size());
159
160
0
            if(nCount != rB.size())
161
0
            {
162
0
                return false;
163
0
            }
164
165
0
            for(size_t a(0); a < nCount; a++)
166
0
            {
167
0
                if(!arePrimitive3DReferencesEqual((*this)[a], rB[a]))
168
0
                {
169
0
                    return false;
170
0
                }
171
0
            }
172
173
0
            return true;
174
0
        }
175
176
        void Primitive3DContainer::append(const Primitive3DContainer& rSource)
177
0
        {
178
0
            insert(end(), rSource.begin(), rSource.end());
179
0
        }
180
181
} // end of namespace
182
183
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */