Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/sdr/contact/viewcontact.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
#ifndef INCLUDED_SVX_SDR_CONTACT_VIEWCONTACT_HXX
21
#define INCLUDED_SVX_SDR_CONTACT_VIEWCONTACT_HXX
22
23
#include <sal/types.h>
24
#include <svx/svxdllapi.h>
25
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
26
27
class SdrObject;
28
class SdrPageView;
29
30
namespace sdr::contact
31
{
32
class DisplayInfo;
33
class ObjectContact;
34
class ViewObjectContact;
35
36
class SVXCORE_DLLPUBLIC ViewContact
37
{
38
private:
39
    // make ViewObjectContact a friend to exclusively allow it to use
40
    // AddViewObjectContact/RemoveViewObjectContact
41
    friend class ViewObjectContact;
42
43
    // List of ViewObjectContacts. This contains all VOCs which were constructed
44
    // with this VC. Since the VOCs remember a reference to this VC, this list needs
45
    // to be kept and is used e.g. at destructor to destroy all VOCs.
46
    // Registering and de-registering is done in the VOC constructors/destructors.
47
    std::vector<ViewObjectContact*> maViewObjectContactVector;
48
49
    // Primitive2DContainer of the ViewContact. This contains all necessary information
50
    // for the graphical visualisation and needs to be supported by all VCs which
51
    // can be visualized.
52
    drawinglayer::primitive2d::Primitive2DContainer mxViewIndependentPrimitive2DSequence;
53
54
    // A new ViewObjectContact was created and shall be remembered.
55
    void AddViewObjectContact(ViewObjectContact& rVOContact);
56
57
    // A ViewObjectContact was deleted and shall be forgotten.
58
    void RemoveViewObjectContact(ViewObjectContact& rVOContact);
59
60
    // internal tooling to delete VOCs
61
    void deleteAllVOCs();
62
63
protected:
64
    // Interface to allow derivates to travel over the registered VOC's
65
0
    sal_uInt32 getViewObjectContactCount() const { return maViewObjectContactVector.size(); }
66
    ViewObjectContact* getViewObjectContact(sal_uInt32 a) const
67
0
    {
68
0
        return maViewObjectContactVector[a];
69
0
    }
70
71
    // Create an Object-Specific ViewObjectContact, set ViewContact and
72
    // ObjectContact. Always needs to return something. Default is to create
73
    // a standard ViewObjectContact containing the given ObjectContact and *this
74
    virtual ViewObjectContact& CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact);
75
76
    // This method is responsible for creating the graphical visualisation data derived ONLY from
77
    // the model data. It will be stored/buffered in mxViewIndependentPrimitive2DSequence. The default implementation
78
    // creates a yellow replacement rectangle (1000, 1000, 5000, 3000) to visualize missing
79
    // implementations. All implementations have to provide basic geometry here, this is the central
80
    // visualisation method and will also be used for BoundRect computations in the long run.
81
    // This means it's always an error when the default implementation is called and thus gets
82
    // asserted there
83
    virtual void createViewIndependentPrimitive2DSequence(
84
        drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const;
85
86
    // basic constructor. Since this is a base class only, it shall
87
    // never be called directly
88
    ViewContact();
89
90
public:
91
    // basic destructor with needed cleanups
92
    virtual ~ViewContact();
93
94
    // get an Object-specific ViewObjectContact for a specific
95
    // ObjectContact (->View). Always needs to return something.
96
    ViewObjectContact& GetViewObjectContact(ObjectContact& rObjectContact);
97
98
    // Test if this ViewContact has ViewObjectContacts(excluding previews) at all. This can
99
    // be used to test if this ViewContact is visualized ATM or not
100
    bool HasViewObjectContacts() const;
101
102
    // Check if this primitive is animated in any OC (View) which means it has
103
    // generated a PrimitiveAnimation in its VOC
104
    bool isAnimatedInAnyViewObjectContact() const;
105
106
    // Access to possible sub-hierarchy and parent. GetObjectCount() default is 0L
107
    // and GetViewContact default pops up an assert since it's an error if
108
    // GetObjectCount has a result != 0 and it's not overridden.
109
    virtual sal_uInt32 GetObjectCount() const;
110
    virtual ViewContact& GetViewContact(sal_uInt32 nIndex) const;
111
    virtual ViewContact* GetParentContact() const;
112
113
    // React on insertion of a child into DRawHierarchy starting
114
    // from this object
115
    void ActionChildInserted(ViewContact& rChild);
116
117
    // access to SdrObject. May return 0L like the default
118
    // implementations do. Override as needed.
119
    virtual SdrObject* TryToGetSdrObject() const;
120
121
    // React on changes of the object of this ViewContact
122
    virtual void ActionChanged();
123
124
    // IASS: helpers for IASS invalidates
125
    void ActionChangedIfDifferentPageView(const SdrPageView& rSdrPageView);
126
    bool hasMultipleViewObjectContacts() const;
127
128
    // access to the local primitive. This will ensure that the primitive is
129
    // current in comparing the local one with a fresh created incarnation
130
    void getViewIndependentPrimitive2DContainer(
131
        drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const;
132
133
    // add Gluepoints (if available)
134
    virtual drawinglayer::primitive2d::Primitive2DContainer
135
    createGluePointPrimitive2DSequence() const;
136
137
    // Allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This
138
    // is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception
139
    // for 3D scenes.
140
    // We take the param by value, since, for the common case, we can just std::move into the param, and
141
    // std::move the result out, avoiding copying.
142
    virtual drawinglayer::primitive2d::Primitive2DContainer
143
    embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer rSource) const;
144
145
    virtual basegfx::B2DRange
146
    getRange(const drawinglayer::geometry::ViewInformation2D& rViewInfo2D) const;
147
148
    // delete all existing VOCs including DrawHierarchy which will invalidate all
149
    // visualisations, too. Used mostly at object removal from DrawHierarchy to
150
    // delete all existing VOCs by purpose, but can also be used for other purposes.
151
    // It is always possible to delete the VOCs, these are re-created on demand
152
    void flushViewObjectContacts(bool bWithHierarchy = true);
153
154
    void getPrimitive2DSequenceHierarchyOfIndex(
155
        sal_uInt32 a, DisplayInfo& rDisplayInfo, ObjectContact& rObjectContact,
156
        drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor);
157
};
158
}
159
160
#endif // INCLUDED_SVX_SDR_CONTACT_VIEWCONTACT_HXX
161
162
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */