1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
28 #include <svx/svdorect.hxx>
29 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
30 #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
31 #include <svl/itemset.hxx>
32 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
33 #include <basegfx/matrix/b2dhommatrixtools.hxx>
34 #include <svx/svdmodel.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace sdr
39 {
40 	namespace contact
41 	{
ViewContactOfSdrRectObj(SdrRectObj & rRectObj)42 		ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
43 		:	ViewContactOfTextObj(rRectObj)
44 		{
45 		}
46 
~ViewContactOfSdrRectObj()47 		ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
48 		{
49 		}
50 
createViewIndependentPrimitive2DSequence() const51 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
52 		{
53 			const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
54 			const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
55 				drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
56                     rItemSet,
57                     GetRectObj().getText(0),
58                     false));
59 
60 			// take unrotated snap rect (direct model data) for position and size
61 			const Rectangle& rRectangle = GetRectObj().GetGeoRect();
62 			const ::basegfx::B2DRange aObjectRange(
63 				rRectangle.Left(), rRectangle.Top(),
64 				rRectangle.Right(), rRectangle.Bottom());
65 			const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
66 
67 			// fill object matrix
68 			basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
69 				aObjectRange.getWidth(), aObjectRange.getHeight(),
70 				rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
71 				rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
72 				aObjectRange.getMinX(), aObjectRange.getMinY()));
73 
74 			// calculate corner radius
75 			sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
76 			double fCornerRadiusX;
77 			double fCornerRadiusY;
78 			drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
79 
80             // #i105856# use knowledge about pickthrough from the model
81             const bool bPickThroughTransparentTextFrames(
82                 GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
83 
84             // create primitive. Always create primitives to allow the decomposition of
85 			// SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
86 			const drawinglayer::primitive2d::Primitive2DReference xReference(
87                 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
88 					aObjectMatrix,
89                     aAttribute,
90                     fCornerRadiusX,
91                     fCornerRadiusY,
92                     // #i105856# use fill for HitTest when TextFrame and not PickThrough
93                     GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
94 
95             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
96 		}
97 	} // end of namespace contact
98 } // end of namespace sdr
99 
100 //////////////////////////////////////////////////////////////////////////////
101 // eof
102