Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/ribbar/conform.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 <svx/svdview.hxx>
21
#include <vcl/ptrstyle.hxx>
22
23
#include <swmodule.hxx>
24
#include <view.hxx>
25
#include <edtwin.hxx>
26
#include <wrtsh.hxx>
27
#include <drawbase.hxx>
28
#include <conform.hxx>
29
30
ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView& rSwView, SdrObjKind eObjKind)
31
0
    : SwDrawBase(pWrtShell, pEditWin, rSwView)
32
0
    , m_eObjKind(eObjKind)
33
0
{
34
0
    m_bInsForm = true;
35
0
}
36
37
bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
38
0
{
39
0
    bool bReturn = false;
40
41
0
    SdrView *pSdrView = m_pSh->GetDrawView();
42
43
0
    pSdrView->SetOrtho(rMEvt.IsShift());
44
0
    pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
45
46
0
    if (rMEvt.IsMod2())
47
0
    {
48
0
        pSdrView->SetCreate1stPointAsCenter(true);
49
0
        pSdrView->SetResizeAtCenter(true);
50
0
    }
51
0
    else
52
0
    {
53
0
        pSdrView->SetCreate1stPointAsCenter(false);
54
0
        pSdrView->SetResizeAtCenter(false);
55
0
    }
56
57
0
    SdrViewEvent aVEvt;
58
0
    SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
59
60
    // Only new object; if not in base mode (or pure selection mode)
61
0
    if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
62
0
        (eHit == SdrHitKind::UnmarkedObject || eHit == SdrHitKind::NONE || m_pSh->IsDrawCreate()))
63
0
    {
64
0
        g_bNoInterrupt = true;
65
0
        m_pWin->CaptureMouse();
66
67
0
        m_pWin->SetPointer(PointerStyle::DrawRect);
68
69
0
        m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
70
0
        bReturn = m_pSh->BeginCreate(m_pWin->GetSdrDrawMode(), SdrInventor::FmForm, m_aStartPos);
71
72
0
        if (bReturn)
73
0
            m_pWin->SetDrawAction(true);
74
0
    }
75
0
    else
76
0
        bReturn = SwDrawBase::MouseButtonDown(rMEvt);
77
78
0
    return bReturn;
79
0
}
80
81
void ConstFormControl::Activate(const sal_uInt16 nSlotId)
82
0
{
83
0
    m_pWin->SetSdrDrawMode(m_eObjKind);
84
0
    SwDrawBase::Activate(nSlotId);
85
0
    m_pSh->GetDrawView()->SetCurrentObj(m_eObjKind);
86
87
0
    m_pWin->SetPointer(PointerStyle::DrawRect);
88
0
}
89
90
void ConstFormControl::CreateDefaultObject()
91
0
{
92
0
    constexpr tools::Long constTwips_5mm = o3tl::toTwips(5, o3tl::Length::mm);
93
0
    constexpr tools::Long constTwips_10mm = o3tl::toTwips(10, o3tl::Length::mm);
94
95
0
    Point aStartPos(GetDefaultCenterPos());
96
0
    Point aEndPos(aStartPos);
97
0
    aStartPos.AdjustX(-constTwips_10mm);
98
0
    aStartPos.AdjustY(-constTwips_5mm);
99
0
    aEndPos.AdjustX(constTwips_10mm);
100
0
    aEndPos.AdjustY(constTwips_5mm);
101
102
0
    if(!m_pSh->HasDrawView())
103
0
        m_pSh->MakeDrawView();
104
105
0
    SdrView *pSdrView = m_pSh->GetDrawView();
106
0
    pSdrView->SetDesignMode();
107
0
    m_pSh->BeginCreate(m_pWin->GetSdrDrawMode(), SdrInventor::FmForm, aStartPos);
108
0
    m_pSh->MoveCreate(aEndPos);
109
0
    m_pSh->EndCreate(SdrCreateCmd::ForceEnd);
110
0
}
111
112
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */