Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdpagv.hxx
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
#pragma once
21
22
#include <com/sun/star/awt/XControlContainer.hpp>
23
#include <rtl/ref.hxx>
24
#include <rtl/ustring.hxx>
25
#include <tools/color.hxx>
26
#include <svx/svdhlpln.hxx>
27
#include <svx/svdsob.hxx>
28
#include <svx/svdtypes.hxx>
29
#include <svx/svxdllapi.h>
30
31
#include <memory>
32
#include <vector>
33
#include <basegfx/range/b2irectangle.hxx>
34
35
36
namespace vcl { class Region; }
37
class SdrObjList;
38
class SdrObject;
39
class SdrPage;
40
class SdrPaintWindow;
41
class SdrView;
42
class UnoControlContainer;
43
44
namespace sdr::contact
45
{
46
    class ViewObjectContactRedirector;
47
}
48
49
// typedefs for a list of SdrPageWindow
50
class SdrPageWindow;
51
52
class SVXCORE_DLLPUBLIC SdrPageView
53
{
54
private:
55
    SdrView&     mrView;
56
    SdrPage*     mpPage;
57
    Point        maPageOrigin;   // The Page's point of origin
58
59
    tools::Rectangle    m_aMarkBound;
60
    tools::Rectangle    m_aMarkSnap;
61
    bool         mbHasMarked;
62
    bool         mbVisible;
63
64
    SdrLayerIDSet    m_aLayerVisi;   // Set of visible Layers
65
    SdrLayerIDSet    m_aLayerLock;   // Set of non-editable Layers
66
    SdrLayerIDSet    m_aLayerPrn;    // Set of printable Layers
67
68
    SdrObjList*  m_pCurrentList;     // Current List, usually the Page
69
    SdrObject*   m_pCurrentGroup;    // Current Group; nullptr means none
70
71
    SdrHelpLineList m_aHelpLines; // Helper lines and points
72
73
    // #103911# Use one reserved slot (bReserveBool2) for the document color
74
    Color         maDocumentColor;
75
76
    // #103834# Use one reserved slot (bReserveBool1) for the background color
77
    Color         maBackgroundColor;
78
79
    std::vector< std::unique_ptr<SdrPageWindow> > maPageWindows;
80
81
    // #i72752# member to remember with which SdrPageWindow the BeginDrawLayer
82
    // was done
83
    SdrPageWindow* mpPreparedPageWindow;
84
85
public:
86
310
    sal_uInt32 PageWindowCount() const { return maPageWindows.size(); }
87
    SdrPageWindow* FindPageWindow( const SdrPaintWindow& rPaintWindow ) const;
88
    SdrPageWindow* FindPageWindow( const OutputDevice& rOutDev ) const;
89
    SdrPageWindow* GetPageWindow(sal_uInt32 nIndex) const;
90
91
    /**
92
     * Finds the page window whose PaintWindow belongs to the given output device
93
     * In opposite to FindPageWindow, this method also cares possibly patched PaintWindow instances.
94
     * That is, a SdrPageWindow might have an original, and a patched SdrPaintWindow instance - if
95
     * this is the case, then the original SdrPaintWindow is examined before the patched one.
96
     */
97
    const SdrPageWindow* FindPatchedPageWindow( const OutputDevice& rOutDev ) const;
98
99
private:
100
    void ImpInvalidateHelpLineArea(sal_uInt16 nNum) const;
101
102
    // return true if changed, false if unchanged
103
    bool SetLayer(const OUString& rName, SdrLayerIDSet& rBS, bool bJa);
104
    bool IsLayer(const OUString& rName, const SdrLayerIDSet& rBS) const;
105
106
    /// Let's see if the current Group (pCurrentGroup) is still inserted
107
    void CheckCurrentGroup();
108
109
    void AdjHdl();
110
111
public:
112
    SdrPageView(SdrPage* pPage1, SdrView& rNewView);
113
    ~SdrPageView();
114
115
    SdrPageView& operator=( SdrPageView const & ) = delete; // MSVC2017 workaround
116
    SdrPageView( SdrPageView const & ) = delete; // MSVC2017 workaround
117
118
119
    /// Is called by PaintView, when modal changes have finished
120
    void ModelHasChanged();
121
122
    void Show();
123
    void Hide();
124
125
    void AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow);
126
    void RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow);
127
128
2.02M
    SdrView& GetView() { return mrView; }
129
26.6k
    const SdrView& GetView() const { return mrView; }
130
131
    /**
132
     * Looks up the control container belonging to given output device
133
     * @return
134
     *      If the given output device belongs to one of the SdrPageViewWinRecs associated with this
135
     *      SdrPageView instance, the XControlContainer for this output device is returned, <NULL/>
136
     *      otherwise.
137
     */
138
    rtl::Reference< UnoControlContainer >
139
        GetControlContainer( const OutputDevice& _rDevice ) const;
140
141
    /// Sets all elements in the view which support a design and an alive mode into the given mode
142
    void    SetDesignMode( bool _bDesignMode ) const;
143
144
358k
    bool IsVisible() const { return mbVisible; }
145
146
    /// Invalidates the Page's whole area
147
    void InvalidateAllWin();
148
149
    /// PrePaint call forwarded from app windows
150
    void PrePaint();
151
152
    /// @param rReg refers to the OutDev and not to the Page
153
    void CompleteRedraw( SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector );
154
155
    /// Write access to mpPreparedPageWindow
156
    void setPreparedPageWindow(SdrPageWindow* pKnownTarget);
157
158
    void DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr,
159
                   const tools::Rectangle& rRect = tools::Rectangle(),
160
                   basegfx::B2IRectangle const* pPageFrame = nullptr);
161
    void DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& rRect, Color aColor = COL_BLACK );
162
163
    tools::Rectangle GetPageRect() const;
164
2.58M
    SdrPage* GetPage() const { return mpPage; }
165
166
    /// Return current List
167
1.89k
    SdrObjList* GetObjList() const { return m_pCurrentList; }
168
169
    /// Return current Group
170
0
    SdrObject* GetCurrentGroup() const { return m_pCurrentGroup; }
171
172
    /// Set current Group and List
173
    void SetCurrentGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList);
174
175
0
    bool HasMarkedObjPageView() const { return mbHasMarked; }
176
179k
    void SetHasMarkedObj(bool bOn) { mbHasMarked = bOn; }
177
178
0
    const tools::Rectangle& MarkBound() const { return m_aMarkBound; }
179
0
    const tools::Rectangle& MarkSnap() const { return m_aMarkSnap; }
180
179k
    tools::Rectangle& MarkBound() { return m_aMarkBound; }
181
179k
    tools::Rectangle& MarkSnap() { return m_aMarkSnap; }
182
183
175k
    bool SetLayerVisible(const OUString& rName, bool bShow) {
184
175k
        const bool bChanged = SetLayer(rName, m_aLayerVisi, bShow);
185
175k
        if (!bChanged)
186
0
            return false;
187
175k
        if(!bShow) AdjHdl();
188
175k
        InvalidateAllWin();
189
175k
        return true;
190
175k
    }
191
0
    bool IsLayerVisible(const OUString& rName) const { return IsLayer(rName, m_aLayerVisi); }
192
193
0
    void SetLayerLocked(const OUString& rName, bool bLock) { SetLayer(rName, m_aLayerLock, bLock); if(bLock) AdjHdl(); }
194
0
    bool IsLayerLocked(const OUString& rName) const { return IsLayer(rName,m_aLayerLock); }
195
196
108k
    void SetLayerPrintable(const OUString& rName, bool bPrn) { SetLayer(rName, m_aLayerPrn, bPrn); }
197
54.4k
    bool IsLayerPrintable(const OUString& rName) const { return IsLayer(rName, m_aLayerPrn); }
198
199
    /// PV represents a RefPage or a SubList of a RefObj, or the Model is ReadOnly
200
    bool IsReadOnly() const;
201
202
    /// The Origin always refers to the upper left corner of the Page
203
0
    const Point& GetPageOrigin() const { return maPageOrigin; }
204
    void SetPageOrigin(const Point& rOrg);
205
206
0
    void LogicToPagePos(Point& rPnt) const { rPnt-=maPageOrigin; }
207
0
    void LogicToPagePos(tools::Rectangle& rRect) const { rRect.Move(-maPageOrigin.X(),-maPageOrigin.Y()); }
208
0
    void PagePosToLogic(Point& rPnt) const { rPnt+=maPageOrigin; }
209
210
0
    void SetVisibleLayers(const SdrLayerIDSet& rSet) { m_aLayerVisi=rSet; }
211
164k
    const SdrLayerIDSet& GetVisibleLayers() const { return m_aLayerVisi; }
212
0
    void SetPrintableLayers(const SdrLayerIDSet& rSet) { m_aLayerPrn=rSet; }
213
0
    const SdrLayerIDSet& GetPrintableLayers() const { return m_aLayerPrn;  }
214
0
    void SetLockedLayers(const SdrLayerIDSet& rSet) { m_aLayerLock=rSet; }
215
0
    const SdrLayerIDSet& GetLockedLayers() const { return m_aLayerLock; }
216
217
0
    const SdrHelpLineList& GetHelpLines() const { return m_aHelpLines; }
218
    void SetHelpLines(const SdrHelpLineList& rHLL);
219
    //void SetHelpLinePos(sal_uInt16 nNum, const Point& rNewPos);
220
    void SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine);
221
    void DeleteHelpLine(sal_uInt16 nNum);
222
    void InsertHelpLine(const SdrHelpLine& rHL);
223
224
    /// At least one member must be visible for the Group object and
225
    /// it must not be locked
226
    /// @returns
227
    ///      true, if the object's layer is visible and not locked
228
    bool IsObjMarkable(SdrObject const * pObj) const;
229
230
    /// Entering (editing) an object group
231
    /// After that, we have direct access to all member objects of the group.
232
    /// All other objects are not editable in the meantime (until the next
233
    /// LeaveGroup())
234
    bool EnterGroup(SdrObject* pObj);
235
236
    /// Leave an object group we entered previously
237
    void LeaveOneGroup();
238
239
    /// Leave all object groups we entered previously
240
    void LeaveAllGroup();
241
242
    /// Determine, how deep we descended (0 = Root(Page))
243
    sal_uInt16 GetEnteredLevel() const;
244
245
    // #103834# Set background color for svx at SdrPageViews
246
    void SetApplicationBackgroundColor(Color aBackgroundColor);
247
248
0
    const Color& GetApplicationBackgroundColor() const { return maBackgroundColor;}
249
250
    // #103911# Set/Get document color for svx at SdrPageViews
251
    void SetApplicationDocumentColor(Color aDocumentColor);
252
0
    const Color& GetApplicationDocumentColor() const { return maDocumentColor;}
253
254
    void resetGridOffsetsOfAllPageWindows() const;
255
};
256
257
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */