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/viewcontactofsdrmeasureobj.hxx>
22 : #include <svx/svdomeas.hxx>
23 : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 : #include <svl/itemset.hxx>
25 : #include <svx/sxmbritm.hxx>
26 : #include <svx/sxmlhitm.hxx>
27 : #include <svx/sxmtritm.hxx>
28 : #include <sxmtaitm.hxx>
29 : #include <sdr/primitive2d/sdrmeasureprimitive2d.hxx>
30 : #include <svx/sxmtpitm.hxx>
31 :
32 :
33 :
34 : namespace sdr
35 : {
36 : namespace contact
37 : {
38 2 : ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
39 2 : : ViewContactOfTextObj(rMeasureObj)
40 : {
41 2 : }
42 :
43 4 : ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
44 : {
45 4 : }
46 :
47 2 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
48 : {
49 2 : const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
50 : const drawinglayer::attribute::SdrLineShadowTextAttribute aAttribute(
51 : drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
52 : rItemSet,
53 2 : GetMeasureObj().getText(0)));
54 :
55 : // take properties which are the model data.
56 4 : const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
57 4 : const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
58 2 : const double fDistance(static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_MEASURELINEDIST)).GetValue());
59 2 : const double fUpperDistance(static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue());
60 2 : const double fLowerDistance(static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST)).GetValue());
61 2 : const double fLeftDelta(static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN)).GetValue());
62 2 : const double fRightDelta(static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN)).GetValue());
63 2 : const bool bBelow(static_cast<const SdrMeasureBelowRefEdgeItem&>(rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE)).GetValue());
64 2 : const bool bTextRotation(static_cast<const SdrMeasureTextRota90Item&>(rItemSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue());
65 2 : const bool bTextAutoAngle(static_cast<const SdrMeasureTextAutoAngleItem&>(rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE)).GetValue());
66 2 : drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
67 2 : drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
68 :
69 2 : switch(static_cast<const SdrMeasureTextHPosItem&>(rItemSet.Get(SDRATTR_MEASURETEXTHPOS)).GetValue())
70 : {
71 : case SDRMEASURE_TEXTLEFTOUTSIDE :
72 : {
73 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
74 0 : break;
75 : }
76 : case SDRMEASURE_TEXTINSIDE :
77 : {
78 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
79 0 : break;
80 : }
81 : case SDRMEASURE_TEXTRIGHTOUTSIDE :
82 : {
83 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
84 0 : break;
85 : }
86 : default : // SDRMEASURE_TEXTHAUTO
87 : {
88 2 : break;
89 : }
90 : }
91 :
92 2 : switch(static_cast<const SdrMeasureTextVPosItem&>(rItemSet.Get(SDRATTR_MEASURETEXTVPOS)).GetValue())
93 : {
94 : case SDRMEASURE_ABOVE :
95 : {
96 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
97 0 : break;
98 : }
99 : case SDRMEASURETEXT_BREAKEDLINE :
100 : case SDRMEASURETEXT_VERTICALCENTERED :
101 : {
102 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
103 0 : break;
104 : }
105 : case SDRMEASURE_BELOW :
106 : {
107 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
108 0 : break;
109 : }
110 : default : // SDRMEASURE_TEXTVAUTO
111 : {
112 2 : break;
113 : }
114 : }
115 :
116 : // create primitive with the model data. Always create primitives to allow the
117 : // decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
118 : // and/or BoundRect
119 : const drawinglayer::primitive2d::Primitive2DReference xReference(
120 : new drawinglayer::primitive2d::SdrMeasurePrimitive2D(
121 : aAttribute, aStart, aEnd,
122 : aMTPHor, aMTPVer, fDistance,
123 : fUpperDistance, fLowerDistance,
124 : fLeftDelta, fRightDelta, bBelow,
125 2 : bTextRotation, bTextAutoAngle));
126 :
127 4 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
128 : }
129 : } // end of namespace contact
130 651 : } // end of namespace sdr
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|