cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrmeasureobj.cxx
blobeb04efd715c826062075e1bbc1c365f3082eda4b
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 <sdr/contact/viewcontactofsdrmeasureobj.hxx>
22 #include <svx/svdomeas.hxx>
23 #include <sdr/primitive2d/sdrattributecreator.hxx>
24 #include <svl/itemset.hxx>
25 #include <svx/sdmetitm.hxx>
26 #include <svx/sxmbritm.hxx>
27 #include <svx/sxmtritm.hxx>
28 #include <sxmtaitm.hxx>
29 #include <sdr/primitive2d/sdrmeasureprimitive2d.hxx>
30 #include <svx/sxmtpitm.hxx>
33 namespace sdr::contact
35 ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
36 : ViewContactOfTextObj(rMeasureObj)
40 ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
44 void ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const
46 const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
47 const drawinglayer::attribute::SdrLineEffectsTextAttribute aAttribute(
48 drawinglayer::primitive2d::createNewSdrLineEffectsTextAttribute(
49 rItemSet,
50 GetMeasureObj().getText(0)));
52 // take properties which are the model data.
53 const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
54 const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
55 const double fDistance(rItemSet.Get(SDRATTR_MEASURELINEDIST).GetValue());
56 const double fUpperDistance(rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG).GetValue());
57 const double fLowerDistance(rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST).GetValue());
58 const double fLeftDelta(rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN).GetValue());
59 const double fRightDelta(rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN).GetValue());
60 const bool bBelow(rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE).GetValue());
61 const bool bTextRotation(rItemSet.Get(SDRATTR_MEASURETEXTROTA90).GetValue());
62 const bool bTextAutoAngle(rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE).GetValue());
63 drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
64 drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
66 switch(rItemSet.Get(SDRATTR_MEASURETEXTHPOS).GetValue())
68 case css::drawing::MeasureTextHorzPos::MeasureTextHorzPos_LEFTOUTSIDE:
70 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
71 break;
73 case css::drawing::MeasureTextHorzPos::MeasureTextHorzPos_INSIDE:
75 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
76 break;
78 case css::drawing::MeasureTextHorzPos::MeasureTextHorzPos_RIGHTOUTSIDE:
80 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
81 break;
83 default: // css::drawing::MeasureTextHorzPos::MeasureTextHorzPos_AUTO
85 break;
89 switch(rItemSet.Get(SDRATTR_MEASURETEXTVPOS).GetValue())
91 case css::drawing::MeasureTextVertPos_EAST:
93 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
94 break;
96 case css::drawing::MeasureTextVertPos_CENTERED:
98 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
99 break;
101 case css::drawing::MeasureTextVertPos_WEST:
103 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
104 break;
106 default : // css::drawing::MeasureTextVertPos_AUTO
108 break;
112 // create primitive with the model data. Always create primitives to allow the
113 // decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
114 // and/or BoundRect
115 const drawinglayer::primitive2d::Primitive2DReference xReference(
116 new drawinglayer::primitive2d::SdrMeasurePrimitive2D(
117 aAttribute, aStart, aEnd,
118 aMTPHor, aMTPVer, fDistance,
119 fUpperDistance, fLowerDistance,
120 fLeftDelta, fRightDelta, bBelow,
121 bTextRotation, bTextAutoAngle));
123 rVisitor.visit(xReference);
125 } // end of namespace
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */