xref: /AOO41X/main/svx/source/sdr/contact/viewobjectcontact.cxx (revision 5be78d22e6c042fbf34ae49f26275dc40c5231d1)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
27cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
28cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx>
29cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
30cdf0e10cSrcweir #include <vcl/region.hxx>
31cdf0e10cSrcweir #include <svx/sdr/animation/objectanimator.hxx>
32cdf0e10cSrcweir #include <svx/sdr/animation/animationstate.hxx>
33cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
34cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
35cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx>
36cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
37cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
38cdf0e10cSrcweir #include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
39cdf0e10cSrcweir #include <drawinglayer/processor2d/baseprocessor2d.hxx>
40cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
41cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using namespace com::sun::star;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	// animated extractor
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	// Necessary to filter a sequence of animated primitives from
54cdf0e10cSrcweir 	// a sequence of primitives to find out if animated or not. The decision for
55cdf0e10cSrcweir 	// what to decompose is hard-coded and only done for knowingly animated primitives
56cdf0e10cSrcweir 	// to not decompose too deeply and unnecessarily. This implies that the list
57cdf0e10cSrcweir 	// which is view-specific needs to be expanded by hand when new animated objects
58cdf0e10cSrcweir 	// are added. This may eventually be changed to a dynamically configurable approach
59cdf0e10cSrcweir 	// if necessary.
60cdf0e10cSrcweir 	class AnimatedExtractingProcessor2D : public drawinglayer::processor2d::BaseProcessor2D
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 	protected:
63cdf0e10cSrcweir         // the found animated primitives
64cdf0e10cSrcweir         drawinglayer::primitive2d::Primitive2DSequence	maPrimitive2DSequence;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         // bitfield
67cdf0e10cSrcweir 		// text animation allowed?
68cdf0e10cSrcweir 		unsigned										mbTextAnimationAllowed : 1;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		// graphic animation allowed?
71cdf0e10cSrcweir 		unsigned										mbGraphicAnimationAllowed : 1;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 		// as tooling, the process() implementation takes over API handling and calls this
74cdf0e10cSrcweir 		// virtual render method when the primitive implementation is BasePrimitive2D-based.
75cdf0e10cSrcweir 		virtual void processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	public:
78cdf0e10cSrcweir 		AnimatedExtractingProcessor2D(
79cdf0e10cSrcweir 			const drawinglayer::geometry::ViewInformation2D& rViewInformation,
80cdf0e10cSrcweir 			bool bTextAnimationAllowed,
81cdf0e10cSrcweir 			bool bGraphicAnimationAllowed);
82cdf0e10cSrcweir         virtual ~AnimatedExtractingProcessor2D();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		// data access
getPrimitive2DSequence() const85cdf0e10cSrcweir         const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; }
isTextAnimationAllowed() const86cdf0e10cSrcweir 		bool isTextAnimationAllowed() const { return mbTextAnimationAllowed; }
isGraphicAnimationAllowed() const87cdf0e10cSrcweir 		bool isGraphicAnimationAllowed() const { return mbGraphicAnimationAllowed; }
88cdf0e10cSrcweir 	};
89cdf0e10cSrcweir 
AnimatedExtractingProcessor2D(const drawinglayer::geometry::ViewInformation2D & rViewInformation,bool bTextAnimationAllowed,bool bGraphicAnimationAllowed)90cdf0e10cSrcweir     AnimatedExtractingProcessor2D::AnimatedExtractingProcessor2D(
91cdf0e10cSrcweir 		const drawinglayer::geometry::ViewInformation2D& rViewInformation,
92cdf0e10cSrcweir 		bool bTextAnimationAllowed,
93cdf0e10cSrcweir 		bool bGraphicAnimationAllowed)
94cdf0e10cSrcweir 	:	drawinglayer::processor2d::BaseProcessor2D(rViewInformation),
95cdf0e10cSrcweir         maPrimitive2DSequence(),
96cdf0e10cSrcweir 		mbTextAnimationAllowed(bTextAnimationAllowed),
97cdf0e10cSrcweir 		mbGraphicAnimationAllowed(bGraphicAnimationAllowed)
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
~AnimatedExtractingProcessor2D()101cdf0e10cSrcweir     AnimatedExtractingProcessor2D::~AnimatedExtractingProcessor2D()
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir 
processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D & rCandidate)105cdf0e10cSrcweir     void AnimatedExtractingProcessor2D::processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate)
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		// known implementation, access directly
108cdf0e10cSrcweir 		switch(rCandidate.getPrimitive2DID())
109cdf0e10cSrcweir 		{
110cdf0e10cSrcweir 			// add and accept animated primitives directly, no need to decompose
111cdf0e10cSrcweir 			case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D :
112cdf0e10cSrcweir 			case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D :
113cdf0e10cSrcweir 			case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D :
114cdf0e10cSrcweir 			{
115cdf0e10cSrcweir 				const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& rSwitchPrimitive = static_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& >(rCandidate);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 				if((rSwitchPrimitive.isTextAnimation() && isTextAnimationAllowed())
118cdf0e10cSrcweir 					|| (rSwitchPrimitive.isGraphicAnimation() && isGraphicAnimationAllowed()))
119cdf0e10cSrcweir 				{
120cdf0e10cSrcweir 					const drawinglayer::primitive2d::Primitive2DReference xReference(const_cast< drawinglayer::primitive2d::BasePrimitive2D* >(&rCandidate));
121cdf0e10cSrcweir                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xReference);
122cdf0e10cSrcweir 				}
123cdf0e10cSrcweir 				break;
124cdf0e10cSrcweir 			}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 			// decompose animated gifs where SdrGrafPrimitive2D produces a GraphicPrimitive2D
127cdf0e10cSrcweir             // which then produces the animation infos (all when used/needed)
128cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D :
129cdf0e10cSrcweir             case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D :
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			// decompose SdrObjects with evtl. animated text
132cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D :
133cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D :
134cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D :
135cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D :
136cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D :
137cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D :
138cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D :
139cdf0e10cSrcweir 			case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D :
140cdf0e10cSrcweir 
141035a2f44SArmin Le Grand             // #121194# With Graphic as Bitmap FillStyle, also check
142035a2f44SArmin Le Grand             // for primitives filled with animated graphics
143035a2f44SArmin Le Grand             case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D:
144035a2f44SArmin Le Grand             case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D:
145035a2f44SArmin Le Grand             case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D:
146035a2f44SArmin Le Grand 
147cdf0e10cSrcweir 			// decompose evtl. animated text contained in MaskPrimitive2D
148cdf0e10cSrcweir 			// or group rimitives
149cdf0e10cSrcweir 			case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
150cdf0e10cSrcweir 			case PRIMITIVE2D_ID_GROUPPRIMITIVE2D :
151cdf0e10cSrcweir 			{
152cdf0e10cSrcweir 				process(rCandidate.get2DDecomposition(getViewInformation2D()));
153cdf0e10cSrcweir 				break;
154cdf0e10cSrcweir 			}
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 			default :
157cdf0e10cSrcweir 			{
158cdf0e10cSrcweir 				// nothing to do for the rest
159cdf0e10cSrcweir 				break;
160cdf0e10cSrcweir 			}
161cdf0e10cSrcweir 		}
162cdf0e10cSrcweir 	}
163cdf0e10cSrcweir } // end of anonymous namespace
164cdf0e10cSrcweir 
165cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
166cdf0e10cSrcweir 
167cdf0e10cSrcweir namespace sdr
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	namespace contact
170cdf0e10cSrcweir 	{
ViewObjectContact(ObjectContact & rObjectContact,ViewContact & rViewContact)171cdf0e10cSrcweir 		ViewObjectContact::ViewObjectContact(ObjectContact& rObjectContact, ViewContact& rViewContact)
172cdf0e10cSrcweir 		:	mrObjectContact(rObjectContact),
173cdf0e10cSrcweir 			mrViewContact(rViewContact),
174cdf0e10cSrcweir 			maObjectRange(),
175cdf0e10cSrcweir 			mxPrimitive2DSequence(),
176cdf0e10cSrcweir 			mpPrimitiveAnimation(0),
177cdf0e10cSrcweir 			mbLazyInvalidate(false)
178cdf0e10cSrcweir 		{
179cdf0e10cSrcweir 			// make the ViewContact remember me
180cdf0e10cSrcweir 			mrViewContact.AddViewObjectContact(*this);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 			// make the ObjectContact remember me
183cdf0e10cSrcweir 			mrObjectContact.AddViewObjectContact(*this);
184cdf0e10cSrcweir 		}
185cdf0e10cSrcweir 
~ViewObjectContact()186cdf0e10cSrcweir 		ViewObjectContact::~ViewObjectContact()
187cdf0e10cSrcweir 		{
188cdf0e10cSrcweir 			// invalidate in view
189cdf0e10cSrcweir             if(!maObjectRange.isEmpty())
190cdf0e10cSrcweir             {
191cdf0e10cSrcweir     			GetObjectContact().InvalidatePartOfView(maObjectRange);
192cdf0e10cSrcweir             }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 			// delete PrimitiveAnimation
195cdf0e10cSrcweir 			if(mpPrimitiveAnimation)
196cdf0e10cSrcweir 			{
197cdf0e10cSrcweir 				delete mpPrimitiveAnimation;
198cdf0e10cSrcweir 				mpPrimitiveAnimation = 0;
199cdf0e10cSrcweir 			}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 			// take care of remebered ObjectContact. Remove from
202cdf0e10cSrcweir             // OC first. The VC removal (below) CAN trigger a StopGettingViewed()
203cdf0e10cSrcweir             // which (depending of it's implementation) may destroy other OCs. This
204cdf0e10cSrcweir             // can trigger the deletion of the helper OC of a page visualising object
205cdf0e10cSrcweir             // which IS the OC of this object. Eventually StopGettingViewed() needs
206cdf0e10cSrcweir             // to get asynchron later
207cdf0e10cSrcweir 			GetObjectContact().RemoveViewObjectContact(*this);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 			// take care of remebered ViewContact
210cdf0e10cSrcweir 			GetViewContact().RemoveViewObjectContact(*this);
211cdf0e10cSrcweir 		}
212cdf0e10cSrcweir 
getObjectRange() const213cdf0e10cSrcweir 		const basegfx::B2DRange& ViewObjectContact::getObjectRange() const
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			if(maObjectRange.isEmpty())
216cdf0e10cSrcweir 			{
217cdf0e10cSrcweir 				// if range is not computed (new or LazyInvalidate objects), force it
218cdf0e10cSrcweir 				const DisplayInfo aDisplayInfo;
219cdf0e10cSrcweir 				const drawinglayer::primitive2d::Primitive2DSequence xSequence(getPrimitive2DSequence(aDisplayInfo));
220cdf0e10cSrcweir 
221cdf0e10cSrcweir                 if(xSequence.hasElements())
222cdf0e10cSrcweir                 {
223cdf0e10cSrcweir 					const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
224cdf0e10cSrcweir                     const_cast< ViewObjectContact* >(this)->maObjectRange =
225cdf0e10cSrcweir                         drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSequence, rViewInformation2D);
226cdf0e10cSrcweir 				}
227cdf0e10cSrcweir 			}
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 			return maObjectRange;
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir 
ActionChanged()232cdf0e10cSrcweir 		void ViewObjectContact::ActionChanged()
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			if(!mbLazyInvalidate)
235cdf0e10cSrcweir 			{
236cdf0e10cSrcweir 				// set local flag
237cdf0e10cSrcweir 				mbLazyInvalidate = true;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 				// force ObjectRange
240cdf0e10cSrcweir 				getObjectRange();
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 				if(!maObjectRange.isEmpty())
243cdf0e10cSrcweir 				{
244cdf0e10cSrcweir 					// invalidate current valid range
245cdf0e10cSrcweir 					GetObjectContact().InvalidatePartOfView(maObjectRange);
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 					// reset ObjectRange, it needs to be recalculated
248cdf0e10cSrcweir 					maObjectRange.reset();
249cdf0e10cSrcweir 				}
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 				// register at OC for lazy invalidate
252cdf0e10cSrcweir 				GetObjectContact().setLazyInvalidate(*this);
253cdf0e10cSrcweir 			}
254cdf0e10cSrcweir 		}
255cdf0e10cSrcweir 
triggerLazyInvalidate()256cdf0e10cSrcweir 		void ViewObjectContact::triggerLazyInvalidate()
257cdf0e10cSrcweir 		{
258cdf0e10cSrcweir 			if(mbLazyInvalidate)
259cdf0e10cSrcweir 			{
260cdf0e10cSrcweir 				// reset flag
261cdf0e10cSrcweir 				mbLazyInvalidate = false;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 				// force ObjectRange
264cdf0e10cSrcweir 				getObjectRange();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 				if(!maObjectRange.isEmpty())
267cdf0e10cSrcweir 				{
268cdf0e10cSrcweir 					// invalidate current valid range
269cdf0e10cSrcweir 					GetObjectContact().InvalidatePartOfView(maObjectRange);
270cdf0e10cSrcweir 				}
271cdf0e10cSrcweir 			}
272cdf0e10cSrcweir 		}
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 		// Take some action when new objects are inserted
ActionChildInserted(ViewContact & rChild)275cdf0e10cSrcweir 		void ViewObjectContact::ActionChildInserted(ViewContact& rChild)
276cdf0e10cSrcweir 		{
277cdf0e10cSrcweir 			// force creation of the new VOC and trigger it's refresh, so it
278cdf0e10cSrcweir 			// will take part in LazyInvalidate immediately
279cdf0e10cSrcweir 			rChild.GetViewObjectContact(GetObjectContact()).ActionChanged();
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 			// forward action to ObjectContact
282cdf0e10cSrcweir 			// const ViewObjectContact& rChildVOC = rChild.GetViewObjectContact(GetObjectContact());
283cdf0e10cSrcweir 			// GetObjectContact().InvalidatePartOfView(rChildVOC.getObjectRange());
284cdf0e10cSrcweir 		}
285cdf0e10cSrcweir 
checkForPrimitive2DAnimations()286cdf0e10cSrcweir 		void ViewObjectContact::checkForPrimitive2DAnimations()
287cdf0e10cSrcweir 		{
288cdf0e10cSrcweir 			// remove old one
289cdf0e10cSrcweir 			if(mpPrimitiveAnimation)
290cdf0e10cSrcweir 			{
291cdf0e10cSrcweir 				delete mpPrimitiveAnimation;
292cdf0e10cSrcweir 				mpPrimitiveAnimation = 0;
293cdf0e10cSrcweir 			}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 			// check for animated primitives
296cdf0e10cSrcweir 			if(mxPrimitive2DSequence.hasElements())
297cdf0e10cSrcweir 			{
298cdf0e10cSrcweir                 const bool bTextAnimationAllowed(GetObjectContact().IsTextAnimationAllowed());
299cdf0e10cSrcweir                 const bool bGraphicAnimationAllowed(GetObjectContact().IsGraphicAnimationAllowed());
300cdf0e10cSrcweir 
301cdf0e10cSrcweir                 if(bTextAnimationAllowed || bGraphicAnimationAllowed)
302cdf0e10cSrcweir                 {
303cdf0e10cSrcweir 				    AnimatedExtractingProcessor2D aAnimatedExtractor(GetObjectContact().getViewInformation2D(),
304cdf0e10cSrcweir 					    bTextAnimationAllowed, bGraphicAnimationAllowed);
305cdf0e10cSrcweir 				    aAnimatedExtractor.process(mxPrimitive2DSequence);
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 				    if(aAnimatedExtractor.getPrimitive2DSequence().hasElements())
308cdf0e10cSrcweir 				    {
309cdf0e10cSrcweir 					    // dervied primitiveList is animated, setup new PrimitiveAnimation
310cdf0e10cSrcweir 					    mpPrimitiveAnimation =  new sdr::animation::PrimitiveAnimation(*this, aAnimatedExtractor.getPrimitive2DSequence());
311cdf0e10cSrcweir 				    }
312cdf0e10cSrcweir                 }
313cdf0e10cSrcweir 			}
314cdf0e10cSrcweir 		}
315cdf0e10cSrcweir 
createPrimitive2DSequence(const DisplayInfo & rDisplayInfo) const316cdf0e10cSrcweir         drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
317cdf0e10cSrcweir         {
318cdf0e10cSrcweir             // get the view-independent Primitive from the viewContact
319cdf0e10cSrcweir             drawinglayer::primitive2d::Primitive2DSequence xRetval(GetViewContact().getViewIndependentPrimitive2DSequence());
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             if(xRetval.hasElements())
322cdf0e10cSrcweir             {
323cdf0e10cSrcweir                 // handle GluePoint
324cdf0e10cSrcweir                 if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible())
325cdf0e10cSrcweir                 {
326cdf0e10cSrcweir                     const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence());
327cdf0e10cSrcweir 
328cdf0e10cSrcweir                     if(xGlue.hasElements())
329cdf0e10cSrcweir                     {
330cdf0e10cSrcweir                         drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue);
331cdf0e10cSrcweir                     }
332cdf0e10cSrcweir                 }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir                 // handle ghosted
335cdf0e10cSrcweir                 if(isPrimitiveGhosted(rDisplayInfo))
336cdf0e10cSrcweir                 {
337cdf0e10cSrcweir                     const basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
338*49c58f9bSArmin Le Grand                     const basegfx::BColorModifierSharedPtr aBColorModifier(
339*49c58f9bSArmin Le Grand                         new basegfx::BColorModifier_interpolate(
340*49c58f9bSArmin Le Grand                             aRGBWhite,
341*49c58f9bSArmin Le Grand                             0.5));
342*49c58f9bSArmin Le Grand                     const drawinglayer::primitive2d::Primitive2DReference xReference(
343*49c58f9bSArmin Le Grand                         new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
344*49c58f9bSArmin Le Grand                             xRetval,
345*49c58f9bSArmin Le Grand                             aBColorModifier));
346*49c58f9bSArmin Le Grand 
347cdf0e10cSrcweir                     xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
348cdf0e10cSrcweir                 }
349cdf0e10cSrcweir             }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 			return xRetval;
352cdf0e10cSrcweir 		}
353cdf0e10cSrcweir 
getPrimitive2DSequence(const DisplayInfo & rDisplayInfo) const354cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
355cdf0e10cSrcweir 		{
356cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xNewPrimitiveSequence;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 			// take care of redirectors and create new list
359cdf0e10cSrcweir 			ViewObjectContactRedirector* pRedirector = GetObjectContact().GetViewObjectContactRedirector();
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 			if(pRedirector)
362cdf0e10cSrcweir 			{
363cdf0e10cSrcweir 				xNewPrimitiveSequence = pRedirector->createRedirectedPrimitive2DSequence(*this, rDisplayInfo);
364cdf0e10cSrcweir 			}
365cdf0e10cSrcweir 			else
366cdf0e10cSrcweir 			{
367cdf0e10cSrcweir 				xNewPrimitiveSequence = createPrimitive2DSequence(rDisplayInfo);
368cdf0e10cSrcweir 			}
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 			// local up-to-date checks. New list different from local one?
371cdf0e10cSrcweir 			if(!drawinglayer::primitive2d::arePrimitive2DSequencesEqual(mxPrimitive2DSequence, xNewPrimitiveSequence))
372cdf0e10cSrcweir 			{
373cdf0e10cSrcweir 				// has changed, copy content
374cdf0e10cSrcweir 				const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = xNewPrimitiveSequence;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir                 // check for animated stuff
377cdf0e10cSrcweir 				const_cast< ViewObjectContact* >(this)->checkForPrimitive2DAnimations();
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 				// always update object range when PrimitiveSequence changes
380cdf0e10cSrcweir 				const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
381cdf0e10cSrcweir                 const_cast< ViewObjectContact* >(this)->maObjectRange =
382cdf0e10cSrcweir                     drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(mxPrimitive2DSequence, rViewInformation2D);
383cdf0e10cSrcweir 			}
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 			// return current Primitive2DSequence
386cdf0e10cSrcweir 			return mxPrimitive2DSequence;
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 
isPrimitiveVisible(const DisplayInfo &) const389cdf0e10cSrcweir 		bool ViewObjectContact::isPrimitiveVisible(const DisplayInfo& /*rDisplayInfo*/) const
390cdf0e10cSrcweir 		{
391cdf0e10cSrcweir 			// default: always visible
392cdf0e10cSrcweir 			return true;
393cdf0e10cSrcweir 		}
394cdf0e10cSrcweir 
isPrimitiveGhosted(const DisplayInfo & rDisplayInfo) const395cdf0e10cSrcweir 		bool ViewObjectContact::isPrimitiveGhosted(const DisplayInfo& rDisplayInfo) const
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			// default: standard check
398cdf0e10cSrcweir 			return (GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive());
399cdf0e10cSrcweir 		}
400cdf0e10cSrcweir 
getPrimitive2DSequenceHierarchy(DisplayInfo & rDisplayInfo) const401cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
402cdf0e10cSrcweir 		{
403cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 			// check model-view visibility
406cdf0e10cSrcweir 			if(isPrimitiveVisible(rDisplayInfo))
407cdf0e10cSrcweir 			{
408cdf0e10cSrcweir 				xRetval = getPrimitive2DSequence(rDisplayInfo);
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 				if(xRetval.hasElements())
411cdf0e10cSrcweir 				{
412cdf0e10cSrcweir 					// get ranges
413cdf0e10cSrcweir 					const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
414cdf0e10cSrcweir 					const basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
415cdf0e10cSrcweir 					const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 					// check geometrical visibility
418cdf0e10cSrcweir 					if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
419cdf0e10cSrcweir 					{
420cdf0e10cSrcweir 						// not visible, release
421cdf0e10cSrcweir 						xRetval.realloc(0);
422cdf0e10cSrcweir 					}
423cdf0e10cSrcweir 				}
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 			return xRetval;
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir 
getPrimitive2DSequenceSubHierarchy(DisplayInfo & rDisplayInfo) const429cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceSubHierarchy(DisplayInfo& rDisplayInfo) const
430cdf0e10cSrcweir 		{
431cdf0e10cSrcweir 			const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
432cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xSeqRetval;
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 			for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
435cdf0e10cSrcweir 			{
436cdf0e10cSrcweir 				const ViewObjectContact& rCandidate(GetViewContact().GetViewContact(a).GetViewObjectContact(GetObjectContact()));
437cdf0e10cSrcweir 
438cdf0e10cSrcweir                 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xSeqRetval, rCandidate.getPrimitive2DSequenceHierarchy(rDisplayInfo));
439cdf0e10cSrcweir 			}
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 			return xSeqRetval;
442cdf0e10cSrcweir 		}
443cdf0e10cSrcweir 	} // end of namespace contact
444cdf0e10cSrcweir } // end of namespace sdr
445cdf0e10cSrcweir 
446cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
447cdf0e10cSrcweir // eof
448