Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrrectobj.cxx
blob13742d358c17c953d2e014f25200a982fe646480
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 .
20 #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
21 #include <svx/svdorect.hxx>
22 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
23 #include <sdr/primitive2d/sdrrectangleprimitive2d.hxx>
24 #include <svl/itemset.hxx>
25 #include <sdr/primitive2d/sdrprimitivetools.hxx>
26 #include <basegfx/matrix/b2dhommatrixtools.hxx>
27 #include <svx/svdmodel.hxx>
29 namespace sdr { namespace contact {
31 ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
32 : ViewContactOfTextObj(rRectObj)
36 ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
40 drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
42 const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
43 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
44 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
45 rItemSet,
46 GetRectObj().getText(0),
47 false));
49 // take unrotated snap rect (direct model data) for position and size
50 tools::Rectangle rRectangle = GetRectObj().GetGeoRect();
51 // Hack for calc, transform position of object according
52 // to current zoom so as objects relative position to grid
53 // appears stable
54 rRectangle += GetRectObj().GetGridOffset();
55 const ::basegfx::B2DRange aObjectRange(
56 rRectangle.Left(), rRectangle.Top(),
57 rRectangle.Right(), rRectangle.Bottom() );
59 const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
61 // fill object matrix
62 basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
63 aObjectRange.getWidth(), aObjectRange.getHeight(),
64 rGeoStat.nShearAngle ? tan((36000 - rGeoStat.nShearAngle) * F_PI18000) : 0.0,
65 rGeoStat.nRotationAngle ? (36000 - rGeoStat.nRotationAngle) * F_PI18000 : 0.0,
66 aObjectRange.getMinX(), aObjectRange.getMinY()));
68 // calculate corner radius
69 sal_uInt32 nCornerRadius((static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
70 double fCornerRadiusX;
71 double fCornerRadiusY;
72 drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
74 // #i105856# use knowledge about pickthrough from the model
75 const bool bPickThroughTransparentTextFrames(
76 GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
78 // create primitive. Always create primitives to allow the decomposition of
79 // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
80 const drawinglayer::primitive2d::Primitive2DReference xReference(
81 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
82 aObjectMatrix,
83 aAttribute,
84 fCornerRadiusX,
85 fCornerRadiusY,
86 // #i105856# use fill for HitTest when TextFrame and not PickThrough
87 GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
89 return drawinglayer::primitive2d::Primitive2DContainer{ xReference };
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */