1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/viewcontactofsdrcircobj.hxx>
22 #include <svx/svdocirc.hxx>
23 #include <svx/sdangitm.hxx>
24 #include <sdr/primitive2d/sdrattributecreator.hxx>
25 #include <sdr/primitive2d/sdrellipseprimitive2d.hxx>
26 #include <svl/itemset.hxx>
27 #include <basegfx/matrix/b2dhommatrixtools.hxx>
28 #include <vcl/canvastools.hxx>
31 namespace sdr::contact
33 ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj
& rCircObj
)
34 : ViewContactOfSdrRectObj(rCircObj
)
38 ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
42 void ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
44 const SfxItemSet
& rItemSet
= GetCircObj().GetMergedItemSet();
45 const drawinglayer::attribute::SdrLineFillEffectsTextAttribute
aAttribute(
46 drawinglayer::primitive2d::createNewSdrLineFillEffectsTextAttribute(
48 GetCircObj().getText(0),
51 // take unrotated snap rect (direct model data) for position and size
52 const basegfx::B2DRange aObjectRange
= vcl::unotools::b2DRectangleFromRectangle(GetCircObj().GetGeoRect());
53 const GeoStat
& rGeoStat(GetCircObj().GetGeoStat());
56 const basegfx::B2DHomMatrix
aObjectMatrix(
57 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 // create primitive data
64 const SdrObjKind
nIdentifier(GetCircObj().GetObjIdentifier());
66 // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
67 // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
69 if(SdrObjKind::CircleOrEllipse
== nIdentifier
)
71 const drawinglayer::primitive2d::Primitive2DReference
xReference(
72 new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
76 rVisitor
.visit(xReference
);
80 const auto nNewStart(rItemSet
.Get(SDRATTR_CIRCSTARTANGLE
).GetValue());
81 const auto nNewEnd(rItemSet
.Get(SDRATTR_CIRCENDANGLE
).GetValue());
82 const double fStart(toRadians((36000_deg100
- nNewEnd
) % 36000_deg100
));
83 const double fEnd(toRadians((36000_deg100
- nNewStart
) % 36000_deg100
));
84 const bool bCloseSegment(SdrObjKind::CircleArc
!= nIdentifier
);
85 const bool bCloseUsingCenter(SdrObjKind::CircleSection
== nIdentifier
);
87 const drawinglayer::primitive2d::Primitive2DReference
xReference(
88 new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
96 rVisitor
.visit(xReference
);
100 } // end of namespace
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */