1f6e50924SAndrew Rist /**************************************************************
2*672a9062Smseidel  *
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
10*672a9062Smseidel  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*672a9062Smseidel  *
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.
19*672a9062Smseidel  *
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/viewcontactofsdrobj.hxx>
27cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
28cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
29cdf0e10cSrcweir #include <svx/svdobj.hxx>
30cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
31cdf0e10cSrcweir #include <vcl/outdev.hxx>
32cdf0e10cSrcweir #include <svx/svdoole2.hxx>
33cdf0e10cSrcweir #include <svx/svdpage.hxx>
34cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx>
35cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx>
36cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
37cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofpageview.hxx>
38cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx>
39cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
40cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
41025b0597SArmin Le Grand #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace sdr
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	namespace contact
48cdf0e10cSrcweir 	{
49cdf0e10cSrcweir 		// Create a Object-Specific ViewObjectContact, set ViewContact and
50cdf0e10cSrcweir 		// ObjectContact. Always needs to return something.
51cdf0e10cSrcweir 		ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
52cdf0e10cSrcweir 		{
53cdf0e10cSrcweir 			ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
54cdf0e10cSrcweir 			DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 			return *pRetval;
57cdf0e10cSrcweir 		}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 		ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
60cdf0e10cSrcweir 		:	ViewContact(),
61cdf0e10cSrcweir 			mrObject(rObj),
62cdf0e10cSrcweir 			meRememberedAnimationKind(SDRTEXTANI_NONE)
63cdf0e10cSrcweir 		{
64cdf0e10cSrcweir 			// init AnimationKind
65cdf0e10cSrcweir 			if(GetSdrObject().ISA(SdrTextObj))
66cdf0e10cSrcweir 			{
67cdf0e10cSrcweir 				SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
68cdf0e10cSrcweir 				meRememberedAnimationKind = rTextObj.GetTextAniKind();
69cdf0e10cSrcweir 			}
70cdf0e10cSrcweir 		}
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 		ViewContactOfSdrObj::~ViewContactOfSdrObj()
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 		}
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 		// Access to possible sub-hierarchy
77cdf0e10cSrcweir 		sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
78cdf0e10cSrcweir 		{
79cdf0e10cSrcweir 			if(GetSdrObject().GetSubList())
80cdf0e10cSrcweir 			{
81cdf0e10cSrcweir 				return GetSdrObject().GetSubList()->GetObjCount();
82cdf0e10cSrcweir 			}
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 			return 0L;
85cdf0e10cSrcweir 		}
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
88cdf0e10cSrcweir 		{
89cdf0e10cSrcweir 			DBG_ASSERT(GetSdrObject().GetSubList(),
90cdf0e10cSrcweir 				"ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
91cdf0e10cSrcweir 			SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
92cdf0e10cSrcweir 			DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
93cdf0e10cSrcweir 			return pObj->GetViewContact();
94cdf0e10cSrcweir 		}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		ViewContact* ViewContactOfSdrObj::GetParentContact() const
97cdf0e10cSrcweir 		{
98cdf0e10cSrcweir 			ViewContact* pRetval = 0L;
99cdf0e10cSrcweir 			SdrObjList* pObjList = GetSdrObject().GetObjList();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 			if(pObjList)
102cdf0e10cSrcweir 			{
103cdf0e10cSrcweir 				if(pObjList->ISA(SdrPage))
104cdf0e10cSrcweir 				{
105cdf0e10cSrcweir 					// Is a page
106cdf0e10cSrcweir 					pRetval = &(((SdrPage*)pObjList)->GetViewContact());
107cdf0e10cSrcweir 				}
108cdf0e10cSrcweir 				else
109cdf0e10cSrcweir 				{
110cdf0e10cSrcweir 					// Is a group?
111cdf0e10cSrcweir 					if(pObjList->GetOwnerObj())
112cdf0e10cSrcweir 					{
113cdf0e10cSrcweir 						pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
114cdf0e10cSrcweir 					}
115cdf0e10cSrcweir 				}
116cdf0e10cSrcweir 			}
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 			return pRetval;
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		// React on changes of the object of this ViewContact
122cdf0e10cSrcweir 		void ViewContactOfSdrObj::ActionChanged()
123cdf0e10cSrcweir 		{
124cdf0e10cSrcweir 			// look for own changes
125cdf0e10cSrcweir 			if(GetSdrObject().ISA(SdrTextObj))
126cdf0e10cSrcweir 			{
127cdf0e10cSrcweir 				SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 				if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
130cdf0e10cSrcweir 				{
131cdf0e10cSrcweir 					// #i38135# now remember new type
132cdf0e10cSrcweir 					meRememberedAnimationKind = rTextObj.GetTextAniKind();
133cdf0e10cSrcweir 				}
134cdf0e10cSrcweir 			}
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 			// call parent
137cdf0e10cSrcweir 			ViewContact::ActionChanged();
138cdf0e10cSrcweir 		}
139cdf0e10cSrcweir 
140*672a9062Smseidel 		// overload for accessing the SdrObject
141cdf0e10cSrcweir 		SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			return &GetSdrObject();
144cdf0e10cSrcweir 		}
145*672a9062Smseidel 
146cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
147cdf0e10cSrcweir 		// primitive stuff
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 		// add Gluepoints (if available)
150cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
151cdf0e10cSrcweir 		{
152cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
153cdf0e10cSrcweir 			const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 			if(pGluePointList)
156cdf0e10cSrcweir 			{
157cdf0e10cSrcweir 				const sal_uInt32 nCount(pGluePointList->GetCount());
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 				if(nCount)
160cdf0e10cSrcweir 				{
161cdf0e10cSrcweir 					// prepare point vector
162cdf0e10cSrcweir 					std::vector< basegfx::B2DPoint > aGluepointVector;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 					// create GluePoint primitives. ATM these are relative to the SnapRect
165cdf0e10cSrcweir 					for(sal_uInt32 a(0L); a < nCount; a++)
166cdf0e10cSrcweir 					{
167cdf0e10cSrcweir 						const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
168cdf0e10cSrcweir 						const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 						aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
171cdf0e10cSrcweir 					}
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 					if(!aGluepointVector.empty())
174cdf0e10cSrcweir 					{
175cdf0e10cSrcweir 						const basegfx::BColor aBackPen(1.0, 1.0, 1.0);
176cdf0e10cSrcweir 						const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE
177cdf0e10cSrcweir 						const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
178*672a9062Smseidel 							aGluepointVector,
179cdf0e10cSrcweir 							drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor)));
180*672a9062Smseidel 						xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
181cdf0e10cSrcweir 					}
182cdf0e10cSrcweir 				}
183cdf0e10cSrcweir 			}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 			return xRetval;
186cdf0e10cSrcweir 		}
187025b0597SArmin Le Grand 
188*672a9062Smseidel 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const
189*672a9062Smseidel 		{
190*672a9062Smseidel 			if(rSource.hasElements() &&
191*672a9062Smseidel 				(GetSdrObject().GetName().Len() ||
192*672a9062Smseidel 				GetSdrObject().GetTitle().Len() ||
193*672a9062Smseidel 				GetSdrObject().GetDescription().Len()))
194*672a9062Smseidel 			{
195*672a9062Smseidel 				const drawinglayer::primitive2d::Primitive2DReference xRef(
196*672a9062Smseidel 					new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
197*672a9062Smseidel 						rSource,
198*672a9062Smseidel 						GetSdrObject().GetName(),
199*672a9062Smseidel 						GetSdrObject().GetTitle(),
200*672a9062Smseidel 						GetSdrObject().GetDescription()));
201*672a9062Smseidel 
202*672a9062Smseidel 				return drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
203*672a9062Smseidel 			}
204*672a9062Smseidel 
205*672a9062Smseidel 			return rSource;
206*672a9062Smseidel 		}
207025b0597SArmin Le Grand 
208cdf0e10cSrcweir 	} // end of namespace contact
209cdf0e10cSrcweir } // end of namespace sdr
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
212cdf0e10cSrcweir // eof
213