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/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>
32 //////////////////////////////////////////////////////////////////////////////
38 ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
39 : ViewObjectContact(rObjectContact
, rViewContact
)
43 ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
47 sdr::MasterPageDescriptor
& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
49 return static_cast< ViewContactOfMasterPageDescriptor
& >(GetViewContact()).GetMasterPageDescriptor();
52 bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
54 if(rDisplayInfo
.GetControlLayerProcessingActive())
59 if(!rDisplayInfo
.GetPageProcessingActive())
67 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
69 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
70 drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence
;
71 const sdr::MasterPageDescriptor
& rDescriptor
= GetMasterPageDescriptor();
73 // used range (retval) is fixed here, it's the MasterPage fill range
74 const SdrPage
& rOwnerPage
= rDescriptor
.GetOwnerPage();
75 const basegfx::B2DRange
aPageFillRange(
76 rOwnerPage
.GetLftBorder(), rOwnerPage
.GetUppBorder(),
77 rOwnerPage
.GetWdt() - rOwnerPage
.GetRgtBorder(), rOwnerPage
.GetHgt() - rOwnerPage
.GetLwrBorder());
79 // Modify DisplayInfo for MasterPageContent collection; remember original layers and
80 // set combined LayerSet; set MasterPagePaint flag
81 const SetOfByte
aRememberedLayers(rDisplayInfo
.GetProcessLayers());
82 SetOfByte
aPreprocessedLayers(aRememberedLayers
);
83 aPreprocessedLayers
&= rDescriptor
.GetVisibleLayers();
84 rDisplayInfo
.SetProcessLayers(aPreprocessedLayers
);
85 rDisplayInfo
.SetSubContentActive(true);
87 // check layer visibility (traditionally was member of layer 1)
88 if(aPreprocessedLayers
.IsSet(1))
90 // hide PageBackground for special DrawModes; historical reasons
91 if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
93 // if visible, create the default background primitive sequence
94 xRetval
= static_cast< ViewContactOfMasterPageDescriptor
& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
98 // hide MasterPage content? Test self here for hierarchy
99 if(isPrimitiveVisible(rDisplayInfo
))
101 // get the VOC of the Master-SdrPage and get it's object hierarchy
102 ViewContact
& rViewContactOfMasterPage(rDescriptor
.GetUsedPage().GetViewContact());
103 ViewObjectContact
& rVOCOfMasterPage(rViewContactOfMasterPage
.GetViewObjectContact(GetObjectContact()));
105 xMasterPageSequence
= rVOCOfMasterPage
.getPrimitive2DSequenceHierarchy(rDisplayInfo
);
108 // reset DisplayInfo changes for MasterPage paint
109 rDisplayInfo
.SetProcessLayers(aRememberedLayers
);
110 rDisplayInfo
.SetSubContentActive(false);
112 if(xMasterPageSequence
.hasElements())
114 // get range of MasterPage sub hierarchy
115 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
116 const basegfx::B2DRange
aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence
, rViewInformation2D
));
118 if(aPageFillRange
.isInside(aSubHierarchyRange
))
120 // completely inside, just render MasterPage content. Add to target
121 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval
, xMasterPageSequence
);
123 else if(aPageFillRange
.overlaps(aSubHierarchyRange
))
125 // overlapping, compute common area
126 basegfx::B2DRange
aCommonArea(aPageFillRange
);
127 aCommonArea
.intersect(aSubHierarchyRange
);
129 // need to create a clip primitive, add clipped list to target
130 const drawinglayer::primitive2d::Primitive2DReference
xReference(new drawinglayer::primitive2d::MaskPrimitive2D(
131 basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea
)), xMasterPageSequence
));
132 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval
, xReference
);
136 // return grouped primitive
139 } // end of namespace contact
140 } // end of namespace sdr
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */