Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
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>
29 :
30 :
31 :
32 : using namespace com::sun::star;
33 :
34 :
35 :
36 : namespace sdr
37 : {
38 : namespace contact
39 : {
40 0 : ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact& rObjectContact, ViewContact& rViewContact)
41 0 : : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
42 : {
43 0 : }
44 :
45 0 : ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
46 : {
47 0 : }
48 :
49 0 : drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
50 : {
51 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
52 :
53 : // check model-view visibility
54 0 : if(isPrimitiveVisible(rDisplayInfo))
55 : {
56 0 : const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
57 :
58 0 : if(nSubHierarchyCount)
59 : {
60 : const sal_Bool bDoGhostedDisplaying(
61 0 : GetObjectContact().DoVisualizeEnteredGroup()
62 0 : && !GetObjectContact().isOutputToPrinter()
63 0 : && GetObjectContact().getActiveViewContact() == &GetViewContact());
64 :
65 0 : if(bDoGhostedDisplaying)
66 : {
67 0 : rDisplayInfo.ClearGhostedDrawMode();
68 : }
69 :
70 : // create object hierarchy
71 0 : xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
72 :
73 0 : if(xRetval.hasElements())
74 : {
75 : // get ranges
76 0 : const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
77 0 : const ::basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
78 0 : const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
79 :
80 : // check geometrical visibility
81 0 : if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
82 : {
83 : // not visible, release
84 0 : xRetval.realloc(0);
85 : }
86 : }
87 :
88 0 : if(bDoGhostedDisplaying)
89 : {
90 0 : rDisplayInfo.SetGhostedDrawMode();
91 : }
92 : }
93 : else
94 : {
95 : // draw replacement object for group. This will use ViewContactOfGroup::createViewIndependentPrimitive2DSequence
96 : // which creates the replacement primitives for an empty group
97 0 : xRetval = ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
98 : }
99 : }
100 0 : return xRetval;
101 : }
102 :
103 0 : bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const
104 : {
105 0 : SetOfByte aObjectLayers;
106 0 : getSdrObject().getMergedHierarchyLayerSet(aObjectLayers);
107 0 : aObjectLayers &= aLayers;
108 0 : return !aObjectLayers.IsEmpty();
109 : }
110 : } // end of namespace contact
111 : } // end of namespace sdr
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|