1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sdr/contact/viewcontactofmasterpagedescriptor.hxx>
21 #include <svx/sdr/contact/viewobjectcontact.hxx>
22 #include <svx/svdpage.hxx>
23 #include <svx/svdobj.hxx>
24 #include <sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
25 #include <sdr/primitive2d/sdrattributecreator.hxx>
26 #include <basegfx/polygon/b2dpolygontools.hxx>
27 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
28 #include <drawinglayer/attribute/sdrfillattribute.hxx>
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <drawinglayer/attribute/fillgradientattribute.hxx>
33 namespace sdr::contact
35 ViewObjectContact
& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact
& rObjectContact
)
37 return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact
, *this));
40 void ViewContactOfMasterPageDescriptor::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
42 drawinglayer::attribute::SdrFillAttribute aFill
;
43 const SdrPageProperties
* pCorrectProperties
= GetMasterPageDescriptor().getCorrectSdrPageProperties();
45 if(pCorrectProperties
)
47 // create page fill attributes when correct properties were identified
48 aFill
= drawinglayer::primitive2d::createNewSdrFillAttribute(pCorrectProperties
->GetItemSet());
51 if(!aFill
.isDefault())
53 // direct model data is the page size, get and use it
54 const SdrPage
& rOwnerPage
= GetMasterPageDescriptor().GetOwnerPage();
55 const basegfx::B2DRange
aInnerRange(
56 rOwnerPage
.GetLeftBorder(), rOwnerPage
.GetUpperBorder(),
57 rOwnerPage
.GetWidth() - rOwnerPage
.GetRightBorder(),
58 rOwnerPage
.GetHeight() - rOwnerPage
.GetLowerBorder());
59 const basegfx::B2DRange
aOuterRange(
60 0, 0, rOwnerPage
.GetWidth(), rOwnerPage
.GetHeight());
61 // ??? somehow only the master page's bit is used
62 bool const isFullSize(GetMasterPageDescriptor().GetUsedPage().IsBackgroundFullSize());
63 const basegfx::B2DPolygon
aFillPolygon(
64 basegfx::utils::createPolygonFromRect(isFullSize
? aOuterRange
: aInnerRange
));
65 const drawinglayer::primitive2d::Primitive2DReference
xReference(
66 drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
67 basegfx::B2DPolyPolygon(aFillPolygon
),
69 drawinglayer::attribute::FillGradientAttribute()));
71 rVisitor
.visit(xReference
);
76 ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor
& rDescriptor
)
77 : mrMasterPageDescriptor(rDescriptor
)
82 ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
86 sal_uInt32
ViewContactOfMasterPageDescriptor::GetObjectCount() const
88 return GetMasterPageDescriptor().GetUsedPage().GetObjCount();
91 ViewContact
& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex
) const
93 return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex
)->GetViewContact();
96 ViewContact
* ViewContactOfMasterPageDescriptor::GetParentContact() const
98 return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
101 } // end of namespace
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */