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 <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>
28 :
29 :
30 :
31 : namespace sdr
32 : {
33 : namespace contact
34 : {
35 0 : ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj)
36 0 : : ViewContactOfSdrRectObj(rCircObj)
37 : {
38 0 : }
39 :
40 0 : ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
41 : {
42 0 : }
43 :
44 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
45 : {
46 0 : const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet();
47 : const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
48 : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
49 : rItemSet,
50 0 : GetCircObj().getText(0),
51 0 : false));
52 :
53 : // take unrotated snap rect (direct model data) for position and size
54 0 : 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 0 : aRectangle += GetRectObj().GetGridOffset();
59 : const basegfx::B2DRange aObjectRange(
60 0 : aRectangle.Left(), aRectangle.Top(),
61 0 : aRectangle.Right(), aRectangle.Bottom() );
62 0 : 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.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
69 0 : rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
70 0 : aObjectRange.getMinX(), aObjectRange.getMinY()));
71 :
72 : // create primitive data
73 0 : 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 0 : if(OBJ_CIRC == nIdentifier)
79 : {
80 : const drawinglayer::primitive2d::Primitive2DReference xReference(
81 : new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
82 : aObjectMatrix,
83 0 : aAttribute));
84 :
85 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
86 : }
87 : else
88 : {
89 0 : const sal_Int32 nNewStart(((SdrCircStartAngleItem&)rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue());
90 0 : const sal_Int32 nNewEnd(((SdrCircEndAngleItem&)rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue());
91 0 : const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000);
92 0 : const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000);
93 0 : const bool bCloseSegment(OBJ_CARC != nIdentifier);
94 0 : 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 0 : bCloseUsingCenter));
104 :
105 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
106 0 : }
107 : }
108 : } // end of namespace contact
109 : } // end of namespace sdr
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|