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 
31 #include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
32 #include <svx/sdr/contact/displayinfo.hxx>
33 #include <svx/sdr/contact/objectcontact.hxx>
34 #include <basegfx/numeric/ftools.hxx>
35 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
36 #include <basegfx/tools/canvastools.hxx>
37 #include <svx/sdr/contact/viewcontact.hxx>
38 
39 //////////////////////////////////////////////////////////////////////////////
40 
41 using namespace com::sun::star;
42 
43 //////////////////////////////////////////////////////////////////////////////
44 
45 namespace sdr
46 {
47 	namespace contact
48 	{
49 		ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact& rObjectContact, ViewContact& rViewContact)
50 		:	ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
51 		{
52 		}
53 
54 		ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
55 		{
56 		}
57 
58         drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
59 		{
60 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
61 
62 			// check model-view visibility
63 			if(isPrimitiveVisible(rDisplayInfo))
64 			{
65 				const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
66 
67 				if(nSubHierarchyCount)
68 				{
69 					const sal_Bool bDoGhostedDisplaying(
70 						GetObjectContact().DoVisualizeEnteredGroup()
71 						&& !GetObjectContact().isOutputToPrinter()
72 						&& GetObjectContact().getActiveViewContact() == &GetViewContact());
73 
74 					if(bDoGhostedDisplaying)
75 					{
76 						rDisplayInfo.ClearGhostedDrawMode();
77 					}
78 
79 					// create object hierarchy
80 					xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
81 
82 					if(xRetval.hasElements())
83 					{
84 						// get ranges
85 						const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
86 						const ::basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
87 						const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
88 
89 						// check geometrical visibility
90 						if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
91 						{
92 							// not visible, release
93 							xRetval.realloc(0);
94 						}
95 					}
96 
97 					if(bDoGhostedDisplaying)
98 					{
99 						rDisplayInfo.SetGhostedDrawMode();
100 					}
101 				}
102 				else
103 				{
104 					// draw replacement object for group. This will use ViewContactOfGroup::createViewIndependentPrimitive2DSequence
105 					// which creates the replacement primitives for an empty group
106 					xRetval = ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
107 				}
108 			}
109 			return xRetval;
110 		}
111 	} // end of namespace contact
112 } // end of namespace sdr
113 
114 //////////////////////////////////////////////////////////////////////////////
115 // eof
116