1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
32 #include <svx/svdorect.hxx>
33 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
34 #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
35 #include <svl/itemset.hxx>
36 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
37 #include <basegfx/matrix/b2dhommatrixtools.hxx>
38 #include <svx/svdmodel.hxx>
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 namespace sdr
43 {
44 	namespace contact
45 	{
46 		ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
47 		:	ViewContactOfTextObj(rRectObj)
48 		{
49 		}
50 
51 		ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
52 		{
53 		}
54 
55 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
56 		{
57 			const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
58 			const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
59 				drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
60                     rItemSet,
61                     GetRectObj().getText(0)));
62 
63 			// take unrotated snap rect (direct model data) for position and size
64 			const Rectangle& rRectangle = GetRectObj().GetGeoRect();
65 			const ::basegfx::B2DRange aObjectRange(
66 				rRectangle.Left(), rRectangle.Top(),
67 				rRectangle.Right(), rRectangle.Bottom());
68 			const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
69 
70 			// fill object matrix
71 			basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
72 				aObjectRange.getWidth(), aObjectRange.getHeight(),
73 				rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
74 				rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
75 				aObjectRange.getMinX(), aObjectRange.getMinY()));
76 
77 			// calculate corner radius
78 			sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
79 			double fCornerRadiusX;
80 			double fCornerRadiusY;
81 			drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
82 
83             // #i105856# use knowledge about pickthrough from the model
84             const bool bPickThroughTransparentTextFrames(
85                 GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
86 
87             // create primitive. Always create primitives to allow the decomposition of
88 			// SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
89 			const drawinglayer::primitive2d::Primitive2DReference xReference(
90                 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
91 					aObjectMatrix,
92                     aAttribute,
93                     fCornerRadiusX,
94                     fCornerRadiusY,
95                     // #i105856# use fill for HitTest when TextFrame and not PickThrough
96                     GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
97 
98             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
99 		}
100 	} // end of namespace contact
101 } // end of namespace sdr
102 
103 //////////////////////////////////////////////////////////////////////////////
104 // eof
105