1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <svx/sdr/contact/viewcontactofsdrcircobj.hxx> 32 #include <svx/svdocirc.hxx> 33 #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 34 #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx> 35 #include <svl/itemset.hxx> 36 #include <svx/sxciaitm.hxx> 37 #include <basegfx/matrix/b2dhommatrixtools.hxx> 38 39 ////////////////////////////////////////////////////////////////////////////// 40 41 namespace sdr 42 { 43 namespace contact 44 { 45 ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj) 46 : ViewContactOfSdrRectObj(rCircObj) 47 { 48 } 49 50 ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj() 51 { 52 } 53 54 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const 55 { 56 const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet(); 57 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( 58 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( 59 rItemSet, 60 GetCircObj().getText(0))); 61 62 // take unrotated snap rect (direct model data) for position and size 63 const Rectangle& rRectangle = GetCircObj().GetGeoRect(); 64 const basegfx::B2DRange aObjectRange( 65 rRectangle.Left(), rRectangle.Top(), 66 rRectangle.Right(), rRectangle.Bottom()); 67 const GeoStat& rGeoStat(GetCircObj().GetGeoStat()); 68 69 // fill object matrix 70 const basegfx::B2DHomMatrix aObjectMatrix( 71 basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 72 aObjectRange.getWidth(), aObjectRange.getHeight(), 73 rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, 74 rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, 75 aObjectRange.getMinX(), aObjectRange.getMinY())); 76 77 // create primitive data 78 const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier()); 79 80 // always create primitives to allow the decomposition of SdrEllipsePrimitive2D 81 // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest 82 // and/or BoundRect 83 if(OBJ_CIRC == nIdentifier) 84 { 85 const drawinglayer::primitive2d::Primitive2DReference xReference( 86 new drawinglayer::primitive2d::SdrEllipsePrimitive2D( 87 aObjectMatrix, 88 aAttribute)); 89 90 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 91 } 92 else 93 { 94 const sal_Int32 nNewStart(((SdrCircStartAngleItem&)rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue()); 95 const sal_Int32 nNewEnd(((SdrCircEndAngleItem&)rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue()); 96 const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000); 97 const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000); 98 const bool bCloseSegment(OBJ_CARC != nIdentifier); 99 const bool bCloseUsingCenter(OBJ_SECT == nIdentifier); 100 101 const drawinglayer::primitive2d::Primitive2DReference xReference( 102 new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D( 103 aObjectMatrix, 104 aAttribute, 105 fStart, 106 fEnd, 107 bCloseSegment, 108 bCloseUsingCenter)); 109 110 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 111 } 112 } 113 } // end of namespace contact 114 } // end of namespace sdr 115 116 ////////////////////////////////////////////////////////////////////////////// 117 // eof 118