1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsPageObjectViewContact.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_sd.hxx"
33 #include "view/SlsPageObjectViewContact.hxx"
35 #include "model/SlsPageDescriptor.hxx"
36 #include "controller/SlsPageObjectFactory.hxx"
38 #include <svx/svdopage.hxx>
39 #include <tools/debug.hxx>
41 #include <basegfx/polygon/b2dpolygontools.hxx>
42 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
44 using namespace ::sdr::contact
;
46 namespace sd
{ namespace slidesorter
{ namespace view
{
49 PageObjectViewContact::PageObjectViewContact (
51 const model::SharedPageDescriptor
& rpDescriptor
)
52 : ViewContactOfPageObj (rPageObj
),
53 mbInDestructor(false),
54 mpDescriptor(rpDescriptor
)
58 PageObjectViewContact::~PageObjectViewContact (void)
60 // remember that this instance is in destruction
61 mbInDestructor
= true;
67 PageObjectViewContact::CreateObjectSpecificViewObjectContact(
68 ObjectContact
& rObjectContact
)
70 OSL_ASSERT(mpDescriptor
.get()!=NULL
);
72 ViewObjectContact
* pResult
73 = mpDescriptor
->GetPageObjectFactory().CreateViewObjectContact (
76 DBG_ASSERT (pResult
!=NULL
,
77 "PageObjectViewContact::CreateObjectSpecificViewObjectContact() was not able to create object.");
81 const SdrPage
* PageObjectViewContact::GetPage (void) const
83 // when this instance itself is in destruction, do no longer
84 // provide the referenced page to VOC childs of this OC. This
85 // happens e.g. in destructor which destroys all child-VOCs which
86 // may in their implementation still reference their VC from
87 // their own destructor
89 return GetReferencedPage();
94 void PageObjectViewContact::ActionChanged (void)
96 ViewContactOfPageObj::ActionChanged();
99 Rectangle
PageObjectViewContact::GetPageObjectBoundingBox (void) const
101 // use model data directly here
102 OSL_ASSERT(mpDescriptor
.get()!=NULL
);
103 Rectangle
aRetval(GetPageObject().GetLastBoundRect());
104 const SvBorder
aPageDescriptorBorder(mpDescriptor
->GetModelBorder());
106 aRetval
.Left() -= aPageDescriptorBorder
.Left();
107 aRetval
.Top() -= aPageDescriptorBorder
.Top();
108 aRetval
.Right() += aPageDescriptorBorder
.Right();
109 aRetval
.Bottom() += aPageDescriptorBorder
.Bottom();
114 SdrPageObj
& PageObjectViewContact::GetPageObject (void) const
116 return ViewContactOfPageObj::GetPageObj();
119 drawinglayer::primitive2d::Primitive2DSequence
PageObjectViewContact::createViewIndependentPrimitive2DSequence() const
121 // ceate graphical visualisation data. Since this is the view-independent version which should not be used,
122 // create a replacement graphic visualisation here. Use GetLastBoundRect to access the model data directly
123 // which is aOutRect for SdrPageObj.
124 OSL_ASSERT(mpDescriptor
.get()!=NULL
);
125 Rectangle
aModelRectangle(GetPageObj().GetLastBoundRect());
126 const SvBorder
aBorder(mpDescriptor
->GetModelBorder());
128 aModelRectangle
.Left() -= aBorder
.Left();
129 aModelRectangle
.Right() += aBorder
.Right();
130 aModelRectangle
.Top() -= aBorder
.Top();
131 aModelRectangle
.Bottom() += aBorder
.Bottom();
133 const basegfx::B2DRange
aModelRange(aModelRectangle
.Left(), aModelRectangle
.Top(), aModelRectangle
.Right(), aModelRectangle
.Bottom());
134 const basegfx::B2DPolygon
aOutline(basegfx::tools::createPolygonFromRect(aModelRange
));
135 const basegfx::BColor
aYellow(1.0, 1.0, 0.0);
136 const drawinglayer::primitive2d::Primitive2DReference
xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline
, aYellow
));
138 return drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
141 } } } // end of namespace ::sd::slidesorter::view