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 <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
25 : #include <svl/itemset.hxx>
26 : #include <svx/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 1858 : ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
37 1858 : : ViewContactOfTextObj(rRectObj)
38 : {
39 1858 : }
40 :
41 3576 : ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
42 : {
43 3576 : }
44 :
45 152 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
46 : {
47 152 : const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
48 : const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
49 : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
50 : rItemSet,
51 152 : GetRectObj().getText(0)));
52 :
53 : // take unrotated snap rect (direct model data) for position and size
54 152 : Rectangle rRectangle = GetRectObj().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 152 : rRectangle += GetRectObj().GetGridOffset();
59 : const ::basegfx::B2DRange aObjectRange(
60 304 : rRectangle.Left(), rRectangle.Top(),
61 456 : rRectangle.Right(), rRectangle.Bottom() );
62 :
63 152 : const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
64 :
65 : // fill object matrix
66 : basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
67 : aObjectRange.getWidth(), aObjectRange.getHeight(),
68 0 : rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
69 : rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
70 152 : aObjectRange.getMinX(), aObjectRange.getMinY()));
71 :
72 : // calculate corner radius
73 152 : sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
74 : double fCornerRadiusX;
75 : double fCornerRadiusY;
76 152 : drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
77 :
78 : // #i105856# use knowledge about pickthrough from the model
79 : const bool bPickThroughTransparentTextFrames(
80 152 : GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
81 :
82 : // create primitive. Always create primitives to allow the decomposition of
83 : // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
84 : const drawinglayer::primitive2d::Primitive2DReference xReference(
85 : new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
86 : aObjectMatrix,
87 : aAttribute,
88 : fCornerRadiusX,
89 : fCornerRadiusY,
90 : // #i105856# use fill for HitTest when TextFrame and not PickThrough
91 152 : GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
92 :
93 152 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
94 : }
95 : } // end of namespace contact
96 : } // end of namespace sdr
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|