1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
22 #include <svx/sdr/contact/displayinfo.hxx>
23 #include <svx/sdr/contact/objectcontact.hxx>
24 #include <basegfx/numeric/ftools.hxx>
25 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
26 #include <basegfx/tools/canvastools.hxx>
27 #include <svx/sdr/contact/viewcontact.hxx>
28 #include <svx/svdobj.hxx>
30 //////////////////////////////////////////////////////////////////////////////
32 using namespace com::sun::star
;
34 //////////////////////////////////////////////////////////////////////////////
40 ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
41 : ViewObjectContactOfSdrObj(rObjectContact
, rViewContact
)
45 ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
49 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
51 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
53 // check model-view visibility
54 if(isPrimitiveVisible(rDisplayInfo
))
56 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
58 if(nSubHierarchyCount
)
60 const sal_Bool
bDoGhostedDisplaying(
61 GetObjectContact().DoVisualizeEnteredGroup()
62 && !GetObjectContact().isOutputToPrinter()
63 && GetObjectContact().getActiveViewContact() == &GetViewContact());
65 if(bDoGhostedDisplaying
)
67 rDisplayInfo
.ClearGhostedDrawMode();
70 // create object hierarchy
71 xRetval
= getPrimitive2DSequenceSubHierarchy(rDisplayInfo
);
73 if(xRetval
.hasElements())
76 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
77 const ::basegfx::B2DRange
aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval
, rViewInformation2D
));
78 const basegfx::B2DRange
aViewRange(rViewInformation2D
.getViewport());
80 // check geometrical visibility
81 if(!aViewRange
.isEmpty() && !aViewRange
.overlaps(aObjectRange
))
83 // not visible, release
88 if(bDoGhostedDisplaying
)
90 rDisplayInfo
.SetGhostedDrawMode();
95 // draw replacement object for group. This will use ViewContactOfGroup::createViewIndependentPrimitive2DSequence
96 // which creates the replacement primitives for an empty group
97 xRetval
= ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo
);
103 bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const SetOfByte
& aLayers
) const
105 SetOfByte aObjectLayers
;
106 getSdrObject().getMergedHierarchyLayerSet(aObjectLayers
);
107 aObjectLayers
&= aLayers
;
108 return !aObjectLayers
.IsEmpty();
110 } // end of namespace contact
111 } // end of namespace sdr
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */