LibreOffice Module svx (master)  1
viewcontact.hxx
Go to the documentation of this file.
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>
26 
27 class SdrLayerIDSet;
28 class SdrPage;
29 class SdrObject;
30 
31 namespace sdr::contact
32 {
33 class ObjectContact;
34 class ViewObjectContact;
35 
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  // A new ViewObjectContact was created and shall be remembered.
50  void AddViewObjectContact(ViewObjectContact& rVOContact);
51 
52  // A ViewObjectContact was deleted and shall be forgotten.
53  void RemoveViewObjectContact(ViewObjectContact& rVOContact);
54 
55  // internal tooling to delete VOCs
56  void deleteAllVOCs();
57 
58 protected:
59  // Interface to allow derivates to travel over the registered VOC's
60  sal_uInt32 getViewObjectContactCount() const { return maViewObjectContactVector.size(); }
62  {
63  return maViewObjectContactVector[a];
64  }
65 
66  // Create an Object-Specific ViewObjectContact, set ViewContact and
67  // ObjectContact. Always needs to return something. Default is to create
68  // a standard ViewObjectContact containing the given ObjectContact and *this
69  virtual ViewObjectContact& CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact);
70 
71  // This method is responsible for creating the graphical visualisation data derived ONLY from
72  // the model data. It will be stored/buffered in mxViewIndependentPrimitive2DSequence. The default implementation
73  // creates a yellow replacement rectangle (1000, 1000, 5000, 3000) to visualize missing
74  // implementations. All implementations have to provide basic geometry here, this is the central
75  // visualisation method and will also be used for BoundRect computations in the long run.
76  // This means it's always an error when the default implementation is called and thus gets
77  // asserted there
79  createViewIndependentPrimitive2DSequence() const;
80 
81  // basic constructor. Since this is a base class only, it shall
82  // never be called directly
83  ViewContact();
84 
85 public:
86  // basic destructor with needed cleanups
87  virtual ~ViewContact();
88 
89  // get an Object-specific ViewObjectContact for a specific
90  // ObjectContact (->View). Always needs to return something.
91  ViewObjectContact& GetViewObjectContact(ObjectContact& rObjectContact);
92 
93  // Test if this ViewContact has ViewObjectContacts(excluding previews) at all. This can
94  // be used to test if this ViewContact is visualized ATM or not
95  bool HasViewObjectContacts() const;
96 
97  // Check if this primitive is animated in any OC (View) which means it has
98  // generated a PrimitiveAnimation in its VOC
99  bool isAnimatedInAnyViewObjectContact() const;
100 
101  // Access to possible sub-hierarchy and parent. GetObjectCount() default is 0L
102  // and GetViewContact default pops up an assert since it's an error if
103  // GetObjectCount has a result != 0 and it's not overridden.
104  virtual sal_uInt32 GetObjectCount() const;
105  virtual ViewContact& GetViewContact(sal_uInt32 nIndex) const;
106  virtual ViewContact* GetParentContact() const;
107 
108  // React on insertion of a child into DRawHierarchy starting
109  // from this object
110  void ActionChildInserted(ViewContact& rChild);
111 
112  // access to SdrObject. May return 0L like the default
113  // implementations do. Override as needed.
114  virtual SdrObject* TryToGetSdrObject() const;
115 
116  // React on changes of the object of this ViewContact
117  virtual void ActionChanged();
118 
119  // access to the local primitive. This will ensure that the primitive is
120  // current in comparing the local one with a fresh created incarnation
121  drawinglayer::primitive2d::Primitive2DContainer getViewIndependentPrimitive2DContainer() const;
122 
123  // add Gluepoints (if available)
125  createGluePointPrimitive2DSequence() const;
126 
127  // Allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This
128  // is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception
129  // for 3D scenes.
130  // We take the param by value, since, for the common case, we can just std::move into the param, and
131  // std::move the result out, avoiding copying.
133  embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer rSource) const;
134 
135  virtual basegfx::B2DRange
136  getRange(const drawinglayer::geometry::ViewInformation2D& rViewInfo2D) const;
137 
138  // delete all existing VOCs including DrawHierarchy which will invalidate all
139  // visualisations, too. Used mostly at object removal from DrawHierarchy to
140  // delete all existing VOCs by purpose, but can also be used for other purposes.
141  // It is always possible to delete the VOCs, these are re-created on demand
142  void flushViewObjectContacts(bool bWithHierarchy = true);
143 };
144 }
145 
146 #endif // INCLUDED_SVX_SDR_CONTACT_VIEWCONTACT_HXX
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< ViewObjectContact * > maViewObjectContactVector
Definition: viewcontact.hxx:47
Abstract DrawObject.
Definition: svdobj.hxx:258
B2DRange getRange(const B2DPolygon &rCandidate)
ViewObjectContact * getViewObjectContact(sal_uInt32 a) const
Definition: viewcontact.hxx:61
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
sal_uInt32 getViewObjectContactCount() const
Definition: viewcontact.hxx:60
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365