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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <svx/sdr/contact/viewcontactofpageobj.hxx>
27 #include <svx/svdopage.hxx>
28 #include <svx/sdr/contact/displayinfo.hxx>
29 #include <vcl/outdev.hxx>
30 #include <svx/svdmodel.hxx>
31 #include <svx/svdpage.hxx>
32 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
33 #include <svx/sdr/contact/viewobjectcontact.hxx>
34 #include <svx/sdr/contact/viewobjectcontactofpageobj.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
37 
38 //////////////////////////////////////////////////////////////////////////////
39 
40 namespace sdr
41 {
42 	namespace contact
43 	{
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)44 		ViewObjectContact& ViewContactOfPageObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
45 		{
46 			ViewObjectContact* pRetval = new ViewObjectContactOfPageObj(rObjectContact, *this);
47 			return *pRetval;
48 		}
49 
50 		// Access to referenced page
GetReferencedPage() const51 		const SdrPage* ViewContactOfPageObj::GetReferencedPage() const
52 		{
53 			return GetPageObj().GetReferencedPage();
54 		}
55 
ViewContactOfPageObj(SdrPageObj & rPageObj)56 		ViewContactOfPageObj::ViewContactOfPageObj(SdrPageObj& rPageObj)
57 		:	ViewContactOfSdrObj(rPageObj)
58 		{
59 		}
60 
~ViewContactOfPageObj()61 		ViewContactOfPageObj::~ViewContactOfPageObj()
62 		{
63 		}
64 
65 		// #i35972# React on changes of the object of this ViewContact
ActionChanged()66 		void ViewContactOfPageObj::ActionChanged()
67 		{
68 			static bool bIsInActionChange(false);
69 
70 			if(!bIsInActionChange)
71 			{
72 				// set recursion flag, see description in *.hxx
73 				bIsInActionChange = true;
74 
75 				// call parent
76 				ViewContactOfSdrObj::ActionChanged();
77 
78 				// reset recursion flag, see description in *.hxx
79 				bIsInActionChange = false;
80 			}
81 		}
82 
createViewIndependentPrimitive2DSequence() const83 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageObj::createViewIndependentPrimitive2DSequence() const
84 		{
85 			// ceate graphical visualisation data. Since this is the view-independent version which should not be used,
86 			// create a replacement graphic visualisation here. Use GetLastBoundRect to access the model data directly
87 			// which is aOutRect for SdrPageObj.
88 			const Rectangle aModelRectangle(GetPageObj().GetLastBoundRect());
89 			const basegfx::B2DRange aModelRange(aModelRectangle.Left(), aModelRectangle.Top(), aModelRectangle.Right(), aModelRectangle.Bottom());
90             const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aModelRange));
91 			const basegfx::BColor aYellow(1.0, 1.0, 0.0);
92 			const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aYellow));
93 
94             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
95 		}
96 
97 	} // end of namespace contact
98 } // end of namespace sdr
99 
100 //////////////////////////////////////////////////////////////////////////////
101 // eof
102