1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
27 #include <svx/sdr/contact/viewobjectcontact.hxx>
28 #include <svx/svdpage.hxx>
29 #include <svx/sdr/contact/displayinfo.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
32 #include <vcl/timer.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <svx/svdview.hxx>
35 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
36 #include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
37 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38 #include <basegfx/polygon/b2dpolygontools.hxx>
39 #include <basegfx/matrix/b2dhommatrix.hxx>
40 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
41 #include <svx/svdpage.hxx>
42 #include <drawinglayer/attribute/sdrfillattribute.hxx>
43 #include <basegfx/polygon/b2dpolygon.hxx>
44 #include <drawinglayer/attribute/fillgradientattribute.hxx>
45 
46 //////////////////////////////////////////////////////////////////////////////
47 
48 namespace sdr
49 {
50 	namespace contact
51 	{
52 		ViewObjectContact& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
53 		{
54 			return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact, *this));
55 		}
56 
57 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPageDescriptor::createViewIndependentPrimitive2DSequence() const
58 		{
59 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
60 			drawinglayer::attribute::SdrFillAttribute aFill;
61             const SdrPageProperties* pCorrectProperties = GetMasterPageDescriptor().getCorrectSdrPageProperties();
62 
63             if(pCorrectProperties)
64             {
65                 // create page fill attributes when correct properties were identified
66                 aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(pCorrectProperties->GetItemSet());
67             }
68 
69 			if(!aFill.isDefault())
70 			{
71                 // direct model data is the page size, get and use it
72 				const SdrPage& rOwnerPage = GetMasterPageDescriptor().GetOwnerPage();
73 				const basegfx::B2DRange aInnerRange(
74 					rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
75 					rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(),
76                     rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
77 				const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
78 				const basegfx::B2DHomMatrix aEmptyTransform;
79                 const drawinglayer::primitive2d::Primitive2DReference xReference(
80 					drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
81 						basegfx::B2DPolyPolygon(aInnerPolgon),
82 						aEmptyTransform,
83 						aFill,
84 						drawinglayer::attribute::FillGradientAttribute()));
85 
86                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
87 			}
88 
89 			return xRetval;
90 		}
91 
92 		// basic constructor
93 		ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor& rDescriptor)
94 		:	ViewContact(),
95 			mrMasterPageDescriptor(rDescriptor)
96 		{
97 		}
98 
99 		// The destructor.
100 		ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
101 		{
102 		}
103 
104 		sal_uInt32 ViewContactOfMasterPageDescriptor::GetObjectCount() const
105 		{
106 			return GetMasterPageDescriptor().GetUsedPage().GetObjCount();
107 		}
108 
109 		ViewContact& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex) const
110 		{
111 			return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex)->GetViewContact();
112 		}
113 
114 		ViewContact* ViewContactOfMasterPageDescriptor::GetParentContact() const
115 		{
116 			return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
117 		}
118 	} // end of namespace contact
119 } // end of namespace sdr
120 
121 //////////////////////////////////////////////////////////////////////////////
122 // eof
123