bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrrectobj.cxx
blobb4088772039f1befb4b58c6e3d3d81dd4c08fe5e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
22 #include <svx/svdorect.hxx>
23 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
25 #include <svl/itemset.hxx>
26 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
27 #include <basegfx/matrix/b2dhommatrixtools.hxx>
28 #include <svx/svdmodel.hxx>
30 //////////////////////////////////////////////////////////////////////////////
32 namespace sdr
34 namespace contact
36 ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
37 : ViewContactOfTextObj(rRectObj)
41 ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
45 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
47 const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
48 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
49 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
50 rItemSet,
51 GetRectObj().getText(0),
52 false));
54 // take unrotated snap rect (direct model data) for position and size
55 Rectangle rRectangle = GetRectObj().GetGeoRect();
56 // Hack for calc, transform position of object according
57 // to current zoom so as objects relative position to grid
58 // appears stable
59 rRectangle += GetRectObj().GetGridOffset();
60 const ::basegfx::B2DRange aObjectRange(
61 rRectangle.Left(), rRectangle.Top(),
62 rRectangle.Right(), rRectangle.Bottom() );
64 const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
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()));
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);
79 // #i105856# use knowledge about pickthrough from the model
80 const bool bPickThroughTransparentTextFrames(
81 GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
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));
94 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
96 } // end of namespace contact
97 } // end of namespace sdr
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */