Update ooo320-m1
[ooovba.git] / svx / source / sdr / contact / viewcontactofsdrrectobj.cxx
blob9c7810ea46a49797b52696bec7f712a71caf1e79
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewcontactofsdrrectobj.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
36 #include <svx/svdorect.hxx>
37 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38 #include <svx/sdr/attribute/sdrallattribute.hxx>
39 #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
40 #include <svtools/itemset.hxx>
41 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 namespace sdr
47 namespace contact
49 ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
50 : ViewContactOfTextObj(rRectObj)
54 ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
58 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
60 drawinglayer::primitive2d::Primitive2DSequence xRetval;
61 const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
62 SdrText* pSdrText = GetRectObj().getText(0);
64 if(pSdrText)
66 drawinglayer::attribute::SdrLineFillShadowTextAttribute* pAttribute = drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(rItemSet, *pSdrText);
68 if(pAttribute)
70 if(pAttribute->isVisible())
72 // take unrotated snap rect (direct model data) for position and size
73 const Rectangle& rRectangle = GetRectObj().GetGeoRect();
74 const ::basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
75 const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
76 ::basegfx::B2DHomMatrix aObjectMatrix;
78 // fill object matrix
79 if(!::basegfx::fTools::equalZero(aObjectRange.getWidth()))
81 aObjectMatrix.set(0, 0, aObjectRange.getWidth());
84 if(!::basegfx::fTools::equalZero(aObjectRange.getHeight()))
86 aObjectMatrix.set(1, 1, aObjectRange.getHeight());
89 if(rGeoStat.nShearWink)
91 aObjectMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000));
94 if(rGeoStat.nDrehWink)
96 aObjectMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000);
99 aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY());
101 // calculate corner radius
102 sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
103 double fCornerRadiusX;
104 double fCornerRadiusY;
105 drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
107 // create primitive
108 const drawinglayer::primitive2d::Primitive2DReference xReference(
109 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
110 aObjectMatrix,
111 *pAttribute,
112 fCornerRadiusX,
113 fCornerRadiusY,
114 GetRectObj().IsTextFrame()));
116 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
119 delete pAttribute;
122 if(!xRetval.hasElements())
124 // #i99123#
125 // Object is invisible. Create a fallback primitive for HitTest
126 basegfx::B2DHomMatrix aObjectMatrix;
127 basegfx::B2DPolyPolygon aObjectPolyPolygon;
128 GetRectObj().TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
129 const drawinglayer::primitive2d::Primitive2DReference xReference(
130 drawinglayer::primitive2d::createFallbackHitTestPrimitive(aObjectMatrix));
131 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
135 return xRetval;
137 } // end of namespace contact
138 } // end of namespace sdr
140 //////////////////////////////////////////////////////////////////////////////
141 // eof