Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/docvw/edtwin3.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 <vcl/event.hxx>
21
#include <vcl/settings.hxx>
22
#include <svx/ruler.hxx>
23
#include <view.hxx>
24
#include <wrtsh.hxx>
25
#include <basesh.hxx>
26
#include <pview.hxx>
27
#include <mdiexp.hxx>
28
#include <edtwin.hxx>
29
#include <swmodule.hxx>
30
#include <modcfg.hxx>
31
#include <docsh.hxx>
32
#include <uiobject.hxx>
33
34
// Core-Notify
35
void ScrollMDI( SwViewShell const & rVwSh, const SwRect &rRect,
36
                sal_uInt16 nRangeX, sal_uInt16 nRangeY,
37
                ScrollSizeMode eScrollSizeMode)
38
3.88k
{
39
3.88k
    SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell();
40
41
3.88k
    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
42
3.88k
        pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY, eScrollSizeMode);
43
3.88k
}
44
45
// Docmdi - movable
46
bool IsScrollMDI( SwViewShell const & rVwSh, const SwRect &rRect )
47
0
{
48
0
    SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell();
49
50
0
    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
51
0
        return pSwView->IsScroll(rRect.SVRect());
52
53
0
    return false;
54
0
}
55
56
// Notify for size change
57
void SizeNotify(SwViewShell const & rVwSh, const Size &rSize)
58
20.3k
{
59
20.3k
    SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell();
60
61
20.3k
    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
62
2.17k
        pSwView->DocSzChgd(rSize);
63
18.2k
    else if (SwPagePreview* pSwPageView = dynamic_cast<SwPagePreview *>(pSfxViewShell))
64
0
        pSwPageView->DocSzChgd(rSize);
65
20.3k
}
66
67
// Notify for page number update
68
void PageNumNotify(SwViewShell const & rVwSh)
69
14.7k
{
70
14.7k
    SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell();
71
72
14.7k
    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
73
14.7k
    {
74
14.7k
        if (pSwView->GetCurShell())
75
6.45k
            pSwView->UpdatePageNums();
76
14.7k
    }
77
14.7k
}
78
79
void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
80
0
{
81
0
    if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
82
0
        SwBaseShell::SetFrameMode(eMode, pWrtShell);
83
0
}
84
85
// Notify for page number update
86
bool SwEditWin::RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode)
87
0
{
88
    // Especially on bigger zoom, changed mouse pointer didn't guarantee
89
    // drag & drop any more because of too small hit area in pixel.
90
    // Enlarge it 5 pixels to cover the whole hit area.
91
0
    tools::Long nTol = 5L;
92
0
    SvxRuler& rRuler = bVerticalMode ?  m_rView.GetVRuler() : m_rView.GetHRuler();
93
0
    return (!rRuler.StartDocDrag( rMEvt, RulerType::Border, nTol ) &&
94
0
            !rRuler.StartDocDrag( rMEvt, RulerType::Margin1, nTol ) &&
95
0
            !rRuler.StartDocDrag( rMEvt, RulerType::Margin2, nTol ));
96
0
}
97
98
// #i23726#
99
// #i42921# - add 3rd parameter <bVerticalMode> in order
100
// to consider vertical layout
101
bool SwEditWin::RulerMarginDrag( const MouseEvent& rMEvt,
102
                                 const bool bVerticalMode )
103
0
{
104
0
    SvxRuler& rRuler = bVerticalMode ?  m_rView.GetVRuler() : m_rView.GetHRuler();
105
0
    return !rRuler.StartDocDrag( rMEvt, RulerType::Indent);
106
0
}
107
108
TableChgMode GetTableChgDefaultMode()
109
78.6k
{
110
78.6k
    SwModuleOptions* pOpt = SwModule::get()->GetModuleConfig();
111
78.6k
    return pOpt ? pOpt->GetTableMode() : TableChgMode::VarWidthChangeAbs;
112
78.6k
}
113
114
void RepaintPagePreview( SwViewShell const * pVwSh, const SwRect& rRect )
115
0
{
116
0
    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
117
118
0
    if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
119
0
        pSwPagePreview->RepaintCoreRect(rRect);
120
0
}
121
122
bool JumpToSwMark( SwViewShell const * pVwSh, const SwMarkName& rMark )
123
1
{
124
1
    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
125
126
1
    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
127
1
        return pSwView->JumpToSwMark(rMark);
128
129
0
    return false;
130
1
}
131
132
void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt )
133
0
{
134
0
    Window::DataChanged( rDCEvt );
135
136
0
    SwWrtShell* pSh = GetView().GetWrtShellPtr();
137
    // DataChanged() is sometimes called prior to creating
138
    // the SwWrtShell
139
0
    if(!pSh)
140
0
        return;
141
0
    bool bViewWasLocked = pSh->IsViewLocked(), bUnlockPaint = false;
142
0
    pSh->LockView( true );
143
0
    switch( rDCEvt.GetType() )
144
0
    {
145
0
    case DataChangedEventType::SETTINGS:
146
        // rearrange ScrollBars, respectively trigger resize, because
147
        // the ScrollBar size can have change. For that, in the reset
148
        // handler, the size of the ScrollBars also has to be queried
149
        // from the settings.
150
0
        if( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
151
0
        {
152
0
            pSh->LockPaint(LockPaintReason::DataChanged);
153
0
            bUnlockPaint = true;
154
0
            pSh->DeleteReplacementBitmaps();
155
0
            GetView().InvalidateBorder();               //Scrollbar work
156
0
        }
157
0
        break;
158
159
0
    case DataChangedEventType::PRINTER:
160
0
    case DataChangedEventType::DISPLAY:
161
0
    case DataChangedEventType::FONTS:
162
0
    case DataChangedEventType::FONTSUBSTITUTION:
163
0
        pSh->LockPaint(LockPaintReason::DataChanged);
164
0
        bUnlockPaint = true;
165
0
        GetView().GetDocShell()->UpdateFontList();  //e.g. printer change
166
0
        pSh->InvalidateLayout(true);
167
0
        break;
168
0
    default: break;
169
0
    }
170
0
    pSh->LockView( bViewWasLocked );
171
0
    if( bUnlockPaint )
172
0
        pSh->UnlockPaint();
173
0
}
174
175
FactoryFunction SwEditWin::GetUITestFactory() const
176
0
{
177
0
    return SwEditWinUIObject::create;
178
0
}
179
180
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */