Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svx/source/sdr/overlay/overlayrectangle.cxx
Line
Count
Source (jump to first uncovered line)
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 <sdr/overlay/overlayrectangle.hxx>
21
#include <sdr/overlay/overlaytools.hxx>
22
#include <svx/sdr/overlay/overlaymanager.hxx>
23
#include <vcl/svapp.hxx>
24
#include <vcl/settings.hxx>
25
26
27
namespace sdr::overlay
28
{
29
        drawinglayer::primitive2d::Primitive2DContainer OverlayRectangle::createOverlayObjectPrimitive2DSequence()
30
0
        {
31
0
            const basegfx::B2DRange aHatchRange(getBasePosition(), maSecondPosition);
32
0
            basegfx::BColor aColor(getBaseColor().getBColor());
33
0
            static const double fChange(0.1); // just small optical change, do not make it annoying
34
35
0
            if(mbOverlayState)
36
0
            {
37
0
                aColor += basegfx::B3DTuple(fChange, fChange, fChange);
38
0
                aColor.clamp();
39
0
            }
40
0
            else
41
0
            {
42
0
                aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
43
0
                aColor.clamp();
44
0
            }
45
46
0
            const drawinglayer::primitive2d::Primitive2DReference aReference(
47
0
                new drawinglayer::primitive2d::OverlayRectanglePrimitive(
48
0
                    aHatchRange,
49
0
                    aColor,
50
0
                    mfTransparence,
51
0
                    mfDiscreteGrow,
52
0
                    mfDiscreteShrink,
53
0
                    mfRotation));
54
55
0
            return drawinglayer::primitive2d::Primitive2DContainer { aReference };
56
0
        }
57
58
        OverlayRectangle::OverlayRectangle(
59
            const basegfx::B2DPoint& rBasePosition,
60
            const basegfx::B2DPoint& rSecondPosition,
61
            const Color& rHatchColor,
62
            double fTransparence,
63
            double fDiscreteGrow,
64
            double fDiscreteShrink,
65
            double fRotation,
66
            bool bAnimate)
67
0
        :   OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
68
0
            maSecondPosition(rSecondPosition),
69
0
            mfTransparence(fTransparence),
70
0
            mfDiscreteGrow(fDiscreteGrow),
71
0
            mfDiscreteShrink(fDiscreteShrink),
72
0
            mfRotation(fRotation),
73
0
            mnBlinkTime(impCheckBlinkTimeValueRange(500)),
74
0
            mbOverlayState(false)
75
0
        {
76
0
            if (!MiscSettings::IsAnimatedOthersAllowed())
77
0
                bAnimate = false;
78
79
            // set AllowsAnimation flag to mark this object as animation capable
80
0
            mbAllowsAnimation = bAnimate;
81
            // use selection colors in HighContrast mode
82
0
            mbHighContrastSelection = true;
83
0
        }
84
85
        void OverlayRectangle::Trigger(sal_uInt32 nTime)
86
0
        {
87
0
            if(!getOverlayManager())
88
0
                return;
89
90
            // #i53216# produce event after nTime + x
91
0
            SetTime(nTime + mnBlinkTime);
92
93
            // switch state
94
0
            if(mbOverlayState)
95
0
            {
96
0
                mbOverlayState = false;
97
0
            }
98
0
            else
99
0
            {
100
0
                mbOverlayState = true;
101
0
            }
102
103
            // re-insert me as event
104
0
            getOverlayManager()->InsertEvent(*this);
105
106
            // register change (after change)
107
0
            objectChange();
108
0
        }
109
} // end of namespace
110
111
112
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */