Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/drawfunc/fuconarc.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 <fuconarc.hxx>
21
#include <tabvwsh.hxx>
22
#include <drawview.hxx>
23
24
// Create default drawing objects via keyboard
25
#include <svx/svdocirc.hxx>
26
#include <svx/svxids.hrc>
27
#include <svx/sxciaitm.hxx>
28
#include <osl/diagnose.h>
29
30
FuConstArc::FuConstArc(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
31
                       SdrModel& rDoc, const SfxRequest& rReq)
32
0
    : FuConstruct(rViewSh, pWin, pViewP, rDoc, rReq)
33
0
{
34
0
}
35
36
FuConstArc::~FuConstArc()
37
0
{
38
0
}
39
40
bool FuConstArc::MouseButtonDown( const MouseEvent& rMEvt )
41
0
{
42
    // remember button state for creation of own MouseEvents
43
0
    SetMouseButtonCode(rMEvt.GetButtons());
44
45
0
    bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
46
47
0
    if ( rMEvt.IsLeft() && !pView->IsAction() )
48
0
    {
49
0
        Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
50
0
        pWindow->CaptureMouse();
51
0
        pView->BegCreateObj( aPnt );
52
0
        bReturn = true;
53
0
    }
54
0
    return bReturn;
55
0
}
56
57
bool FuConstArc::MouseButtonUp( const MouseEvent& rMEvt )
58
0
{
59
    // remember button state for creation of own MouseEvents
60
0
    SetMouseButtonCode(rMEvt.GetButtons());
61
62
0
    bool bReturn = false;
63
64
0
    if ( pView->IsCreateObj() && rMEvt.IsLeft() )
65
0
    {
66
0
        pView->EndCreateObj( SdrCreateCmd::NextPoint );
67
0
        bReturn = true;
68
0
    }
69
0
    return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
70
0
}
71
72
void FuConstArc::Activate()
73
0
{
74
0
    SdrObjKind aObjKind;
75
76
0
    switch (aSfxRequest.GetSlot() )
77
0
    {
78
0
        case SID_DRAW_ARC:
79
0
            aNewPointer = PointerStyle::DrawArc;
80
0
            aObjKind = SdrObjKind::CircleArc;
81
0
            break;
82
83
0
        case SID_DRAW_PIE:
84
0
            aNewPointer = PointerStyle::DrawPie;
85
0
            aObjKind = SdrObjKind::CircleSection;
86
0
            break;
87
88
0
        case SID_DRAW_CIRCLECUT:
89
0
            aNewPointer = PointerStyle::DrawCircleCut;
90
0
            aObjKind = SdrObjKind::CircleCut;
91
0
            break;
92
93
0
        default:
94
0
            aNewPointer = PointerStyle::Cross;
95
0
            aObjKind = SdrObjKind::CircleArc;
96
0
            break;
97
0
    }
98
99
0
    pView->SetCurrentObj(aObjKind);
100
101
0
    aOldPointer = pWindow->GetPointer();
102
0
    rViewShell.SetActivePointer( aNewPointer );
103
104
0
    FuDraw::Activate();
105
0
}
106
107
void FuConstArc::Deactivate()
108
0
{
109
0
    FuDraw::Deactivate();
110
0
    rViewShell.SetActivePointer( aOldPointer );
111
0
}
112
113
// Create default drawing objects via keyboard
114
rtl::Reference<SdrObject> FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
115
0
{
116
    // case SID_DRAW_ARC:
117
    // case SID_DRAW_PIE:
118
    // case SID_DRAW_CIRCLECUT:
119
120
0
    rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
121
0
        rDrDoc,
122
0
        pView->GetCurrentObjInventor(),
123
0
        pView->GetCurrentObjIdentifier()));
124
125
0
    if(pObj)
126
0
    {
127
0
        if(dynamic_cast<const SdrCircObj*>( pObj.get() ) !=  nullptr)
128
0
        {
129
0
            tools::Rectangle aRect(rRectangle);
130
131
0
            if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
132
0
            {
133
                // force quadratic
134
0
                ImpForceQuadratic(aRect);
135
0
            }
136
137
0
            pObj->SetLogicRect(aRect);
138
139
0
            SfxItemSet aAttr(rDrDoc.GetItemPool());
140
0
            aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
141
0
            aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
142
143
0
            pObj->SetMergedItemSet(aAttr);
144
0
        }
145
0
        else
146
0
        {
147
0
            OSL_FAIL("Object is NO circle object");
148
0
        }
149
0
    }
150
151
0
    return pObj;
152
0
}
153
154
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */