1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/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 <svx/sxmtaitm.hxx>
29 #include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
30 #include <svx/sxmtpitm.hxx>
32 //////////////////////////////////////////////////////////////////////////////
38 ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj
& rMeasureObj
)
39 : ViewContactOfTextObj(rMeasureObj
)
43 ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
47 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
49 const SfxItemSet
& rItemSet
= GetMeasureObj().GetMergedItemSet();
50 const drawinglayer::attribute::SdrLineShadowTextAttribute
aAttribute(
51 drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
53 GetMeasureObj().getText(0)));
55 // take properties which are the model data.
56 const ::basegfx::B2DPoint
aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
57 const ::basegfx::B2DPoint
aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
58 const double fDistance(((SdrMeasureLineDistItem
&)rItemSet
.Get(SDRATTR_MEASURELINEDIST
)).GetValue());
59 const double fUpperDistance(((SdrMeasureHelplineOverhangItem
&)rItemSet
.Get(SDRATTR_MEASUREHELPLINEOVERHANG
)).GetValue());
60 const double fLowerDistance(((SdrMeasureHelplineDistItem
&)rItemSet
.Get(SDRATTR_MEASUREHELPLINEDIST
)).GetValue());
61 const double fLeftDelta(((SdrMeasureHelpline1LenItem
&)rItemSet
.Get(SDRATTR_MEASUREHELPLINE1LEN
)).GetValue());
62 const double fRightDelta(((SdrMeasureHelpline2LenItem
&)rItemSet
.Get(SDRATTR_MEASUREHELPLINE2LEN
)).GetValue());
63 const bool bBelow(((SdrMeasureBelowRefEdgeItem
&)rItemSet
.Get(SDRATTR_MEASUREBELOWREFEDGE
)).GetValue());
64 const bool bTextRotation(((SdrMeasureTextRota90Item
&)rItemSet
.Get(SDRATTR_MEASURETEXTROTA90
)).GetValue());
65 const bool bTextAutoAngle(((SdrMeasureTextAutoAngleItem
&)rItemSet
.Get(SDRATTR_MEASURETEXTAUTOANGLE
)).GetValue());
66 drawinglayer::primitive2d::MeasureTextPosition
aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC
);
67 drawinglayer::primitive2d::MeasureTextPosition
aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC
);
69 switch(((SdrMeasureTextHPosItem
&)rItemSet
.Get(SDRATTR_MEASURETEXTHPOS
)).GetValue())
71 case SDRMEASURE_TEXTLEFTOUTSIDE
:
73 aMTPHor
= drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE
;
76 case SDRMEASURE_TEXTINSIDE
:
78 aMTPHor
= drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED
;
81 case SDRMEASURE_TEXTRIGHTOUTSIDE
:
83 aMTPHor
= drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE
;
86 default : // SDRMEASURE_TEXTHAUTO
92 switch(((SdrMeasureTextVPosItem
&)rItemSet
.Get(SDRATTR_MEASURETEXTVPOS
)).GetValue())
94 case SDRMEASURE_ABOVE
:
96 aMTPVer
= drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE
;
99 case SDRMEASURETEXT_BREAKEDLINE
:
100 case SDRMEASURETEXT_VERTICALCENTERED
:
102 aMTPVer
= drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED
;
105 case SDRMEASURE_BELOW
:
107 aMTPVer
= drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE
;
110 default : // SDRMEASURE_TEXTVAUTO
116 // create primitive with the model data. Always create primitives to allow the
117 // decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
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 bTextRotation
, bTextAutoAngle
));
127 return drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
129 } // end of namespace contact
130 } // end of namespace sdr
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */