1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/contact/viewcontactofgroup.hxx>
31 #include <svx/svdogrp.hxx>
32 #include <svx/svdpage.hxx>
33 #include <svx/sdr/contact/viewobjectcontact.hxx>
34 #include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
35 #include <basegfx/polygon/b2dpolygon.hxx>
36 #include <basegfx/polygon/b2dpolygontools.hxx>
37 #include <basegfx/color/bcolor.hxx>
38 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace sdr
44 {
45 	namespace contact
46 	{
47 		// Create a Object-Specific ViewObjectContact, set ViewContact and
48 		// ObjectContact. Always needs to return something.
49 		ViewObjectContact& ViewContactOfGroup::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
50 		{
51 			ViewObjectContact* pRetval = new ViewObjectContactOfGroup(rObjectContact, *this);
52 			DBG_ASSERT(pRetval, "ViewContactOfGroup::CreateObjectSpecificViewObjectContact() failed (!)");
53 
54 			return *pRetval;
55 		}
56 
57 		ViewContactOfGroup::ViewContactOfGroup(SdrObjGroup& rGroup)
58 		:	ViewContactOfSdrObj(rGroup)
59 		{
60 		}
61 
62 		ViewContactOfGroup::~ViewContactOfGroup()
63 		{
64 		}
65 
66 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGroup::createViewIndependentPrimitive2DSequence() const
67 		{
68 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
69 			const sal_uInt32 nObjectCount(GetObjectCount());
70 
71 			if(nObjectCount)
72 			{
73 				// collect all sub-primitives
74 				for(sal_uInt32 a(0); a < nObjectCount; a++)
75 				{
76 					const ViewContact& rCandidate(GetViewContact(a));
77 					const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
78 
79 					drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
80 				}
81 			}
82 			else
83 			{
84 				// append an invisible outline for the cases where no visible content exists
85 				const Rectangle aCurrentBoundRect(GetSdrObjGroup().GetLastBoundRect());
86 				const basegfx::B2DRange aCurrentRange(
87 					aCurrentBoundRect.Left(), aCurrentBoundRect.Top(),
88 					aCurrentBoundRect.Right(), aCurrentBoundRect.Bottom());
89 
90 				const drawinglayer::primitive2d::Primitive2DReference xReference(
91 					drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
92 						false, aCurrentRange));
93 
94 				xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
95 			}
96 
97             return xRetval;
98 		}
99 	} // end of namespace contact
100 } // end of namespace sdr
101 
102 //////////////////////////////////////////////////////////////////////////////
103 // eof
104