1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
28 #include <svx/svdomeas.hxx>
29 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
30 #include <svl/itemset.hxx>
31 #include <svx/sxmbritm.hxx>
32 #include <svx/sxmlhitm.hxx>
33 #include <svx/sxmtritm.hxx>
34 #include <svx/sxmtaitm.hxx>
35 #include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
36 #include <svx/sxmtpitm.hxx>
37 
38 //////////////////////////////////////////////////////////////////////////////
39 
40 namespace sdr
41 {
42 	namespace contact
43 	{
ViewContactOfSdrMeasureObj(SdrMeasureObj & rMeasureObj)44 		ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
45 		:	ViewContactOfTextObj(rMeasureObj)
46 		{
47 		}
48 
~ViewContactOfSdrMeasureObj()49 		ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
50 		{
51 		}
52 
createViewIndependentPrimitive2DSequence() const53 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
54 		{
55 			const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
56 			const drawinglayer::attribute::SdrLineShadowTextAttribute aAttribute(
57 				drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
58 					rItemSet,
59 					GetMeasureObj().getText(0)));
60 
61 			// take properties which are the model data.
62 			const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
63 			const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
64 			const double fDistance(((SdrMeasureLineDistItem&)rItemSet.Get(SDRATTR_MEASURELINEDIST)).GetValue());
65 			const double fUpperDistance(((SdrMeasureHelplineOverhangItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue());
66 			const double fLowerDistance(((SdrMeasureHelplineDistItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST)).GetValue());
67 			const double fLeftDelta(((SdrMeasureHelpline1LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN)).GetValue());
68 			const double fRightDelta(((SdrMeasureHelpline2LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN)).GetValue());
69 			const bool bBelow(((SdrMeasureBelowRefEdgeItem&)rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE)).GetValue());
70 			const bool bTextRotation(((SdrMeasureTextRota90Item&)rItemSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue());
71 			const bool bTextAutoAngle(((SdrMeasureTextAutoAngleItem&)rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE)).GetValue());
72 			drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
73 			drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
74 
75 			switch(((SdrMeasureTextHPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTHPOS)).GetValue())
76 			{
77 				case SDRMEASURE_TEXTLEFTOUTSIDE :
78 				{
79 					aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
80 					break;
81 				}
82 				case SDRMEASURE_TEXTINSIDE :
83 				{
84 					aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
85 					break;
86 				}
87 				case SDRMEASURE_TEXTRIGHTOUTSIDE :
88 				{
89 					aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
90 					break;
91 				}
92 				default : // SDRMEASURE_TEXTHAUTO
93 				{
94 					break;
95 				}
96 			}
97 
98 			switch(((SdrMeasureTextVPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTVPOS)).GetValue())
99 			{
100 				case SDRMEASURE_ABOVE :
101 				{
102 					aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
103 					break;
104 				}
105 				case SDRMEASURETEXT_BREAKEDLINE :
106 				case SDRMEASURETEXT_VERTICALCENTERED :
107 				{
108 					aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
109 					break;
110 				}
111 				case SDRMEASURE_BELOW :
112 				{
113 					aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
114 					break;
115 				}
116 				default : // SDRMEASURE_TEXTVAUTO
117 				{
118 					break;
119 				}
120 			}
121 
122 			// create primitive with the model data. Always create primitives to allow the
123 			// decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
124 			// and/or BoundRect
125 			const drawinglayer::primitive2d::Primitive2DReference xReference(
126 				new drawinglayer::primitive2d::SdrMeasurePrimitive2D(
127 					aAttribute, aStart, aEnd,
128 					aMTPHor, aMTPVer, fDistance,
129 					fUpperDistance, fLowerDistance,
130 					fLeftDelta, fRightDelta, bBelow,
131 					bTextRotation, bTextAutoAngle));
132 
133 			return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
134 		}
135 	} // end of namespace contact
136 } // end of namespace sdr
137 
138 //////////////////////////////////////////////////////////////////////////////
139 // eof
140