xref: /AOO41X/main/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
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     {
42         ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
43         :   ViewContactOfTextObj(rRectObj)
44         {
45         }
46 
47         ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
48         {
49         }
50 
51         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 
59             // take unrotated snap rect (direct model data) for position and size
60             const Rectangle& rRectangle = GetRectObj().GetGeoRect();
61             const ::basegfx::B2DRange aObjectRange(
62                 rRectangle.Left(), rRectangle.Top(),
63                 rRectangle.Right(), rRectangle.Bottom());
64             const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
65 
66             // fill object matrix
67             basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
68                 aObjectRange.getWidth(), aObjectRange.getHeight(),
69                 rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
70                 rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
71                 aObjectRange.getMinX(), aObjectRange.getMinY()));
72 
73             // calculate corner radius
74             sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
75             double fCornerRadiusX;
76             double fCornerRadiusY;
77             drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
78 
79             // #i105856# use knowledge about pickthrough from the model
80             const bool bPickThroughTransparentTextFrames(
81                 GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
82 
83             // create primitive. Always create primitives to allow the decomposition of
84             // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
85             const drawinglayer::primitive2d::Primitive2DReference xReference(
86                 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
87                     aObjectMatrix,
88                     aAttribute,
89                     fCornerRadiusX,
90                     fCornerRadiusY,
91                     // #i105856# use fill for HitTest when TextFrame and not PickThrough
92                     GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
93 
94             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
95         }
96     } // end of namespace contact
97 } // end of namespace sdr
98 
99 //////////////////////////////////////////////////////////////////////////////
100 // eof
101