1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewcontactofsdrcircobj.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewcontactofsdrcircobj.hxx>
36 #include <svx/svdocirc.hxx>
37 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38 #include <svx/sdr/attribute/sdrallattribute.hxx>
39 #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
40 #include <svtools/itemset.hxx>
41 #include <svx/sxciaitm.hxx>
43 //////////////////////////////////////////////////////////////////////////////
49 ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj
& rCircObj
)
50 : ViewContactOfSdrRectObj(rCircObj
)
54 ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
58 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
60 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
61 const SfxItemSet
& rItemSet
= GetCircObj().GetMergedItemSet();
62 SdrText
* pSdrText
= GetCircObj().getText(0);
66 drawinglayer::attribute::SdrLineFillShadowTextAttribute
* pAttribute
= drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(rItemSet
, *pSdrText
);
70 if(pAttribute
->isVisible())
72 // take unrotated snap rect (direct model data) for position and size
73 const Rectangle
& rRectangle
= GetCircObj().GetGeoRect();
74 const ::basegfx::B2DRange
aObjectRange(rRectangle
.Left(), rRectangle
.Top(), rRectangle
.Right(), rRectangle
.Bottom());
75 const GeoStat
& rGeoStat(GetCircObj().GetGeoStat());
76 ::basegfx::B2DHomMatrix aObjectMatrix
;
79 if(!::basegfx::fTools::equalZero(aObjectRange
.getWidth()))
81 aObjectMatrix
.set(0, 0, aObjectRange
.getWidth());
84 if(!::basegfx::fTools::equalZero(aObjectRange
.getHeight()))
86 aObjectMatrix
.set(1, 1, aObjectRange
.getHeight());
89 if(rGeoStat
.nShearWink
)
91 aObjectMatrix
.shearX(tan((36000 - rGeoStat
.nShearWink
) * F_PI18000
));
94 if(rGeoStat
.nDrehWink
)
96 aObjectMatrix
.rotate((36000 - rGeoStat
.nDrehWink
) * F_PI18000
);
99 aObjectMatrix
.translate(aObjectRange
.getMinX(), aObjectRange
.getMinY());
101 // create primitive data
102 const sal_uInt16
nIdentifier(GetCircObj().GetObjIdentifier());
104 if(OBJ_CIRC
== nIdentifier
)
106 const drawinglayer::primitive2d::Primitive2DReference
xReference(new drawinglayer::primitive2d::SdrEllipsePrimitive2D(aObjectMatrix
, *pAttribute
));
107 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
111 const sal_Int32
nNewStart(((SdrCircStartAngleItem
&)rItemSet
.Get(SDRATTR_CIRCSTARTANGLE
)).GetValue());
112 const sal_Int32
nNewEnd(((SdrCircEndAngleItem
&)rItemSet
.Get(SDRATTR_CIRCENDANGLE
)).GetValue());
113 const double fStart(((36000 - nNewEnd
) % 36000) * F_PI18000
);
114 const double fEnd(((36000 - nNewStart
) % 36000) * F_PI18000
);
115 const bool bCloseSegment(OBJ_CARC
!= nIdentifier
);
116 const bool bCloseUsingCenter(OBJ_SECT
== nIdentifier
);
117 const drawinglayer::primitive2d::Primitive2DReference
xReference(new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(aObjectMatrix
, *pAttribute
, fStart
, fEnd
, bCloseSegment
, bCloseUsingCenter
));
118 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
128 } // end of namespace contact
129 } // end of namespace sdr
131 //////////////////////////////////////////////////////////////////////////////