1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 #include <svx/sdr/contact/viewcontactofsdrcircobj.hxx> 28 #include <svx/svdocirc.hxx> 29 #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 30 #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx> 31 #include <svl/itemset.hxx> 32 #include <svx/sxciaitm.hxx> 33 #include <basegfx/matrix/b2dhommatrixtools.hxx> 34 35 ////////////////////////////////////////////////////////////////////////////// 36 37 namespace sdr 38 { 39 namespace contact 40 { 41 ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj) 42 : ViewContactOfSdrRectObj(rCircObj) 43 { 44 } 45 46 ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj() 47 { 48 } 49 50 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const 51 { 52 const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet(); 53 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( 54 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( 55 rItemSet, 56 GetCircObj().getText(0))); 57 58 // take unrotated snap rect (direct model data) for position and size 59 const Rectangle& rRectangle = GetCircObj().GetGeoRect(); 60 const basegfx::B2DRange aObjectRange( 61 rRectangle.Left(), rRectangle.Top(), 62 rRectangle.Right(), rRectangle.Bottom()); 63 const GeoStat& rGeoStat(GetCircObj().GetGeoStat()); 64 65 // fill object matrix 66 const basegfx::B2DHomMatrix aObjectMatrix( 67 basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 68 aObjectRange.getWidth(), aObjectRange.getHeight(), 69 rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, 70 rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, 71 aObjectRange.getMinX(), aObjectRange.getMinY())); 72 73 // create primitive data 74 const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier()); 75 76 // always create primitives to allow the decomposition of SdrEllipsePrimitive2D 77 // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest 78 // and/or BoundRect 79 if(OBJ_CIRC == nIdentifier) 80 { 81 const drawinglayer::primitive2d::Primitive2DReference xReference( 82 new drawinglayer::primitive2d::SdrEllipsePrimitive2D( 83 aObjectMatrix, 84 aAttribute)); 85 86 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 87 } 88 else 89 { 90 const sal_Int32 nNewStart(((SdrCircStartAngleItem&)rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue()); 91 const sal_Int32 nNewEnd(((SdrCircEndAngleItem&)rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue()); 92 const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000); 93 const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000); 94 const bool bCloseSegment(OBJ_CARC != nIdentifier); 95 const bool bCloseUsingCenter(OBJ_SECT == nIdentifier); 96 97 const drawinglayer::primitive2d::Primitive2DReference xReference( 98 new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D( 99 aObjectMatrix, 100 aAttribute, 101 fStart, 102 fEnd, 103 bCloseSegment, 104 bCloseUsingCenter)); 105 106 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 107 } 108 } 109 } // end of namespace contact 110 } // end of namespace sdr 111 112 ////////////////////////////////////////////////////////////////////////////// 113 // eof 114