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