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