xref: /trunk/main/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
31 #include <svx/sdr/contact/viewobjectcontact.hxx>
32 #include <svx/svdpage.hxx>
33 #include <svx/sdr/contact/displayinfo.hxx>
34 #include <svx/svdobj.hxx>
35 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
36 #include <vcl/timer.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdview.hxx>
39 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
40 #include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
41 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
42 #include <basegfx/polygon/b2dpolygontools.hxx>
43 #include <basegfx/matrix/b2dhommatrix.hxx>
44 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
45 #include <svx/svdpage.hxx>
46 #include <drawinglayer/attribute/sdrfillattribute.hxx>
47 #include <basegfx/polygon/b2dpolygon.hxx>
48 #include <drawinglayer/attribute/fillgradientattribute.hxx>
49 
50 //////////////////////////////////////////////////////////////////////////////
51 
52 namespace sdr
53 {
54     namespace contact
55     {
56         ViewObjectContact& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
57         {
58             return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact, *this));
59         }
60 
61         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPageDescriptor::createViewIndependentPrimitive2DSequence() const
62         {
63             drawinglayer::primitive2d::Primitive2DSequence xRetval;
64             drawinglayer::attribute::SdrFillAttribute aFill;
65             const SdrPageProperties* pCorrectProperties = GetMasterPageDescriptor().getCorrectSdrPageProperties();
66 
67             if(pCorrectProperties)
68             {
69                 // create page fill attributes when correct properties were identified
70                 aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(pCorrectProperties->GetItemSet());
71             }
72 
73             if(!aFill.isDefault())
74             {
75                 // direct model data is the page size, get and use it
76                 const SdrPage& rOwnerPage = GetMasterPageDescriptor().GetOwnerPage();
77                 const basegfx::B2DRange aInnerRange(
78                     rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
79                     rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(),
80                     rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
81                 const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
82                 const basegfx::B2DHomMatrix aEmptyTransform;
83                 const drawinglayer::primitive2d::Primitive2DReference xReference(
84                     drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
85                         basegfx::B2DPolyPolygon(aInnerPolgon),
86                         aEmptyTransform,
87                         aFill,
88                         drawinglayer::attribute::FillGradientAttribute()));
89 
90                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
91             }
92 
93             return xRetval;
94         }
95 
96         // basic constructor
97         ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor& rDescriptor)
98         :   ViewContact(),
99             mrMasterPageDescriptor(rDescriptor)
100         {
101         }
102 
103         // The destructor.
104         ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
105         {
106         }
107 
108         sal_uInt32 ViewContactOfMasterPageDescriptor::GetObjectCount() const
109         {
110             return GetMasterPageDescriptor().GetUsedPage().GetObjCount();
111         }
112 
113         ViewContact& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex) const
114         {
115             return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex)->GetViewContact();
116         }
117 
118         ViewContact* ViewContactOfMasterPageDescriptor::GetParentContact() const
119         {
120             return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
121         }
122     } // end of namespace contact
123 } // end of namespace sdr
124 
125 //////////////////////////////////////////////////////////////////////////////
126 // eof
127