merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / contact / viewcontactofgroup.cxx
blob5c5e6edc48f58c89d5a6b877bc278dbc9e0da8f2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewcontactofgroup.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/contact/viewcontactofgroup.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/sdr/contact/viewobjectcontact.hxx>
37 #include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
38 #include <basegfx/polygon/b2dpolygon.hxx>
39 #include <basegfx/polygon/b2dpolygontools.hxx>
40 #include <basegfx/color/bcolor.hxx>
41 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 namespace sdr
47 namespace contact
49 // Create a Object-Specific ViewObjectContact, set ViewContact and
50 // ObjectContact. Always needs to return something.
51 ViewObjectContact& ViewContactOfGroup::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
53 ViewObjectContact* pRetval = new ViewObjectContactOfGroup(rObjectContact, *this);
54 DBG_ASSERT(pRetval, "ViewContactOfGroup::CreateObjectSpecificViewObjectContact() failed (!)");
56 return *pRetval;
59 ViewContactOfGroup::ViewContactOfGroup(SdrObjGroup& rGroup)
60 : ViewContactOfSdrObj(rGroup)
64 ViewContactOfGroup::~ViewContactOfGroup()
68 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGroup::createViewIndependentPrimitive2DSequence() const
70 drawinglayer::primitive2d::Primitive2DSequence xRetval;
71 const sal_uInt32 nObjectCount(GetObjectCount());
73 if(nObjectCount)
75 // collect all sub-primitives
76 for(sal_uInt32 a(0); a < nObjectCount; a++)
78 const ViewContact& rCandidate(GetViewContact(a));
79 const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
81 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
85 if(xRetval.hasElements())
87 return xRetval;
89 else
91 // create a gray placeholder hairline polygon in object size. Use the model data directly. For empty groups,
92 // this is SdrObject::aOutRect, as can be seen in SdrObjGroup::GetSnapRect(). Access that using GetLastBoundRect()
93 // to not execute anything.
94 const Rectangle aCurrentBoundRect(GetSdrObjGroup().GetLastBoundRect());
95 const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(
96 aCurrentBoundRect.Left(), aCurrentBoundRect.Top(), aCurrentBoundRect.Right(), aCurrentBoundRect.Bottom())));
97 const basegfx::BColor aGrayTone(0xc0 / 255.0, 0xc0 / 255.0, 0xc0 / 255.0);
98 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aGrayTone));
100 // The replacement object may also get a text like 'empty group' here later
101 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
104 } // end of namespace contact
105 } // end of namespace sdr
107 //////////////////////////////////////////////////////////////////////////////
108 // eof