Update ooo320-m1
[ooovba.git] / svx / source / sdr / contact / viewobjectcontactofgroup.cxx
blob9f58fe5f9e6de38986262e2b93d086b8fef396aa
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: viewobjectcontactofgroup.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
36 #include <svx/sdr/contact/displayinfo.hxx>
37 #include <svx/sdr/contact/objectcontact.hxx>
38 #include <basegfx/numeric/ftools.hxx>
39 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
40 #include <basegfx/tools/canvastools.hxx>
41 #include <svx/sdr/contact/viewcontact.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 using namespace com::sun::star;
47 //////////////////////////////////////////////////////////////////////////////
49 namespace sdr
51 namespace contact
53 ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact& rObjectContact, ViewContact& rViewContact)
54 : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
58 ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
62 bool ViewObjectContactOfGroup::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
64 const bool bHasChildren(0 != GetViewContact().GetObjectCount());
66 if(!bHasChildren && (GetObjectContact().isOutputToPrinter() || GetObjectContact().isOutputToRecordingMetaFile()))
68 // empty group uses fallback gray empty frame display. Do neither print nor PDF export it
69 return false;
72 // call parent
73 return ViewObjectContactOfSdrObj::isPrimitiveVisible(rDisplayInfo);
76 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
78 const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
80 if(nSubHierarchyCount)
82 const sal_Bool bDoGhostedDisplaying(
83 GetObjectContact().DoVisualizeEnteredGroup()
84 && !GetObjectContact().isOutputToPrinter()
85 && GetObjectContact().getActiveViewContact() == &GetViewContact());
87 if(bDoGhostedDisplaying)
89 rDisplayInfo.ClearGhostedDrawMode();
92 // create object hierarchy
93 drawinglayer::primitive2d::Primitive2DSequence xRetval(getPrimitive2DSequenceSubHierarchy(rDisplayInfo));
95 if(xRetval.hasElements())
97 // get ranges
98 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
99 const ::basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
100 const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
102 // check geometrical visibility
103 if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
105 // not visible, release
106 xRetval.realloc(0);
110 if(bDoGhostedDisplaying)
112 rDisplayInfo.SetGhostedDrawMode();
115 return xRetval;
117 else
119 // draw replacement object for group. This will use ViewContactOfGroup::createViewIndependentPrimitive2DSequence
120 // which creates the replacement primitives for an empty group
121 return ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
124 } // end of namespace contact
125 } // end of namespace sdr
127 //////////////////////////////////////////////////////////////////////////////
128 // eof