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 	{
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)52 		ViewObjectContact& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
53 		{
54 			return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact, *this));
55 		}
56 
createViewIndependentPrimitive2DSequence() const57 		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 drawinglayer::primitive2d::Primitive2DReference xReference(
79 					drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
80 						basegfx::B2DPolyPolygon(aInnerPolgon),
81 						aFill,
82 						drawinglayer::attribute::FillGradientAttribute()));
83 
84                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
85 			}
86 
87 			return xRetval;
88 		}
89 
90 		// basic constructor
ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor & rDescriptor)91 		ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor& rDescriptor)
92 		:	ViewContact(),
93 			mrMasterPageDescriptor(rDescriptor)
94 		{
95 		}
96 
97 		// The destructor.
~ViewContactOfMasterPageDescriptor()98 		ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
99 		{
100 		}
101 
GetObjectCount() const102 		sal_uInt32 ViewContactOfMasterPageDescriptor::GetObjectCount() const
103 		{
104 			return GetMasterPageDescriptor().GetUsedPage().GetObjCount();
105 		}
106 
GetViewContact(sal_uInt32 nIndex) const107 		ViewContact& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex) const
108 		{
109 			return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex)->GetViewContact();
110 		}
111 
GetParentContact() const112 		ViewContact* ViewContactOfMasterPageDescriptor::GetParentContact() const
113 		{
114 			return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
115 		}
116 	} // end of namespace contact
117 } // end of namespace sdr
118 
119 //////////////////////////////////////////////////////////////////////////////
120 // eof
121