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 <svx/sdr/contact/viewcontactofsdrcircobj.hxx>
22 #include <svx/svdocirc.hxx>
23 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
25 #include <svl/itemset.hxx>
26 #include <svx/sxciaitm.hxx>
27 #include <basegfx/matrix/b2dhommatrixtools.hxx>
29 //////////////////////////////////////////////////////////////////////////////
35 ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj
& rCircObj
)
36 : ViewContactOfSdrRectObj(rCircObj
)
40 ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
44 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
46 const SfxItemSet
& rItemSet
= GetCircObj().GetMergedItemSet();
47 const drawinglayer::attribute::SdrLineFillShadowTextAttribute
aAttribute(
48 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
50 GetCircObj().getText(0),
53 // take unrotated snap rect (direct model data) for position and size
54 Rectangle aRectangle
= GetCircObj().GetGeoRect();
55 // Hack for calc, transform position of object according
56 // to current zoom so as objects relative position to grid
58 aRectangle
+= GetRectObj().GetGridOffset();
59 const basegfx::B2DRange
aObjectRange(
60 aRectangle
.Left(), aRectangle
.Top(),
61 aRectangle
.Right(), aRectangle
.Bottom() );
62 const GeoStat
& rGeoStat(GetCircObj().GetGeoStat());
65 const basegfx::B2DHomMatrix
aObjectMatrix(
66 basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
67 aObjectRange
.getWidth(), aObjectRange
.getHeight(),
68 rGeoStat
.nShearWink
? tan((36000 - rGeoStat
.nShearWink
) * F_PI18000
) : 0.0,
69 rGeoStat
.nDrehWink
? (36000 - rGeoStat
.nDrehWink
) * F_PI18000
: 0.0,
70 aObjectRange
.getMinX(), aObjectRange
.getMinY()));
72 // create primitive data
73 const sal_uInt16
nIdentifier(GetCircObj().GetObjIdentifier());
75 // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
76 // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
78 if(OBJ_CIRC
== nIdentifier
)
80 const drawinglayer::primitive2d::Primitive2DReference
xReference(
81 new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
85 return drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
89 const sal_Int32
nNewStart(((SdrCircStartAngleItem
&)rItemSet
.Get(SDRATTR_CIRCSTARTANGLE
)).GetValue());
90 const sal_Int32
nNewEnd(((SdrCircEndAngleItem
&)rItemSet
.Get(SDRATTR_CIRCENDANGLE
)).GetValue());
91 const double fStart(((36000 - nNewEnd
) % 36000) * F_PI18000
);
92 const double fEnd(((36000 - nNewStart
) % 36000) * F_PI18000
);
93 const bool bCloseSegment(OBJ_CARC
!= nIdentifier
);
94 const bool bCloseUsingCenter(OBJ_SECT
== nIdentifier
);
96 const drawinglayer::primitive2d::Primitive2DReference
xReference(
97 new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
105 return drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
108 } // end of namespace contact
109 } // end of namespace sdr
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */