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/viewcontactofsdrrectobj.hxx>
22 : #include <svx/svdorect.hxx>
23 : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 : #include <sdr/primitive2d/sdrrectangleprimitive2d.hxx>
25 : #include <svl/itemset.hxx>
26 : #include <sdr/primitive2d/sdrprimitivetools.hxx>
27 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
28 : #include <svx/svdmodel.hxx>
29 :
30 :
31 :
32 : namespace sdr
33 : {
34 : namespace contact
35 : {
36 31444 : ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
37 31444 : : ViewContactOfTextObj(rRectObj)
38 : {
39 31444 : }
40 :
41 60884 : ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
42 : {
43 60884 : }
44 :
45 28646 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
46 : {
47 28646 : const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
48 : const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
49 : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
50 : rItemSet,
51 57292 : GetRectObj().getText(0),
52 57292 : false));
53 :
54 : // take unrotated snap rect (direct model data) for position and size
55 28646 : Rectangle rRectangle = GetRectObj().GetGeoRect();
56 : // Hack for calc, transform position of object according
57 : // to current zoom so as objects relative position to grid
58 : // appears stable
59 28646 : rRectangle += GetRectObj().GetGridOffset();
60 : const ::basegfx::B2DRange aObjectRange(
61 57292 : rRectangle.Left(), rRectangle.Top(),
62 85938 : rRectangle.Right(), rRectangle.Bottom() );
63 :
64 28646 : const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
65 :
66 : // fill object matrix
67 : basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
68 : aObjectRange.getWidth(), aObjectRange.getHeight(),
69 0 : rGeoStat.nShearAngle ? tan((36000 - rGeoStat.nShearAngle) * F_PI18000) : 0.0,
70 336 : rGeoStat.nRotationAngle ? (36000 - rGeoStat.nRotationAngle) * F_PI18000 : 0.0,
71 57628 : aObjectRange.getMinX(), aObjectRange.getMinY()));
72 :
73 : // calculate corner radius
74 28646 : sal_uInt32 nCornerRadius((static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
75 : double fCornerRadiusX;
76 : double fCornerRadiusY;
77 28646 : drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
78 :
79 : // #i105856# use knowledge about pickthrough from the model
80 : const bool bPickThroughTransparentTextFrames(
81 28646 : GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
82 :
83 : // create primitive. Always create primitives to allow the decomposition of
84 : // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
85 : const drawinglayer::primitive2d::Primitive2DReference xReference(
86 : new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
87 : aObjectMatrix,
88 : aAttribute,
89 : fCornerRadiusX,
90 : fCornerRadiusY,
91 : // #i105856# use fill for HitTest when TextFrame and not PickThrough
92 57292 : GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
93 :
94 57292 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
95 : }
96 : } // end of namespace contact
97 651 : } // end of namespace sdr
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|