Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <sdr/contact/viewcontactofsdrcircobj.hxx>
22 : #include <svx/svdocirc.hxx>
23 : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 : #include <sdr/primitive2d/sdrellipseprimitive2d.hxx>
25 : #include <svl/itemset.hxx>
26 : #include <svx/sxciaitm.hxx>
27 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
28 :
29 :
30 :
31 : namespace sdr
32 : {
33 : namespace contact
34 : {
35 116 : ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj)
36 116 : : ViewContactOfSdrRectObj(rCircObj)
37 : {
38 116 : }
39 :
40 232 : ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
41 : {
42 232 : }
43 :
44 326 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
45 : {
46 326 : const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet();
47 : const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
48 : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
49 : rItemSet,
50 652 : GetCircObj().getText(0),
51 652 : false));
52 :
53 : // take unrotated snap rect (direct model data) for position and size
54 326 : Rectangle aRectangle = GetCircObj().GetGeoRect();
55 : // Hack for calc, transform position of object according
56 : // to current zoom so as objects relative position to grid
57 : // appears stable
58 326 : aRectangle += GetRectObj().GetGridOffset();
59 : const basegfx::B2DRange aObjectRange(
60 652 : aRectangle.Left(), aRectangle.Top(),
61 978 : aRectangle.Right(), aRectangle.Bottom() );
62 326 : const GeoStat& rGeoStat(GetCircObj().GetGeoStat());
63 :
64 : // fill object matrix
65 : const basegfx::B2DHomMatrix aObjectMatrix(
66 : basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
67 : aObjectRange.getWidth(), aObjectRange.getHeight(),
68 0 : rGeoStat.nShearAngle ? tan((36000 - rGeoStat.nShearAngle) * F_PI18000) : 0.0,
69 0 : rGeoStat.nRotationAngle ? (36000 - rGeoStat.nRotationAngle) * F_PI18000 : 0.0,
70 652 : aObjectRange.getMinX(), aObjectRange.getMinY()));
71 :
72 : // create primitive data
73 326 : const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier());
74 :
75 : // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
76 : // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
77 : // and/or BoundRect
78 326 : if(OBJ_CIRC == nIdentifier)
79 : {
80 : const drawinglayer::primitive2d::Primitive2DReference xReference(
81 : new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
82 : aObjectMatrix,
83 254 : aAttribute));
84 :
85 254 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
86 : }
87 : else
88 : {
89 72 : const sal_Int32 nNewStart(static_cast<const SdrAngleItem&>(rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue());
90 72 : const sal_Int32 nNewEnd(static_cast<const SdrAngleItem&>(rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue());
91 72 : const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000);
92 72 : const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000);
93 72 : const bool bCloseSegment(OBJ_CARC != nIdentifier);
94 72 : const bool bCloseUsingCenter(OBJ_SECT == nIdentifier);
95 :
96 : const drawinglayer::primitive2d::Primitive2DReference xReference(
97 : new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
98 : aObjectMatrix,
99 : aAttribute,
100 : fStart,
101 : fEnd,
102 : bCloseSegment,
103 72 : bCloseUsingCenter));
104 :
105 72 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
106 326 : }
107 : }
108 : } // end of namespace contact
109 435 : } // end of namespace sdr
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|