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 <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 17825 : ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact& rObjectContact, ViewContact& rViewContact)
41 17825 : : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
42 : {
43 17825 : }
44 :
45 34932 : ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
46 : {
47 34932 : }
48 :
49 20044 : drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
50 : {
51 20044 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
52 :
53 : // check model-view visibility
54 20044 : if(isPrimitiveVisible(rDisplayInfo))
55 : {
56 19097 : const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
57 :
58 19097 : if(nSubHierarchyCount)
59 : {
60 : const bool bDoGhostedDisplaying(
61 19010 : GetObjectContact().DoVisualizeEnteredGroup()
62 18931 : && !GetObjectContact().isOutputToPrinter()
63 37941 : && GetObjectContact().getActiveViewContact() == &GetViewContact());
64 :
65 19010 : if(bDoGhostedDisplaying)
66 : {
67 0 : rDisplayInfo.ClearGhostedDrawMode();
68 : }
69 :
70 : // create object hierarchy
71 19010 : xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
72 :
73 19010 : if(xRetval.hasElements())
74 : {
75 : // get ranges
76 16517 : const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
77 16517 : const ::basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
78 16517 : const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
79 :
80 : // check geometrical visibility
81 16517 : if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
82 : {
83 : // not visible, release
84 0 : xRetval.realloc(0);
85 : }
86 : }
87 :
88 19010 : 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 87 : xRetval = ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
98 : }
99 : }
100 20044 : return xRetval;
101 : }
102 :
103 20131 : bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const
104 : {
105 20131 : SetOfByte aObjectLayers;
106 20131 : getSdrObject().getMergedHierarchyLayerSet(aObjectLayers);
107 20131 : aObjectLayers &= aLayers;
108 20131 : return !aObjectLayers.IsEmpty();
109 : }
110 : } // end of namespace contact
111 : } // end of namespace sdr
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|