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