cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrrectobj.cxx
blob46cdd21ad0c2d9e62bc3de8fe14e1424de12d735
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 <sdr/contact/viewcontactofsdrrectobj.hxx>
21 #include <svx/svdorect.hxx>
22 #include <sdr/primitive2d/sdrattributecreator.hxx>
23 #include <sdr/primitive2d/sdrrectangleprimitive2d.hxx>
24 #include <svl/itemset.hxx>
25 #include <basegfx/matrix/b2dhommatrixtools.hxx>
26 #include <svx/svdmodel.hxx>
27 #include <vcl/canvastools.hxx>
28 #include <svx/sdmetitm.hxx>
30 namespace sdr::contact {
32 ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
33 : ViewContactOfTextObj(rRectObj)
37 ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
41 void ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const
43 const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
44 const drawinglayer::attribute::SdrLineFillEffectsTextAttribute aAttribute(
45 drawinglayer::primitive2d::createNewSdrLineFillEffectsTextAttribute(
46 rItemSet,
47 GetRectObj().getText(0),
48 false));
50 // take unrotated snap rect (direct model data) for position and size
51 const tools::Rectangle aRectangle(GetRectObj().GetGeoRect());
52 const ::basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aRectangle);
54 const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
56 // fill object matrix
57 basegfx::B2DHomMatrix aObjectMatrix(basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
58 aObjectRange.getWidth(), aObjectRange.getHeight(),
59 -rGeoStat.mfTanShearAngle,
60 rGeoStat.m_nRotationAngle ? toRadians(36000_deg100 - rGeoStat.m_nRotationAngle) : 0.0,
61 aObjectRange.getMinX(), aObjectRange.getMinY()));
63 // calculate corner radius
64 sal_uInt32 nCornerRadius(rItemSet.Get(SDRATTR_CORNER_RADIUS).GetValue());
65 double fCornerRadiusX;
66 double fCornerRadiusY;
67 drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
69 // #i105856# use knowledge about pickthrough from the model
70 const bool bPickThroughTransparentTextFrames(GetRectObj().getSdrModelFromSdrObject().IsPickThroughTransparentTextFrames());
72 // create primitive. Always create primitives to allow the decomposition of
73 // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
74 const drawinglayer::primitive2d::Primitive2DReference xReference(
75 new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
76 aObjectMatrix,
77 aAttribute,
78 fCornerRadiusX,
79 fCornerRadiusY,
80 // #i105856# use fill for HitTest when TextFrame and not PickThrough
81 GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
83 rVisitor.visit(xReference);
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */