1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SDR_CONTACT_OBJECTCONTACT_HXX
25 #define _SDR_CONTACT_OBJECTCONTACT_HXX
26 
27 #include <svx/sdr/animation/objectanimator.hxx>
28 #include "svx/svxdllapi.h"
29 #include <drawinglayer/geometry/viewinformation2d.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 // predeclarations
33 
34 class SetOfByte;
35 class Rectangle;
36 class SdrPageView;
37 class OutputDevice;
38 
39 namespace sdr { namespace contact {
40 	class DisplayInfo;
41 	class ViewContact;
42 	class ViewObjectContactRedirector;
43 }}
44 
45 namespace sdr { namespace event {
46 	class TimerEventHandler;
47 }}
48 
49 namespace basegfx {
50 	class B2DRange;
51 	class B2DHomMatrix;
52 }
53 
54 //////////////////////////////////////////////////////////////////////////////
55 
56 namespace sdr
57 {
58 	namespace contact
59 	{
60 		class SVX_DLLPUBLIC ObjectContact
61 		{
62 		private:
63 			// make ViewObjectContact a friend to exclusively allow it to use
64 			// AddViewObjectContact/RemoveViewObjectContact
65 			friend class ViewObjectContact;
66 
67 			// All VOCs which are created using this OC, thus remembering this OC
68 			// as a reference. All those VOCs need to be deleted when the OC goes down.
69 			// Registering and de-registering is done in the VOC constructors/destructors.
70 			std::vector< ViewObjectContact* >				maViewObjectContactVector;
71 
72 			// A new ViewObjectContact was created and shall be remembered.
73 			void AddViewObjectContact(ViewObjectContact& rVOContact);
74 
75 			// A ViewObjectContact was deleted and shall be forgotten.
76 			virtual void RemoveViewObjectContact(ViewObjectContact& rVOContact);
77 
78 			// the primitiveAnimator which is used if this View and/or the contained primitives
79 			// support animatedSwitchPrimitives
80 			sdr::animation::primitiveAnimator				maPrimitiveAnimator;
81 
82 			// the EventHandler for e.g. asynchronious loading of graphics
83 			sdr::event::TimerEventHandler*					mpEventHandler;
84 
85 			// The redirector. If set it is used to pipe all supported calls
86 			// to the redirector
87 			ViewObjectContactRedirector*					mpViewObjectContactRedirector;
88 
89 			// the Primitive2DParameters containing view information
90 			drawinglayer::geometry::ViewInformation2D		maViewInformation2D;
91 
92 			// bitfield
93 			// flag for preview renderer
94 			unsigned										mbIsPreviewRenderer : 1;
95 
96 			// method to create a EventHandler. Needs to give a result.
97 			sdr::event::TimerEventHandler* CreateEventHandler();
98 
99 		protected:
100 			// Interface to allow derivates to travel over the registered VOC's
getViewObjectContactCount() const101 			sal_uInt32 getViewObjectContactCount() const { return maViewObjectContactVector.size(); }
getViewObjectContact(sal_uInt32 a) const102 			ViewObjectContact* getViewObjectContact(sal_uInt32 a) const { return maViewObjectContactVector[a]; }
103 
104 			// interface to allow derivates to set PreviewRenderer flag
setPreviewRenderer(bool bNew)105 			void setPreviewRenderer(bool bNew) { mbIsPreviewRenderer = bNew; }
106 
107 			// interface to allow derivates to set ViewInformation2D
updateViewInformation2D(const drawinglayer::geometry::ViewInformation2D & rViewInformation2D)108 			void updateViewInformation2D(const drawinglayer::geometry::ViewInformation2D& rViewInformation2D) { maViewInformation2D = rViewInformation2D; }
109 
110 		public:
111 			// basic constructor
112 			ObjectContact();
113 			virtual ~ObjectContact();
114 
115 			// LazyInvalidate request. This is used from the VOCs to mark that they
116 			// got invalidated by an ActionCanged() call. An active view needs to remember
117 			// this and take action on it. Default implementation directly calls back
118 			// triggerLazyInvalidate() wich promptly handles the request
119 			virtual void setLazyInvalidate(ViewObjectContact& rVOC);
120 
121 			// call this to support evtl. preparations for repaint. Default does nothing
122 			virtual void PrepareProcessDisplay();
123 
124 			// Process the whole displaying
125 			virtual void ProcessDisplay(DisplayInfo& rDisplayInfo);
126 
127 			// test if visualizing of entered groups is switched on at all. Default
128 			// implementation returns sal_False.
129 			virtual bool DoVisualizeEnteredGroup() const;
130 
131 			// get active group's (the entered group) ViewContact
132 			virtual const ViewContact* getActiveViewContact() const;
133 
134 			// Invalidate given rectangle at the window/output which is represented by
135 			// this ObjectContact. Default does nothing.
136             virtual void InvalidatePartOfView(const basegfx::B2DRange& rRange) const;
137 
138 			// Get info if given Rectangle is visible in this view
139             virtual bool IsAreaVisible(const basegfx::B2DRange& rRange) const;
140 
141 			// Get info about the need to visualize GluePoints. The default
142 			// is that it is not necessary.
143 			virtual bool AreGluePointsVisible() const;
144 
145 			// method to get the primitiveAnimator
146 			sdr::animation::primitiveAnimator& getPrimitiveAnimator();
147 
148 			// method to get the EventHandler. It will
149 			// return a existing one or create a new one using CreateEventHandler().
150 			sdr::event::TimerEventHandler& GetEventHandler() const;
151 
152 			// delete the EventHandler
153 			void DeleteEventHandler();
154 
155 			// test if there is an EventHandler without creating one on demand
156 			bool HasEventHandler() const;
157 
158 			// check if text animation is allowed. Default is sal_true.
159 			virtual bool IsTextAnimationAllowed() const;
160 
161 			// check if graphic animation is allowed. Default is sal_true.
162 			virtual bool IsGraphicAnimationAllowed() const;
163 
164 			// check if asynchronious graphis loading is allowed. Default is sal_False.
165 			virtual bool IsAsynchronGraphicsLoadingAllowed() const;
166 
167 			// access to ViewObjectContactRedirector
168 			ViewObjectContactRedirector* GetViewObjectContactRedirector() const;
169 			void SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew);
170 
171 			// check if buffering of MasterPages is allowed. Default is sal_False.
172 			virtual bool IsMasterPageBufferingAllowed() const;
173 
174 			// print? Default is false
175 			virtual bool isOutputToPrinter() const;
176 
177 			// window? Default is true
178 			virtual bool isOutputToWindow() const;
179 
180 			// VirtualDevice? Default is false
181 			virtual bool isOutputToVirtualDevice() const;
182 
183 			// recording MetaFile? Default is false
184 			virtual bool isOutputToRecordingMetaFile() const;
185 
186 			// pdf export? Default is false
187 			virtual bool isOutputToPDFFile() const;
188 
189 			// gray display mode
190 			virtual bool isDrawModeGray() const;
191 
192 			// gray display mode
193 			virtual bool isDrawModeBlackWhite() const;
194 
195 			// high contrast display mode
196 			virtual bool isDrawModeHighContrast() const;
197 
198 			// check if this is a preview renderer. Default is sal_False.
IsPreviewRenderer() const199 			bool IsPreviewRenderer() const { return mbIsPreviewRenderer; }
200 
201 			// get Primitive2DParameters for this view
getViewInformation2D() const202 			const drawinglayer::geometry::ViewInformation2D& getViewInformation2D() const { return maViewInformation2D; }
203 
204             // access to SdrPageView. May return 0L like the default implementations do. Needs to be overloaded as needed.
205 			virtual SdrPageView* TryToGetSdrPageView() const;
206 
207 			// access to OutputDevice. May return 0L like the default implementations do. Needs to be overloaded as needed.
208 			virtual OutputDevice* TryToGetOutputDevice() const;
209 
210             // reset ViewPort at internal ViewInformation2D. This is needed when the OC is used
211             // not for ProcessDisplay() but to get a VOC associated with it. When trying to get
212             // a sequence of primitives from the VOC then, the last initialized ViewPort from
213             // the last ProcessDisplay() is used for geometric visibility testing. If this is not
214             // wanted (like in such cases) this method is used. It will reuse the current
215             // ViewInformation2D, but clear the ViewPort (no ViewPort means all is visible)
216             void resetViewPort();
217 		};
218 	} // end of namespace contact
219 } // end of namespace sdr
220 
221 //////////////////////////////////////////////////////////////////////////////
222 
223 #endif //_SDR_CONTACT_OBJECTCONTACT_HXX
224 
225 // eof
226