update dev300-m58
[ooovba.git] / svx / source / sdr / contact / viewobjectcontactofmasterpagedescriptor.cxx
blob567708e5daaafef8471a6fa54639d008a1fca061
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewobjectcontactofmasterpagedescriptor.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
36 #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
37 #include <svx/sdr/contact/displayinfo.hxx>
38 #include <svx/sdr/contact/objectcontact.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdview.hxx>
41 #include <svx/svdpage.hxx>
42 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
43 #include <basegfx/polygon/b2dpolygontools.hxx>
44 #include <basegfx/polygon/b2dpolygon.hxx>
46 //////////////////////////////////////////////////////////////////////////////
48 namespace sdr
50 namespace contact
52 ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact& rObjectContact, ViewContact& rViewContact)
53 : ViewObjectContact(rObjectContact, rViewContact)
57 ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
61 sdr::MasterPageDescriptor& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
63 return static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).GetMasterPageDescriptor();
66 bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
68 if(rDisplayInfo.GetControlLayerProcessingActive())
70 return false;
73 if(!rDisplayInfo.GetPageProcessingActive())
75 return false;
78 return true;
81 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
83 drawinglayer::primitive2d::Primitive2DSequence xRetval;
84 drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence;
85 const sdr::MasterPageDescriptor& rDescriptor = GetMasterPageDescriptor();
87 // used range (retval) is fixed here, it's the MasterPage fill range
88 const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
89 const basegfx::B2DRange aPageFillRange(
90 rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
91 rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
93 // Modify DisplayInfo for MasterPageContent collection; remember original layers and
94 // set combined LayerSet; set MasterPagePaint flag
95 const SetOfByte aRememberedLayers(rDisplayInfo.GetProcessLayers());
96 SetOfByte aPreprocessedLayers(aRememberedLayers);
97 aPreprocessedLayers &= rDescriptor.GetVisibleLayers();
98 rDisplayInfo.SetProcessLayers(aPreprocessedLayers);
99 rDisplayInfo.SetSubContentActive(true);
101 // check if there is a MasterPageBackgroundObject and if it's visible in the LayerSet
102 const SdrObject* pBackgroundCandidate = rDescriptor.GetBackgroundObject();
104 if(pBackgroundCandidate && aPreprocessedLayers.IsSet(pBackgroundCandidate->GetLayer()))
106 // hide PageBackground for special DrawModes; historical reasons
107 if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
109 // if yes, create the default background primitive sequence
110 xRetval = static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
114 // hide MasterPage content? Test self here for hierarchy
115 if(isPrimitiveVisible(rDisplayInfo))
117 // get the VOC of the Master-SdrPage and get it's object hierarchy
118 ViewContact& rViewContactOfMasterPage(rDescriptor.GetUsedPage().GetViewContact());
119 ViewObjectContact& rVOCOfMasterPage(rViewContactOfMasterPage.GetViewObjectContact(GetObjectContact()));
121 xMasterPageSequence = rVOCOfMasterPage.getPrimitive2DSequenceHierarchy(rDisplayInfo);
124 // reset DisplayInfo changes for MasterPage paint
125 rDisplayInfo.SetProcessLayers(aRememberedLayers);
126 rDisplayInfo.SetSubContentActive(false);
128 if(xMasterPageSequence.hasElements())
130 // get range of MasterPage sub hierarchy
131 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
132 const basegfx::B2DRange aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence, rViewInformation2D));
134 if(aPageFillRange.isInside(aSubHierarchyRange))
136 // completely inside, just render MasterPage content. Add to target
137 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xMasterPageSequence);
139 else if(aPageFillRange.overlaps(aSubHierarchyRange))
141 // overlapping, compute common area
142 basegfx::B2DRange aCommonArea(aPageFillRange);
143 aCommonArea.intersect(aSubHierarchyRange);
145 // need to create a clip primitive, add clipped list to target
146 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MaskPrimitive2D(
147 basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea)), xMasterPageSequence));
148 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
152 // return grouped primitive
153 return xRetval;
155 } // end of namespace contact
156 } // end of namespace sdr
158 //////////////////////////////////////////////////////////////////////////////
159 // eof