Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/primitive2d/primitivetools2d.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/primitive2d/primitivetools2d.hxx>
21
#include <basegfx/vector/b2dvector.hxx>
22
#include <drawinglayer/geometry/viewinformation2d.hxx>
23
24
25
namespace drawinglayer::primitive2d
26
{
27
        void DiscreteMetricDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
28
0
        {
29
            // get the current DiscreteUnit, look at X and Y and use the maximum
30
0
            const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
31
0
            const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
32
0
            if(basegfx::fTools::equalZero(fDiscreteUnit))
33
0
                return;
34
35
0
            if(hasBuffered2DDecomposition() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
36
0
            {
37
                // conditions of last local decomposition have changed, delete
38
0
                const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(nullptr);
39
0
            }
40
41
0
            if(!hasBuffered2DDecomposition())
42
0
            {
43
                // remember new valid DiscreteUnit
44
0
                const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
45
0
            }
46
47
            // call base implementation
48
0
            BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
49
0
        }
50
51
52
53
54
        void ViewportDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
55
0
        {
56
            // get the current Viewport
57
0
            const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
58
59
0
            if(hasBuffered2DDecomposition() && !rViewport.equal(getViewport()))
60
0
            {
61
                // conditions of last local decomposition have changed, delete
62
0
                const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(nullptr);
63
0
            }
64
65
0
            if(!hasBuffered2DDecomposition())
66
0
            {
67
                // remember new valid DiscreteUnit
68
0
                const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
69
0
            }
70
71
            // call base implementation
72
0
            BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
73
0
        }
74
75
        void ViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
76
0
        {
77
            // get the current ViewTransformation
78
0
            const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
79
80
0
            if(hasBuffered2DDecomposition() && rViewTransformation != getViewTransformation())
81
0
            {
82
                // conditions of last local decomposition have changed, delete
83
0
                const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(nullptr);
84
0
            }
85
86
0
            if(!hasBuffered2DDecomposition())
87
0
            {
88
                // remember new valid ViewTransformation
89
0
                const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
90
0
            }
91
92
            // call base implementation
93
0
            BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
94
0
        }
95
96
        void ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
97
0
        {
98
            // get the current ViewTransformation
99
0
            const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
100
101
0
            if(hasBuffered2DDecomposition() && rViewTransformation != getViewTransformation())
102
0
            {
103
                // conditions of last local decomposition have changed, delete
104
0
                const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(nullptr);
105
0
            }
106
107
            // get the current ObjectTransformation
108
0
            const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
109
110
0
            if(hasBuffered2DDecomposition() && rObjectTransformation != getObjectTransformation())
111
0
            {
112
                // conditions of last local decomposition have changed, delete
113
0
                const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(nullptr);
114
0
            }
115
116
0
            if(!hasBuffered2DDecomposition())
117
0
            {
118
                // remember new valid ViewTransformation, and ObjectTransformation
119
0
                const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
120
0
                const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
121
0
            }
122
123
            // call base implementation
124
0
            BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
125
0
        }
126
127
} // end of namespace
128
129
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */