merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / contact / viewcontactofmasterpagedescriptor.cxx
blob0b7d9d757293e1cd0839e2121a94a67182112627
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: viewcontactofmasterpagedescriptor.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
34 #include <svx/sdr/contact/viewobjectcontact.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/sdr/contact/displayinfo.hxx>
37 #include <svx/svdobj.hxx>
38 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
39 #include <vcl/timer.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <svx/svdview.hxx>
42 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
43 #include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
44 #include <drawinglayer/attribute/sdrattribute.hxx>
45 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
46 #include <basegfx/polygon/b2dpolygontools.hxx>
47 #include <basegfx/matrix/b2dhommatrix.hxx>
48 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
49 #include <svx/svdpage.hxx>
51 //////////////////////////////////////////////////////////////////////////////
53 namespace sdr
55 namespace contact
57 ViewObjectContact& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
59 return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact, *this));
62 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPageDescriptor::createViewIndependentPrimitive2DSequence() const
64 drawinglayer::primitive2d::Primitive2DSequence xRetval;
65 const SdrObject* pBackgroundCandidate = GetMasterPageDescriptor().GetBackgroundObject();
67 if(pBackgroundCandidate)
69 // build primitive from pBackgroundCandidate's attributes
70 const SfxItemSet& rFillProperties = pBackgroundCandidate->GetMergedItemSet();
71 drawinglayer::attribute::SdrFillAttribute* pFill = drawinglayer::primitive2d::createNewSdrFillAttribute(rFillProperties);
73 if(pFill)
75 if(pFill->isVisible())
77 // direct model data is the page size, get and use it
78 const SdrPage& rOwnerPage = GetMasterPageDescriptor().GetOwnerPage();
79 const basegfx::B2DRange aInnerRange(
80 rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
81 rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
82 const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
83 const basegfx::B2DHomMatrix aEmptyTransform;
84 const drawinglayer::primitive2d::Primitive2DReference xReference(drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
85 basegfx::B2DPolyPolygon(aInnerPolgon), aEmptyTransform, *pFill));
87 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
90 delete pFill;
94 return xRetval;
97 // basic constructor
98 ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor& rDescriptor)
99 : ViewContact(),
100 mrMasterPageDescriptor(rDescriptor)
104 // The destructor.
105 ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
109 sal_uInt32 ViewContactOfMasterPageDescriptor::GetObjectCount() const
111 sal_uInt32 nRetval(GetMasterPageDescriptor().GetUsedPage().GetObjCount());
113 if(nRetval && GetMasterPageDescriptor().GetUsedPage().GetObj(0)->IsMasterPageBackgroundObject())
115 nRetval--;
118 return nRetval;
121 ViewContact& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex) const
123 if(GetMasterPageDescriptor().GetUsedPage().GetObjCount() && GetMasterPageDescriptor().GetUsedPage().GetObj(0)->IsMasterPageBackgroundObject())
125 nIndex++;
128 return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex)->GetViewContact();
131 ViewContact* ViewContactOfMasterPageDescriptor::GetParentContact() const
133 return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
135 } // end of namespace contact
136 } // end of namespace sdr
138 //////////////////////////////////////////////////////////////////////////////
139 // eof