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/viewobjectcontactofmasterpagedescriptor.hxx>
22 : #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
23 : #include <svx/sdr/contact/displayinfo.hxx>
24 : #include <svx/sdr/contact/objectcontact.hxx>
25 : #include <svx/svdpagv.hxx>
26 : #include <svx/svdview.hxx>
27 : #include <svx/svdpage.hxx>
28 : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
29 : #include <basegfx/polygon/b2dpolygontools.hxx>
30 : #include <basegfx/polygon/b2dpolygon.hxx>
31 :
32 : //////////////////////////////////////////////////////////////////////////////
33 :
34 : namespace sdr
35 : {
36 : namespace contact
37 : {
38 0 : ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact& rObjectContact, ViewContact& rViewContact)
39 0 : : ViewObjectContact(rObjectContact, rViewContact)
40 : {
41 0 : }
42 :
43 0 : ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
44 : {
45 0 : }
46 :
47 0 : sdr::MasterPageDescriptor& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
48 : {
49 0 : return static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).GetMasterPageDescriptor();
50 : }
51 :
52 0 : bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
53 : {
54 0 : if(rDisplayInfo.GetControlLayerProcessingActive())
55 : {
56 0 : return false;
57 : }
58 :
59 0 : if(!rDisplayInfo.GetPageProcessingActive())
60 : {
61 0 : return false;
62 : }
63 :
64 0 : return true;
65 : }
66 :
67 0 : drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
68 : {
69 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
70 0 : drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence;
71 0 : const sdr::MasterPageDescriptor& rDescriptor = GetMasterPageDescriptor();
72 :
73 : // used range (retval) is fixed here, it's the MasterPage fill range
74 0 : const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
75 : const basegfx::B2DRange aPageFillRange(
76 0 : rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
77 0 : rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
78 :
79 : // Modify DisplayInfo for MasterPageContent collection; remember original layers and
80 : // set combined LayerSet; set MasterPagePaint flag
81 0 : const SetOfByte aRememberedLayers(rDisplayInfo.GetProcessLayers());
82 0 : SetOfByte aPreprocessedLayers(aRememberedLayers);
83 0 : aPreprocessedLayers &= rDescriptor.GetVisibleLayers();
84 0 : rDisplayInfo.SetProcessLayers(aPreprocessedLayers);
85 0 : rDisplayInfo.SetSubContentActive(true);
86 :
87 : // check layer visibility (traditionally was member of layer 1)
88 0 : if(aPreprocessedLayers.IsSet(1))
89 : {
90 : // hide PageBackground for special DrawModes; historical reasons
91 0 : if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
92 : {
93 : // if visible, create the default background primitive sequence
94 0 : xRetval = static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
95 : }
96 : }
97 :
98 : // hide MasterPage content? Test self here for hierarchy
99 0 : if(isPrimitiveVisible(rDisplayInfo))
100 : {
101 : // get the VOC of the Master-SdrPage and get it's object hierarchy
102 0 : ViewContact& rViewContactOfMasterPage(rDescriptor.GetUsedPage().GetViewContact());
103 0 : ViewObjectContact& rVOCOfMasterPage(rViewContactOfMasterPage.GetViewObjectContact(GetObjectContact()));
104 :
105 0 : xMasterPageSequence = rVOCOfMasterPage.getPrimitive2DSequenceHierarchy(rDisplayInfo);
106 : }
107 :
108 : // reset DisplayInfo changes for MasterPage paint
109 0 : rDisplayInfo.SetProcessLayers(aRememberedLayers);
110 0 : rDisplayInfo.SetSubContentActive(false);
111 :
112 0 : if(xMasterPageSequence.hasElements())
113 : {
114 : // get range of MasterPage sub hierarchy
115 0 : const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
116 0 : const basegfx::B2DRange aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence, rViewInformation2D));
117 :
118 0 : if(aPageFillRange.isInside(aSubHierarchyRange))
119 : {
120 : // completely inside, just render MasterPage content. Add to target
121 0 : drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xMasterPageSequence);
122 : }
123 0 : else if(aPageFillRange.overlaps(aSubHierarchyRange))
124 : {
125 : // overlapping, compute common area
126 0 : basegfx::B2DRange aCommonArea(aPageFillRange);
127 0 : aCommonArea.intersect(aSubHierarchyRange);
128 :
129 : // need to create a clip primitive, add clipped list to target
130 : const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MaskPrimitive2D(
131 0 : basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea)), xMasterPageSequence));
132 0 : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
133 : }
134 : }
135 :
136 : // return grouped primitive
137 0 : return xRetval;
138 : }
139 : } // end of namespace contact
140 : } // end of namespace sdr
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|