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